aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt1
-rw-r--r--Makefile.in3
-rw-r--r--fopen.c38
-rw-r--r--fopen.h27
-rw-r--r--nametoaddr.c5
-rw-r--r--savefile.c16
-rw-r--r--sf-pcap.c28
7 files changed, 29 insertions, 89 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 863b2d78..797ba586 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -765,7 +765,6 @@ set(PROJECT_SOURCE_LIST_C
bpf_image.c
etherent.c
fmtutils.c
- fopen.c
gencode.c
nametoaddr.c
optimize.c
diff --git a/Makefile.in b/Makefile.in
index 79840e22..a49e29a6 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -91,7 +91,7 @@ FSRC = @V_FINDALLDEVS@
SSRC = @SSRC@
CSRC = pcap.c gencode.c optimize.c nametoaddr.c etherent.c \
fmtutils.c \
- savefile.c sf-pcap.c sf-pcapng.c fopen.c pcap-common.c \
+ savefile.c sf-pcap.c sf-pcapng.c pcap-common.c \
bpf_image.c bpf_dump.c
GENSRC = scanner.c grammar.c bpf_filter.c
LIBOBJS = @LIBOBJS@
@@ -126,7 +126,6 @@ HDR = $(PUBHDR) \
ethertype.h \
extract.h \
fmtutils.h \
- fopen.h \
ftmacros.h \
gencode.h \
ieee80211.h \
diff --git a/fopen.c b/fopen.c
deleted file mode 100644
index 884a9e51..00000000
--- a/fopen.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 1993, 1994, 1995, 1996, 1997
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University nor the names of its contributors may be used to endorse
- * or promote products derived from this software without specific prior
- * written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef _MSC_VER
-
-#include <stdio.h>
-#include <errno.h>
-
-#include "fopen.h"
-
-int
-pcap_fopen(FILE **fpp, const char *filename, const char* mode)
-{
- *fpp = fopen(filename, mode);
- if (*fpp == NULL)
- return (errno);
- else
- return (0);
-}
-#endif
diff --git a/fopen.h b/fopen.h
deleted file mode 100644
index 8af377e8..00000000
--- a/fopen.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 1993, 1994, 1995, 1996, 1997
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University nor the names of its contributors may be used to endorse
- * or promote products derived from this software without specific prior
- * written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifdef _MSC_VER
-#define pcap_fopen fopen_s
-#else
-extern int pcap_fopen(FILE **fpp, const char *filename, const char* mode);
-#endif
-
diff --git a/nametoaddr.c b/nametoaddr.c
index eea629a9..c69c36dd 100644
--- a/nametoaddr.c
+++ b/nametoaddr.c
@@ -133,8 +133,6 @@
#include <string.h>
#include <stdio.h>
-#include "fopen.h"
-
#include "pcap-int.h"
#include "gencode.h"
@@ -717,8 +715,9 @@ pcap_ether_hostton(const char *name)
static int init = 0;
if (!init) {
+ fp = fopen(PCAP_ETHERS_FILE, "r");
++init;
- if (pcap_fopen(&fp, PCAP_ETHERS_FILE, "r") != 0)
+ if (fp == NULL)
return (NULL);
} else if (fp == NULL)
return (NULL);
diff --git a/savefile.c b/savefile.c
index 40ab5ecd..57375224 100644
--- a/savefile.c
+++ b/savefile.c
@@ -44,8 +44,6 @@
#include <stdlib.h>
#include <string.h>
-#include "fopen.h"
-
#include "pcap-int.h"
#ifdef HAVE_OS_PROTO_H
@@ -271,12 +269,16 @@ pcap_open_offline_with_tstamp_precision(const char *fname, u_int precision,
#endif
}
else {
- int err;
-
- err = pcap_fopen(&fp, fname, "rb");
- if (err != 0) {
+ /*
+ * "b" is supported as of C90, so *all* UN*Xes should
+ * support it, even though it does nothing. It's
+ * required on Windows, as the file is a binary file
+ * and must be read in binary mode.
+ */
+ fp = fopen(fname, "rb");
+ if (fp == NULL) {
pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE,
- err, "%s", fname);
+ errno, "%s", fname);
return (NULL);
}
}
diff --git a/sf-pcap.c b/sf-pcap.c
index fa6ad7c6..acc256a5 100644
--- a/sf-pcap.c
+++ b/sf-pcap.c
@@ -44,8 +44,6 @@
#include <stdlib.h>
#include <string.h>
-#include "fopen.h"
-
#include "pcap-int.h"
#include "pcap-common.h"
@@ -795,12 +793,16 @@ pcap_dump_open(pcap_t *p, const char *fname)
f = stdout;
fname = "standard output";
} else {
- int err;
-
- err = pcap_fopen(&f, fname, "wb");
- if (err != 0) {
+ /*
+ * "b" is supported as of C90, so *all* UN*Xes should
+ * support it, even though it does nothing. It's
+ * required on Windows, as the file is a binary file
+ * and must be written in binary mode.
+ */
+ f = fopen(fname, "wb");
+ if (f == NULL) {
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
- err, "%s", fname);
+ errno, "%s", fname);
return (NULL);
}
}
@@ -830,7 +832,6 @@ pcap_dump_fopen(pcap_t *p, FILE *f)
pcap_dumper_t *
pcap_dump_open_append(pcap_t *p, const char *fname)
{
- int err;
FILE *f;
int linktype;
size_t amt_read;
@@ -852,10 +853,15 @@ pcap_dump_open_append(pcap_t *p, const char *fname)
if (fname[0] == '-' && fname[1] == '\0')
return (pcap_setup_dump(p, linktype, stdout, "standard output"));
- err = pcap_fopen(&f, fname, "rb+");
- if (err != 0) {
+ /*
+ * "b" is supported as of C90, so *all* UN*Xes should support it,
+ * even though it does nothing. It's required on Windows, as the
+ * file is a binary file and must be read in binary mode.
+ */
+ f = fopen(fname, "rb+");
+ if (f == NULL) {
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
- err, "%s", fname);
+ errno, "%s", fname);
return (NULL);
}