38 #include <sys/types.h>
76 while((wPos = wlist.tokenize(wtoken, wPos,
' ')) != -1)
92 {
if ((n = strlen(want[i])))
93 {
if (*(want[i]+(n-1)) !=
'.') n = 0;
107 while((tP = gcP->
Match))
125 throw std::invalid_argument(
"XrdSysError object not supplied!");
151 char *var, drctv[64], body[4096];
153 bool trim =
false, addKey =
true;
157 if (!(gcP->
Match))
return 0;
169 if ( (cfgFD =
open(cfname, O_RDONLY, 0)) < 0)
171 if (gcP->
eDest) gcP->
eDest->
Emsg(
"Gcf", rc,
"open config file", cfname);
177 Config.Attach(cfgFD, 4096);
179 if (parms && *parms) theGrab = parms;
184 {
case full_lines: *drctv =
'\n';
trim =
false; addKey =
true;
break;
185 case trim_lines: *drctv =
'\n';
trim =
true; addKey =
true;
break;
186 case only_body: *drctv =
' ';
trim =
false; addKey =
false;
break;
187 case trim_body: *drctv =
' ';
trim =
true; addKey =
true;
break;
188 default:
break;
return 0;
194 while((var =
Config.GetMyFirstWord()))
196 while(tP && ((tP->val && strncmp(var, tP->
text, tP->val)) ||
197 (!tP->val && strcmp( var, tP->
text)))) tP = tP->
next;
202 {
char *dot = index(var,
'.');
203 if (dot && *(dot+1)) var = dot+1;
205 int n = snprintf(drctv+1,
sizeof(drctv)-1,
"%s ", var);
206 if (n >= (
int)
sizeof(drctv)-1)
212 if (!
Config.GetRest(body,
sizeof(body)))
213 {
if (gcP->
eDest) gcP->
eDest->
Emsg(
"Gcf", E2BIG,
"handle arguments");
226 if ((rc =
Config.LastError()))
227 {
if (gcP->
eDest) gcP->
eDest->
Emsg(
"Gcf", rc,
"read config file", cfname);
228 return (rc < 0 ? rc : -rc);
234 if ((n = theGrab.
length()) <= 1) n = 0;
235 else {gcP->
gBuff = (
char *)malloc(n);
253 if (!theLine) gcP->
lline =
"";
254 else gcP->
lline = theLine;
292 const char* txt4,
const char* txt5,
const char* txt6)
297 mVec[n++] =
"Config mistake:";
298 if (txt1) mVec[n++] = txt1;
299 if (txt2) mVec[n++] = txt2;
300 if (txt3) mVec[n++] = txt3;
301 if (txt4) mVec[n++] = txt4;
302 if (txt5) mVec[n++] = txt5;
303 if (txt6) mVec[n++] = txt6;
313 const char* txt4,
const char* txt5,
const char* txt6)
318 mVec[n++] =
"Config warning:";
319 if (txt1) mVec[n++] = txt1;
320 if (txt2) mVec[n++] = txt2;
321 if (txt3) mVec[n++] = txt3;
322 if (txt4) mVec[n++] = txt4;
323 if (txt5) mVec[n++] = txt5;
324 if (txt6) mVec[n++] = txt6;
333 void XrdOucGatherConf::MsgX(
const char** mVec,
int n)
340 throw std::invalid_argument(
"XrdSysError object not supplied!");
344 for (
int i = 0; i < n; i++)
346 if (i+1 < n) theMsg +=
' ';
364 va_start (args, fmt);
368 vsnprintf(buffer,
sizeof(buffer), fmt, args);
372 MsgfX(
"Config mistake: ", buffer);
383 va_start (args, fmt);
387 vsnprintf(buffer,
sizeof(buffer), fmt, args);
391 MsgfX(
"Config warning: ", buffer);
398 void XrdOucGatherConf::MsgfX(
const char* txt1,
const char* txt2)
404 throw std::invalid_argument(
"XrdSysError object not supplied!");
437 if (!data || *data == 0)
return false;
440 gcP->
gBuff = strdup(data);
void trim(std::string &str)
int open(const char *path, int oflag,...)
char * GetToken(char **rest=0, int lowcase=0)
XrdOucGatherConf(const char *want, XrdSysError *errP=0)
void MsgfW(const char *fmt,...)
void MsgW(const char *txt1, const char *txt2=0, const char *txt3=0, const char *txt4=0, const char *txt5=0, const char *txt6=0)
void MsgfE(const char *fmt,...)
int Gather(const char *cfname, Level lvl, const char *parms=0)
void MsgE(const char *txt1, const char *txt2=0, const char *txt3=0, const char *txt4=0, const char *txt5=0, const char *txt6=0)
void EchoOrder(bool doBefore)
bool useData(const char *data)
@ trim_lines
Prefix trimmed lines.
@ trim_body
Prefix trimmed lines as a string blob.
@ only_body
Only directive bodies as a string blob.
@ full_lines
Complete lines.
const char * c_str() const
char * GetToken(char **rest=0, int lowcase=0)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
void Say(const char *text1, const char *text2=0, const char *txt3=0, const char *text4=0, const char *text5=0, const char *txt6=0)
XrdOucTokenizer Tokenizer
XrdOucGatherConfData(XrdSysError *eP)