Fix a typo.
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 19 Oct 2006 17:34:11 +0000 (17:34 +0000)
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 19 Oct 2006 17:34:11 +0000 (17:34 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@19610 f5534014-38df-0310-8fa8-9805f1628bb7

epan/wslua/wslua_pinfo.c

index adf819aa99bf845a65207957b06a71a95569b08a..28608fc7c99854c97491c0f359029e31dd8b2784 100644 (file)
@@ -60,19 +60,19 @@ void* push_Pinfo(lua_State* L, Pinfo pinfo) {
 #define PUSH_COLUMN(L,c) g_ptr_array_add(outstanding_stuff,pushColumn(L,c))
 #define PUSH_COLUMNS(L,c) g_ptr_array_add(outstanding_stuff,pushColumns(L,c))
 
-WSLUA_CLASS_DEFINE(Address,NOP,NOP) /* Represents an address */
+WSLUA_CLASS_DEFINE(Address,NOP,NOP); /* Represents an address */
 
 WSLUA_CONSTRUCTOR Address_ip(lua_State* L) { /* Creates an Address Object representing an IP address. */
 #define WSLUA_ARG_Address_ip_HOSTNAME 1 /* The address or name of the IP host. */
     Address addr = g_malloc(sizeof(address));
     guint32* ip_addr = g_malloc(sizeof(guint32));
     const gchar* name = luaL_checkstring(L,WSLUA_ARG_Address_ip_HOSTNAME);
-    
+
     if (! get_host_ipaddr(name, (guint32*)ip_addr)) {
         *ip_addr = 0;
     }
-        
-    SET_ADDRESS(addr, AT_IPv4, 4, ip_addr); 
+
+    SET_ADDRESS(addr, AT_IPv4, 4, ip_addr);
     pushAddress(L,addr);
     WSLUA_RETURN(1); /* the Address object */
 }
@@ -82,7 +82,7 @@ WSLUA_CONSTRUCTOR Address_ip(lua_State* L) { /* Creates an Address Object repres
 static int Address_ipv6(lua_State* L) {
     Address addr = g_malloc(sizeof(address));
 
-    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4)); 
+    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4));
 
     pushAddress(L,addr);
     return 1;
@@ -90,96 +90,96 @@ static int Address_ipv6(lua_State* L) {
 static int Address_ss7(lua_State* L) {
     Address addr = g_malloc(sizeof(address));
 
-    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4)); 
-    
+    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4));
+
     pushAddress(L,addr);
     return 1;
 }
 static int Address_eth(lua_State* L) {
     Address addr = g_malloc(sizeof(address));
 
-    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4)); 
-    
+    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4));
+
     pushAddress(L,addr);
     return 1;
 }
 static int Address_sna(lua_State* L) {
     Address addr = g_malloc(sizeof(address));
 
-    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4)); 
-    
+    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4));
+
     pushAddress(L,addr);
     return 1;
 }
 static int Address_atalk(lua_State* L) {
     Address addr = g_malloc(sizeof(address));
 
-    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4)); 
-    
+    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4));
+
     pushAddress(L,addr);
     return 1;
 }
 static int Address_vines(lua_State* L) {
     Address addr = g_malloc(sizeof(address));
 
-    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4)); 
-    
+    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4));
+
     pushAddress(L,addr);
     return 1;
 }
 static int Address_osi(lua_State* L) {
     Address addr = g_malloc(sizeof(address));
 
-    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4)); 
-    
+    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4));
+
     pushAddress(L,addr);
     return 1;
 }
 static int Address_arcnet(lua_State* L) {
     Address addr = g_malloc(sizeof(address));
 
-    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4)); 
-    
+    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4));
+
     pushAddress(L,addr);
     return 1;
 }
 static int Address_fc(lua_State* L) {
     Address addr = g_malloc(sizeof(address));
 
-    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4)); 
-    
+    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4));
+
     pushAddress(L,addr);
     return 1;
 }
 static int Address_string(lua_State* L) {
     Address addr = g_malloc(sizeof(address));
 
-    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4)); 
-    
+    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4));
+
     pushAddress(L,addr);
     return 1;
 }
 static int Address_eui64(lua_State* L) {
     Address addr = g_malloc(sizeof(address));
 
-    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4)); 
-    
+    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4));
+
     pushAddress(L,addr);
     return 1;
 }
 static int Address_uri(lua_State* L) {
     Address addr = g_malloc(sizeof(address));
 
-    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4)); 
-    
+    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4));
+
     pushAddress(L,addr);
     return 1;
 }
 static int Address_tipc(lua_State* L) {
     Address addr = g_malloc(sizeof(address));
 
-    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4)); 
-    
+    SET_ADDRESS(addr, AT_NONE, 4, g_malloc(4));
+
     pushAddress(L,addr);
     return 1;
 }
@@ -208,15 +208,15 @@ WSLUA_METHODS Address_methods[] = {
 
 WSLUA_METAMETHOD Address__tostring(lua_State* L) {
     Address addr = checkAddress(L,1);
-    
+
     lua_pushstring(L,get_addr_name(addr));
-    
+
     WSLUA_RETURN(1); /* The string representing the address. */
 }
 
 static int Address__gc(lua_State* L) {
     Address addr = checkAddress(L,1);
-    
+
     if (addr) {
         if (addr->data) g_free((void*)addr->data);
         g_free((void*)addr);
@@ -229,12 +229,12 @@ WSLUA_METAMETHOD Address__eq(lua_State* L) { /* compares two Addresses */
     Address addr1 = checkAddress(L,1);
     Address addr2 = checkAddress(L,2);
     gboolean result = FALSE;
-    
+
     if (ADDRESSES_EQUAL(addr1, addr2))
         result = TRUE;
-    
+
     lua_pushboolean(L,result);
-    
+
     return 1;
 }
 
@@ -242,12 +242,12 @@ WSLUA_METAMETHOD Address__le(lua_State* L) { /* compares two Addresses */
     Address addr1 = checkAddress(L,1);
     Address addr2 = checkAddress(L,2);
     gboolean result = FALSE;
-    
+
     if (CMP_ADDRESS(addr1, addr2) <= 0)
         result = TRUE;
-    
+
     lua_pushboolean(L,result);
-    
+
     return 1;
 }
 
@@ -255,12 +255,12 @@ WSLUA_METAMETHOD Address__lt(lua_State* L) { /* compares two Addresses */
     Address addr1 = checkAddress(L,1);
     Address addr2 = checkAddress(L,2);
     gboolean result = FALSE;
-    
+
     if (CMP_ADDRESS(addr1, addr2) < 0)
         result = TRUE;
-    
+
     lua_pushboolean(L,result);
-    
+
     return 1;
 }
 
@@ -338,18 +338,18 @@ static const struct col_names_t colnames[] = {
 };
 
 static gint col_name_to_id(const gchar* name) {
-    const struct col_names_t* cn;    
+    const struct col_names_t* cn;
     for(cn = colnames; cn->name; cn++) {
         if (g_str_equal(cn->name,name)) {
             return cn->id;
         }
     }
-    
+
     return 0;
 }
 
 static const gchar*  col_id_to_name(gint id) {
-    const struct col_names_t* cn;    
+    const struct col_names_t* cn;
     for(cn = colnames; cn->name; cn++) {
         if ( cn->id == id ) {
             return cn->name;
@@ -362,27 +362,27 @@ static const gchar*  col_id_to_name(gint id) {
 WSLUA_METAMETHOD Column__tostring(lua_State *L) {
     Column c = checkColumn(L,1);
     const gchar* name;
-    
+
     if (!(c)) {
         return 0;
     }
-    
+
     /* 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_METHOD Column_clear(lua_State *L) {
        /* Clears a Column */
     Column c = checkColumn(L,1);
-    
+
     if (!(c && c->cinfo)) return 0;
-    
+
     if (check_col(c->cinfo, c->col))
         col_clear(c->cinfo, c->col);
-    
+
     return 0;
 }
 
@@ -391,7 +391,7 @@ WSLUA_METHOD Column_set(lua_State *L) {
 #define WSLUA_ARG_Column_set_TEXT 2 /* The text to which to set the Column */
        Column c = checkColumn(L,1);
     const gchar* s = luaL_checkstring(L,WSLUA_ARG_Column_set_TEXT);
-    
+
     if (!(c && c->cinfo))
                return 0;
 
@@ -399,7 +399,7 @@ WSLUA_METHOD Column_set(lua_State *L) {
 
     if (check_col(c->cinfo, c->col))
         col_set_str(c->cinfo, c->col, s);
-    
+
     return 0;
 }
 
@@ -408,7 +408,7 @@ WSLUA_METHOD Column_append(lua_State *L) {
 #define WSLUA_ARG_Column_append_TEXT 2 /* The text to append to the Column */
     Column c = checkColumn(L,1);
     const gchar* s = luaL_checkstring(L,WSLUA_ARG_Column_append_TEXT);
-    
+
        if (!(c && c->cinfo))
                return 0;
 
@@ -417,7 +417,7 @@ WSLUA_METHOD Column_append(lua_State *L) {
 
     if (check_col(c->cinfo, c->col))
         col_append_str(c->cinfo, c->col, s);
-    
+
     return 0;
 }
 
@@ -426,7 +426,7 @@ WSLUA_METHOD Column_preppend(lua_State *L) {
 #define WSLUA_ARG_Column_prepend_TEXT 2 /* The text to prepend to the Column */
     Column c = checkColumn(L,1);
     const gchar* s = luaL_checkstring(L,WSLUA_ARG_Column_prepend_TEXT);
-    
+
        if (!(c && c->cinfo))
                return 0;
 
@@ -434,7 +434,7 @@ WSLUA_METHOD Column_preppend(lua_State *L) {
 
     if (check_col(c->cinfo, c->col))
         col_prepend_fstr(c->cinfo, c->col, "%s",s);
-    
+
     return 0;
 }
 
@@ -477,15 +477,15 @@ WSLUA_METAMETHOD Columns__newindex(lua_State *L) {
 #define WSLUA_ARG_Columns__newindex_COLUMN 2 /* the name of the column to set */
 #define WSLUA_ARG_Columns__newindex_TEXT 3 /* the text for the column */
     Columns cols = checkColumns(L,1);
-    const struct col_names_t* cn;    
+    const struct col_names_t* cn;
     const char* colname;
     const char* text;
-    
+
     if (!cols) return 0;
-    
+
     colname = luaL_checkstring(L,WSLUA_ARG_Columns__newindex_COLUMN);
     text = luaL_checkstring(L,WSLUA_ARG_Columns__newindex_TEXT);
-    
+
     for(cn = colnames; cn->name; cn++) {
         if( g_str_equal(cn->name,colname) ) {
             if (check_col(cols, cn->id))
@@ -495,26 +495,26 @@ WSLUA_METAMETHOD Columns__newindex(lua_State *L) {
     }
 
        WSLUA_ARG_ERROR(Columns__newindex,COLUMN,"the column name must be a valid column");
-    
+
     return 0;
 }
 
 WSLUA_METAMETHOD Columns_index(lua_State *L) {
     Columns cols = checkColumns(L,1);
-    const struct col_names_t* cn;    
+    const struct col_names_t* cn;
     const char* colname = luaL_checkstring(L,2);
 
     if (!cols) {
         Column c = ep_alloc(sizeof(struct _wslua_col_info));
         c->cinfo = NULL;
         c->col = col_name_to_id(colname);
-        
+
         PUSH_COLUMN(L,c);
         return 1;
     }
-    
-    
-    
+
+
+
     if (!colname) return 0;
 
     for(cn = colnames; cn->name; cn++) {
@@ -607,15 +607,15 @@ static int Pinfo_visited(lua_State *L) {
 
 static int Pinfo_match(lua_State *L) {
     Pinfo pinfo = checkPinfo(L,1);
-    
+
     if (!pinfo) return 0;
-    
+
     if (pinfo->match_string) {
         lua_pushstring(L,pinfo->match_string);
     } else {
         lua_pushnumber(L,(lua_Number)(pinfo->match_port));
     }
-    
+
     return 1;
 }
 
@@ -657,12 +657,12 @@ static int pushnil_param(lua_State* L, packet_info* pinfo _U_, pinfo_param_type_
 int Pinfo_set_addr(lua_State* L, packet_info* pinfo, pinfo_param_type_t pt) {
     const address* from = checkAddress(L,1);
     address* to;
-    
+
     if (! from ) {
         luaL_error(L,"Not an OK address");
         return 0;
     }
-    
+
     switch(pt) {
         case PARAM_ADDR_SRC:
             to = &(pinfo->src);
@@ -685,14 +685,14 @@ int Pinfo_set_addr(lua_State* L, packet_info* pinfo, pinfo_param_type_t pt) {
         default:
             g_assert(!"BUG: A bad parameter");
     }
-    
+
     COPY_ADDRESS(to,from);
     return 0;
 }
 
 int Pinfo_set_int(lua_State* L, packet_info* pinfo, pinfo_param_type_t pt) {
     guint v = luaL_checkint(L,1);
-    
+
     switch(pt) {
         case PARAM_PORT_SRC:
             pinfo->srcport = v;
@@ -706,7 +706,7 @@ int Pinfo_set_int(lua_State* L, packet_info* pinfo, pinfo_param_type_t pt) {
         default:
             g_assert(!"BUG: A bad parameter");
     }
-    
+
     return 0;
 }
 
@@ -722,13 +722,13 @@ static int Pinfo_hi(lua_State *L) {
        Address addr = g_malloc(sizeof(address));
 
        if (!pinfo) return 0;
-       
+
        if (CMP_ADDRESS(&(pinfo->src), &(pinfo->dst) ) >= 0) {
                COPY_ADDRESS(addr, &(pinfo->src));
        } else {
                COPY_ADDRESS(addr, &(pinfo->dst));
        }
-       
+
        pushAddress(L,addr);
        return 1;
 }
@@ -736,91 +736,91 @@ static int Pinfo_hi(lua_State *L) {
 static int Pinfo_lo(lua_State *L) {
     Pinfo pinfo = checkPinfo(L,1);
        Address addr = g_malloc(sizeof(address));
-       
+
        if (!pinfo) return 0;
-       
+
        if (CMP_ADDRESS(&(pinfo->src), &(pinfo->dst) ) < 0) {
                COPY_ADDRESS(addr, &(pinfo->src));
        } else {
                COPY_ADDRESS(addr, &(pinfo->dst));
        }
-       
+
        pushAddress(L,addr);
        return 1;
 }
 
 
 static const pinfo_method_t Pinfo_methods[] = {
-       
+
        /* WSLUA_ATTRIBUTE Pinfo_number RO The number of this packet in the current file */
     {"number", Pinfo_number, pushnil_param, PARAM_NONE},
 
        /* WSLUA_ATTRIBUTE Pinfo_len  RO The length of the frame */
     {"len", Pinfo_len, pushnil_param, PARAM_NONE },
-       
+
        /* WSLUA_ATTRIBUTE Pinfo_caplen RO The captured length of the frame */
     {"caplen", Pinfo_caplen, pushnil_param, PARAM_NONE },
-       
+
        /* WSLUA_ATTRIBUTE Pinfo_abs_ts RO When the packet was captured */
     {"abs_ts",Pinfo_abs_ts, pushnil_param, PARAM_NONE },
-       
+
        /* WSLUA_ATTRIBUTE Pinfo_rel_ts RO Number of seconds passed since beginning of capture */
     {"rel_ts",Pinfo_rel_ts, pushnil_param, PARAM_NONE },
-       
+
        /* WSLUA_ATTRIBUTE Pinfo_delta_ts RO Number of seconds passed since the last packet */
     {"delta_ts",Pinfo_delta_ts, pushnil_param, PARAM_NONE },
-       
+
        /* WSLUA_ATTRIBUTE Pinfo_visited RO Whether this packet hass been already visited */
     {"visited",Pinfo_visited, pushnil_param, PARAM_NONE },
-       
+
        /* WSLUA_ATTRIBUTE Pinfo_src RW Source Address of this Packet */
     {"src", Pinfo_src, Pinfo_set_addr, PARAM_ADDR_SRC },
-       
+
        /* WSLUA_ATTRIBUTE Pinfo_dst RW Destination Address of this Packet */
     {"dst", Pinfo_dst, Pinfo_set_addr, PARAM_ADDR_DST },
-       
+
        /* WSLUA_ATTRIBUTE Pinfo_lo RO lower Address of this Packet */
     {"lo", Pinfo_lo, pushnil_param, PARAM_NONE },
-       
+
        /* WSLUA_ATTRIBUTE Pinfo_hi RW higher Address of this Packet */
     {"hi", Pinfo_hi, pushnil_param, PARAM_NONE },
-       
+
        /* WSLUA_ATTRIBUTE Pinfo_dl_src RW Data Link Source Address of this Packet */
     {"dl_src", Pinfo_dl_src, Pinfo_set_addr, PARAM_ADDR_DL_SRC },
-       
+
        /* WSLUA_ATTRIBUTE Pinfo_dl_dst RW Data Link Destination Address of this Packet */
     {"dl_dst", Pinfo_dl_dst, Pinfo_set_addr, PARAM_ADDR_DL_DST },
-       
+
        /* WSLUA_ATTRIBUTE Pinfo_net_src RW Network Layer Source Address of this Packet */
     {"net_src", Pinfo_net_src, Pinfo_set_addr, PARAM_ADDR_NET_SRC },
-       
+
        /* WSLUA_ATTRIBUTE Pinfo_net_dst RW Network Layer Destination Address of this Packet */
     {"net_dst", Pinfo_net_dst, Pinfo_set_addr, PARAM_ADDR_NET_DST },
 
        /* WSLUA_ATTRIBUTE Pinfo_ptype RW Type of Port of .src_port and .dst_port */
     {"port_type", Pinfo_ptype, pushnil_param, PARAM_NONE },
-       
+
        /* WSLUA_ATTRIBUTE Pinfo_src_port RW Source Port of this Packet */
     {"src_port", Pinfo_src_port, Pinfo_set_int,  PARAM_PORT_SRC },
-       
+
        /* WSLUA_ATTRIBUTE Pinfo_dst_port RW Source Address of this Packet */
     {"dst_port", Pinfo_dst_port, Pinfo_set_int,  PARAM_PORT_SRC },
-       
+
        /* WSLUA_ATTRIBUTE Pinfo_ipproto RO IP Protocol id */
     {"ipproto", Pinfo_ipproto, pushnil_param,  PARAM_NONE },
-       
+
        /* WSLUA_ATTRIBUTE Pinfo_circuit_id RO For circuit based protocols */
     {"circuit_id", Pinfo_circuit_id, Pinfo_set_int, PARAM_CIRCUIT_ID },
-       
-       /* WSLUA_ATTRIBUTE Pinfo_match RO Port/Data we are matching */  
+
+       /* WSLUA_ATTRIBUTE Pinfo_match RO Port/Data we are matching */
     {"match", Pinfo_match, pushnil_param, PARAM_NONE },
-       
-       /* WSLUA_ATTRIBUTE Pinfo_match RO Which Protocol are we dissecting */   
+
+       /* WSLUA_ATTRIBUTE Pinfo_match RO Which Protocol are we dissecting */
     {"curr_proto", Pinfo_curr_proto, pushnil_param, PARAM_NONE },
-       
-       /* WSLUA_ATTRIBUTE Pinfo_columns RO Accesss to the packet list columns */       
+
+       /* WSLUA_ATTRIBUTE Pinfo_columns RO Accesss to the packet list columns */
     {"cols", Pinfo_columns, pushnil_param, PARAM_NONE },
-    
+
        {NULL,NULL,NULL,PARAM_NONE}
 };
 
@@ -835,19 +835,19 @@ static int Pinfo_index(lua_State* L) {
     const gchar* name = luaL_checkstring(L,2);
     lua_CFunction method = pushnil;
     const pinfo_method_t* curr;
-    
+
     if (! (pinfo && name) ) {
         lua_pushnil(L);
         return 1;
     }
-    
+
     for (curr = Pinfo_methods ; curr->name ; curr++) {
         if (g_str_equal(curr->name,name)) {
             method = curr->get;
             break;
         }
     }
-    
+
     lua_settop(L,1);
     return method(L);
 }
@@ -858,11 +858,11 @@ static int Pinfo_setindex(lua_State* L) {
     int (*method)(lua_State*, packet_info* pinfo, pinfo_param_type_t) = pushnil_param;
     const pinfo_method_t* curr;
     pinfo_param_type_t param_type = PARAM_NONE;
-    
+
     if (! (pinfo && name) ) {
         return 0;
     }
-    
+
     for (curr = Pinfo_methods ; curr->name ; curr++) {
         if (g_str_equal(curr->name,name)) {
             method = curr->set;
@@ -870,9 +870,9 @@ static int Pinfo_setindex(lua_State* L) {
             break;
         }
     }
-    
+
+    lua_remove(L,1);
     lua_remove(L,1);
-    lua_remove(L,1);    
     return method(L,pinfo,param_type);
 }