diff options
author | Michael Mann <mmann78@netscape.net> | 2013-02-25 20:43:06 +0000 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2013-02-25 20:43:06 +0000 |
commit | 41bd69d601bf8f43f8900896e9c5fe5bb5c3e509 (patch) | |
tree | 93e06ab4773e9b60da489805344d9e72bd419e3f /epan/wslua/wslua_pinfo.c | |
parent | 8692843ee300ac5ebebbf92e73ac0532b3256d4c (diff) |
LUA API improvements
1. Add col_set_fence() equivalent
2. Update __tostring function to actually return column text
From Hadriel Kaplan, bug 8295 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8295)
svn path=/trunk/; revision=47882
Diffstat (limited to 'epan/wslua/wslua_pinfo.c')
-rw-r--r-- | epan/wslua/wslua_pinfo.c | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/epan/wslua/wslua_pinfo.c b/epan/wslua/wslua_pinfo.c index cbbc335805..46146cc84b 100644 --- a/epan/wslua/wslua_pinfo.c +++ b/epan/wslua/wslua_pinfo.c @@ -604,17 +604,21 @@ static const gchar* col_id_to_name(gint id) { WSLUA_METAMETHOD Column__tostring(lua_State *L) { Column c = checkColumn(L,1); - const gchar* name; + const gchar* text; - if (!(c)) { - return 0; + if (!c) { + lua_pushstring(L,"(nil)"); + } + else if (!c->cinfo) { + text = col_id_to_name(c->col); + lua_pushfstring(L, "(%s)", text ? text : "unknown"); + } + else { + text = col_get_text(c->cinfo, c->col); + lua_pushstring(L, text ? text : "(nil)"); } - /* XXX: should return the column's text ! */ - name = col_id_to_name(c->col); - lua_pushstring(L,name ? name : "Unknown Column"); - - WSLUA_RETURN(1); /* A string representing the column */ + WSLUA_RETURN(1); /* The column's string text (in parenthesis if not available) */ } static int Column__gc(lua_State* L) { @@ -691,12 +695,24 @@ WSLUA_METHOD Column_prepend(lua_State *L) { return 0; } +WSLUA_METHOD Column_fence(lua_State *L) { + /* Sets Column text fence, to prevent overwriting */ + Column c = checkColumn(L,1); + + if (c && c->cinfo) + col_set_fence(c->cinfo, c->col); + + return 0; +} + + WSLUA_METHODS Column_methods[] = { WSLUA_CLASS_FNREG(Column,clear), WSLUA_CLASS_FNREG(Column,set), WSLUA_CLASS_FNREG(Column,append), WSLUA_CLASS_FNREG(Column,prepend), WSLUA_CLASS_FNREG_ALIAS(Column,preppend,prepend), + WSLUA_CLASS_FNREG(Column,fence), {0,0} }; |