XRootD
Loading...
Searching...
No Matches
XrdOucString Class Reference

#include <XrdOucString.hh>

+ Collaboration diagram for XrdOucString:

Public Member Functions

 XrdOucString (const char *s, int lmx=0)
 
 XrdOucString (const char c, int lmx=0)
 
 XrdOucString (const XrdOucString &s)
 
 XrdOucString (const XrdOucString &s, int j, int k=-1, int lmx=0)
 
 XrdOucString (int lmx=0)
 
virtual ~XrdOucString ()
 
void append (const char *s)
 
void append (const char c)
 
void append (const int i)
 
void append (const XrdOucString s)
 
void assign (const char *s, int j, int k=-1)
 
void assign (const XrdOucString s, int j, int k=-1)
 
long atoi (int from=0, int to=-1)
 
bool beginswith (char c)
 
bool beginswith (const char *s)
 
bool beginswith (XrdOucString s)
 
const char * c_str () const
 
int capacity () const
 
bool endswith (char c)
 
bool endswith (const char *s)
 
bool endswith (XrdOucString s)
 
int erase (const char *s, int from=0, int to=-1)
 
int erase (int start=0, int size=0)
 
int erase (XrdOucString s, int from=0, int to=-1)
 
int erasefromend (int sz=0)
 
int erasefromstart (int sz=0)
 
int find (const char *s, int start=0)
 
int find (const char c, int start=0, bool forward=1)
 
int find (XrdOucString s, int start=0)
 
int form (const char *fmt,...)
 
void hardreset ()
 
void insert (const char *s, int start=-1, int lmx=0)
 
void insert (const char c, int start=-1)
 
void insert (const int i, int start=-1)
 
void insert (const XrdOucString s, int start=-1)
 
bool isdigit (int from=0, int to=-1)
 
int keep (int start=0, int size=0)
 
int length () const
 
void lower (int pos, int size=0)
 
int matches (const char *s, char wch=' *')
 
int operator!= (const char *s)
 
int operator!= (const char c)
 
int operator!= (const int i)
 
int operator!= (const XrdOucString s)
 
XrdOucStringoperator+= (const char *s)
 
XrdOucStringoperator+= (const char c)
 
XrdOucStringoperator+= (const int i)
 
XrdOucStringoperator+= (const XrdOucString s)
 
XrdOucStringoperator= (const char *s)
 
XrdOucStringoperator= (const char c)
 
XrdOucStringoperator= (const int i)
 
XrdOucStringoperator= (const XrdOucString s)
 
int operator== (const char *s)
 
int operator== (const char c)
 
int operator== (const int i)
 
int operator== (const XrdOucString s)
 
char & operator[] (int j)
 
int replace (const char *s1, const char *s2, int from=0, int to=-1)
 
int replace (const char *s1, const XrdOucString s2, int from=0, int to=-1)
 
int replace (const XrdOucString s1, const char *s2, int from=0, int to=-1)
 
int replace (const XrdOucString s1, const XrdOucString s2, int from=0, int to=-1)
 
void reset (const char c, int j=0, int k=-1)
 
void resize (int lmx=0)
 
int rfind (const char *s, int start=STR_NPOS)
 
int rfind (const char c, int start=STR_NPOS)
 
int rfind (XrdOucString s, int start=STR_NPOS)
 
void setbuffer (char *buf)
 
int tokenize (XrdOucString &tok, int from, char del=':')
 
void upper (int pos, int size=0)
 

Static Public Member Functions

static int form (XrdOucString &str, const char *fmt,...)
 
static int getblksize ()
 
static void setblksize (const int bs)
 

Friends

XrdOucString operator+ (const XrdOucString &s1, const char *s)
 
XrdOucString operator+ (const XrdOucString &s1, const char c)
 
XrdOucString operator+ (const XrdOucString &s1, const int i)
 
XrdOucString operator+ (const XrdOucString &s1, const XrdOucString &s)
 

Detailed Description

Definition at line 252 of file XrdOucString.hh.

Constructor & Destructor Documentation

◆ XrdOucString() [1/5]

XrdOucString::XrdOucString ( int lmx = 0)
inline

Definition at line 270 of file XrdOucString.hh.

270{ init(); if (lmx > 0) str = bufalloc(lmx+1); }

◆ XrdOucString() [2/5]

XrdOucString::XrdOucString ( const char * s,
int lmx = 0 )

Definition at line 153 of file XrdOucString.cc.

154{
155 // Constructor
156 // Create space to store the null terminated string s.
157 // If ls > 0 create space for ls+1 bytes, store the first
158 // ls bytes of s (truncating, if needed), and null-terminate.
159 // This is useful to import non null-terminated string buffers
160 // of known length.
161
162 init();
163
164 // If required, allocate the buffer to the requested size
165 if (ls > 0)
166 str = bufalloc(ls+1);
167 int lr = s ? strlen(s) : 0;
168 if (lr >= 0)
169 assign(s,0,ls-1);
170}
void assign(const char *s, int j, int k=-1)

References assign().

+ Here is the call graph for this function:

◆ XrdOucString() [3/5]

XrdOucString::XrdOucString ( const char c,
int lmx = 0 )

Definition at line 132 of file XrdOucString.cc.

133{
134 // Constructor
135 // Create space to store char c as a null-terminated string.
136 // If ls > 0 create space for ls+1 bytes.
137
138 init();
139
140 // If required, allocate the buffer to the requested size
141 if (ls > 0)
142 str = bufalloc(ls+1);
143 else
144 str = bufalloc(2);
145 if (str) {
146 str[0] = c;
147 str[1] = 0;
148 len = 1;
149 }
150}

◆ XrdOucString() [4/5]

XrdOucString::XrdOucString ( const XrdOucString & s)

Definition at line 173 of file XrdOucString.cc.

174{
175 // Copy constructor
176
177 init();
178 assign(s.c_str(),0,-1);
179}
const char * c_str() const

References assign(), and c_str().

+ Here is the call graph for this function:

◆ XrdOucString() [5/5]

XrdOucString::XrdOucString ( const XrdOucString & s,
int j,
int k = -1,
int lmx = 0 )

Definition at line 182 of file XrdOucString.cc.

183{
184 // Copy constructor (portion of string s: from j to k, inclusive)
185
186 init();
187 // If required, allocate the buffer to the requested size
188 if (ls > 0)
189 str = bufalloc(ls+1);
190
191 int lr = s.length();
192 if (lr > 0) {
193 // Adjust range (to fit in the allocated buffer, if any)
194 if (adjust(lr, j, k, ls) > 0)
195 // assign the string portion
196 assign(s.c_str(),j,k);
197 }
198}
int length() const

References assign(), c_str(), and length().

+ Here is the call graph for this function:

◆ ~XrdOucString()

XrdOucString::~XrdOucString ( )
virtual

Definition at line 201 of file XrdOucString.cc.

202{
203 // Destructor
204
205 if (str) free(str);
206}

