diff --git a/compat.h b/compat.h index 59e378e..3573e3b 100644 --- a/compat.h +++ b/compat.h @@ -15,3 +15,11 @@ void *reallocarray(void *, size_t, size_t); #ifndef HAVE_TIMINGSAFE_MEMCMP int timingsafe_memcmp(const void *, const void *, size_t); #endif + +#ifndef HAVE_STRSEP +char *strsep(char **sp, char *sep); +#endif + +#ifndef HAVE_STPCPY +char* stpcpy(char *dst, const char *src); +#endif diff --git a/compat/freezero.c b/compat/freezero.c index 31face3..e94975f 100644 --- a/compat/freezero.c +++ b/compat/freezero.c @@ -19,6 +19,7 @@ #include #include +#include "compat.h" void freezero(void *ptr, size_t sz) diff --git a/compat/stpcpy.c b/compat/stpcpy.c new file mode 100644 index 0000000..0608694 --- /dev/null +++ b/compat/stpcpy.c @@ -0,0 +1,8 @@ +#ifndef HAVE_STPCPY +#include +char* stpcpy(char *dst, const char *src) +{ + const size_t len = strlen(src); + return (char*)memcpy(dst, src, len + 1) + len; +} +#endif diff --git a/compat/strsep.c b/compat/strsep.c new file mode 100644 index 0000000..5a6b980 --- /dev/null +++ b/compat/strsep.c @@ -0,0 +1,35 @@ +#ifndef HAVE_STRSEP +#include +char *strsep(char **s, const char *delim) +{ + char *begin, *end; + begin = *s; + if (!begin) { + return 0; + } + if (delim[0] == '\0' || delim[1] == '\0') { + char ch = delim[0]; + if (ch == '\0') { + end = 0; + } else { + if (*begin == ch) { + end = begin; + } else if (*begin == '\0') { + end = 0; + } else { + end = strchr(begin + 1, ch); + } + } + } else { + end = strpbrk(begin, delim); + } + if (end) { + *end++ = '\0'; + *s = end; + } + else { + *s = 0; + } + return begin; +} +#endif diff --git a/tls.c b/tls.c index 1d1a8f3..8ea97ff 100644 --- a/tls.c +++ b/tls.c @@ -15,7 +15,11 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include +#ifdef WIN32 +# include +#else +# include +#endif #include #include diff --git a/tls_client.c b/tls_client.c index 27500fb..908c3d3 100644 --- a/tls_client.c +++ b/tls_client.c @@ -16,16 +16,20 @@ */ #include -#include +#ifdef WIN32 +# include +# include +#else +# include +# include +# include +# include +#endif #include -#include -#include - #include #include #include -#include #include #include diff --git a/tls_conninfo.c b/tls_conninfo.c index e0ce051..6994c9b 100644 --- a/tls_conninfo.c +++ b/tls_conninfo.c @@ -22,6 +22,10 @@ #include #include "tls_internal.h" +#ifdef WIN32 +# include +#endif + int ASN1_time_tm_clamp_notafter(struct tm *tm); int diff --git a/tls_internal.h b/tls_internal.h index b2a6a25..777a715 100644 --- a/tls_internal.h +++ b/tls_internal.h @@ -21,8 +21,13 @@ #include -#include -#include +#ifdef WIN32 +# include +# include +#else +# include +# include +#endif #include diff --git a/tls_server.c b/tls_server.c index 71c0483..f00e5d9 100644 --- a/tls_server.c +++ b/tls_server.c @@ -15,9 +15,13 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include - -#include +#ifdef WIN32 +# include +# include +#else +# include +# include +#endif #include #include