aboutsummaryrefslogtreecommitdiffstats
path: root/epan/tvbuff.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2018-10-20 17:46:34 -0400
committerAnders Broman <a.broman58@gmail.com>2018-10-21 07:55:40 +0000
commit7a4e9325718e13e5d977677032f211c93e91aba9 (patch)
tree202cbefec4c9a64ff6de997bf6554d36d5e35ec6 /epan/tvbuff.c
parent7ce9081fdcf48085611d2de6db0964dffd9ae700 (diff)
Add tvb_ascii_isprint API
This allows dissectors to check if a portion of the tvb is an ascii string while hiding the use of tvb_get_ptr. Change-Id: Iaec7559dcfdefb8a5ae23e099ced45e90e611f8f Reviewed-on: https://code.wireshark.org/review/30291 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r--epan/tvbuff.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index c759b91a26..9d3ca4b82f 100644
--- a/epan/tvbuff.c
+++ b/epan/tvbuff.c
@@ -3330,6 +3330,17 @@ tvb_get_nstringz0(tvbuff_t *tvb, const gint offset, const guint bufsize, guint8*
}
}
+gboolean tvb_ascii_isprint(tvbuff_t *tvb, const gint offset, const gint length)
+{
+ const guint8* buf = tvb_get_ptr(tvb, offset, length);
+
+ for (int i = 0; i < length; i++, buf++)
+ if (!g_ascii_isprint(*buf))
+ return FALSE;
+
+ return TRUE;
+}
+
static ws_mempbrk_pattern pbrk_crlf;
/*