Stefan Schuermans
initial commit of files from bluebox project
Stefan Schuermans commited fd252ce at 2015-12-19 20:16:38
/* bluebox distributor
* version 0.3.2 date 2007-07-18
* Copyright (C) 2006-2007 Stefan Schuermans <stefan@blinkenarea.org>
* Copyleft: GNU public license V2.0 - http://www.gnu.org/copyleft/gpl.html
* a BlinkenArea project - http://www.blinkenarea.org/
*/
#include <stdio.h>
#include <string.h>
#include "config.h"
//parse config file
void config_parse( char * filename, st_config_setting * p_settings, int settings_cnt )
{
int i, len;
FILE * p_file;
char section[256], line[1024], dummy[1024], * p_lf, * p_hash, * p_line, * p_equal, * p_setting, * p_value, * p_append;
//empty all strings in settings array
for( i = 0; i < settings_cnt; i++ )
if( p_settings[i].buffer != NULL && p_settings[i].buffer_len > 0 )
p_settings[i].buffer[0] = 0;
//check filename (fopen segaults in these cases)
if( filename == NULL || filename[0] == 0 )
{
printf( "no config file was supplied\n" );
return;
}
//open file
p_file = fopen( filename, "rt" );
if( p_file == NULL )
{
printf( "could not open config file \"%s\"\n", filename );
return;
}
//no section yet
section[0] = 0;
//read file
while( !feof( p_file ) )
{
//read a line
line[0] = 0;
fgets( line, sizeof( line ), p_file );
//find LF in line in replace it with 0
p_lf = strchr( line, '\n' );
if( p_lf != NULL )
 
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX