120int main(
int argc,
char *argv[])
130 const char *Cfn = 0, *Host = 0, *Name = 0, *Xeq =
"xrootd", *oFile=0;
131 const char *noSub[] = {
"cms.prepmsg",
"ofs.notifymsg",
"oss.stagemsg",
132 "frm.xfr.copycmd", 0};
133 const char *ifChk[] = {
"xrd.port",
"all.role",
"all.manager", 0};
134 const char *slChk[] = {
"frm.xfr.copycmd", 0};
136 char buff[4096], *var, c;
137 int i, retc = 0, cfgFD, chkQ = 0;
142 if (argc > 1 &&
'-' == *argv[1])
143 while ((c = getopt(argc,argv,
":c:h:n:o:x:")) && ((
unsigned char)c != 0xff))
146 case 'c': Cfn = optarg;
148 case 'h': Host= optarg;
150 case 'n': Name= optarg;
152 case 'o': oFile=optarg;
154 case 'x': Xeq = optarg;
156 default: sprintf(buff,
"'%c'",
optopt);
157 if (c ==
':')
Say.Say(Pgm, buff,
" value not specified.");
158 else Say.Say(Pgm, buff,
" option is invalid.");
165 if (!Cfn) {
Say.Say(Pgm,
"Config file not specified.");
Usage(1);}
169 if (!Host) Host = theAddr.
Name();
170 else if (!theAddr.
Set(Host,0)) Host = theAddr.
Name();
171 if (!Host) {
Say.Say(Pgm,
"Unable to determine host name."); exit(3);}
176 chkQ = (DirQ.
First() != 0);
180 if ( (cfgFD =
open(Cfn, O_RDONLY, 0)) < 0)
181 {
Say.Say(Pgm,
XrdSysE2T(errno),
" opening config file ", Cfn);
188 sprintf(buff,
"%s %s@%s", Xeq, Name, Host);
190 Config->Attach(cfgFD);
195 Config->Capture(&theConfig);
199 while((var = Config->GetMyFirstWord()))
200 {
if (chkQ && !DirQ.
Find(var)) {Config->noEcho();
continue;}
203 while((var = Config->GetWord()) && *var !=
'/') {}
204 oldEnv = Config->SetEnv(0);
205 if (var) Config->GetRest(buff,
sizeof(buff));
206 Config->SetEnv(oldEnv);
208 else if (
inList(var, ifChk))
209 {
while((var = Config->GetWord()) && strcmp(var,
"if")) {}
212 {Config->noEcho();
continue;}
214 else Config->GetRest(buff,
sizeof(buff));
220 if ((retc = Config->LastError()))
221 {
Say.Say(Pgm,
XrdSysE2T(retc),
" reading config file ", Cfn); retc = 8;}
226 if (oFile && !retc) retc =
cfOut(oFile, theConfig);
static int doIf(XrdSysError *eDest, XrdOucStream &Config, const char *what, const char *hname, const char *nname, const char *pname)