se->field = LTTV_FILTER_UNDEFINED;
se->op = NULL;
se->offset = 0;
-// se->value.v_uint64 = 0;
return se;
}
case LTTV_FILTER_EVENT_NAME:
switch(op) {
case LTTV_FIELD_EQ:
- se->op = lttv_apply_op_eq_string;
+ se->op = lttv_apply_op_eq_quark;
break;
case LTTV_FIELD_NE:
- se->op = lttv_apply_op_ne_string;
+ se->op = lttv_apply_op_ne_quark;
break;
default:
g_warning("Error encountered in operator assignment = or != expected");
// g_print("se->value:%s\n",value);
unsigned i;
gboolean is_double = FALSE;
- LttTime t;
- GString* v;
+ LttTime t = ltt_time_zero;
+ GString* v;
+ GQuark quark;
switch(se->field) {
/*
- * string
+ * string --> g_quark
*/
case LTTV_FILTER_TRACE_NAME:
case LTTV_FILTER_TRACEFILE_NAME:
case LTTV_FILTER_STATE_P_NAME:
case LTTV_FILTER_EVENT_NAME:
- se->value.v_string = value;
+// se->value.v_string = value;
+ se->value.v_uint32 = g_quark_try_string(value);
+ g_free(value);
break;
/*
* integer
}
/* number can be integer or double */
if(is_double) t.tv_nsec = atoi(v);
- else t.tv_nsec = 0;
+ else t.tv_sec = atoi(v);
+
g_string_free(v,TRUE);
se->value.v_ltttime = t;
break;
default:
g_warning("Error encountered in value assignation ! Field type = %i",se->field);
+ g_free(value);
return FALSE;
}
return (!g_strcasecmp(r,v2.v_string));
}
+/**
+ * @fn gboolean lttv_apply_op_eq_quark(const gpointer,LttvFieldValue)
+ *
+ * Applies the 'equal' operator to the
+ * specified structure and value
+ * @param v1 left member of comparison
+ * @param v2 right member of comparison
+ * @return success/failure of operation
+ */
+gboolean lttv_apply_op_eq_quark(const gpointer v1, LttvFieldValue v2) {
+ GQuark* r = (GQuark*) v1;
+ g_print("v1:%i v2:%i\n",*r,v2.v_uint32);
+ return (*r == v2.v_uint32);
+}
+
/**
* @fn gboolean lttv_apply_op_eq_ltttime(const gpointer,LttvFieldValue)
*
*/
gboolean lttv_apply_op_eq_ltttime(const gpointer v1, LttvFieldValue v2) {
LttTime* r = (LttTime*) v1;
- return ((r->tv_sec == v2.v_ltttime.tv_sec) && (r->tv_nsec == v2.v_ltttime.tv_nsec));
+// return ((r->tv_sec == v2.v_ltttime.tv_sec) && (r->tv_nsec == v2.v_ltttime.tv_nsec));
+ return ltt_time_compare(*r, v2.v_ltttime)==0?1:0;
}
return (g_strcasecmp(r,v2.v_string));
}
+/**
+ * @fn gboolean lttv_apply_op_ne_quark(const gpointer,LttvFieldValue)
+ *
+ * Applies the 'not equal' operator to the
+ * specified structure and value
+ * @param v1 left member of comparison
+ * @param v2 right member of comparison
+ * @return success/failure of operation
+ */
+gboolean lttv_apply_op_ne_quark(const gpointer v1, LttvFieldValue v2) {
+ GQuark* r = (GQuark*) v1;
+ return (*r != v2.v_uint32);
+}
+
+
/**
* @fn gboolean lttv_apply_op_ne_ltttime(const gpointer,LttvFieldValue)
*
*/
gboolean lttv_apply_op_lt_ltttime(const gpointer v1, LttvFieldValue v2) {
LttTime* r = (LttTime*) v1;
- 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)));
+// 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)));
+ return ltt_time_compare(*r, v2.v_ltttime)==-1?1:0;
}
*/
gboolean lttv_apply_op_le_ltttime(const gpointer v1, LttvFieldValue v2) {
LttTime* r = (LttTime*) v1;
- 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)));
+// 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)));
+ return ltt_time_compare(*r, v2.v_ltttime)<1?1:0;
}
*/
gboolean lttv_apply_op_gt_ltttime(const gpointer v1, LttvFieldValue v2) {
LttTime* r = (LttTime*) v1;
- 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)));
+// 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)));
+ return ltt_time_compare(*r, v2.v_ltttime)==1?1:0;
}
*/
gboolean lttv_apply_op_ge_ltttime(const gpointer v1, LttvFieldValue v2) {
LttTime* r = (LttTime*) v1;
- 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)));
+// 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)));
+ return ltt_time_compare(*r, v2.v_ltttime)>-1?1:0;
}
switch(se->field) {
case LTTV_FILTER_TRACE_NAME:
if(trace == NULL) return TRUE;
- else return se->op((gpointer)ltt_trace_name(trace),v);
+ else {
+ GQuark quark = g_quark_try_string(ltt_trace_name(trace));
+ return se->op((gpointer)&quark,v);
+ }
break;
case LTTV_FILTER_TRACEFILE_NAME:
if(tracefile == NULL) return TRUE;
- else return se->op((gpointer)ltt_tracefile_name(tracefile),v);
+ else {
+ GQuark quark = g_quark_try_string(ltt_tracefile_name(tracefile));
+ return se->op((gpointer)&quark,v);
+ }
break;
case LTTV_FILTER_STATE_PID:
if(state == NULL) return TRUE;
*/
if(state == NULL) return TRUE;
else {
- return se->op((gpointer)g_quark_to_string(state->name),v);
+ GQuark quark = g_quark_try_string(state->name);
+ return se->op((gpointer)&quark,v);
}
break;
case LTTV_FILTER_STATE_EX_MODE:
case LTTV_FILTER_STATE_CPU:
if(context == NULL) return TRUE;
else {
- return se->op((gpointer)g_quark_to_string(((LttvTracefileState*)context)->cpu_name),v);
+ /* FIXME: not sure of that one */
+ return se->op((gpointer)g_quark_try_string(((LttvTracefileState*)context)->cpu_name),v);
}
break;
case LTTV_FILTER_EVENT_NAME:
else {
LttEventType* et;
et = ltt_event_eventtype(event);
- return se->op((gpointer)ltt_eventtype_name(et),v);
+ g_print("v:%s\n",ltt_eventtype_name(et));
+ GQuark quark = g_quark_try_string(ltt_eventtype_name(et));
+ return se->op((gpointer)&quark,v);
}
break;
case LTTV_FILTER_EVENT_CATEGORY:
/*
- * FIXME: Not yet implemented
+ * TODO: Not yet implemented
*/
return TRUE;
break;