From d9c4a95345bd758e45196b29368bd2ff0f2790e3 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 6 Apr 2013 13:14:48 +0200 Subject: tagging ychat-0.5.2 --- conf.cpp | 71 ++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 36 insertions(+), 35 deletions(-) mode change 100755 => 100644 conf.cpp (limited to 'conf.cpp') diff --git a/conf.cpp b/conf.cpp old mode 100755 new mode 100644 index 3ff71b8..14dc199 --- a/conf.cpp +++ b/conf.cpp @@ -10,66 +10,67 @@ using namespace std; conf::conf( string s_conf = CONFILE ) : name( s_conf ) { - parse( ); // parse the config file. + parse( ); // parse the config file. } conf::~conf() -{ -} +{} void conf::parse() { #ifdef VERBOSE - cout << CFILEOK << get_name() << endl; + cout << CFILEOK << get_name() << endl; #endif - ifstream fs_conf( get_name().c_str() ); + ifstream fs_conf( get_name().c_str() ); - if ( ! fs_conf ) - { + if ( ! fs_conf ) + { #ifdef VERBOSE - cout << CFILENO << get_name() << endl; + cout << CFILENO << get_name() << endl; #endif - return; - } - char c_buf[READBUF]; + return; + } + + char c_buf[READBUF]; - while( fs_conf.getline( c_buf, READBUF ) ) - { - string s_token( c_buf ); - unsigned int ui_pos = s_token.find( "#", 0 ); - - // if line is commented out: - if ( ui_pos == 0 ) - continue; + while( fs_conf.getline( c_buf, READBUF ) ) + { + string s_token( c_buf ); + unsigned int ui_pos = s_token.find( "#", 0 ); - ui_pos = s_token.find( ";", 0 ); + // if line is commented out: + if ( ui_pos == 0 ) + continue; - // if token has not been found. - if ( ui_pos == string::npos ) - continue; + ui_pos = s_token.find( ";", 0 ); - s_token = s_token.substr( 0 , --ui_pos ); - ui_pos = s_token.find ( "\"", 0 ); + // if token has not been found. + if ( ui_pos == string::npos ) + continue; - if ( ui_pos == string::npos ) - continue; + s_token = s_token.substr( 0 , --ui_pos ); + ui_pos = s_token.find ( "\"", 0 ); - string s_val = s_token.substr( ui_pos+1, s_token.length() ); - string s_key = s_token.substr( 0 , --ui_pos ); + if ( ui_pos == string::npos ) + continue; + + string s_val = s_token.substr( ui_pos+1, s_token.length() ); + string s_key = s_token.substr( 0 , --ui_pos ); #ifdef VERBOSE2 - cout << s_key << "=" << s_val << endl; + + cout << s_key << "=" << s_val << endl; #endif - // fill the map. - map_vals[s_key] = s_val; - } + // fill the map. + map_vals[s_key] = s_val; + } - fs_conf.close(); - fs_conf.~ifstream(); + fs_conf.close(); + fs_conf.~ifstream(); } #endif -- cgit v1.2.3