Cleanup and export the TVB parser.

svn path=/trunk/; revision=32689
This commit is contained in:
Jaap Keuter 2010-05-06 18:37:47 +00:00
parent f9981411f1
commit 069bc0a909
2 changed files with 64 additions and 44 deletions

View File

@ -1056,6 +1056,29 @@ tvb_strneql
tvb_strnlen tvb_strnlen
tvb_strsize tvb_strsize
tvb_uncompress tvb_uncompress
tvbparse_casestring
tvbparse_char
tvbparse_chars
tvbparse_curr_offset
tvbparse_find
tvbparse_get
tvbparse_handle
tvbparse_hashed
tvbparse_hashed_add
tvbparse_init
tvbparse_len_left
tvbparse_not_char
tvbparse_not_chars
tvbparse_peek
tvbparse_quoted
tvbparse_reset
tvbparse_set_oneof
tvbparse_set_seq
tvbparse_shrink_token_cb
tvbparse_some
tvbparse_string
tvbparse_tree_add_elem
tvbparse_until
uat_add_record uat_add_record
uat_clear uat_clear
uat_fld_chk_enum uat_fld_chk_enum

View File

@ -1,4 +1,3 @@
/* tvbparse.h /* tvbparse.h
* *
* an API for text tvb parsers * an API for text tvb parsers
@ -103,34 +102,34 @@ typedef enum {
struct _tvbparse_wanted_t { struct _tvbparse_wanted_t {
int id; int id;
tvbparse_condition_t condition; tvbparse_condition_t condition;
union { union {
const gchar* str; const gchar* str;
struct _tvbparse_wanted_t** handle; struct _tvbparse_wanted_t** handle;
struct { struct {
union { union {
gint64 i; gint64 i;
guint64 u; guint64 u;
gdouble f; gdouble f;
} value; } value;
gboolean (*comp)(void*,const void*); gboolean (*comp)(void*,const void*);
void* (*extract)(tvbuff_t*,guint); void* (*extract)(tvbuff_t*,guint);
} number; } number;
enum ftenum ftenum; enum ftenum ftenum;
struct { struct {
until_mode_t mode; until_mode_t mode;
const tvbparse_wanted_t* subelem; const tvbparse_wanted_t* subelem;
} until; } until;
struct { struct {
GHashTable* table; GHashTable* table;
struct _tvbparse_wanted_t* key; struct _tvbparse_wanted_t* key;
struct _tvbparse_wanted_t* other; struct _tvbparse_wanted_t* other;
} hash; } hash;
GPtrArray* elems; GPtrArray* elems;
const tvbparse_wanted_t* subelem; const tvbparse_wanted_t* subelem;
void* p; void* p;
} control; } control;
int len; int len;
@ -141,14 +140,13 @@ struct _tvbparse_wanted_t {
tvbparse_action_t before; tvbparse_action_t before;
tvbparse_action_t after; tvbparse_action_t after;
}; };
/* an instance of a per packet parser */ /* an instance of a per packet parser */
struct _tvbparse_t { struct _tvbparse_t {
tvbuff_t* tvb; tvbuff_t* tvb;
int offset; int offset;
int end_offset; int end_offset;
void* data; void* data;
const tvbparse_wanted_t* ignore; const tvbparse_wanted_t* ignore;
}; };
@ -308,14 +306,13 @@ tvbparse_wanted_t* tvbparse_set_oneof(const int id,
/* /*
* hashed * hashed
*/ */
tvbparse_wanted_t* tvbparse_hashed(const int id, tvbparse_wanted_t* tvbparse_hashed(const int id,
const void* data, const void* data,
tvbparse_action_t before_cb, tvbparse_action_t before_cb,
tvbparse_action_t after_cb, tvbparse_action_t after_cb,
tvbparse_wanted_t* key, tvbparse_wanted_t* key,
tvbparse_wanted_t* other, tvbparse_wanted_t* other,
...); ...);
void tvbparse_hashed_add(tvbparse_wanted_t* w, ...); void tvbparse_hashed_add(tvbparse_wanted_t* w, ...);
@ -334,6 +331,7 @@ tvbparse_wanted_t* tvbparse_set_seq(const int id,
tvbparse_action_t before_cb, tvbparse_action_t before_cb,
tvbparse_action_t after_cb, tvbparse_action_t after_cb,
...); ...);
/* /*
* some * some
* *
@ -422,12 +420,12 @@ void tvbparse_shrink_token_cb(void* tvbparse_data,
/* initialize the parser (at every packet) /* initialize the parser (at every packet)
* tvb: what are we parsing? * tvb: what are we parsing?
* offset: from where * offset: from where
* len: for how many bytes * len: for how many bytes
* private_data: will be passed to the action callbacks * private_data: will be passed to the action callbacks
* ignore: a wanted token type to be ignored (the associated cb WILL be called when it matches) * ignore: a wanted token type to be ignored (the associated cb WILL be called when it matches)
*/ */
tvbparse_t* tvbparse_init(tvbuff_t* tvb, tvbparse_t* tvbparse_init(tvbuff_t* tvb,
const int offset, const int offset,
int len, int len,
@ -449,7 +447,7 @@ guint tvbparse_len_left(tvbparse_t* tt);
* The parser will be left in its original state and no callbacks will be called. * The parser will be left in its original state and no callbacks will be called.
*/ */
gboolean tvbparse_peek(tvbparse_t* tt, gboolean tvbparse_peek(tvbparse_t* tt,
const tvbparse_wanted_t* wanted); const tvbparse_wanted_t* wanted);
/* /*
* This will look for the wanted token at the current offset or after any given * This will look for the wanted token at the current offset or after any given
@ -465,7 +463,6 @@ tvbparse_elem_t* tvbparse_get(tvbparse_t* tt,
* current offset. * current offset.
* This function is slow. * This function is slow.
*/ */
tvbparse_elem_t* tvbparse_find(tvbparse_t* tt, tvbparse_elem_t* tvbparse_find(tvbparse_t* tt,
const tvbparse_wanted_t* wanted); const tvbparse_wanted_t* wanted);