diff options
author | Richard Sharpe <sharpe@ns.aus.com> | 2000-09-07 13:00:12 +0000 |
---|---|---|
committer | Richard Sharpe <sharpe@ns.aus.com> | 2000-09-07 13:00:12 +0000 |
commit | 9b2144f9bf07aa92b16b566e81b6bdb8251ffc90 (patch) | |
tree | 0a5f1f66639a320e947f5bf23da8e9d05792a056 /tvbuff.c | |
parent | a708cd140f218c1b8a233f54baed67977a760db6 (diff) | |
download | wireshark-9b2144f9bf07aa92b16b566e81b6bdb8251ffc90.tar.gz wireshark-9b2144f9bf07aa92b16b566e81b6bdb8251ffc90.tar.bz2 wireshark-9b2144f9bf07aa92b16b566e81b6bdb8251ffc90.zip |
Add tvb_strneql routine for checking if a string is present in the
tvb at the current offset.
svn path=/trunk/; revision=2394
Diffstat (limited to 'tvbuff.c')
-rw-r--r-- | tvbuff.c | 28 |
1 files changed, 27 insertions, 1 deletions
@@ -9,7 +9,7 @@ * the data of a backing tvbuff, or can be a composite of * other tvbuffs. * - * $Id: tvbuff.c,v 1.8 2000/08/30 02:50:04 gram Exp $ + * $Id: tvbuff.c,v 1.9 2000/09/07 13:00:12 sharpe Exp $ * * Copyright (c) 2000 by Gilbert Ramirez <gram@xiexie.org> * @@ -998,6 +998,32 @@ gint tvb_strnlen(tvbuff_t *tvb, gint offset, guint maxlength) } } +/* + * Implement strneql etc + */ + +/* Call strncmp after checking if enough chars left, otherwise return -1 */ + +tvb_strneql(tvbuff_t *tvb, gint offset, guint8 *str, gint size) +{ + guint8 *ptr; + + ptr = ensure_contiguous(tvb, offset, size); + + if (ptr) { + + int cmp = strncmp(ptr, str, size); + + return (cmp == 0 ? 0 : -1); /* Make it -1 if comparison failed */ + + } + else { + + return -1; /* Not enough chars in the TVB */ + + } + +} /* Looks for a stringz (NUL-terminated string) in tvbuff and copies * no more than maxlength number of bytes, including terminating NUL, to buffer. |