winevt_c 0.6.1 → 0.7.0

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: b390dc340de45facd91c7de698c1d72f7f706e961f6beb776a748499886fa4c2
4
- data.tar.gz: cb6bb22241cb81551cbb84363e7c9bddb205f38fb6aa138da2c6c4489667044c
3
+ metadata.gz: a1e26f9f7aef69fdf599f08c4c309fd1a60e00178d0a4db7a24b76cde7376254
4
+ data.tar.gz: 20e705a60f389912acd1594eecd0ea1a79230de00e887b0033016ccf72d8383f
5
5
  SHA512:
6
- metadata.gz: b8e2666c0d51dcf9bfc114c1bd73b1f075a1702999d44e8dd318878d837b762a568aceffffadfc89f0ce33010629fb677f0edd040a312d32a5f35a20c6f3f0cc
7
- data.tar.gz: 6adec333c1e0998a712b149f470091ed24f441806b5454a05e80d937bca63de7346b806ddd1904835428344158e81108b12a1cc2aa628a595299ed243ce83abc
6
+ metadata.gz: ec1d0dfbf4c1ec66619a709e012c76ab5487944f1c2970520b09ed46d9f3689d8ab5dcfc4499e34aeb2cde111f571e652cbf6bf337c20c5b7d5d836ef602d4ab
7
+ data.tar.gz: '01842dfd20afb70a08a928baf7d38c1c3c3df79a7ffd9303275d25623520b1f3e81adfcfcd43a730e8e36cb6931933c48871bd72bb3a21b9bbc33bde91bda366'
data/.travis.yml ADDED
@@ -0,0 +1,15 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.4
4
+
5
+ services:
6
+ - docker
7
+
8
+ gemfile:
9
+ - Gemfile
10
+
11
+ before_install:
12
+ - gem update --system=2.7.8
13
+
14
+ script:
15
+ - bundle exec rake gem:native
data/Rakefile CHANGED
@@ -27,8 +27,8 @@ desc 'Build gems for Windows per rake-compiler-dock'
27
27
  task 'gem:native' do
28
28
  # See RUBY_CC_VERSION in https://github.com/rake-compiler/rake-compiler-dock/blob/master/Dockerfile.mri
29
29
  RakeCompilerDock.sh <<-EOS
30
- gem install bundler --no-doc && bundle --local
31
- bundle exec rake cross native gem RUBY_CC_VERSION=2.4.0:2.5.0:2.6.0
30
+ gem install bundler yard --no-doc && bundle
31
+ rake cross native gem RUBY_CC_VERSION=2.4.0:2.5.0:2.6.0
32
32
  EOS
33
33
  end
34
34
 
@@ -78,7 +78,7 @@ struct WinevtSubscribe
78
78
  EVT_HANDLE hEvents[SUBSCRIBE_ARRAY_SIZE];
79
79
  DWORD count;
80
80
  DWORD flags;
81
- BOOL tailing;
81
+ BOOL readExistingEvents;
82
82
  DWORD rateLimit;
83
83
  time_t lastTime;
84
84
  DWORD currentRate;
@@ -88,42 +88,43 @@ rb_winevt_subscribe_initialize(VALUE self)
88
88
  winevtSubscribe->lastTime = 0;
89
89
  winevtSubscribe->currentRate = 0;
90
90
  winevtSubscribe->renderAsXML = TRUE;
91
+ winevtSubscribe->readExistingEvents = TRUE;
91
92
 
92
93
  return Qnil;
93
94
  }
94
95
 
95
96
  /*
96
- * This method specifies whether tailing or not.
97
+ * This method specifies whether read existing events or not.
97
98
  *
98
- * @param rb_tailing_p [Boolean]
99
+ * @param rb_read_existing_events_p [Boolean]
99
100
  */
100
101
  static VALUE
101
- rb_winevt_subscribe_set_tail(VALUE self, VALUE rb_tailing_p)
102
+ rb_winevt_subscribe_set_read_existing_events(VALUE self, VALUE rb_read_existing_events_p)
102
103
  {
103
104
  struct WinevtSubscribe* winevtSubscribe;
104
105
 
105
106
  TypedData_Get_Struct(
106
107
  self, struct WinevtSubscribe, &rb_winevt_subscribe_type, winevtSubscribe);
107
108
 
108
- winevtSubscribe->tailing = RTEST(rb_tailing_p);
109
+ winevtSubscribe->readExistingEvents = RTEST(rb_read_existing_events_p);
109
110
 
110
111
  return Qnil;
111
112
  }
112
113
 
113
114
  /*
114
- * This method returns whether tailing or not.
115
+ * This method returns whether read existing events or not.
115
116
  *
116
117
  * @return [Boolean]
117
118
  */
118
119
  static VALUE
