aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/vms.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2004-01-25 21:55:17 +0000
committerGuy Harris <guy@alum.mit.edu>2004-01-25 21:55:17 +0000
commitd6cd61061efe7207b298b5ac40a92e7b86b00b3e (patch)
tree392720e018248f9cf2b46db00a4a9740ff7d1fca /wiretap/vms.c
parent34bddb3c1a932632fd0515f7999ed96ef9974611 (diff)
Have the Wiretap open, read, and seek-and-read routines return, in
addition to an error code, an error info string, for WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and WTAP_ERR_BAD_RECORD errors. Replace the error messages logged with "g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed strings returned as the error info string, and change the callers of those routines to, for those errors, put the info string into the printed message or alert box for the error. Add messages for cases where those errors were returned without printing an additional message. Nobody uses the error code from "cf_read()" - "cf_read()" puts up the alert box itself for failures; get rid of the error code, so it just returns a success/failure indication. Rename "file_read_error_message()" to "cf_read_error_message()", as it handles read errors from Wiretap, and have it take an error info string as an argument. (That handles a lot of the work of putting the info string into the error message.) Make some variables in "ascend-grammar.y" static. Check the return value of "erf_read_header()" in "erf_seek_read()". Get rid of an unused #define in "i4btrace.c". svn path=/trunk/; revision=9852
Diffstat (limited to 'wiretap/vms.c')
-rw-r--r--wiretap/vms.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/wiretap/vms.c b/wiretap/vms.c
index 9258b234d7..a8f9ee7d60 100644
--- a/wiretap/vms.c
+++ b/wiretap/vms.c
@@ -1,6 +1,6 @@
/* vms.c
*
- * $Id: vms.c,v 1.20 2004/01/24 16:48:12 jmayer Exp $
+ * $Id: vms.c,v 1.21 2004/01/25 21:55:17 guy Exp $
*
* Wiretap Library
* Copyright (c) 2001 by Marc Milgram <ethereal@mmilgram.NOSPAMmail.net>
@@ -143,14 +143,16 @@ to handle them.
#define VMS_HEADER_LINES_TO_CHECK 200
#define VMS_LINE_LENGTH 240
-static gboolean vms_read(wtap *wth, int *err, long *data_offset);
+static gboolean vms_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset);
static gboolean vms_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err);
+ union wtap_pseudo_header *pseudo_header, guint8 *pd, int len,
+ int *err, gchar **err_info);
static gboolean parse_single_hex_dump_line(char* rec, guint8 *buf,
long byte_offset, int in_off, int remaining_bytes);
static gboolean parse_vms_hex_dump(FILE_T fh, int pkt_len, guint8* buf,
- int *err);
-static int parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err);
+ int *err, gchar **err_info);
+static int parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err, gchar **err_info);
#ifdef TCPIPTRACE_FRAGMENTS_HAVE_HEADER_LINE
/* Seeks to the beginning of the next packet, and returns the
@@ -253,7 +255,7 @@ static gboolean vms_check_file_type(wtap *wth, int *err)
}
-int vms_open(wtap *wth, int *err)
+int vms_open(wtap *wth, int *err, gchar **err_info _U_)
{
/* Look for VMS header */
if (!vms_check_file_type(wth, err)) {
@@ -274,7 +276,8 @@ int vms_open(wtap *wth, int *err)
}
/* Find the next packet and parse it; called from wtap_loop(). */
-static gboolean vms_read(wtap *wth, int *err, long *data_offset)
+static gboolean vms_read(wtap *wth, int *err, gchar **err_info,
+ long *data_offset)
{
long offset = 0;
guint8 *buf;
@@ -290,7 +293,7 @@ static gboolean vms_read(wtap *wth, int *err, long *data_offset)
return FALSE;
/* Parse the header */
- pkt_len = parse_vms_rec_hdr(wth, wth->fh, err);
+ pkt_len = parse_vms_rec_hdr(wth, wth->fh, err, err_info);
if (pkt_len == -1)
return FALSE;
@@ -299,7 +302,7 @@ static gboolean vms_read(wtap *wth, int *err, long *data_offset)
buf = buffer_start_ptr(wth->frame_buffer);
/* Convert the ASCII hex dump to binary data */
- if (!parse_vms_hex_dump(wth->fh, pkt_len, buf, err))
+ if (!parse_vms_hex_dump(wth->fh, pkt_len, buf, err, err_info))
return FALSE;
wth->data_offset = offset;
@@ -311,22 +314,25 @@ static gboolean vms_read(wtap *wth, int *err, long *data_offset)
static gboolean
vms_seek_read (wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header _U_,
- guint8 *pd, int len, int *err)
+ guint8 *pd, int len, int *err, gchar **err_info)
{
int pkt_len;
if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1)
return FALSE;
- pkt_len = parse_vms_rec_hdr(NULL, wth->random_fh, err);
+ pkt_len = parse_vms_rec_hdr(NULL, wth->random_fh, err, err_info);
if (pkt_len != len) {
- if (pkt_len != -1)
+ if (pkt_len != -1) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("vms: requested length %d doesn't match length %d",
+ len, pkt_len);
+ }
return FALSE;
}
- return parse_vms_hex_dump(wth->random_fh, pkt_len, pd, err);
+ return parse_vms_hex_dump(wth->random_fh, pkt_len, pd, err, err_info);
}
/* isdumpline assumes that dump lines start with some non-alphanumerics
@@ -356,7 +362,7 @@ isdumpline( gchar *line )
/* Parses a packet record header. */
static int
-parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err)
+parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err, gchar **err_info)
{
char line[VMS_LINE_LENGTH + 1];
int num_items_scanned;
@@ -406,6 +412,7 @@ parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err)
/* We will need to add code to handle new format */
if (num_items_scanned != 8) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("vms: header line not valid");
return -1;
}
}
@@ -416,6 +423,7 @@ parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err)
if ( !*p ) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("vms: Length field not valid");
return -1;
}
@@ -444,7 +452,8 @@ parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err)
/* Converts ASCII hex dump to binary data */
static gboolean
-parse_vms_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err)
+parse_vms_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err,
+ gchar **err_info)
{
gchar line[VMS_LINE_LENGTH + 1];
int i;
@@ -476,6 +485,7 @@ parse_vms_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err)
if (!parse_single_hex_dump_line(line, buf, i,
offset, pkt_len - i)) {
*err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("vms: hex dump not valid");
return FALSE;
}
}