Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it work with mingw64 #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions compat/freezero.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <string.h>
#include <stdlib.h>
#include "compat.h"

void
freezero(void *ptr, size_t sz)
Expand Down
8 changes: 8 additions & 0 deletions compat/stpcpy.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef HAVE_STPCPY
#include <string.h>
char* stpcpy(char *dst, const char *src)
{
const size_t len = strlen(src);
return (char*)memcpy(dst, src, len + 1) + len;
}
#endif
35 changes: 35 additions & 0 deletions compat/strsep.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef HAVE_STRSEP
#include <string.h>
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
6 changes: 5 additions & 1 deletion tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include <sys/socket.h>
#ifdef WIN32
# include <Winsock2.h>
#else
# include <sys/socket.h>
#endif

#include <errno.h>
#include <limits.h>
Expand Down
14 changes: 9 additions & 5 deletions tls_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@
*/

#include <sys/types.h>
#include <sys/socket.h>
#ifdef WIN32
# include <Winsock2.h>
# include <ws2tcpip.h>
#else
# include <sys/socket.h>
# include <arpa/inet.h>
# include <netinet/in.h>
# include <netdb.h>
#endif
#include <sys/stat.h>

#include <arpa/inet.h>
#include <netinet/in.h>

#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <netdb.h>
#include <stdlib.h>
#include <unistd.h>

Expand Down
4 changes: 4 additions & 0 deletions tls_conninfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#include <tls.h>
#include "tls_internal.h"

#ifdef WIN32
# include <time.h>
#endif

int ASN1_time_tm_clamp_notafter(struct tm *tm);

int
Expand Down
9 changes: 7 additions & 2 deletions tls_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@

#include <pthread.h>

#include <arpa/inet.h>
#include <netinet/in.h>
#ifdef WIN32
# include <Winsock2.h>
# include <in6addr.h>
#else
# include <netinet/in.h>
# include <arpa/inet.h>
#endif

#include <bearssl.h>

Expand Down
10 changes: 7 additions & 3 deletions tls_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include <sys/socket.h>

#include <arpa/inet.h>
#ifdef WIN32
# include <Winsock2.h>
# include <ws2tcpip.h>
#else
# include <sys/socket.h>
# include <arpa/inet.h>
#endif

#include <errno.h>
#include <stdlib.h>
Expand Down