summaryrefslogtreecommitdiff
path: root/wiretap/csids.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-10-09 16:44:15 -0700
committerGuy Harris <guy@alum.mit.edu>2014-10-09 23:45:30 +0000
commit45e462985db891248ffcb9db21e6b66733de0b84 (patch)
tree90d031f9769c07abaea83330a58dd9d3933eb7b1 /wiretap/csids.c
parent112c90a04b778958985b02b9663743cea1039f47 (diff)
downloadwireshark-45e462985db891248ffcb9db21e6b66733de0b84.tar.gz
Use an enum for the open-routine return value, as per Evan Huus's suggestion.
Clean up some things we ran across while making those changes. Change-Id: Ic0d8943d36e6e120d7af0a6148fad98015d1e83e Reviewed-on: https://code.wireshark.org/review/4581 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap/csids.c')
-rw-r--r--wiretap/csids.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/wiretap/csids.c b/wiretap/csids.c
index 72f4f940a8..7c0551a95c 100644
--- a/wiretap/csids.c
+++ b/wiretap/csids.c
@@ -57,8 +57,7 @@ struct csids_header {
guint16 caplen; /* the capture length */
};
-/* XXX - return -1 on I/O error and actually do something with 'err'. */
-int csids_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val csids_open(wtap *wth, int *err, gchar **err_info)
{
/* There is no file header. There is only a header for each packet
* so we read a packet header and compare the caplen with iplen. They
@@ -77,31 +76,31 @@ int csids_open(wtap *wth, int *err, gchar **err_info)
/* check the file to make sure it is a csids file. */
if( !wtap_read_bytes( wth->fh, &hdr, sizeof( struct csids_header), err, err_info ) ) {
if( *err != WTAP_ERR_SHORT_READ ) {
- return -1;
+ return WTAP_OPEN_ERROR;
}
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
if( hdr.zeropad != 0 || hdr.caplen == 0 ) {
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
hdr.seconds = pntoh32( &hdr.seconds );
hdr.caplen = pntoh16( &hdr.caplen );
if( !wtap_read_bytes( wth->fh, &tmp, 2, err, err_info ) ) {
if( *err != WTAP_ERR_SHORT_READ ) {
- return -1;
+ return WTAP_OPEN_ERROR;
}
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
if( !wtap_read_bytes(wth->fh, &iplen, 2, err, err_info ) ) {
if( *err != WTAP_ERR_SHORT_READ ) {
- return -1;
+ return WTAP_OPEN_ERROR;
}
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
iplen = pntoh16(&iplen);
if ( iplen == 0 )
- return 0;
+ return WTAP_OPEN_NOT_MINE;
/* if iplen and hdr.caplen are equal, default to no byteswap. */
if( iplen > hdr.caplen ) {
@@ -114,7 +113,7 @@ int csids_open(wtap *wth, int *err, gchar **err_info)
byteswap = TRUE;
} else {
/* don't know this one */
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
} else {
byteswap = FALSE;
@@ -122,7 +121,7 @@ int csids_open(wtap *wth, int *err, gchar **err_info)
/* no file header. So reset the fh to 0 so we can read the first packet */
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
csids = (csids_t *)g_malloc(sizeof(csids_t));
wth->priv = (void *)csids;
@@ -134,7 +133,7 @@ int csids_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_seek_read = csids_seek_read;
wth->file_tsprec = WTAP_TSPREC_SEC;
- return 1;
+ return WTAP_OPEN_MINE;
}
/* Find the next packet and parse it; called from wtap_read(). */