utils/slog.c
int parse_config(const char *cfg_name)
{
    /* Used variables */
    FILE *file;
    char *line = NULL;
    size_t len = 0;
    ssize_t read;
    int ret = 1;

    /* Open file pointer */
    file = fopen(cfg_name, "r");
    if(file == NULL) return 1;

    /* Line-by-line read cfg file */
    while ((read = getline(&line, &len, file)) != -1) 
    {
        /* Find level in file */
        if(strstr(line, "LOGLEVEL") != NULL) 
        {
            /* Get log level */
            slg.level = atoi(line+8);
            ret = 0;
        }
        else if(strstr(line, "LOGTOFILE") != NULL) 
        {
            /* Get log level */
            slg.to_file = atoi(line+9);
            ret = 0;
        }
    } 

    /* Cleanup */
    if (line) free(line);
    fclose(file);

    return ret;
}
/*
 * parse_config - Parse config file. Argument cfg_name is path 
 * of config file name to be parsed. Function opens config file 
 * and parses LOGLEVEL and LOGTOFILE flags from it.
 */
Parse config file. Argument cfg_name is path
of config file name to be parsed. Function opens config file
and parses LOGLEVEL and LOGTOFILE flags from it.
Parse config file . Argument cfg_name is path of config file name to be parsed . Function opens config file and parses LOGLEVEL and LOGTOFILE flags from it .
int parse_config(const char *cfg_name)
{
    FILE *file;
    char *line = NULL;
    size_t len = 0;
    ssize_t read;
    int ret = 1;
    file = fopen(cfg_name, "r");
    if(file == NULL) return 1;
    while ((read = getline(&line, &len, file)) != -1) 
    {
        if(strstr(line, "LOGLEVEL") != NULL) 
        {
            slg.level = atoi(line+8);
            ret = 0;
        }
        else if(strstr(line, "LOGTOFILE") != NULL) 
        {
            slg.to_file = atoi(line+9);
            ret = 0;
        }
    } 
    if (line) free(line);
    fclose(file);
    return ret;
}
int parse_config ( const char * cfg_name ) { FILE * file ; char * line = NULL ; size_t len = 0 ; ssize_t read ; int ret = 1 ; file = fopen ( cfg_name , " " ) ; if ( file == NULL ) return 1 ; while ( ( read = getline ( & line , & len , file ) ) != -1 ) { if ( strstr ( line , " " ) != NULL ) { slg . level = atoi ( line + 8 ) ; ret = 0 ; } else if ( strstr ( line , " " ) != NULL ) { slg . to_file = atoi ( line + 9 ) ; ret = 0 ; } } if ( line ) free ( line ) ; fclose ( file ) ; return ret ; }
parse_config - Parse config file.
parse_config - Parse config file .
/* Used variables */ /* Open file pointer */ /* Line-by-line read cfg file */ /* Find level in file */ /* Get log level */ /* Get log level */ /* Cleanup */