diff --git a/libs/sipcc/Makefile.am b/libs/sipcc/Makefile.am index 74a1784d64..a09220a6df 100644 --- a/libs/sipcc/Makefile.am +++ b/libs/sipcc/Makefile.am @@ -125,7 +125,7 @@ core/src-common/util_ios_queue.c \ core/src-common/util_parse.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/cpr_darwin_errno.c \ @@ -342,6 +342,7 @@ cpr/darwin/cpr_darwin_timers.h \ cpr/darwin/cpr_darwin_tst.h \ cpr/darwin/cpr_darwin_types.h \ cpr/include/cpr.h \ +cpr/include/plstr.h \ cpr/include/cpr_assert.h \ cpr/include/cpr_debug.h \ cpr/include/cpr_errno.h \ diff --git a/libs/sipcc/core/gsm/gsm_sdp.c b/libs/sipcc/core/gsm/gsm_sdp.c index 6a795200fd..e349a347ae 100644 --- a/libs/sipcc/core/gsm/gsm_sdp.c +++ b/libs/sipcc/core/gsm/gsm_sdp.c @@ -22,7 +22,7 @@ #include "platform_api.h" #include "vcm.h" //#include "prlog.h" -//#include "plstr.h" +#include "plstr.h" #include "sdp_private.h" //TODO Need to place this in a portable location diff --git a/libs/sipcc/core/sdp/sdp_attr.c b/libs/sipcc/core/sdp/sdp_attr.c index fadaceede8..b0105ee59d 100644 --- a/libs/sipcc/core/sdp/sdp_attr.c +++ b/libs/sipcc/core/sdp/sdp_attr.c @@ -5,7 +5,7 @@ #include #include -//#include "plstr.h" +#include "plstr.h" #include "sdp_os_defs.h" #include "sdp.h" #include "sdp_private.h" diff --git a/libs/sipcc/core/sipstack/ccsip_messaging.c b/libs/sipcc/core/sipstack/ccsip_messaging.c index 515d0a90bc..d9a79651e9 100644 --- a/libs/sipcc/core/sipstack/ccsip_messaging.c +++ b/libs/sipcc/core/sipstack/ccsip_messaging.c @@ -2,7 +2,7 @@ * 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" +#include "plstr.h" #include "cpr_types.h" #include "cpr_time.h" #include "cpr_stdio.h" diff --git a/libs/sipcc/core/sipstack/ccsip_pmh.c b/libs/sipcc/core/sipstack/ccsip_pmh.c index 9717058a3a..e298993c09 100644 --- a/libs/sipcc/core/sipstack/ccsip_pmh.c +++ b/libs/sipcc/core/sipstack/ccsip_pmh.c @@ -15,7 +15,7 @@ #include #include -//#include "plstr.h" +#include "plstr.h" #include "cpr_types.h" #include "cpr_stdio.h" #include "cpr_stdlib.h" diff --git a/libs/sipcc/core/sipstack/ccsip_spi_utils.c b/libs/sipcc/core/sipstack/ccsip_spi_utils.c index 781bee2d43..97ce502d31 100755 --- a/libs/sipcc/core/sipstack/ccsip_spi_utils.c +++ b/libs/sipcc/core/sipstack/ccsip_spi_utils.c @@ -9,7 +9,7 @@ * CCAPI callids, conversion from CCAPI to SIP cause codes and the * like. */ -//#include "plstr.h" +#include "plstr.h" #include "cpr_types.h" #include "cpr_stdlib.h" #include "cpr_string.h" diff --git a/libs/sipcc/cpr/common/strtok.c b/libs/sipcc/cpr/common/strtok.c new file mode 100644 index 0000000000..08182290fa --- /dev/null +++ b/libs/sipcc/cpr/common/strtok.c @@ -0,0 +1,55 @@ +/* -*- 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; +} diff --git a/libs/sipcc/cpr/include/plstr.h b/libs/sipcc/cpr/include/plstr.h new file mode 100644 index 0000000000..46f101a26a --- /dev/null +++ b/libs/sipcc/cpr/include/plstr.h @@ -0,0 +1,42 @@ +/* -*- 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 */