]> The Tcpdump Group git mirrors - libpcap/commitdiff
Make "pcap_dump_flush()" return a success-vs-failure indication;
authorguy <guy>
Sun, 22 Dec 2002 23:05:52 +0000 (23:05 +0000)
committerguy <guy>
Sun, 22 Dec 2002 23:05:52 +0000 (23:05 +0000)
unfortunately, we can't fix "pcap_dump()" and "pcap_dump_close()" to do
that, as any application that tests the return value would fail to work
correctly if linked at runtime with an older libpcap, but we should
perhaps introduce "pcap_dump_ex()" and "pcap_dump_close_ex()" routines
that do return a success-vs-vailure indication.

pcap.3
pcap.h
savefile.c

diff --git a/pcap.3 b/pcap.3
index 6cac2395d197ead2b2250e6560a5eb36191bc2b6..7236c63757a5832e9836198ff903c154e8e25db4 100644 (file)
--- a/pcap.3
+++ b/pcap.3
@@ -1,4 +1,4 @@
-.\" @(#) $Header: /tcpdump/master/libpcap/Attic/pcap.3,v 1.43 2002-12-22 02:36:51 guy Exp $
+.\" @(#) $Header: /tcpdump/master/libpcap/Attic/pcap.3,v 1.44 2002-12-22 23:05:52 guy Exp $
 .\"
 .\" Copyright (c) 1994, 1996, 1997
 .\"    The Regents of the University of California.  All rights reserved.
@@ -100,7 +100,7 @@ char *pcap_strerror(int error)
 .LP
 .ft B
 void pcap_close(pcap_t *p)
-void pcap_dump_flush(pcap_dumper_t *p)
+int pcap_dump_flush(pcap_dumper_t *p)
 void pcap_dump_close(pcap_dumper_t *p)
 .ft
 .fi
@@ -883,6 +883,8 @@ flushes the output buffer to the ``savefile,'' so that any packets
 written with
 .B pcap_dump()
 but not yet written to the ``savefile'' will be written.
+.B \-1
+is returned on error, 0 on success.
 .PP
 .B pcap_dump_close()
 closes the ``savefile.''
diff --git a/pcap.h b/pcap.h
index b8e7df9719cd874359734e0bd19ab66417edff51..7d4e0ad1f179b2fc2f04b453a1b3381c8eed887e 100644 (file)
--- a/pcap.h
+++ b/pcap.h
@@ -31,7 +31,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * @(#) $Header: /tcpdump/master/libpcap/pcap.h,v 1.40 2002-12-22 02:36:51 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/libpcap/pcap.h,v 1.41 2002-12-22 23:05:53 guy Exp $ (LBL)
  */
 
 #ifndef lib_pcap_h
@@ -202,7 +202,7 @@ FILE        *pcap_file(pcap_t *);
 int    pcap_fileno(pcap_t *);
 
 pcap_dumper_t *pcap_dump_open(pcap_t *, const char *);
-void   pcap_dump_flush(pcap_dumper_t *);
+int    pcap_dump_flush(pcap_dumper_t *);
 void   pcap_dump_close(pcap_dumper_t *);
 void   pcap_dump(u_char *, const struct pcap_pkthdr *, const u_char *);
 
index 61a17ee8313c98983ea3c47e52774ba48ffe57b8..7e8fdf7a0f3afeb1dfe4791b05a1a6998fa40a2e 100644 (file)
@@ -30,7 +30,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.71 2002-12-21 23:38:52 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.72 2002-12-22 23:05:53 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -691,11 +691,14 @@ pcap_dump_open(pcap_t *p, const char *fname)
        return ((pcap_dumper_t *)f);
 }
 
-void
+int
 pcap_dump_flush(pcap_dumper_t *p)
 {
 
-       (void)fflush((FILE *)p);
+       if (fflush((FILE *)p) == EOF)
+               return (-1);
+       else
+               return (0);
 }
 
 void