XRootD
XrdOuca2x Class Reference

#include <XrdOuca2x.hh>

+ Collaboration diagram for XrdOuca2x:

Static Public Member Functions

static int a2fm (XrdSysError &, const char *emsg, const char *item, int *val, int minv)
 
static int a2fm (XrdSysError &, const char *emsg, const char *item, int *val, int minv, int maxv)
 
static int a2i (XrdSysError &, const char *emsg, const char *item, int *val, int minv=-1, int 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 a2p (XrdSysError &, const char *ptype, const char *val, bool anyOK=true)
 
static int a2sn (XrdSysError &, const char *emsg, const char *item, int *val, int nScale, int minv=-1, int maxv=-1)
 
static int a2sp (XrdSysError &, const char *emsg, const char *item, long long *val, long long minv=-1, long long maxv=-1)
 
static int a2sz (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 a2vp (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 x2b (const char *src, int slen, unsigned char *dst, int dlen, bool radj=false)
 

Detailed Description

Definition at line 37 of file XrdOuca2x.hh.

Member Function Documentation

◆ a2fm() [1/2]

int XrdOuca2x::a2fm ( XrdSysError Eroute,
const char *  emsg,
const char *  item,
int *  val,
int  minv 
)
static

Definition at line 117 of file XrdOuca2x.cc.

119 {
120  if (!item || !*item)
121  {Eroute.Emsg("a2x", emsg, "value not specified"); return -1;}
122 
123  errno = 0;
124  *val = strtol(item, (char **)NULL, 8);
125  if (errno)
126  {Eroute.Emsg("a2x", emsg, item, "is not an octal number");
127  return -1;
128  }
129  if (!(*val & minv))
130  {Eroute.Emsg("a2x", emsg, item, "is too exclusive");;
131  return -1;
132  }
133  return 0;
134 }
int emsg(int rc, char *msg)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition: XrdSysError.cc:95

References XrdSysError::Emsg(), and emsg().

Referenced by a2fm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ a2fm() [2/2]

int XrdOuca2x::a2fm ( XrdSysError Eroute,
const char *  emsg,
const char *  item,
int *  val,
int  minv,
int  maxv 
)
static

Definition at line 95 of file XrdOuca2x.cc.

97 { int rc, num;
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.");
101  return -1;
102  }
103 
104  *val = 0;
105  if (num & 0100) *val |= S_IXUSR; // execute permission: owner
106  if (num & 0200) *val |= S_IWUSR; // write permission: owner
107  if (num & 0400) *val |= S_IRUSR; // read permission: owner
108  if (num & 0010) *val |= S_IXGRP; // execute permission: group
109  if (num & 0020) *val |= S_IWGRP; // write permission: group
110  if (num & 0040) *val |= S_IRGRP; // read permission: group
111  if (num & 0001) *val |= S_IXOTH; // execute permission: other
112  if (num & 0002) *val |= S_IWOTH; // write permission: other
113  if (num & 0004) *val |= S_IROTH; // read permission: other
114  return 0;
115 }
static int a2fm(XrdSysError &, const char *emsg, const char *item, int *val, int minv)
Definition: XrdOuca2x.cc:117

References a2fm(), XrdSysError::Emsg(), and emsg().

+ Here is the call graph for this function:

◆ a2i()

int XrdOuca2x::a2i ( XrdSysError Eroute,
const char *  emsg,
const char *  item,
int *  val,
int  minv = -1,
int  maxv = -1 
)
static

Definition at line 45 of file XrdOuca2x.cc.

47 {
48  char *eP;
49 
50  if (!item || !*item)
51  {Eroute.Emsg("a2x", emsg, "value not specified"); return -1;}
52 
53  errno = 0;
54  *val = strtol(item, &eP, 10);
55  if (errno || *eP)
56  {Eroute.Emsg("a2x", emsg, item, "is not a number");
57  return -1;
58  }
59  if (*val < minv)
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);
63  return 0;
64 }

References XrdSysError::Emsg(), and emsg().

Referenced by a2p(), XrdOucLogging::configLog(), XrdFrmConfig::Configure(), XrdHttpReadRangeHandler::Configure(), XrdPfc::Cache::ExecuteCommandUrl(), XrdOucPsx::ParseCio(), XrdCmsUtils::ParseMan(), XrdOucPsx::ParseSet(), XrdOssSys::Stage_RT(), XrdOssSys::xalloc(), XrdOssSys::xfdlimit(), XrdOssSys::xmemf(), XrdOssSys::xprerd(), XrdOfsgetPrepare(), XrdOssSys::xusage(), and XrdOssSys::xxfr().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ a2ll()

int XrdOuca2x::a2ll ( XrdSysError Eroute,
const char *  emsg,
const char *  item,
long long *  val,
long long  minv = -1,
long long  maxv = -1 
)
static

Definition at line 70 of file XrdOuca2x.cc.

72 {
73  char *eP;
74 
75  if (!item || !*item)
76  {Eroute.Emsg("a2x", emsg, "value not specified"); return -1;}
77 
78  errno = 0;
79  *val = strtoll(item, &eP, 10);
80  if (errno || *eP)
81  {Eroute.Emsg("a2x", emsg, item, "is not a number");
82  return -1;
83  }
84  if (*val < minv)
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);
88  return 0;
89 }

