Skip to content

Commit

Permalink
Add strtok_r stub for MinGW
Browse files Browse the repository at this point in the history
  • Loading branch information
Levak committed Jun 5, 2015
1 parent 536af3a commit 671bdfc
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/tools/geoip.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,39 @@

#ifdef __MINGW32__
# include <Winsock.h>
/*
* public domain strtok_r() by Charlie Gordon
*
* from comp.lang.c 9/14/2007
*
* http://groups.google.com/group/comp.lang.c/msg/2ab1ecbb86646684
*
* (Declaration that it's public domain):
* http://groups.google.com/group/comp.lang.c/msg/7c7b39328fefab9c
*/

char* strtok_r(char *str, const char *delim, char **nextp)
{
char *ret;

if (str == NULL)
str = *nextp;

str += strspn(str, delim);

if (*str == '\0')
return NULL;

ret = str;
str += strcspn(str, delim);

if (*str)
*str++ = '\0';

*nextp = str;

return ret;
}
#else
# include <sys/socket.h>
# include <netinet/in.h>
Expand Down

0 comments on commit 671bdfc

Please sign in to comment.