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

View File

@ -38,6 +38,7 @@ PseuInstance::PseuInstance()
_ver_short="A12-dev1" DEBUG_APPENDIX; _ver_short="A12-dev1" DEBUG_APPENDIX;
_wsession=NULL; _wsession=NULL;
_rsession=NULL; _rsession=NULL;
_stop=false;
} }
@ -69,18 +70,18 @@ bool PseuInstance::Init(void) {
if(!_scp->variables.ReadVarsFromFile(_confdir + "PseuWoW.conf")) 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; return false;
} }
_conf->ApplyFromVarSet(_scp->variables); _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 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());); // //DEBUG1(printf("Main_Init: Loading DefScripts from folder '%s'\n",defScpPath.c_str()););
if(!_scp->RunScriptByName("_startup",NULL,255)){ //if(!_scp->RunScriptByName("_startup",NULL,255)){
printf("Main_Init: Error executing '_startup.def'\n"); // printf("Main_Init: Error executing '_startup.def'\n");
} //}
if(_stop){ if(_stop){
printf("Errors while initializing, proc halted!!\n"); printf("Errors while initializing, proc halted!!\n");

View File

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