use DISSECTOR_ASSERT instead of g_assert
[obnox/wireshark/wip.git] / ringbuffer.c
index 082844946161eb180ae91c01659336aed347522e..1a89e6d4bb66891bc57389b01dc5cd5b29de9196 100644 (file)
@@ -1,7 +1,7 @@
 /* ringbuffer.c
  * Routines for packet capture windows
  *
- * $Id: ringbuffer.c,v 1.10 2004/06/02 18:49:40 guy Exp $
+ * $Id$
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -97,13 +97,17 @@ typedef struct _ringbuf_data {
   int           filetype;
   int           linktype;
   int           snaplen;
-  guint16       number;
+
   int           fd;                 /* Current ringbuffer file descriptor */
   wtap_dumper  *pdh;  
 } ringbuf_data;
 
 static ringbuf_data rb_data;
 
+
+/*
+ * create the next filename and open a new binary file with that name 
+ */
 static int ringbuf_open_file(rb_file *rfile, int *err)
 {
   char    filenum[5+1];
@@ -123,9 +127,7 @@ static int ringbuf_open_file(rb_file *rfile, int *err)
 #endif
   current_time = time(NULL);
 
-  rb_data.number++;
-
-  snprintf(filenum, sizeof(filenum), "%05d", rb_data.number);
+  snprintf(filenum, sizeof(filenum), "%05d", rb_data.curr_file_num + 1 /*.number*/);
   strftime(timestr, sizeof(timestr), "%Y%m%d%H%M%S", localtime(&current_time));
   rfile->name = g_strconcat(rb_data.fprefix, "_", filenum, "_", timestr,
                            rb_data.fsuffix, NULL);
@@ -161,7 +163,6 @@ ringbuf_init(const char *capfile_name, guint num_files)
   rb_data.unlimited = FALSE;
   rb_data.fd = -1;
   rb_data.pdh = NULL;
-  rb_data.number = 0;
 
   /* just to be sure ... */
   if (num_files <= RINGBUFFER_MAX_NUM_FILES) {
@@ -251,7 +252,7 @@ ringbuf_init_wtap_dump_fdopen(int filetype, int linktype, int snaplen, int *err)
  * Switches to the next ringbuffer file
  */
 gboolean
-ringbuf_switch_file(capture_file *cf, wtap_dumper **pdh, int *err)
+ringbuf_switch_file(wtap_dumper **pdh, gchar **save_file, int *save_file_fd, int *err)
 {
   int     next_file_num;
   rb_file *next_rfile = NULL;
@@ -284,8 +285,8 @@ ringbuf_switch_file(capture_file *cf, wtap_dumper **pdh, int *err)
 
   /* switch to the new file */
   rb_data.curr_file_num = next_file_num;
-  cf->save_file = next_rfile->name;
-  cf->save_file_fd = rb_data.fd;
+  *save_file = next_rfile->name;
+  *save_file_fd = rb_data.fd;
   (*pdh) = rb_data.pdh;
 
   return TRUE;
@@ -295,7 +296,7 @@ ringbuf_switch_file(capture_file *cf, wtap_dumper **pdh, int *err)
  * Calls wtap_dump_close() for the current ringbuffer file
  */
 gboolean
-ringbuf_wtap_dump_close(capture_file *cf, int *err)
+ringbuf_wtap_dump_close(gchar **save_file, int *err)
 {
   gboolean  ret_val = TRUE;
 
@@ -311,7 +312,7 @@ ringbuf_wtap_dump_close(capture_file *cf, int *err)
   }
 
   /* set the save file name to the current file */
-  cf->save_file = rb_data.files[rb_data.curr_file_num].name;
+  *save_file = rb_data.files[rb_data.curr_file_num].name;
   return ret_val;
 }