From d776ac03c3ce8a9090b847f20d2cdd16d745441f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 1 Mar 2009 16:16:16 +0100 Subject: Move next_token_talloc() to top-level. --- source3/lib/util_str.c | 112 ------------------------------------------------- 1 file changed, 112 deletions(-) (limited to 'source3/lib/util_str.c') diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 9358061797..b9ccb83e55 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -35,118 +35,6 @@ const char toupper_ascii_fast_table[128] = { 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f }; -/** - * @file - * @brief String utilities. - **/ - -static bool next_token_internal_talloc(TALLOC_CTX *ctx, - const char **ptr, - char **pp_buff, - const char *sep, - bool ltrim) -{ - char *s; - char *saved_s; - char *pbuf; - bool quoted; - size_t len=1; - - *pp_buff = NULL; - if (!ptr) { - return(false); - } - - s = (char *)*ptr; - - /* default to simple separators */ - if (!sep) { - sep = " \t\n\r"; - } - - /* find the first non sep char, if left-trimming is requested */ - if (ltrim) { - while (*s && strchr_m(sep,*s)) { - s++; - } - } - - /* nothing left? */ - if (!*s) { - return false; - } - - /* When restarting we need to go from here. */ - saved_s = s; - - /* Work out the length needed. */ - for (quoted = false; *s && - (quoted || !strchr_m(sep,*s)); s++) { - if (*s == '\"') { - quoted = !quoted; - } else { - len++; - } - } - - /* We started with len = 1 so we have space for the nul. */ - *pp_buff = TALLOC_ARRAY(ctx, char, len); - if (!*pp_buff) { - return false; - } - - /* copy over the token */ - pbuf = *pp_buff; - s = saved_s; - for (quoted = false; *s && - (quoted || !strchr_m(sep,*s)); s++) { - if ( *s == '\"' ) { - quoted = !quoted; - } else { - *pbuf++ = *s; - } - } - - *ptr = (*s) ? s+1 : s; - *pbuf = 0; - - return true; -} - -#if 0 -/* - * Get the next token from a string, return false if none found. Handles - * double-quotes. This version trims leading separator characters before - * looking for a token. - */ -bool next_token(const char **ptr, char *buff, const char *sep, size_t bufsize) -{ - return next_token_internal(ptr, buff, sep, bufsize, true); -} -#endif - -bool next_token_talloc(TALLOC_CTX *ctx, - const char **ptr, - char **pp_buff, - const char *sep) -{ - return next_token_internal_talloc(ctx, ptr, pp_buff, sep, true); -} - -/* - * Get the next token from a string, return false if none found. Handles - * double-quotes. This version does not trim leading separator characters - * before looking for a token. - */ - -bool next_token_no_ltrim_talloc(TALLOC_CTX *ctx, - const char **ptr, - char **pp_buff, - const char *sep) -{ - return next_token_internal_talloc(ctx, ptr, pp_buff, sep, false); -} - /** * Case insensitive string compararison. * -- cgit