Member Function Documentation

◆ append() [1/4]

void XrdOucString::append ( const char * s)

Definition at line 598 of file XrdOucString.cc.

599{
600 // Append string pointed by s to local string.
601 // Memory is reallocated.
602
603 return insert(s);
604}
void insert(const int i, int start=-1)

References insert().

+ Here is the call graph for this function:

◆ append() [2/4]

void XrdOucString::append ( const char c)

Definition at line 616 of file XrdOucString.cc.

617{
618 // Append char c to local string.
619 // Memory is reallocated.
620
621 return insert(c);
622}

References insert().

+ Here is the call graph for this function:

◆ append() [3/4]

void XrdOucString::append ( const int i)

Definition at line 625 of file XrdOucString.cc.

626{
627 // Append string representing integer i to local string.
628
629 return insert(i);
630}

References insert().

Referenced by XrdOucStream::Capture(), XrdXrootdProtocol::Configure(), operator+=(), operator+=(), operator+=(), operator+=(), XrdOfsConfigCP::Parse(), XrdHttpReq::ProcessHTTPReq(), and XrdSutMkdir().

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

◆ append() [4/4]

void XrdOucString::append ( const XrdOucString s)

Definition at line 607 of file XrdOucString.cc.

608{
609 // Append string s to local string.
610 // Memory is reallocated.
611
612 return insert(s);
613}

References insert().

+ Here is the call graph for this function:

◆ assign() [1/2]

void XrdOucString::assign ( const char * s,
int j,
int k = -1 )

Definition at line 511 of file XrdOucString.cc.

512{
513 // Assign portion of buffer s to local string.
514 // For k == -1 assign all string starting from position j (inclusive).
515 // Use j == 0 and k == -1 to assign the full string.
516
517 int ls = s ? strlen(s) : 0;
518 if (!s) {
519 // We are passed an empty string
520 if (str) {
521 // empty the local string, leaving capacity as it is
522 str[0] = 0;
523 len = 0;
524 }
525 } else {
526 // Adjust range and get length of portion to copy
527 int nlen = adjust(ls, j, k);
528 // Resize, if needed
529 if (nlen > (siz-1))
530 str = bufalloc(nlen+1);
531 if (str) {
532 if (nlen > 0) {
533 strncpy(str,s+j,nlen);
534 str[nlen] = 0;
535 len = nlen;
536 } else {
537 // empty the local string, leaving capacity as it is
538 str[0] = 0;
539 len = 0;
540 }
541 }
542 }
543}

Referenced by XrdOucString(), XrdOucString(), XrdOucString(), assign(), ExpPuk(), operator=(), operator=(), operator=(), operator=(), SavePasswd(), XrdSutPFile::SearchEntries(), tokenize(), XrdVomsFun::VOMSInit(), XrdSutExpand(), and XrdSutParseTime().

+ Here is the caller graph for this function:

◆ assign() [2/2]

void XrdOucString::assign ( const XrdOucString s,
int j,
int k = -1 )

Definition at line 546 of file XrdOucString.cc.

547{
548 // Assign portion of buffer s to local string.
549
550 assign(s.c_str(),j,k);
551}

References assign(), and c_str().

+ Here is the call graph for this function:

◆ atoi()

long XrdOucString::atoi ( int from = 0,
int to = -1 )

Definition at line 1295 of file XrdOucString.cc.

1296{
1297 // Return the long integer corresponding to the number between from and to
1298 // (included), assuming they are digits (check with 'isdigit()').
1299 // Return LONG_MAX in case they are not digits
1300
1301 if (!isdigit(from, to)) return LONG_MAX;
1302
1303 // Adjust range
1304 if (from < 0 || from > (len-1)) from = 0;
1305 if (to < from) to = len - 1;
1306
1307 // Save end char
1308 char e = str[to+1];
1309 str[to+1] = '\0';
1310 long out = strtol(&str[from], 0, 10);
1311 str[to+1] = e;
1312 return out;
1313}
bool isdigit(int from=0, int to=-1)

References isdigit().

Referenced by XrdOucGMap::XrdOucGMap(), and XrdVomsFun::VOMSInit().

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

◆ beginswith() [1/3]

bool XrdOucString::beginswith ( char c)
inline

Definition at line 289 of file XrdOucString.hh.

289{ return (find(c) == 0); }
int find(const char c, int start=0, bool forward=1)

References find().

Referenced by XrdCryptosslX509Crl::XrdCryptosslX509Crl(), XrdOucGMap::XrdOucGMap(), XrdSecProtocolpwd::Authenticate(), FindMatchingCondition(), FindMatchingCondition(), and XrdHttpReq::ProcessHTTPReq().

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

◆ beginswith() [2/3]

bool XrdOucString::beginswith ( const char * s)
inline

Definition at line 290 of file XrdOucString.hh.

290{ return (find(s) == 0); }

References find().

+ Here is the call graph for this function:

◆ beginswith() [3/3]

bool XrdOucString::beginswith ( XrdOucString s)
inline

Definition at line 291 of file XrdOucString.hh.

291{ return (find(s) == 0); }

References find().

+ Here is the call graph for this function:

◆ c_str()

const char * XrdOucString::c_str ( ) const
inline

Definition at line 278 of file XrdOucString.hh.

278{ return (const char *)str; }

