123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- #ifndef portability_h
- #define portability_h
- #include "pcap/funcattrs.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- #ifndef HAVE_STRLCPY
-
- #if defined(_MSC_VER) || defined(__MINGW32__)
-
- #define strlcpy(x, y, z) \
- strncpy_s((x), (z), (y), _TRUNCATE)
- #else
- #define strlcpy(x, y, z) \
- (strncpy((x), (y), (z)), \
- ((z) <= 0 ? 0 : ((x)[(z) - 1] = '\0')), \
- (void) strlen((y)))
- #endif
- #endif
- #ifndef HAVE_STRLCAT
-
- #if defined(_MSC_VER) || defined(__MINGW32__)
-
- #define strlcat(x, y, z) \
- strncat_s((x), (z), (y), _TRUNCATE)
- #else
-
- #define strlcat(x, y, z) \
- strncat((x), (y), (z) - strlen((x)) - 1)
- #endif
- #endif
- #ifdef _MSC_VER
-
- #ifndef strdup
- #define strdup _strdup
- #endif
- #endif
- #ifdef HAVE_SNPRINTF
- #define pcap_snprintf snprintf
- #else
- extern int pcap_snprintf(char *, size_t, PCAP_FORMAT_STRING(const char *), ...)
- PCAP_PRINTFLIKE(3, 4);
- #endif
- #ifdef HAVE_VSNPRINTF
- #define pcap_vsnprintf vsnprintf
- #else
- extern int pcap_vsnprintf(char *, size_t, const char *, va_list ap);
- #endif
- #ifdef HAVE_STRTOK_R
- #define pcap_strtok_r strtok_r
- #else
- #ifdef _WIN32
-
- #define pcap_strtok_r strtok_s
- #else
-
- #define NEED_STRTOK_R
- extern char *pcap_strtok_r(char *, const char *, char **);
- #endif
- #endif
- #ifdef _WIN32
- #if !defined(__cplusplus)
- #define inline __inline
- #endif
- #endif
- #ifdef __cplusplus
- }
- #endif
- #endif
|