aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-03-12 14:37:58 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-03-12 14:37:58 +0000
commiteecfe4ea3aca90f90f3db562b5a8b38c310ec816 (patch)
tree864e9775c67ea41a3a8b82c98f46540bf99de8a2
parentb5e4fce1f3297a4a05b09163b844f0990ea3d455 (diff)
downloadrspamd-eecfe4ea3aca90f90f3db562b5a8b38c310ec816.tar.gz
rspamd-eecfe4ea3aca90f90f3db562b5a8b38c310ec816.zip
[Feature] Add map:get_uri method
-rw-r--r--src/lua/lua_map.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/lua/lua_map.c b/src/lua/lua_map.c
index df8e60fb1..0f8b077bf 100644
--- a/src/lua/lua_map.c
+++ b/src/lua/lua_map.c
@@ -79,6 +79,13 @@ LUA_FUNCTION_DEF (map, set_sign_key);
*/
LUA_FUNCTION_DEF (map, set_callback);
+/***
+ * @method map:get_uri()
+ * Get uri for a specified map
+ * @return {string} map's URI
+ */
+LUA_FUNCTION_DEF (map, get_uri);
+
static const struct luaL_reg maplib_m[] = {
LUA_INTERFACE_DEF (map, get_key),
LUA_INTERFACE_DEF (map, is_signed),
@@ -86,6 +93,7 @@ static const struct luaL_reg maplib_m[] = {
LUA_INTERFACE_DEF (map, get_sign_key),
LUA_INTERFACE_DEF (map, set_sign_key),
LUA_INTERFACE_DEF (map, set_callback),
+ LUA_INTERFACE_DEF (map, get_uri),
{"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -629,6 +637,28 @@ lua_map_set_callback (lua_State *L)
return 0;
}
+static int
+lua_map_get_uri (lua_State *L)
+{
+ struct rspamd_lua_map *map = lua_check_map (L);
+ const gchar *ret = "undefined";
+
+ if (map != NULL) {
+ if (map->map == NULL) {
+ ret = "embedded";
+ }
+ else {
+ ret = map->map->uri;
+ }
+ }
+ else {
+ return luaL_error (L, "invalid arguments");
+ }
+
+ lua_pushstring (L, ret);
+ return 1;
+}
+
void
luaopen_map (lua_State * L)
{