Referenced by XrdCryptosslX509Crl::XrdCryptosslX509Crl(), XrdHttpExtReq::XrdHttpExtReq(), XrdOucGatherConf::XrdOucGatherConf(), XrdOucGMap::XrdOucGMap(), XrdOucString(), XrdOucString(), XrdSecProtocolgsi::XrdSecProtocolgsi(), XrdSecProtocolpwd::XrdSecProtocolpwd(), XrdSutBucket::XrdSutBucket(), XrdXrootdPgwFob::~XrdXrootdPgwFob(), AddPassword(), AddPassword(), AskConfirm(), assign(), XrdSecProtocolgsi::Authenticate(), XrdSecProtocolpwd::Authenticate(), XrdNetPMarkCfg::Begin(), XrdCryptoX509Chain::CAhash(), XrdCryptoX509Chain::CAname(), cfOut(), XrdConfig::Configure(), XrdXrootdProtocol::Configure(), XrdOucGMap::dn2user(), XrdHttpProtocol::doChksum(), XrdSutBuffer::Dump(), XrdOucGatherConf::EchoLine(), XrdCryptoX509Chain::EEChash(), XrdCryptoX509Chain::EECname(), endswith(), erase(), ExpPuk(), find(), FindMatchingCondition(), FindMatchingCondition(), XrdOucUtils::findPgm(), XrdSutPFCache::Flush(), XrdOucGatherConf::Gather(), XrdSecProtocolgsi::getCredentials(), XrdSecProtocolpwd::getCredentials(), GetEntry(), XrdSutBuffer::GetOptions(), XrdSutBuffer::GetProtocol(), XrdSecProtocolgsi::Init(), XrdSecProtocolpwd::Init(), insert(), XrdCryptosslX509::Issuer(), XrdCryptosslX509Crl::Issuer(), XrdCryptosslX509::IssuerHash(), XrdCryptosslX509Crl::IssuerHash(), XrdCryptoX509Chain::LastError(), XrdSutPFile::LastErrStr(), XrdOucGatherConf::LastLine(), LocateFactoryIndex(), main(), XrdCryptoX509::MatchHostnames(), XrdSutPFile::Open(), operator<<(), operator=(), operator==(), XrdCryptosslX509::ParentFile(), XrdCryptosslX509Crl::ParentFile(), XrdOfsConfigCP::Parse(), ParseArguments(), XrdHttpProtocol::Process(), XrdHttpReq::ProcessHTTPReq(), ReadPasswd(), ReadPuk(), ReadPuk(), XrdHttpReq::Redir(), XrdSutPFCache::Refresh(), replace(), replace(), replace(), rfind(), SavePasswd(), SavePuk(), XrdSutBuffer::Serialized(), XrdCryptosslX509::Subject(), XrdCryptosslX509Req::Subject(), XrdCryptosslX509::SubjectHash(), XrdCryptosslX509Req::SubjectHash(), XrdSutBucket::Update(), XrdSutBuffer::UpdateBucket(), XrdCryptoX509Chain::Verify(), XrdVomsFun::VOMSFun(), XrdVomsFun::VOMSInit(), XrdAccAuthorizeObject(), XrdOfsgetPrepare(), XrdSecgsiGMAPFun(), XrdSecgsiGMAPInit(), XrdSecProtocolgsiInit(), XrdSecProtocolpwdInit(), XrdSecProtocolztnInit(), XrdSutAskConfirm(), XrdSutExpand(), XrdSutHome(), XrdSutMkdir(), XrdSutParseTime(), XrdOssSys::xspace(), and XrdOssSys::xspaceBuild().

◆ capacity()

int XrdOucString::capacity ( ) const
inline

Definition at line 280 of file XrdOucString.hh.

280{ return siz; }

Referenced by XrdOucGatherConf::LastLine().

+ Here is the caller graph for this function:

◆ endswith() [1/3]

bool XrdOucString::endswith ( char c)

Definition at line 406 of file XrdOucString.cc.

407{
408 // returns 1 if the stored string ends with string s
409
410 return ((len > 0) ? (rfind(c) == (int)(len-1)) : 0);
411}
int rfind(const char c, int start=STR_NPOS)

References rfind().

Referenced by XrdOucGatherConf::XrdOucGatherConf(), FindMatchingCondition(), FindMatchingCondition(), XrdSecProtocolgsi::Init(), XrdSecProtocolpwd::Init(), main(), XrdXrootdProtocol::Process2(), XrdHttpReq::ProcessHTTPReq(), and XrdOssSys::xspace().

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

◆ endswith() [2/3]

bool XrdOucString::endswith ( const char * s)

Definition at line 414 of file XrdOucString.cc.

415{
416 // returns 1 if the stored string ends with string s
417
418 int ls = -1;
419 if (s && (ls = (int)strlen(s)) <= len)
420 return ((rfind(s) == (int)(len-strlen(s))) ? 1 : 0);
421
422 return 0;
423}

References rfind().

+ Here is the call graph for this function:

◆ endswith() [3/3]

bool XrdOucString::endswith ( XrdOucString s)
inline

Definition at line 294 of file XrdOucString.hh.

294{ return (endswith(s.c_str())); }
bool endswith(char c)

References c_str(), and endswith().

Referenced by endswith().

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

◆ erase() [1/3]

int XrdOucString::erase ( const char * s,
int from = 0,
int to = -1 )

Definition at line 866 of file XrdOucString.cc.

867{
868 // Remove any occurence of string s within from and to inclusive.
869 // Use from == 0 and to == -1 to remove all occurences (default).
870 // Return number of bytes removed ( <=size )
871
872 return -replace(s,0,from,to);
873}
int replace(const char *s1, const char *s2, int from=0, int to=-1)

References replace().

+ Here is the call graph for this function:

◆ erase() [2/3]

int XrdOucString::erase ( int start = 0,
int size = 0 )

Definition at line 827 of file XrdOucString.cc.

828{
829 // Remove size bytes starting from position start.
830 // If size == 0, remove any bytes from start on.
831 // Return number of bytes removed ( <=size )
832
833 int rc = 0;
834
835 // Make sure start makes sense
836 int st = start;
837 if (st < 0 || st > (len-1))
838 return rc;
839
840 // Make sure size makes sense
841 if (size < 0)
842 return rc;
843 int nrem = 0;
844 if (size == 0) {
845 nrem = len - st;
846 } else {
847 nrem = (size > (len-st)) ? (len-st) : size;
848 }
849 // Do nothing if no byte removal has been requested
850 if (nrem <= 0)
851 return rc;
852 // Calculate new length and allocated new string
853 int nlen = len - nrem;
854 // Copy the remaining bytes, if any
855 if (len-st-nrem)
856 memmove(str+st,str+st+nrem,len-st-nrem);
857 // Null terminate
858 str[nlen] = 0;
859 // Assign new length
860 len = nlen;
861 // Return number of bytes removed
862 return nrem;
863}

Referenced by XrdSecProtocolgsi::Authenticate(), erasefromend(), erasefromstart(), XrdSecProtocolgsi::Init(), XrdSecProtocolpwd::Init(), LocateFactoryIndex(), main(), ParseArguments(), XrdSutExpand(), and XrdSutParseTime().

+ Here is the caller graph for this function:

◆ erase() [3/3]

int XrdOucString::erase ( XrdOucString s,
int from = 0,
int to = -1 )

Definition at line 876 of file XrdOucString.cc.

877{
878 // Remove any occurence of string s within from and to inclusive.
879 // Use from == 0 and to == -1 to remove all occurences (default).
880 // Return number of bytes removed ( <=size )
881
882 return -replace(s.c_str(),0,from,to);
883}

References c_str(), and replace().

+ Here is the call graph for this function:

◆ erasefromend()

int XrdOucString::erasefromend ( int sz = 0)
inline

Definition at line 329 of file XrdOucString.hh.

329{ return erase(len-sz,sz); }
int erase(int start=0, int size=0)

References erase().

Referenced by XrdHttpReq::ProcessHTTPReq(), and XrdOssSys::xspaceBuild().

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

◆ erasefromstart()

int XrdOucString::erasefromstart ( int sz = 0)
inline

Definition at line 328 of file XrdOucString.hh.

328{ return erase(0,sz); }

References erase().

Referenced by XrdOucGMap::XrdOucGMap(), XrdCryptoX509::MatchHostnames(), and XrdAccAuthorizeObject().

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

◆ find() [1/3]

int XrdOucString::find ( const char * s,
int start = 0 )

Definition at line 306 of file XrdOucString.cc.

