summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am8
-rw-r--r--Makefile.nmake3
-rw-r--r--packet-ftp.c3
-rw-r--r--packet-http.c3
-rw-r--r--packet-nntp.c3
-rw-r--r--packet-rsh.c3
-rw-r--r--packet-rtcp.c3
-rw-r--r--packet-rtsp.c3
-rw-r--r--packet-sdp.c3
-rw-r--r--packet-smb-pipe.c3
-rw-r--r--packet-smb.c3
-rw-r--r--packet-smtp.c3
-rw-r--r--packet-socks.c3
-rw-r--r--packet-srvloc.c3
-rw-r--r--packet-tcp.c3
-rw-r--r--packet-telnet.c3
-rw-r--r--packet.c188
-rw-r--r--packet.h7
-rw-r--r--strutil.c221
-rw-r--r--strutil.h36
-rw-r--r--tvbuff.c5
21 files changed, 296 insertions, 214 deletions
diff --git a/Makefile.am b/Makefile.am
index 486ff7a1bc..fc2b0b6c6b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
# Makefile.am
# Automake file for Ethereal
#
-# $Id: Makefile.am,v 1.225 2000/08/30 12:42:30 sharpe Exp $
+# $Id: Makefile.am,v 1.226 2000/09/11 16:16:00 gram Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@zing.org>
@@ -306,6 +306,8 @@ ETHEREAL_COMMON_SOURCES = \
resolv.c \
resolv.h \
smb.h \
+ strutil.c \
+ strutil.h \
timestamp.h \
tvbuff.c \
tvbuff.h \
@@ -472,8 +474,8 @@ randpkt.o: randpkt.c
randpkt: randpkt.o wiretap/libwiretap.a
$(LINK) -o randpkt randpkt.o wiretap/libwiretap.a `glib-config --libs` -lz
-tvbtest: tvbtest.o tvbuff.o except.o
- $(LINK) -o tvbtest tvbtest.o tvbuff.o except.o `glib-config --libs`
+tvbtest: tvbtest.o tvbuff.o except.o strutil.o
+ $(LINK) -o tvbtest tvbtest.o tvbuff.o except.o strutil.o `glib-config --libs`
DISTCLEANFILES = \
register.c \
diff --git a/Makefile.nmake b/Makefile.nmake
index 1cc763b28a..4b9789963b 100644
--- a/Makefile.nmake
+++ b/Makefile.nmake
@@ -1,7 +1,7 @@
## Makefile for building ethereal.exe with Microsoft C and nmake
## Use: nmake -f makefile.nmake
#
-# $Id: Makefile.nmake,v 1.53 2000/08/18 15:26:52 gram Exp $
+# $Id: Makefile.nmake,v 1.54 2000/09/11 16:16:01 gram Exp $
include config.nmake
@@ -177,6 +177,7 @@ ETHEREAL_COMMON_OBJECTS = \
ptvcursor.obj \
register.obj \
resolv.obj \
+ strutil.obj \
tvbuff.obj \
util.obj \
xdlc.obj \
diff --git a/packet-ftp.c b/packet-ftp.c
index ceec43993d..b09c3c4da5 100644
--- a/packet-ftp.c
+++ b/packet-ftp.c
@@ -2,7 +2,7 @@
* Routines for ftp packet dissection
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
*
- * $Id: packet-ftp.c,v 1.18 2000/08/13 14:08:11 deniel Exp $
+ * $Id: packet-ftp.c,v 1.19 2000/09/11 16:16:01 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -43,6 +43,7 @@
#include <string.h>
#include <glib.h>
#include "packet.h"
+#include "strutil.h"
static int proto_ftp = -1;
static int hf_ftp_response = -1;
diff --git a/packet-http.c b/packet-http.c
index 5b1e88366c..daacc6e1d2 100644
--- a/packet-http.c
+++ b/packet-http.c
@@ -3,7 +3,7 @@
*
* Guy Harris <guy@alum.mit.edu>
*
- * $Id: packet-http.c,v 1.21 2000/08/13 14:08:12 deniel Exp $
+ * $Id: packet-http.c,v 1.22 2000/09/11 16:16:02 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -41,6 +41,7 @@
#include <glib.h>
#include "packet.h"
#include "packet-ipp.h"
+#include "strutil.h"
typedef enum _http_type {
HTTP_REQUEST,
diff --git a/packet-nntp.c b/packet-nntp.c
index 0a27f21f33..5c8aedeef1 100644
--- a/packet-nntp.c
+++ b/packet-nntp.c
@@ -2,7 +2,7 @@
* Routines for nntp packet dissection
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
*
- * $Id: packet-nntp.c,v 1.12 2000/08/13 14:08:31 deniel Exp $
+ * $Id: packet-nntp.c,v 1.13 2000/09/11 16:16:02 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -40,6 +40,7 @@
#include <string.h>
#include <glib.h>
#include "packet.h"
+#include "strutil.h"
static int proto_nntp = -1;
static int hf_nntp_response = -1;
diff --git a/packet-rsh.c b/packet-rsh.c
index 298412ae8f..2facb05e66 100644
--- a/packet-rsh.c
+++ b/packet-rsh.c
@@ -4,7 +4,7 @@
* Robert Tsai <rtsai@netapp.com>
* Liberally copied from packet-http.c, by Guy Harris <guy@alum.mit.edu>
*
- * $Id: packet-rsh.c,v 1.3 2000/08/13 14:08:43 deniel Exp $
+ * $Id: packet-rsh.c,v 1.4 2000/09/11 16:16:02 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -38,6 +38,7 @@
#include <glib.h>
#include "packet.h"
+#include "strutil.h"
static int proto_rsh = -1;
static int hf_rsh_response = -1;
diff --git a/packet-rtcp.c b/packet-rtcp.c
index c0f7b56088..604f15bac6 100644
--- a/packet-rtcp.c
+++ b/packet-rtcp.c
@@ -3,7 +3,7 @@
*
* Jason Lango <jal@netapp.com>
*
- * $Id: packet-rtcp.c,v 1.4 2000/08/13 14:08:43 deniel Exp $
+ * $Id: packet-rtcp.c,v 1.5 2000/09/11 16:16:02 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -43,6 +43,7 @@
#include <glib.h>
#include "packet.h"
#include "packet-rtcp.h"
+#include "strutil.h"
static int proto_rtcp = -1;
diff --git a/packet-rtsp.c b/packet-rtsp.c
index 62207931dd..46e7960f2a 100644
--- a/packet-rtsp.c
+++ b/packet-rtsp.c
@@ -4,7 +4,7 @@
* Jason Lango <jal@netapp.com>
* Liberally copied from packet-http.c, by Guy Harris <guy@alum.mit.edu>
*
- * $Id: packet-rtsp.c,v 1.17 2000/08/21 18:36:33 guy Exp $
+ * $Id: packet-rtsp.c,v 1.18 2000/09/11 16:16:03 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -43,6 +43,7 @@
#include "packet-rtp.h"
#include "packet-rtcp.h"
#include "conversation.h"
+#include "strutil.h"
static int proto_rtsp = -1;
static gint ett_rtsp = -1;
diff --git a/packet-sdp.c b/packet-sdp.c
index 5b57df7e8f..edb6a127df 100644
--- a/packet-sdp.c
+++ b/packet-sdp.c
@@ -4,7 +4,7 @@
* Jason Lango <jal@netapp.com>
* Liberally copied from packet-http.c, by Guy Harris <guy@alum.mit.edu>
*
- * $Id: packet-sdp.c,v 1.9 2000/08/13 14:08:46 deniel Exp $
+ * $Id: packet-sdp.c,v 1.10 2000/09/11 16:16:03 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -39,6 +39,7 @@
#include <glib.h>
#include "packet.h"
+#include "strutil.h"
static int proto_sdp = -1;
diff --git a/packet-smb-pipe.c b/packet-smb-pipe.c
index 3a497e3a08..c6b120e8f5 100644
--- a/packet-smb-pipe.c
+++ b/packet-smb-pipe.c
@@ -2,7 +2,7 @@
* Routines for smb packet dissection
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
*
- * $Id: packet-smb-pipe.c,v 1.10 2000/08/13 14:08:49 deniel Exp $
+ * $Id: packet-smb-pipe.c,v 1.11 2000/09/11 16:16:03 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -47,6 +47,7 @@
#include "conversation.h"
#include "smb.h"
#include "alignment.h"
+#include "strutil.h"
static int proto_smb_lanman = -1;
diff --git a/packet-smb.c b/packet-smb.c
index 4ad21712b5..68edea73d8 100644
--- a/packet-smb.c
+++ b/packet-smb.c
@@ -2,7 +2,7 @@
* Routines for smb packet dissection
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
*
- * $Id: packet-smb.c,v 1.71 2000/08/13 14:08:50 deniel Exp $
+ * $Id: packet-smb.c,v 1.72 2000/09/11 16:16:04 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -47,6 +47,7 @@
#include "conversation.h"
#include "smb.h"
#include "alignment.h"
+#include "strutil.h"
guint32 dissect_mailslot_smb(const u_char *, int, frame_data *, proto_tree *, proto_tree *, struct smb_info, int, int, int, int, const u_char *, int, int, int, int);
diff --git a/packet-smtp.c b/packet-smtp.c
index 4500b46553..7e2c0152e6 100644
--- a/packet-smtp.c
+++ b/packet-smtp.c
@@ -1,7 +1,7 @@
/* packet-smtp.c
* Routines for SMTP packet disassembly
*
- * $Id: packet-smtp.c,v 1.5 2000/08/26 11:25:28 sharpe Exp $
+ * $Id: packet-smtp.c,v 1.6 2000/09/11 16:16:07 gram Exp $
*
* Copyright (c) 2000 by Richard Sharpe <rsharpe@ns.aus.com>
*
@@ -45,6 +45,7 @@
#include "conversation.h"
#include "resolv.h"
#include "prefs.h"
+#include "strutil.h"
#define TCP_PORT_SMTP 25
diff --git a/packet-socks.c b/packet-socks.c
index e2edb4e575..d7510362af 100644
--- a/packet-socks.c
+++ b/packet-socks.c
@@ -2,7 +2,7 @@
* Routines for socks versions 4 &5 packet dissection
* Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
*
- * $Id: packet-socks.c,v 1.11 2000/08/21 18:36:33 guy Exp $
+ * $Id: packet-socks.c,v 1.12 2000/09/11 16:16:07 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -76,6 +76,7 @@
#include "packet-tcp.h"
#include "packet-udp.h"
+#include "strutil.h"
#define CHECK_PACKET_LENGTH(X) if (!BYTES_ARE_IN_FRAME(offset, X)){ \
diff --git a/packet-srvloc.c b/packet-srvloc.c
index 3525e86bba..988beb9c41 100644
--- a/packet-srvloc.c
+++ b/packet-srvloc.c
@@ -6,7 +6,7 @@
* In particular I have not had an opportunity to see how it
* responds to SRVLOC over TCP.
*
- * $Id: packet-srvloc.c,v 1.14 2000/08/13 14:09:02 deniel Exp $
+ * $Id: packet-srvloc.c,v 1.15 2000/09/11 16:16:08 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -54,6 +54,7 @@
#include "packet.h"
#include "packet-ipv6.h"
+#include "strutil.h"
static int proto_srvloc = -1;
static int hf_srvloc_version = -1;
diff --git a/packet-tcp.c b/packet-tcp.c
index cd5cb266d8..2be0cb3405 100644
--- a/packet-tcp.c
+++ b/packet-tcp.c
@@ -1,7 +1,7 @@
/* packet-tcp.c
* Routines for TCP packet disassembly
*
- * $Id: packet-tcp.c,v 1.81 2000/08/13 14:08:47 deniel Exp $
+ * $Id: packet-tcp.c,v 1.82 2000/09/11 16:16:10 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -50,6 +50,7 @@
#include "packet-tcp.h"
#include "packet-ip.h"
#include "conversation.h"
+#include "strutil.h"
/* Place TCP summary in proto tree */
gboolean g_tcp_summary_in_tree = TRUE;
diff --git a/packet-telnet.c b/packet-telnet.c
index 3d2826c126..8bc0cb801a 100644
--- a/packet-telnet.c
+++ b/packet-telnet.c
@@ -2,7 +2,7 @@
* Routines for telnet packet dissection
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
*
- * $Id: packet-telnet.c,v 1.15 2000/08/13 14:08:44 deniel Exp $
+ * $Id: packet-telnet.c,v 1.16 2000/09/11 16:16:11 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -42,6 +42,7 @@
#include <string.h>
#include <glib.h>
#include "packet.h"
+#include "strutil.h"
static int proto_telnet = -1;
diff --git a/packet.c b/packet.c
index 35fdcbb38d..2dcae0a5e0 100644
--- a/packet.c
+++ b/packet.c
@@ -1,7 +1,7 @@
/* packet.c
* Routines for packet disassembly
*
- * $Id: packet.c,v 1.104 2000/09/10 06:44:35 guy Exp $
+ * $Id: packet.c,v 1.105 2000/09/11 16:16:11 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -409,192 +409,6 @@ display_signed_time(gchar *buf, int buflen, gint32 sec, gint32 usec)
snprintf(buf, buflen, "%s%d.%06d", sign, sec, usec);
}
-/*
- * Given a pointer into a data buffer, and to the end of the buffer,
- * find the end of the (putative) line at that position in the data
- * buffer.
- * Return a pointer to the EOL character(s) in "*eol".
- */
-const u_char *
-find_line_end(const u_char *data, const u_char *dataend, const u_char **eol)
-{
- const u_char *lineend;
-
- lineend = memchr(data, '\n', dataend - data);
- if (lineend == NULL) {
- /*
- * No LF - line is probably continued in next TCP segment.
- */
- lineend = dataend;
- *eol = dataend;
- } else {
- /*
- * Is the LF at the beginning of the line?
- */
- if (lineend > data) {
- /*
- * No - is it preceded by a carriage return?
- * (Perhaps it's supposed to be, but that's not guaranteed....)
- */
- if (*(lineend - 1) == '\r') {
- /*
- * Yes. The EOL starts with the CR.
- */
- *eol = lineend - 1;
- } else {
- /*
- * No. The EOL starts with the LF.
- */
- *eol = lineend;
-
- /*
- * I seem to remember that we once saw lines ending with LF-CR
- * in an HTTP request or response, so check if it's *followed*
- * by a carriage return.
- */
- if (lineend < (dataend - 1) && *(lineend + 1) == '\r') {
- /*
- * It's <non-LF><LF><CR>; say it ends with the CR.
- */
- lineend++;
- }
- }
- }
-
- /*
- * Point to the character after the last character.
- */
- lineend++;
- }
- return lineend;
-}
-
-#define MAX_COLUMNS_LINE_DETAIL 62
-
-/*
- * Get the length of the next token in a line, and the beginning of the
- * next token after that (if any).
- * Return 0 if there is no next token.
- */
-int
-get_token_len(const u_char *linep, const u_char *lineend,
- const u_char **next_token)
-{
- const u_char *tokenp;
- int token_len;
-
- tokenp = linep;
-
- /*
- * Search for a blank, a CR or an LF, or the end of the buffer.
- */
- while (linep < lineend && *linep != ' ' && *linep != '\r' && *linep != '\n')
- linep++;
- token_len = linep - tokenp;
-
- /*
- * Skip trailing blanks.
- */
- while (linep < lineend && *linep == ' ')
- linep++;
-
- *next_token = linep;
-
- return token_len;
-}
-
-/*
- * Given a string, generate a string from it that shows non-printable
- * characters as C-style escapes, and return a pointer to it.
- */
-gchar *
-format_text(const u_char *string, int len)
-{
- static gchar fmtbuf[MAX_COLUMNS_LINE_DETAIL + 3 + 4 + 1];
- gchar *fmtbufp;
- int column;
- const u_char *stringend = string + len;
- u_char c;
- int i;
-
- column = 0;
- fmtbufp = &fmtbuf[0];
- while (string < stringend) {
- if (column >= MAX_COLUMNS_LINE_DETAIL) {
- /*
- * Put "..." and quit.
- */
- strcpy(fmtbufp, " ...");
- fmtbufp += 4;
- break;
- }
- c = *string++;
- if (isprint(c)) {
- *fmtbufp++ = c;
- column++;
- } else {
- *fmtbufp++ = '\\';
- column++;
- switch (c) {
-
- case '\\':
- *fmtbufp++ = '\\';
- column++;
- break;
-
- case '\a':
- *fmtbufp++ = 'a';
- column++;
- break;
-
- case '\b':
- *fmtbufp++ = 'b';
- column++;
- break;
-
- case '\f':
- *fmtbufp++ = 'f';
- column++;
- break;
-
- case '\n':
- *fmtbufp++ = 'n';
- column++;
- break;
-
- case '\r':
- *fmtbufp++ = 'r';
- column++;
- break;
-
- case '\t':
- *fmtbufp++ = 't';
- column++;
- break;
-
- case '\v':
- *fmtbufp++ = 'v';
- column++;
- break;
-
- default:
- i = (c>>6)&03;
- *fmtbufp++ = i + '0';
- column++;
- i = (c>>3)&07;
- *fmtbufp++ = i + '0';
- column++;
- i = (c>>0)&07;
- *fmtbufp++ = i + '0';
- column++;
- break;
- }
- }
- }
- *fmtbufp = '\0';
- return fmtbuf;
-}
-
/* Tries to match val against each element in the value_string array vs.
Returns the associated string ptr on a match.
diff --git a/packet.h b/packet.h
index 9b2a2dd357..fdcac95631 100644
--- a/packet.h
+++ b/packet.h
@@ -1,7 +1,7 @@
/* packet.h
* Definitions for packet disassembly structures and routines
*
- * $Id: packet.h,v 1.200 2000/09/10 06:44:36 guy Exp $
+ * $Id: packet.h,v 1.201 2000/09/11 16:16:12 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -252,11 +252,6 @@ gchar* abs_time_to_str(struct timeval*);
gchar* rel_time_to_str(struct timeval*);
gchar* time_secs_to_str(guint32);
gchar* bytes_to_str(const guint8 *, int);
-const u_char *find_line_end(const u_char *data, const u_char *dataend,
- const u_char **eol);
-int get_token_len(const u_char *linep, const u_char *lineend,
- const u_char **next_token);
-gchar* format_text(const u_char *line, int len);
gchar* val_to_str(guint32, const value_string *, const char *);
gchar* match_strval(guint32, const value_string*);
char * decode_bitfield_value(char *buf, guint32 val, guint32 mask, int width);
diff --git a/strutil.c b/strutil.c
new file mode 100644
index 0000000000..e061cb77a0
--- /dev/null
+++ b/strutil.c
@@ -0,0 +1,221 @@
+/* strutil.c
+ * String utility routines
+ *
+ * $Id: strutil.c,v 1.1 2000/09/11 16:16:13 gram Exp $
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@zing.org>
+ * Copyright 1998 Gerald Combs
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <glib.h>
+
+
+/*
+ * Given a pointer into a data buffer, and to the end of the buffer,
+ * find the end of the (putative) line at that position in the data
+ * buffer.
+ * Return a pointer to the EOL character(s) in "*eol".
+ */
+const u_char *
+find_line_end(const u_char *data, const u_char *dataend, const u_char **eol)
+{
+ const u_char *lineend;
+
+ lineend = memchr(data, '\n', dataend - data);
+ if (lineend == NULL) {
+ /*
+ * No LF - line is probably continued in next TCP segment.
+ */
+ lineend = dataend;
+ *eol = dataend;
+ } else {
+ /*
+ * Is the LF at the beginning of the line?
+ */
+ if (lineend > data) {
+ /*
+ * No - is it preceded by a carriage return?
+ * (Perhaps it's supposed to be, but that's not guaranteed....)
+ */
+ if (*(lineend - 1) == '\r') {
+ /*
+ * Yes. The EOL starts with the CR.
+ */
+ *eol = lineend - 1;
+ } else {
+ /*
+ * No. The EOL starts with the LF.
+ */
+ *eol = lineend;
+
+ /*
+ * I seem to remember that we once saw lines ending with LF-CR
+ * in an HTTP request or response, so check if it's *followed*
+ * by a carriage return.
+ */
+ if (lineend < (dataend - 1) && *(lineend + 1) == '\r') {
+ /*
+ * It's <non-LF><LF><CR>; say it ends with the CR.
+ */
+ lineend++;
+ }
+ }
+ }
+
+ /*
+ * Point to the character after the last character.
+ */
+ lineend++;
+ }
+ return lineend;
+}
+
+/*
+ * Get the length of the next token in a line, and the beginning of the
+ * next token after that (if any).
+ * Return 0 if there is no next token.
+ */
+int
+get_token_len(const u_char *linep, const u_char *lineend,
+ const u_char **next_token)
+{
+ const u_char *tokenp;
+ int token_len;
+
+ tokenp = linep;
+
+ /*
+ * Search for a blank, a CR or an LF, or the end of the buffer.
+ */
+ while (linep < lineend && *linep != ' ' && *linep != '\r' && *linep != '\n')
+ linep++;
+ token_len = linep - tokenp;
+
+ /*
+ * Skip trailing blanks.
+ */
+ while (linep < lineend && *linep == ' ')
+ linep++;
+
+ *next_token = linep;
+
+ return token_len;
+}
+
+
+#define MAX_COLUMNS_LINE_DETAIL 62
+
+/*
+ * Given a string, generate a string from it that shows non-printable
+ * characters as C-style escapes, and return a pointer to it.
+ */
+gchar *
+format_text(const u_char *string, int len)
+{
+ static gchar fmtbuf[MAX_COLUMNS_LINE_DETAIL + 3 + 4 + 1];
+ gchar *fmtbufp;
+ int column;
+ const u_char *stringend = string + len;
+ u_char c;
+ int i;
+
+ column = 0;
+ fmtbufp = &fmtbuf[0];
+ while (string < stringend) {
+ if (column >= MAX_COLUMNS_LINE_DETAIL) {
+ /*
+ * Put "..." and quit.
+ */
+ strcpy(fmtbufp, " ...");
+ fmtbufp += 4;
+ break;
+ }
+ c = *string++;
+ if (isprint(c)) {
+ *fmtbufp++ = c;
+ column++;
+ } else {
+ *fmtbufp++ = '\\';
+ column++;
+ switch (c) {
+
+ case '\\':
+ *fmtbufp++ = '\\';
+ column++;
+ break;
+
+ case '\a':
+ *fmtbufp++ = 'a';
+ column++;
+ break;
+
+ case '\b':
+ *fmtbufp++ = 'b';
+ column++;
+ break;
+
+ case '\f':
+ *fmtbufp++ = 'f';
+ column++;
+ break;
+
+ case '\n':
+ *fmtbufp++ = 'n';
+ column++;
+ break;
+
+ case '\r':
+ *fmtbufp++ = 'r';
+ column++;
+ break;
+
+ case '\t':
+ *fmtbufp++ = 't';
+ column++;
+ break;
+
+ case '\v':
+ *fmtbufp++ = 'v';
+ column++;
+ break;
+
+ default:
+ i = (c>>6)&03;
+ *fmtbufp++ = i + '0';
+ column++;
+ i = (c>>3)&07;
+ *fmtbufp++ = i + '0';
+ column++;
+ i = (c>>0)&07;
+ *fmtbufp++ = i + '0';
+ column++;
+ break;
+ }
+ }
+ }
+ *fmtbufp = '\0';
+ return fmtbuf;
+}
diff --git a/strutil.h b/strutil.h
new file mode 100644
index 0000000000..56607a77c0
--- /dev/null
+++ b/strutil.h
@@ -0,0 +1,36 @@
+/* util.h
+ * Utility definitions
+ *
+ * $Id: strutil.h,v 1.1 2000/09/11 16:16:13 gram Exp $
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@zing.org>
+ * Copyright 1998 Gerald Combs
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __STRUTIL_H__
+#define __STRUTIL_H__
+
+const u_char *find_line_end(const u_char *data, const u_char *dataend,
+ const u_char **eol);
+int get_token_len(const u_char *linep, const u_char *lineend,
+ const u_char **next_token);
+gchar* format_text(const u_char *line, int len);
+
+
+#endif /* __STRUTIL_H__ */
diff --git a/tvbuff.c b/tvbuff.c
index 98c6b006cd..1b2953e185 100644
--- a/tvbuff.c
+++ b/tvbuff.c
@@ -9,7 +9,7 @@
* the data of a backing tvbuff, or can be a composite of
* other tvbuffs.
*
- * $Id: tvbuff.c,v 1.13 2000/09/11 07:33:56 sharpe Exp $
+ * $Id: tvbuff.c,v 1.14 2000/09/11 16:16:13 gram Exp $
*
* Copyright (c) 2000 by Gilbert Ramirez <gram@xiexie.org>
*
@@ -37,8 +37,7 @@
#include "pint.h"
#include "tvbuff.h"
-#include "packet.h"
-
+#include "strutil.h"
typedef struct {
/* The backing tvbuff_t */