summaryrefslogtreecommitdiff
path: root/wiretap/daintree-sna.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/daintree-sna.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/daintree-sna.c')
-rw-r--r--wiretap/daintree-sna.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/wiretap/daintree-sna.c b/wiretap/daintree-sna.c
index 672393dc95..eeddbc800f 100644
--- a/wiretap/daintree-sna.c
+++ b/wiretap/daintree-sna.c
@@ -90,34 +90,31 @@ static gboolean daintree_sna_process_hex_data(struct wtap_pkthdr *phdr,
Buffer *buf, char *readData, int *err, gchar **err_info);
/* Open a file and determine if it's a Daintree file */
-int daintree_sna_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val daintree_sna_open(wtap *wth, int *err, gchar **err_info)
{
char readLine[DAINTREE_MAX_LINE_SIZE];
- guint i;
/* get first line of file header */
if (file_gets(readLine, DAINTREE_MAX_LINE_SIZE, wth->fh)==NULL) {
*err = file_error(wth->fh, err_info);
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
/* check magic text */
- i = 0;
- while (i < DAINTREE_MAGIC_TEXT_SIZE) {
- if (readLine[i] != daintree_magic_text[i]) return 0; /* not daintree format */
- i++;
- }
+ if (memcmp(readLine, daintree_magic_text, DAINTREE_MAGIC_TEXT_SIZE) != 0)
+ return WTAP_OPEN_NOT_MINE; /* not daintree format */
/* read second header line */
if (file_gets(readLine, DAINTREE_MAX_LINE_SIZE, wth->fh)==NULL) {
*err = file_error(wth->fh, err_info);
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
- if (readLine[0] != COMMENT_LINE) return 0; /* daintree files have a two line header */
+ if (readLine[0] != COMMENT_LINE)
+ return WTAP_OPEN_NOT_MINE; /* daintree files have a two line header */
/* set up the pointers to the handlers for this file type */
wth->subtype_read = daintree_sna_read;
@@ -129,7 +126,7 @@ int daintree_sna_open(wtap *wth, int *err, gchar **err_info)
wth->file_tsprec = WTAP_TSPREC_USEC;
wth->snapshot_length = 0; /* not available in header */
- return 1; /* it's a Daintree file */
+ return WTAP_OPEN_MINE; /* it's a Daintree file */
}
/* Read the capture file sequentially