307{
308 // Find index of first occurence of null-terminated string s, starting
309 // from position start.
310 // Return index if found, STR_NPOS if not.
311
312 int rc = STR_NPOS;
313
314 // Make sure start makes sense
315 if (start < 0 || start > (len-1))
316 return rc;
317
318 // Make sure the string is defined
319 if (!s)
320 return rc;
321
322 // length of substring
323 int ls = strlen(s);
324
325 // if only one meaningful char, use dedicated method
326 if (ls == 1)
327 return find(s[0],start);
328
329 // Make sure that it can fit
330 if (ls > (len-start))
331 return rc;
332
333 // Now loop
334 int i = start;
335 for (; i < len; i++) {
336 if (str[i] == s[0])
337 if (!strncmp(str+i+1,s+1,ls-1))
338 return i;
339 }
340
341 // Nothing found
342 return rc;
343}
#define STR_NPOS

References find(), and STR_NPOS.

+ Here is the call graph for this function:

◆ find() [2/3]

int XrdOucString::find ( const char c,
int start = 0,
bool forward = 1 )

Definition at line 260 of file XrdOucString.cc.

261{
262 // Find index of first occurence of char c starting from position start
263 // Return index if found, STR_NPOS if not.
264
265 int rc = STR_NPOS;
266
267 // STR_NPOS indicates start from the end
268 if (start == STR_NPOS)
269 start = len - 1;
270
271 // Make sure start makes sense
272 if (start < 0 || start > (len-1))
273 return rc;
274
275 // Now loop
276 int i = start;
277 if (forward) {
278 // forward search
279 for (; i < len; i++) {
280 if (str[i] == c)
281 return i;
282 }
283 } else {
284 // backward search
285 for (; i >= 0; i--) {
286 if (str[i] == c)
287 return i;
288 }
289 }
290
291 // Nothing found
292 return rc;
293}

References STR_NPOS.

Referenced by AddPassword(), AddPassword(), XrdSecProtocolgsi::Authenticate(), beginswith(), beginswith(), beginswith(), find(), find(), FindMatchingCondition(), FindMatchingCondition(), replace(), rfind(), rfind(), tokenize(), XrdVomsFun::VOMSInit(), XrdSutExpand(), XrdSutMkdir(), and XrdSutResolve().

+ Here is the caller graph for this function:

◆ find() [3/3]

int XrdOucString::find ( XrdOucString s,
int start = 0 )

Definition at line 296 of file XrdOucString.cc.

297{
298 // Find index of first occurence of string s, starting
299 // from position start.
300 // Return index if found, STR_NPOS if not.
301
302 return find((const char *)s.c_str(),start);
303}

References c_str(), and find().

+ Here is the call graph for this function:

◆ form() [1/2]

int XrdOucString::form ( const char * fmt,
... )

Definition at line 225 of file XrdOucString.cc.

226{
227 // Recreate the string according to 'fmt' and the arguments
228 // Return -1 in case of failure, or the new length.
229
230 // Decode the arguments
231 XOSINTFORM(fmt, str);
232 siz = buf_len;
233
234 // Re-adjust the length
235 len = strlen(str);
236 str = bufalloc(len+1);
237
238 // Return the new length (in n)
239 return n;
240}
#define XOSINTFORM(f, b)

References XOSINTFORM.

Referenced by XrdSecProtocolgsi::Authenticate(), and XrdSecProtocolgsi::getCredentials().

+ Here is the caller graph for this function:

◆ form() [2/2]

int XrdOucString::form ( XrdOucString & str,
const char * fmt,
... )
static

Definition at line 243 of file XrdOucString.cc.

244{
245 // Format a string in 'str' according to 'fmt' and the arguments
246
247 // Decode the arguments
248 char *buf = 0;
249 XOSINTFORM(fmt, buf);
250
251 // Adopt the new formatted buffer in the string
252 str.setbuffer(buf);
253
254 // Done
255 return n;
256}
void setbuffer(char *buf)

References setbuffer(), and XOSINTFORM.

+ Here is the call graph for this function:

◆ getblksize()

int XrdOucString::getblksize ( )
static

Definition at line 1204 of file XrdOucString.cc.

1205{
1206 // Getter for the block size
1207
1208 return XrdOucString::blksize;
1209}

◆ hardreset()

void XrdOucString::hardreset ( )

Definition at line 952 of file XrdOucString.cc.

953{
954 // Reset string making sure to erase completely the information.
955 if (str)
956 while (len > 0)
957 str[--len] = '\0';
958
959 len = 0;
960}

Referenced by AddPassword().

+ Here is the caller graph for this function:

◆ insert() [1/4]

void XrdOucString::insert ( const char * s,
int start = -1,
int lmx = 0 )

Definition at line 633 of file XrdOucString.cc.

634{
635 // Insert null-terminated string pointed by s in local string starting
636 // at position start (default append, i.e. start == len).
637 // Memory is reallocated.
638 // If ls > 0, insert only the first ls bytes of s
639
640 // Check start
641 int at = start;
642 at = (at < 0 || at > len) ? len : at;
643
644 if (s) {
645 int lstr = (ls > 0) ? ls : strlen(s);
646 if (str) {
647 int lnew = len + lstr;
648 if (lnew > (siz-1))
649 str = bufalloc(lnew+1);
650 if (str) {
651 // Move the rest of the existing string, if any
652 if (at < len)
653 memmove(str+at+lstr,str+at,(len-at));
654 // Add new string now
655 memcpy(str+at,s,lstr);
656 // Null termination
657 str[lnew] = 0;
658 len = lnew;
659 }
660 } else {
661 if ((str = bufalloc(lstr+1))) {
662 strncpy(str,s,lstr);
663 str[lstr] = 0;
664 len = lstr;
665 }
666 }
667 }
668}

◆ insert() [2/4]

void XrdOucString::insert ( const char c,
int start = -1 )

Definition at line 680 of file XrdOucString.cc.

681{
682 // Insert char c in local string starting at position start (default
683 // append, i.e. start == len).
684
685 char sc[2] = {0};
686 sc[0] = c;
687 return insert((const char *)&sc[0], start);
688}

References insert().

+ Here is the call graph for this function:

◆ insert() [3/4]

void XrdOucString::insert ( const int i,
int start = -1 )

Definition at line 691 of file XrdOucString.cc.

692{
693 // Insert string representing integer i in local string starting at
694 // position start (default
695
696 char si[kMAXINT64LEN] = {0};
697 sprintf(si,"%d",i);
698 return insert((const char *)&si[0], start);
699}
#define kMAXINT64LEN

References insert(), and kMAXINT64LEN.

