summaryrefslogtreecommitdiff
path: root/wiretap/libpcap.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2010-06-06 19:14:32 +0000
committerGuy Harris <guy@alum.mit.edu>2010-06-06 19:14:32 +0000
commit1bf478fdef0992236d338ee0158fbcdd2e69007a (patch)
treee1bf983e5ebcfb0d88953f49acec3bf24b219d35 /wiretap/libpcap.c
parent1b3be7a75487d5f5b3e6cbb120cf84edb4405065 (diff)
downloadwireshark-1bf478fdef0992236d338ee0158fbcdd2e69007a.tar.gz
Rename wtap_dump_file_write_all() to wtap_dump_file_write(), and have
everybody use it; the places using the old wtap_dump_file_write() were using it in the same way the old wtap_dump_file_write_all() did. That also lets us get rid of wtap_dump_file_ferror(). Also, have the new wtap_dump_file_write() check for errors from gzwrite() and fwrite() differently - the former returns 0 on error, the latter can return a short write on error. svn path=/trunk/; revision=33113
Diffstat (limited to 'wiretap/libpcap.c')
-rw-r--r--wiretap/libpcap.c34
1 files changed, 4 insertions, 30 deletions
diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c
index 117409c25a..484a79d5e7 100644
--- a/wiretap/libpcap.c
+++ b/wiretap/libpcap.c
@@ -911,7 +911,6 @@ gboolean libpcap_dump_open(wtap_dumper *wdh, gboolean cant_seek _U_, int *err)
{
guint32 magic;
struct pcap_hdr file_hdr;
- size_t nwritten;
/* This is a libpcap file */
wdh->subtype_write = libpcap_dump;
@@ -945,14 +944,8 @@ gboolean libpcap_dump_open(wtap_dumper *wdh, gboolean cant_seek _U_, int *err)
return FALSE;
}
- nwritten = wtap_dump_file_write(wdh, &magic, sizeof magic);
- if (nwritten != sizeof magic) {
- if (nwritten == 0 && wtap_dump_file_ferror(wdh))
- *err = wtap_dump_file_ferror(wdh);
- else
- *err = WTAP_ERR_SHORT_WRITE;
+ if (!wtap_dump_file_write(wdh, &magic, sizeof magic, err))
return FALSE;
- }
wdh->bytes_dumped += sizeof magic;
/* current "libpcap" format is 2.4 */
@@ -974,14 +967,8 @@ gboolean libpcap_dump_open(wtap_dumper *wdh, gboolean cant_seek _U_, int *err)
file_hdr.snaplen = (wdh->snaplen != 0) ? wdh->snaplen :
WTAP_MAX_PACKET_SIZE;
file_hdr.network = wtap_wtap_encap_to_pcap_encap(wdh->encap);
- nwritten = wtap_dump_file_write(wdh, &file_hdr, sizeof file_hdr);
- if (nwritten != sizeof file_hdr) {
- if (nwritten == 0 && wtap_dump_file_ferror(wdh))
- *err = wtap_dump_file_ferror(wdh);
- else
- *err = WTAP_ERR_SHORT_WRITE;
+ if (!wtap_dump_file_write(wdh, &file_hdr, sizeof file_hdr, err))
return FALSE;
- }
wdh->bytes_dumped += sizeof file_hdr;
return TRUE;
@@ -996,7 +983,6 @@ static gboolean libpcap_dump(wtap_dumper *wdh,
{
struct pcaprec_ss990915_hdr rec_hdr;
size_t hdr_size;
- size_t nwritten;
int phdrsize;
phdrsize = pcap_get_phdr_size(wdh->encap, pseudo_header);
@@ -1069,27 +1055,15 @@ static gboolean libpcap_dump(wtap_dumper *wdh,
return FALSE;
}
- nwritten = wtap_dump_file_write(wdh, &rec_hdr, hdr_size);
- if (nwritten != hdr_size) {
- if (nwritten == 0 && wtap_dump_file_ferror(wdh))
- *err = wtap_dump_file_ferror(wdh);
- else
- *err = WTAP_ERR_SHORT_WRITE;
+ if (!wtap_dump_file_write(wdh, &rec_hdr, hdr_size, err))
return FALSE;
- }
wdh->bytes_dumped += hdr_size;
if (!pcap_write_phdr(wdh, wdh->encap, pseudo_header, err))
return FALSE;
- nwritten = wtap_dump_file_write(wdh, pd, phdr->caplen);
- if (nwritten != phdr->caplen) {
- if (nwritten == 0 && wtap_dump_file_ferror(wdh))
- *err = wtap_dump_file_ferror(wdh);
- else
- *err = WTAP_ERR_SHORT_WRITE;
+ if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err))
return FALSE;
- }
wdh->bytes_dumped += phdr->caplen;
return TRUE;
}