aboutsummaryrefslogtreecommitdiffstats
path: root/ringbuffer.c
diff options
context:
space:
mode:
authorMichael Tüxen <tuexen@fh-muenster.de>2012-12-20 14:53:09 +0000
committerMichael Tüxen <tuexen@fh-muenster.de>2012-12-20 14:53:09 +0000
commit7e84abf005afa5952b046d11584d3ff36522c721 (patch)
tree286d014028d629d7a13a35ce19d42169ca2996c0 /ringbuffer.c
parenta1cca8c54ac5fb3d0b9415c0ea86437f80458357 (diff)
Add ws_fclose(), ws_fflush(), and ws_fdopen() to the fileutils.
Retire libpcap_fdopen(), libpcap_dump_flush(), and libpcap_dump_close(). svn path=/trunk/; revision=46636
Diffstat (limited to 'ringbuffer.c')
-rw-r--r--ringbuffer.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/ringbuffer.c b/ringbuffer.c
index 8c4a47bffd..c5a095dfff 100644
--- a/ringbuffer.c
+++ b/ringbuffer.c
@@ -63,7 +63,6 @@
#include <glib.h>
-#include "pcapio.h"
#include "ringbuffer.h"
#include <wsutil/file_util.h>
@@ -226,12 +225,17 @@ const gchar *ringbuf_current_filename(void)
}
/*
- * Calls libpcap_fdopen() for the current ringbuffer file
+ * Calls ws_fdopen() for the current ringbuffer file
*/
FILE *
ringbuf_init_libpcap_fdopen(int *err)
{
- rb_data.pdh = libpcap_fdopen(rb_data.fd, err);
+ rb_data.pdh = ws_fdopen(rb_data.fd, "wb");
+ if (rb_data.pdh == NULL) {
+ if (err != NULL) {
+ *err = errno;
+ }
+ }
return rb_data.pdh;
}
@@ -246,7 +250,10 @@ ringbuf_switch_file(FILE **pdh, gchar **save_file, int *save_file_fd, int *err)
/* close current file */
- if (!libpcap_dump_close(rb_data.pdh, err)) {
+ if (ws_fclose(rb_data.pdh) == EOF) {
+ if (err != NULL) {
+ *err = errno;
+ }
ws_close(rb_data.fd); /* XXX - the above should have closed this already */
rb_data.pdh = NULL; /* it's still closed, we just got an error while closing */
rb_data.fd = -1;
@@ -279,7 +286,7 @@ ringbuf_switch_file(FILE **pdh, gchar **save_file, int *save_file_fd, int *err)
}
/*
- * Calls libpcap_dump_close() for the current ringbuffer file
+ * Calls ws_fclose() for the current ringbuffer file
*/
gboolean
ringbuf_libpcap_dump_close(gchar **save_file, int *err)
@@ -288,11 +295,13 @@ ringbuf_libpcap_dump_close(gchar **save_file, int *err)
/* close current file, if it's open */
if (rb_data.pdh != NULL) {
- if (!libpcap_dump_close(rb_data.pdh, err)) {
+ if (ws_fclose(rb_data.pdh) == EOF) {
+ if (err != NULL) {
+ *err = errno;
+ }
ws_close(rb_data.fd);
ret_val = FALSE;
}
-
rb_data.pdh = NULL;
rb_data.fd = -1;
}
@@ -340,15 +349,13 @@ ringbuf_error_cleanup(void)
/* try to close via wtap */
if (rb_data.pdh != NULL) {
- if (libpcap_dump_close(rb_data.pdh, NULL)) {
+ if (ws_fclose(rb_data.pdh) == 0) {
rb_data.fd = -1;
}
rb_data.pdh = NULL;
}
/* close directly if still open */
- /* XXX - it shouldn't still be open; "libpcap_dump_close()" should leave the
- file closed even if it fails */
if (rb_data.fd != -1) {
ws_close(rb_data.fd);
rb_data.fd = -1;