Referenced by XrdSecProtocolgsi::XrdSecProtocolgsi(), XrdSecProtocolpwd::XrdSecProtocolpwd(), AddPassword(), AddPassword(), append(), append(), append(), append(), AskConfirm(), XrdNetPMarkCfg::Begin(), CheckOption(), XrdSecProtocolgsi::Init(), XrdSecProtocolpwd::Init(), insert(), insert(), insert(), main(), operator+(), operator+(), operator+(), ParseArguments(), XrdCryptosslNameOneLine(), XrdSutAskConfirm(), and XrdSutExpand().

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

◆ insert() [4/4]

void XrdOucString::insert ( const XrdOucString s,
int start = -1 )

Definition at line 671 of file XrdOucString.cc.

672{
673 // Insert string s in local string starting at position start (default
674 // append, i.e. start == len).
675
676 return insert(s.c_str(), start);
677}

References c_str(), and insert().

+ Here is the call graph for this function:

◆ isdigit()

bool XrdOucString::isdigit ( int from = 0,
int to = -1 )

Definition at line 1270 of file XrdOucString.cc.

1271{
1272 // Return true is all chars between from and to (included) are digits
1273
1274 // Make sure inputs make sense
1275 if (len <= 0) return 0;
1276
1277 // Adjust range
1278 if (from < 0 || from > (len-1)) from = 0;
1279 if (to < from) to = len - 1;
1280
1281 char *c = str + from;
1282
1283 // Skip initial '-'
1284 if (*c == '-') c++;
1285
1286 while (c <= str + to) {
1287 if (*c < 48 || *c > 57) return 0;
1288 c++;
1289 }
1290
1291 return 1;
1292}

Referenced by XrdOucGMap::XrdOucGMap(), atoi(), and XrdVomsFun::VOMSInit().

+ Here is the caller graph for this function:

◆ keep()

int XrdOucString::keep ( int start = 0,
int size = 0 )

Definition at line 554 of file XrdOucString.cc.

555{
556 // Keep size bytes starting from position start
557 // If size == 0, keep any bytes from start on.
558 // Return number of bytes kept ( <=size )
559
560 int rc = 0;
561
562 // Make sure start makes sense
563 int st = start;
564 if (st < 0 || st > (len-1))
565 return rc;
566
567 // Make sure size makes sense
568 if (size < 0)
569 return rc;
570 int nlen = 0;
571 if (size == 0) {
572 nlen = len - st;
573 } else {
574 nlen = (size > (len - st)) ? (len - st) : size;
575 }
576
577 // Do nothing if all the bytes requested
578 if (nlen >= len)
579 return len;
580
581 // Allocated new string
582 if (nlen > (siz-1))
583 str = bufalloc(nlen+1);
584 if (str) {
585 // Copy the bytes
586 memmove(str,str+st,nlen);
587 // Null terminate
588 str[nlen] = 0;
589 // Assign new string
590 len = nlen;
591 // Return number of bytes kept
592 return nlen;
593 } else
594 return rc;
595}

◆ length()

int XrdOucString::length ( ) const
inline

Definition at line 279 of file XrdOucString.hh.

279{ return len; }

Referenced by XrdOucGatherConf::XrdOucGatherConf(), XrdOucGMap::XrdOucGMap(), XrdOucString(), XrdSecProtocolgsi::XrdSecProtocolgsi(), XrdSecProtocolpwd::XrdSecProtocolpwd(), XrdSutBucket::XrdSutBucket(), AddPassword(), AddPassword(), AskConfirm(), XrdSecProtocolgsi::Authenticate(), XrdSecProtocolpwd::Authenticate(), XrdCryptoX509Chain::CAhash(), XrdCryptoX509Chain::CAname(), cfOut(), XrdNetPMarkCfg::Config(), Display(), XrdOucGMap::dn2user(), XrdHttpProtocol::doChksum(), XrdSutBuffer::Dump(), XrdOucGatherConf::EchoLine(), XrdCryptoX509Chain::EEChash(), XrdCryptoX509Chain::EECname(), ExpPuk(), XrdSutPFCache::Flush(), XrdOucGatherConf::Gather(), XrdSecProtocolgsi::getCredentials(), XrdSecProtocolpwd::getCredentials(), XrdSecProtocolgsi::Init(), XrdSecProtocolpwd::Init(), XrdCryptosslX509::Issuer(), XrdCryptosslX509Crl::Issuer(), XrdCryptosslX509::IssuerHash(), XrdCryptosslX509Crl::IssuerHash(), main(), XrdCryptoX509::MatchHostnames(), operator+(), operator+(), operator+(), operator+=(), operator==(), ParseArguments(), XrdHttpProtocol::Process(), XrdHttpReq::ProcessHTTPReq(), ReadPasswd(), ReadPuk(), ReadPuk(), XrdSutPFCache::Refresh(), XrdCryptoX509Chain::Reorder(), SavePasswd(), SavePuk(), XrdSutBuffer::Serialized(), XrdCryptosslX509::Subject(), XrdCryptosslX509Req::Subject(), XrdCryptosslX509::SubjectHash(), XrdCryptosslX509Req::SubjectHash(), tokenize(), XrdSutBucket::Update(), XrdSutBuffer::UpdateBucket(), XrdVomsFun::VOMSFun(), XrdVomsFun::VOMSInit(), XrdAccAuthorizeObject(), XrdOfsgetPrepare(), XrdSecgsiGMAPFun(), XrdSecgsiGMAPInit(), XrdSecProtocolgsiInit(), XrdSecProtocolpwdInit(), XrdSutAskConfirm(), XrdSutExpand(), XrdSutGetLine(), XrdSutHome(), XrdSutMkdir(), XrdSutParseTime(), and XrdSutResolve().

+ Here is the caller graph for this function:

◆ lower()

void XrdOucString::lower ( int pos,
int size = 0 )

Definition at line 886 of file XrdOucString.cc.

887{
888 // Set to lower case size chars starting from position start.
889 // If size == 0, lower all bytes from start on.
890
891 // Make sure start makes sense
892 int st = start;
893 if (st < 0 || st > (len-1))
894 return;
895
896 // Make sure size makes sense
897 if (size < 0)
898 return;
899 int nlw = 0;
900 if (size == 0) {
901 nlw = len - st;
902 } else {
903 nlw = (size > (len-st)) ? (len-st) : size;
904 }
905
906 // Do nothing if no byte removal has been requested
907 if (nlw <= 0)
908 return;
909
910 // Set to lower
911 int i = st;
912 for (; i < st + nlw ; i++ ) {
913 if (str[i] > 0x40 && str[i] < 0x5b)
914 str[i] += 0x20;
915 }
916}

Referenced by AskConfirm(), XrdCryptoX509::MatchHostnames(), and XrdSutAskConfirm().

+ Here is the caller graph for this function:

◆ matches()

int XrdOucString::matches ( const char * s,
char wch = '*' )

Definition at line 426 of file XrdOucString.cc.

