diff options
author | João Valverde <j@v6e.pt> | 2023-12-08 12:40:39 +0000 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2023-12-08 15:44:07 +0000 |
commit | 0bcd2b6e6f296483c0272ceaa52d1b464d13d684 (patch) | |
tree | 26ae6aab06dd645949af35653a4b3615d542cee5 /epan/wslua | |
parent | 5f6b5c40f401ece3fbf4043fbf697feca4ce0f7c (diff) |
wslua: Add a scope field to lua plugin description
Diffstat (limited to 'epan/wslua')
-rw-r--r-- | epan/wslua/init_wslua.c | 31 | ||||
-rw-r--r-- | epan/wslua/init_wslua.h | 8 |
2 files changed, 21 insertions, 18 deletions
diff --git a/epan/wslua/init_wslua.c b/epan/wslua/init_wslua.c index 4e54c7e7f3..779a5f42e6 100644 --- a/epan/wslua/init_wslua.c +++ b/epan/wslua/init_wslua.c @@ -35,6 +35,7 @@ typedef struct _wslua_plugin { gchar *name; /**< plugin name */ gchar *version; /**< plugin version */ gchar *filename; /**< plugin filename */ + plugin_scope_e scope; /**< plugin scope */ struct _wslua_plugin *next; } wslua_plugin; @@ -549,7 +550,8 @@ static int error_handler_with_callback(lua_State *LS) { return 1; } -static void wslua_add_plugin(const gchar *name, const gchar *version, const gchar *filename) +static void wslua_add_plugin(const gchar *name, const gchar *version, + const gchar *filename, plugin_scope_e scope) { wslua_plugin *new_plug, *lua_plug; @@ -568,6 +570,7 @@ static void wslua_add_plugin(const gchar *name, const gchar *version, const gcha new_plug->name = g_strdup(name); new_plug->version = g_strdup(version); new_plug->filename = g_strdup(filename); + new_plug->scope = scope; new_plug->next = NULL; } @@ -731,11 +734,12 @@ static gboolean lua_load_internal_script(const gchar* filename) { static gboolean lua_load_plugin_script(const gchar* name, const gchar* filename, const gchar* dirname, + plugin_scope_e scope, const int file_count) { ws_debug("Loading lua script: %s", filename); if (lua_load_script(filename, dirname, file_count)) { - wslua_add_plugin(name, get_current_plugin_version(), filename); + wslua_add_plugin(name, get_current_plugin_version(), filename, scope); clear_current_plugin_version(); return TRUE; } @@ -834,7 +838,8 @@ static int lua_load_plugins(const char *dirname, register_cb cb, gpointer client if (!count_only) { if (cb) (*cb)(RA_LUA_PLUGINS, name, client_data); - lua_load_plugin_script(name, filename, is_user ? dirname : NULL, 0); + lua_load_plugin_script(name, filename, is_user ? dirname : NULL, + is_user ? WS_PLUGIN_SCOPE_USER : WS_PLUGIN_SCOPE_GLOBAL, 0); if (loaded_files) { g_hash_table_insert(loaded_files, g_strdup(name), NULL); @@ -892,22 +897,25 @@ int wslua_count_plugins(void) { return plugins_counter; } -void wslua_plugins_get_descriptions(wslua_plugin_description_callback callback, void *user_data) { +void wslua_plugins_get_descriptions(plugin_description_callback callback, void *user_data) { wslua_plugin *lua_plug; for (lua_plug = wslua_plugin_list; lua_plug != NULL; lua_plug = lua_plug->next) { - callback(lua_plug->name, lua_plug->version, wslua_plugin_type_name(), - lua_plug->filename, user_data); + callback(lua_plug->name, lua_plug->version, + 0 /* flags */, "" /* spdx */, "" /* blurb */, "" /* home_url */, + lua_plug->filename, lua_plug->scope, user_data); } } static void print_wslua_plugin_description(const char *name, const char *version, - const char *description, const char *filename, - void *user_data _U_) + uint32_t flags _U_, const char *spdx_id _U_, + const char *blurb _U_, const char *home_url _U_, + const char *filename, plugin_scope_e scope _U_, + void *user_data _U_) { - printf("%s\t%s\t%s\t%s\n", name, version, description, filename); + printf("%s\t%s\t%s\t%s\n", name, version, "lua script", filename); } void @@ -916,10 +924,6 @@ wslua_plugins_dump_all(void) wslua_plugins_get_descriptions(print_wslua_plugin_description, NULL); } -const char *wslua_plugin_type_name(void) { - return "lua script"; -} - static ei_register_info* ws_lua_ei = NULL; static int ws_lua_ei_len = 0; @@ -1680,6 +1684,7 @@ void wslua_init(register_cb cb, gpointer client_data) { lua_load_plugin_script(ws_dir_get_name(script_filename), script_filename, dname ? dname : "", + WS_PLUGIN_SCOPE_CLI, file_count); file_count++; g_free(dirname); diff --git a/epan/wslua/init_wslua.h b/epan/wslua/init_wslua.h index 5063076d42..6b4e332566 100644 --- a/epan/wslua/init_wslua.h +++ b/epan/wslua/init_wslua.h @@ -12,6 +12,8 @@ #include "ws_symbol_export.h" +#include <wsutil/plugins.h> + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -19,12 +21,8 @@ extern "C" { WS_DLL_PUBLIC int wslua_count_plugins(void); WS_DLL_PUBLIC void wslua_reload_plugins (register_cb cb, gpointer client_data); -typedef void (*wslua_plugin_description_callback)(const char *, const char *, - const char *, const char *, - void *); -WS_DLL_PUBLIC void wslua_plugins_get_descriptions(wslua_plugin_description_callback callback, void *user_data); +WS_DLL_PUBLIC void wslua_plugins_get_descriptions(plugin_description_callback callback, void *user_data); WS_DLL_PUBLIC void wslua_plugins_dump_all(void); -WS_DLL_PUBLIC const char *wslua_plugin_type_name(void); #ifdef __cplusplus } |