119
- rb_winevt_subscribe_tail_p(VALUE self)
120
+ rb_winevt_subscribe_read_existing_events_p(VALUE self)
120
121
  {
121
122
  struct WinevtSubscribe* winevtSubscribe;
122
123
 
123
124
  TypedData_Get_Struct(
124
125
  self, struct WinevtSubscribe, &rb_winevt_subscribe_type, winevtSubscribe);
125
126
 
126
- return winevtSubscribe->tailing ? Qtrue : Qfalse;
127
+ return winevtSubscribe->readExistingEvents ? Qtrue : Qfalse;
127
128
  }
128
129
 
129
130
  /*
@@ -194,19 +195,30 @@ rb_winevt_subscribe_subscribe(int argc, VALUE* argv, VALUE self)
194
195
 
195
196
  if (hBookmark) {
196
197
  flags |= EvtSubscribeStartAfterBookmark;
197
- } else if (winevtSubscribe->tailing) {
198
- flags |= EvtSubscribeToFutureEvents;
199
- } else {
198
+ } else if (winevtSubscribe->readExistingEvents) {
200
199
  flags |= EvtSubscribeStartAtOldestRecord;
200
+ } else {
201
+ flags |= EvtSubscribeToFutureEvents;
201
202
  }
202
203
 
203
204
  hSubscription =
204
205
  EvtSubscribe(NULL, hSignalEvent, path, query, hBookmark, NULL, NULL, flags);
205
206
  if (!hSubscription) {
207
+ if (hBookmark != NULL) {
208
+ EvtClose(hBookmark);
209
+ }
210
+ if (hSignalEvent != NULL) {
211
+ CloseHandle(hSignalEvent);
212
+ }
206
213
  status = GetLastError();
207
214
  raise_system_error(rb_eWinevtQueryError, status);
208
215
  }
209
216
 
217
+ if (winevtSubscribe->subscription != NULL) {
218
+ // should be disgarded the old event subscription handle.
219
+ EvtClose(winevtSubscribe->subscription);
220
+ }
221
+
210
222
  ALLOCV_END(wpathBuf);
211
223
  ALLOCV_END(wqueryBuf);
212
224
 
@@ -217,6 +229,12 @@ rb_winevt_subscribe_subscribe(int argc, VALUE* argv, VALUE self)
217
229
  } else {
218
230
  winevtSubscribe->bookmark = EvtCreateBookmark(NULL);
219
231
  if (winevtSubscribe->bookmark == NULL) {
232
+ if (hSubscription != NULL) {
233
+ EvtClose(hSubscription);
234
+ }
235
+ if (hSignalEvent != NULL) {
236
+ CloseHandle(hSignalEvent);
237
+ }
220
238
  status = GetLastError();
221
239
  raise_system_error(rb_eWinevtQueryError, status);
222
240
  }
@@ -517,8 +535,14 @@ Init_winevt_subscribe(VALUE rb_cEventLog)
517
535
  rb_define_method(rb_cSubscribe, "next", rb_winevt_subscribe_next, 0);
518
536
  rb_define_method(rb_cSubscribe, "each", rb_winevt_subscribe_each, 0);
519
537
  rb_define_method(rb_cSubscribe, "bookmark", rb_winevt_subscribe_get_bookmark, 0);
520
- rb_define_method(rb_cSubscribe, "tail?", rb_winevt_subscribe_tail_p, 0);
521
- rb_define_method(rb_cSubscribe, "tail=", rb_winevt_subscribe_set_tail, 1);
538
+ /*
539
+ * @since 0.7.0
540
+ */
541
+ rb_define_method(rb_cSubscribe, "read_existing_events?", rb_winevt_subscribe_read_existing_events_p, 0);
542
+ /*
543
+ * @since 0.7.0
544
+ */
545
+ rb_define_method(rb_cSubscribe, "read_existing_events=", rb_winevt_subscribe_set_read_existing_events, 1);
522
546
  rb_define_method(rb_cSubscribe, "rate_limit", rb_winevt_subscribe_get_rate_limit, 0);
523
547
  rb_define_method(rb_cSubscribe, "rate_limit=", rb_winevt_subscribe_set_rate_limit, 1);
524
548
  rb_define_method(
@@ -1,3 +1,3 @@
1
1
  module Winevt
2
- VERSION = "0.6.1"
2
+ VERSION = "0.7.0"
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.6.1
4
+ version: 0.7.0
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-10-21 00:00:00.000000000 Z
11
+ date: 2020-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -110,6 +110,7 @@ extra_rdoc_files: []
110
110
  files:
111
111
  - ".clang-format"
112
112
  - ".gitignore"
113
+ - ".travis.yml"
113
114
  - Gemfile
114
115
  - LICENSE.txt
115
116
  - README.md
@@ -155,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
156
  version: '0'
156
157
  requirements: []
157
158
  rubyforge_project:
158
- rubygems_version: 2.7.3
159
+ rubygems_version: 2.7.6.2
159
160
  signing_key:
160
161
  specification_version: 4
161
162
  summary: Windows Event Log API bindings from winevt.h.