aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_common.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-07-01 11:08:43 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-07-01 11:08:43 +0100
commit6bd388ae930900bef74532f810c4411650761868 (patch)
treebb164cd166ae1a43c2c7214d6961f0acda622ec8 /src/lua/lua_common.c
parent083e6ac5ce374e1e9759c7998dd04b9525333eb4 (diff)
downloadrspamd-6bd388ae930900bef74532f810c4411650761868.tar.gz
rspamd-6bd388ae930900bef74532f810c4411650761868.zip
[Minor] Add flags for rspamd_lua_parse_table_arguments
Diffstat (limited to 'src/lua/lua_common.c')
-rw-r--r--src/lua/lua_common.c51
1 files changed, 40 insertions, 11 deletions
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c
index 785042b8e..354a932f9 100644
--- a/src/lua/lua_common.c
+++ b/src/lua/lua_common.c
@@ -1238,7 +1238,9 @@ rspamd_lua_add_preload (lua_State *L, const gchar *name, lua_CFunction func)
gboolean
rspamd_lua_parse_table_arguments (lua_State *L, gint pos,
- GError **err, const gchar *extraction_pattern, ...)
+ GError **err,
+ enum rspamd_lua_parse_arguments_flags how,
+ const gchar *extraction_pattern, ...)
{
const gchar *p, *key = NULL, *end, *cls;
va_list ap;
@@ -1314,7 +1316,10 @@ rspamd_lua_parse_table_arguments (lua_State *L, gint pos,
}
else if (t == LUA_TNIL || t == LUA_TNONE) {
failed = TRUE;
- *(va_arg (ap, const gchar **)) = NULL;
+
+ if (how != RSPAMD_LUA_PARSE_ARGUMENTS_IGNORE_MISSING) {
+ *(va_arg (ap, const gchar **)) = NULL;
+ }
}
else {
g_set_error (err,
@@ -1341,7 +1346,9 @@ rspamd_lua_parse_table_arguments (lua_State *L, gint pos,
}
else if (t == LUA_TNIL || t == LUA_TNONE) {
failed = TRUE;
- *(va_arg (ap, gint64 *)) = 0;
+ if (how != RSPAMD_LUA_PARSE_ARGUMENTS_IGNORE_MISSING) {
+ *(va_arg (ap, gint64 *)) = 0;
+ }
}
else {
g_set_error (err,
@@ -1372,7 +1379,11 @@ rspamd_lua_parse_table_arguments (lua_State *L, gint pos,
}
else if (t == LUA_TNIL || t == LUA_TNONE) {
failed = TRUE;
- *(va_arg (ap, gint *)) = -1;
+
+ if (how != RSPAMD_LUA_PARSE_ARGUMENTS_IGNORE_MISSING) {
+ *(va_arg (ap, gint *)) = -1;
+ }
+
if (is_table) {
lua_pop (L, 1);
}
@@ -1404,7 +1415,10 @@ rspamd_lua_parse_table_arguments (lua_State *L, gint pos,
}
else if (t == LUA_TNIL || t == LUA_TNONE) {
failed = TRUE;
- *(va_arg (ap, gboolean *)) = 0;
+
+ if (how != RSPAMD_LUA_PARSE_ARGUMENTS_IGNORE_MISSING) {
+ *(va_arg (ap, gboolean *)) = 0;
+ }
}
else {
g_set_error (err,
@@ -1432,7 +1446,10 @@ rspamd_lua_parse_table_arguments (lua_State *L, gint pos,
}
else if (t == LUA_TNIL || t == LUA_TNONE) {
failed = TRUE;
- *(va_arg (ap, gdouble *)) = 0;
+
+ if (how != RSPAMD_LUA_PARSE_ARGUMENTS_IGNORE_MISSING) {
+ *(va_arg (ap, gdouble *)) = 0;
+ }
}
else {
g_set_error (err,
@@ -1460,7 +1477,10 @@ rspamd_lua_parse_table_arguments (lua_State *L, gint pos,
}
else if (t == LUA_TNIL || t == LUA_TNONE) {
failed = TRUE;
- *(va_arg (ap, gdouble *)) = NAN;
+
+ if (how != RSPAMD_LUA_PARSE_ARGUMENTS_IGNORE_MISSING) {
+ *(va_arg (ap, gdouble *)) = NAN;
+ }
}
else {
g_set_error (err,
@@ -1491,8 +1511,11 @@ rspamd_lua_parse_table_arguments (lua_State *L, gint pos,
}
else if (t == LUA_TNIL || t == LUA_TNONE) {
failed = TRUE;
- *(va_arg (ap, const char **)) = NULL;
- *valuelen = 0;
+
+ if (how != RSPAMD_LUA_PARSE_ARGUMENTS_IGNORE_MISSING) {
+ *(va_arg (ap, const char **)) = NULL;
+ *valuelen = 0;
+ }
}
else {
g_set_error (err,
@@ -1520,7 +1543,10 @@ rspamd_lua_parse_table_arguments (lua_State *L, gint pos,
}
else {
failed = TRUE;
- *(va_arg (ap, ucl_object_t **)) = NULL;
+
+ if (how != RSPAMD_LUA_PARSE_ARGUMENTS_IGNORE_MISSING) {
+ *(va_arg (ap, ucl_object_t **)) = NULL;
+ }
}
if (is_table) {
@@ -1530,7 +1556,10 @@ rspamd_lua_parse_table_arguments (lua_State *L, gint pos,
case 'U':
if (t == LUA_TNIL || t == LUA_TNONE) {
failed = TRUE;
- *(va_arg (ap, void **)) = NULL;
+
+ if (how != RSPAMD_LUA_PARSE_ARGUMENTS_IGNORE_MISSING) {
+ *(va_arg (ap, void **)) = NULL;
+ }
}
else if (t != LUA_TUSERDATA) {
g_set_error (err,