References XrdSysError::Emsg(), and emsg().

Referenced by XrdPfc::Cache::Config(), and XrdPfcPurgeQuota::ConfigPurgePin().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ a2p()

int XrdOuca2x::a2p ( XrdSysError eDest,
const char *  ptype,
const char *  val,
bool  anyOK = true 
)
static

Definition at line 140 of file XrdOuca2x.cc.

142 {
143  int pnum;
144 
145  if (!strcmp("any", val))
146  {if (anyOK) return 0;
147  eDest.Emsg("Config", "port 'any' is not allowed");
148  return -1;
149  }
150 
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" );
154 
155  if (isdigit(*val))
156  {if (XrdOuca2x::a2i(eDest,invp,val,&pnum,1,65535)) return -1;}
157  else if (!(pnum = XrdNetUtils::ServPort(val, (*ptype != 't'))))
158  {eDest.Emsg("Config", invs, val);
159  return -1;
160  }
161  return pnum;
162 }
static XrdSysError eDest(0,"crypto_")
static int ServPort(const char *sName, bool isUDP=false, const char **eText=0)
Definition: XrdNetUtils.cc:839
static int a2i(XrdSysError &, const char *emsg, const char *item, int *val, int minv=-1, int maxv=-1)
Definition: XrdOuca2x.cc:45

References a2i(), eDest, XrdSysError::Emsg(), and XrdNetUtils::ServPort().

Referenced by XrdConfig::Configure(), and XrdNetPMarkCfg::Parse().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ a2sn()

int XrdOuca2x::a2sn ( XrdSysError Eroute,
const char *  emsg,
const char *  item,
int *  val,
int  nScale,
int  minv = -1,
int  maxv = -1 
)
static

Definition at line 168 of file XrdOuca2x.cc.

170 {
171  char *eP;
172  int nsVal = nScale;
173 
174  if (!item || !*item)
175  {Eroute.Emsg("a2x", emsg, "value not specified"); return -1;}
176 
177  errno = 0;
178  *val = strtol(item, &eP, 10);
179  if (errno || (*eP && *eP != '.'))
180  {Eroute.Emsg("a2x", emsg, item, "is not a number");
181  return -1;
182  }
183 
184  if (*eP == '.')
185  {eP++;
186  while(*eP >= '0' && *eP <= '9')
187  {if (nsVal > 1)
188  {*val = (*val * 10) + (*eP - int('0'));
189  nsVal /= 10;
190  }
191  eP++;
192  }
193  if (*eP)
194  {Eroute.Emsg("a2x", emsg, item, "is not a number");
195  return -1;
196  }
197  }
198  *val *= nsVal;
199 
200  if (*val < minv)
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));
206  return 0;
207 }

References XrdSysError::Emsg(), and emsg().

+ Here is the call graph for this function:

◆ a2sp()

int XrdOuca2x::a2sp ( XrdSysError Eroute,
const char *  emsg,
const char *  item,
long long *  val,
long long  minv = -1,
long long  maxv = -1 
)
static

Definition at line 213 of file XrdOuca2x.cc.

215 {
216  char *pp, buff[120];
217  int i;
218 
219  if (!item || !*item)
220  {Eroute.Emsg("a2x", emsg, "value not specified"); return -1;}
221 
222  i = strlen(item);
223  if (item[i-1] != '%') return a2sz(Eroute, emsg, item, val, minv, maxv);
224 
225  errno = 0;
226  *val = strtoll(item, &pp, 10);
227 
228  if (errno || *pp != '%')
229  {Eroute.Emsg("a2x", emsg, item, "is not a number");
230  return -1;
231  }
232 
233  if (maxv < 0) maxv = 100;
234 
235  if (*val > maxv)
236  {sprintf(buff, "may not be greater than %lld%%", maxv);
237  Eroute.Emsg("a2x", emsg, item, buff);
238  return -1;
239  }
240 
241  if (minv < 0) minv = 0;
242 
243  if (*val > maxv)
244  {sprintf(buff, "may not be less than %lld%%", minv);
245  Eroute.Emsg("a2x", emsg, item, buff);
246  return -1;
247  }
248 
249  *val = -*val;
250  return 0;
251 }
static int a2sz(XrdSysError &, const char *emsg, const char *item, long long *val, long long minv=-1, long long maxv=-1)
Definition: XrdOuca2x.cc:257

References a2sz(), XrdSysError::Emsg(), and emsg().

+ Here is the call graph for this function:

◆ a2sz()

int XrdOuca2x::a2sz ( XrdSysError Eroute,
const char *  emsg,
const char *  item,
long long *  val,
long long  minv = -1,
long long  maxv = -1 
)
static

