diff options
author | Michael Mann <mmann78@netscape.net> | 2018-12-02 22:54:12 -0500 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-12-09 07:17:21 +0000 |
commit | df9378ed3f8ad283efb4f8562bcb7a23cf2b2152 (patch) | |
tree | 8d3cb30d81a8eb989d4078e5f4ce6f88fd032765 /epan/tvbuff.h | |
parent | 0b79b9c2db3581191dd4d6a9a6e65e40f0471657 (diff) |
Add tvb_get_token_len
This is intended to be a replacement for get_token_len (from strutil.h) when its used on a tvb. It should be a little safer and remove the need for a dissector to use tvb_get_ptr.
Change-Id: Ib2d4a79718b6fba4eb9acc0129b13be6c8199a43
Reviewed-on: https://code.wireshark.org/review/30892
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/tvbuff.h')
-rw-r--r-- | epan/tvbuff.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/epan/tvbuff.h b/epan/tvbuff.h index e2ec44c083..763a659762 100644 --- a/epan/tvbuff.h +++ b/epan/tvbuff.h @@ -807,6 +807,26 @@ WS_DLL_PUBLIC gint tvb_skip_wsp_return(tvbuff_t *tvb, const gint offset); int tvb_skip_guint8(tvbuff_t *tvb, int offset, const int maxlength, const guint8 ch); /** +* Given a tvbuff, an offset into the tvbuff, and a length that starts +* at that offset (which may be -1 for "all the way to the end of the +* tvbuff"), find the end of the token that starts at the +* specified offset in the tvbuff, going no further than the specified +* length. +* +* Return the length of the token, or, if we don't find a terminator: +* +* if "deseg" is true, return -1; +* +* if "deseg" is false, return the amount of data remaining in +* the buffer. +* +* Set "*next_offset" to the offset of the character past the +* terminator, or past the end of the buffer if we don't find a line +* terminator. (It's not set if we return -1.) +*/ +WS_DLL_PUBLIC int tvb_get_token_len(tvbuff_t *tvb, const gint offset, int len, gint *next_offset, const gboolean desegment); + +/** * Call strncmp after checking if enough chars left, returning 0 if * it returns 0 (meaning "equal") and -1 otherwise, otherwise return -1. */ |