The Styleguide section has been moved to the Wireshark Developer's Guide.
[obnox/wireshark/wip.git] / mergecap.c
index 5b0aa952355b4c9f13b36404b194ad36a7f585f9..05bb517666d8090f66ad0d802e1e2bae64c13562 100644 (file)
 #include <string.h>
 #include "wtap.h"
 
-#ifdef NEED_GETOPT_H
-#include "getopt.h"
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#else
+#include "wsutil/wsgetopt.h"
 #endif
 
 #include "svnversion.h"
 static int
 get_natural_int(const char *string, const char *name)
 {
-  long number;
+  int number;
   char *p;
 
-  number = strtol(string, &p, 10);
+  number = (int) strtol(string, &p, 10);
   if (p == string || *p != '\0') {
     fprintf(stderr, "mergecap: The specified %s \"%s\" isn't a decimal number\n",
            name, string);
@@ -67,7 +69,7 @@ get_natural_int(const char *string, const char *name)
 static int
 get_positive_int(const char *string, const char *name)
 {
-  long number;
+  int number;
 
   number = get_natural_int(string, name);
 
@@ -89,28 +91,28 @@ usage(void)
 
   fprintf(stderr, "Mergecap %s"
 #ifdef SVNVERSION
-         " (" SVNVERSION ")"
+         " (" SVNVERSION " from " SVNPATH ")"
 #endif
          "\n", VERSION);
   fprintf(stderr, "Merge two or more capture files into one.\n");
   fprintf(stderr, "See http://www.wireshark.org for more information.\n");
   fprintf(stderr, "\n");
-  fprintf(stderr, "Usage: mergecap [options] -w <outfile|-> <infile> ...\n");
+  fprintf(stderr, "Usage: mergecap [options] -w <outfile>|- <infile> ...\n");
   fprintf(stderr, "\n");
   fprintf(stderr, "Output:\n");
-  fprintf(stderr, "  -a                files should be concatenated, not merged\n");
-  fprintf(stderr, "                    Default merges based on frame timestamps\n");
-  fprintf(stderr, "  -s <snaplen>      truncate packets to <snaplen> bytes of data\n");
-  fprintf(stderr, "  -w <outfile|->    set the output filename to <outfile> or '-' for stdout\n");
-  fprintf(stderr, "  -F <capture type> set the output file type, default is libpcap\n");
-  fprintf(stderr, "                    an empty \"-F\" option will list the file types\n");
-  fprintf(stderr, "  -T <encap type>   set the output file encapsulation type,\n");
-  fprintf(stderr, "                    default is the same as the first input file\n");
-  fprintf(stderr, "                    an empty \"-T\" option will list the encapsulation types\n");
+  fprintf(stderr, "  -a                concatenate rather than merge files.\n");
+  fprintf(stderr, "                    default is to merge based on frame timestamps.\n");
+  fprintf(stderr, "  -s <snaplen>      truncate packets to <snaplen> bytes of data.\n");
+  fprintf(stderr, "  -w <outfile>|-    set the output filename to <outfile> or '-' for stdout.\n");
+  fprintf(stderr, "  -F <capture type> set the output file type; default is libpcap.\n");
+  fprintf(stderr, "                    an empty \"-F\" option will list the file types.\n");
+  fprintf(stderr, "  -T <encap type>   set the output file encapsulation type;\n");
+  fprintf(stderr, "                    default is the same as the first input file.\n");
+  fprintf(stderr, "                    an empty \"-T\" option will list the encapsulation types.\n");
   fprintf(stderr, "\n");
   fprintf(stderr, "Miscellaneous:\n");
-  fprintf(stderr, "  -h                display this help and exit\n");
-  fprintf(stderr, "  -v                verbose output\n");
+  fprintf(stderr, "  -h                display this help and exit.\n");
+  fprintf(stderr, "  -v                verbose output.\n");
 }
 
 static void list_capture_types(void) {
@@ -140,8 +142,6 @@ static void list_encap_types(void) {
 int
 main(int argc, char *argv[])
 {
-  extern char *optarg;
-  extern int   optind;
   int          opt;
   gboolean     do_append     = FALSE;
   gboolean     verbose       = FALSE;