28 #include "XrdOuc/XrdOucEnv.hh"
29 #include "XrdOuc/XrdOucStream.hh"
30 #include "XrdOuc/XrdOucString.hh"
37 XrdOucString XrdProofdConfig::fgHost;
42 XrdProofdConfig::XrdProofdConfig(
const char *fn, XrdSysError *edest)
43 : fCfgFile(fn), fEDest(edest)
45 SetCfgEDest(fn, edest);
51 void XrdProofdConfig::SetCfgEDest(
const char *fn, XrdSysError *edest)
54 if (fn && fCfgFile.fName != fn) {
56 XrdProofdAux::Expand(fCfgFile.fName);
67 bool XrdProofdConfig::ReadFile(
bool update)
69 XPDLOC(ALL,
"Config::ReadFile")
72 if (fCfgFile.fName.length() > 0) {
76 if (stat(fCfgFile.fName.c_str(), &st) != 0)
78 TRACE(DBG,
"file: " << fCfgFile.fName);
79 TRACE(DBG,
"time of last modification: " << st.st_mtime);
82 if (st.st_mtime <= fCfgFile.fMtime)
86 if (update) fCfgFile.fMtime = st.st_mtime;
102 int XrdProofdConfig::ParseFile(
bool rcf)
104 XPDLOC(ALL,
"Config::ParseFile")
110 TRACE(DBG,
"config file already parsed ");
115 if (fgHost.length() <= 0) {
116 char *host = XrdSysDNS::getHostName();
117 fgHost = host ? host :
"";
123 fDirectives.Apply(SetHostInDirectives, (
void *)fgHost.c_str());
127 const char *cfn = fCfgFile.fName.c_str();
128 if ((cfgFD = open(cfn, O_RDONLY, 0)) < 0) {
129 TRACE(XERR,
"unable to open : " << cfn);
135 XrdOucStream cfg(fEDest, getenv(
"XRDINSTANCE"), &myEnv);
139 char *var = 0, *val = 0;
140 while ((var = cfg.GetMyFirstWord())) {
141 if (!(strncmp(
"xpd.", var, 4)) && var[4]) {
145 XrdProofdDirective *d = fDirectives.Find(var);
149 d->DoDirective(val, &cfg, rcf);
153 XrdProofdDirective *d = fDirectives.Find(var);
157 d->DoDirective(val, &cfg, rcf);