427{
428 // Check if local string is compatible with 's' which may
429 // contain wild char wch (default: '*'). For example, if local string
430 // is 'mouse.at.home' the match will be true for 'mouse.*',
431 // and false for 'mouse.*.cinema' .
432 // If does not contain wild characters, this is just a comparison
433 // based on strncmp.
434 // Returns the number of characters matching or 0.
435
436 // Make sure s is defined and we have a local string
437 if (!s || !str)
438 return 0;
439
440 // string size
441 int ls = strlen(s);
442
443 // If no wild card, just make a simple strcmp comparison
444 if (!strchr(s,wch)) {
445 if (!strcmp(str,s))
446 return ls;
447 else
448 return 0;
449 }
450
451 // If s == wch the match is always true
452 if (ls == 1)
453 return 1;
454
455 int rc = 1;
456 // Starting position for the check
457 int cs = 0;
458
459 // token delimiters and size
460 int tb = 0; // begin
461 char *ps = (char *)strchr(s+tb,wch);
462 bool next = 1;
463 while (next) {
464
465 // token end
466 int te = ps ? (ps - s) : ls;
467 // token size
468 int ts = te - tb;
469
470 if (ts) {
471 bool found = 0;
472 while (cs < len) {
473 if (!strncmp(str+cs,s+tb,ts)) {
474 cs += ts;
475 found = 1;
476 break;
477 }
478 cs++;
479 }
480 if (!found) {
481 rc = 0;
482 break;
483 }
484 }
485 // next token begin, if any
486 tb = te + 1;
487 ps = (tb < ls) ? (char *)strchr(s+tb, wch) : 0;
488 next = (ps || (tb < ls)) ? 1 : 0;
489 }
490
491 // If s does not end with a wild card
492 // make sure that everything has been checked
493 if (s[ls-1] != wch && cs < len)
494 rc = 0;
495
496 // The number of chars matching is the number of chars in s
497 // which are not '*'
498 int nm = 0;
499 if (rc > 0) {
500 nm = ls;
501 int n = ls;
502 while (n--) {
503 if (s[n] == wch) nm--;
504 }
505 }
506
507 return nm;
508}
static std::string ts()
timestamp output for logging messages
Definition XrdCephOss.cc:53

References ts().

Referenced by FindMatchingCondition(), FindMatchingCondition(), XrdCryptoX509::MatchHostnames(), XrdSutPFile::ReadEntry(), and XrdSutPFile::SearchEntries().

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

◆ operator!=() [1/4]

int XrdOucString::operator!= ( const char * s)
inline

Definition at line 361 of file XrdOucString.hh.

361{ return !(*this == s); }

◆ operator!=() [2/4]

int XrdOucString::operator!= ( const char c)
inline

Definition at line 360 of file XrdOucString.hh.

360{ return !(*this == c); }

◆ operator!=() [3/4]

int XrdOucString::operator!= ( const int i)
inline

Definition at line 359 of file XrdOucString.hh.

359{ return !(*this == i); }

◆ operator!=() [4/4]

int XrdOucString::operator!= ( const XrdOucString s)
inline

Definition at line 362 of file XrdOucString.hh.

362{ return !(*this == s); }

◆ operator+=() [1/4]

XrdOucString & XrdOucString::operator+= ( const char * s)

Definition at line 1080 of file XrdOucString.cc.

1081{
1082 // Add string at s to local string.
1083
1084 if (s && strlen(s))
1085 this->append(s);
1086 return *this;
1087}
void append(const int i)

References append().

+ Here is the call graph for this function:

◆ operator+=() [2/4]

XrdOucString & XrdOucString::operator+= ( const char c)

Definition at line 1100 of file XrdOucString.cc.

1101{
1102 // Add char c to local string.
1103
1104 this->append(c);
1105 return *this;
1106}

References append().

+ Here is the call graph for this function:

◆ operator+=() [3/4]

XrdOucString & XrdOucString::operator+= ( const int i)

Definition at line 1109 of file XrdOucString.cc.

1110{
1111 // Add string representing integer i to local string.
1112
1113 this->append(i);
1114 return *this;
1115}

References append().

+ Here is the call graph for this function:

◆ operator+=() [4/4]

XrdOucString & XrdOucString::operator+= ( const XrdOucString s)

Definition at line 1090 of file XrdOucString.cc.

1091{
1092 // Add string s to local string.
1093
1094 if (s.length())
1095 this->append(s);
1096 return *this;
1097}

References append(), and length().

+ Here is the call graph for this function:

◆ operator=() [1/4]

XrdOucString & XrdOucString::operator= ( const char * s)

Definition at line 1002 of file XrdOucString.cc.

1003{
1004 // Assign buffer s to local string.
1005
1006 assign(s,0,-1);
1007
1008 return *this;
1009}

References assign().

+ Here is the call graph for this function:

◆ operator=() [2/4]

XrdOucString & XrdOucString::operator= ( const char c)

Definition at line 992 of file XrdOucString.cc.

993{
994 // Assign char c to local string.
995
996 const char s[] = {c,0};
997 assign(s,0,-1);
998 return *this;
999}

References assign().

+ Here is the call graph for this function:

◆ operator=() [3/4]

XrdOucString & XrdOucString::operator= ( const int i)

Definition at line 981 of file XrdOucString.cc.

982{
983 // Assign string representing integer i to local string
984
985 char s[kMAXINT64LEN] = {0};
986 sprintf(s,"%d",i);
987 assign((const char *)&s[0],0,-1);
988 return *this;
989}

References assign(), and kMAXINT64LEN.

+ Here is the call graph for this function:

◆ operator=() [4/4]

XrdOucString & XrdOucString::operator= ( const XrdOucString s)

Definition at line 1012 of file XrdOucString.cc.

1013{
1014 // Assign string s to local string.
1015 assign(s.c_str(), 0, -1);
1016
1017 return *this;
1018}

References assign(), and c_str().

+ Here is the call graph for this function:

◆ operator==() [1/4]

int XrdOucString::operator== ( const char * s)

Definition at line 1119 of file XrdOucString.cc.

1120{
1121 // Compare string at s to local string: return 1 if matches, 0 if not
1122
1123 if (s && (strlen(s) == (unsigned int)len))
1124 if (!strncmp(str,s,len))
1125 return 1;
1126 return 0;
1127}

◆ operator==() [2/4]

int XrdOucString::operator== ( const char c)

Definition at line 1141 of file XrdOucString.cc.

1142{
1143 // Compare char c to local string: return 1 if matches, 0 if not
1144
1145 if (len == 1) {
1146 if (str[0] == c)
1147 return 1;
1148 }
1149 return 0;
1150}

◆ operator==() [3/4]

int XrdOucString::operator== ( const int i)

Definition at line 1153 of file XrdOucString.cc.

1154{
1155 // Compare string representing integer i to local string:
1156 // return 1 if matches, 0 if not
1157
1158 char s[kMAXINT64LEN] = {0};
1159 sprintf(s,"%d",i);
1160 return (*this == ((const char *)&s[0]));
1161}

References kMAXINT64LEN.

◆ operator==() [4/4]

int XrdOucString::operator== ( const XrdOucString s)

