~ubuntu-branches/ubuntu/gutsy/wireshark/gutsy-security

« back to all changes in this revision

Viewing changes to epan/wslua/wslua_field.c

  • Committer: Bazaar Package Importer
  • Author(s): Frederic Peters
  • Date: 2007-04-01 08:58:40 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070401085840-or3qhrpv8alt1bwg
Tags: 0.99.5-1
* New upstream release.
* debian/patches/09_idl2wrs.dpatch: updated to patch idl2wrs.sh.in.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *
6
6
 * (c) 2006, Luis E. Garcia Ontanon <luis.ontanon@gmail.com>
7
7
 *
8
 
 * $Id: wslua_field.c 19595 2006-10-18 18:45:24Z lego $
 
8
 * $Id: wslua_field.c 19992 2006-11-26 18:31:53Z wmeier $
9
9
 *
10
10
 * Wireshark - Network traffic analyzer
11
11
 * By Gerald Combs <gerald@wireshark.org>
37
37
 
38
38
WSLUA_METAMETHOD FieldInfo__len(lua_State* L) {
39
39
        /*
40
 
         The Length of the field
 
40
         Obtain the Length of the field
41
41
         */
42
42
        FieldInfo fi = checkFieldInfo(L,1);
43
43
        lua_pushnumber(L,fi->length);
46
46
 
47
47
WSLUA_METAMETHOD FieldInfo__unm(lua_State* L) {
48
48
        /*
49
 
         The Offset of the field
 
49
         Obtain the Offset of the field
50
50
         */
51
51
        FieldInfo fi = checkFieldInfo(L,1);
52
52
        lua_pushnumber(L,fi->start);
55
55
 
56
56
WSLUA_METAMETHOD FieldInfo__call(lua_State* L) {
57
57
        /*
58
 
         The Value of the field
 
58
         Obtain the Value of the field
59
59
         */
60
60
        FieldInfo fi = checkFieldInfo(L,1);
61
61
 
137
137
}
138
138
 
139
139
WSLUA_METAMETHOD FieldInfo__tostring(lua_State* L) {
 
140
        /* the string representation of the field */
140
141
        FieldInfo fi = checkFieldInfo(L,1);
141
142
        if (fi) {
142
143
                if (fi->value.ftype->val_to_string_repr)
147
148
        return 1;
148
149
}
149
150
 
150
 
WSLUA_ATTR_GET FieldInfo_get_data_source(lua_State* L) {
151
 
        FieldInfo fi = checkFieldInfo(L,1);
152
 
        pushTvb(L,fi->ds_tvb);
153
 
        return 1;
154
 
}
155
 
 
156
151
WSLUA_ATTR_GET FieldInfo_get_range(lua_State* L) {
 
152
        /* the TvbRange covering this field */
157
153
        FieldInfo fi = checkFieldInfo(L,1);
158
154
        TvbRange r = ep_alloc(sizeof(struct _wslua_tvbrange));
159
155
 
165
161
        return 1;
166
162
}
167
163
 
168
 
 
169
 
WSLUA_ATTR_GET FieldInfo_get_hidden(lua_State* L) {
170
 
        FieldInfo fi = checkFieldInfo(L,1);
171
 
        lua_pushboolean(L,FI_GET_FLAG(fi, FI_HIDDEN));
172
 
        return 1;
173
 
}
174
 
 
175
164
WSLUA_ATTR_GET FieldInfo_get_generated(lua_State* L) {
 
165
        /* Whether this field was marked as generated. */
176
166
        FieldInfo fi = checkFieldInfo(L,1);
177
167
        lua_pushboolean(L,FI_GET_FLAG(fi, FI_GENERATED));
178
168
        return 1;
179
169
}
180
170
 
181
171
WSLUA_ATTR_GET FieldInfo_get_name(lua_State* L) {
 
172
        /* the filter name of this field. */
182
173
        FieldInfo fi = checkFieldInfo(L,1);
183
174
        lua_pushstring(L,fi->hfinfo->abbrev);
184
175
        return 1;
185
176
}
186
177
 
187
178
static const luaL_reg FieldInfo_get[] = {
188
 
    {"data_source", FieldInfo_get_data_source },
 
179
/*    {"data_source", FieldInfo_get_data_source }, */
189
180
    {"range", FieldInfo_get_range},
190
 
    {"hidden", FieldInfo_get_hidden},
 
181
/*    {"hidden", FieldInfo_get_hidden}, */
191
182
    {"generated", FieldInfo_get_generated},
192
183
    {"name", FieldInfo_get_name},
193
184
    {"label", FieldInfo__tostring},
197
188
    {0, 0}
198
189
};
199
190
 
200
 
WSLUA_METAMETHOD FieldInfo__index(lua_State* L) {
 
191
static int FieldInfo__index(lua_State* L) {
201
192
        /*
202
193
         Other attributes:
203
194
         */
216
207
}
217
208
 
218
209
WSLUA_METAMETHOD FieldInfo__eq(lua_State* L) {
 
210
        /* checks whether lhs is within rhs */
219
211
        FieldInfo l = checkFieldInfo(L,1);
220
212
        FieldInfo r = checkFieldInfo(L,2);
221
213
 
231
223
}
232
224
 
233
225
WSLUA_METAMETHOD FieldInfo__le(lua_State* L) {
 
226
        /* checks whether the end byte of lhs is before the end of rhs */
234
227
        FieldInfo l = checkFieldInfo(L,1);
235
228
        FieldInfo r = checkFieldInfo(L,2);
236
229
 
237
230
        if (l->ds_tvb != r->ds_tvb)
238
 
                WSLUA_ERROR(FieldInfo__eq,"data source must be the same for both fields");
 
231
                return 0;
239
232
 
240
233
        if (r->start + r->length <= l->start + r->length) {
241
234
                lua_pushboolean(L,1);
246
239
}
247
240
 
248
241
WSLUA_METAMETHOD FieldInfo__lt(lua_State* L) {
 
242
        /* checks whether the end byte of rhs is before the beginning of rhs */
249
243
        FieldInfo l = checkFieldInfo(L,1);
250
244
        FieldInfo r = checkFieldInfo(L,2);
251
245
 
280
274
 
281
275
 
282
276
WSLUA_FUNCTION wslua_all_field_infos(lua_State* L) {
 
277
        /* obtain all fields from the current tree */
283
278
        GPtrArray* found = lua_tree->tree ? proto_all_finfos(lua_tree->tree) : NULL;
284
279
        int items_found = 0;
285
280
        guint i;
289
284
                        pushFieldInfo(L,g_ptr_array_index(found,i));
290
285
                        items_found++;
291
286
                }
292
 
                
 
287
 
293
288
                g_ptr_array_free(found,TRUE);
294
289
        }
295
 
        
 
290
 
296
291
        return items_found;
297
292
}
298
293
 
382
377
}
383
378
 
384
379
WSLUA_METAMETHOD Field__call (lua_State* L) {
 
380
        /* obtain all values (see FieldInfo) for this field. */
385
381
    Field f = checkField(L,1);
386
382
    header_field_info* in = *f;
387
383
        int items_found = 0;
411
407
}
412
408
 
413
409
WSLUA_METAMETHOD Field_tostring(lua_State* L) {
 
410
        /* obtain a srting with the field name */
414
411
    Field f = checkField(L,1);
415
412
 
416
413
    if ( !(f && *f) ) {