Remove use of APPEND_BOOLEAN_FLAG in favor of proto_tree_add_bitmask_with_flags.
[metze/wireshark/wip.git] / reordercap.c
index 53e7f45c203d3fa5817aa2800ae8f098bc04d1b2..61c3d9c0c0461e77a2d2f9d895ce1abcaf978e5f 100644 (file)
 #include <string.h>
 #include <glib.h>
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 #ifdef HAVE_GETOPT_H
 #include <getopt.h>
 #endif
@@ -68,7 +64,7 @@ typedef struct FrameRecord_t {
     gint64       offset;
     guint        num;
 
-    nstime_t     time;
+    nstime_t     frame_time;
 } FrameRecord_t;
 
 
@@ -115,7 +111,7 @@ frame_write(FrameRecord_t *frame, wtap *wth, wtap_dumper *pdh,
     /* Copy, and set length and timestamp from item. */
     /* TODO: remove when wtap_seek_read() fills in phdr,
        including time stamps, for all file types  */
-    phdr->ts = frame->time;
+    phdr->ts = frame->frame_time;
 
     /* Dump frame to outfile */
     if (!wtap_dump(pdh, phdr, ws_buffer_start_ptr(buf), &err, &err_info)) {
@@ -140,8 +136,8 @@ frames_compare(gconstpointer a, gconstpointer b)
     const FrameRecord_t *frame1 = *(const FrameRecord_t *const *) a;
     const FrameRecord_t *frame2 = *(const FrameRecord_t *const *) b;
 
-    const nstime_t *time1 = &frame1->time;
-    const nstime_t *time2 = &frame2->time;
+    const nstime_t *time1 = &frame1->frame_time;
+    const nstime_t *time2 = &frame2->frame_time;
 
     return nstime_cmp(time1, time2);
 }
@@ -208,7 +204,7 @@ DIAG_OFF(cast-qual)
 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);
@@ -233,7 +229,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);
@@ -272,15 +268,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;
 
@@ -305,9 +307,9 @@ DIAG_ON(cast-qual)
         newFrameRecord->num = frames->len + 1;
         newFrameRecord->offset = data_offset;
         if (phdr->presence_flags & WTAP_HAS_TS) {
-            newFrameRecord->time = phdr->ts;
+            newFrameRecord->frame_time = phdr->ts;
         } else {
-            nstime_set_unset(&newFrameRecord->time);
+            nstime_set_unset(&newFrameRecord->frame_time);
         }
 
         if (prevFrame && frames_compare(&newFrameRecord, &prevFrame) < 0) {