9c312311 |
1 | /* This file is part of the Linux Trace Toolkit viewer |
852f16bb |
2 | * Copyright (C) 2003-2005 Michel Dagenais and Simon Bouvier-Zappa |
9c312311 |
3 | * |
4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License Version 2 as |
6 | * published by the Free Software Foundation; |
7 | * |
8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU General Public License |
14 | * along with this program; if not, write to the Free Software |
15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
16 | * MA 02111-1307, USA. |
17 | */ |
18 | |
7e7af7f2 |
19 | /*! \file lttv/lttv/filter.c |
20 | * \brief Defines the core filter of application |
21 | * |
22 | * consist in AND, OR and NOT nested expressions, forming a tree with |
23 | * simple relations as leaves. The simple relations test if a field |
24 | * in an event is equal, not equal, smaller, smaller or equal, larger, or |
25 | * larger or equal to a specified value. |
26 | * |
27 | * Fields specified in a simple expression can take following |
28 | * values |
29 | * |
da2e1bfb |
30 | * \verbatim |
31 | * LttvTracefileContext{} |
7e7af7f2 |
32 | * |->event\ |
33 | * | |->name (String, converted to GQuark) |
34 | * | |->category (String, not yet implemented) |
35 | * | |->time (LttTime) |
bbd9d557 |
36 | * | |->tsc (LttCycleCount --> uint64) |
7e7af7f2 |
37 | * | |->fields |
38 | * | |->"event name" |
39 | * | |->"field name" |
40 | * | |->"sub-field name" |
41 | * | |->... |
42 | * | |->"leaf-field name" (field type) |
43 | * |->tracefile |
44 | * | |->name (String, converted to GQuark) |
45 | * |->trace |
46 | * | |->name (String, converted to GQuark) |
47 | * |->state |
48 | * |->pid (uint64) |
49 | * |->ppid (uint64) |
50 | * |->creation_time (LttTime) |
51 | * |->insertion_time (LttTime) |
52 | * |->process_name (String, converted to GQuark) |
53 | * |->execution_mode (LttvExecutionMode) |
54 | * |->execution_submode (LttvExecutionSubmode) |
55 | * |->process_status (LttvProcessStatus) |
6e0d58d6 |
56 | * |->cpu (guint) |
da2e1bfb |
57 | * \endverbatim |
150f0d33 |
58 | */ |
59 | |
60 | /* |
bbd9d557 |
61 | * \todo |
150f0d33 |
62 | * - refine switch of expression in multiple uses functions |
be66ef34 |
63 | * - remove the idle expressions in the tree |
150f0d33 |
64 | */ |
65 | |
4e4d11b3 |
66 | #ifdef HAVE_CONFIG_H |
67 | #include <config.h> |
68 | #endif |
69 | |
72911c5d |
70 | //#define TEST |
be66ef34 |
71 | #ifdef TEST |
72 | #include <time.h> |
73 | #include <sys/time.h> |
74 | #endif |
75 | |
150f0d33 |
76 | #include <lttv/filter.h> |
327a4314 |
77 | #include <ltt/trace.h> |
348c6ba8 |
78 | #include <ltt/type.h> |
327a4314 |
79 | #include <stdlib.h> |
80 | #include <string.h> |
80f9611a |
81 | |
82 | /** |
56e29124 |
83 | * @fn LttvSimpleExpression* lttv_simple_expression_new() |
84 | * |
80f9611a |
85 | * Constructor for LttvSimpleExpression |
86 | * @return pointer to new LttvSimpleExpression |
87 | */ |
88 | LttvSimpleExpression* |
89 | lttv_simple_expression_new() { |
90 | |
91 | LttvSimpleExpression* se = g_new(LttvSimpleExpression,1); |
92 | |
93 | se->field = LTTV_FILTER_UNDEFINED; |
94 | se->op = NULL; |
95 | se->offset = 0; |
80f9611a |
96 | |
97 | return se; |
98 | } |
99 | |
0769c82f |
100 | /** |
7e7af7f2 |
101 | * @fn gboolean lttv_simple_expression_assign_field(GPtrArray*,LttvSimpleExpression*) |
56e29124 |
102 | * |
0769c82f |
103 | * Parse through filtering field hierarchy as specified |
104 | * by user. This function compares each value to |
105 | * predetermined quarks |
106 | * @param fp The field path list |
bb87caa7 |
107 | * @param se current simple expression |
0769c82f |
108 | * @return success/failure of operation |
109 | */ |
110 | gboolean |
9ab5ebd7 |
111 | lttv_simple_expression_assign_field(GPtrArray* fp, LttvSimpleExpression* se) { |
0769c82f |
112 | |
f4e9dd16 |
113 | GString* f = NULL; |
73050a5f |
114 | |
2b99ec10 |
115 | if(fp->len < 2) return FALSE; |
327a4314 |
116 | g_assert((f=g_ptr_array_remove_index(fp,0))); |
73050a5f |
117 | |
47aa6e58 |
118 | /* |
119 | * Parse through the specified |
120 | * hardcoded fields. |
121 | * |
122 | * Take note however that the |
123 | * 'event' subfields might change |
124 | * depending on values specified |
125 | * in core.xml file. Hence, if |
126 | * none of the subfields in the |
127 | * array match the hardcoded |
128 | * subfields, it will be considered |
129 | * as a dynamic field |
130 | */ |
80f9611a |
131 | if(!g_strcasecmp(f->str,"trace") ) { |
47aa6e58 |
132 | /* |
133 | * Possible values: |
134 | * trace.name |
135 | */ |
73050a5f |
136 | g_string_free(f,TRUE); |
137 | f=g_ptr_array_remove_index(fp,0); |
80f9611a |
138 | if(!g_strcasecmp(f->str,"name")) { |
389ba50e |
139 | se->field = LTTV_FILTER_TRACE_NAME; |
140 | } |
80f9611a |
141 | } else if(!g_strcasecmp(f->str,"traceset") ) { |
47aa6e58 |
142 | /* |
143 | * FIXME: not yet implemented ! |
144 | */ |
80f9611a |
145 | } else if(!g_strcasecmp(f->str,"tracefile") ) { |
47aa6e58 |
146 | /* |
147 | * Possible values: |
148 | * tracefile.name |
149 | */ |
73050a5f |
150 | g_string_free(f,TRUE); |
151 | f=g_ptr_array_remove_index(fp,0); |
80f9611a |
152 | if(!g_strcasecmp(f->str,"name")) { |
389ba50e |
153 | se->field = LTTV_FILTER_TRACEFILE_NAME; |
154 | } |
80f9611a |
155 | } else if(!g_strcasecmp(f->str,"state") ) { |
47aa6e58 |
156 | /* |
157 | * Possible values: |
158 | * state.pid |
159 | * state.ppid |
160 | * state.creation_time |
161 | * state.insertion_time |
162 | * state.process_name |
163 | * state.execution_mode |
164 | * state.execution_submode |
165 | * state.process_status |
166 | * state.cpu |
167 | */ |
73050a5f |
168 | g_string_free(f,TRUE); |
169 | f=g_ptr_array_remove_index(fp,0); |
80f9611a |
170 | if(!g_strcasecmp(f->str,"pid") ) { |
389ba50e |
171 | se->field = LTTV_FILTER_STATE_PID; |
172 | } |
80f9611a |
173 | else if(!g_strcasecmp(f->str,"ppid") ) { |
389ba50e |
174 | se->field = LTTV_FILTER_STATE_PPID; |
175 | } |
80f9611a |
176 | else if(!g_strcasecmp(f->str,"creation_time") ) { |
389ba50e |
177 | se->field = LTTV_FILTER_STATE_CT; |
178 | } |
80f9611a |
179 | else if(!g_strcasecmp(f->str,"insertion_time") ) { |
389ba50e |
180 | se->field = LTTV_FILTER_STATE_IT; |
181 | } |
80f9611a |
182 | else if(!g_strcasecmp(f->str,"process_name") ) { |
389ba50e |
183 | se->field = LTTV_FILTER_STATE_P_NAME; |
184 | } |
80f9611a |
185 | else if(!g_strcasecmp(f->str,"execution_mode") ) { |
389ba50e |
186 | se->field = LTTV_FILTER_STATE_EX_MODE; |
187 | } |
80f9611a |
188 | else if(!g_strcasecmp(f->str,"execution_submode") ) { |
389ba50e |
189 | se->field = LTTV_FILTER_STATE_EX_SUBMODE; |
190 | } |
80f9611a |
191 | else if(!g_strcasecmp(f->str,"process_status") ) { |
389ba50e |
192 | se->field = LTTV_FILTER_STATE_P_STATUS; |
193 | } |
80f9611a |
194 | else if(!g_strcasecmp(f->str,"cpu") ) { |
389ba50e |
195 | se->field = LTTV_FILTER_STATE_CPU; |
196 | } |
80f9611a |
197 | } else if(!g_strcasecmp(f->str,"event") ) { |
389ba50e |
198 | /* |
199 | * Possible values: |
200 | * event.name |
201 | * event.category |
202 | * event.time |
203 | * event.tsc |
204 | */ |
73050a5f |
205 | g_string_free(f,TRUE); |
206 | f=g_ptr_array_remove_index(fp,0); |
80f9611a |
207 | if(!g_strcasecmp(f->str,"name") ) { |
389ba50e |
208 | se->field = LTTV_FILTER_EVENT_NAME; |
209 | } |
80f9611a |
210 | else if(!g_strcasecmp(f->str,"category") ) { |
389ba50e |
211 | /* |
212 | * FIXME: Category not yet functional in lttv |
213 | */ |
214 | se->field = LTTV_FILTER_EVENT_CATEGORY; |
215 | } |
80f9611a |
216 | else if(!g_strcasecmp(f->str,"time") ) { |
389ba50e |
217 | se->field = LTTV_FILTER_EVENT_TIME; |
2b99ec10 |
218 | } |
80f9611a |
219 | else if(!g_strcasecmp(f->str,"tsc") ) { |
389ba50e |
220 | se->field = LTTV_FILTER_EVENT_TSC; |
2b99ec10 |
221 | } |
222 | else { /* core.xml specified options */ |
389ba50e |
223 | se->field = LTTV_FILTER_EVENT_FIELD; |
2b99ec10 |
224 | } |
91ad3f0a |
225 | } else { |
226 | g_warning("Unrecognized field in filter string"); |
0769c82f |
227 | } |
47aa6e58 |
228 | |
56e29124 |
229 | /* free memory for last string */ |
73050a5f |
230 | g_string_free(f,TRUE); |
56e29124 |
231 | |
232 | /* array should be empty */ |
73050a5f |
233 | g_assert(fp->len == 0); |
56e29124 |
234 | |
56e29124 |
235 | if(se->field == LTTV_FILTER_UNDEFINED) { |
236 | g_warning("The specified field was not recognized !"); |
237 | return FALSE; |
238 | } |
91ad3f0a |
239 | return TRUE; |
0769c82f |
240 | } |
241 | |
bb87caa7 |
242 | /** |
56e29124 |
243 | * @fn gboolean lttv_simple_expression_assign_operator(LttvSimpleExpression*,LttvExpressionOp) |
244 | * |
bb87caa7 |
245 | * Sets the function pointer for the current |
246 | * Simple Expression |
247 | * @param se current simple expression |
7e7af7f2 |
248 | * @param op current operator |
bb87caa7 |
249 | * @return success/failure of operation |
250 | */ |
be66ef34 |
251 | gboolean |
252 | lttv_simple_expression_assign_operator(LttvSimpleExpression* se, LttvExpressionOp op) { |
aa4600f3 |
253 | |
bb87caa7 |
254 | switch(se->field) { |
56e29124 |
255 | /* |
256 | * string |
257 | */ |
bb87caa7 |
258 | case LTTV_FILTER_TRACE_NAME: |
259 | case LTTV_FILTER_TRACEFILE_NAME: |
260 | case LTTV_FILTER_STATE_P_NAME: |
261 | case LTTV_FILTER_EVENT_NAME: |
be66ef34 |
262 | case LTTV_FILTER_STATE_EX_MODE: |
263 | case LTTV_FILTER_STATE_EX_SUBMODE: |
264 | case LTTV_FILTER_STATE_P_STATUS: |
bb87caa7 |
265 | switch(op) { |
266 | case LTTV_FIELD_EQ: |
c6832b57 |
267 | se->op = lttv_apply_op_eq_quark; |
bb87caa7 |
268 | break; |
269 | case LTTV_FIELD_NE: |
c6832b57 |
270 | se->op = lttv_apply_op_ne_quark; |
bb87caa7 |
271 | break; |
272 | default: |
73050a5f |
273 | g_warning("Error encountered in operator assignment = or != expected"); |
bb87caa7 |
274 | return FALSE; |
275 | } |
276 | break; |
56e29124 |
277 | /* |
278 | * integer |
279 | */ |
bbd9d557 |
280 | case LTTV_FILTER_EVENT_TSC: |
bb87caa7 |
281 | switch(op) { |
282 | case LTTV_FIELD_EQ: |
283 | se->op = lttv_apply_op_eq_uint64; |
284 | break; |
285 | case LTTV_FIELD_NE: |
286 | se->op = lttv_apply_op_ne_uint64; |
287 | break; |
288 | case LTTV_FIELD_LT: |
289 | se->op = lttv_apply_op_lt_uint64; |
290 | break; |
291 | case LTTV_FIELD_LE: |
292 | se->op = lttv_apply_op_le_uint64; |
293 | break; |
294 | case LTTV_FIELD_GT: |
295 | se->op = lttv_apply_op_gt_uint64; |
296 | break; |
297 | case LTTV_FIELD_GE: |
298 | se->op = lttv_apply_op_ge_uint64; |
299 | break; |
300 | default: |
301 | g_warning("Error encountered in operator assignment"); |
302 | return FALSE; |
303 | } |
304 | break; |
6e0d58d6 |
305 | /* |
306 | * 32 bits unsigned integers |
307 | */ |
308 | case LTTV_FILTER_STATE_CPU: |
309 | case LTTV_FILTER_STATE_PID: |
310 | case LTTV_FILTER_STATE_PPID: |
311 | switch(op) { |
312 | case LTTV_FIELD_EQ: |
313 | se->op = lttv_apply_op_eq_uint32; |
314 | break; |
315 | case LTTV_FIELD_NE: |
316 | se->op = lttv_apply_op_ne_uint32; |
317 | break; |
318 | case LTTV_FIELD_LT: |
319 | se->op = lttv_apply_op_lt_uint32; |
320 | break; |
321 | case LTTV_FIELD_LE: |
322 | se->op = lttv_apply_op_le_uint32; |
323 | break; |
324 | case LTTV_FIELD_GT: |
325 | se->op = lttv_apply_op_gt_uint32; |
326 | break; |
327 | case LTTV_FIELD_GE: |
328 | se->op = lttv_apply_op_ge_uint32; |
329 | break; |
330 | default: |
331 | g_warning("Error encountered in operator assignment"); |
332 | return FALSE; |
333 | } |
334 | break; |
335 | |
f017db44 |
336 | /* |
337 | * Enums |
be66ef34 |
338 | * Entered as string, converted to enum |
339 | * |
f017db44 |
340 | * can only be compared with 'equal' or 'not equal' operators |
341 | * |
342 | * unsigned int of 16 bits are used here since enums |
be66ef34 |
343 | * should not go over 2^16-1 values |
f017db44 |
344 | */ |
be66ef34 |
345 | // case /*NOTHING*/: |
346 | // switch(op) { |
347 | // case LTTV_FIELD_EQ: |
348 | // se->op = lttv_apply_op_eq_uint16; |
349 | // break; |
350 | // case LTTV_FIELD_NE: |
351 | // se->op = lttv_apply_op_ne_uint16; |
352 | // break; |
353 | // default: |
354 | // g_warning("Error encountered in operator assignment = or != expected"); |
355 | // return FALSE; |
356 | // } |
357 | // break; |
56e29124 |
358 | /* |
7145a073 |
359 | * Ltttime |
56e29124 |
360 | */ |
bb87caa7 |
361 | case LTTV_FILTER_STATE_CT: |
362 | case LTTV_FILTER_STATE_IT: |
363 | case LTTV_FILTER_EVENT_TIME: |
bb87caa7 |
364 | switch(op) { |
365 | case LTTV_FIELD_EQ: |
7145a073 |
366 | se->op = lttv_apply_op_eq_ltttime; |
bb87caa7 |
367 | break; |
368 | case LTTV_FIELD_NE: |
7145a073 |
369 | se->op = lttv_apply_op_ne_ltttime; |
bb87caa7 |
370 | break; |
371 | case LTTV_FIELD_LT: |
7145a073 |
372 | se->op = lttv_apply_op_lt_ltttime; |
bb87caa7 |
373 | break; |
374 | case LTTV_FIELD_LE: |
7145a073 |
375 | se->op = lttv_apply_op_le_ltttime; |
bb87caa7 |
376 | break; |
377 | case LTTV_FIELD_GT: |
7145a073 |
378 | se->op = lttv_apply_op_gt_ltttime; |
bb87caa7 |
379 | break; |
380 | case LTTV_FIELD_GE: |
7145a073 |
381 | se->op = lttv_apply_op_ge_ltttime; |
bb87caa7 |
382 | break; |
383 | default: |
384 | g_warning("Error encountered in operator assignment"); |
385 | return FALSE; |
386 | } |
387 | break; |
388 | default: |
9ab5ebd7 |
389 | g_warning("Error encountered in operator assignation ! Field type:%i",se->field); |
bb87caa7 |
390 | return FALSE; |
391 | } |
aa4600f3 |
392 | |
393 | return TRUE; |
bb87caa7 |
394 | |
395 | } |
396 | |
9ab5ebd7 |
397 | /** |
7e7af7f2 |
398 | * @fn gboolean lttv_simple_expression_assign_value(LttvSimpleExpression*,char*) |
9ab5ebd7 |
399 | * |
400 | * Assign the value field to the current LttvSimpleExpression |
401 | * @param se pointer to the current LttvSimpleExpression |
402 | * @param value string value for simple expression |
403 | */ |
be66ef34 |
404 | gboolean |
405 | lttv_simple_expression_assign_value(LttvSimpleExpression* se, char* value) { |
9ab5ebd7 |
406 | |
46c40a93 |
407 | unsigned i; |
408 | gboolean is_double = FALSE; |
c6832b57 |
409 | LttTime t = ltt_time_zero; |
410 | GString* v; |
9ab5ebd7 |
411 | |
412 | switch(se->field) { |
413 | /* |
be66ef34 |
414 | * Strings |
415 | * entered as strings, converted to Quarks |
9ab5ebd7 |
416 | */ |
417 | case LTTV_FILTER_TRACE_NAME: |
418 | case LTTV_FILTER_TRACEFILE_NAME: |
419 | case LTTV_FILTER_STATE_P_NAME: |
420 | case LTTV_FILTER_EVENT_NAME: |
be66ef34 |
421 | case LTTV_FILTER_STATE_EX_MODE: |
422 | case LTTV_FILTER_STATE_EX_SUBMODE: |
423 | case LTTV_FILTER_STATE_P_STATUS: |
424 | // se->value.v_string = value; |
bbd9d557 |
425 | se->value.v_uint32 = g_quark_from_string(value); |
c6832b57 |
426 | g_free(value); |
9ab5ebd7 |
427 | break; |
428 | /* |
be66ef34 |
429 | * integer -- supposed to be uint64 |
9ab5ebd7 |
430 | */ |
bbd9d557 |
431 | case LTTV_FILTER_EVENT_TSC: |
9ab5ebd7 |
432 | se->value.v_uint64 = atoi(value); |
433 | g_free(value); |
434 | break; |
6e0d58d6 |
435 | /* |
436 | * 32 bits integer |
437 | */ |
438 | case LTTV_FILTER_STATE_PID: |
439 | case LTTV_FILTER_STATE_PPID: |
440 | case LTTV_FILTER_STATE_CPU: |
441 | se->value.v_uint32 = atoi(value); |
442 | g_free(value); |
443 | break; |
9ab5ebd7 |
444 | /* |
7145a073 |
445 | * LttTime |
9ab5ebd7 |
446 | */ |
447 | case LTTV_FILTER_STATE_CT: |
448 | case LTTV_FILTER_STATE_IT: |
449 | case LTTV_FILTER_EVENT_TIME: |
7145a073 |
450 | //se->value.v_double = atof(value); |
46c40a93 |
451 | /* |
452 | * parsing logic could be optimised, |
453 | * but as for now, simpler this way |
454 | */ |
455 | v = g_string_new(""); |
456 | for(i=0;i<strlen(value);i++) { |
457 | if(value[i] == '.') { |
458 | /* cannot specify number with more than one '.' */ |
459 | if(is_double) return FALSE; |
460 | else is_double = TRUE; |
826f1ab2 |
461 | t.tv_sec = atoi(v->str); |
46c40a93 |
462 | g_string_free(v,TRUE); |
463 | v = g_string_new(""); |
464 | } else g_string_append_c(v,value[i]); |
465 | } |
466 | /* number can be integer or double */ |
826f1ab2 |
467 | if(is_double) t.tv_nsec = atoi(v->str); |
468 | else t.tv_sec = atoi(v->str); |
c6832b57 |
469 | |
46c40a93 |
470 | g_string_free(v,TRUE); |
471 | |
472 | se->value.v_ltttime = t; |
9ab5ebd7 |
473 | g_free(value); |
474 | break; |
475 | default: |
476 | g_warning("Error encountered in value assignation ! Field type = %i",se->field); |
c6832b57 |
477 | g_free(value); |
9ab5ebd7 |
478 | return FALSE; |
479 | } |
480 | |
481 | return TRUE; |
482 | |
483 | } |
484 | |
31452f49 |
485 | /** |
56e29124 |
486 | * @fn void lttv_simple_expression_destroy(LttvSimpleExpression*) |
487 | * |
9ab5ebd7 |
488 | * Disallocate memory for the current |
56e29124 |
489 | * simple expression |
490 | * @param se pointer to the current LttvSimpleExpression |
491 | */ |
492 | void |
493 | lttv_simple_expression_destroy(LttvSimpleExpression* se) { |
494 | |
9ab5ebd7 |
495 | // g_free(se->value); |
786c5c3b |
496 | // switch(se->field) { |
497 | // case LTTV_FILTER_TRACE_NAME: |
498 | // case LTTV_FILTER_TRACEFILE_NAME: |
499 | // case LTTV_FILTER_STATE_P_NAME: |
500 | // case LTTV_FILTER_EVENT_NAME: |
501 | // g_free(se->value.v_string); |
502 | // break; |
503 | // } |
56e29124 |
504 | g_free(se); |
505 | |
506 | } |
507 | |
508 | /** |
509 | * @fn gint lttv_struct_type(gint) |
510 | * |
80f9611a |
511 | * Finds the structure type depending |
512 | * on the fields in parameters |
513 | * @params ft Field of the current structure |
514 | * @return LttvStructType enum or -1 for error |
84a333d6 |
515 | */ |
80f9611a |
516 | gint |
517 | lttv_struct_type(gint ft) { |
5f185a2b |
518 | |
80f9611a |
519 | switch(ft) { |
520 | case LTTV_FILTER_TRACE_NAME: |
521 | return LTTV_FILTER_TRACE; |
522 | break; |
523 | case LTTV_FILTER_TRACEFILE_NAME: |
524 | return LTTV_FILTER_TRACEFILE; |
525 | break; |
526 | case LTTV_FILTER_STATE_PID: |
527 | case LTTV_FILTER_STATE_PPID: |
528 | case LTTV_FILTER_STATE_CT: |
529 | case LTTV_FILTER_STATE_IT: |
530 | case LTTV_FILTER_STATE_P_NAME: |
531 | case LTTV_FILTER_STATE_EX_MODE: |
532 | case LTTV_FILTER_STATE_EX_SUBMODE: |
533 | case LTTV_FILTER_STATE_P_STATUS: |
534 | case LTTV_FILTER_STATE_CPU: |
535 | return LTTV_FILTER_STATE; |
536 | break; |
537 | case LTTV_FILTER_EVENT_NAME: |
538 | case LTTV_FILTER_EVENT_CATEGORY: |
539 | case LTTV_FILTER_EVENT_TIME: |
540 | case LTTV_FILTER_EVENT_TSC: |
541 | case LTTV_FILTER_EVENT_FIELD: |
542 | return LTTV_FILTER_EVENT; |
543 | break; |
544 | default: |
545 | return -1; |
546 | } |
84a333d6 |
547 | } |
548 | |
150f0d33 |
549 | /** |
7e7af7f2 |
550 | * @fn gboolean lttv_apply_op_eq_uint64(gpointer,LttvFieldValue) |
56e29124 |
551 | * |
150f0d33 |
552 | * Applies the 'equal' operator to the |
47aa6e58 |
553 | * specified structure and value |
554 | * @param v1 left member of comparison |
555 | * @param v2 right member of comparison |
150f0d33 |
556 | * @return success/failure of operation |
557 | */ |
4d9ff942 |
558 | gboolean lttv_apply_op_eq_uint64(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
559 | |
560 | guint64* r = (guint64*) v1; |
9ab5ebd7 |
561 | return (*r == v2.v_uint64); |
83aa92fc |
562 | |
563 | } |
150f0d33 |
564 | |
5b729fcf |
565 | /** |
7e7af7f2 |
566 | * @fn gboolean lttv_apply_op_eq_uint32(gpointer,LttvFieldValue) |
56e29124 |
567 | * |
5b729fcf |
568 | * Applies the 'equal' operator to the |
47aa6e58 |
569 | * specified structure and value |
570 | * @param v1 left member of comparison |
571 | * @param v2 right member of comparison |
5b729fcf |
572 | * @return success/failure of operation |
573 | */ |
4d9ff942 |
574 | gboolean lttv_apply_op_eq_uint32(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
575 | guint32* r = (guint32*) v1; |
9ab5ebd7 |
576 | return (*r == v2.v_uint32); |
83aa92fc |
577 | } |
5b729fcf |
578 | |
579 | /** |
7e7af7f2 |
580 | * @fn gboolean lttv_apply_op_eq_uint16(gpointer,LttvFieldValue) |
56e29124 |
581 | * |
5b729fcf |
582 | * Applies the 'equal' operator to the |
47aa6e58 |
583 | * specified structure and value |
584 | * @param v1 left member of comparison |
585 | * @param v2 right member of comparison |
5b729fcf |
586 | * @return success/failure of operation |
587 | */ |
4d9ff942 |
588 | gboolean lttv_apply_op_eq_uint16(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
589 | guint16* r = (guint16*) v1; |
9ab5ebd7 |
590 | return (*r == v2.v_uint16); |
83aa92fc |
591 | } |
5b729fcf |
592 | |
593 | /** |
7e7af7f2 |
594 | * @fn gboolean lttv_apply_op_eq_double(gpointer,LttvFieldValue) |
56e29124 |
595 | * |
5b729fcf |
596 | * Applies the 'equal' operator to the |
47aa6e58 |
597 | * specified structure and value |
598 | * @param v1 left member of comparison |
599 | * @param v2 right member of comparison |
5b729fcf |
600 | * @return success/failure of operation |
601 | */ |
4d9ff942 |
602 | gboolean lttv_apply_op_eq_double(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
603 | double* r = (double*) v1; |
9ab5ebd7 |
604 | return (*r == v2.v_double); |
83aa92fc |
605 | } |
5b729fcf |
606 | |
607 | /** |
7e7af7f2 |
608 | * @fn gboolean lttv_apply_op_eq_string(gpointer,LttvFieldValue) |
56e29124 |
609 | * |
5b729fcf |
610 | * Applies the 'equal' operator to the |
47aa6e58 |
611 | * specified structure and value |
612 | * @param v1 left member of comparison |
613 | * @param v2 right member of comparison |
5b729fcf |
614 | * @return success/failure of operation |
615 | */ |
4d9ff942 |
616 | gboolean lttv_apply_op_eq_string(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
617 | char* r = (char*) v1; |
9ab5ebd7 |
618 | return (!g_strcasecmp(r,v2.v_string)); |
83aa92fc |
619 | } |
150f0d33 |
620 | |
c6832b57 |
621 | /** |
7e7af7f2 |
622 | * @fn gboolean lttv_apply_op_eq_quark(gpointer,LttvFieldValue) |
c6832b57 |
623 | * |
624 | * Applies the 'equal' operator to the |
625 | * specified structure and value |
626 | * @param v1 left member of comparison |
627 | * @param v2 right member of comparison |
628 | * @return success/failure of operation |
629 | */ |
630 | gboolean lttv_apply_op_eq_quark(const gpointer v1, LttvFieldValue v2) { |
631 | GQuark* r = (GQuark*) v1; |
1a252208 |
632 | // g_print("v1:%i v2:%i\n",*r,v2.v_uint32); |
c6832b57 |
633 | return (*r == v2.v_uint32); |
634 | } |
635 | |
7145a073 |
636 | /** |
7e7af7f2 |
637 | * @fn gboolean lttv_apply_op_eq_ltttime(gpointer,LttvFieldValue) |
7145a073 |
638 | * |
639 | * Applies the 'equal' operator to the |
640 | * specified structure and value |
641 | * @param v1 left member of comparison |
642 | * @param v2 right member of comparison |
643 | * @return success/failure of operation |
644 | */ |
4d9ff942 |
645 | gboolean lttv_apply_op_eq_ltttime(const gpointer v1, LttvFieldValue v2) { |
7145a073 |
646 | LttTime* r = (LttTime*) v1; |
c6832b57 |
647 | return ltt_time_compare(*r, v2.v_ltttime)==0?1:0; |
7145a073 |
648 | } |
649 | |
650 | |
150f0d33 |
651 | /** |
7e7af7f2 |
652 | * @fn gboolean lttv_apply_op_ne_uint64(gpointer,LttvFieldValue) |
56e29124 |
653 | * |
150f0d33 |
654 | * Applies the 'not equal' operator to the |
47aa6e58 |
655 | * specified structure and value |
656 | * @param v1 left member of comparison |
657 | * @param v2 right member of comparison |
150f0d33 |
658 | * @return success/failure of operation |
659 | */ |
4d9ff942 |
660 | gboolean lttv_apply_op_ne_uint64(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
661 | guint64* r = (guint64*) v1; |
9ab5ebd7 |
662 | return (*r != v2.v_uint64); |
83aa92fc |
663 | } |
150f0d33 |
664 | |
5b729fcf |
665 | /** |
7e7af7f2 |
666 | * @fn gboolean lttv_apply_op_ne_uint32(gpointer,LttvFieldValue) |
56e29124 |
667 | * |
5b729fcf |
668 | * Applies the 'not equal' operator to the |
47aa6e58 |
669 | * specified structure and value |
670 | * @param v1 left member of comparison |
671 | * @param v2 right member of comparison |
5b729fcf |
672 | * @return success/failure of operation |
673 | */ |
4d9ff942 |
674 | gboolean lttv_apply_op_ne_uint32(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
675 | guint32* r = (guint32*) v1; |
9ab5ebd7 |
676 | return (*r != v2.v_uint32); |
83aa92fc |
677 | } |
5b729fcf |
678 | |
679 | /** |
7e7af7f2 |
680 | * @fn gboolean lttv_apply_op_ne_uint16(gpointer,LttvFieldValue) |
56e29124 |
681 | * |
5b729fcf |
682 | * Applies the 'not equal' operator to the |
47aa6e58 |
683 | * specified structure and value |
684 | * @param v1 left member of comparison |
685 | * @param v2 right member of comparison |
5b729fcf |
686 | * @return success/failure of operation |
687 | */ |
4d9ff942 |
688 | gboolean lttv_apply_op_ne_uint16(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
689 | guint16* r = (guint16*) v1; |
9ab5ebd7 |
690 | return (*r != v2.v_uint16); |
83aa92fc |
691 | } |
5b729fcf |
692 | |
693 | /** |
7e7af7f2 |
694 | * @fn gboolean lttv_apply_op_ne_double(gpointer,LttvFieldValue) |
56e29124 |
695 | * |
5b729fcf |
696 | * Applies the 'not equal' operator to the |
47aa6e58 |
697 | * specified structure and value |
698 | * @param v1 left member of comparison |
699 | * @param v2 right member of comparison |
5b729fcf |
700 | * @return success/failure of operation |
701 | */ |
4d9ff942 |
702 | gboolean lttv_apply_op_ne_double(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
703 | double* r = (double*) v1; |
9ab5ebd7 |
704 | return (*r != v2.v_double); |
83aa92fc |
705 | } |
5b729fcf |
706 | |
707 | /** |
7e7af7f2 |
708 | * @fn gboolean lttv_apply_op_ne_string(gpointer,LttvFieldValue) |
56e29124 |
709 | * |
5b729fcf |
710 | * Applies the 'not equal' operator to the |
47aa6e58 |
711 | * specified structure and value |
712 | * @param v1 left member of comparison |
713 | * @param v2 right member of comparison |
5b729fcf |
714 | * @return success/failure of operation |
715 | */ |
4d9ff942 |
716 | gboolean lttv_apply_op_ne_string(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
717 | char* r = (char*) v1; |
9ab5ebd7 |
718 | return (g_strcasecmp(r,v2.v_string)); |
83aa92fc |
719 | } |
150f0d33 |
720 | |
c6832b57 |
721 | /** |
7e7af7f2 |
722 | * @fn gboolean lttv_apply_op_ne_quark(gpointer,LttvFieldValue) |
c6832b57 |
723 | * |
724 | * Applies the 'not equal' operator to the |
725 | * specified structure and value |
726 | * @param v1 left member of comparison |
727 | * @param v2 right member of comparison |
728 | * @return success/failure of operation |
729 | */ |
730 | gboolean lttv_apply_op_ne_quark(const gpointer v1, LttvFieldValue v2) { |
731 | GQuark* r = (GQuark*) v1; |
732 | return (*r != v2.v_uint32); |
733 | } |
734 | |
735 | |
7145a073 |
736 | /** |
7e7af7f2 |
737 | * @fn gboolean lttv_apply_op_ne_ltttime(gpointer,LttvFieldValue) |
7145a073 |
738 | * |
739 | * Applies the 'not equal' operator to the |
740 | * specified structure and value |
741 | * @param v1 left member of comparison |
742 | * @param v2 right member of comparison |
743 | * @return success/failure of operation |
744 | */ |
4d9ff942 |
745 | gboolean lttv_apply_op_ne_ltttime(const gpointer v1, LttvFieldValue v2) { |
7145a073 |
746 | LttTime* r = (LttTime*) v1; |
46c40a93 |
747 | return ltt_time_compare(*r, v2.v_ltttime)!=0?1:0; |
7145a073 |
748 | } |
749 | |
750 | |
150f0d33 |
751 | /** |
7e7af7f2 |
752 | * @fn gboolean lttv_apply_op_lt_uint64(gpointer,LttvFieldValue) |
56e29124 |
753 | * |
150f0d33 |
754 | * Applies the 'lower than' operator to the |
47aa6e58 |
755 | * specified structure and value |
756 | * @param v1 left member of comparison |
757 | * @param v2 right member of comparison |
150f0d33 |
758 | * @return success/failure of operation |
759 | */ |
4d9ff942 |
760 | gboolean lttv_apply_op_lt_uint64(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
761 | guint64* r = (guint64*) v1; |
9ab5ebd7 |
762 | return (*r < v2.v_uint64); |
83aa92fc |
763 | } |
150f0d33 |
764 | |
5b729fcf |
765 | /** |
7e7af7f2 |
766 | * @fn gboolean lttv_apply_op_lt_uint32(gpointer,LttvFieldValue) |
56e29124 |
767 | * |
5b729fcf |
768 | * Applies the 'lower than' operator to the |
47aa6e58 |
769 | * specified structure and value |
770 | * @param v1 left member of comparison |
771 | * @param v2 right member of comparison |
5b729fcf |
772 | * @return success/failure of operation |
773 | */ |
4d9ff942 |
774 | gboolean lttv_apply_op_lt_uint32(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
775 | guint32* r = (guint32*) v1; |
9ab5ebd7 |
776 | return (*r < v2.v_uint32); |
83aa92fc |
777 | } |
5b729fcf |
778 | |
779 | /** |
7e7af7f2 |
780 | * @fn gboolean lttv_apply_op_lt_uint16(gpointer,LttvFieldValue) |
56e29124 |
781 | * |
5b729fcf |
782 | * Applies the 'lower than' operator to the |
47aa6e58 |
783 | * specified structure and value |
784 | * @param v1 left member of comparison |
785 | * @param v2 right member of comparison |
5b729fcf |
786 | * @return success/failure of operation |
787 | */ |
4d9ff942 |
788 | gboolean lttv_apply_op_lt_uint16(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
789 | guint16* r = (guint16*) v1; |
9ab5ebd7 |
790 | return (*r < v2.v_uint16); |
83aa92fc |
791 | } |
5b729fcf |
792 | |
793 | /** |
7e7af7f2 |
794 | * @fn gboolean lttv_apply_op_lt_double(gpointer,LttvFieldValue) |
56e29124 |
795 | * |
5b729fcf |
796 | * Applies the 'lower than' operator to the |
47aa6e58 |
797 | * specified structure and value |
798 | * @param v1 left member of comparison |
799 | * @param v2 right member of comparison |
5b729fcf |
800 | * @return success/failure of operation |
801 | */ |
4d9ff942 |
802 | gboolean lttv_apply_op_lt_double(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
803 | double* r = (double*) v1; |
9ab5ebd7 |
804 | return (*r < v2.v_double); |
83aa92fc |
805 | } |
5b729fcf |
806 | |
7145a073 |
807 | /** |
7e7af7f2 |
808 | * @fn gboolean lttv_apply_op_lt_ltttime(gpointer,LttvFieldValue) |
7145a073 |
809 | * |
810 | * Applies the 'lower than' operator to the |
811 | * specified structure and value |
812 | * @param v1 left member of comparison |
813 | * @param v2 right member of comparison |
814 | * @return success/failure of operation |
815 | */ |
4d9ff942 |
816 | gboolean lttv_apply_op_lt_ltttime(const gpointer v1, LttvFieldValue v2) { |
7145a073 |
817 | LttTime* r = (LttTime*) v1; |
c6832b57 |
818 | // return ((r->tv_sec < v2.v_ltttime.tv_sec) || ((r->tv_sec == v2.v_ltttime.tv_sec) && (r->tv_nsec < v2.v_ltttime.tv_nsec))); |
819 | return ltt_time_compare(*r, v2.v_ltttime)==-1?1:0; |
7145a073 |
820 | } |
821 | |
822 | |
5b729fcf |
823 | /** |
7e7af7f2 |
824 | * @fn gboolean lttv_apply_op_le_uint64(gpointer,LttvFieldValue) |
56e29124 |
825 | * |
826 | * Applies the 'lower or equal' operator to the |
47aa6e58 |
827 | * specified structure and value |
828 | * @param v1 left member of comparison |
829 | * @param v2 right member of comparison |
5b729fcf |
830 | * @return success/failure of operation |
831 | */ |
4d9ff942 |
832 | gboolean lttv_apply_op_le_uint64(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
833 | guint64* r = (guint64*) v1; |
9ab5ebd7 |
834 | return (*r <= v2.v_uint64); |
83aa92fc |
835 | } |
150f0d33 |
836 | |
837 | /** |
7e7af7f2 |
838 | * @fn gboolean lttv_apply_op_le_uint32(gpointer,LttvFieldValue) |
56e29124 |
839 | * |
150f0d33 |
840 | * Applies the 'lower or equal' operator to the |
47aa6e58 |
841 | * specified structure and value |
842 | * @param v1 left member of comparison |
843 | * @param v2 right member of comparison |
150f0d33 |
844 | * @return success/failure of operation |
845 | */ |
4d9ff942 |
846 | gboolean lttv_apply_op_le_uint32(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
847 | guint32* r = (guint32*) v1; |
9ab5ebd7 |
848 | return (*r <= v2.v_uint32); |
83aa92fc |
849 | } |
150f0d33 |
850 | |
5b729fcf |
851 | /** |
7e7af7f2 |
852 | * @fn gboolean lttv_apply_op_le_uint16(gpointer,LttvFieldValue) |
56e29124 |
853 | * |
5b729fcf |
854 | * Applies the 'lower or equal' operator to the |
47aa6e58 |
855 | * specified structure and value |
856 | * @param v1 left member of comparison |
857 | * @param v2 right member of comparison |
5b729fcf |
858 | * @return success/failure of operation |
859 | */ |
4d9ff942 |
860 | gboolean lttv_apply_op_le_uint16(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
861 | guint16* r = (guint16*) v1; |
9ab5ebd7 |
862 | return (*r <= v2.v_uint16); |
83aa92fc |
863 | } |
5b729fcf |
864 | |
865 | /** |
7e7af7f2 |
866 | * @fn gboolean lttv_apply_op_le_double(gpointer,LttvFieldValue) |
56e29124 |
867 | * |
5b729fcf |
868 | * Applies the 'lower or equal' operator to the |
47aa6e58 |
869 | * specified structure and value |
870 | * @param v1 left member of comparison |
871 | * @param v2 right member of comparison |
5b729fcf |
872 | * @return success/failure of operation |
873 | */ |
4d9ff942 |
874 | gboolean lttv_apply_op_le_double(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
875 | double* r = (double*) v1; |
9ab5ebd7 |
876 | return (*r <= v2.v_double); |
83aa92fc |
877 | } |
5b729fcf |
878 | |
7145a073 |
879 | /** |
7e7af7f2 |
880 | * @fn gboolean lttv_apply_op_le_ltttime(gpointer,LttvFieldValue) |
7145a073 |
881 | * |
882 | * Applies the 'lower or equal' operator to the |
883 | * specified structure and value |
884 | * @param v1 left member of comparison |
885 | * @param v2 right member of comparison |
886 | * @return success/failure of operation |
887 | */ |
4d9ff942 |
888 | gboolean lttv_apply_op_le_ltttime(const gpointer v1, LttvFieldValue v2) { |
7145a073 |
889 | LttTime* r = (LttTime*) v1; |
c6832b57 |
890 | // return ((r->tv_sec < v2.v_ltttime.tv_sec) || ((r->tv_sec == v2.v_ltttime.tv_sec) && (r->tv_nsec <= v2.v_ltttime.tv_nsec))); |
891 | return ltt_time_compare(*r, v2.v_ltttime)<1?1:0; |
7145a073 |
892 | } |
893 | |
894 | |
5b729fcf |
895 | /** |
7e7af7f2 |
896 | * @fn gboolean lttv_apply_op_gt_uint64(gpointer,LttvFieldValue) |
56e29124 |
897 | * |
83aa92fc |
898 | * Applies the 'greater than' operator to the |
47aa6e58 |
899 | * specified structure and value |
900 | * @param v1 left member of comparison |
901 | * @param v2 right member of comparison |
5b729fcf |
902 | * @return success/failure of operation |
903 | */ |
4d9ff942 |
904 | gboolean lttv_apply_op_gt_uint64(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
905 | guint64* r = (guint64*) v1; |
9ab5ebd7 |
906 | return (*r > v2.v_uint64); |
83aa92fc |
907 | } |
150f0d33 |
908 | |
909 | /** |
7e7af7f2 |
910 | * @fn gboolean lttv_apply_op_gt_uint32(gpointer,LttvFieldValue) |
56e29124 |
911 | * |
150f0d33 |
912 | * Applies the 'greater than' operator to the |
47aa6e58 |
913 | * specified structure and value |
914 | * @param v1 left member of comparison |
915 | * @param v2 right member of comparison |
150f0d33 |
916 | * @return success/failure of operation |
917 | */ |
4d9ff942 |
918 | gboolean lttv_apply_op_gt_uint32(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
919 | guint32* r = (guint32*) v1; |
9ab5ebd7 |
920 | return (*r > v2.v_uint32); |
83aa92fc |
921 | } |
150f0d33 |
922 | |
5b729fcf |
923 | /** |
7e7af7f2 |
924 | * @fn gboolean lttv_apply_op_gt_uint16(gpointer,LttvFieldValue) |
56e29124 |
925 | * |
5b729fcf |
926 | * Applies the 'greater than' operator to the |
47aa6e58 |
927 | * specified structure and value |
928 | * @param v1 left member of comparison |
929 | * @param v2 right member of comparison |
5b729fcf |
930 | * @return success/failure of operation |
931 | */ |
4d9ff942 |
932 | gboolean lttv_apply_op_gt_uint16(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
933 | guint16* r = (guint16*) v1; |
9ab5ebd7 |
934 | return (*r > v2.v_uint16); |
83aa92fc |
935 | } |
5b729fcf |
936 | |
937 | /** |
7e7af7f2 |
938 | * @fn gboolean lttv_apply_op_gt_double(gpointer,LttvFieldValue) |
56e29124 |
939 | * |
5b729fcf |
940 | * Applies the 'greater than' operator to the |
47aa6e58 |
941 | * specified structure and value |
942 | * @param v1 left member of comparison |
943 | * @param v2 right member of comparison |
5b729fcf |
944 | * @return success/failure of operation |
945 | */ |
4d9ff942 |
946 | gboolean lttv_apply_op_gt_double(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
947 | double* r = (double*) v1; |
9ab5ebd7 |
948 | return (*r > v2.v_double); |
83aa92fc |
949 | } |
5b729fcf |
950 | |
7145a073 |
951 | /** |
7e7af7f2 |
952 | * @fn gboolean lttv_apply_op_gt_ltttime(gpointer,LttvFieldValue) |
7145a073 |
953 | * |
954 | * Applies the 'greater than' operator to the |
955 | * specified structure and value |
956 | * @param v1 left member of comparison |
957 | * @param v2 right member of comparison |
958 | * @return success/failure of operation |
959 | */ |
4d9ff942 |
960 | gboolean lttv_apply_op_gt_ltttime(const gpointer v1, LttvFieldValue v2) { |
7145a073 |
961 | LttTime* r = (LttTime*) v1; |
c6832b57 |
962 | // return ((r->tv_sec > v2.v_ltttime.tv_sec) || ((r->tv_sec == v2.v_ltttime.tv_sec) && (r->tv_nsec > v2.v_ltttime.tv_nsec))); |
963 | return ltt_time_compare(*r, v2.v_ltttime)==1?1:0; |
7145a073 |
964 | } |
965 | |
966 | |
5b729fcf |
967 | /** |
7e7af7f2 |
968 | * @fn gboolean lttv_apply_op_ge_uint64(gpointer,LttvFieldValue) |
56e29124 |
969 | * |
83aa92fc |
970 | * Applies the 'greater or equal' operator to the |
47aa6e58 |
971 | * specified structure and value |
972 | * @param v1 left member of comparison |
973 | * @param v2 right member of comparison |
5b729fcf |
974 | * @return success/failure of operation |
975 | */ |
4d9ff942 |
976 | gboolean lttv_apply_op_ge_uint64(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
977 | guint64* r = (guint64*) v1; |
9ab5ebd7 |
978 | return (*r >= v2.v_uint64); |
83aa92fc |
979 | } |
150f0d33 |
980 | |
981 | /** |
7e7af7f2 |
982 | * @fn gboolean lttv_apply_op_ge_uint32(gpointer,LttvFieldValue) |
56e29124 |
983 | * |
150f0d33 |
984 | * Applies the 'greater or equal' operator to the |
47aa6e58 |
985 | * specified structure and value |
986 | * @param v1 left member of comparison |
987 | * @param v2 right member of comparison |
150f0d33 |
988 | * @return success/failure of operation |
989 | */ |
4d9ff942 |
990 | gboolean lttv_apply_op_ge_uint32(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
991 | guint32* r = (guint32*) v1; |
9ab5ebd7 |
992 | return (*r >= v2.v_uint32); |
83aa92fc |
993 | } |
150f0d33 |
994 | |
5b729fcf |
995 | /** |
7e7af7f2 |
996 | * @fn gboolean lttv_apply_op_ge_uint16(gpointer,LttvFieldValue) |
56e29124 |
997 | * |
5b729fcf |
998 | * Applies the 'greater or equal' operator to the |
47aa6e58 |
999 | * specified structure and value |
1000 | * @param v1 left member of comparison |
1001 | * @param v2 right member of comparison |
5b729fcf |
1002 | * @return success/failure of operation |
1003 | */ |
4d9ff942 |
1004 | gboolean lttv_apply_op_ge_uint16(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
1005 | guint16* r = (guint16*) v1; |
9ab5ebd7 |
1006 | return (*r >= v2.v_uint16); |
83aa92fc |
1007 | } |
150f0d33 |
1008 | |
5b729fcf |
1009 | /** |
7e7af7f2 |
1010 | * @fn gboolean lttv_apply_op_ge_double(gpointer,LttvFieldValue) |
56e29124 |
1011 | * |
5b729fcf |
1012 | * Applies the 'greater or equal' operator to the |
47aa6e58 |
1013 | * specified structure and value |
1014 | * @param v1 left member of comparison |
1015 | * @param v2 right member of comparison |
5b729fcf |
1016 | * @return success/failure of operation |
1017 | */ |
4d9ff942 |
1018 | gboolean lttv_apply_op_ge_double(const gpointer v1, LttvFieldValue v2) { |
83aa92fc |
1019 | double* r = (double*) v1; |
9ab5ebd7 |
1020 | return (*r >= v2.v_double); |
83aa92fc |
1021 | } |
150f0d33 |
1022 | |
7145a073 |
1023 | /** |
7e7af7f2 |
1024 | * @fn gboolean lttv_apply_op_ge_ltttime(gpointer,LttvFieldValue) |
7145a073 |
1025 | * |
1026 | * Applies the 'greater or equal' operator to the |
1027 | * specified structure and value |
1028 | * @param v1 left member of comparison |
1029 | * @param v2 right member of comparison |
1030 | * @return success/failure of operation |
1031 | */ |
4d9ff942 |
1032 | gboolean lttv_apply_op_ge_ltttime(const gpointer v1, LttvFieldValue v2) { |
7145a073 |
1033 | LttTime* r = (LttTime*) v1; |
c6832b57 |
1034 | // return ((r->tv_sec > v2.v_ltttime.tv_sec) || ((r->tv_sec == v2.v_ltttime.tv_sec) && (r->tv_nsec >= v2.v_ltttime.tv_nsec))); |
1035 | return ltt_time_compare(*r, v2.v_ltttime)>-1?1:0; |
7145a073 |
1036 | } |
1037 | |
1038 | |
150f0d33 |
1039 | |
1040 | /** |
56e29124 |
1041 | * Makes a copy of the current filter tree |
1042 | * @param tree pointer to the current tree |
1043 | * @return new copy of the filter tree |
150f0d33 |
1044 | */ |
1045 | LttvFilterTree* |
4d9ff942 |
1046 | lttv_filter_tree_clone(const LttvFilterTree* tree) { |
150f0d33 |
1047 | |
8c89f5a8 |
1048 | LttvFilterTree* newtree = lttv_filter_tree_new(); |
150f0d33 |
1049 | |
8c89f5a8 |
1050 | newtree->node = tree->node; |
1051 | |
1052 | newtree->left = tree->left; |
1053 | if(newtree->left == LTTV_TREE_NODE) { |
1054 | newtree->l_child.t = lttv_filter_tree_clone(tree->l_child.t); |
1055 | } else if(newtree->left == LTTV_TREE_LEAF) { |
1056 | newtree->l_child.leaf = lttv_simple_expression_new(); |
1057 | newtree->l_child.leaf->field = tree->l_child.leaf->field; |
1058 | newtree->l_child.leaf->offset = tree->l_child.leaf->offset; |
1059 | newtree->l_child.leaf->op = tree->l_child.leaf->op; |
9ab5ebd7 |
1060 | /* FIXME: special case for string copy ! */ |
1061 | newtree->l_child.leaf->value = tree->l_child.leaf->value; |
8c89f5a8 |
1062 | } |
1063 | |
1064 | newtree->right = tree->right; |
1065 | if(newtree->right == LTTV_TREE_NODE) { |
1066 | newtree->r_child.t = lttv_filter_tree_clone(tree->r_child.t); |
1067 | } else if(newtree->right == LTTV_TREE_LEAF) { |
1068 | newtree->r_child.leaf = lttv_simple_expression_new(); |
1069 | newtree->r_child.leaf->field = tree->r_child.leaf->field; |
1070 | newtree->r_child.leaf->offset = tree->r_child.leaf->offset; |
1071 | newtree->r_child.leaf->op = tree->r_child.leaf->op; |
9ab5ebd7 |
1072 | newtree->r_child.leaf->value = tree->r_child.leaf->value; |
8c89f5a8 |
1073 | } |
1074 | |
1075 | return newtree; |
1076 | |
150f0d33 |
1077 | } |
1078 | |
1079 | /** |
56e29124 |
1080 | * Makes a copy of the current filter |
1081 | * @param filter pointer to the current filter |
1082 | * @return new copy of the filter |
150f0d33 |
1083 | */ |
1084 | LttvFilter* |
4d9ff942 |
1085 | lttv_filter_clone(const LttvFilter* filter) { |
ebcead4a |
1086 | |
1087 | if(!filter) return NULL; |
1088 | |
150f0d33 |
1089 | LttvFilter* newfilter = g_new(LttvFilter,1); |
1090 | |
150f0d33 |
1091 | strcpy(newfilter->expression,filter->expression); |
1092 | |
1093 | newfilter->head = lttv_filter_tree_clone(filter->head); |
1094 | |
1095 | return newfilter; |
1096 | |
1097 | } |
1098 | |
1099 | |
84a333d6 |
1100 | /** |
56e29124 |
1101 | * @fn LttvFilter* lttv_filter_new() |
1102 | * |
7e7af7f2 |
1103 | * Creates a new LttvFilter |
1104 | * @return the current LttvFilter or NULL if error |
31452f49 |
1105 | */ |
2ea36caf |
1106 | LttvFilter* |
5f185a2b |
1107 | lttv_filter_new() { |
a4c292d4 |
1108 | |
5f185a2b |
1109 | LttvFilter* filter = g_new(LttvFilter,1); |
1110 | filter->expression = NULL; |
1111 | filter->head = NULL; |
7e7af7f2 |
1112 | |
1113 | return filter; |
5f185a2b |
1114 | |
1115 | } |
a4c292d4 |
1116 | |
8c89f5a8 |
1117 | /** |
56e29124 |
1118 | * @fn gboolean lttv_filter_update(LttvFilter*) |
1119 | * |
8c89f5a8 |
1120 | * Updates the current LttvFilter by building |
1121 | * its tree based upon the expression string |
1122 | * @param filter pointer to the current LttvFilter |
1123 | * @return Failure/Success of operation |
1124 | */ |
5f185a2b |
1125 | gboolean |
1126 | lttv_filter_update(LttvFilter* filter) { |
1127 | |
4d9ff942 |
1128 | // g_print("filter::lttv_filter_new()\n"); /* debug */ |
5f185a2b |
1129 | |
1130 | if(filter->expression == NULL) return FALSE; |
1131 | |
f3020899 |
1132 | int |
a4c292d4 |
1133 | i, |
72911c5d |
1134 | p_nesting=0, /* parenthesis nesting value */ |
1135 | not=0; |
1136 | |
1601b365 |
1137 | /* trees */ |
5b729fcf |
1138 | LttvFilterTree |
1601b365 |
1139 | *tree = lttv_filter_tree_new(), /* main tree */ |
1140 | *subtree = NULL, /* buffer for subtrees */ |
1141 | *t1, /* buffer #1 */ |
72911c5d |
1142 | *t2, /* buffer #2 */ |
1143 | *t3; /* buffer #3 */ |
1601b365 |
1144 | |
5f185a2b |
1145 | /* |
1146 | * the filter |
1147 | * If the tree already exists, |
1148 | * destroy it and build a new one |
1149 | */ |
1150 | if(filter->head != NULL) lttv_filter_tree_destroy(filter->head); |
f3020899 |
1151 | filter->head = NULL; /* will be assigned at the end */ |
5f185a2b |
1152 | |
1601b365 |
1153 | /* |
1154 | * Tree Stack |
f4e9dd16 |
1155 | * each element of the list |
1156 | * is a sub tree created |
1157 | * by the use of parenthesis in the |
1158 | * global expression. The final tree |
1601b365 |
1159 | * will be the one left at the root of |
f4e9dd16 |
1160 | * the list |
1161 | */ |
18d1226f |
1162 | GPtrArray *tree_stack = g_ptr_array_new(); |
1163 | g_ptr_array_add( tree_stack,(gpointer) tree ); |
f4e9dd16 |
1164 | |
a4c292d4 |
1165 | /* temporary values */ |
0769c82f |
1166 | GString *a_field_component = g_string_new(""); |
56e29124 |
1167 | GPtrArray *a_field_path = g_ptr_array_new(); |
1168 | |
1169 | /* simple expression buffer */ |
389ba50e |
1170 | LttvSimpleExpression* a_simple_expression = lttv_simple_expression_new(); |
0769c82f |
1171 | |
a4c292d4 |
1172 | /* |
1173 | * Parse entire expression and construct |
1174 | * the binary tree. There are two steps |
1175 | * in browsing that string |
f4e9dd16 |
1176 | * 1. finding boolean ops " &,|,^,! " and parenthesis " {,(,[,],),} " |
a4c292d4 |
1177 | * 2. finding simple expressions |
0769c82f |
1178 | * - field path ( separated by dots ) |
a4c292d4 |
1179 | * - op ( >, <, =, >=, <=, !=) |
0769c82f |
1180 | * - value ( integer, string ... ) |
1181 | * To spare computing time, the whole |
1182 | * string is parsed in this loop for a |
1183 | * O(n) complexity order. |
1601b365 |
1184 | * |
18d1226f |
1185 | * When encountering logical op &,|,^ |
1186 | * 1. parse the last value if any |
1187 | * 2. create a new tree |
1188 | * 3. add the expression (simple exp, or exp (subtree)) to the tree |
1189 | * 4. concatenate this tree with the current tree on top of the stack |
1190 | * When encountering math ops >,>=,<,<=,=,!= |
1191 | * 1. add to op to the simple expression |
1192 | * 2. concatenate last field component to field path |
1193 | * When encountering concatening ops . |
1194 | * 1. concatenate last field component to field path |
1195 | * When encountering opening parenthesis (,{,[ |
1196 | * 1. create a new subtree on top of tree stack |
1197 | * When encountering closing parenthesis ),},] |
1198 | * 1. add the expression on right child of the current tree |
1199 | * 2. the subtree is completed, allocate a new subtree |
1200 | * 3. pop the tree value from the tree stack |
1201 | */ |
be66ef34 |
1202 | |
1203 | #ifdef TEST |
1204 | struct timeval starttime; |
1205 | struct timeval endtime; |
1206 | gettimeofday(&starttime, NULL); |
1207 | #endif |
18d1226f |
1208 | |
5f185a2b |
1209 | for(i=0;i<strlen(filter->expression);i++) { |
1210 | // debug |
72911c5d |
1211 | // g_print("%c\n ",filter->expression[i]); |
4d9ff942 |
1212 | |
5f185a2b |
1213 | switch(filter->expression[i]) { |
a4c292d4 |
1214 | /* |
1215 | * logical operators |
1216 | */ |
1217 | case '&': /* and */ |
72911c5d |
1218 | |
1219 | /* get current tree in tree stack */ |
5b729fcf |
1220 | t1 = (LttvFilterTree*)g_ptr_array_index(tree_stack,tree_stack->len-1); |
72911c5d |
1221 | |
1222 | /* get current node at absolute right */ |
9ab5ebd7 |
1223 | while(t1->right != LTTV_TREE_IDLE) { |
1224 | g_assert(t1->right == LTTV_TREE_NODE); |
1225 | t1 = t1->r_child.t; |
1226 | } |
18d1226f |
1227 | t2 = lttv_filter_tree_new(); |
0cdc2470 |
1228 | t2->node = LTTV_LOGICAL_AND; |
72911c5d |
1229 | t1->right = LTTV_TREE_NODE; |
1230 | t1->r_child.t = t2; |
1231 | if(not) { /* add not operator to tree */ |
1232 | t3 = lttv_filter_tree_new(); |
1233 | t3->node = LTTV_LOGICAL_NOT; |
1234 | t2->left = LTTV_TREE_NODE; |
1235 | t2->l_child.t = t3; |
72911c5d |
1236 | t2 = t3; |
1237 | not = 0; |
72911c5d |
1238 | } |
bb87caa7 |
1239 | if(subtree != NULL) { /* append subtree to current tree */ |
18d1226f |
1240 | t2->left = LTTV_TREE_NODE; |
1241 | t2->l_child.t = subtree; |
f4e9dd16 |
1242 | subtree = NULL; |
bb87caa7 |
1243 | } else { /* append a simple expression */ |
9ab5ebd7 |
1244 | lttv_simple_expression_assign_value(a_simple_expression,g_string_free(a_field_component,FALSE)); |
18d1226f |
1245 | a_field_component = g_string_new(""); |
1246 | t2->left = LTTV_TREE_LEAF; |
0cdc2470 |
1247 | t2->l_child.leaf = a_simple_expression; |
389ba50e |
1248 | a_simple_expression = lttv_simple_expression_new(); |
f4e9dd16 |
1249 | } |
f4e9dd16 |
1250 | break; |
aa4600f3 |
1251 | |
a4c292d4 |
1252 | case '|': /* or */ |
aa4600f3 |
1253 | |
e00d6a24 |
1254 | t1 = (LttvFilterTree*)g_ptr_array_index(tree_stack,tree_stack->len-1); |
9ab5ebd7 |
1255 | while(t1->right != LTTV_TREE_IDLE) { |
1256 | g_assert(t1->right == LTTV_TREE_NODE); |
1257 | t1 = t1->r_child.t; |
1258 | } |
1601b365 |
1259 | t2 = lttv_filter_tree_new(); |
0cdc2470 |
1260 | t2->node = LTTV_LOGICAL_OR; |
72911c5d |
1261 | t1->right = LTTV_TREE_NODE; |
1262 | t1->r_child.t = t2; |
1263 | if(not) { // add not operator to tree |
1264 | t3 = lttv_filter_tree_new(); |
1265 | t3->node = LTTV_LOGICAL_NOT; |
1266 | t2->left = LTTV_TREE_NODE; |
1267 | t2->l_child.t = t3; |
1268 | t2 = t3; |
1269 | not = 0; |
1270 | } |
1271 | if(subtree != NULL) { /* append subtree to current tree */ |
1601b365 |
1272 | t2->left = LTTV_TREE_NODE; |
1273 | t2->l_child.t = subtree; |
1274 | subtree = NULL; |
72911c5d |
1275 | } else { /* append a simple expression */ |
9ab5ebd7 |
1276 | lttv_simple_expression_assign_value(a_simple_expression,g_string_free(a_field_component,FALSE)); |
1601b365 |
1277 | a_field_component = g_string_new(""); |
1278 | t2->left = LTTV_TREE_LEAF; |
0cdc2470 |
1279 | t2->l_child.leaf = a_simple_expression; |
389ba50e |
1280 | a_simple_expression = lttv_simple_expression_new(); |
1601b365 |
1281 | } |
f4e9dd16 |
1282 | break; |
aa4600f3 |
1283 | |
a4c292d4 |
1284 | case '^': /* xor */ |
aa4600f3 |
1285 | |
e00d6a24 |
1286 | t1 = (LttvFilterTree*)g_ptr_array_index(tree_stack,tree_stack->len-1); |
9ab5ebd7 |
1287 | while(t1->right != LTTV_TREE_IDLE) { |
1288 | g_assert(t1->right == LTTV_TREE_NODE); |
1289 | t1 = t1->r_child.t; |
1290 | } |
1601b365 |
1291 | t2 = lttv_filter_tree_new(); |
0cdc2470 |
1292 | t2->node = LTTV_LOGICAL_XOR; |
72911c5d |
1293 | t1->right = LTTV_TREE_NODE; |
1294 | t1->r_child.t = t2; |
1295 | if(not) { // add not operator to tree |
1296 | t3 = lttv_filter_tree_new(); |
1297 | t3->node = LTTV_LOGICAL_NOT; |
1298 | t2->left = LTTV_TREE_NODE; |
1299 | t2->l_child.t = t3; |
1300 | t2 = t3; |
1301 | not = 0; |
1302 | } |
bb87caa7 |
1303 | if(subtree != NULL) { /* append subtree to current tree */ |
1601b365 |
1304 | t2->left = LTTV_TREE_NODE; |
1305 | t2->l_child.t = subtree; |
1306 | subtree = NULL; |
bb87caa7 |
1307 | } else { /* append a simple expression */ |
9ab5ebd7 |
1308 | lttv_simple_expression_assign_value(a_simple_expression,g_string_free(a_field_component,FALSE)); |
1601b365 |
1309 | a_field_component = g_string_new(""); |
1310 | t2->left = LTTV_TREE_LEAF; |
0cdc2470 |
1311 | t2->l_child.leaf = a_simple_expression; |
389ba50e |
1312 | a_simple_expression = lttv_simple_expression_new(); |
1601b365 |
1313 | } |
a4c292d4 |
1314 | break; |
aa4600f3 |
1315 | |
a4c292d4 |
1316 | case '!': /* not, or not equal (math op) */ |
aa4600f3 |
1317 | |
5f185a2b |
1318 | if(filter->expression[i+1] == '=') { /* != */ |
0cdc2470 |
1319 | g_ptr_array_add( a_field_path,(gpointer) a_field_component ); |
9ab5ebd7 |
1320 | lttv_simple_expression_assign_field(a_field_path,a_simple_expression); |
0cdc2470 |
1321 | a_field_component = g_string_new(""); |
56e29124 |
1322 | lttv_simple_expression_assign_operator(a_simple_expression,LTTV_FIELD_NE); |
aa4600f3 |
1323 | i++; |
a4c292d4 |
1324 | } else { /* ! */ |
72911c5d |
1325 | not=1; |
a4c292d4 |
1326 | } |
1327 | break; |
aa4600f3 |
1328 | |
a4c292d4 |
1329 | case '(': /* start of parenthesis */ |
91ad3f0a |
1330 | case '[': |
1331 | case '{': |
aa4600f3 |
1332 | |
91ad3f0a |
1333 | p_nesting++; /* incrementing parenthesis nesting value */ |
1601b365 |
1334 | t1 = lttv_filter_tree_new(); |
72911c5d |
1335 | if(not) { /* add not operator to tree */ |
1336 | t3 = lttv_filter_tree_new(); |
1337 | t3->node = LTTV_LOGICAL_NOT; |
1338 | t1->right = LTTV_TREE_NODE; |
1339 | t1->r_child.t = t3; |
1340 | not = 0; |
1341 | } |
1601b365 |
1342 | g_ptr_array_add( tree_stack,(gpointer) t1 ); |
a4c292d4 |
1343 | break; |
aa4600f3 |
1344 | |
a4c292d4 |
1345 | case ')': /* end of parenthesis */ |
91ad3f0a |
1346 | case ']': |
1347 | case '}': |
aa4600f3 |
1348 | |
91ad3f0a |
1349 | p_nesting--; /* decrementing parenthesis nesting value */ |
18d1226f |
1350 | if(p_nesting<0 || tree_stack->len<2) { |
f4e9dd16 |
1351 | g_warning("Wrong filtering options, the string\n\"%s\"\n\ |
5f185a2b |
1352 | is not valid due to parenthesis incorrect use",filter->expression); |
1353 | return FALSE; |
f4e9dd16 |
1354 | } |
56e29124 |
1355 | |
1356 | /* there must at least be the root tree left in the array */ |
18d1226f |
1357 | g_assert(tree_stack->len>0); |
72911c5d |
1358 | |
1359 | t1 = g_ptr_array_index(tree_stack,tree_stack->len-1); |
1360 | while(t1->right != LTTV_TREE_IDLE) { |
1361 | t1 = t1->r_child.t; |
1362 | } |
1363 | if(not) { // add not operator to tree |
1364 | g_print("ici"); |
1365 | t3 = lttv_filter_tree_new(); |
1366 | t3->node = LTTV_LOGICAL_NOT; |
1367 | t1->right = LTTV_TREE_NODE; |
1368 | t1->r_child.t = t3; |
1369 | t1 = t3; |
1370 | not = 0; |
1371 | } |
bb87caa7 |
1372 | if(subtree != NULL) { /* append subtree to current tree */ |
18d1226f |
1373 | t1->right = LTTV_TREE_NODE; |
1374 | t1->r_child.t = subtree; |
1375 | subtree = g_ptr_array_index(tree_stack,tree_stack->len-1); |
1376 | g_ptr_array_remove_index(tree_stack,tree_stack->len-1); |
bb87caa7 |
1377 | } else { /* assign subtree as current tree */ |
9ab5ebd7 |
1378 | lttv_simple_expression_assign_value(a_simple_expression,g_string_free(a_field_component,FALSE)); |
18d1226f |
1379 | a_field_component = g_string_new(""); |
18d1226f |
1380 | t1->right = LTTV_TREE_LEAF; |
0cdc2470 |
1381 | t1->r_child.leaf = a_simple_expression; |
389ba50e |
1382 | a_simple_expression = lttv_simple_expression_new(); |
9ab5ebd7 |
1383 | subtree = g_ptr_array_remove_index(tree_stack,tree_stack->len-1); |
18d1226f |
1384 | } |
a4c292d4 |
1385 | break; |
1386 | |
1387 | /* |
1388 | * mathematic operators |
1389 | */ |
1390 | case '<': /* lower, lower or equal */ |
aa4600f3 |
1391 | |
1392 | g_ptr_array_add( a_field_path,(gpointer) a_field_component ); |
9ab5ebd7 |
1393 | lttv_simple_expression_assign_field(a_field_path,a_simple_expression); |
aa4600f3 |
1394 | a_field_component = g_string_new(""); |
5f185a2b |
1395 | if(filter->expression[i+1] == '=') { /* <= */ |
a4c292d4 |
1396 | i++; |
56e29124 |
1397 | lttv_simple_expression_assign_operator(a_simple_expression,LTTV_FIELD_LE); |
1398 | } else lttv_simple_expression_assign_operator(a_simple_expression,LTTV_FIELD_LT); |
aa4600f3 |
1399 | break; |
1400 | |
1401 | case '>': /* higher, higher or equal */ |
1402 | |
1403 | g_ptr_array_add( a_field_path,(gpointer) a_field_component ); |
9ab5ebd7 |
1404 | lttv_simple_expression_assign_field(a_field_path,a_simple_expression); |
f4e9dd16 |
1405 | a_field_component = g_string_new(""); |
5f185a2b |
1406 | if(filter->expression[i+1] == '=') { /* >= */ |
a4c292d4 |
1407 | i++; |
56e29124 |
1408 | lttv_simple_expression_assign_operator(a_simple_expression,LTTV_FIELD_GE); |
1409 | } else lttv_simple_expression_assign_operator(a_simple_expression,LTTV_FIELD_GT); |
aa4600f3 |
1410 | break; |
1411 | |
a4c292d4 |
1412 | case '=': /* equal */ |
aa4600f3 |
1413 | |
f4e9dd16 |
1414 | g_ptr_array_add( a_field_path,(gpointer) a_field_component ); |
9ab5ebd7 |
1415 | lttv_simple_expression_assign_field(a_field_path,a_simple_expression); |
f4e9dd16 |
1416 | a_field_component = g_string_new(""); |
56e29124 |
1417 | lttv_simple_expression_assign_operator(a_simple_expression,LTTV_FIELD_EQ); |
a4c292d4 |
1418 | break; |
aa4600f3 |
1419 | |
0769c82f |
1420 | /* |
1421 | * Field concatening caracter |
1422 | */ |
1423 | case '.': /* dot */ |
aa4600f3 |
1424 | |
bb87caa7 |
1425 | /* |
1426 | * divide field expression into elements |
1427 | * in a_field_path array. |
4d9ff942 |
1428 | * |
1429 | * A dot can also be present in double values |
bb87caa7 |
1430 | */ |
8ff6243c |
1431 | if(a_simple_expression->field == LTTV_FILTER_UNDEFINED) { |
bb87caa7 |
1432 | g_ptr_array_add( a_field_path,(gpointer) a_field_component ); |
1433 | a_field_component = g_string_new(""); |
8ff6243c |
1434 | } |
1435 | break; |
4d9ff942 |
1436 | case ' ': /* ignore */ |
1437 | case '\n': /* ignore */ |
0769c82f |
1438 | break; |
a4c292d4 |
1439 | default: /* concatening current string */ |
73050a5f |
1440 | g_string_append_c(a_field_component,filter->expression[i]); |
a4c292d4 |
1441 | } |
1442 | } |
1601b365 |
1443 | |
0cdc2470 |
1444 | /* |
1445 | * Preliminary check to see |
1446 | * if tree was constructed correctly |
1447 | */ |
1448 | if( p_nesting>0 ) { |
1449 | g_warning("Wrong filtering options, the string\n\"%s\"\n\ |
5f185a2b |
1450 | is not valid due to parenthesis incorrect use",filter->expression); |
1451 | return FALSE; |
0cdc2470 |
1452 | } |
1453 | |
1454 | if(tree_stack->len != 1) /* only root tree should remain */ |
5f185a2b |
1455 | return FALSE; |
1601b365 |
1456 | |
72911c5d |
1457 | /* |
1458 | * processing last element of expression |
1459 | */ |
410c83da |
1460 | t1 = g_ptr_array_index(tree_stack,tree_stack->len-1); |
9ab5ebd7 |
1461 | while(t1->right != LTTV_TREE_IDLE) { |
1462 | g_assert(t1->right == LTTV_TREE_NODE); |
1463 | t1 = t1->r_child.t; |
1464 | } |
72911c5d |
1465 | if(not) { // add not operator to tree |
1466 | t3 = lttv_filter_tree_new(); |
1467 | t3->node = LTTV_LOGICAL_NOT; |
1468 | t1->right = LTTV_TREE_NODE; |
1469 | t1->r_child.t = t3; |
1470 | t1 = t3; |
1471 | not = 0; |
1472 | } |
410c83da |
1473 | if(subtree != NULL) { /* add the subtree */ |
1474 | t1->right = LTTV_TREE_NODE; |
0cdc2470 |
1475 | t1->r_child.t = subtree; |
410c83da |
1476 | subtree = NULL; |
1477 | } else { /* add a leaf */ |
9ab5ebd7 |
1478 | lttv_simple_expression_assign_value(a_simple_expression,g_string_free(a_field_component,FALSE)); |
56e29124 |
1479 | a_field_component = NULL; |
410c83da |
1480 | t1->right = LTTV_TREE_LEAF; |
0cdc2470 |
1481 | t1->r_child.leaf = a_simple_expression; |
56e29124 |
1482 | a_simple_expression = NULL; |
410c83da |
1483 | } |
1484 | |
56e29124 |
1485 | |
73050a5f |
1486 | /* free the pointer array */ |
1487 | g_assert(a_field_path->len == 0); |
1488 | g_ptr_array_free(a_field_path,TRUE); |
56e29124 |
1489 | |
1490 | /* free the tree stack -- but keep the root tree */ |
f3020899 |
1491 | filter->head = g_ptr_array_remove_index(tree_stack,0); |
1492 | g_ptr_array_free(tree_stack,TRUE); |
1493 | |
56e29124 |
1494 | /* free the field buffer if allocated */ |
1495 | if(a_field_component != NULL) g_string_free(a_field_component,TRUE); |
1496 | |
1497 | /* free the simple expression buffer if allocated */ |
1498 | if(a_simple_expression != NULL) lttv_simple_expression_destroy(a_simple_expression); |
73050a5f |
1499 | |
f3020899 |
1500 | g_assert(filter->head != NULL); /* tree should exist */ |
56e29124 |
1501 | g_assert(subtree == NULL); /* remaining subtree should be included in main tree */ |
be66ef34 |
1502 | |
1503 | #ifdef TEST |
1504 | gettimeofday(&endtime, NULL); |
1505 | |
1506 | /* Calcul du temps de l'algorithme */ |
1507 | double time1 = starttime.tv_sec + (starttime.tv_usec/1000000.0); |
1508 | double time2 = endtime.tv_sec + (endtime.tv_usec/1000000.0); |
1509 | // g_print("Tree build took %.10f ms for strlen of %i\n",(time2-time1)*1000,strlen(filter->expression)); |
1510 | g_print("%.10f %i\n",(time2-time1)*1000,strlen(filter->expression)); |
1511 | #endif |
a4c292d4 |
1512 | |
56e29124 |
1513 | /* debug */ |
1514 | g_print("+++++++++++++++ BEGIN PRINT ++++++++++++++++\n"); |
72911c5d |
1515 | lttv_print_tree(filter->head,0) ; |
56e29124 |
1516 | g_print("+++++++++++++++ END PRINT ++++++++++++++++++\n"); |
1517 | |
1518 | /* success */ |
5f185a2b |
1519 | return TRUE; |
80f9611a |
1520 | |
31452f49 |
1521 | } |
1522 | |
8c89f5a8 |
1523 | /** |
56e29124 |
1524 | * @fn void lttv_filter_destroy(LttvFilter*) |
1525 | * |
8c89f5a8 |
1526 | * Destroy the current LttvFilter |
1527 | * @param filter pointer to the current LttvFilter |
1528 | */ |
1da1525d |
1529 | void |
2ea36caf |
1530 | lttv_filter_destroy(LttvFilter* filter) { |
5f185a2b |
1531 | |
ebcead4a |
1532 | if(!filter) return; |
1533 | |
1534 | if(filter->expression) |
1535 | g_free(filter->expression); |
1536 | if(filter->head) |
1537 | lttv_filter_tree_destroy(filter->head); |
5f185a2b |
1538 | g_free(filter); |
1539 | |
1da1525d |
1540 | } |
1541 | |
150f0d33 |
1542 | /** |
8ff6243c |
1543 | * @fn LttvFilterTree* lttv_filter_tree_new() |
56e29124 |
1544 | * |
150f0d33 |
1545 | * Assign a new tree for the current expression |
1546 | * or sub expression |
1547 | * @return pointer of LttvFilterTree |
1548 | */ |
5f185a2b |
1549 | LttvFilterTree* |
1550 | lttv_filter_tree_new() { |
150f0d33 |
1551 | LttvFilterTree* tree; |
1552 | |
e00d6a24 |
1553 | tree = g_new(LttvFilterTree,1); |
150f0d33 |
1554 | tree->node = 0; //g_new(lttv_expression,1); |
150f0d33 |
1555 | tree->left = LTTV_TREE_IDLE; |
1556 | tree->right = LTTV_TREE_IDLE; |
f3020899 |
1557 | tree->r_child.t = NULL; |
1558 | tree->l_child.t = NULL; |
1559 | |
150f0d33 |
1560 | return tree; |
1561 | } |
1562 | |
80f9611a |
1563 | /** |
56e29124 |
1564 | * @fn void lttv_filter_append_expression(LttvFilter*,char*) |
1565 | * |
80f9611a |
1566 | * Append a new expression to the expression |
1567 | * defined in the current filter |
1568 | * @param filter pointer to the current LttvFilter |
1569 | * @param expression string that must be appended |
56e29124 |
1570 | * @return Success/Failure of operation |
80f9611a |
1571 | */ |
be66ef34 |
1572 | gboolean |
1573 | lttv_filter_append_expression(LttvFilter* filter, const char *expression) { |
80f9611a |
1574 | |
56e29124 |
1575 | if(expression == NULL) return FALSE; |
da2e1bfb |
1576 | if(filter == NULL) return FALSE; |
0bc23ba9 |
1577 | if(expression[0] == '\0') return FALSE; /* Empty expression */ |
80f9611a |
1578 | |
da2e1bfb |
1579 | GString* s = g_string_new(""); |
1580 | if(filter->expression != NULL) { |
1581 | g_string_append(s,filter->expression); |
1582 | g_string_append_c(s,'&'); |
1583 | } |
1584 | g_string_append(s,expression); |
786c5c3b |
1585 | |
1586 | g_free(filter->expression); |
da2e1bfb |
1587 | filter->expression = g_string_free(s,FALSE); |
1588 | |
1589 | /* TRUE if construction of tree proceeded without errors */ |
56e29124 |
1590 | return lttv_filter_update(filter); |
80f9611a |
1591 | |
1592 | } |
1593 | |
1594 | /** |
56e29124 |
1595 | * @fn void lttv_filter_clear_expression(LttvFilter*) |
1596 | * |
80f9611a |
1597 | * Clear the filter expression from the |
1598 | * current filter and sets its pointer to NULL |
1599 | * @param filter pointer to the current LttvFilter |
1600 | */ |
be66ef34 |
1601 | void |
1602 | lttv_filter_clear_expression(LttvFilter* filter) { |
80f9611a |
1603 | |
1604 | if(filter->expression != NULL) { |
1605 | g_free(filter->expression); |
1606 | filter->expression = NULL; |
1607 | } |
1608 | |
1609 | } |
1610 | |
150f0d33 |
1611 | /** |
56e29124 |
1612 | * @fn void lttv_filter_tree_destroy(LttvFilterTree*) |
1613 | * |
150f0d33 |
1614 | * Destroys the tree and his sub-trees |
1615 | * @param tree Tree which must be destroyed |
1616 | */ |
5f185a2b |
1617 | void |
1618 | lttv_filter_tree_destroy(LttvFilterTree* tree) { |
56e29124 |
1619 | |
150f0d33 |
1620 | if(tree == NULL) return; |
1621 | |
56e29124 |
1622 | if(tree->left == LTTV_TREE_LEAF) lttv_simple_expression_destroy(tree->l_child.leaf); |
150f0d33 |
1623 | else if(tree->left == LTTV_TREE_NODE) lttv_filter_tree_destroy(tree->l_child.t); |
1624 | |
56e29124 |
1625 | if(tree->right == LTTV_TREE_LEAF) lttv_simple_expression_destroy(tree->r_child.leaf); |
150f0d33 |
1626 | else if(tree->right == LTTV_TREE_NODE) lttv_filter_tree_destroy(tree->r_child.t); |
1627 | |
e00d6a24 |
1628 | // g_free(tree->node); |
150f0d33 |
1629 | g_free(tree); |
1630 | } |
1631 | |
84a333d6 |
1632 | /** |
80f9611a |
1633 | * Global parsing function for the current |
1634 | * LttvFilterTree |
7e7af7f2 |
1635 | * @param t pointer to the current LttvFilterTree |
80f9611a |
1636 | * @param event current LttEvent, NULL if not used |
1637 | * @param tracefile current LttTracefile, NULL if not used |
1638 | * @param trace current LttTrace, NULL if not used |
1639 | * @param state current LttvProcessState, NULL if not used |
4d9ff942 |
1640 | * @param context current LttvTracefileContext, NULL if not used |
1641 | * @return response of filter |
84a333d6 |
1642 | */ |
31452f49 |
1643 | gboolean |
80f9611a |
1644 | lttv_filter_tree_parse( |
4d9ff942 |
1645 | const LttvFilterTree* t, |
1646 | const LttEvent* event, |
1647 | const LttTracefile* tracefile, |
1648 | const LttTrace* trace, |
4d9ff942 |
1649 | const LttvTracefileContext* context |
80f9611a |
1650 | /*,...*/) |
1651 | { |
0769c82f |
1652 | |
80f9611a |
1653 | /* |
1601b365 |
1654 | * Each tree is parsed in inorder. |
1655 | * This way, it's possible to apply the left filter of the |
1656 | * tree, then decide whether or not the right branch should |
1657 | * be parsed depending on the linking logical operator |
1658 | * |
80f9611a |
1659 | * Each node consists in a |
1660 | * 1. logical operator |
1661 | * 2. left child ( node or simple expression ) |
1662 | * 3. right child ( node or simple expression ) |
1663 | * |
1664 | * When the child is a simple expression, we must |
1665 | * before all determine if the expression refers to |
1666 | * a structure which is whithin observation ( not NULL ). |
1667 | * -If so, the expression is evaluated. |
1668 | * -If not, the result is set to TRUE since this particular |
1669 | * operation does not interfere with the lttv structure |
1670 | * |
1671 | * The result of each simple expression will directly |
1672 | * affect the next branch. This way, depending on |
1673 | * the linking logical operator, the parser will decide |
1674 | * to explore or not the next branch. |
1675 | * 1. AND OPERATOR |
1676 | * -If result of left branch is 0 / FALSE |
1677 | * then don't explore right branch and return 0; |
1678 | * -If result of left branch is 1 / TRUE then explore |
1679 | * 2. OR OPERATOR |
1680 | * -If result of left branch is 1 / TRUE |
1681 | * then don't explore right branch and return 1; |
1682 | * -If result of left branch is 0 / FALSE then explore |
1683 | * 3. XOR OPERATOR |
56e29124 |
1684 | * -Result of left branch will not affect exploration of |
80f9611a |
1685 | * right branch |
1601b365 |
1686 | */ |
73050a5f |
1687 | |
80f9611a |
1688 | gboolean lresult = FALSE, rresult = FALSE; |
33e44b82 |
1689 | |
1690 | LttvProcessState* state; |
1691 | |
6e0d58d6 |
1692 | guint cpu = ltt_tracefile_num(context->tf); |
1693 | LttvTraceState *ts = (LttvTraceState*)context->t_context; |
1694 | state = ts->running_process[cpu]; |
0769c82f |
1695 | |
80f9611a |
1696 | /* |
1697 | * Parse left branch |
1698 | */ |
4d9ff942 |
1699 | if(t->left == LTTV_TREE_NODE) { |
33e44b82 |
1700 | lresult = lttv_filter_tree_parse(t->l_child.t,event,tracefile,trace,context); |
4d9ff942 |
1701 | } |
5b729fcf |
1702 | else if(t->left == LTTV_TREE_LEAF) { |
4d9ff942 |
1703 | lresult = lttv_filter_tree_parse_branch(t->l_child.leaf,event,tracefile,trace,state,context); |
0cdc2470 |
1704 | } |
4d9ff942 |
1705 | |
80f9611a |
1706 | /* |
1707 | * Parse linking operator |
1708 | * make a cutoff if possible |
1709 | */ |
1710 | if((t->node & LTTV_LOGICAL_OR) && lresult == TRUE) return TRUE; |
1711 | if((t->node & LTTV_LOGICAL_AND) && lresult == FALSE) return FALSE; |
1712 | |
1713 | /* |
1714 | * Parse right branch |
1715 | */ |
4d9ff942 |
1716 | if(t->right == LTTV_TREE_NODE) { |
33e44b82 |
1717 | rresult = lttv_filter_tree_parse(t->r_child.t,event,tracefile,trace,context); |
4d9ff942 |
1718 | } |
5b729fcf |
1719 | else if(t->right == LTTV_TREE_LEAF) { |
4d9ff942 |
1720 | rresult = lttv_filter_tree_parse_branch(t->r_child.leaf,event,tracefile,trace,state,context); |
1721 | } |
2bdb97c5 |
1722 | |
2bdb97c5 |
1723 | |
4d9ff942 |
1724 | /* |
1725 | * Apply and return the |
1726 | * logical link between the |
1727 | * two operation |
1728 | */ |
1729 | switch(t->node) { |
1730 | case LTTV_LOGICAL_OR: return (lresult | rresult); |
1731 | case LTTV_LOGICAL_AND: return (lresult & rresult); |
72911c5d |
1732 | case LTTV_LOGICAL_NOT: |
1733 | return (t->left==LTTV_TREE_LEAF)?!lresult:((t->right==LTTV_TREE_LEAF)?!rresult:TRUE); |
4d9ff942 |
1734 | case LTTV_LOGICAL_XOR: return (lresult ^ rresult); |
1735 | case 0: return (rresult); |
1736 | default: |
1737 | /* |
1738 | * This case should never be |
1739 | * parsed, if so, this subtree |
1740 | * is cancelled ! |
1741 | */ |
1742 | return TRUE; |
1743 | } |
1744 | |
1745 | } |
1746 | |
1747 | /** |
4d9ff942 |
1748 | * This function parses a particular branch of the tree |
7e7af7f2 |
1749 | * @param se pointer to the current LttvSimpleExpression |
4d9ff942 |
1750 | * @param event current LttEvent, NULL if not used |
1751 | * @param tracefile current LttTracefile, NULL if not used |
1752 | * @param trace current LttTrace, NULL if not used |
1753 | * @param state current LttvProcessState, NULL if not used |
1754 | * @param context current LttvTracefileContext, NULL if not used |
1755 | * @return response of filter |
1756 | */ |
be66ef34 |
1757 | gboolean |
1758 | lttv_filter_tree_parse_branch( |
4d9ff942 |
1759 | const LttvSimpleExpression* se, |
1760 | const LttEvent* event, |
1761 | const LttTracefile* tracefile, |
1762 | const LttTrace* trace, |
1763 | const LttvProcessState* state, |
1764 | const LttvTracefileContext* context) { |
1765 | |
9ab5ebd7 |
1766 | LttvFieldValue v; |
4d9ff942 |
1767 | v = se->value; |
1768 | switch(se->field) { |
80f9611a |
1769 | case LTTV_FILTER_TRACE_NAME: |
4d9ff942 |
1770 | if(trace == NULL) return TRUE; |
c6832b57 |
1771 | else { |
eed2ef37 |
1772 | GQuark quark = ltt_trace_name(trace); |
c6832b57 |
1773 | return se->op((gpointer)&quark,v); |
1774 | } |
80f9611a |
1775 | break; |
1776 | case LTTV_FILTER_TRACEFILE_NAME: |
4d9ff942 |
1777 | if(tracefile == NULL) return TRUE; |
c6832b57 |
1778 | else { |
eed2ef37 |
1779 | GQuark quark = ltt_tracefile_name(tracefile); |
c6832b57 |
1780 | return se->op((gpointer)&quark,v); |
1781 | } |
80f9611a |
1782 | break; |
1783 | case LTTV_FILTER_STATE_PID: |
4d9ff942 |
1784 | if(state == NULL) return TRUE; |
1785 | else return se->op((gpointer)&state->pid,v); |
80f9611a |
1786 | break; |
1787 | case LTTV_FILTER_STATE_PPID: |
4d9ff942 |
1788 | if(state == NULL) return TRUE; |
1789 | else return se->op((gpointer)&state->ppid,v); |
80f9611a |
1790 | break; |
1791 | case LTTV_FILTER_STATE_CT: |
4d9ff942 |
1792 | if(state == NULL) return TRUE; |
80f9611a |
1793 | else { |
4d9ff942 |
1794 | return se->op((gpointer)&state->creation_time,v); |
80f9611a |
1795 | } |
1796 | break; |
1797 | case LTTV_FILTER_STATE_IT: |
4d9ff942 |
1798 | if(state == NULL) return TRUE; |
80f9611a |
1799 | else { |
4d9ff942 |
1800 | return se->op((gpointer)&state->insertion_time,v); |
80f9611a |
1801 | } |
1802 | break; |
1803 | case LTTV_FILTER_STATE_P_NAME: |
1804 | /* |
4d9ff942 |
1805 | * All 'unnamed' for the moment |
80f9611a |
1806 | */ |
4d9ff942 |
1807 | if(state == NULL) return TRUE; |
46c40a93 |
1808 | else { |
bbd9d557 |
1809 | GQuark quark = state->name; |
c6832b57 |
1810 | return se->op((gpointer)&quark,v); |
46c40a93 |
1811 | } |
80f9611a |
1812 | break; |
1813 | case LTTV_FILTER_STATE_EX_MODE: |
4d9ff942 |
1814 | if(state == NULL) return TRUE; |
1815 | else return se->op((gpointer)&state->state->t,v); |
80f9611a |
1816 | break; |
1817 | case LTTV_FILTER_STATE_EX_SUBMODE: |
4d9ff942 |
1818 | if(state == NULL) return TRUE; |
1819 | else return se->op((gpointer)&state->state->n,v); |
80f9611a |
1820 | break; |
1821 | case LTTV_FILTER_STATE_P_STATUS: |
4d9ff942 |
1822 | if(state == NULL) return TRUE; |
1823 | else return se->op((gpointer)&state->state->s,v); |
80f9611a |
1824 | break; |
1825 | case LTTV_FILTER_STATE_CPU: |
4d9ff942 |
1826 | if(context == NULL) return TRUE; |
46c40a93 |
1827 | else { |
348c6ba8 |
1828 | /* FIXME: not sure of that one Mathieu : fixed.*/ |
1829 | // GQuark quark = ((LttvTracefileState*)context)->cpu_name; |
1830 | // return se->op((gpointer)&quark,v); |
1831 | if(state == NULL) return TRUE; |
1832 | else return se->op((gpointer)&state->cpu,v); |
46c40a93 |
1833 | } |
80f9611a |
1834 | break; |
1835 | case LTTV_FILTER_EVENT_NAME: |
4d9ff942 |
1836 | if(event == NULL) return TRUE; |
1837 | else { |
46c40a93 |
1838 | LttEventType* et; |
1839 | et = ltt_event_eventtype(event); |
eed2ef37 |
1840 | GQuark quark = ltt_eventtype_name(et); |
c6832b57 |
1841 | return se->op((gpointer)&quark,v); |
4d9ff942 |
1842 | } |
1843 | break; |
1844 | |
80f9611a |
1845 | case LTTV_FILTER_EVENT_CATEGORY: |
1846 | /* |
c6832b57 |
1847 | * TODO: Not yet implemented |
80f9611a |
1848 | */ |
4d9ff942 |
1849 | return TRUE; |
80f9611a |
1850 | break; |
1851 | case LTTV_FILTER_EVENT_TIME: |
4d9ff942 |
1852 | if(event == NULL) return TRUE; |
46c40a93 |
1853 | else { |
1854 | LttTime time = ltt_event_time(event); |
4d9ff942 |
1855 | return se->op((gpointer)&time,v); |
46c40a93 |
1856 | } |
80f9611a |
1857 | break; |
1858 | case LTTV_FILTER_EVENT_TSC: |
bbd9d557 |
1859 | if(event == NULL) return TRUE; |
1860 | else { |
1861 | LttCycleCount count = ltt_event_cycle_count(event); |
1862 | return se->op((gpointer)&count,v); |
1863 | } |
80f9611a |
1864 | break; |
1865 | case LTTV_FILTER_EVENT_FIELD: |
1866 | /* |
1867 | * TODO: Use the offset to |
1868 | * find the dynamic field |
1869 | * in the event struct |
1870 | */ |
4d9ff942 |
1871 | return TRUE; |
80f9611a |
1872 | default: |
1873 | /* |
1874 | * This case should never be |
4d9ff942 |
1875 | * parsed, if so, the whole |
1876 | * filtering is cancelled |
80f9611a |
1877 | */ |
1878 | g_warning("Error while parsing the filter tree"); |
1879 | return TRUE; |
1880 | } |
4d9ff942 |
1881 | |
1882 | /* should never get here */ |
1883 | return TRUE; |
1884 | |
80f9611a |
1885 | } |
0769c82f |
1886 | |
4d9ff942 |
1887 | |
1888 | |
80f9611a |
1889 | /** |
7e7af7f2 |
1890 | * Debug function. Prints tree memory allocation. |
56e29124 |
1891 | * @param t the pointer to the current LttvFilterTree |
80f9611a |
1892 | */ |
1893 | void |
72911c5d |
1894 | lttv_print_tree(const LttvFilterTree* t, const int count) { |
0769c82f |
1895 | |
72911c5d |
1896 | g_print("node:%p lchild:%p rchild:%p depth:%i\n",t, //t->l_child.t,t->r_child.t); |
80f9611a |
1897 | (t->left==LTTV_TREE_NODE)?t->l_child.t:NULL, |
72911c5d |
1898 | (t->right==LTTV_TREE_NODE)?t->r_child.t:NULL, |
1899 | count); |
1900 | g_print("logic operator: %s\n",(t->node&1)?"OR":((t->node&2)?"AND":((t->node&4)?"NOT":((t->node&8)?"XOR":"IDLE")))); |
1901 | g_print("|-> left branch %p is a %s\n",t->l_child.t,(t->left==LTTV_TREE_NODE)?"NODE":((t->left==LTTV_TREE_LEAF)?"LEAF":"IDLE")); |
1902 | if(t->left == LTTV_TREE_LEAF) { |
1903 | g_print("| |-> field type number: %i\n",t->l_child.leaf->field); |
1904 | g_print("| |-> offset is: %i\n",t->l_child.leaf->offset); |
1905 | g_print("| |-> operator function is: %p\n",t->l_child.leaf->op); |
0769c82f |
1906 | } |
72911c5d |
1907 | g_print("|-> right branch %p is a %s\n",t->r_child.t,(t->right==LTTV_TREE_NODE)?"NODE":((t->right==LTTV_TREE_LEAF)?"LEAF":"IDLE")); |
1908 | if(t->right == LTTV_TREE_LEAF) { |
1909 | g_print("| |-> field type number: %i\n",t->r_child.leaf->field); |
1910 | g_print("| |-> offset is: %i\n",t->r_child.leaf->offset); |
1911 | g_print("| |-> operator function is: %p\n",t->r_child.leaf->op); |
80f9611a |
1912 | } |
72911c5d |
1913 | |
1914 | if(t->left == LTTV_TREE_NODE) lttv_print_tree(t->l_child.t,count+1); |
1915 | if(t->right == LTTV_TREE_NODE) lttv_print_tree(t->r_child.t,count+1); |
80f9611a |
1916 | } |
1917 | |
91ad3f0a |
1918 | /** |
56e29124 |
1919 | * @fn static void module_init() |
1920 | * |
91ad3f0a |
1921 | * Initializes the filter module and specific values |
1922 | */ |
1a7fa682 |
1923 | static void module_init() |
1924 | { |
91ad3f0a |
1925 | |
1a7fa682 |
1926 | } |
1927 | |
91ad3f0a |
1928 | /** |
7e7af7f2 |
1929 | * Destroys the filter module and specific values |
91ad3f0a |
1930 | */ |
1a7fa682 |
1931 | static void module_destroy() |
1932 | { |
56e29124 |
1933 | |
1a7fa682 |
1934 | } |
1935 | |
1936 | |
91ad3f0a |
1937 | LTTV_MODULE("filter", "Filters traceset and events", \ |
1938 | "Filters traceset and events specifically to user input", \ |
1a7fa682 |
1939 | module_init, module_destroy) |
1940 | |
1941 | |
1942 | |