library/src/utility/BP-StringUtilities.cc
// Strips quotes from a string.  This relies on BP_CheckIfBufferIsQuoted to determine
// quote types and strips from there.  The return value is NULL in the case that the
// string has quotes which were unable to be removed, or a newly allocated string
// containing the unquoted string.  The return value must be freed.  It is recommended
// that you call the check routine before utilizing this routine for thoroughness reasons.
Strips quotes from a string.  This relies on BP_CheckIfBufferIsQuoted to determine
quote types and strips from there.  The return value is NULL in the case that the
string has quotes which were unable to be removed, or a newly allocated string
containing the unquoted string.  The return value must be freed.  It is recommended
that you call the check routine before utilizing this routine for thoroughness reasons.
Strips quotes from a string . This relies on BP_CheckIfBufferIsQuoted to determine quote types and strips from there . The return value is NULL in the case that the string has quotes which were unable to be removed or a newly allocated string containing the unquoted string . The return value must be freed . It is recommended that you call the check routine before utilizing this routine for thoroughness reasons .
char * BP_UnquoteQuotedString(char *buffer, size_t buffer_len)
{
	if(!buffer || !buffer_len)
		return NULL;
	BP_STRING_QUOTE_CHECK_RESULTS quote_check = BP_CheckIfBufferIsQuoted(buffer, buffer_len);
	if
	(
		(quote_check != BP_STRING_IS_DOUBLE_QUOTED) &&
		(quote_check != BP_STRING_IS_SINGLE_QUOTED)
	)
	{
		return NULL;
	}
	char * ret_str = (char *) bpcalloc(buffer_len, 1);
	if(!ret_str)
		return NULL;
	char * read_pos = (char *) &buffer[1];
	memcpy(ret_str, read_pos, buffer_len-2);
	return ret_str;
}
char * BP_UnquoteQuotedString ( char * buffer , size_t buffer_len ) { if ( ! buffer || ! buffer_len ) return NULL ; BP_STRING_QUOTE_CHECK_RESULTS quote_check = BP_CheckIfBufferIsQuoted ( buffer , buffer_len ) ; if ( ( quote_check != BP_STRING_IS_DOUBLE_QUOTED ) && ( quote_check != BP_STRING_IS_SINGLE_QUOTED ) ) { return NULL ; } char * ret_str = ( char * ) bpcalloc ( buffer_len , 1 ) ; if ( ! ret_str ) return NULL ; char * read_pos = ( char * ) & buffer [ 1 ] ; memcpy ( ret_str , read_pos , buffer_len - 2 ) ; return ret_str ; }
Strips quotes from a string.
Strips quotes from a string .
// ensure we have a buffer and a length associated // add quote check // ensure that the string is quoted in some direct way // if it's not quoted, return NULL // allocate space for the new string // ensure we can allocate the string // set read position as +1 (for quote removal) // copy in data // return null by default