diff options
author | Dhawal Arora <d.p.arora1@gmail.com> | 2015-04-24 10:50:53 +0530 |
---|---|---|
committer | Dhawal Arora <d.p.arora1@gmail.com> | 2015-04-24 10:50:53 +0530 |
commit | 334f20997377b3e6e1aa126446aa536a96e13b41 (patch) | |
tree | d8206461f542c3cf7e8926490377e139d6225365 /src/lua | |
parent | fed128523e71f89cb2222552cfbc7228ee5f89f6 (diff) | |
download | rspamd-334f20997377b3e6e1aa126446aa536a96e13b41.tar.gz rspamd-334f20997377b3e6e1aa126446aa536a96e13b41.zip |
minor syntax changes and pushed rspamd{url} to stack
Diffstat (limited to 'src/lua')
-rw-r--r-- | src/lua/lua_url.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/lua/lua_url.c b/src/lua/lua_url.c index 5c6eb4135..24658f1bc 100644 --- a/src/lua/lua_url.c +++ b/src/lua/lua_url.c @@ -375,31 +375,37 @@ static gint lua_url_all (lua_State *L) { struct rspamd_url *url; + struct rspamd_lua_url *lua_url; rspamd_mempool_t *pool = rspamd_lua_check_mempool (L, 1); const gchar *text,*end; - gint length,i; + gint i = 1; + size_t length; const gchar **pos; if (pool == NULL) { lua_pushnil (L); } else { - text = luaL_checkstring (L, 2); + text = luaL_checklstring (L, 2, &length); if (text != NULL) { - length = strlen(text); - *pos=text; - end=text+length; - lua_newtable(L); - while(*pos<=end){ + *pos = text; + end = text + length; + lua_newtable (L); + + while (*pos <= end) { url = rspamd_url_get_next (pool, text, pos, NULL); - if (url!=NULL) { - lua_pushinteger (L, i); + if (url != NULL) { + lua_url = lua_newuserdata (L, sizeof (struct rspamd_lua_url)); + rspamd_lua_setclass (L, "rspamd{url}", -1); + lua_url->url = url; + lua_pushinteger (L, i++); lua_pushlstring (L, url->string, url->urllen); lua_settable (L, -3); } - i++; + else + break; } } |