prevent ringbuffer from having to know about capture_file type at all (decoupling...
authorulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 3 Feb 2005 21:58:33 +0000 (21:58 +0000)
committerulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 3 Feb 2005 21:58:33 +0000 (21:58 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@13266 f5534014-38df-0310-8fa8-9805f1628bb7

capture_loop.c
ringbuffer.c
ringbuffer.h
tethereal.c

index fdad9599b48167387fc208458598ac2e9066456a..76a968526601707c0ddbe8bc35fb655546b3df93 100644 (file)
@@ -840,7 +840,7 @@ static int capture_loop_open_wiretap_output(capture_options *capture_opts, loop_
 
 static gboolean capture_loop_close_output(capture_options *capture_opts, loop_data *ld, int *err_close) {
   if (capture_opts->multi_files_on) {
 
 static gboolean capture_loop_close_output(capture_options *capture_opts, loop_data *ld, int *err_close) {
   if (capture_opts->multi_files_on) {
-    return ringbuf_wtap_dump_close(&cfile, err_close);
+    return ringbuf_wtap_dump_close(&cfile.save_file, err_close);
   } else {
     return wtap_dump_close(ld->wtap_pdh, err_close);
   }
   } else {
     return wtap_dump_close(ld->wtap_pdh, err_close);
   }
@@ -1106,7 +1106,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
           }
 
           /* Switch to the next ringbuffer file */
           }
 
           /* Switch to the next ringbuffer file */
-          if (ringbuf_switch_file(&cfile, &ld.wtap_pdh, &ld.err)) {
+          if (ringbuf_switch_file(&ld.wtap_pdh, &cfile.save_file, &cfile.save_file_fd, &ld.err)) {
             /* File switch succeeded: reset the conditions */
             cnd_reset(cnd_autostop_size);
             if (cnd_file_duration) {
             /* File switch succeeded: reset the conditions */
             cnd_reset(cnd_autostop_size);
             if (cnd_file_duration) {
@@ -1175,7 +1175,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
           }
 
           /* Switch to the next ringbuffer file */
           }
 
           /* Switch to the next ringbuffer file */
-          if (ringbuf_switch_file(&cfile, &ld.wtap_pdh, &ld.err)) {
+          if (ringbuf_switch_file(&ld.wtap_pdh, &cfile.save_file, &cfile.save_file_fd, &ld.err)) {
             /* file switch succeeded: reset the conditions */
             cnd_reset(cnd_file_duration);
             if(cnd_autostop_size)
             /* file switch succeeded: reset the conditions */
             cnd_reset(cnd_file_duration);
             if(cnd_autostop_size)
index cc633eab3c1cdb12fc7216611d174ce874e71812..1a89e6d4bb66891bc57389b01dc5cd5b29de9196 100644 (file)
@@ -252,7 +252,7 @@ ringbuf_init_wtap_dump_fdopen(int filetype, int linktype, int snaplen, int *err)
  * Switches to the next ringbuffer file
  */
 gboolean
  * 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;
 {
   int     next_file_num;
   rb_file *next_rfile = NULL;
@@ -285,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;
 
   /* 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;
   (*pdh) = rb_data.pdh;
 
   return TRUE;
@@ -296,7 +296,7 @@ ringbuf_switch_file(capture_file *cf, wtap_dumper **pdh, int *err)
  * Calls wtap_dump_close() for the current ringbuffer file
  */
 gboolean
  * 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;
 
 {
   gboolean  ret_val = TRUE;
 
@@ -312,7 +312,7 @@ ringbuf_wtap_dump_close(capture_file *cf, int *err)
   }
 
   /* set the save file name to the current file */
   }
 
   /* 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;
 }
 
   return ret_val;
 }
 
index f3acec11e0aeb870f6666c41c0d6f0e3113e0217..b5904053e320ec532dba3ab59f49cffd35fa7c68 100644 (file)
@@ -40,8 +40,8 @@
 int ringbuf_init(const char *capture_name, guint num_files);
 wtap_dumper* ringbuf_init_wtap_dump_fdopen(int filetype, int linktype,
   int snaplen, int *err);
 int ringbuf_init(const char *capture_name, guint num_files);
 wtap_dumper* ringbuf_init_wtap_dump_fdopen(int filetype, int linktype,
   int snaplen, int *err);
-gboolean ringbuf_switch_file(capture_file *cf, wtap_dumper **pdh, int *err);
-gboolean ringbuf_wtap_dump_close(capture_file *cf, int *err);
+gboolean ringbuf_switch_file(wtap_dumper **pdh, gchar **save_file, int *save_file_fd, int *err);
+gboolean ringbuf_wtap_dump_close(gchar **save_file, int *err);
 void ringbuf_free(void);
 void ringbuf_error_cleanup(void);
 
 void ringbuf_free(void);
 void ringbuf_error_cleanup(void);
 
index c015bcdd49f8423abf8f3510032f72cf5e273eac..367ec2c73ccc6cef41589811bc43ebc0cb1fe945 100644 (file)
@@ -2034,7 +2034,7 @@ capture(int out_file_type)
            its maximum size. */
         if (capture_opts.ringbuffer_on) {
           /* Switch to the next ringbuffer file */
            its maximum size. */
         if (capture_opts.ringbuffer_on) {
           /* Switch to the next ringbuffer file */
-          if (ringbuf_switch_file(&cfile, &ld.pdh, &loop_err)) {
+          if (ringbuf_switch_file(&ld.pdh, &cfile.save_file, &cfile.save_file_fd, &loop_err)) {
             /* File switch succeeded: reset the condition */
             cnd_reset(cnd_stop_capturesize);
            if (cnd_ring_timeout) {
             /* File switch succeeded: reset the condition */
             cnd_reset(cnd_stop_capturesize);
            if (cnd_ring_timeout) {
@@ -2103,7 +2103,7 @@ capture(int out_file_type)
   if (cfile.save_file != NULL) {
     /* We're saving to a file or files; close all files. */
     if (capture_opts.ringbuffer_on) {
   if (cfile.save_file != NULL) {
     /* We're saving to a file or files; close all files. */
     if (capture_opts.ringbuffer_on) {
-      dump_ok = ringbuf_wtap_dump_close(&cfile, &err);
+      dump_ok = ringbuf_wtap_dump_close(&cfile.save_file, &err);
     } else {
       dump_ok = wtap_dump_close(ld.pdh, &err);
     }
     } else {
       dump_ok = wtap_dump_close(ld.pdh, &err);
     }
@@ -2193,7 +2193,7 @@ capture_pcap_cb(guchar *user, const struct pcap_pkthdr *phdr,
    */
   if (cnd_ring_timeout != NULL && cnd_eval(cnd_ring_timeout)) {
     /* time elapsed for this ring file, switch to the next */
    */
   if (cnd_ring_timeout != NULL && cnd_eval(cnd_ring_timeout)) {
     /* time elapsed for this ring file, switch to the next */
-    if (ringbuf_switch_file(&cfile, &ldat->pdh, &loop_err)) {
+    if (ringbuf_switch_file(&ldat->pdh, &cfile.save_file, &cfile.save_file_fd, &loop_err)) {
       /* File switch succeeded: reset the condition */
       cnd_reset(cnd_ring_timeout);
     } else {
       /* File switch succeeded: reset the condition */
       cnd_reset(cnd_ring_timeout);
     } else {