aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2013-08-31 14:31:36 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2013-08-31 14:31:36 +0100
commit89281e03aee94e205619c57790687d8af568ecc9 (patch)
tree8cc2bd49108c3ec1a27ecdd511799fda3dae87d1
parent9ad8f568037eadb2c610e70c22709c58db0bcf91 (diff)
downloadrspamd-89281e03aee94e205619c57790687d8af568ecc9.tar.gz
rspamd-89281e03aee94e205619c57790687d8af568ecc9.zip
Use flags instead of size for integers.
-rw-r--r--src/cfg_rcl.c22
-rw-r--r--src/cfg_rcl.h6
2 files changed, 13 insertions, 15 deletions
diff --git a/src/cfg_rcl.c b/src/cfg_rcl.c
index 4b11bea4e..562b734f5 100644
--- a/src/cfg_rcl.c
+++ b/src/cfg_rcl.c
@@ -340,15 +340,7 @@ rspamd_rcl_parse_struct_integer (struct config_file *cfg, rspamd_cl_object_t *ob
} target;
gint64 val;
- if (pd->size == sizeof (gint)) {
- target.ip = (gint *)(((gchar *)pd->user_struct) + pd->offset);
- if (!rspamd_cl_obj_toint_safe (obj, &val)) {
- g_set_error (err, CFG_RCL_ERROR, EINVAL, "cannot convert param to integer");
- return FALSE;
- }
- *target.ip = val;
- }
- else if (pd->size == sizeof (gint32)) {
+ if (pd->flags == RSPAMD_CL_FLAG_INT_32) {
target.i32p = (gint32 *)(((gchar *)pd->user_struct) + pd->offset);
if (!rspamd_cl_obj_toint_safe (obj, &val)) {
g_set_error (err, CFG_RCL_ERROR, EINVAL, "cannot convert param to integer");
@@ -356,7 +348,7 @@ rspamd_rcl_parse_struct_integer (struct config_file *cfg, rspamd_cl_object_t *ob
}
*target.i32p = val;
}
- else if (pd->size == sizeof (gint16)) {
+ else if (pd->flags == RSPAMD_CL_FLAG_INT_16) {
target.i16p = (gint16 *)(((gchar *)pd->user_struct) + pd->offset);
if (!rspamd_cl_obj_toint_safe (obj, &val)) {
g_set_error (err, CFG_RCL_ERROR, EINVAL, "cannot convert param to integer");
@@ -364,7 +356,7 @@ rspamd_rcl_parse_struct_integer (struct config_file *cfg, rspamd_cl_object_t *ob
}
*target.i16p = val;
}
- else if (pd->size == sizeof (gint64)) {
+ else if (pd->flags == RSPAMD_CL_FLAG_INT_64) {
target.i64p = (gint64 *)(((gchar *)pd->user_struct) + pd->offset);
if (!rspamd_cl_obj_toint_safe (obj, &val)) {
g_set_error (err, CFG_RCL_ERROR, EINVAL, "cannot convert param to integer");
@@ -373,8 +365,12 @@ rspamd_rcl_parse_struct_integer (struct config_file *cfg, rspamd_cl_object_t *ob
*target.i64p = val;
}
else {
- g_set_error (err, CFG_RCL_ERROR, E2BIG, "unknown integer size");
- return FALSE;
+ target.ip = (gint *)(((gchar *)pd->user_struct) + pd->offset);
+ if (!rspamd_cl_obj_toint_safe (obj, &val)) {
+ g_set_error (err, CFG_RCL_ERROR, EINVAL, "cannot convert param to integer");
+ return FALSE;
+ }
+ *target.ip = val;
}
return TRUE;
diff --git a/src/cfg_rcl.h b/src/cfg_rcl.h
index f90bfc399..afe27d480 100644
--- a/src/cfg_rcl.h
+++ b/src/cfg_rcl.h
@@ -40,12 +40,14 @@ struct rspamd_rcl_section;
struct rspamd_rcl_struct_parser {
gpointer user_struct;
goffset offset;
- gsize size;
enum {
RSPAMD_CL_FLAG_TIME_FLOAT = 0x1 << 0,
RSPAMD_CL_FLAG_TIME_TIMEVAL = 0x1 << 1,
RSPAMD_CL_FLAG_TIME_TIMESPEC = 0x1 << 2,
- RSPAMD_CL_FLAG_TIME_INTEGER = 0x1 << 3
+ RSPAMD_CL_FLAG_TIME_INTEGER = 0x1 << 3,
+ RSPAMD_CL_FLAG_INT_16 = 0x1 << 4,
+ RSPAMD_CL_FLAG_INT_32 = 0x1 << 5,
+ RSPAMD_CL_FLAG_INT_64 = 0x1 << 6
} flags;
};