@@ -92,6 +92,19 @@ typedef struct YRX_BUFFER {
92
92
size_t length ;
93
93
} YRX_BUFFER ;
94
94
95
+ // Callback function passed to [`yrx_scanner_on_matching_rule`] or
96
+ // [`yrx_rules_iterate`].
97
+ //
98
+ // The callback receives a pointer to a rule, represented by a [`YRX_RULE`]
99
+ // structure. This pointer is guaranteed to be valid while the callback
100
+ // function is being executed, but it may be freed after the callback function
101
+ // returns, so you cannot use the pointer outside the callback.
102
+ //
103
+ // It also receives the `user_data` pointer that can point to arbitrary data
104
+ // owned by the user.
105
+ typedef void (* YRX_RULE_CALLBACK )(const struct YRX_RULE * rule ,
106
+ void * user_data );
107
+
95
108
// Represents a metadata value that contains raw bytes.
96
109
typedef struct YRX_METADATA_BYTES {
97
110
// Number of bytes.
@@ -160,20 +173,6 @@ typedef struct YRX_PATTERNS {
160
173
struct YRX_PATTERN * patterns ;
161
174
} YRX_PATTERNS ;
162
175
163
- // Callback function passed to the scanner via [`yrx_scanner_on_matching_rule`]
164
- // which receives notifications about matching rules.
165
- //
166
- // The callback receives a pointer to the matching rule, represented by a
167
- // [`YRX_RULE`] structure. This pointer is guaranteed to be valid while the
168
- // callback function is being executed, but it may be freed after the callback
169
- // function returns, so you cannot use the pointer outside the callback.
170
- //
171
- // It also receives the `user_data` pointer that was passed to the
172
- // [`yrx_scanner_on_matching_rule`] function, which can point to arbitrary
173
- // data owned by the user.
174
- typedef void (* YRX_ON_MATCHING_RULE )(const struct YRX_RULE * rule ,
175
- void * user_data );
176
-
177
176
// Compiles YARA source code and creates a [`YRX_RULES`] object that contains
178
177
// the compiled rules.
179
178
//
@@ -199,6 +198,17 @@ enum YRX_RESULT yrx_rules_deserialize(const uint8_t *data,
199
198
size_t len ,
200
199
struct YRX_RULES * * rules );
201
200
201
+ // Iterates over the compiled rules, calling the callback function for each
202
+ // rule.
203
+ //
204
+ // The `user_data` pointer can be used to provide additional context to your
205
+ // callback function.
206
+ //
207
+ // See [`YRX_RULE_CALLBACK`] for more details.
208
+ enum YRX_RESULT yrx_rules_iterate (struct YRX_RULES * rules ,
209
+ YRX_RULE_CALLBACK callback ,
210
+ void * user_data );
211
+
202
212
// Destroys a [`YRX_RULES`] object.
203
213
void yrx_rules_destroy (struct YRX_RULES * rules );
204
214
@@ -504,9 +514,9 @@ enum YRX_RESULT yrx_scanner_scan(struct YRX_SCANNER *scanner,
504
514
// callback function. If the callback is not set, the scanner doesn't notify
505
515
// about matching rules.
506
516
//
507
- // See [`YRX_ON_MATCHING_RULE `] for more details.
517
+ // See [`YRX_RULE_CALLBACK `] for more details.
508
518
enum YRX_RESULT yrx_scanner_on_matching_rule (struct YRX_SCANNER * scanner ,
509
- YRX_ON_MATCHING_RULE callback ,
519
+ YRX_RULE_CALLBACK callback ,
510
520
void * user_data );
511
521
512
522
// Specifies the output data structure for a module.
0 commit comments