Remove all the verbose-mode code from merge.c, and put most of it in
[obnox/wireshark/wip.git] / merge.h
1 /* merge.h
2  * Definitions for routines for merging files.
3  *
4  * $Id$
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@ethereal.com>
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  */
24
25 #ifndef __MERGE_H__
26 #define __MERGE_H__
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif /* __cplusplus */
31
32 /**
33  * Structures to manage our input files.
34  */
35 typedef struct merge_in_file_s {
36   const char *filename;
37   wtap       *wth;
38   int         err;
39   gchar      *err_info;
40   long        data_offset;
41   gboolean    ok;
42 } merge_in_file_t;
43
44 /**
45  * Structures to manage our output file.
46  */
47 typedef struct merge_out_file_s {
48   wtap_dumper *pdh;
49   unsigned int snaplen;
50   int          count;
51 } merge_out_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 /** Open the output file.
77  * 
78  * @param out_file the output file array, which we fill in
79  * @param fd the file descriptor to use for the output file
80  * @param file_type the file type to write
81  * @param frame_type the frame type to write
82  * @param snapshot_len the snapshot length of the output file
83  * @param err wiretap error, if failed
84  * @return TRUE, if the output file could be opened, and FALSE otherwise
85  */
86 extern gboolean
87 merge_open_outfile(merge_out_file_t *out_file, int fd, int file_type,
88                    int frame_type, int snapshot_len, int *err);
89
90 /** Close the output file again.
91  * 
92  * @param out_file the output file array
93  * @param err wiretap error, if failed
94  * @return TRUE if the close succeeded, FALSE otherwise
95  */
96 extern gboolean
97 merge_close_outfile(merge_out_file_t *out_file, int *err);
98
99 /** Try to get the frame type from the input files.
100  * 
101  * @param in_file_count number of entries in in_files
102  * @param in_files input file array
103  * @return the frame type
104  */
105 extern int
106 merge_select_frame_type(int in_file_count, merge_in_file_t in_files[]);
107
108 /** Try to get the snapshot length from the input files.
109  * 
110  * @param in_file_count number of entries in in_files
111  * @param in_files input file array
112  * @return the snapshot length
113  */
114 extern int
115 merge_max_snapshot_length(int in_file_count, merge_in_file_t in_files[]);
116
117 /** Merge the packets from the input files into the output file sorted chronologically.
118  * 
119  * @param in_file_count number of entries in in_files
120  * @param in_files input file array
121  * @param out_file the output file array
122  * @param err wiretap error, if failed
123  * @return TRUE on success or read failure, FALSE on write failure
124  */
125 extern gboolean
126 merge_files(int in_file_count, merge_in_file_t in_files[], merge_out_file_t *out_file, int *err);
127
128 /** Append the packets from the input files into the output file.
129  * 
130  * @param in_file_count number of entries in in_files
131  * @param in_files input file array
132  * @param out_file the output file array
133  * @param err wiretap error, if failed
134  * @return TRUE on success or read failure, FALSE on write failure
135  */
136 extern gboolean
137 merge_append_files(int in_file_count, merge_in_file_t in_files[],
138                    merge_out_file_t *out_file, int *err);
139
140 #ifdef __cplusplus
141 }
142 #endif /* __cplusplus */
143
144 #endif /* __MERGE_H__ */
145