diff options
author | Luis Ontanon <luis.ontanon@gmail.com> | 2005-09-27 22:57:07 +0000 |
---|---|---|
committer | Luis Ontanon <luis.ontanon@gmail.com> | 2005-09-27 22:57:07 +0000 |
commit | 95d60cc7ead74e8252fb7af6888659d4f922cf25 (patch) | |
tree | 33e7065921742050155007675dedfc37be93a8be /epan/tvbparse.c | |
parent | ec0f669770875b390d3645a0e5e314517768664a (diff) |
in tvbparse:
- tvbparse_some now handles 0 items.
- added accessors for a tt's offset and remaining length.
in packet-xml:
- min_len=0 for tvbparse_chars() is soon going to mean zero instead of 1 change the 0s to 1s.
- attribute names can have ':' even if it's namespaces isn't managed yet.
- split the xml grammar in more elements so It can be actually read by a human being.
svn path=/trunk/; revision=16031
Diffstat (limited to 'epan/tvbparse.c')
-rw-r--r-- | epan/tvbparse.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/epan/tvbparse.c b/epan/tvbparse.c index e10dad9e5b..94a23c2526 100644 --- a/epan/tvbparse.c +++ b/epan/tvbparse.c @@ -50,7 +50,8 @@ typedef enum _tvbparse_wanted_type_t { /* composed tokens */ TVBPARSE_WANTED_SET_ONEOF, /* one of the given types */ TVBPARSE_WANTED_SET_SEQ, /* an exact sequence of tokens of the given types */ - TVBPARSE_WANTED_CARDINALITY, /* one or more tokens of the given type */ + TVBPARSE_WANTED_CARDINALITY /* one or more tokens of the given type */ + } tvbparse_type_t; struct _tvbparse_t { @@ -284,7 +285,7 @@ tvbparse_wanted_t* tvbparse_some(int id, tvbparse_wanted_t* w = g_malloc(sizeof(tvbparse_wanted_t)); - g_assert(from > 0 && from < to); + g_assert(from <= to); w->id = id; w->type = TVBPARSE_WANTED_CARDINALITY; @@ -420,6 +421,13 @@ static tvbparse_elem_t* new_tok(tvbparse_t* tt, return tok; } +guint tvbparse_curr_offset(tvbparse_t* tt) { + return tt->offset; +} +guint tvbparse_len_left(tvbparse_t* tt) { + return tt->max_len; +} + tvbparse_elem_t* tvbparse_get(tvbparse_t* tt, const tvbparse_wanted_t* wanted) { tvbparse_elem_t* tok = NULL; @@ -629,6 +637,10 @@ tvbparse_elem_t* tvbparse_get(tvbparse_t* tt, guint got_so_far = 0; tvbparse_wanted_t* w = g_ptr_array_index(wanted->elems,0); + if ( wanted->min == 0 ) { + new_tok(tt,wanted->id,tt->offset,0,wanted); + } + while (got_so_far < wanted->max) { tvbparse_elem_t* new = tvbparse_get(tt, w); |