Move the print modules into epan.
[metze/wireshark/wip.git] / merge.h
1 /* merge.h
2  * Definitions for routines for merging files.
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 __MERGE_H__
26 #define __MERGE_H__
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif /* __cplusplus */
31
32 typedef enum {
33   PACKET_PRESENT,
34   PACKET_NOT_PRESENT,
35   AT_EOF,
36   GOT_ERROR
37 } in_file_state_e;
38
39 /**
40  * Structures to manage our input files.
41  */
42 typedef struct merge_in_file_s {
43   const char     *filename;
44   wtap           *wth;
45   gint64          data_offset;
46   in_file_state_e state;
47   guint32         packet_num;     /* current packet number */
48   gint64          size;               /* file size */
49   guint32         interface_id;   /* identifier of the interface. 
50                                                                    * Used for fake interfaces when writing WTAP_ENCAP_PER_PACKET */
51 } merge_in_file_t;
52
53 /** Open a number of input files to merge.
54  * 
55  * @param in_file_count number of entries in in_file_names and in_files
56  * @param in_file_names filenames of the input files
57  * @param in_files input file array to be filled (>= sizeof(merge_in_file_t) * in_file_count)
58  * @param err wiretap error, if failed
59  * @param err_info wiretap error string, if failed
60  * @param err_fileno file on which open failed, if failed
61  * @return TRUE if all files could be opened, FALSE otherwise
62  */
63 extern gboolean
64 merge_open_in_files(int in_file_count, char *const *in_file_names,
65                     merge_in_file_t **in_files, int *err, gchar **err_info,
66                     int *err_fileno);
67
68 /** Close the input files again.
69  * 
70  * @param in_file_count number of entries in in_files
71  * @param in_files input file array to be closed
72  */
73 extern void
74 merge_close_in_files(int in_file_count, merge_in_file_t in_files[]);
75
76 /** Try to get the frame type from the input files.
77  * 
78  * @param in_file_count number of entries in in_files
79  * @param in_files input file array
80  * @return the frame type
81  */
82 extern int
83 merge_select_frame_type(int in_file_count, merge_in_file_t in_files[]);
84
85 /** Try to get the snapshot length from the input files.
86  * 
87  * @param in_file_count number of entries in in_files
88  * @param in_files input file array
89  * @return the snapshot length
90  */
91 extern int
92 merge_max_snapshot_length(int in_file_count, merge_in_file_t in_files[]);
93
94 /** Read the next packet, in chronological order, from the set of files to
95  * be merged.
96  * 
97  * @param in_file_count number of entries in in_files
98  * @param in_files input file array
99  * @param err wiretap error, if failed
100  * @param err_info wiretap error string, if failed
101  * @return pointer to merge_in_file_t for file from which that packet
102  * came, or NULL on error or EOF
103  */
104 extern merge_in_file_t *
105 merge_read_packet(int in_file_count, merge_in_file_t in_files[], int *err,
106                   gchar **err_info);
107
108
109 /** Read the next packet, in file sequence order, from the set of files
110  * to be merged.
111  * 
112  * @param in_file_count number of entries in in_files
113  * @param in_files input file array
114  * @param err wiretap error, if failed
115  * @param err_info wiretap error string, if failed
116  * @return pointer to merge_in_file_t for file from which that packet
117  * came, or NULL on error or EOF
118  */
119 extern merge_in_file_t *
120 merge_append_read_packet(int in_file_count, merge_in_file_t in_files[],
121                          int *err, gchar **err_info);
122
123 #ifdef __cplusplus
124 }
125 #endif /* __cplusplus */
126
127 #endif /* __MERGE_H__ */
128