Definition at line 1130 of file XrdOucString.cc.

1131{
1132 // Compare string s to local string: return 1 if matches, 0 if not
1133
1134 if (s.length() == len)
1135 if (!strncmp(str,s.c_str(),len))
1136 return 1;
1137 return 0;
1138}

References c_str(), and length().

+ Here is the call graph for this function:

◆ operator[]()

char & XrdOucString::operator[] ( int j)

Definition at line 1021 of file XrdOucString.cc.

1022{
1023 // Return charcater at location i.
1024 static char c = '\0';
1025
1026 if (str) {
1027 if (i > -1 && i < len)
1028 return str[i];
1029 else
1030 abort();
1031 }
1032 return c;
1033}

◆ replace() [1/4]

int XrdOucString::replace ( const char * s1,
const char * s2,
int from = 0,
int to = -1 )

Definition at line 733 of file XrdOucString.cc.

734{
735 // Replace any occurrence of s1 with s2 from position 'from' to position
736 // 'to' (inclusive).
737 // Return signed size of length modification (in bytes)
738
739 // We must have something to replace
740 if (!str || len <= 0 || !s1 || !s2)
741 return 0;
742
743 // The string to replace must be defined and not empty
744 int l1 = s1 ? strlen(s1) : 0;
745 if (l1 <= 0)
746 return 0;
747
748 // Check and adjust indeces
749 if (adjust(len,from,to) <= 0)
750 return 0;
751
752 // length of replacing string
753 int l2 = s2 ? strlen(s2) : 0;
754
755 // If new string is longer we need number of occurencies
756 int nr = 0;
757 if (l1 < l2) {
758 int at = find(s1,from);
759 while (at > -1 && at <= (to-l1+1)) {
760 nr++;
761 at = find(s1,at+l1);
762 }
763 }
764
765 // New size
766 int nlen = (nr > 0) ? (len + nr*(l2-l1)) : len ;
767
768 // Reallocate, if needed
769 if (nlen > (siz-1))
770 str = bufalloc(nlen+1);
771
772 // Now act
773 int dd = l2-l1;
774 int dl = 0;
775 if (str) {
776 if (dd < 0) {
777 int nc = 0;
778 int at = find(s1,from);
779 while (at > -1 && at <= (to-l1+1)) {
780 int atn = find(s1,at+l1);
781 atn = (atn == -1 || atn > (to-l1+1)) ? len : atn;
782 int ln = atn - at - l1;
783 char *pc = str+at+nc*dd;
784 if (l2 > 0)
785 memcpy(pc,s2,l2);
786 if (ln > 0)
787 memmove(pc+l2,str+at+l1,ln);
788 nc++;
789 at = atn;
790 }
791 dl = nc*dd;
792 } else if (dd == 0) {
793 int at = find(s1,from);
794 while (at > -1 && at <= (to-l1+1)) {
795 memcpy(str+at,s2,l2);
796 at = find(s1,at+l1);
797 }
798 } else if (dd > 0) {
799 int nc = nr;
800 int at = rfind(s1,to);
801 int atn = len;
802 while (at > -1 && at >= from) {
803 int ln = atn - at - l1;
804 char *pc = str + at + l1 + nc*dd;
805 if (ln > 0)
806 memmove(pc,str+at+l1,ln);
807 if (l2 > 0)
808 memcpy(pc-l2,s2,l2);
809 nc--;
810 atn = at;
811 if( at - l1 < 0 ) at = -1;
812 else at = rfind(s1,at-l1);
813 }
814 dl = nr*dd;
815 }
816 // Variation of string length
817 len += dl;
818 // Ensure null-termination
819 str[len] = '\0';
820 }
821
822 // We are done
823 return dl;
824}

References find(), and rfind().

Referenced by XrdCryptosslX509Crl::XrdCryptosslX509Crl(), erase(), erase(), replace(), replace(), replace(), XrdCryptosslNameOneLine(), XrdSutResolve(), and XrdOssSys::xspace().

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

◆ replace() [2/4]

int XrdOucString::replace ( const char * s1,
const XrdOucString s2,
int from = 0,
int to = -1 )

Definition at line 712 of file XrdOucString.cc.

713{
714 // Replace any occurrence of s1 with s2 from position 'from' to position
715 // 'to' (inclusive).
716 // Return signed size of length modification (in bytes)
717
718 return replace(s1,s2.c_str(),from,to);
719}

References c_str(), and replace().

+ Here is the call graph for this function:

◆ replace() [3/4]

int XrdOucString::replace ( const XrdOucString s1,
const char * s2,
int from = 0,
int to = -1 )

Definition at line 702 of file XrdOucString.cc.

703{
704 // Replace any occurrence of s1 with s2 from position 'from' to position
705 // 'to' (inclusive).
706 // Return signed size of length modification (in bytes)
707
708 return replace(s1.c_str(),s2,from,to);
709}

References c_str(), and replace().

+ Here is the call graph for this function:

◆ replace() [4/4]

int XrdOucString::replace ( const XrdOucString s1,
const XrdOucString s2,
int from = 0,
int to = -1 )

Definition at line 722 of file XrdOucString.cc.

724{
725 // Replace any occurrence of s1 with s2 from position 'from' to position
726 // 'to' (inclusive).
727 // Return signed size of length modification (in bytes)
728
729 return replace(s1.c_str(),s2.c_str(),from,to);
730}

References c_str(), and replace().

+ Here is the call graph for this function:

◆ reset()

void XrdOucString::reset ( const char c,
int j = 0,
int k = -1 )

Definition at line 963 of file XrdOucString.cc.

964{
965 // Reset string making sure to erase completely the information.
966
967 j = (j >= 0 && j < siz) ? j : 0;
968 k = (k >= j && k < siz) ? k : siz-1;
969
970 if (!str)
971 return;
972
973 for (int i = j; i <= k; i++)
974 str[i] = c;
975
976 while (str[len-1] == 0)
977 --len;
978}

◆ resize()

void XrdOucString::resize ( int lmx = 0)
inline

Definition at line 301 of file XrdOucString.hh.

301 { int ns = (lmx > 0) ? lmx + 1 : 0;
302 str = bufalloc(ns); }

Referenced by XrdSecProtocolpwd::XrdSecProtocolpwd(), and XrdOucGatherConf::Gather().

+ Here is the caller graph for this function:

◆ rfind() [1/3]

int XrdOucString::rfind ( const char * s,
int start = STR_NPOS )

Definition at line 357 of file XrdOucString.cc.

