Initial OBD-II PIDs dissector.
[metze/wireshark/wip.git] / ringbuffer.c
index 4873c34c4824054fdb096e545592822f013c4e18..be8aff86e10fe7cb88b9cac3e7ac18144a2b94e2 100644 (file)
 
 #ifdef HAVE_LIBPCAP
 
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 #include <stdio.h>
 #include <string.h>
 #include <time.h>
 #include <errno.h>
 
-#include <pcap.h>
+#include <wsutil/wspcap.h>
 
 #include <glib.h>
 
@@ -95,6 +87,7 @@ static int ringbuf_open_file(rb_file *rfile, int *err)
   char    filenum[5+1];
   char    timestr[14+1];
   time_t  current_time;
+  struct tm *tm;
 
   if (rfile->name != NULL) {
     if (rb_data.unlimited == FALSE) {
@@ -110,7 +103,11 @@ static int ringbuf_open_file(rb_file *rfile, int *err)
   current_time = time(NULL);
 
   g_snprintf(filenum, sizeof(filenum), "%05u", (rb_data.curr_file_num + 1) % RINGBUFFER_MAX_NUM_FILES);
-  strftime(timestr, sizeof(timestr), "%Y%m%d%H%M%S", localtime(&current_time));
+  tm = localtime(&current_time);
+  if (tm != NULL)
+    strftime(timestr, sizeof(timestr), "%Y%m%d%H%M%S", tm);
+  else
+    g_strlcpy(timestr, "196912312359", sizeof(timestr)); /* second before the Epoch */
   rfile->name = g_strconcat(rb_data.fprefix, "_", filenum, "_", timestr,
                             rb_data.fsuffix, NULL);