summaryrefslogtreecommitdiff
path: root/missing
Commit message (Collapse)AuthorAgeFilesLines
* Fixup a comment in missing/asprintf.c. [skip ci]Denis Ovsienko2023-02-191-1/+1
|
* Fix some typosFrancois-Xavier Le Bail2022-08-011-1/+1
| | | | [skip ci]
* Cleaning spacesFrancois-Xavier Le Bail2019-11-081-1/+1
| | | | [skip ci]
* Remove some workarounds for old compilers.Guy Harris2019-08-093-676/+2
| | | | | | | | | | | | | 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.
* Use asprintf(), and provide a version for systems that lack it.Guy Harris2019-02-094-1/+169
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* Provide out own strlcpy() and strlcat() routines if necessary.Guy Harris2018-10-162-0/+117
| | | | | | | | | | | | | | 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.
* Clean up the code a bit.Guy Harris2018-09-141-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.)
* Fixing va_start/va_end usagennposter2018-08-091-2/+4
| | | | | | | 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.
* Squelch warning about optreset not being declared.Gisle Vanem2018-05-021-1/+1
|
* Don't use old-style function definitions.Guy Harris2018-03-201-4/+1
|
* Always include <config.h> rather than "config.h".Guy Harris2017-08-181-1/+1
| | | | | | | | 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.
* Add a wrapper for strtok_r().Guy Harris2016-08-111-0/+87
| | | | | | | | | | | | | | | | 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).
* Fix MSVC compile warnings on the WinPcap specific code.Yang Luo2016-07-291-1/+1
|
* Oops, forgot to add the file with the Windows _snprintf() wrappers.Guy Harris2015-11-031-0/+31
|
* Use pcap_snprintf() instead of snprintf().Guy Harris2015-11-032-10/+12
| | | | | | | | | | | 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.
* Extract progname from argv[0].Guy Harris2015-11-011-5/+8
| | | | | | | 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.
* Add a "getopt.h" header and include it instead of <unistd.h> on Windows.Guy Harris2015-11-011-0/+7
| | | | | | | | | | | | | 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.
* Move getopt.c to the missing directory.Guy Harris2015-09-231-0/+121
| | | | | | 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.
* remove libpcap's own CVS keywordsDenis Ovsienko2014-01-031-7/+0
| | | | | | 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.
* Move "snprintf.c" to the "missing" directory, as that's whereguy2004-04-051-0/+632
"Makefile.in" expects it to be (tcpdump puts "snprintf.c" and the like into a "missing" subdirectory).