358{
359 // Find index of first occurence of null-terminated string s in
360 // backwards direction starting from position start.
361 // If start == STR_NPOS, search starts from end of string (default).
362 // Return index if found, STR_NPOS if not.
363
364 int rc = STR_NPOS;
365
366 // STR_NPOS indicates start from the end
367 if (start == STR_NPOS)
368 start = len - 1;
369
370 // Make sure start makes sense
371 if (start < 0 || start > (len-1))
372 return rc;
373
374 // Make sure the string is defined
375 if (!s)
376 return rc;
377
378 // length of substring
379 int ls = strlen(s);
380
381 // if only one meaningful char, use dedicated method
382 if (ls == 1)
383 return find(s[0],start,0);
384
385 // Make sure that it can fit
386 if (ls > len)
387 return rc;
388
389 // Start from the first meaningful position
390 if (ls > (len-start))
391 start = len-ls;
392
393 // Now loop
394 int i = start;
395 for (; i >= 0; i--) {
396 if (str[i] == s[0])
397 if (!strncmp(str+i+1,s+1,ls-1))
398 return i;
399 }
400
401 // Nothing found
402 return rc;
403}

References find(), and STR_NPOS.

+ Here is the call graph for this function:

◆ rfind() [2/3]

int XrdOucString::rfind ( const char c,
int start = STR_NPOS )
inline

Definition at line 285 of file XrdOucString.hh.

286 { return find(c, start, 0); }

References find().

Referenced by endswith(), endswith(), XrdSecProtocolpwd::Init(), LocateFactoryIndex(), replace(), and rfind().

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

◆ rfind() [3/3]

int XrdOucString::rfind ( XrdOucString s,
int start = STR_NPOS )

Definition at line 346 of file XrdOucString.cc.

347{
348 // Find index of first occurence of string s in backward
349 // direction starting from position start.
350 // If start == STR_NPOS, search starts from end of string (default).
351 // Return index if found, STR_NPOS if not.
352
353 return rfind(s.c_str(),start);
354}

References c_str(), and rfind().

+ Here is the call graph for this function:

◆ setblksize()

void XrdOucString::setblksize ( const int bs)
static

Definition at line 1212 of file XrdOucString.cc.

1213{
1214 // Set for the block size
1215
1216 XrdOucString::blksize = bs;
1217}

◆ setbuffer()

void XrdOucString::setbuffer ( char * buf)

Definition at line 209 of file XrdOucString.cc.

210{
211 // Adopt buffer 'buf'
212
213 if (str) free(str);
214 init();
215 if (buf) {
216 str = buf;
217 len = strlen(buf);
218 siz = len + 1;
219 str = (char *)realloc(str, siz);
220 }
221}

Referenced by form().

+ Here is the caller graph for this function:

◆ tokenize()

int XrdOucString::tokenize ( XrdOucString & tok,
int from,
char del = ':' )

Definition at line 1220 of file XrdOucString.cc.

1221{
1222 // Search for tokens delimited by 'del' (def ':') in string s; search starts
1223 // from 'from' and the token is returned in 'tok'.
1224 // Returns -1 when there are no more tokens to be analyzed; the length of the
1225 // last valid token, if there are no more delimiters after 'from'; the next
1226 // position after the delimiter, when there are left delimiters in the string.
1227 //
1228 // This method allows to loop over tokens in this way:
1229 //
1230 // XrdOucString myl = "tok1 tok2 tok3";
1231 // char del = ' ';
1232 // XrdOucString tok;
1233 // int from = 1;
1234 // while ((from = myl.tokenize(tok, from, del) != -1) {
1235 // // Analyse tok
1236 // ...
1237 // }
1238 //
1239 // Warning: it may return empty tokens (e.g. in cases like "::"), so
1240 // the token length must always be checked.
1241
1242 // Make sure inputs make sense
1243 if (len <= 0 || from < 0 || from > (len-1))
1244 return -1;
1245
1246 // Find delimiter
1247 int pos = find(del, from);
1248
1249 // Assign to token
1250 if (pos == -1 || pos > from) {
1251 int last = (pos > 0) ? (pos - 1) : -1;
1252 tok.assign(str, from, last);
1253 } else
1254 tok = "";
1255
1256 int next = pos + 1;
1257 if (pos == -1) {
1258 if (tok.length() > 0)
1259 // So we can analize the last one
1260 next = len;
1261 else
1262 next = pos;
1263 }
1264
1265 // return
1266 return next;
1267}

References assign(), find(), and length().

Referenced by XrdCryptosslX509Crl::XrdCryptosslX509Crl(), XrdVomsMapfile::Apply(), XrdSecProtocolgsi::Authenticate(), Display(), XrdOucUtils::findPgm(), XrdSecProtocolgsi::Init(), XrdSecProtocolpwd::Init(), XrdCryptoX509::MatchHostnames(), ParseCrypto(), XrdVomsFun::VOMSInit(), XrdAccAuthorizeObject(), and XrdOfsgetPrepare().

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

◆ upper()

void XrdOucString::upper ( int pos,
int size = 0 )

Definition at line 919 of file XrdOucString.cc.

920{
921 // Set to upper case size chars starting from position start.
922 // If size == 0, upper all bytes from start on.
923
924 // Make sure start makes sense
925 int st = start;
926 if (st < 0 || st > (len-1))
927 return;
928
929 // Make sure size makes sense
930 if (size < 0)
931 return;
932 int nup = 0;
933 if (size == 0) {
934 nup = len - st;
935 } else {
936 nup = (size > (len-st)) ? (len-st) : size;
937 }
938
939 // Do nothing if no byte removal has been requested
940 if (nup <= 0)
941 return;
942
943 // Set to upper
944 int i = st;
945 for (; i < st + nup ; i++ ) {
946 if (str[i] > 0x60 && str[i] < 0x7b)
947 str[i] -= 0x20;
948 }
949}

Friends And Related Symbol Documentation

◆ operator+ [1/4]

XrdOucString operator+ ( const XrdOucString & s1,
const char * s )
friend

Definition at line 1036 of file XrdOucString.cc.

1037{
1038 // Return string resulting from concatenation
1039
1040 XrdOucString ns(s1);
1041 if (s && strlen(s))
1042 ns.append(s);
1043 return ns;
1044}

◆ operator+ [2/4]

XrdOucString operator+ ( const XrdOucString & s1,
const char c )
friend

Definition at line 1058 of file XrdOucString.cc.

1059{
1060 // Return string resulting from concatenation of local string
1061 // and char c
1062
1063 XrdOucString ns(s1);
1064 ns.append(c);
1065 return ns;
1066}

◆ operator+ [3/4]

XrdOucString operator+ ( const XrdOucString & s1,
const int i )
friend

Definition at line 1069 of file XrdOucString.cc.

1070{
1071 // Return string resulting from concatenation of local string
1072 // and string representing integer i.
1073
1074 XrdOucString ns(s1);
1075 ns.append(i);
1076 return ns;
1077}

◆ operator+ [4/4]

XrdOucString operator+ ( const XrdOucString & s1,
const XrdOucString & s )
friend

Definition at line 1047 of file XrdOucString.cc.

1048{
1049 // Return string resulting from concatenation
1050
1051 XrdOucString ns(s1);
1052 if (s.length())
1053 ns.append(s);
1054 return ns;
1055}

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