src/common/string.c
/**
 * Gets all characters up to a specified delimiter character
 *
 * The caller must supply a uninitialized char pointer which will
 * contain the newly allocated string, as well as a size pointer which will
 * contain the strlen of the new string
 *
 * The resulting string will consist of all characters up to the delimiter
 * character. If consume is true then the delimiter will also be included
 *
 * The caller must free the result
 *
 * The function either returns NO_ERROR or an error if it occured
 */
Gets all characters up to a specified delimiter character
The caller must supply a uninitialized char pointer which will
contain the newly allocated string, as well as a size pointer which will
contain the strlen of the new string

The resulting string will consist of all characters up to the delimiter
character. If consume is true then the delimiter will also be included

The caller must free the result

The function either returns NO_ERROR or an error if it occured
Gets all characters up to a specified delimiter character The caller must supply a uninitialized char pointer which will contain the newly allocated string as well as a size pointer which will contain the strlen of the new string The resulting string will consist of all characters up to the delimiter character . If consume is true then the delimiter will also be included The caller must free the result The function either returns NO_ERROR or an error if it occured
enum natwm_error string_get_delimiter(const char *string, char delimiter, char **destination,
                                      size_t *length, bool consume)
{
        size_t index = 0;
        enum natwm_error find_err = string_find_char(string, delimiter, &index);
        if (find_err != NO_ERROR) {
                return find_err;
        }
        if (consume) {
                ++index;
        }
        enum natwm_error splice_err = string_splice(string, 0, index, destination, length);
        if (splice_err != NO_ERROR) {
                return splice_err;
        }
        return NO_ERROR;
}
enum natwm_error string_get_delimiter ( const char * string , char delimiter , char * * destination , size_t * length , bool consume ) { size_t index = 0 ; enum natwm_error find_err = string_find_char ( string , delimiter , & index ) ; if ( find_err != NO_ERROR ) { return find_err ; } if ( consume ) { ++ index ; } enum natwm_error splice_err = string_splice ( string , 0 , index , destination , length ) ; if ( splice_err != NO_ERROR ) { return splice_err ; } return NO_ERROR ; }
Gets all characters up to a specified delimiter character
 The caller must supply a uninitialized char pointer which will
 contain the newly allocated string, as well as a size pointer which will
 contain the strlen of the new string
Gets all characters up to a specified delimiter character The caller must supply a uninitialized char pointer which will contain the newly allocated string as well as a size pointer which will contain the strlen of the new string