diff options
author | Luis Ontanon <luis.ontanon@gmail.com> | 2006-06-29 13:49:56 +0000 |
---|---|---|
committer | Luis Ontanon <luis.ontanon@gmail.com> | 2006-06-29 13:49:56 +0000 |
commit | 8c8a4ce877d51c345b501448dbd68c8a36669c41 (patch) | |
tree | 5d9077bfae93d2fce022124888d930cc32215220 /plugins | |
parent | 20b7999d60e2b0045be3a13c968ac54c7b37c98b (diff) |
Some improvements to the Lua plugin:
- Makefile.am fix: elua_register.h generation + checking serialized
- ProtoField.new(..) parameter parsing fix and changes
- enabling gui_enabled() function in Lua (typo fix, thanks to Tamas Regos)
svn path=/trunk/; revision=18611
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/lua/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/lua/elua_gui.c | 2 | ||||
-rw-r--r-- | plugins/lua/elua_proto.c | 20 |
3 files changed, 10 insertions, 14 deletions
diff --git a/plugins/lua/Makefile.am b/plugins/lua/Makefile.am index 338177ce4f..122e48da69 100644 --- a/plugins/lua/Makefile.am +++ b/plugins/lua/Makefile.am @@ -78,7 +78,7 @@ elua.h: elua_register.h # do not do not unnecessarilly modify the old file in order avoid recompiling every module every time elua_register.h: elua_makereg.pl $(lua_modules) - $(PERL) elua_makereg.pl $(lua_modules) > elua_register.h.new + $(PERL) elua_makereg.pl $(lua_modules) > elua_register.h.new ;\ if diff elua_register.h.new elua_register.h >/dev/null; then rm elua_register.h.new; else mv elua_register.h.new elua_register.h; fi doc: $(lua_modules) diff --git a/plugins/lua/elua_gui.c b/plugins/lua/elua_gui.c index c058ac05f2..c2149e55c8 100644 --- a/plugins/lua/elua_gui.c +++ b/plugins/lua/elua_gui.c @@ -40,7 +40,7 @@ static int menu_cb_error_handler(lua_State* L) { return 0; } -ELUA_FUNCTION lua_gui_enabled(lua_State* L) { /* Checks whether the GUI facility is enabled. */ +ELUA_FUNCTION elua_gui_enabled(lua_State* L) { /* Checks whether the GUI facility is enabled. */ lua_pushboolean(L,GPOINTER_TO_INT(ops)); ELUA_RETURN(1); /* A boolean: true if it is enabled, false if it isn't. */ } diff --git a/plugins/lua/elua_proto.c b/plugins/lua/elua_proto.c index 3144f3101e..a8dff7e156 100644 --- a/plugins/lua/elua_proto.c +++ b/plugins/lua/elua_proto.c @@ -287,7 +287,6 @@ static const eth_ft_types_t ftenums[] = { {NULL,FT_NONE} }; -#if 0 static enum ftenum get_ftenum(const gchar* type) { const eth_ft_types_t* ts; for (ts = ftenums; ts->str; ts++) { @@ -298,7 +297,6 @@ static enum ftenum get_ftenum(const gchar* type) { return FT_NONE; } -#endif static const gchar* ftenum_to_string(enum ftenum ft) { const eth_ft_types_t* ts; @@ -335,7 +333,6 @@ static const gchar* base_to_string(base_display_e base) { return NULL; } -#if 0 static base_display_e string_to_base(const gchar* str) { const struct base_display_string_t* b; for (b=base_displays;b->str;b++) { @@ -344,7 +341,6 @@ static base_display_e string_to_base(const gchar* str) { } return BASE_NONE; } -#endif static value_string* value_string_from_table(lua_State* L, int idx) { GArray* vs = g_array_new(TRUE,TRUE,sizeof(value_string)); @@ -397,10 +393,10 @@ ELUA_CONSTRUCTOR ProtoField_new(lua_State* L) { /* Creates a new field to be use #define ELUA_ARG_ProtoField_new_NAME 1 /* Actual name of the field (the string that appears in the tree). */ #define ELUA_ARG_ProtoField_new_ABBR 2 /* Filter name of the field (the string that is used in filters). */ #define ELUA_ARG_ProtoField_new_TYPE 3 /* Field Type (FT_*). */ -#define ELUA_OPTARG_ProtoField_new_VALUESTRING 3 /* a ValueString object. */ -#define ELUA_OPTARG_ProtoField_new_BASE 4 /* The representation BASE_*. */ -#define ELUA_OPTARG_ProtoField_new_MASK 5 /* the bitmask to be used. */ -#define ELUA_OPTARG_ProtoField_new_DESCR 6 /* The description of the field. */ +#define ELUA_OPTARG_ProtoField_new_VALUESTRING 4 /* a ValueString object. */ +#define ELUA_OPTARG_ProtoField_new_BASE 5 /* The representation BASE_*. */ +#define ELUA_OPTARG_ProtoField_new_MASK 6 /* the bitmask to be used. */ +#define ELUA_OPTARG_ProtoField_new_DESCR 7 /* The description of the field. */ ProtoField f = g_malloc(sizeof(eth_field_t)); value_string* vs; @@ -410,7 +406,7 @@ ELUA_CONSTRUCTOR ProtoField_new(lua_State* L) { /* Creates a new field to be use f->ett = -1; f->name = g_strdup(luaL_checkstring(L,ELUA_ARG_ProtoField_new_NAME)); f->abbr = g_strdup(luaL_checkstring(L,ELUA_ARG_ProtoField_new_ABBR)); - f->type = luaL_checkint(L,ELUA_ARG_ProtoField_new_TYPE); + f->type = get_ftenum(luaL_checkstring(L,ELUA_ARG_ProtoField_new_TYPE)); /*XXX do it better*/ if (f->type == FT_NONE) { @@ -418,8 +414,8 @@ ELUA_CONSTRUCTOR ProtoField_new(lua_State* L) { /* Creates a new field to be use return 0; } - if (! lua_isnil(L,4) ) { - vs = value_string_from_table(L,4); + if (! lua_isnil(L,ELUA_OPTARG_ProtoField_new_VALUESTRING) ) { + vs = value_string_from_table(L,ELUA_OPTARG_ProtoField_new_VALUESTRING); if (vs) { f->vs = vs; @@ -434,7 +430,7 @@ ELUA_CONSTRUCTOR ProtoField_new(lua_State* L) { /* Creates a new field to be use } /* XXX: need BASE_ERROR */ - f->base = luaL_optint(L, ELUA_OPTARG_ProtoField_new_BASE, BASE_NONE); + f->base = string_to_base(luaL_optstring(L, ELUA_OPTARG_ProtoField_new_BASE, "BASE_NONE")); f->mask = luaL_optint(L, ELUA_OPTARG_ProtoField_new_MASK, 0x0); f->blob = g_strdup(luaL_optstring(L,ELUA_OPTARG_ProtoField_new_DESCR,"")); |