src/core/config/parser.c
/**
 * Handle creating a config_value from a string
 *
 * The parser will be pointing to the beginning of a line containing a
 * config value in the format:
 *
 * config_key = config_value
 *
 * or in the case of array values (which allow multi-line values)
 *
 * config_key = [
 *      <value>,
 *      <value>,
 *]
 *
 * If the value starts with VARIABLE_START then  a lookup is performed
 * in the existing variables. If something is found then the value is
 * replaced by what was found - otherwise -1 is returned
 *
 * These are used to create the returned config_value. If there is an
 * error while parsing then NULL is returned and no memory is left
 * allocated
 */
Handle creating a config_value from a string
The parser will be pointing to the beginning of a line containing a
config value in the format.



or in the case of array values (which allow multi-line values)



If the value starts with VARIABLE_START then  a lookup is performed
in the existing variables. If something is found then the value is
replaced by what was found - otherwise -1 is returned

These are used to create the returned config_value. If there is an
error while parsing then NULL is returned and no memory is left
allocated
Handle creating a config_value from a string The parser will be pointing to the beginning of a line containing a config value in the format . or in the case of array values ( which allow multi - line values ) If the value starts with VARIABLE_START then a lookup is performed in the existing variables . If something is found then the value is replaced by what was found - otherwise - 1 is returned These are used to create the returned config_value . If there is an error while parsing then NULL is returned and no memory is left allocated
enum natwm_error parser_read_item(struct parser *parser, char **key_result,
                                  struct config_value **value_result)
{
        enum natwm_error err = GENERIC_ERROR;
        char *key = NULL;
        err = parser_read_key(parser, &key, NULL);
        if (err != NO_ERROR) {
                return err;
        }
        char *value = NULL;
        err = parser_read_value(parser, &value, NULL);
        if (err != NO_ERROR) {
                free(key);
                return err;
        }
        struct config_value *config_value = parser_parse_value(parser, value);
        if (config_value == NULL) {
                LOG_ERROR(natwm_logger, "Failed to save '%s' - Line %zu", key, parser->line_num);
                free(key);
                free(value);
                return GENERIC_ERROR;
        }
        *key_result = key;
        *value_result = config_value;
        return NO_ERROR;
}
enum natwm_error parser_read_item ( struct parser * parser , char * * key_result , struct config_value * * value_result ) { enum natwm_error err = GENERIC_ERROR ; char * key = NULL ; err = parser_read_key ( parser , & key , NULL ) ; if ( err != NO_ERROR ) { return err ; } char * value = NULL ; err = parser_read_value ( parser , & value , NULL ) ; if ( err != NO_ERROR ) { free ( key ) ; return err ; } struct config_value * config_value = parser_parse_value ( parser , value ) ; if ( config_value == NULL ) { LOG_ERROR ( natwm_logger , " " , key , parser -> line_num ) ; free ( key ) ; free ( value ) ; return GENERIC_ERROR ; } * key_result = key ; * value_result = config_value ; return NO_ERROR ; }
Handle creating a config_value from a string
 The parser will be pointing to the beginning of a line containing a
 config value in the format:
Handle creating a config_value from a string The parser will be pointing to the beginning of a line containing a config value in the format :