index 1bd0d5354e652656b891d0178cdf5030bf4992ec..a81cea45b5b6e5f52d5c6ba671f5b2ae42aa1e3c 100644 (file)
--- a/src/include/core/data.h
+++ b/src/include/core/data.h
#include <inttypes.h>
#include <stddef.h>
+#include <sys/types.h>
+#include <regex.h>
+
#ifdef __cplusplus
extern "C" {
#endif
SDB_TYPE_STRING,
SDB_TYPE_DATETIME,
SDB_TYPE_BINARY,
+ SDB_TYPE_REGEX,
};
#define SDB_TYPE_TO_STRING(t) \
- (((t) == SDB_TYPE_INTEGER) \
- ? "INTEGER" \
- : ((t) == SDB_TYPE_DECIMAL) \
- ? "DECIMAL" \
- : ((t) == SDB_TYPE_STRING) \
- ? "STRING" \
- : ((t) == SDB_TYPE_DATETIME) \
- ? "DATETIME" \
- : ((t) == SDB_TYPE_BINARY) \
- ? "BINARY" \
- : "UNKNOWN")
+ (((t) == SDB_TYPE_INTEGER) ? "INTEGER" \
+ : ((t) == SDB_TYPE_DECIMAL) ? "DECIMAL" \
+ : ((t) == SDB_TYPE_STRING) ? "STRING" \
+ : ((t) == SDB_TYPE_DATETIME) ? "DATETIME" \
+ : ((t) == SDB_TYPE_BINARY) ? "BINARY" \
+ : ((t) == SDB_TYPE_REGEX) ? "REGEX" : "UNKNOWN")
/*
* sdb_data_t:
size_t length;
unsigned char *datum;
} binary; /* SDB_TYPE_BINARY */
+ struct {
+ char *raw;
+ regex_t regex;
+ } re; /* SDB_TYPE_REGEX */
} data;
} sdb_data_t;
#define SDB_DATA_INIT { 0, { .integer = 0 } }
* specified as (floating point) number of seconds since the epoch. For string
* and binary data, the input string is passed to the datum. The function does
* not allocate new memory for that purpose. Use sdb_data_copy() if you want
- * to do that.
+ * to do that. For regex data, the input string is copied to newly allocated
+ * memory and also compiled to a regex. Use sdb_data_free_datum() to free the
+ * dynamically allocated memory.
*
* Returns:
* - 0 on success