winevt_c 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: 3d57a1e5432029466922d8c4f3805be355d3e8cb9cca1aaa32a7ae5bb597ec6f
4
- data.tar.gz: 27a0b12c234cc124e0b9a172d70fdb24aa6c78a44dae07e6ca708d0ae4f8c3d6
3
+ metadata.gz: d2e44e576e569f125c6961bdf8f55e68c31deea1700fe19c5b6885060eabfd3e
4
+ data.tar.gz: 794d697c6ab3b8747e7bd0e8b37a001c1889a8e4a87021cb50d5828ee53c7add
5
5
  SHA512:
6
- metadata.gz: d536676a7bf61dc45272e7e39803259c553548018fb72228bcb72114827ba385adfebb3a3c1b28b11c1dafe336e145e9922599c3b246b28f9aad9b4627e5e50e
7
- data.tar.gz: 687a2123c881ce0e5140d2afd5f2e5c8c775698e450dc9672d0a48f1d91a3400e48e19de7c8dd6a77e7761d624429a02f2c90f589d715f5a7bbdc416c20cc08a
6
+ metadata.gz: 699187c2446d3f60b5853abb2174299127a4c96ba60fc0fee273023eec922111640d8ba3b54d2b3ca38a21e7f0daad92f56a533e8ab20279b58e004b32f2ca09
7
+ data.tar.gz: a3b330defbc50aad97adb11f7f7ecce1123ff3e06e1415dc0019f0b4fec4135ab19e01895937356ca544dc631a192959abdd777f6318ffa24c4df3af718fbcb5
data/README.md CHANGED
@@ -1,32 +1,32 @@
1
- # winevt_c
2
-
3
- [![Build status](https://ci.appveyor.com/api/projects/status/hr3phv8ihvgc68oj/branch/master?svg=true)](https://ci.appveyor.com/project/cosmo0920/winevt-c/branch/master)
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem 'winevt_c'
11
- ```
12
-
13
- And then execute:
14
-
15
- $ bundle
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install winevt_c
20
-
21
- ## Usage
22
-
23
- Usage examples are found in [example directory](example).
24
- ## Development
25
-
26
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
27
-
28
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
29
-
30
- ## Contributing
31
-
32
- Bug reports and pull requests are welcome on GitHub at https://github.com/cosmo0920/winevt_c.
1
+ # winevt_c
2
+
3
+ [![Build status](https://ci.appveyor.com/api/projects/status/hr3phv8ihvgc68oj/branch/master?svg=true)](https://ci.appveyor.com/project/cosmo0920/winevt-c/branch/master)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'winevt_c'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install winevt_c
20
+
21
+ ## Usage
22
+
23
+ Usage examples are found in [example directory](example).
24
+ ## Development
25
+
26
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
27
+
28
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
29
+
30
+ ## Contributing
31
+
32
+ Bug reports and pull requests are welcome on GitHub at https://github.com/cosmo0920/winevt_c.
data/ext/winevt/winevt.c CHANGED
@@ -32,7 +32,7 @@ static void subscribe_free(void *ptr);
32
32
  static void query_free(void *ptr);
33
33
  static void bookmark_free(void *ptr);
34
34
  static char* render_event(EVT_HANDLE handle, DWORD flags);
35
- static DWORD WINAPI SubscriptionCallback(EVT_SUBSCRIBE_NOTIFY_ACTION action, PVOID pContext, EVT_HANDLE hEvent);
35
+ static char* wstr_to_mbstr(UINT cp, const WCHAR *wstr, int clen);
36
36
 
37
37
  static const rb_data_type_t rb_winevt_channel_type = {
38
38
  "winevt/channel", {
@@ -128,7 +128,6 @@ rb_winevt_channel_each(VALUE self)
128
128
  DWORD bufferSize = 0;
129
129
  DWORD bufferUsed = 0;
130
130
  DWORD status = ERROR_SUCCESS;
131
- ULONG len;
132
131
 
133
132
  RETURN_ENUMERATOR(self, 0, 0);
134
133
 
@@ -166,9 +165,7 @@ rb_winevt_channel_each(VALUE self)
166
165
  }
167
166
  }
168
167
 
169
- len = WideCharToMultiByte(CP_UTF8, 0, buffer, -1, NULL, 0, NULL, NULL);
170
- if (!(result = malloc(len))) return "";
171
- WideCharToMultiByte(CP_UTF8, 0, buffer, -1, result, len, NULL, NULL);
168
+ result = wstr_to_mbstr(CP_UTF8, buffer, -1);
172
169
 
173
170
  rb_yield(rb_str_new2(result));
174
171
  }
@@ -176,6 +173,18 @@ rb_winevt_channel_each(VALUE self)
176
173
  return Qnil;
177
174
  }
178
175
 
176
+ static char *
177
+ wstr_to_mbstr(UINT cp, const WCHAR *wstr, int clen)
178
+ {
179
+ char *ptr;
180
+ int len = WideCharToMultiByte(cp, 0, wstr, clen, NULL, 0, NULL, NULL);
181
+ if (!(ptr = malloc(len))) return 0;
182
+ WideCharToMultiByte(cp, 0, wstr, clen, ptr, len, NULL, NULL);
183
+
184
+ return ptr;
185
+ }
186
+
187
+
179
188
  static void
180
189
  subscribe_free(void *ptr)
181
190
  {
@@ -568,7 +577,7 @@ static char* render_event(EVT_HANDLE handle, DWORD flags)
568
577
  ULONG bufferSize = 0;
569
578
  ULONG bufferSizeNeeded = 0;
570
579
  EVT_HANDLE event;
571
- ULONG len, status, count;
580
+ ULONG status, count;
572
581
  char* errBuf;
573
582
  char* result;
574
583
  LPTSTR msgBuf;
@@ -607,16 +616,15 @@ static char* render_event(EVT_HANDLE handle, DWORD flags)
607
616
  NULL, status,
608
617
  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
609
618
  &msgBuf, 0, NULL);
610
- len = WideCharToMultiByte(CP_UTF8, 0, msgBuf, -1, NULL, 0, NULL, NULL);
611
- if (!(result = malloc(len))) return "";
612
- WideCharToMultiByte(CP_UTF8, 0, msgBuf, -1, result, len, NULL, NULL);
619
+ result = wstr_to_mbstr(CP_ACP, msgBuf, -1);
613
620
 
614
621
  rb_raise(rb_eWinevtQueryError, "ErrorCode: %d\nError: %s\n", status, result);
615
622
  }
616
623
 
617
- len = WideCharToMultiByte(CP_UTF8, 0, buffer, -1, NULL, 0, NULL, NULL);
618
- if (!(result = malloc(len))) return "";
619
- WideCharToMultiByte(CP_UTF8, 0, buffer, -1, result, len, NULL, NULL);
624
+ result = wstr_to_mbstr(CP_UTF8, buffer, -1);
625
+
626
+ if (buffer)
627
+ free(buffer);
620
628
 
621
629
  return result;
622
630
  }
@@ -1,3 +1,3 @@
1
1
  module Winevt
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: winevt_c
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Hatake
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-11 00:00:00.000000000 Z
11
+ date: 2019-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler