This commit is contained in:
False.Genesis 2007-01-05 21:35:23 +00:00
parent d27b34100a
commit fe91c8ebd6
3 changed files with 23 additions and 12 deletions

View File

@ -87,16 +87,22 @@ bool VarSet::ReadVarsFromFile(std::string fn)
while(!fh.eof())
{
c=fh.get();
if(c=='\n')
if(c=='\n' || fh.eof())
{
if(line.empty())
continue;
vn.clear();
vv.clear();
while(line.at(0)==' ' || line.at(0)=='\t')
line.erase(0,1);
while(line.at(line.length()-1)==' ' || line.at(line.length()-1)=='\t')
line.erase(line.length(),1);
//while(line.at(line.length()-1)==' ' || line.at(line.length()-1)=='\t')
// line.erase(line.length(),1);
if(line.empty() || (line.at(0)=='/' && line.at(0)=='/') )
{
line.clear();
continue;
}
if(line.at(0)=='[' && line.at(line.length()-1)==']')
{
prefix=line.substr(1,line.length()-2);
@ -108,16 +114,19 @@ bool VarSet::ReadVarsFromFile(std::string fn)
{
upper=true;
lower=false;
prefix.clear();
}
else if(prefix=="#normal")
{
upper=false;
lower=false;
prefix.clear();
}
else if(prefix=="#lowercase")
{
lower=true;
upper=false;
prefix.clear();
}
else
{
@ -130,7 +139,7 @@ bool VarSet::ReadVarsFromFile(std::string fn)
unsigned int pos=line.find("=");
if(pos)
{
std::string v=line.substr(0,pos-1);;
std::string v=line.substr(0,pos);;
if(upper)
v=toUpper(v);
@ -140,6 +149,7 @@ bool VarSet::ReadVarsFromFile(std::string fn)
vn=prefix+v;
vv=line.substr(pos+1,line.length()-1);
Set(vn,vv);
DEB(printf("DEBUG: Var import [%s] = %s\n",vn.c_str(),vv.c_str()););
}
// else invalid line, must have '='
}

View File

@ -38,6 +38,7 @@ PseuInstance::PseuInstance()
_ver_short="A12-dev1" DEBUG_APPENDIX;
_wsession=NULL;
_rsession=NULL;
_stop=false;
}
@ -69,18 +70,18 @@ bool PseuInstance::Init(void) {
if(!_scp->variables.ReadVarsFromFile(_confdir + "PseuWoW.conf"))
{
printf("Error reading conf file [%s]",_confdir.append("PseuoW.conf").c_str());
printf("Error reading conf file [%s]",_confdir.append("PseuWoW.conf").c_str());
return false;
}
_conf->ApplyFromVarSet(_scp->variables);
if(!_scp->variables.ReadVarsFromFile(_confdir + "users.conf"))
if(_scp->variables.ReadVarsFromFile(_confdir + "users.conf"))
{
//printf("-> Done.\n");
printf("-> Done reading users.\n");
}
else
{
printf("Error reading conf file [%s] - NO PERMISSIONS SET!",_confdir.append("users.conf").c_str());
printf("Error reading conf file [%s] - NO PERMISSIONS SET!\n",_confdir.append("users.conf").c_str());
}
@ -96,9 +97,9 @@ bool PseuInstance::Init(void) {
// //DEBUG1(printf("Main_Init: Loading DefScripts from folder '%s'\n",defScpPath.c_str()););
if(!_scp->RunScriptByName("_startup",NULL,255)){
printf("Main_Init: Error executing '_startup.def'\n");
}
//if(!_scp->RunScriptByName("_startup",NULL,255)){
// printf("Main_Init: Error executing '_startup.def'\n");
//}
if(_stop){
printf("Errors while initializing, proc halted!!\n");

View File

@ -7,7 +7,7 @@
#define DEBUG_APPENDIX " - DEBUG"
#define CODEDEB(code) fprintf(stderr,"[[ %s ]]\n",#code); code;
#else
#define DEB(code)
#define DEB(code) ;
#define DEBUG_APPENDIX
#define CODEDEB(code) code;
#endif