ReactOS 0.4.16-dev-1093-g93e9710
mbstok.cpp
Go to the documentation of this file.
1/***
2*mbstok.c - Break string into tokens (MBCS)
3*
4* Copyright (c) Microsoft Corporation. All rights reserved.
5*
6*Purpose:
7* Break string into tokens (MBCS)
8*
9*******************************************************************************/
10#ifndef _MBCS
11 #error This file should only be compiled with _MBCS defined
12#endif
13
14#include <corecrt_internal.h>
16#include <locale.h>
17#include <stddef.h>
18#include <string.h>
19
20/***
21* _mbstok - Break string into tokens (MBCS)
22*
23*Purpose:
24* strtok considers the string to consist of a sequence of zero or more
25* text tokens separated by spans of one or more control chars. the first
26* call, with string specified, returns a pointer to the first char of the
27* first token, and will write a null char into string immediately
28* following the returned token. subsequent calls with zero for the first
29* argument (string) will work thru the string until no tokens remain. the
30* control string may be different from call to call. when no tokens remain
31* in string a nullptr pointer is returned. remember the control chars with a
32* bit map, one bit per ascii char. the null char is always a control char.
33*
34* MBCS chars supported correctly.
35*
36*Entry:
37* char *string = string to break into tokens.
38* char *sepset = set of characters to use as seperators
39*
40*Exit:
41* returns pointer to token, or nullptr if no more tokens
42*
43*Exceptions:
44* Input parameters are validated. Refer to the validation section of the function.
45*
46*******************************************************************************/
47
48extern "C" unsigned char * __cdecl _mbstok_l(
49 unsigned char* const string,
50 unsigned char const* const sepset,
51 _locale_t const locale
52 )
53{
54 return _mbstok_s_l(string, sepset, &__acrt_getptd()->_mbstok_token, locale);
55}
56
57extern "C" unsigned char * __cdecl _mbstok(
58 unsigned char * string,
59 const unsigned char * sepset
60 )
61{
62 /* We call the deprecated _mbstok_l (and not _mbstok_s_l) so that we keep one
63 * single nextoken in the single thread case, i.e. the nextoken declared as static
64 * inside _mbstok_l
65 */
67 return _mbstok_l(string, sepset, nullptr);
69}
#define __cdecl
Definition: accygwin.h:79
Definition: _locale.h:75
__acrt_ptd *__cdecl __acrt_getptd(void)
#define _BEGIN_SECURE_CRT_DEPRECATION_DISABLE
#define _END_SECURE_CRT_DEPRECATION_DISABLE
unsigned char *__cdecl _mbstok_l(unsigned char *const string, unsigned char const *const sepset, _locale_t const locale)
Definition: mbstok.cpp:48
unsigned char *__cdecl _mbstok(unsigned char *string, const unsigned char *sepset)
Definition: mbstok.cpp:57
unsigned char *__cdecl _mbstok_s_l(unsigned char *_String, const unsigned char *_Control, unsigned char **_Context, _LOCALE_ARG_DECL)
Definition: mbstok_s.cpp:17