提交 a4923bbe authored 作者: Michael Jerris's avatar Michael Jerris

add PL_strtok_r

上级 86487ed4
...@@ -125,7 +125,7 @@ core/src-common/util_ios_queue.c \ ...@@ -125,7 +125,7 @@ core/src-common/util_ios_queue.c \
core/src-common/util_parse.c \ core/src-common/util_parse.c \
core/src-common/util_string.c core/src-common/util_string.c
CPR_COMMON_SRC = cpr/common/cpr_string.c CPR_COMMON_SRC = cpr/common/cpr_string.c cpr/common/strtok.c
CPR_DARWIN_SRC = \ CPR_DARWIN_SRC = \
cpr/darwin/cpr_darwin_errno.c \ cpr/darwin/cpr_darwin_errno.c \
...@@ -342,6 +342,7 @@ cpr/darwin/cpr_darwin_timers.h \ ...@@ -342,6 +342,7 @@ cpr/darwin/cpr_darwin_timers.h \
cpr/darwin/cpr_darwin_tst.h \ cpr/darwin/cpr_darwin_tst.h \
cpr/darwin/cpr_darwin_types.h \ cpr/darwin/cpr_darwin_types.h \
cpr/include/cpr.h \ cpr/include/cpr.h \
cpr/include/plstr.h \
cpr/include/cpr_assert.h \ cpr/include/cpr_assert.h \
cpr/include/cpr_debug.h \ cpr/include/cpr_debug.h \
cpr/include/cpr_errno.h \ cpr/include/cpr_errno.h \
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "platform_api.h" #include "platform_api.h"
#include "vcm.h" #include "vcm.h"
//#include "prlog.h" //#include "prlog.h"
//#include "plstr.h" #include "plstr.h"
#include "sdp_private.h" #include "sdp_private.h"
//TODO Need to place this in a portable location //TODO Need to place this in a portable location
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include <errno.h> #include <errno.h>
#include <limits.h> #include <limits.h>
//#include "plstr.h" #include "plstr.h"
#include "sdp_os_defs.h" #include "sdp_os_defs.h"
#include "sdp.h" #include "sdp.h"
#include "sdp_private.h" #include "sdp_private.h"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//#include "plstr.h" #include "plstr.h"
#include "cpr_types.h" #include "cpr_types.h"
#include "cpr_time.h" #include "cpr_time.h"
#include "cpr_stdio.h" #include "cpr_stdio.h"
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <errno.h> #include <errno.h>
#include <limits.h> #include <limits.h>
//#include "plstr.h" #include "plstr.h"
#include "cpr_types.h" #include "cpr_types.h"
#include "cpr_stdio.h" #include "cpr_stdio.h"
#include "cpr_stdlib.h" #include "cpr_stdlib.h"
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* CCAPI callids, conversion from CCAPI to SIP cause codes and the * CCAPI callids, conversion from CCAPI to SIP cause codes and the
* like. * like.
*/ */
//#include "plstr.h" #include "plstr.h"
#include "cpr_types.h" #include "cpr_types.h"
#include "cpr_stdlib.h" #include "cpr_stdlib.h"
#include "cpr_string.h" #include "cpr_string.h"
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "plstr.h"
char * PL_strtok_r(char *s1, const char *s2, char **lasts)
{
const char *sepp;
int c, sc;
char *tok;
if( s1 == NULL )
{
if( *lasts == NULL )
return NULL;
s1 = *lasts;
}
for( ; (c = *s1) != 0; s1++ )
{
for( sepp = s2 ; (sc = *sepp) != 0 ; sepp++ )
{
if( c == sc )
break;
}
if( sc == 0 )
break;
}
if( c == 0 )
{
*lasts = NULL;
return NULL;
}
tok = s1++;
for( ; (c = *s1) != 0; s1++ )
{
for( sepp = s2; (sc = *sepp) != 0; sepp++ )
{
if( c == sc )
{
*s1++ = '\0';
*lasts = s1;
return tok;
}
}
}
*lasts = NULL;
return tok;
}
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef _plstr_h
#define _plstr_h
#include "cpr_types.h"
__BEGIN_DECLS
/*
* PL_strtok_r
*
* Splits the string s1 into tokens, separated by one or more characters
* from the separator string s2. The argument lasts points to a
* user-supplied char * pointer in which PL_strtok_r stores information
* for it to continue scanning the same string.
*
* In the first call to PL_strtok_r, s1 points to a string and the value
* of *lasts is ignored. PL_strtok_r returns a pointer to the first
* token, writes '\0' into the character following the first token, and
* updates *lasts.
*
* In subsequent calls, s1 is null and lasts must stay unchanged from the
* previous call. The separator string s2 may be different from call to
* call. PL_strtok_r returns a pointer to the next token in s1. When no
* token remains in s1, PL_strtok_r returns null.
*/
char * PL_strtok_r(char *s1, const char *s2, char **lasts);
/*
* Things not (yet?) included: strspn/strcspn, strsep.
* memchr, memcmp, memcpy, memccpy, index, rindex, bcmp, bcopy, bzero.
* Any and all i18n/l10n stuff.
*/
__END_DECLS
#endif /* _plstr_h */
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论