commit 5d7a33f: [Minor] Add some missing types and docs to rspamd_lua_parse_table_arguments
Vsevolod Stakhov
vsevolod at highsecure.ru
Tue Apr 14 14:56:08 UTC 2020
Author: Vsevolod Stakhov
Date: 2020-04-14 15:25:34 +0100
URL: https://github.com/rspamd/rspamd/commit/5d7a33f313ec86598c38f40c535e77ce8eed4729
[Minor] Add some missing types and docs to rspamd_lua_parse_table_arguments
---
src/lua/lua_common.c | 32 ++++++++++++++++++++++++++++++++
src/lua/lua_common.h | 6 ++++--
2 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c
index 8a562f7b3..2be91140a 100644
--- a/src/lua/lua_common.c
+++ b/src/lua/lua_common.c
@@ -1449,6 +1449,38 @@ rspamd_lua_parse_table_arguments (lua_State *L, gint pos,
}
break;
+ case 'i':
+ if (t == LUA_TNUMBER) {
+ *(va_arg (ap, gint32 *)) = lua_tointeger (L, idx);
+ }
+ else if (t == LUA_TNIL || t == LUA_TNONE) {
+ failed = TRUE;
+ if (how != RSPAMD_LUA_PARSE_ARGUMENTS_IGNORE_MISSING) {
+ *(va_arg (ap, gint32 *)) = 0;
+ }
+ else {
+ (void)va_arg (ap, gint32 *);
+ }
+ }
+ else {
+ g_set_error (err,
+ lua_error_quark (),
+ 1,
+ "bad type for key:"
+ " %.*s: '%s', '%s' is expected",
+ (gint) keylen,
+ key,
+ lua_typename (L, lua_type (L, idx)),
+ "int64");
+ va_end (ap);
+
+ return FALSE;
+ }
+ if (is_table) {
+ lua_pop (L, 1);
+ }
+ break;
+
case 'F':
if (t == LUA_TFUNCTION) {
if (!is_table) {
diff --git a/src/lua/lua_common.h b/src/lua/lua_common.h
index 8252da004..5edec663b 100644
--- a/src/lua/lua_common.h
+++ b/src/lua/lua_common.h
@@ -411,18 +411,20 @@ enum rspamd_lua_parse_arguments_flags {
* [*]key=S|I|N|B|V|U{a-z};[key=...]
* - S - const char *
* - I - gint64_t
+ * - i - int32_t
* - N - double
- * - B - boolean
+ * - B - gboolean
* - V - size_t + const char *
* - U{classname} - userdata of the following class (stored in gpointer)
* - F - function
* - O - ucl_object_t *
+ * - D - same as N but argument is set to NAN not to 0.0
*
* If any of keys is prefixed with `*` then it is treated as required argument
* @param L lua state
* @param pos at which pos start extraction
* @param err error pointer
- * @param how extraction type
+ * @param how extraction type (IGNORE_MISSING means that default values will not be set)
* @param extraction_pattern static pattern
* @return TRUE if a table has been parsed
*/
More information about the Commits
mailing list