axl main logo
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Modules Pages
int axl_stream_replace ( char **  source,
int  source_len,
const char *  string,
int  string_len,
const char *  replacement,
int  replacement_len 
)

Allows to replace the provided string by the provided replacement on the provided source string, doing the replacement in an effective manner.

Parameters
sourceThe source string where to look and replace. The result will be reported as a new pointer on this parameter. The function will dealloc previous string (passed in source).
source_lenThe replace function can handle binary strings. This parameter signals the function how many bytes are found on the source pointer.
stringThe string that will be looked for replacement. The string can be binary data but its length must be configured.
string_lenString length or -1. The string parameter can be binary data (may include \0) but length must be especified. If -1 is provided, the function will use strlen () to get current string size.
replacementThe replace string. The replacement can be binary data but its length must be configured.
replacement_lenReplacement string length or -1. The replacement parameter can be binary data (may include \0) but length must be especified. If -1 is provided, the function will use strlen () to get current string size.
Returns
The function returns the new size of the string. The function returns the same source length when no replacement was done. The function return source_len in the case some argument is NULL.

References axl_free(), axl_memcmp(), axl_new, and axl_return_val_if_fail.