Lua: Switch from disable_lua to enable_lua.
Deprecate "disable_lua" in favor of "enable_lua". Configuration options typically use "true" or a similar value to enable features. Using "disable_lua = false" to enable Lua seems odd. Change-Id: I224acad0559d409ea0a28b5555d1eb898564328c Reviewed-on: https://code.wireshark.org/review/28773 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
381ea0973f
commit
61dd06ed9f
|
@ -20,21 +20,23 @@ the Department of Computer Science.
|
||||||
In Wireshark Lua can be used to write dissectors, taps, and capture file readers
|
In Wireshark Lua can be used to write dissectors, taps, and capture file readers
|
||||||
and writers.
|
and writers.
|
||||||
|
|
||||||
Wireshark’s Lua interpreter starts by loading `init.lua` that is located in the
|
Wireshark’s Lua interpreter starts by loading a file named `init.lua` in
|
||||||
global configuration directory of Wireshark. Lua is enabled by default. To
|
Wireshark's global configuration directory. It is enabled by default. To
|
||||||
disable Lua the line variable _$$disable_lua$$_ should be set to _true_ in
|
disable Lua the line variable _$$enable_lua$$_ should be set to _false_
|
||||||
`init.lua`.
|
in _init.lua_. Wireshark 2.6 and earlier enabled and disabled Lua using
|
||||||
|
the variable _$$disable_lua$$_. It is still supported, but is deprecated
|
||||||
|
and support may be removed in a future release. _$$enable_lua$$_ takes
|
||||||
|
precedence over _$$disable_lua$$_.
|
||||||
|
|
||||||
After loading _init.lua_ from the data directory if Lua is enabled Wireshark
|
If Lua is enabled Wireshark will then try to load a file named _init.lua_
|
||||||
will try to load a file named `init.lua` in the user’s directory.
|
in the user’s personal configuration directory. Wireshark will also load
|
||||||
|
all files with a _.lua_ suffix from both the global and the personal
|
||||||
Wireshark will also load all files with `.lua` suffix from both the global and
|
plugins directory.
|
||||||
the personal plugins directory.
|
|
||||||
|
|
||||||
The command line option _$$-X lua_script:$$++file.lua++_ can be used to load
|
The command line option _$$-X lua_script:$$++file.lua++_ can be used to load
|
||||||
Lua scripts as well.
|
Lua scripts as well.
|
||||||
|
|
||||||
The Lua code will be executed once after all the protocol dissectors have being
|
The Lua code will be executed once after all the protocol dissectors have been
|
||||||
initialized and before reading any file.
|
initialized and before reading any file.
|
||||||
|
|
||||||
[[wslua_dissector_example]]
|
[[wslua_dissector_example]]
|
||||||
|
|
|
@ -767,6 +767,7 @@ wslua_allocf(void *ud _U_, void *ptr, size_t osize _U_, size_t nsize)
|
||||||
void wslua_init(register_cb cb, gpointer client_data) {
|
void wslua_init(register_cb cb, gpointer client_data) {
|
||||||
gchar* filename;
|
gchar* filename;
|
||||||
const funnel_ops_t* ops = funnel_get_funnel_ops();
|
const funnel_ops_t* ops = funnel_get_funnel_ops();
|
||||||
|
gboolean enable_lua = TRUE;
|
||||||
gboolean run_anyway = FALSE;
|
gboolean run_anyway = FALSE;
|
||||||
expert_module_t* expert_lua;
|
expert_module_t* expert_lua;
|
||||||
int file_count = 1;
|
int file_count = 1;
|
||||||
|
@ -923,16 +924,25 @@ void wslua_init(register_cb cb, gpointer client_data) {
|
||||||
filename = NULL;
|
filename = NULL;
|
||||||
|
|
||||||
/* check if lua is to be disabled */
|
/* check if lua is to be disabled */
|
||||||
lua_getglobal(L,"disable_lua");
|
lua_getglobal(L, "disable_lua"); // 2.6 and earlier, deprecated
|
||||||
|
if (lua_isboolean(L,-1)) {
|
||||||
|
enable_lua = ! lua_toboolean(L,-1);
|
||||||
|
}
|
||||||
|
lua_pop(L,1); /* pop the getglobal result */
|
||||||
|
|
||||||
if (lua_isboolean(L,-1) && lua_toboolean(L,-1)) {
|
lua_getglobal(L, "enable_lua"); // 3.0 and later
|
||||||
|
if (lua_isboolean(L,-1)) {
|
||||||
|
enable_lua = lua_toboolean(L,-1);
|
||||||
|
}
|
||||||
|
lua_pop(L,1); /* pop the getglobal result */
|
||||||
|
|
||||||
|
if (!enable_lua) {
|
||||||
/* disable lua */
|
/* disable lua */
|
||||||
lua_close(L);
|
lua_close(L);
|
||||||
L = NULL;
|
L = NULL;
|
||||||
first_time = FALSE;
|
first_time = FALSE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lua_pop(L,1); /* pop the getglobal result */
|
|
||||||
|
|
||||||
/* load global scripts */
|
/* load global scripts */
|
||||||
lua_load_global_plugins(cb, client_data, FALSE);
|
lua_load_global_plugins(cb, client_data, FALSE);
|
||||||
|
|
|
@ -11,10 +11,10 @@
|
||||||
--
|
--
|
||||||
-- SPDX-License-Identifier: GPL-2.0-or-later
|
-- SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
-- Set disable_lua to true to disable Lua support.
|
-- Set enable_lua to false to disable Lua support.
|
||||||
disable_lua = false
|
enable_lua = true
|
||||||
|
|
||||||
if disable_lua then
|
if not enable_lua then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -720,8 +720,8 @@
|
||||||
["datafile_path"] = '<function 33>',
|
["datafile_path"] = '<function 33>',
|
||||||
["debug"] = '<function 381>',
|
["debug"] = '<function 381>',
|
||||||
["deregister_filehandler"] = '<function 382>',
|
["deregister_filehandler"] = '<function 382>',
|
||||||
["disable_lua"] = false,
|
|
||||||
["dofile"] = '<function 383>',
|
["dofile"] = '<function 383>',
|
||||||
|
["enable_lua"] = true,
|
||||||
["error"] = '<function 384>',
|
["error"] = '<function 384>',
|
||||||
["expert"] = {
|
["expert"] = {
|
||||||
["group"] = {
|
["group"] = {
|
||||||
|
|
|
@ -15,6 +15,7 @@ epan/dissectors/asn1/*/*asn
|
||||||
epan/nghttp2/*
|
epan/nghttp2/*
|
||||||
epan/wmem/wmem_strbuf.c
|
epan/wmem/wmem_strbuf.c
|
||||||
epan/wmem/wmem_strutil.c
|
epan/wmem/wmem_strutil.c
|
||||||
|
epan/wslua/init_wslua.c
|
||||||
extcap/*
|
extcap/*
|
||||||
image/stock_icons/*
|
image/stock_icons/*
|
||||||
mmdbresolve.c
|
mmdbresolve.c
|
||||||
|
|
Loading…
Reference in New Issue