36 #include "XrdSys/XrdWin32.hh"
46 int *val,
int minv,
int maxv)
51 {Eroute.
Emsg(
"a2x",
emsg,
"value not specified");
return -1;}
54 *val = strtol(item, &eP, 10);
56 {Eroute.
Emsg(
"a2x",
emsg, item,
"is not a number");
60 return Emsg(Eroute,
emsg, item,
"may not be less than %d", minv);
61 if (maxv >= 0 && *val > maxv)
62 return Emsg(Eroute,
emsg, item,
"may not be greater than %d", maxv);
71 long long *val,
long long minv,
long long maxv)
76 {Eroute.
Emsg(
"a2x",
emsg,
"value not specified");
return -1;}
79 *val = strtoll(item, &eP, 10);
81 {Eroute.
Emsg(
"a2x",
emsg, item,
"is not a number");
85 return Emsg(Eroute,
emsg, item,
"may not be less than %lld", minv);
86 if (maxv >= 0 && *val > maxv)
87 return Emsg(Eroute,
emsg, item,
"may not be greater than %lld", maxv);
96 int *val,
int minv,
int maxv)
98 if ((rc =
a2fm(Eroute,
emsg, item, &num, minv)))
return rc;
99 if ((*val | maxv) != maxv)
100 {Eroute.
Emsg(
"a2fm",
emsg, item,
"is too inclusive.");
105 if (num & 0100) *val |= S_IXUSR;
106 if (num & 0200) *val |= S_IWUSR;
107 if (num & 0400) *val |= S_IRUSR;
108 if (num & 0010) *val |= S_IXGRP;
109 if (num & 0020) *val |= S_IWGRP;
110 if (num & 0040) *val |= S_IRGRP;
111 if (num & 0001) *val |= S_IXOTH;
112 if (num & 0002) *val |= S_IWOTH;
113 if (num & 0004) *val |= S_IROTH;
121 {Eroute.
Emsg(
"a2x",
emsg,
"value not specified");
return -1;}
124 *val = strtol(item, (
char **)NULL, 8);
126 {Eroute.
Emsg(
"a2x",
emsg, item,
"is not an octal number");
130 {Eroute.
Emsg(
"a2x",
emsg, item,
"is too exclusive");;
145 if (!strcmp(
"any", val))
146 {
if (anyOK)
return 0;
147 eDest.
Emsg(
"Config",
"port 'any' is not allowed");
151 const char *invp = (*ptype ==
't' ?
"tcp port" :
"udp port" );
152 const char *invs = (*ptype ==
't' ?
"Unable to find tcp service" :
153 "Unable to find udp service" );
169 int *val,
int nScale,
int minv,
int maxv)
175 {Eroute.
Emsg(
"a2x",
emsg,
"value not specified");
return -1;}
178 *val = strtol(item, &eP, 10);
179 if (errno || (*eP && *eP !=
'.'))
180 {Eroute.
Emsg(
"a2x",
emsg, item,
"is not a number");
186 while(*eP >=
'0' && *eP <=
'9')
188 {*val = (*val * 10) + (*eP -
int(
'0'));
194 {Eroute.
Emsg(
"a2x",
emsg, item,
"is not a number");
201 return Emsg(Eroute,
emsg, item,
"may not be less than %f",
202 double(minv)/
double(nScale));
203 if (maxv >= 0 && *val > maxv)
204 return Emsg(Eroute,
emsg, item,
"may not be greater than %d",
205 double(maxv)/
double(nScale));
214 long long *val,
long long minv,
long long maxv)
220 {Eroute.
Emsg(
"a2x",
emsg,
"value not specified");
return -1;}
223 if (item[i-1] !=
'%')
return a2sz(Eroute,
emsg, item, val, minv, maxv);
226 *val = strtoll(item, &pp, 10);
228 if (errno || *pp !=
'%')
229 {Eroute.
Emsg(
"a2x",
emsg, item,
"is not a number");
233 if (maxv < 0) maxv = 100;
236 {sprintf(buff,
"may not be greater than %lld%%", maxv);
237 Eroute.
Emsg(
"a2x",
emsg, item, buff);
241 if (minv < 0) minv = 0;
244 {sprintf(buff,
"may not be less than %lld%%", minv);
245 Eroute.
Emsg(
"a2x",
emsg, item, buff);
258 long long *val,
long long minv,
long long maxv)
259 {
if (!item || !*item)
260 {Eroute.
Emsg(
"a2x",
emsg,
"value not specified");
return -1;}
263 char *eP, *fP = (
char *)item + strlen(item) - 1;
265 if (*fP ==
'k' || *fP ==
'K') qmult = 1024LL;
266 else if (*fP ==
'm' || *fP ==
'M') qmult = 1024LL*1024LL;
267 else if (*fP ==
'g' || *fP ==
'G') qmult = 1024LL*1024LL*1024LL;
268 else if (*fP ==
't' || *fP ==
'T') qmult = 1024LL*1024LL*1024LL*1024LL;
269 else {qmult = 1; fP++;}
271 double dval = strtod(item, &eP) * qmult;
272 if (errno || eP != fP)
273 {Eroute.
Emsg(
"a2x",
emsg, item,
"is not a number");
276 *val = (
long long)dval;
278 return Emsg(Eroute,
emsg, item,
"may not be less than %lld", minv);
279 if (maxv >= 0 && *val > maxv)
280 return Emsg(Eroute,
emsg, item,
"may not be greater than %lld", maxv);
290 {
if (!item || !*item)
291 {Eroute.
Emsg(
"a2x",
emsg,
"value not specified");
return -1;}
294 char *eP, *fP = (
char *)item + strlen(item) - 1;
296 if (*fP ==
's' || *fP ==
'S') qmult = 1;
297 else if (*fP ==
'm' || *fP ==
'M') qmult = 60;
298 else if (*fP ==
'h' || *fP ==
'H') qmult = 60*60;
299 else if (*fP ==
'd' || *fP ==
'D') qmult = 60*60*24;
300 else {qmult = 1; fP++;}
303 *val = strtoll(item, &eP, 10) * qmult;
304 if (errno || eP != fP)
305 {Eroute.
Emsg(
"a2x",
emsg, item,
"is not a number");
309 return Emsg(Eroute,
emsg, item,
"may not be less than %d", minv);
310 if (maxv >= 0 && *val > maxv)
311 return Emsg(Eroute,
emsg, item,
"may not be greater than %d", maxv);
320 int *val,
int minv,
int maxv)
325 {Eroute.
Emsg(
"a2x",
emsg,
"value not specified");
return -1;}
328 *val = strtol(item, &pp, 10);
330 if (!errno && *pp ==
'%')
332 {Eroute.
Emsg(
"a2x",
emsg, item,
"may not be negative.");
336 {Eroute.
Emsg(
"a2x",
emsg, item,
"may not be greater than 100%.");
339 else {*val = -*val;
return 0;}
343 return Emsg(Eroute,
emsg, item,
"may not be less than %d", minv);
344 if (maxv >= 0 && *val > maxv)
345 return Emsg(Eroute,
emsg, item,
"may not be greater than %d", maxv);
355 static const char *hv =
"0123456789abcdef";
359 if (dlen < slen*2+1)
return 0;
363 for (
int i = 0; i < slen; i++)
364 {*dst++ = hv[(src[i] >> 4) & 0x0f];
365 *dst++ = hv[ src[i] & 0x0f];
381 int n, len = (slen+1)/2;
386 if (len > dlen)
return 0;
390 if (radj && slen & 0x01) {*dst = 0; odd =
true;}
395 {
if (*src >=
'0' && *src <=
'9') n = *src-48;
396 else if (*src >=
'a' && *src <=
'f') n = *src-87;
397 else if (*src >=
'A' && *src <=
'F') n = *src-55;
399 if (odd) *dst++ |= n;
410 int XrdOuca2x::Emsg(
XrdSysError &Eroute,
const char *etxt1,
const char *item,
411 const char *etxt2,
double val)
413 sprintf(buff, etxt2, val);
414 Eroute.
Emsg(
"a2x", etxt1, item, buff);
418 int XrdOuca2x::Emsg(
XrdSysError &Eroute,
const char *etxt1,
const char *item,
419 const char *etxt2,
int val)
421 sprintf(buff, etxt2, val);
422 Eroute.
Emsg(
"a2x", etxt1, item, buff);
426 int XrdOuca2x::Emsg(
XrdSysError &Eroute,
const char *etxt1,
const char *item,
427 const char *etxt2,
long long val)
429 sprintf(buff, etxt2, val);
430 Eroute.
Emsg(
"a2x", etxt1, item, buff);
static XrdSysError eDest(0,"crypto_")
int emsg(int rc, char *msg)
static int ServPort(const char *sName, bool isUDP=false, const char **eText=0)
static int x2b(const char *src, int slen, unsigned char *dst, int dlen, bool radj=false)
static int a2fm(XrdSysError &, const char *emsg, const char *item, int *val, int minv)
static int a2sp(XrdSysError &, const char *emsg, const char *item, long long *val, long long minv=-1, long long maxv=-1)
static int a2i(XrdSysError &, const char *emsg, const char *item, int *val, int minv=-1, int maxv=-1)
static int b2x(const unsigned char *src, int slen, char *dst, int dlen)
static int a2sz(XrdSysError &, const char *emsg, const char *item, long long *val, long long minv=-1, long long maxv=-1)
static int a2ll(XrdSysError &, const char *emsg, const char *item, long long *val, long long minv=-1, long long maxv=-1)
static int a2tm(XrdSysError &, const char *emsg, const char *item, int *val, int minv=-1, int maxv=-1)
static int a2sn(XrdSysError &, const char *emsg, const char *item, int *val, int nScale, int minv=-1, int maxv=-1)
static int a2vp(XrdSysError &, const char *emsg, const char *item, int *val, int minv=-1, int maxv=-1)
static int a2p(XrdSysError &, const char *ptype, const char *val, bool anyOK=true)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)