From 769d58e4946b35976c4da2ab54c56f6430a45d89 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Sat, 2 May 2015 01:40:33 -0500 Subject: further refactoring, working libtls-standalone --- libtls-standalone/include/string.h | 49 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) (limited to 'libtls-standalone/include/string.h') diff --git a/libtls-standalone/include/string.h b/libtls-standalone/include/string.h index c42fcba..05d1ffc 100644 --- a/libtls-standalone/include/string.h +++ b/libtls-standalone/include/string.h @@ -17,12 +17,57 @@ #include #endif -#ifndef HAVE_EXPLICIT_BZERO -void explicit_bzero(void *, size_t); +#ifndef HAVE_STRLCPY +size_t strlcpy(char *dst, const char *src, size_t siz); +#endif + +#ifndef HAVE_STRLCAT +size_t strlcat(char *dst, const char *src, size_t siz); +#endif + +#ifndef HAVE_STRNDUP +char * strndup(const char *str, size_t maxlen); +/* the only user of strnlen is strndup, so only build it if needed */ +#ifndef HAVE_STRNLEN +size_t strnlen(const char *str, size_t maxlen); +#endif #endif #ifndef HAVE_STRSEP char *strsep(char **stringp, const char *delim); #endif +#ifndef HAVE_EXPLICIT_BZERO +void explicit_bzero(void *, size_t); +#endif + +#ifndef HAVE_TIMINGSAFE_BCMP +int timingsafe_bcmp(const void *b1, const void *b2, size_t n); +#endif + +#ifndef HAVE_TIMINGSAFE_MEMCMP +int timingsafe_memcmp(const void *b1, const void *b2, size_t len); +#endif + +#ifndef HAVE_MEMMEM +void * memmem(const void *big, size_t big_len, const void *little, + size_t little_len); +#endif + +#ifdef _WIN32 +#include + +static inline char * +posix_strerror(int errnum) +{ + if (errnum == ECONNREFUSED) { + return "Connection refused"; + } + return strerror(errnum); +} + +#define strerror(errnum) posix_strerror(errnum) + +#endif + #endif -- cgit v1.2.3-55-g6feb