1245 |
1245 |
const char *field,
|
1246 |
1246 |
idmef_criterion_operator_t operator, idmef_criterion_value_t *value)
|
1247 |
1247 |
{
|
|
1248 |
int ret;
|
1248 |
1249 |
const void *vptr;
|
1249 |
1250 |
|
1250 |
1251 |
if ( operator == IDMEF_CRITERION_OPERATOR_NULL )
|
1251 |
1252 |
return prelude_string_sprintf(output, "%s IS NULL", field);
|
1252 |
1253 |
|
1253 |
|
if ( operator == IDMEF_CRITERION_OPERATOR_NOT_NULL )
|
|
1254 |
else if ( operator == IDMEF_CRITERION_OPERATOR_NOT_NULL )
|
1254 |
1255 |
return prelude_string_sprintf(output, "%s IS NOT NULL", field);
|
1255 |
1256 |
|
|
1257 |
else if ( operator & IDMEF_CRITERION_OPERATOR_NOT ) {
|
|
1258 |
ret = prelude_string_sprintf(output, "(%s IS NULL OR ", field);
|
|
1259 |
if ( ret < 0 )
|
|
1260 |
return ret;
|
|
1261 |
}
|
|
1262 |
|
1256 |
1263 |
vptr = idmef_criterion_value_get_value(value);
|
1257 |
1264 |
|
1258 |
1265 |
switch ( idmef_criterion_value_get_type(value) ) {
|
1259 |
1266 |
|
1260 |
1267 |
case IDMEF_CRITERION_VALUE_TYPE_VALUE:
|
1261 |
|
return build_criterion_fixed_value(sql, output, field, operator,
|
1262 |
|
idmef_criterion_value_get_value(value));
|
|
1268 |
ret = build_criterion_fixed_value(sql, output, field, operator,
|
|
1269 |
idmef_criterion_value_get_value(value));
|
|
1270 |
break;
|
1263 |
1271 |
|
1264 |
1272 |
case IDMEF_CRITERION_VALUE_TYPE_REGEX:
|
1265 |
|
return build_criterion_regex(sql, output, field, operator,
|
1266 |
|
idmef_criterion_value_get_regex(value));
|
1267 |
|
|
|
1273 |
ret = build_criterion_regex(sql, output, field, operator,
|
|
1274 |
idmef_criterion_value_get_regex(value));
|
|
1275 |
break;
|
|
1276 |
|
1268 |
1277 |
case IDMEF_CRITERION_VALUE_TYPE_BROKEN_DOWN_TIME:
|
1269 |
|
return build_criterion_broken_down_time(sql, output, field, operator,
|
1270 |
|
idmef_criterion_value_get_broken_down_time(value));
|
|
1278 |
ret = build_criterion_broken_down_time(sql, output, field, operator,
|
|
1279 |
idmef_criterion_value_get_broken_down_time(value));
|
|
1280 |
break;
|
1271 |
1281 |
|
1272 |
1282 |
default:
|
1273 |
|
/* nop */;
|
|
1283 |
ret = -1;
|
1274 |
1284 |
}
|
1275 |
|
|
1276 |
|
return -1;
|
|
1285 |
|
|
1286 |
if ( ret >= 0 && operator & IDMEF_CRITERION_OPERATOR_NOT )
|
|
1287 |
ret = prelude_string_sprintf(output, ")");
|
|
1288 |
|
|
1289 |
return ret;
|
1277 |
1290 |
}
|
1278 |
1291 |
|
1279 |
1292 |
|