added: created directory 'content' which has Content:: files
added: created directory 'templates' which has Templates:: and TemplatesFunctions:: files changed: content.cpp split into many files (directory 'content') changed: templates.cpp split into many files (directory 'templates') added: full permissions changed: building of the program (GNU make is used now) Makefile and Makefile.dep added into directories added: a parser 'FunctionParser' is used to parse the GET string it recognizes directories, items, functions, functions parameters added: other classes: Function, Functions added: function: ls, privileges changed: function 'id' to 'node' changed: version: to 0.2.0 added/changed: a lot of work have been done git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@469 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -20,27 +20,31 @@ Config::Config()
|
||||
|
||||
|
||||
|
||||
//!! czy tu w ogole mozemy uzywac log << ?
|
||||
//!! przeciez jeszcze nie zostal przetworzony plik konfiguracyjny
|
||||
|
||||
|
||||
void Config::ShowError()
|
||||
{
|
||||
|
||||
switch( conf_parser.status )
|
||||
{
|
||||
case ConfParser::ok:
|
||||
log << log2 << "config syntax ok" << logend;
|
||||
log << log2 << "Config: syntax ok" << logend;
|
||||
break;
|
||||
|
||||
case ConfParser::cant_open_file:
|
||||
if( errors_to_stdout )
|
||||
std::cout << "cant open a config file: " << data.config_file << std::endl;
|
||||
std::cout << "Config: cant open a config file: " << data.config_file << std::endl;
|
||||
|
||||
log << log1 << "cant open a config file: " << data.config_file << logend;
|
||||
log << log1 << "Config: cant open a config file: " << data.config_file << logend;
|
||||
break;
|
||||
|
||||
case ConfParser::syntax_error:
|
||||
if( errors_to_stdout )
|
||||
std::cout << "syntax error a config file: line " << conf_parser.line << std::endl;
|
||||
std::cout << "Config: syntax error, line: " << conf_parser.line << std::endl;
|
||||
|
||||
log << log1 << "config file: syntax error: line " << conf_parser.line << logend;
|
||||
log << log1 << "Config: syntax error, line: " << conf_parser.line << logend;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -56,11 +60,11 @@ bool Config::ReadConfig(bool errors_to_stdout_)
|
||||
|
||||
if( data.config_file.empty() )
|
||||
{
|
||||
log << log2 << "name of the config file is empty" << logend;
|
||||
log << log2 << "Config: name of the config file is empty" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
log << log2 << "reading config file" << logend;
|
||||
log << log2 << "Config: reading a config file" << logend;
|
||||
|
||||
ConfParser::Status status = conf_parser.Parse( data.config_file.c_str() );
|
||||
|
||||
@@ -102,6 +106,9 @@ void Config::AssignValues()
|
||||
data.db_user = Text("db_user");
|
||||
data.db_pass = Text("db_pass");
|
||||
data.base_url = Text("base_url");
|
||||
|
||||
NoLastSlash(data.base_url);
|
||||
|
||||
data.one_item_is_showed = Bool("one_item_is_showed");
|
||||
|
||||
data.priv_no_user = Text("priv_no_user");
|
||||
@@ -117,11 +124,11 @@ std::string & Config::Text(const char * name)
|
||||
|
||||
if( i == conf_parser.table.end() )
|
||||
{
|
||||
log << log2 << "warning: " << name << " is not defined in the config, default will be: \"" << default_str << "\"" << logend;
|
||||
log << log2 << "Config: warning: " << name << " is not defined in the config, default will be: \"" << default_str << "\"" << logend;
|
||||
return default_str;
|
||||
}
|
||||
|
||||
//log << log3 << name << "=" << i->second << logend;
|
||||
log << log3 << "Config: " << name << "=" << i->second << logend;
|
||||
|
||||
return i->second;
|
||||
}
|
||||
@@ -135,12 +142,12 @@ int Config::Int(const char * name)
|
||||
|
||||
if( i == conf_parser.table.end() || i->second.empty() )
|
||||
{
|
||||
log << log2 << "warning: " << name << " is not defined in the config, default will be: " << default_int << logend;
|
||||
log << log2 << "Config: warning: " << name << " is not defined in the config, default will be: " << default_int << logend;
|
||||
return default_int;
|
||||
}
|
||||
|
||||
long res = (i->second[0] == '0')? strtol(i->second.c_str() + 1, 0, 8) : strtol(i->second.c_str(), 0, 10);
|
||||
log << log3 << name << "=" << res << logend;
|
||||
log << log3 << "Config: " << name << "=" << res << logend;
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -153,7 +160,7 @@ bool Config::Bool(const char * name)
|
||||
|
||||
if( i == conf_parser.table.end() )
|
||||
{
|
||||
log << log2 << "warning: " << name << " is not defined in the config, default will be: " << (default_bool?"true":"false") << logend;
|
||||
log << log2 << "Config: warning: " << name << " is not defined in the config, default will be: " << (default_bool?"true":"false") << logend;
|
||||
return default_int;
|
||||
}
|
||||
|
||||
@@ -162,7 +169,7 @@ bool Config::Bool(const char * name)
|
||||
if( i->second == "true" || i->second == "1" || i->second == "yes" )
|
||||
res = true;
|
||||
|
||||
log << log3 << name << "=" << (res?"true":"false") << logend;
|
||||
log << log3 << "Config: " << name << "=" << (res?"true":"false") << logend;
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -170,13 +177,23 @@ return res;
|
||||
|
||||
|
||||
|
||||
void Config::NoLastSlash(std::string & s)
|
||||
{
|
||||
if( s.empty() )
|
||||
return;
|
||||
|
||||
log << log2 << "Config: removing the last slash from: " << s << logend;
|
||||
|
||||
if( *(--s.end()) == '/' )
|
||||
s.erase(--s.end());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user