From f3ed13c22ea9a73cad6f65488eacc59770197b0c Mon Sep 17 00:00:00 2001 From: Jakub Zawadzki Date: Wed, 10 Jul 2013 18:14:15 +0000 Subject: tvbuff: replace type with operation vtable It's begin of work to allow adding new tvbuff types (think: wtap_tvbuff, base64_tvbuff). svn path=/trunk/; revision=50486 --- epan/tvbuff-int.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'epan/tvbuff-int.h') diff --git a/epan/tvbuff-int.h b/epan/tvbuff-int.h index 6f7e9818a0..e85e661d25 100644 --- a/epan/tvbuff-int.h +++ b/epan/tvbuff-int.h @@ -26,6 +26,19 @@ #ifndef __TVBUFF_INT_H__ #define __TVBUFF_INT_H__ +struct tvbuff; + +struct tvb_ops { + void (*tvb_init)(struct tvbuff *tvb); + void (*tvb_free)(struct tvbuff *tvb); + guint (*tvb_offset)(const struct tvbuff *tvb, guint counter); + const guint8 *(*tvb_get_ptr)(struct tvbuff *tvb, const guint abs_offset, const guint abs_length); + void *(*tvb_memcpy)(struct tvbuff *tvb, void *target, guint offset, size_t length); + + gint (*tvb_find_guint8)(tvbuff_t *tvb, guint abs_offset, guint limit, guint8 needle); + gint (*tvb_pbrk_guint8)(tvbuff_t *tvb, guint abs_offset, guint limit, guint8 *needles, guchar *found_needle); +}; + typedef struct { /** The backing tvbuff_t */ struct tvbuff *tvb; @@ -59,7 +72,7 @@ struct tvbuff { tvbuff_t *previous; /* Record-keeping */ - tvbuff_type type; + const struct tvb_ops *ops; gboolean initialized; guint flags; struct tvbuff *ds_tvb; /**< data source top-level tvbuff */ -- cgit v1.2.1