TCAP: fix indent and add modelines (use 2 spaces)
[metze/wireshark/wip.git] / reordercap.c
index 9939f26987e7269d83d801e6e56aeaaf15b768c7..b96b214b1a87e377e6eff5f87002de06de91b5c4 100644 (file)
@@ -36,7 +36,7 @@
 #include <zlib.h>      /* to get the libz version number */
 #endif
 
-#include "wtap.h"
+#include <wiretap/wtap.h>
 
 #ifndef HAVE_GETOPT_LONG
 #include "wsutil/wsgetopt.h"
@@ -195,16 +195,14 @@ main(int argc, char *argv[])
     FrameRecord_t *prevFrame = NULL;
 
     int opt;
-DIAG_OFF(cast-qual)
     static const struct option long_options[] = {
-        {(char *)"help", no_argument, NULL, 'h'},
-        {(char *)"version", no_argument, NULL, 'v'},
+        {"help", no_argument, NULL, 'h'},
+        {"version", no_argument, NULL, 'v'},
         {0, 0, 0, 0 }
     };
-DIAG_ON(cast-qual)
     int file_count;
     char *infile;
-    char *outfile;
+    const char *outfile;
 
     /* Get the compile-time version information string */
     comp_info_str = get_compiled_version_info(NULL, get_reordercap_compiled_info);
@@ -229,7 +227,7 @@ DIAG_ON(cast-qual)
             case 'h':
                 printf("Reordercap (Wireshark) %s\n"
                        "Reorder timestamps of input file frames into output file.\n"
-                       "See http://www.wireshark.org for more information.\n",
+                       "See https://www.wireshark.org for more information.\n",
                        get_ws_vcs_version_info());
                 print_usage(stdout);
                 exit(0);
@@ -268,15 +266,21 @@ DIAG_ON(cast-qual)
         }
         exit(1);
     }
-    DEBUG_PRINT("file_type_subtype is %u\n", wtap_file_type_subtype(wth));
+    DEBUG_PRINT("file_type_subtype is %d\n", wtap_file_type_subtype(wth));
 
     shb_hdr = wtap_file_get_shb_for_new_file(wth);
     idb_inf = wtap_file_get_idb_info(wth);
     nrb_hdr = wtap_file_get_nrb_for_new_file(wth);
 
     /* Open outfile (same filetype/encap as input file) */
-    pdh = wtap_dump_open_ng(outfile, wtap_file_type_subtype(wth), wtap_file_encap(wth),
-                            65535, FALSE, shb_hdr, idb_inf, nrb_hdr, &err);
+    if (strcmp(outfile, "-") == 0) {
+      pdh = wtap_dump_open_stdout_ng(wtap_file_type_subtype(wth), wtap_file_encap(wth),
+                                     65535, FALSE, shb_hdr, idb_inf, nrb_hdr, &err);
+      outfile = "standard output";
+    } else {
+      pdh = wtap_dump_open_ng(outfile, wtap_file_type_subtype(wth), wtap_file_encap(wth),
+                              65535, FALSE, shb_hdr, idb_inf, nrb_hdr, &err);
+    }
     g_free(idb_inf);
     idb_inf = NULL;