| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
| |
[skip ci]
|
|
|
|
| |
[skip ci]
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Require Visual Studio 2015 or later; fail if we don't have it, and
remove checks for older versions.
That means we have C99-compliant snprintf() and vsnprintf(); require
them when configuring for UN*X, and then use them directly, rather than
having wrappers for systems lacking them.
If we're using MSVC, skip the tests for options to request C99
compatibility - either we have VS 2015, which is sufficient, or we
don't, in which case we fail.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This lets us get rid of places where we calculate the length that a
formatted string will require, attempt to allocate a buffer for the
string, and then format the string into that buffer; this way, we don't
have to hope we got the calculation correct, we rely on the same code
that formats strings to do the calculation.
Provide versions of asprintf() for:
1) Windows and the MSVC runtime, where we use _vscprintf() to determine
the length;
2) systems that have (what is presumed to be) an snprintf() that, when
handed a too-short buffer, returns the number of characters that would
have been written had the buffer been long enough (as C99 specifies),
where we format to a one-character buffer to determine the length;
3) systems that don't have snprintf(), where we use the asprintf()
provided by the missing/snprintf.c file that also provides snprintf().
While we're at it, include "portability.h" in missing/win_snprintf.c, to
get declaration/definition checking done.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We now depend on the *full* semantics of those routines, including the
return value being usable for truncation checks.
If we're building for a UN*X that has them, define pcap_strl{cpy,cat} to
be strl{cpy,cat}.
If we're building for Windows using MSVC, define pcap_strl{cpy,cat}, not
strl{cpy,cat}.
Otherwise, build our won versions of pcap_strl{cpy,cat} from BSD-derived
source code.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This eliminates a warning from MSVC, and makes the flow a little
clearer.
(Yes, it duplicates some code, but compilers have been pretty good at
merging common code sequences, so it might just turn it into the
equivalent of
if (optopt == (int)':')
goto label2;
oli = strchr(ostr, optopt);
if (!oli) {
/*
* if the user didn't specify '-' as an option,
* assume it means -1.
*/
if (optopt == (int)'-')
return (-1);
label2:
if (!*place)
++optind;
if (opterr && *ostr != ':')
(void)fprintf(stderr,
"%s: illegal option -- %c\n", __progname, optopt);
return (BADCH);
}
although it does mean that the same C code exists in two places.)
|
|
|
|
|
|
|
| |
Per ISO/IEC 9899:201x and POSIX:
As the functions vfprintf, vfscanf, vprintf, vscanf, vsnprintf, vsprintf, and vsscanf invoke the va_arg macro, the value of [args] after the return is indeterminate.
What needs to be done instead is to wrap each invocation of pcap*snprintf with its own pair of va_start and va_end.
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
This can prevent bizarre failures if, for example, you've done a
configuration in the top-level source directory, leaving behind one
config.h file, and then do an out-of-tree build in another directory,
with different configuration options. This way, we always pick up the
same config.h, in the build directory.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Have a pcap_strtok_r(), which behaves like the standard UNIX strtok_r().
If we have strtok_r(), pcap_strtok_r is just #defined to be strtok_r.
If we're building with MSVC, pcap_strtok_r is just #defined to be
strtok_s.
Otherwise, we build our own, taken from FreeBSD.
Use it in sockutils.c, to avoid warnings and to make sure it's
thread-safe (the Single UNIX Specification does not guarantee that
strtok() is thread-safe - it could, but it isn't required to, use
thread-local storage for the state).
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
On UN*Xes with snprintf(), we just #define pcap_snprintf to snprintf.
On UN*Xes without snprintf(), we provide our own, but call it
pcap_snprintf().
On Windows, we have a routine that wraps _snprintf(), with C99 semantics
(ensuring null termination if the string won't fit), called
pcap_snprintf(), and use that.
|
|
|
|
|
|
|
| |
On UN*X, __progname is a BSD-specific variable, so don't rely on it
being defined by the system.
On Windows, don't hardwire "windump" as the program name.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We include <unistd.h> for getopt(), but, on Windows, we supply our own
getopt() (as it's a UN*X API), so supply our own header and include that
instead.
While we're at it, mark the copyright strings as unused (to squelch
compiler warnings), and don't include the headers for select() or poll()
in capturetest.c, as we don't use those APIs there (that's what
selpolltest(), which is UN*X-only, is for). <unistd.h> or "getopt.h"
should declare the getopt() external variables, so don't declare them
ourselves.
|
|
|
|
|
|
| |
It's currently not used on any UN*X, so it doesn't need to be there, but
this puts all the "source for replacement functions" stuff in the
missing directory.
|
|
|
|
|
|
| |
This change removes CVS keywords that express that the file belongs to
libpcap repository. All such keywords represented the revision and
timestamp by the end of 2008 or even older.
|
|
"Makefile.in" expects it to be (tcpdump puts "snprintf.c" and the like
into a "missing" subdirectory).
|