aboutsummaryrefslogtreecommitdiffstats
path: root/epan/tvbuff.c
diff options
context:
space:
mode:
authorAnders Broman <anders.broman@ericsson.com>2010-03-08 20:45:13 +0000
committerAnders Broman <anders.broman@ericsson.com>2010-03-08 20:45:13 +0000
commit25af78517ec4f15d11864f7785f5cf4856821a80 (patch)
tree3219dd0f933a6450e80401c9dcd2f481a425e112 /epan/tvbuff.c
parent990454aa93f83fcdfb3bef4c02d34052ee5335c2 (diff)
Make tvb_pbrk_guint8() return the found needle.
svn path=/trunk/; revision=32144
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r--epan/tvbuff.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index 5979d114f9..4a12b8efa7 100644
--- a/epan/tvbuff.c
+++ b/epan/tvbuff.c
@@ -970,7 +970,7 @@ guint8_find(const guint8* haystack, size_t haystacklen, guint8 needle)
}
static const guint8*
-guint8_pbrk(const guint8* haystack, size_t haystacklen, const guint8 *needles)
+guint8_pbrk(const guint8* haystack, size_t haystacklen, const guint8 *needles, guchar *found_needle)
{
const guint8 *b;
int i;
@@ -981,8 +981,11 @@ guint8_pbrk(const guint8* haystack, size_t haystacklen, const guint8 *needles)
item = *b;
needlep = needles;
while ((needle = *needlep) != '\0') {
- if (item == needle)
+ if (item == needle){
+ if(found_needle)
+ *found_needle = needle;
return b;
+ }
needlep++;
}
}
@@ -1856,7 +1859,7 @@ tvb_find_guint8(tvbuff_t *tvb, gint offset, gint maxlength, guint8 needle)
* in that case, -1 will be returned if the boundary is reached before
* finding needle. */
gint
-tvb_pbrk_guint8(tvbuff_t *tvb, gint offset, gint maxlength, const guint8 *needles)
+tvb_pbrk_guint8(tvbuff_t *tvb, gint offset, gint maxlength, const guint8 *needles, guchar *found_needle)
{
const guint8 *result;
guint abs_offset, junk_length;
@@ -1886,7 +1889,7 @@ tvb_pbrk_guint8(tvbuff_t *tvb, gint offset, gint maxlength, const guint8 *needle
/* If we have real data, perform our search now. */
if (tvb->real_data) {
- result = guint8_pbrk(tvb->real_data + abs_offset, limit, needles);
+ result = guint8_pbrk(tvb->real_data + abs_offset, limit, needles, found_needle);
if (result == NULL) {
return -1;
}
@@ -1902,7 +1905,7 @@ tvb_pbrk_guint8(tvbuff_t *tvb, gint offset, gint maxlength, const guint8 *needle
case TVBUFF_SUBSET:
return tvb_pbrk_guint8(tvb->tvbuffs.subset.tvb,
abs_offset - tvb->tvbuffs.subset.offset,
- limit, needles);
+ limit, needles, found_needle);
case TVBUFF_COMPOSITE:
DISSECTOR_ASSERT_NOT_REACHED();
@@ -2529,6 +2532,7 @@ tvb_find_line_end(tvbuff_t *tvb, gint offset, int len, gint *next_offset,
gint eob_offset;
gint eol_offset;
int linelen;
+ guchar found_needle = 0;
if (len == -1)
len = tvb_length_remaining(tvb, offset);
@@ -2541,7 +2545,7 @@ tvb_find_line_end(tvbuff_t *tvb, gint offset, int len, gint *next_offset,
/*
* Look either for a CR or an LF.
*/
- eol_offset = tvb_pbrk_guint8(tvb, offset, len, (const guint8 *)"\r\n");
+ eol_offset = tvb_pbrk_guint8(tvb, offset, len, (const guint8 *)"\r\n", &found_needle);
if (eol_offset == -1) {
/*
* No CR or LF - line is presumably continued in next packet.
@@ -2570,8 +2574,8 @@ tvb_find_line_end(tvbuff_t *tvb, gint offset, int len, gint *next_offset,
/*
* Is it a CR?
- */
- if (tvb_get_guint8(tvb, eol_offset) == '\r') {
+ */
+ if (found_needle == '\r') {
/*
* Yes - is it followed by an LF?
*/
@@ -2643,7 +2647,7 @@ tvb_find_line_end_unquoted(tvbuff_t *tvb, gint offset, int len,
{
gint cur_offset, char_offset;
gboolean is_quoted;
- guchar c;
+ guchar c = 0;
gint eob_offset;
int linelen;
@@ -2672,7 +2676,7 @@ tvb_find_line_end_unquoted(tvbuff_t *tvb, gint offset, int len,
* Look either for a CR, an LF, or a '"'.
*/
char_offset = tvb_pbrk_guint8(tvb, cur_offset, len,
- (const guint8 *)"\r\n\"");
+ (const guint8 *)"\r\n\"", &c);
}
if (char_offset == -1) {
/*
@@ -2698,7 +2702,6 @@ tvb_find_line_end_unquoted(tvbuff_t *tvb, gint offset, int len,
/*
* OK, what is it?
*/
- c = tvb_get_guint8(tvb, char_offset);
if (c == '"') {
/*
* Un-quoted "; it begins a quoted