journald-native 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f07112165499f340a1a856b2f5eb952ab67512c3
4
- data.tar.gz: 084815636014a24e2cc2500853b15b2aba90f713
3
+ metadata.gz: 7074ca755c39b71b382f63b7befe21e0dc7e18ec
4
+ data.tar.gz: 585840efef3b5ee2b50f97e830ecf21df0ec811b
5
5
  SHA512:
6
- metadata.gz: 846465074f639a88087fa6a7b164a7c177c49877fa7b0115392917fd5f229c0860450a7632cacda6c835518bba766fbc98260fa2c45a7f2cef403853283c02c5
7
- data.tar.gz: 27e0430e831019f557f68e715a9bf60b9902c108617a103481a3251d514d66f3acc79620cc8dcb1a06be94c3003e83cd4fd3c405ff6a36ba8f5c80ad692809ef
6
+ metadata.gz: e19cdf3224ca356c47319c5dd6897cc364a8f4d87a1f9c7d9319a31be19be2b4298cbc1b869024e8f0846f48115947dc296afb9d809de368bc16ae18434cdb2a
7
+ data.tar.gz: 214828671762b128ae1875fffce35e8a3db25217db47e6bca8d4a127750c3ad1ca55d9c8999c623829dce3a8b998ffe70d2fe62395b3dedf75b3479d3487532a
data/README.md CHANGED
@@ -44,9 +44,9 @@ Journald::Native.print Journald::LOG_WARNING, "message"
44
44
  Journald::Native.perror "message"
45
45
  ```
46
46
 
47
- It is not recommended to use ```print``` and ```perror``` as you may lose ```'\0'``` byte in your string due to
48
- C zero-terminated string format (all zero bytes in the middle will be removed) On the contrary ```send``` uses
49
- binary buffers and does not have this shortcoming.
47
+ It is not recommended to use ```print``` and ```perror``` as you may get exception if your string contains
48
+ ```'\0'``` byte due to C zero-terminated string format. On the contrary ```send``` uses binary buffers and
49
+ does not have this shortcoming.
50
50
 
51
51
  ### License
52
52
 
@@ -17,34 +17,13 @@ inline auto r(Func f, Args... args) -> decltype(f(args...))
17
17
  return ruby_exception_wrapper::ruby_raisable_call(f, args...);
18
18
  }
19
19
 
20
- // Remove zeros from the string
21
- std::string create_safe_string(VALUE v_string)
22
- {
23
- /* convert to string */
24
- r(rb_string_value, &v_string);
25
-
26
- char* str = (char *)RSTRING_PTR(v_string);
27
- size_t len = (size_t)RSTRING_LEN(v_string);
28
-
29
- std::string safe_str;
30
- safe_str.reserve(len);
31
-
32
- for (size_t i = 0; i < len; i++) {
33
- if (str[i]) {
34
- safe_str += str[i];
35
- }
36
- }
37
-
38
- return safe_str;
39
- }
40
-
41
20
  /* methods */
42
21
  inline VALUE native_print(VALUE v_self, VALUE v_priority, VALUE v_message)
43
22
  {
44
- int priority = NUM2INT(v_priority);
45
- auto message = create_safe_string(v_message);
23
+ int priority = NUM2INT(v_priority);
24
+ std::string message = r(rb_string_value_cstr, &v_message);
46
25
 
47
- int result = sd_journal_print(priority, "%s", message.c_str());
26
+ int result = sd_journal_print(priority, "%s", message.c_str());
48
27
 
49
28
  return INT2NUM(result);
50
29
  }
@@ -67,9 +46,9 @@ inline VALUE native_send(int argc, VALUE* argv, VALUE v_self)
67
46
 
68
47
  inline VALUE native_perror(VALUE v_self, VALUE v_message)
69
48
  {
70
- auto message = create_safe_string(v_message);
49
+ std::string message = r(rb_string_value_cstr, &v_message);
71
50
 
72
- int result = sd_journal_perror(message.c_str());
51
+ int result = sd_journal_perror(message.c_str());
73
52
 
74
53
  return INT2NUM(result);
75
54
  }
@@ -1,5 +1,5 @@
1
1
  module Journald
2
2
  module Native
3
- VERSION = '1.0.5'
3
+ VERSION = '1.0.6'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: journald-native
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Smirnov