summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a3dc4c5)
raw | patch | inline | side by side (parent: a3dc4c5)
author | Sebastian Harl <sh@tokkee.org> | |
Tue, 8 Jul 2014 19:42:45 +0000 (21:42 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Tue, 8 Jul 2014 19:42:45 +0000 (21:42 +0200) |
src/core/data.c | patch | blob | history | |
src/include/sysdb.h.in | patch | blob | history |
diff --git a/src/core/data.c b/src/core/data.c
index 47c54cc41e5b3e8ed881747c50f28b9a41125410..2381636092ceb03b7d4ef25ae8c9935ec3300583 100644 (file)
--- a/src/core/data.c
+++ b/src/core/data.c
# include "config.h"
#endif /* HAVE_CONFIG_H */
+#include "sysdb.h"
+
#include "core/data.h"
#include "utils/error.h"
if (d1->type != d2->type)
return -1;
-#define CMP(a, b) ((a) < (b) ? -1 : (a) > (b) ? 1 : 0)
switch (d1->type) {
case SDB_TYPE_INTEGER:
- return CMP(d1->data.integer, d2->data.integer);
+ return SDB_CMP(d1->data.integer, d2->data.integer);
case SDB_TYPE_DECIMAL:
- return CMP(d1->data.decimal, d2->data.decimal);
+ return SDB_CMP(d1->data.decimal, d2->data.decimal);
case SDB_TYPE_STRING:
CMP_NULL(d1->data.string, d2->data.string);
return strcasecmp(d1->data.string, d2->data.string);
case SDB_TYPE_DATETIME:
- return CMP(d1->data.datetime, d2->data.datetime);
+ return SDB_CMP(d1->data.datetime, d2->data.datetime);
case SDB_TYPE_BINARY:
{
int diff;
default:
return -1;
}
-#undef CMP
#undef CMP_NULL
} /* sdb_data_cmp */
diff --git a/src/include/sysdb.h.in b/src/include/sysdb.h.in
index 67666412416d703450d87fc7a52f0231cba0f37a..7bd2ad95c26f6ee19f9dfdc2bdce2acd555483a7 100644 (file)
--- a/src/include/sysdb.h.in
+++ b/src/include/sysdb.h.in
#define SDB_STATIC_ARRAY_LEN(a) (sizeof((a)) / sizeof((a)[0]))
+#define SDB_MIN(a, b) ((a) <= (b) ? (a) : (b))
+#define SDB_MAX(a, b) ((a) >= (b) ? (a) : (b))
+
+#define SDB_CMP(a, b) ((a) < (b) ? -1 : (a) > (b) ? 1 : 0)
+
#ifdef __cplusplus
extern "C" {
#endif