From 891f884c641ed70b28cd66ca8ebe14c4cddfbc83 Mon Sep 17 00:00:00 2001 From: Cosmin Apreutesei Date: Wed, 9 Dec 2020 02:07:02 +0200 Subject: [PATCH 1/3] mingw64: add missing libc functions --- compat.h | 10 +++++++++- compat/freezero.c | 1 + compat/stpcpy.c | 8 ++++++++ compat/strsep.c | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 compat/stpcpy.c create mode 100644 compat/strsep.c diff --git a/compat.h b/compat.h index 59e378e..2944f24 100644 --- a/compat.h +++ b/compat.h @@ -1,7 +1,7 @@ #include #ifndef HAVE_EXPLICIT_BZERO -void explicit_bzero(void *, size_t); +void explicit_bzero(void *s, size_t len); #endif #ifndef HAVE_FREEZERO @@ -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 From 8ae90f1c3a7220238e501c137330627d8e159393 Mon Sep 17 00:00:00 2001 From: Cosmin Apreutesei Date: Wed, 9 Dec 2020 02:12:38 +0200 Subject: [PATCH 2/3] mingw64: windows includes --- tls.c | 6 +++++- tls_client.c | 14 +++++++++----- tls_conninfo.c | 4 ++++ tls_internal.h | 9 +++++++-- tls_server.c | 10 +++++++--- 5 files changed, 32 insertions(+), 11 deletions(-) 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 From 7615d14b82df68aba15d278ec3bc9e6b5f581d12 Mon Sep 17 00:00:00 2001 From: Cosmin Apreutesei Date: Wed, 9 Dec 2020 04:21:40 +0200 Subject: [PATCH 3/3] unimportant --- compat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat.h b/compat.h index 2944f24..3573e3b 100644 --- a/compat.h +++ b/compat.h @@ -1,7 +1,7 @@ #include #ifndef HAVE_EXPLICIT_BZERO -void explicit_bzero(void *s, size_t len); +void explicit_bzero(void *, size_t); #endif #ifndef HAVE_FREEZERO