%{
#include "lib.h"
+#include "str-parse.h"
#include "wildcard-match.h"
#include "lib-event-private.h"
#include "event-filter-private.h"
/* Filter currently supports only comparing strings
and numbers. */
- if (str_to_intmax(b, &node->field.value.intmax) < 0) {
- /* not a number - no problem
- Either we have a string, or a number with wildcards */
- node->field.value.intmax = INT_MIN;
- } else {
- /* leave a hint that this is in fact a valid number */
+ if (str_to_intmax(b, &node->field.value.intmax) == 0) {
+ /* Leave a hint that this is in fact a valid number. */
node->field.value_type = EVENT_FIELD_VALUE_TYPE_INTMAX;
+ } else {
+ /* This field contains no valid number.
+ Either this is a string that contains a size unit, a
+ number with wildcard or another arbitrary string. */
+ node->field.value.intmax = INT_MIN;
+
+ /* If the field contains a size unit, take that. */
+ uoff_t bytes;
+ const char *error;
+ int ret = str_parse_get_size(b, &bytes, &error);
+ if (ret == 0 && bytes <= INTMAX_MAX) {
+ node->field.value.intmax = (intmax_t) bytes;
+ node->field.value_type = EVENT_FIELD_VALUE_TYPE_INTMAX;
+ }
}
if (wildcard_is_literal(node->field.value.str))