winevt_c 0.1.0-x86-mingw32 → 0.1.1-x86-mingw32

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: 5cf95319c95243ca432d01b7a5b386603b3d1e100eb873f791e56e1e014cb49b
4
- data.tar.gz: 74e6d59960089642a685771ba71562f68424ee1836dd3641576cdad79fc37ab1
3
+ metadata.gz: 2b6b5aad981795315f2447d7a3059ea6b8aa36cf876e928eeb48f8ac07359fae
4
+ data.tar.gz: 74b530f1abc6a1dd7c5bf8d92589c440a36edbeebefc91867e9ced2043032830
5
5
  SHA512:
6
- metadata.gz: a1b809b0b7c612aed9b8e76c90e8d4d0ee326c79da950ba10a2c35f058fdaf88b22367dafdefac267023b02fed8ea97dc815d329c88fc95d25cb9ef006b45b9a
7
- data.tar.gz: cf97a89b5b0c42bde5b90fb3ed5faef71430ce56ad58987c3ed7b364ccfe96b545d95e38aaf7ae8916a4e39425d54846fedfa6de8c99b871e7b60f4ec1444cc5
6
+ metadata.gz: b164bd8437b99a30da71c6b9b30daf702dfee0bb661c217761dc29212af75b8abf5f21489d48460585d6d57cfc92443ca92e45a8e4713452a74418572080b7f7
7
+ data.tar.gz: '049978f7001c998f7bb4447ab7b677c916cc12dc0be5420da5f6c98b8620af016295049eb7e2ff11042f1fd923a7d1691d52de52dc9e62468c17fae875f961af'
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # winevt_c
2
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
+
3
5
  ## Installation
4
6
 
5
7
  Add this line to your application's Gemfile:
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
  }
Binary file
Binary file
Binary file
@@ -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: x86-mingw32
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