2 * Definitions for routines for merging files.
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
8 * Copyright 1998 Gerald Combs
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.
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.
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.
30 #endif /* __cplusplus */
33 * Structures to manage our input files.
35 typedef struct merge_in_file_s {
45 * Structures to manage our output file.
47 typedef struct merge_out_file_s {
53 /** Verbosity levels. */
60 /** Current verbosity level, default is VERBOSE_NONE. */
61 extern int merge_verbose;
63 /** Open a number of input files to merge.
65 * @param in_file_count number of entries in in_file_names and in_files
66 * @param in_file_names filenames of the input files
67 * @param in_files input file array to be filled (>= sizeof(merge_in_file_t) * in_file_count)
68 * @param err wiretap error, if failed and VERBOSE_NONE
69 * @param err_info wiretap error string, if failed and VERBOSE_NONE
70 * @param err_fileno file on which open failed, if VERBOSE_NONE
71 * @return number of opened input files
74 merge_open_in_files(int in_file_count, char *const *in_file_names,
75 merge_in_file_t **in_files, int *err, gchar **err_info,
78 /** Close the input files again.
80 * @param in_file_count number of entries in in_files
81 * @param in_files input file array to be closed
84 merge_close_in_files(int in_file_count, merge_in_file_t in_files[]);
86 /** Open the output file.
88 * @param out_file the output file array, which we fill in
89 * @param fd the file descriptor to use for the output file
90 * @param file_type the file type to write
91 * @param frame_type the frame type to write
92 * @param snapshot_len the snapshot length of the output file
93 * @param err wiretap error, if failed
94 * @return TRUE, if the output file could be opened
97 merge_open_outfile(merge_out_file_t *out_file, int fd, int file_type,
98 int frame_type, int snapshot_len, int *err);
100 /** Close the output file again.
102 * @param out_file the output file array
103 * @param err wiretap error, if failed
104 * @return TRUE if the close succeeded, FALSE otherwise
107 merge_close_outfile(merge_out_file_t *out_file, int *err);
109 /** Try to get the frame type from the input files.
111 * @param in_file_count number of entries in in_files
112 * @param in_files input file array
113 * @return the frame type
116 merge_select_frame_type(int in_file_count, merge_in_file_t in_files[]);
118 /** Try to get the snapshot length from the input files.
120 * @param in_file_count number of entries in in_files
121 * @param in_files input file array
122 * @return the snapshot length
125 merge_max_snapshot_length(int in_file_count, merge_in_file_t in_files[]);
127 /** Merge the packets from the input files into the output file sorted chronologically.
129 * @param in_file_count number of entries in in_files
130 * @param in_files input file array
131 * @param out_file the output file array
132 * @param err wiretap error, if failed
133 * @return TRUE on success or read failure, FALSE on write failure
136 merge_files(int in_file_count, merge_in_file_t in_files[], merge_out_file_t *out_file, int *err);
138 /** Append the packets from the input files into the output file.
140 * @param in_file_count number of entries in in_files
141 * @param in_files input file array
142 * @param out_file the output file array
143 * @param err wiretap error, if failed
144 * @return TRUE on success or read failure, FALSE on write failure
147 merge_append_files(int in_file_count, merge_in_file_t in_files[], merge_out_file_t *out_file, int *err);
149 /** Return status from merge_n_files */
152 MERGE_OPEN_INPUT_FAILED,
153 MERGE_OPEN_OUTPUT_FAILED,
158 * Convenience function: merge any number of input files into one.
160 * @param out_filename the output filename
161 * @param in_file_count number of input files
162 * @param in_filenames array of input filenames
163 * @param do_append TRUE to append, FALSE to merge chronologically
164 * @param err wiretap error, if failed and VERBOSE_NONE
165 * @param err_info wiretap error string, if failed and VERBOSE_NONE
166 * @param err_fileno file on which open failed, if VERBOSE_NONE
167 * @return merge_status_e
169 extern merge_status_e
170 merge_n_files(int out_fd, int in_file_count, char *const *in_filenames,
171 int filetype, gboolean do_append, int *err, gchar **err_info,
177 #endif /* __cplusplus */
179 #endif /* __MERGE_H__ */