diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-01-12 21:27:30 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-01-12 21:27:30 +0000 |
commit | 07bb08245320b20c81df9c50cfeabb3baffbd935 (patch) | |
tree | 9cb41033fad48074f089023ac95e23fc99369ab6 /src/lua | |
parent | a9fed83b41d13c360767818d63ff891d216f2691 (diff) | |
download | rspamd-07bb08245320b20c81df9c50cfeabb3baffbd935.tar.gz rspamd-07bb08245320b20c81df9c50cfeabb3baffbd935.zip |
[Minor] Start arrays support in xmlrpc output
Diffstat (limited to 'src/lua')
-rw-r--r-- | src/lua/lua_xmlrpc.c | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/src/lua/lua_xmlrpc.c b/src/lua/lua_xmlrpc.c index 27d944712..01850af70 100644 --- a/src/lua/lua_xmlrpc.c +++ b/src/lua/lua_xmlrpc.c @@ -132,6 +132,12 @@ xmlrpc_start_element (GMarkupParseContext *context, lua_newtable (ud->L); ud->depth++; } + else if (g_ascii_strcasecmp (name, "array") == 0) { + ud->parser_state = 14; + /* Create new param of table type */ + lua_newtable (ud->L); + ud->depth++; + } else if (g_ascii_strcasecmp (name, "string") == 0) { ud->parser_state = 11; ud->got_text = FALSE; @@ -202,6 +208,66 @@ xmlrpc_start_element (GMarkupParseContext *context, lua_newtable (ud->L); ud->depth++; } + else if (g_ascii_strcasecmp (name, "array") == 0) { + ud->parser_state = 14; + /* Create new param of table type */ + lua_newtable (ud->L); + ud->depth++; + } + else { + /* Error state */ + ud->parser_state = 99; + } + break; + case 14: + /* Parse array */ + /* Expect data */ + if (g_ascii_strcasecmp (name, "data") == 0) { + ud->parser_state = 15; + } + else { + /* Error state */ + ud->parser_state = 99; + } + break; + case 15: + /* Accept array value */ + if (g_ascii_strcasecmp (name, "value") == 0) { + ud->parser_state = 16; + } + else { + /* Error state */ + ud->parser_state = 99; + } + break; + case 16: + /* Parse any values */ + /* Primitives */ + if (g_ascii_strcasecmp (name, "string") == 0) { + ud->parser_state = 11; + ud->got_text = FALSE; + } + else if (g_ascii_strcasecmp (name, "int") == 0) { + ud->parser_state = 12; + ud->got_text = FALSE; + } + else if (g_ascii_strcasecmp (name, "double") == 0) { + ud->parser_state = 13; + ud->got_text = FALSE; + } + /* Structure */ + else if (g_ascii_strcasecmp (name, "struct") == 0) { + ud->parser_state = 5; + /* Create new param of table type */ + lua_newtable (ud->L); + ud->depth++; + } + else if (g_ascii_strcasecmp (name, "array") == 0) { + ud->parser_state = 14; + /* Create new param of table type */ + lua_newtable (ud->L); + ud->depth++; + } else { /* Error state */ ud->parser_state = 99; @@ -348,6 +414,39 @@ xmlrpc_end_element (GMarkupParseContext *context, ud->parser_state = 99; } break; + case 14: + /* Got tag array */ + if (g_ascii_strcasecmp (name, "array") == 0) { + ud->parser_state = 4; + ud->depth--; + } + else { + /* Error state */ + ud->parser_state = 99; + } + break; + case 15: + /* Got tag data */ + if (g_ascii_strcasecmp (name, "data") == 0) { + ud->parser_state = 14; + } + else { + /* Error state */ + ud->parser_state = 99; + } + break; + case 17: + /* Got tag value */ + if (g_ascii_strcasecmp (name, "value") == 0) { + guint tbl_len = rspamd_lua_table_size (ud->L, -2); + lua_rawseti (ud->L, -2, tbl_len + 1); + ud->parser_state = 15; + } + else { + /* Error state */ + ud->parser_state = 99; + } + break; } if (ud->parser_state == 99) { |