aboutsummaryrefslogtreecommitdiffstats
path: root/file.h
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2000-06-27 07:13:42 +0000
committerGuy Harris <guy@alum.mit.edu>2000-06-27 07:13:42 +0000
commit7843ac6d0e5f52db0eaa47d594b1976bec2334a4 (patch)
treed2e7cd26316c0a79a8fc65a12749ecdea4de2cc8 /file.h
parent5af6a8d416ac56e03d281b44d125195ab9653d30 (diff)
Add routines to Wiretap to allow a client of Wiretap to get:
a pointer to the "wtap_pkthdr" structure for an open capture file; a pointer to the "wtap_pseudo_header" union for an open capture file; a pointer to the packet buffer for an open capture file; so that a program using "wtap_read()" in a loop can get at those items. Keep, in a "capture_file" structure, an indicator of whether: no file is open; a file is open, and being read; a file is open, and is being read, but the user tried to quit out of reading the file (e.g., by doing "File/Quit"); a file is open, and has been completely read. Abort if we try to close a capture that's being read if the user hasn't tried to quit out of the read. Have "File/Quit" check if a file is being read; if so, just set the state indicator to "user tried to quit out of it", so that the code reading the file can do what's appropriate to clean up, rather than closing the file out from under that code and causing crashes. Have "read_cap_file()" read the capture file with a loop using "wtap_read()", rather than by using "wtap_loop()"; have it check after reading each packet whether the user tried to abort the read and, if so, close the capture and return an indication that the read was aborted by the user. Otherwise, return an indication of whether the read completely succeeded or failed in the middle (and, if it failed, return the error code through a pointer). Have "continue_tail_cap_file()" read the capture file with a loop using "wtap_read()", rather than by using "wtap_loop()"; have it check after reading each packet whether the user tried to abort the read and, if so, quit the loop, and after the loop finishes (even if it read no packets), return an indication that the read was aborted by the user if that happened. Otherwise, return an indication of whether the read completely succeeded or failed in the middle (and, if it failed, return the error code through a pointer). Have "finish_tail_cap_file()" read the capture file with a loop using "wtap_read()", rather than by using "wtap_loop()"; have it check after reading each packet whether the user tried to abort the read and, if so, quit the loop, and after the loop finishes (even if it read no packets), close the capture and return an indication that the read was aborted by the user if that happened. Otherwise, return an indication of whether the read completely succeeded or failed in the middle (and, if it failed, return the error code through a pointer). Have their callers check whether the read was aborted or not and, if it was, bail out in the appropriate fashion (exit if it's reading a file specified by "-r" on the command line; exit the main loop if it's reading a file specified with File->Open; kill the capture child if it's "continue_tail_cap_file()"; exit the main loop if it's "finish_tail_cap_file()". svn path=/trunk/; revision=2095
Diffstat (limited to 'file.h')
-rw-r--r--file.h25
1 files changed, 21 insertions, 4 deletions
diff --git a/file.h b/file.h
index 3788d28605..db477fb323 100644
--- a/file.h
+++ b/file.h
@@ -1,7 +1,7 @@
/* file.h
* Definitions for file structures and routines
*
- * $Id: file.h,v 1.68 2000/05/19 23:06:07 gram Exp $
+ * $Id: file.h,v 1.69 2000/06/27 07:13:14 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -69,7 +69,16 @@
typedef struct bpf_program bpf_prog;
+/* Current state of file. */
+typedef enum {
+ FILE_CLOSED, /* No file open */
+ FILE_READ_IN_PROGRESS, /* Reading a file we've opened */
+ FILE_READ_ABORTED, /* Read aborted by user */
+ FILE_READ_DONE /* Read completed */
+} file_state;
+
typedef struct _capture_file {
+ file_state state; /* Current state of capture file */
int filed; /* File descriptor of capture file */
gchar *filename; /* Name of capture file */
gboolean is_tempfile; /* Is capture file a temporary file? */
@@ -113,12 +122,20 @@ typedef struct _capture_file {
FILE *print_fh; /* File we're printing to */
} capture_file;
+/* Return values from "read_cap_file()", "continue_tail_cap_file()",
+ and "finish_tail_cap_file()". */
+typedef enum {
+ READ_SUCCESS, /* read succeeded */
+ READ_ERROR, /* read got an error */
+ READ_ABORTED /* read aborted by user */
+} read_status_t;
+
int open_cap_file(char *, gboolean, capture_file *);
void close_cap_file(capture_file *, void *);
-int read_cap_file(capture_file *);
+read_status_t read_cap_file(capture_file *, int *);
int start_tail_cap_file(char *, gboolean, capture_file *);
-int continue_tail_cap_file(capture_file *, int);
-int finish_tail_cap_file(capture_file *);
+read_status_t continue_tail_cap_file(capture_file *, int, int *);
+read_status_t finish_tail_cap_file(capture_file *, int *);
/* size_t read_frame_header(capture_file *); */
int save_cap_file(char *, capture_file *, gboolean, guint);