reactos/sdk/lib/crt/string/strtok_s.c

34 lines
737 B
C
Raw Normal View History

/* Taken from Wine Staging msvcrt/string.c */
#include <precomp.h>
#include <internal/wine/msvcrt.h>
/*********************************************************************
* strtok_s (MSVCRT.@)
*/
char * CDECL strtok_s(char *str, const char *delim, char **ctx)
{
if (!MSVCRT_CHECK_PMT(delim != NULL)) return NULL;
if (!MSVCRT_CHECK_PMT(ctx != NULL)) return NULL;
if (!MSVCRT_CHECK_PMT(str != NULL || *ctx != NULL)) return NULL;
if(!str)
str = *ctx;
while(*str && strchr(delim, *str))
str++;
if(!*str)
{
*ctx = str;
return NULL;
}
*ctx = str+1;
while(**ctx && !strchr(delim, **ctx))
(*ctx)++;
if(**ctx)
*(*ctx)++ = 0;
return str;
}