Use "progdlg_t *" rather than "void *" as the handle for a progress
[obnox/wireshark/wip.git] / file.h
diff --git a/file.h b/file.h
index 03dcf5d2d7c50b8be5ca91d0b72c3b500ca4eec0..b91cfbba68f52377cd2924bdb0fa22da4b7fdfa4 100644 (file)
--- a/file.h
+++ b/file.h
@@ -1,7 +1,7 @@
 /* file.h
  * Definitions for file structures and routines
  *
- * $Id: file.h,v 1.37 1999/08/18 04:17:28 guy Exp $
+ * $Id: file.h,v 1.70 2000/07/03 08:35:41 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
 #include <sys/types.h>
 #endif
 
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-
 #ifndef __WTAP_H__
 #include "wiretap/wtap.h"
 #endif
 #include "dfilter.h"
 #endif
 
+#ifndef __COLORS_H__
+#include "gtk/colors.h"                /* XXX */
+#endif
+
+#ifndef __PRINT_H__
+#include "print.h"
+#endif
+
+#include <errno.h>
+
+#ifdef HAVE_LIBZ
+#include "zlib.h"
+#define FILE_T gzFile
+#define file_open gzopen
+#define filed_open gzdopen
+#define file_close gzclose
+#else /* No zLib */
+#define FILE_T FILE *
+#define file_open fopen
+#define filed_open fdopen
+#define file_close fclose
+#endif /* HAVE_LIBZ */
+
 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        *fh;        /* Capture file */
-  gchar       *filename;  /* filename */
-  long         f_len;     /* File length */
-  guint16      cd_t;      /* Capture data type */
-  const gchar *cd_t_desc; /* Description of that data type */
+  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? */
+  gboolean     user_saved;/* If capture file is temporary, has it been saved by user yet? */
+  long         f_len;     /* Length of capture file */
+  guint16      cd_t;      /* File type of capture file */
+  int          lnk_t;     /* Link-layer type with which to save capture */
   guint32      vers;      /* Version.  For tcpdump minor is appended to major */
   guint32      count;     /* Packet count */
-  gfloat       unfiltered_count; /* used for dfilter progress bar */
   guint32      drops;     /* Dropped packets */
   guint32      esec;      /* Elapsed seconds */
   guint32      eusec;     /* Elapsed microseconds */
   guint32      snap;      /* Captured packet length */
+  long         progbar_quantum; /* Number of bytes read per progress bar update */
+  long         progbar_nextstep; /* Next point at which to update progress bar */
   gchar       *iface;     /* Interface */
   gchar       *save_file; /* File that user saved capture to */
   int          save_file_fd; /* File descriptor for saved file */
-  gint         user_saved;/* Was capture file saved by user yet? */
   wtap        *wth;       /* Wiretap session */
   dfilter     *rfcode;    /* Compiled read filter program */ 
   gchar       *dfilter;   /* Display filter string */
+  colfilter   *colors;   /* Colors for colorizing packet window */
   dfilter     *dfcode;    /* Compiled display filter program */ 
 #ifdef HAVE_LIBPCAP
   gchar       *cfilter;   /* Capture filter string */
   bpf_prog     fcode;     /* Compiled capture filter program */
 #endif
-  /* XXX - I'm cheating for now. I'll hardcode 65536 here until I re-arrange
-   * more header files so that ethereal.h is split up into two files, a
-   * generic header and a gtk+-specific header (or the gtk+ definitions are
-   * moved to different header files) --gilbert
-   */
-  /*guint8       pd[MAX_PACKET_SIZE];*/  /* Packet data */
-  guint8       pd[65536];  /* Packet data */
+  gchar       *sfilter;   /* Search filter string */
+  gboolean     sbackward;  /* TRUE if search is backward, FALSE if forward */
+  union wtap_pseudo_header pseudo_header;      /* Packet pseudo_header */
+  guint8       pd[WTAP_MAX_PACKET_SIZE];  /* Packet data */
+  GMemChunk   *plist_chunk; /* Memory chunk for frame_data structures */
   frame_data  *plist;     /* Packet list */
   frame_data  *plist_end; /* Last packet in list */
+  frame_data  *first_displayed; /* First frame displayed */
+  frame_data  *last_displayed;  /* Last frame displayed */
   column_info  cinfo;    /* Column formatting information */
-  int          selected_packet;   /* Index in packet list of currently selected packet, if any */
-  int          selected_row;   /* Row in packet display of currently selected packet, if any */
-  frame_data  *fd;        /* Frame data for currently selected packet */
+  frame_data  *current_frame;  /* Frame data for current frame */
   proto_tree  *protocol_tree; /* Protocol tree for currently selected packet */
   FILE        *print_fh;  /* File we're printing to */
 } capture_file;
 
-int  open_cap_file(char *, capture_file *);
-void close_cap_file(capture_file *, void *, guint);
-int  read_cap_file(capture_file *);
-int  tail_cap_file(char *, 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 *);
+read_status_t read_cap_file(capture_file *, int *);
+int  start_tail_cap_file(char *, gboolean, 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);
 
-int print_packets(capture_file *cf, int to_file, const char *dest);
-void filter_packets(capture_file *);
+int filter_packets(capture_file *cf, gchar *dfilter);
+void colorize_packets(capture_file *);
+int print_packets(capture_file *cf, print_args_t *print_args);
 void change_time_formats(capture_file *);
+gboolean find_packet(capture_file *cf, dfilter *sfcode);
+
+typedef enum {
+  FOUND_FRAME,         /* found the frame */
+  NO_SUCH_FRAME,       /* no frame with that number */
+  FRAME_NOT_DISPLAYED  /* frame with that number isn't displayed */
+} goto_result_t;
+goto_result_t goto_frame(capture_file *cf, guint fnumber);
+
 void select_packet(capture_file *, int);
 void unselect_packet(capture_file *);