forked from osmocom/wireshark
Whitespace cleanup, sort options, add modelines.
svn path=/trunk/; revision=51804
This commit is contained in:
parent
faad753c65
commit
51b613e485
73
mergecap.c
73
mergecap.c
|
@ -1,4 +1,4 @@
|
|||
/* Combine two dump files, either by appending or by merging by timestamp
|
||||
/* Combine dump files, either by appending or by merging by timestamp
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
|
@ -75,8 +75,7 @@ get_natural_int(const char *string, const char *name)
|
|||
exit(1);
|
||||
}
|
||||
if (number < 0) {
|
||||
fprintf(stderr, "mergecap: The specified %s is a negative number\n",
|
||||
name);
|
||||
fprintf(stderr, "mergecap: The specified %s is a negative number\n", name);
|
||||
exit(1);
|
||||
}
|
||||
if (number > INT_MAX) {
|
||||
|
@ -95,8 +94,7 @@ get_positive_int(const char *string, const char *name)
|
|||
number = get_natural_int(string, name);
|
||||
|
||||
if (number == 0) {
|
||||
fprintf(stderr, "mergecap: The specified %s is zero\n",
|
||||
name);
|
||||
fprintf(stderr, "mergecap: The specified %s is zero\n", name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -109,7 +107,6 @@ get_positive_int(const char *string, const char *name)
|
|||
static void
|
||||
usage(void)
|
||||
{
|
||||
|
||||
fprintf(stderr, "Mergecap %s"
|
||||
#ifdef SVNVERSION
|
||||
" (" SVNVERSION " from " SVNPATH ")"
|
||||
|
@ -158,8 +155,7 @@ string_nat_compare(gconstpointer a, gconstpointer b)
|
|||
static void
|
||||
string_elem_print(gpointer data, gpointer not_used _U_)
|
||||
{
|
||||
fprintf(stderr, " %s - %s\n",
|
||||
((struct string_elem *)data)->sstr,
|
||||
fprintf(stderr, " %s - %s\n", ((struct string_elem *)data)->sstr,
|
||||
((struct string_elem *)data)->lstr);
|
||||
}
|
||||
|
||||
|
@ -208,7 +204,6 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
int opt;
|
||||
|
||||
gboolean do_append = FALSE;
|
||||
gboolean verbose = FALSE;
|
||||
int in_file_count = 0;
|
||||
|
@ -224,7 +219,7 @@ main(int argc, char *argv[])
|
|||
int i;
|
||||
struct wtap_pkthdr *phdr, snap_phdr;
|
||||
wtap_dumper *pdh;
|
||||
int open_err, read_err=0, write_err, close_err;
|
||||
int open_err, read_err = 0, write_err, close_err;
|
||||
gchar *err_info;
|
||||
int err_fileno;
|
||||
char *out_filename = NULL;
|
||||
|
@ -237,27 +232,13 @@ main(int argc, char *argv[])
|
|||
#endif /* _WIN32 */
|
||||
|
||||
/* Process the options first */
|
||||
while ((opt = getopt(argc, argv, "hvas:T:F:w:")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "aF:hs:T:vw:")) != -1) {
|
||||
|
||||
switch (opt) {
|
||||
case 'w':
|
||||
out_filename = optarg;
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
do_append = !do_append;
|
||||
break;
|
||||
|
||||
case 'T':
|
||||
frame_type = wtap_short_string_to_encap(optarg);
|
||||
if (frame_type < 0) {
|
||||
fprintf(stderr, "mergecap: \"%s\" isn't a valid encapsulation type\n",
|
||||
optarg);
|
||||
list_encap_types();
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'F':
|
||||
file_type = wtap_short_string_to_file_type(optarg);
|
||||
if (file_type < 0) {
|
||||
|
@ -268,17 +249,31 @@ main(int argc, char *argv[])
|
|||
}
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
verbose = TRUE;
|
||||
case 'h':
|
||||
usage();
|
||||
exit(0);
|
||||
break;
|
||||
|
||||
case 's':
|
||||
snaplen = get_positive_int(optarg, "snapshot length");
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
usage();
|
||||
exit(0);
|
||||
case 'T':
|
||||
frame_type = wtap_short_string_to_encap(optarg);
|
||||
if (frame_type < 0) {
|
||||
fprintf(stderr, "mergecap: \"%s\" isn't a valid encapsulation type\n",
|
||||
optarg);
|
||||
list_encap_types();
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
verbose = TRUE;
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
out_filename = optarg;
|
||||
break;
|
||||
|
||||
case '?': /* Bad options if GNU getopt */
|
||||
|
@ -294,9 +289,7 @@ main(int argc, char *argv[])
|
|||
}
|
||||
exit(1);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* check for proper args; at a minimum, must have an output
|
||||
|
@ -416,7 +409,7 @@ main(int argc, char *argv[])
|
|||
pdh = wtap_dump_fdopen_ng(out_fd, file_type, frame_type, snaplen,
|
||||
FALSE /* compressed */, shb_hdr, NULL /* wtapng_iface_descriptions_t *idb_inf */, &open_err);
|
||||
g_string_free(comment_gstr, TRUE);
|
||||
}else{
|
||||
} else {
|
||||
pdh = wtap_dump_fdopen(out_fd, file_type, frame_type, snaplen, FALSE /* compressed */, &open_err);
|
||||
}
|
||||
if (pdh == NULL) {
|
||||
|
@ -516,3 +509,17 @@ main(int argc, char *argv[])
|
|||
|
||||
return (!got_read_error && !got_write_error) ? 0 : 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 2
|
||||
* tab-width: 2
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=2 tabstop=2 expandtab:
|
||||
* :indentSize=2:tabSize=2:noTabs=true:
|
||||
*/
|
||||
|
||||
|
|
Loading…
Reference in New Issue