Definition at line 257 of file XrdOuca2x.cc.

259 { if (!item || !*item)
260  {Eroute.Emsg("a2x", emsg, "value not specified"); return -1;}
261 
262  long long qmult;
263  char *eP, *fP = (char *)item + strlen(item) - 1;
264 
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++;}
270  errno = 0;
271  double dval = strtod(item, &eP) * qmult;
272  if (errno || eP != fP)
273  {Eroute.Emsg("a2x", emsg, item, "is not a number");
274  return -1;
275  }
276  *val = (long long)dval;
277  if (*val < minv)
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);
281  return 0;
282 }

References XrdSysError::Emsg(), and emsg().

Referenced by a2sp(), XrdOssSys::Alloc_Cache(), XrdPfc::Cache::Config(), XrdOucLogging::configLog(), XrdPfcPurgeQuota::ConfigPurgePin(), XrdPfc::Cache::ExecuteCommandUrl(), XrdOfsConfigCP::Parse(), XrdOucPsx::ParseCache(), XrdOssSpace::Quotas(), XrdOssCsi::tagOpenEnv(), XrdOssSys::xalloc(), XrdOssSys::xmaxsz(), XrdOssSys::xmemf(), XrdOssSys::xprerd(), XrdOfsgetPrepare(), and XrdOssSys::xxfr().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ a2tm()

int XrdOuca2x::a2tm ( XrdSysError Eroute,
const char *  emsg,
const char *  item,
int *  val,
int  minv = -1,
int  maxv = -1 
)
static

Definition at line 288 of file XrdOuca2x.cc.

290 { if (!item || !*item)
291  {Eroute.Emsg("a2x", emsg, "value not specified"); return -1;}
292 
293  int qmult;
294  char *eP, *fP = (char *)item + strlen(item) - 1;
295 
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++;}
301 
302  errno = 0;
303  *val = strtoll(item, &eP, 10) * qmult;
304  if (errno || eP != fP)
305  {Eroute.Emsg("a2x", emsg, item, "is not a number");
306  return -1;
307  }
308  if (*val < minv)
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);
312  return 0;
313 }

References XrdSysError::Emsg(), and emsg().

Referenced by XrdFrmConfig::Configure(), XrdNetPMarkCfg::Parse(), XrdOucPsx::ParseSet(), XrdOssSys::xcachescan(), and XrdOssSys::xxfr().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ a2vp()

int XrdOuca2x::a2vp ( XrdSysError Eroute,
const char *  emsg,
const char *  item,
int *  val,
int  minv = -1,
int  maxv = -1 
)
static

Definition at line 319 of file XrdOuca2x.cc.

321 {
322  char *pp;
323 
324  if (!item || !*item)
325  {Eroute.Emsg("a2x", emsg, "value not specified"); return -1;}
326 
327  errno = 0;
328  *val = strtol(item, &pp, 10);
329 
330  if (!errno && *pp == '%')
331  {if (*val < 0)
332  {Eroute.Emsg("a2x", emsg, item, "may not be negative.");
333  return -1;
334  }
335  if (*val > 100)
336  {Eroute.Emsg("a2x", emsg, item, "may not be greater than 100%.");
337  return -1;
338  }
339  else {*val = -*val; return 0;}
340  }
341 
342  if (*val < minv)
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);
346  return 0;
347 }

References XrdSysError::Emsg(), and emsg().

+ Here is the call graph for this function:

◆ b2x()

int XrdOuca2x::b2x ( const unsigned char *  src,
int  slen,
char *  dst,
int  dlen 
)
static

Definition at line 353 of file XrdOuca2x.cc.

354 {
355  static const char *hv = "0123456789abcdef";
356 
357 // Make sure destination buffer is large enough (2*slen+1)
358 //
359  if (dlen < slen*2+1) return 0;
360 
361 // Do conversion
362 //
363  for (int i = 0; i < slen; i++)
364  {*dst++ = hv[(src[i] >> 4) & 0x0f];
365  *dst++ = hv[ src[i] & 0x0f];
366  }
367 
368 // End with null byte and return the full length
369 //
370  *dst = '\0';
371  return slen*2+1;
372 }

◆ x2b()

int XrdOuca2x::x2b ( const char *  src,
int  slen,
unsigned char *  dst,
int  dlen,
bool  radj = false 
)
static

Definition at line 378 of file XrdOuca2x.cc.

380 {
381  int n, len = (slen+1)/2;
382  bool odd = false;
383 
384 // Make sure we have enough destination bytes
385 //
386  if (len > dlen) return 0;
387 
388 // If the length is odd then the first nibble is set to zero
389 //
390  if (radj && slen & 0x01) {*dst = 0; odd = true;}
391 
392 // Perform conversion
393 //
394  while(slen--)
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;
398  else return 0;
399  if (odd) *dst++ |= n;
400  else *dst = n << 4;
401  src++; odd = !odd;
402  }
403  return len;
404 }

The documentation for this class was generated from the following files: