1 #include "StDbDefaults.hh"
2 #include "stdb_streams.h"
8 StDbDefaults::StDbDefaults(){
10 strncpy(mversion,
"default",
sizeof(mversion));
11 strncpy(mflavor,
"ofl",
sizeof(mflavor));
14 strncpy(mdbServerVar,
"STDB_SERVERS",
sizeof(mdbServerVar));
15 strncpy(mdbServerFile,
"dbServers.xml",
sizeof(mdbServerFile));
20 char* StDbDefaults::getServerFileName(
const dbFindServerMode mode){
22 if(mode==userHome)
return getFileName(
"HOME");
23 if(mode==serverEnvVar)
return getFileName(mdbServerVar);
24 if(mode==starDefault)
return getFileName(
"STAR");
31 char* StDbDefaults::getFileName(
const char* fileName){
34 if(!fileName)
return nullReturn;
38 if(strcmp(fileName,
"HOME")==0){
39 fn << ( getenv(
"HOME") ? getenv(
"HOME") :
"" ) <<
"/" << mdbServerFile;
40 }
else if(strcmp(fileName,
"STAR")==0){
41 fn << ( getenv(
"STAR") ? getenv(
"STAR") :
"" ) <<
"/" <<
"StDb/servers/" <<mdbServerFile;
43 char* fname = getenv(fileName);
44 if ( fname == NULL || !fname ) {
return nullReturn; }
46 if ( opendir(fname) ) { fn <<
"/" << mdbServerFile; }
50 char* retVal=
new char[fns.length()+1];
51 strcpy(retVal,fns.c_str());