If the user enables gtk3, (silently) disable gtk2 rather than forcing the user
[metze/wireshark/wip.git] / cfile.h
1 /* cfile.h
2  * capture_file definition & GUI-independent manipulation
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24
25 #ifndef __CFILE_H__
26 #define __CFILE_H__
27
28 #include <epan/dfilter/dfilter.h>
29 #include <epan/frame_data.h>
30 #include "frame_data_sequence.h"
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif /* __cplusplus */
35
36 /* Current state of file. */
37 typedef enum {
38   FILE_CLOSED,                  /* No file open */
39   FILE_READ_IN_PROGRESS,        /* Reading a file we've opened */
40   FILE_READ_ABORTED,            /* Read aborted by user */
41   FILE_READ_DONE                /* Read completed */
42 } file_state;
43
44 /* Character set for text search. */
45 typedef enum {
46   SCS_NARROW_AND_WIDE,
47   SCS_NARROW,
48   SCS_WIDE
49   /* add EBCDIC when it's implemented */
50 } search_charset_t;
51
52 typedef enum {
53   SD_FORWARD,
54   SD_BACKWARD
55 } search_direction;
56
57 /*
58  * We store the frame_data structures in a radix tree, with 1024
59  * elements per level.  The leaf nodes are arrays of 1024 frame_data
60  * structures; the nodes above them are arrays of 1024 pointers to
61  * the nodes below them.  The capture_file structure has a pointer
62  * to the root node.
63  *
64  * As frame numbers are 32 bits, and as 1024 is 2^10, that gives us
65  * up to 4 levels of tree.
66  */
67 #define LOG2_NODES_PER_LEVEL    10
68 #define NODES_PER_LEVEL         (1<<LOG2_NODES_PER_LEVEL)
69
70 typedef struct _capture_file {
71   file_state   state;           /* Current state of capture file */
72   gchar       *filename;        /* Name of capture file */
73   gchar       *source;          /* Temp file source, e.g. "Pipe from elsewhere" */
74   gboolean     is_tempfile;     /* Is capture file a temporary file? */
75   gboolean     unsaved_changes; /* Does the capture file have changes that have not been saved? */
76   gint64       f_datalen;       /* Size of capture file data (uncompressed) */
77   guint16      cd_t;            /* File type of capture file */
78   gboolean     iscompressed;    /* TRUE if the file is compressed */
79   int          lnk_t;           /* File link-layer type; could be WTAP_ENCAP_PER_PACKET */
80   GArray      *linktypes;       /* Array of packet link-layer types */
81   guint32      count;           /* Total number of frames */
82   guint64      packet_comment_count; /* Number of comments in frames (could be >1 per frame... */
83   guint32      displayed_count; /* Number of displayed frames */
84   guint32      marked_count;    /* Number of marked frames */
85   guint32      ignored_count;   /* Number of ignored frames */
86   guint32      ref_time_count;  /* Number of time referenced frames */
87   gboolean     drops_known;     /* TRUE if we know how many packets were dropped */
88   guint32      drops;           /* Dropped packets */
89   nstime_t     elapsed_time;    /* Elapsed time */
90   gboolean     has_snap;        /* TRUE if maximum capture packet length is known */
91   int          snap;            /* Maximum captured packet length */
92   wtap        *wth;             /* Wiretap session */
93   dfilter_t   *rfcode;          /* Compiled read filter program */
94   dfilter_t   *dfcode;          /* Compiled display filter program */
95   gchar       *dfilter;         /* Display filter string */
96   gboolean     redissecting;    /* TRUE if currently redissecting (cf_redissect_packets) */
97   /* search */
98   gchar       *sfilter;         /* Filter, hex value, or string being searched */
99   gboolean     hex;             /* TRUE if "Hex value" search was last selected */
100   gboolean     string;          /* TRUE if "String" search was last selected */
101   gboolean     summary_data;    /* TRUE if "String" search in "Packet list" (Info column) was last selected */
102   gboolean     decode_data;     /* TRUE if "String" search in "Packet details" was last selected */
103   gboolean     packet_data;     /* TRUE if "String" search in "Packet data" was last selected */
104   guint32      search_pos;      /* Byte position of last byte found in a hex search */
105   gboolean     case_type;       /* TRUE if case-insensitive text search */
106   search_charset_t scs_type;    /* Character set for text search */
107   search_direction dir;         /* Direction in which to do searches */
108   gboolean     search_in_progress; /* TRUE if user just clicked OK in the Find dialog or hit <control>N/B */
109   /* packet data */
110   struct wtap_pkthdr phdr;                /* Packet header */
111   Buffer       buf;             /* Packet data */
112   /* frames */
113   frame_data_sequence *frames;  /* Sequence of frames, if we're keeping that information */
114   guint32      first_displayed; /* Frame number of first frame displayed */
115   guint32      last_displayed;  /* Frame number of last frame displayed */
116   column_info  cinfo;           /* Column formatting information */
117   gboolean     columns_changed; /**< Have the columns been changed in the prefs? */
118   frame_data  *current_frame;   /* Frame data for current frame */
119   gint         current_row;     /* Row number for current frame */
120   epan_dissect_t *edt;          /* Protocol dissection for currently selected packet */
121   field_info  *finfo_selected;  /* Field info for currently selected field */
122 #ifdef WANT_PACKET_EDITOR
123   GTree       *edited_frames;   /* BST with modified frames */
124 #endif
125   gpointer     window;          /* Top-level window associated with file */
126 } capture_file;
127
128 extern void cap_file_init(capture_file *cf);
129
130 #ifdef __cplusplus
131 }
132 #endif /* __cplusplus */
133
134 #endif /* cfile.h */