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))
127 throw std::invalid_argument(
"XrdSysError object not supplied!");
153 char *var, drctv[64], body[4096];
155 bool trim =
false, addKey =
true;
159 if (!(gcP->
Match))
return 0;
171 if ( (cfgFD =
open(cfname, O_RDONLY, 0)) < 0)
173 if (gcP->
eDest) gcP->
eDest->
Emsg(
"Gcf", rc,
"open config file", cfname);
179 Config.Attach(cfgFD, 4096);
181 if (parms && *parms) theGrab = parms;
186 {
case full_lines: *drctv =
'\n';
trim =
false; addKey =
true;
break;
187 case trim_lines: *drctv =
'\n';
trim =
true; addKey =
true;
break;
188 case only_body: *drctv =
' ';
trim =
false; addKey =
false;
break;
189 case trim_body: *drctv =
' ';
trim =
true; addKey =
true;
break;
190 default:
break;
return 0;
196 while((var =
Config.GetMyFirstWord()))
198 while(tP && ((tP->val && strncmp(var, tP->
text, tP->val)) ||
199 (!tP->val && strcmp( var, tP->
text)))) tP = tP->
next;
204 {
char *dot = index(var,
'.');
205 if (dot && *(dot+1)) var = dot+1;
207 int n = snprintf(drctv+1,
sizeof(drctv)-1,
"%s ", var);
208 if (n >= (
int)
sizeof(drctv)-1)
214 if (!
Config.GetRest(body,
sizeof(body)))
215 {
if (gcP->
eDest) gcP->
eDest->
Emsg(
"Gcf", E2BIG,
"handle arguments");
228 if ((rc =
Config.LastError()))
229 {
if (gcP->
eDest) gcP->
eDest->
Emsg(
"Gcf", rc,
"read config file", cfname);
230 return (rc < 0 ? rc : -rc);
236 if ((n = theGrab.
length()) <= 1) n = 0;
237 else {gcP->
gBuff = (
char *)malloc(n);
255 if (!theLine) gcP->
lline =
"";
256 else gcP->
lline = theLine;
294 const char* txt4,
const char* txt5,
const char* txt6)
299 mVec[n++] =
"Config mistake:";
300 if (txt1) mVec[n++] = txt1;
301 if (txt2) mVec[n++] = txt2;
302 if (txt3) mVec[n++] = txt3;
303 if (txt4) mVec[n++] = txt4;
304 if (txt5) mVec[n++] = txt5;
305 if (txt6) mVec[n++] = txt6;
315 const char* txt4,
const char* txt5,
const char* txt6)
320 mVec[n++] =
"Config warning:";
321 if (txt1) mVec[n++] = txt1;
322 if (txt2) mVec[n++] = txt2;
323 if (txt3) mVec[n++] = txt3;
324 if (txt4) mVec[n++] = txt4;
325 if (txt5) mVec[n++] = txt5;
326 if (txt6) mVec[n++] = txt6;
335 void XrdOucGatherConf::MsgX(
const char** mVec,
int n)
342 throw std::invalid_argument(
"XrdSysError object not supplied!");
346 for (
int i = 0; i < n; i++)
348 if (i+1 < n) theMsg +=
' ';
366 va_start (args, fmt);
370 vsnprintf(buffer,
sizeof(buffer), fmt, args);
374 MsgfX(
"Config mistake: ", buffer);
385 va_start (args, fmt);
389 vsnprintf(buffer,
sizeof(buffer), fmt, args);
393 MsgfX(
"Config warning: ", buffer);
400 void XrdOucGatherConf::MsgfX(
const char* txt1,
const char* txt2)
406 throw std::invalid_argument(
"XrdSysError object not supplied!");
439 if (!data || *data == 0)
return false;
442 gcP->
gBuff = strdup(data);
void trim(std::string &str)
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)