XRootD
XrdCl::Utils Class Reference

Random utilities. More...

#include <XrdClUtils.hh>

+ Collaboration diagram for XrdCl::Utils:

Public Types

enum  AddressType {
  IPAuto = 0 ,
  IPAll = 1 ,
  IPv6 = 2 ,
  IPv4 = 3 ,
  IPv4Mapped6 = 4
}
 Address type. More...
 

Static Public Member Functions

static std::string BytesToString (uint64_t bytes)
 Convert bytes to a human readable string. More...
 
static std::string Char2Hex (uint8_t *array, uint16_t size)
 Print a char array as hex. More...
 
static bool CheckEC (const Message *req, const URL &url)
 Check if this client can support given EC redirect. More...
 
static XRootDStatus CheckTPC (const std::string &server, uint16_t timeout=0)
 Check if peer supports tpc. More...
 
static XRootDStatus CheckTPCLite (const std::string &server, uint16_t timeout=0)
 
static std::string FQDNToCC (const std::string &fqdn)
 Convert the fully qualified host name to country code. More...
 
static Status GetDirectoryEntries (std::vector< std::string > &entries, const std::string &path)
 Get directory entries. More...
 
static uint64_t GetElapsedMicroSecs (timeval start, timeval end)
 Get the elapsed microseconds between two timevals. More...
 
static Status GetHostAddresses (std::vector< XrdNetAddr > &addresses, const URL &url, AddressType type)
 Resolve IP addresses. More...
 
static int GetIntParameter (const URL &url, const std::string &name, int defaultVal)
 Get a parameter either from the environment or URL. More...
 
static XRootDStatus GetLocalCheckSum (std::string &checkSum, const std::string &checkSumType, const std::string &path)
 Get a checksum from local file. More...
 
static XrdCl::XRootDStatus GetProtocolVersion (const XrdCl::URL url, int &protver)
 
static XRootDStatus GetRemoteCheckSum (std::string &checkSum, const std::string &checkSumType, const URL &url)
 Get a checksum from a remote xrootd server. More...
 
static std::string GetStringParameter (const URL &url, const std::string &name, const std::string &defaultVal)
 Get a parameter either from the environment or URL. More...
 
static std::vector< std::string > GetSupportedCheckSums (const XrdCl::URL &url)
 Get supported checksum types for given URL. More...
 
static bool HasPgRW (const XrdCl::URL &url)
 
static bool HasXAttr (const XrdCl::URL &url)
 
static std::string InferChecksumType (const XrdCl::URL &source, const XrdCl::URL &destination, bool zip=false)
 Automatically infer the right checksum type. More...
 
static void LogHostAddresses (Log *log, uint64_t type, const std::string &hostId, std::vector< XrdNetAddr > &addresses)
 Log all the addresses on the list. More...
 
static void LogPropertyList (Log *log, uint64_t topic, const char *format, const PropertyList &list)
 Log property list. More...
 
static std::string NormalizeChecksum (const std::string &name, const std::string &checksum)
 Normalize checksum. More...
 
static Status ProcessConfig (std::map< std::string, std::string > &config, const std::string &file)
 Process a config file and return key-value pairs. More...
 
static Status ProcessConfigDir (std::map< std::string, std::string > &config, const std::string &dir)
 Process a config directory and return key-value pairs. More...
 
static void SplitChunks (std::vector< ChunkList > &listsvec, const ChunkList &chunks, const uint32_t maxcs, const size_t maxc)
 Split chunks in a ChunkList into one or more ChunkLists. More...
 
template<class Container >
static void splitString (Container &result, const std::string &input, const std::string &delimiter)
 Split a string. More...
 
static AddressType String2AddressType (const std::string &addressType)
 Interpret a string as address type, default to IPAll. More...
 
static std::string TimeToString (time_t timestamp)
 Convert timestamp to a string. More...
 
static void Trim (std::string &str)
 Trim a string. More...
 

Detailed Description

Random utilities.

Definition at line 49 of file XrdClUtils.hh.

Member Enumeration Documentation

◆ AddressType

Address type.

Enumerator
IPAuto 
IPAll 
IPv6 
IPv4 
IPv4Mapped6 

Definition at line 86 of file XrdClUtils.hh.

87  {
88  IPAuto = 0,
89  IPAll = 1,
90  IPv6 = 2,
91  IPv4 = 3,
92  IPv4Mapped6 = 4
93  };

Member Function Documentation

◆ BytesToString()

std::string XrdCl::Utils::BytesToString ( uint64_t  bytes)
static

Convert bytes to a human readable string.

Definition at line 366 of file XrdClUtils.cc.

367  {
368  double final = bytes;
369  int i = 0;
370  char suf[3] = { 'k', 'M', 'G' };
371  for( i = 0; i < 3 && final > 1024; ++i, final /= 1024 ) {};
372  std::ostringstream o;
373  o << std::setprecision(4) << final;
374  if( i > 0 ) o << suf[i-1];
375  return o.str();
376  }

Referenced by ProgressDisplay::GetProgressBar(), ProgressDisplay::GetSummaryBar(), and ProgressDisplay::JobProgress().

+ Here is the caller graph for this function:

◆ Char2Hex()

std::string XrdCl::Utils::Char2Hex ( uint8_t *  array,
uint16_t  size 
)
static

Print a char array as hex.

Definition at line 632 of file XrdClUtils.cc.

633  {
634  char *hex = new char[2*size+1];
635  for( uint16_t i = 0; i < size; ++i )
636  snprintf( hex+(2*i), 3, "%02x", (int)array[i] );
637  std::string result = hex;
638  delete [] hex;
639  return result;
640  }
@ hex
Definition: XrdSysTrace.hh:42

References Xrd::hex.

◆ CheckEC()

bool XrdCl::Utils::CheckEC ( const Message req,
const URL url 
)
static

Check if this client can support given EC redirect.

Definition at line 700 of file XrdClUtils.cc.

701  {
702 #ifdef WITH_XRDEC
703  // make sure that if we will be writing it is a new file
704  ClientRequest *request = (ClientRequest*)req->GetBuffer();
705  uint16_t options = ntohs( request->open.options );
706  bool open_wrt = ( options & kXR_open_updt ) || ( options & kXR_open_wrto );
707  bool open_new = ( options & kXR_new );
708  if( open_wrt && !open_new ) return false;
709 
710  const URL::ParamsMap &params = url.GetParams();
711  // make sure all the xrdec. tokens are present and the values are sane
712  URL::ParamsMap::const_iterator itr = params.find( "xrdec.nbdta" );
713  if( itr == params.end() ) return false;
714  size_t nbdta = std::stoul( itr->second );
715 
716  itr = params.find( "xrdec.nbprt" );
717  if( itr == params.end() ) return false;
718  size_t nbprt = std::stoul( itr->second );
719 
720  itr = params.find( "xrdec.blksz" );
721  if( itr == params.end() ) return false;
722 
723  itr = params.find( "xrdec.plgr" );
724  if( itr == params.end() ) return false;
725  std::vector<std::string> plgr;
726  splitString( plgr, itr->second, "," );
727  if( plgr.size() < nbdta + nbprt ) return false;
728 
729  itr = params.find( "xrdec.objid" );
730  if( itr == params.end() ) return false;
731 
732  itr = params.find( "xrdec.format" );
733  if( itr == params.end() ) return false;
734  size_t format = std::stoul( itr->second );
735  if( format != 1 ) return false; // TODO use constant
736 
737  itr = params.find( "xrdec.dtacgi" );
738  if( itr != params.end() )
739  {
740  std::vector<std::string> dtacgi;
741  splitString( dtacgi, itr->second, "," );
742  if( plgr.size() != dtacgi.size() ) return false;
743  }
744 
745  itr = params.find( "xrdec.mdtacgi" );
746  if( itr != params.end() )
747  {
748  std::vector<std::string> mdtacgi;
749  splitString( mdtacgi, itr->second, "," );
750  if( plgr.size() != mdtacgi.size() ) return false;
751  }
752 
753  itr = params.find( "xrdec.cosc" );
754  if( itr == params.end() ) return false;
755  std::string cosc = itr->second;
756  if( cosc != "true" && cosc != "false" ) return false;
757 
758  return true;
759 #else
760  return false;
761 #endif
762  }
kXR_unt16 options
Definition: XProtocol.hh:481
@ kXR_open_wrto
Definition: XProtocol.hh:469
@ kXR_open_updt
Definition: XProtocol.hh:457
@ kXR_new
Definition: XProtocol.hh:455
struct ClientOpenRequest open
Definition: XProtocol.hh:858
std::map< std::string, std::string > ParamsMap
Definition: XrdClURL.hh:33
static void splitString(Container &result, const std::string &input, const std::string &delimiter)
Split a string.
Definition: XrdClUtils.hh:56

References XrdCl::Buffer::GetBuffer(), XrdCl::URL::GetParams(), kXR_new, kXR_open_updt, kXR_open_wrto, ClientRequest::open, ClientOpenRequest::options, and splitString().

Referenced by XrdCl::XRootDMsgHandler::Process().

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

◆ CheckTPC()

XRootDStatus XrdCl::Utils::CheckTPC ( const std::string &  server,
uint16_t  timeout = 0 
)
static

Check if peer supports tpc.

Definition at line 381 of file XrdClUtils.cc.

382  {
383  Log *log = DefaultEnv::GetLog();
384  log->Debug( UtilityMsg, "Checking if the data server %s supports tpc",
385  server.c_str() );
386 
387  FileSystem sourceDSFS( server );
388  Buffer queryArg; queryArg.FromString( "tpc" );
389  Buffer *queryResponse = 0;
390  XRootDStatus st;
391  st = sourceDSFS.Query( QueryCode::Config, queryArg, queryResponse,
392  timeout );
393  if( !st.IsOK() )
394  {
395  log->Error( UtilityMsg, "Cannot query source data server %s: %s",
396  server.c_str(), st.ToStr().c_str() );
397  st.status = stFatal;
398  return st;
399  }
400 
401  if( !queryResponse )
402  {
403  log->Error( UtilityMsg, "Cannot query source data server: empty response." );
404  st.status = stFatal;
405  return st;
406  }
407 
408  std::string answer = queryResponse->ToString();
409  delete queryResponse;
410  if( answer.length() == 1 || !isdigit( answer[0] ) || atoi(answer.c_str()) == 0)
411  {
412  log->Debug( UtilityMsg, "Third party copy not supported at: %s",
413  server.c_str() );
414  return XRootDStatus( stError, errNotSupported );
415  }
416  log->Debug( UtilityMsg, "Third party copy supported at: %s",
417  server.c_str() );
418 
419  return XRootDStatus();
420  }
static Log * GetLog()
Get default log.
const uint16_t stFatal
Fatal error, it's still an error.
Definition: XrdClStatus.hh:33
const uint16_t stError
An error occurred that could potentially be retried.
Definition: XrdClStatus.hh:32
const uint64_t UtilityMsg
const uint16_t errNotSupported
Definition: XrdClStatus.hh:62
XrdSysError Log
Definition: XrdConfig.cc:111
@ Config
Query server configuration.

References XrdCl::QueryCode::Config, XrdCl::Log::Debug(), XrdCl::errNotSupported, XrdCl::Log::Error(), XrdCl::Buffer::FromString(), XrdCl::DefaultEnv::GetLog(), XrdCl::Status::IsOK(), XrdCl::FileSystem::Query(), XrdCl::Status::status, XrdCl::stError, XrdCl::stFatal, XrdCl::XRootDStatus::ToStr(), XrdCl::Buffer::ToString(), and XrdCl::UtilityMsg.

+ Here is the call graph for this function:

◆ CheckTPCLite()

XRootDStatus XrdCl::Utils::CheckTPCLite ( const std::string &  server,
uint16_t  timeout = 0 
)
static

Check if peer supports tpc / tpc lite

Returns
: suDone if TPC lite is supported, suPartial if plain TPC is supported, stError otherwise

Definition at line 425 of file XrdClUtils.cc.

426  {
427  Log *log = DefaultEnv::GetLog();
428  log->Debug( UtilityMsg, "Checking if the data server %s supports tpc / tpc lite",
429  server.c_str() );
430 
431  FileSystem sourceDSFS( server );
432  Buffer queryArg; queryArg.FromString( "tpc tpcdlg" );
433  Buffer *queryResponse = 0;
434  XRootDStatus st;
435  st = sourceDSFS.Query( QueryCode::Config, queryArg, queryResponse,
436  timeout );
437  if( !st.IsOK() )
438  {
439  log->Error( UtilityMsg, "Cannot query source data server %s: %s",
440  server.c_str(), st.ToStr().c_str() );
441  st.status = stFatal;
442  return st;
443  }
444 
445  if( !queryResponse )
446  {
447  log->Error( UtilityMsg, "Cannot query source data server: empty response." );
448  st.status = stFatal;
449  return st;
450  }
451 
452  std::string answer = queryResponse->ToString();
453  delete queryResponse;
454 
455  if( answer.empty() )
456  {
457  log->Error( UtilityMsg, "Cannot query source data server: empty response." );
458  st.status = stFatal;
459  return st;
460  }
461 
462  std::vector<std::string> resp;
463  Utils::splitString( resp, answer, "\n" );
464 
465  if( resp.empty() || resp[0].empty() ||
466  !isdigit( resp[0][0]) || atoi( resp[0].c_str() ) == 0 )
467  {
468  log->Debug( UtilityMsg, "Third party copy not supported at: %s",
469  server.c_str() );
470  return XRootDStatus( stError, errNotSupported );
471  }
472 
473  if( resp.size() == 1 || resp[1] == "tpcdlg" )
474  {
475  log->Debug( UtilityMsg, "TPC lite not supported at: %s",
476  server.c_str() );
477  return XRootDStatus( stOK, suPartial );
478  }
479 
480  log->Debug( UtilityMsg, "TPC lite supported at: %s",
481  server.c_str() );
482 
483  return XRootDStatus();
484  }
const uint16_t suPartial
Definition: XrdClStatus.hh:41
const uint16_t stOK
Everything went OK.
Definition: XrdClStatus.hh:31

References XrdCl::QueryCode::Config, XrdCl::Log::Debug(), XrdCl::errNotSupported, XrdCl::Log::Error(), XrdCl::Buffer::FromString(), XrdCl::DefaultEnv::GetLog(), XrdCl::Status::IsOK(), XrdCl::FileSystem::Query(), splitString(), XrdCl::Status::status, XrdCl::stError, XrdCl::stFatal, XrdCl::stOK, XrdCl::suPartial, XrdCl::XRootDStatus::ToStr(), XrdCl::Buffer::ToString(), and XrdCl::UtilityMsg.

+ Here is the call graph for this function:

◆ FQDNToCC()

std::string XrdCl::Utils::FQDNToCC ( const std::string &  fqdn)
static

Convert the fully qualified host name to country code.

Definition at line 489 of file XrdClUtils.cc.

490  {
491  std::vector<std::string> el;
492  Utils::splitString( el, fqdn, "." );
493  if( el.size() < 2 )
494  return "us";
495 
496  std::string cc = *el.rbegin();
497  if( cc.length() == 2 )
498  return cc;
499  return "us";
500  }

References splitString().

+ Here is the call graph for this function:

◆ GetDirectoryEntries()

Status XrdCl::Utils::GetDirectoryEntries ( std::vector< std::string > &  entries,
const std::string &  path 
)
static

Get directory entries.

Definition at line 505 of file XrdClUtils.cc.

507  {
508  DIR *dp = opendir( path.c_str() );
509  if( !dp )
510  return Status( stError, errOSError, errno );
511 
512  dirent *dirEntry;
513 
514  while( (dirEntry = readdir(dp)) != 0 )
515  {
516  std::string entryName = dirEntry->d_name;
517  if( !entryName.compare( 0, 2, "..") )
518  continue;
519  if( !entryName.compare( 0, 1, ".") )
520  continue;
521 
522  entries.push_back( dirEntry->d_name );
523  }
524 
525  closedir(dp);
526 
527  return Status();
528  }
struct dirent * readdir(DIR *dirp)
int closedir(DIR *dirp)
DIR * opendir(const char *path)
const uint16_t errOSError
Definition: XrdClStatus.hh:61

References closedir(), XrdCl::errOSError, opendir(), readdir(), and XrdCl::stError.

Referenced by ProcessConfigDir().

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

◆ GetElapsedMicroSecs()

uint64_t XrdCl::Utils::GetElapsedMicroSecs ( timeval  start,
timeval  end 
)
static

Get the elapsed microseconds between two timevals.

Definition at line 268 of file XrdClUtils.cc.

269  {
270  uint64_t startUSec = start.tv_sec*1000000 + start.tv_usec;
271  uint64_t endUSec = end.tv_sec*1000000 + end.tv_usec;
272  return endUSec-startUSec;
273  }

Referenced by XrdCl::ClassicCopyJob::Run(), and XrdCl::ThirdPartyCopyJob::Run().

+ Here is the caller graph for this function:

◆ GetHostAddresses()

Status XrdCl::Utils::GetHostAddresses ( std::vector< XrdNetAddr > &  addresses,
const URL url,
Utils::AddressType  type 
)
static

Resolve IP addresses.

Definition at line 139 of file XrdClUtils.cc.

142  {
143  Log *log = DefaultEnv::GetLog();
144  const char *err = 0;
145  int ordn;
146 
147  //--------------------------------------------------------------------------
148  // Resolve all the addresses
149  //--------------------------------------------------------------------------
150  std::ostringstream o; o << url.GetHostName() << ":" << url.GetPort();
152 
153  if( type == IPv6 ) opts = XrdNetUtils::onlyIPv6;
154  else if( type == IPv4 ) opts = XrdNetUtils::onlyIPv4;
155  else if( type == IPv4Mapped6 ) opts = XrdNetUtils::allV4Map;
156  else if( type == IPAll ) opts = XrdNetUtils::allIPMap;
158 
159  //--------------------------------------------------------------------------
160  // Check what are the preferences IPv6 or IPv4
161  //--------------------------------------------------------------------------
162  int preferIPv4 = DefaultPreferIPv4;
163  DefaultEnv::GetEnv()->GetInt( "PreferIPv4", preferIPv4 );
164 
165  //--------------------------------------------------------------------------
166  // Partition the addresses according to the preferences
167  //
168  // The preferred IP family goes to the back as it is easier to remove
169  // items from the back of the vector
170  //--------------------------------------------------------------------------
171  opts |= (preferIPv4 ? XrdNetUtils::order64 : XrdNetUtils::order46);
172 
173  //--------------------------------------------------------------------------
174  // Now get all of the properly partitioned addresses; ordn will hold the
175  // number of non-preferred addresses at the front of the table.
176  //--------------------------------------------------------------------------
177  err = XrdNetUtils::GetAddrs( o.str(), addresses, &ordn, opts );
178 
179  if( err )
180  {
181  log->Error( UtilityMsg, "Unable to resolve %s: %s", o.str().c_str(),
182  err );
183  return Status( stError, errInvalidAddr );
184  }
185 
186  if( addresses.size() == 0 )
187  {
188  log->Error( UtilityMsg, "No addresses for %s were found",
189  o.str().c_str() );
190  return Status( stError, errInvalidAddr );
191  }
192 
193  //--------------------------------------------------------------------------
194  // Shuffle each partition
195  //--------------------------------------------------------------------------
196 
197  int ipNoShuffle = DefaultIPNoShuffle;
198  Env *env = DefaultEnv::GetEnv();
199  env->GetInt( "IPNoShuffle", ipNoShuffle );
200 
201  if( !ipNoShuffle )
202  {
203 #if __cplusplus < 201103L
204  // initialize the random generator only once
205  static struct only_once_t
206  {
207  only_once_t()
208  {
209  std::srand ( unsigned ( std::time(0) ) );
210  }
211  } only_once;
212 
213  std::random_shuffle( addresses.begin(), addresses.begin() + ordn );
214  std::random_shuffle( addresses.begin() + ordn, addresses.end() );
215 #else
216  static std::default_random_engine rand_engine(
217  std::chrono::system_clock::now().time_since_epoch().count() );
218 
219  std::shuffle( addresses.begin(), addresses.begin() + ordn, rand_engine );
220  std::shuffle( addresses.begin() + ordn, addresses.end(), rand_engine );
221 #endif
222  }
223 
224  //--------------------------------------------------------------------------
225  // Return status as the result is already in the output parameter
226  //--------------------------------------------------------------------------
227  return Status();
228  }
struct myOpts opts
static Env * GetEnv()
Get default client environment.
bool GetInt(const std::string &key, int &value)
Definition: XrdClEnv.cc:89
static const char * GetAddrs(const char *hSpec, XrdNetAddr *aListP[], int &aListN, AddrOpts opts=allIPMap, int pNum=PortInSpec)
Definition: XrdNetUtils.cc:238
const uint16_t errInvalidAddr
Definition: XrdClStatus.hh:71
const int DefaultIPNoShuffle
const int DefaultPreferIPv4

References XrdNetUtils::allIPMap, XrdNetUtils::allV4Map, XrdCl::DefaultIPNoShuffle, XrdCl::DefaultPreferIPv4, XrdCl::errInvalidAddr, XrdCl::Log::Error(), XrdNetUtils::GetAddrs(), XrdCl::DefaultEnv::GetEnv(), XrdCl::URL::GetHostName(), XrdCl::Env::GetInt(), XrdCl::DefaultEnv::GetLog(), XrdCl::URL::GetPort(), IPAll, IPv4, IPv4Mapped6, IPv6, XrdNetUtils::onlyIPv4, XrdNetUtils::onlyIPv6, opts, XrdNetUtils::order46, XrdNetUtils::order64, XrdNetUtils::prefAuto, XrdCl::stError, and XrdCl::UtilityMsg.

Referenced by XrdCl::Stream::CanCollapse(), XrdCl::Socket::Connect(), and XrdCl::Stream::EnableLink().

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

◆ GetIntParameter()

int XrdCl::Utils::GetIntParameter ( const URL url,
const std::string &  name,
int  defaultVal 
)
static

Get a parameter either from the environment or URL.

Definition at line 80 of file XrdClUtils.cc.

83  {
84  Env *env = DefaultEnv::GetEnv();
85  int value = defaultVal;
86  char *endPtr;
87  URL::ParamsMap::const_iterator it;
88 
89  env->GetInt( name, value );
90  it = url.GetParams().find( std::string("XrdCl.") + name );
91  if( it != url.GetParams().end() )
92  {
93  int urlValue = (int)strtol( it->second.c_str(), &endPtr, 0 );
94  if( !*endPtr )
95  value = urlValue;
96  }
97  return value;
98  }

References XrdCl::DefaultEnv::GetEnv(), XrdCl::Env::GetInt(), and XrdCl::URL::GetParams().

Referenced by XrdCl::Stream::Stream().

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

◆ GetLocalCheckSum()

XRootDStatus XrdCl::Utils::GetLocalCheckSum ( std::string &  checkSum,
const std::string &  checkSumType,
const std::string &  path 
)
static

Get a checksum from local file.

Definition at line 329 of file XrdClUtils.cc.

332  {
333  Log *log = DefaultEnv::GetLog();
334  CheckSumManager *cksMan = DefaultEnv::GetCheckSumManager();
335 
336  if( !cksMan )
337  {
338  log->Error( UtilityMsg, "Unable to get the checksum manager" );
339  return XRootDStatus( stError, errInternal );
340  }
341 
342  XrdCksData ckSum; ckSum.Set( checkSumType.c_str() );
343  bool status = cksMan->Calculate( ckSum, checkSumType, path.c_str() );
344  if( !status )
345  {
346  log->Error( UtilityMsg, "Error while calculating checksum for %s",
347  path.c_str() );
348  return XRootDStatus( stError, errCheckSumError );
349  }
350 
351  char *cksBuffer = new char[265];
352  ckSum.Get( cksBuffer, 256 );
353  checkSum = checkSumType + ":";
354  checkSum += NormalizeChecksum( checkSumType, cksBuffer );
355  delete [] cksBuffer;
356 
357  log->Dump( UtilityMsg, "Checksum for %s is: %s", path.c_str(),
358  checkSum.c_str() );
359 
360  return XRootDStatus();
361  }
int Set(const char *csName)
Definition: XrdCksData.hh:81
int Get(char *Buff, int Blen)
Definition: XrdCksData.hh:69
static CheckSumManager * GetCheckSumManager()
Get checksum manager.
static std::string NormalizeChecksum(const std::string &name, const std::string &checksum)
Normalize checksum.
Definition: XrdClUtils.cc:645
const uint16_t errInternal
Internal error.
Definition: XrdClStatus.hh:56
const uint16_t errCheckSumError
Definition: XrdClStatus.hh:101

References XrdCl::CheckSumManager::Calculate(), XrdCl::Log::Dump(), XrdCl::errCheckSumError, XrdCl::errInternal, XrdCl::Log::Error(), XrdCksData::Get(), XrdCl::DefaultEnv::GetCheckSumManager(), XrdCl::DefaultEnv::GetLog(), NormalizeChecksum(), XrdCksData::Set(), XrdCl::stError, and XrdCl::UtilityMsg.

+ Here is the call graph for this function:

◆ GetProtocolVersion()

static XrdCl::XRootDStatus XrdCl::Utils::GetProtocolVersion ( const XrdCl::URL  url,
int &  protver 
)
inlinestatic

Get protocol version of the given server

Parameters
url: URL pointing to the server
protver: protocol version (output parameter)
Returns
: operation status

Definition at line 235 of file XrdClUtils.hh.

236  {
237  XrdCl::AnyObject qryResult;
239  QueryTransport( url, XrdCl::XRootDQuery::ProtocolVersion, qryResult );
240  if( !st.IsOK() ) return st;
241  int *tmp = 0;
242  qryResult.Get( tmp );
243  protver = *tmp;
244  delete tmp;
245  return XrdCl::XRootDStatus();
246  }
void Get(Type &object)
Retrieve the object being held.
static PostMaster * GetPostMaster()
Get default post master.
bool IsOK() const
We're fine.
Definition: XrdClStatus.hh:124
static const uint16_t ProtocolVersion
returns the protocol version

References XrdCl::AnyObject::Get(), XrdCl::DefaultEnv::GetPostMaster(), XrdCl::Status::IsOK(), and XrdCl::XRootDQuery::ProtocolVersion.

Referenced by HasPgRW(), HasXAttr(), and XrdCl::FileStateHandler::PgRead().

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

◆ GetRemoteCheckSum()

XRootDStatus XrdCl::Utils::GetRemoteCheckSum ( std::string &  checkSum,
const std::string &  checkSumType,
const URL url 
)
static

Get a checksum from a remote xrootd server.

Definition at line 278 of file XrdClUtils.cc.

281  {
282  FileSystem *fs = new FileSystem( url );
283  // add the 'cks.type' cgi tag in order to
284  // select the proper checksum type in case
285  // the server supports more than one checksum
286  size_t pos = url.GetPath().find( '?' );
287  std::string cksPath = url.GetPath() + ( pos == std::string::npos ? '?' : '&' ) + "cks.type=" + checkSumType;
288  Buffer arg; arg.FromString( cksPath );
289  Buffer *cksResponse = 0;
290  XRootDStatus st;
291  Log *log = DefaultEnv::GetLog();
292 
293  st = fs->Query( QueryCode::Checksum, arg, cksResponse );
294  delete fs;
295 
296  if( !st.IsOK() )
297  {
298  std::string msg = st.GetErrorMessage();
299  msg += " Got an error while querying the checksum!";
300  st.SetErrorMessage( msg );
301  return st;
302  }
303 
304  if( !cksResponse )
305  return XRootDStatus( stError, errInternal, 0, "Got invalid response while querying the checksum!" );
306 
307  std::vector<std::string> elems;
308  Utils::splitString( elems, cksResponse->ToString(), " " );
309  delete cksResponse;
310 
311  if( elems.size() != 2 )
312  return XRootDStatus( stError, errInvalidResponse, 0, "Got invalid response while querying the checksum!" );
313 
314  if( elems[0] != checkSumType )
315  return XRootDStatus( stError, errCheckSumError );
316 
317  checkSum = elems[0] + ":";
318  checkSum += NormalizeChecksum( elems[0], elems[1] );
319 
320  log->Dump( UtilityMsg, "Checksum for %s checksum: %s",
321  url.GetPath().c_str(), checkSum.c_str() );
322 
323  return XRootDStatus();
324  }
const uint16_t errInvalidResponse
Definition: XrdClStatus.hh:99
@ Checksum
Query file checksum.

References XrdCl::QueryCode::Checksum, XrdCl::Log::Dump(), XrdCl::errCheckSumError, XrdCl::errInternal, XrdCl::errInvalidResponse, XrdCl::Buffer::FromString(), XrdCl::XRootDStatus::GetErrorMessage(), XrdCl::DefaultEnv::GetLog(), XrdCl::URL::GetPath(), XrdCl::Status::IsOK(), NormalizeChecksum(), XrdCl::FileSystem::Query(), XrdCl::XRootDStatus::SetErrorMessage(), splitString(), XrdCl::stError, XrdCl::Buffer::ToString(), and XrdCl::UtilityMsg.

Referenced by XrdCl::ThirdPartyCopyJob::Run().

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

◆ GetStringParameter()

std::string XrdCl::Utils::GetStringParameter ( const URL url,
const std::string &  name,
const std::string &  defaultVal 
)
static

Get a parameter either from the environment or URL.

Definition at line 103 of file XrdClUtils.cc.

106  {
107  Env *env = DefaultEnv::GetEnv();
108  std::string value = defaultVal;
109  URL::ParamsMap::const_iterator it;
110 
111  env->GetString( name, value );
112  it = url.GetParams().find( std::string("XrdCl.") + name );
113  if( it != url.GetParams().end() )
114  value = it->second;
115 
116  return value;
117  }

References XrdCl::DefaultEnv::GetEnv(), XrdCl::URL::GetParams(), and XrdCl::Env::GetString().

Referenced by XrdCl::Stream::Stream().

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

◆ GetSupportedCheckSums()

std::vector< std::string > XrdCl::Utils::GetSupportedCheckSums ( const XrdCl::URL url)
static

Get supported checksum types for given URL.

Definition at line 662 of file XrdClUtils.cc.

663  {
664  std::vector<std::string> ret;
665 
666  FileSystem fs( url );
667  Buffer arg; arg.FromString( "chksum" );
668  Buffer *resp = 0;
669  XRootDStatus st = fs.Query( QueryCode::Config, arg, resp );
670  if( st.IsOK() )
671  {
672  std::string response = resp->ToString();
673  if( response != "chksum" )
674  {
675  // we are expecting a response of format: '0:zcrc32,1:adler32'
676  std::vector<std::string> result;
677  Utils::splitString( result, response, "," );
678 
679  std::vector<std::string>::iterator itr = result.begin();
680  for( ; itr != result.end(); ++itr )
681  {
682  size_t pos = itr->find( ':' );
683  if( pos == std::string::npos ) continue;
684  std::string cksname = itr->substr( pos + 1 );
685  // remove all white spaces
686  cksname.erase( std::remove_if( cksname.begin(), cksname.end(), ::isspace ),
687  cksname.end() );
688  ret.push_back( std::move( cksname ) );
689  }
690  }
691  }
692 
693  return ret;
694  }

References XrdCl::QueryCode::Config, XrdCl::Buffer::FromString(), XrdCl::Status::IsOK(), XrdCl::FileSystem::Query(), splitString(), and XrdCl::Buffer::ToString().

Referenced by InferChecksumType().

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

◆ HasPgRW()

static bool XrdCl::Utils::HasPgRW ( const XrdCl::URL url)
inlinestatic

Check if given server supports pgread/pgwrite

Parameters
url: URL pointing to the server
Returns
: true if yes, false otherwise

Definition at line 267 of file XrdClUtils.hh.

268  {
269  if( url.IsLocalFile() ) return false;
270  int protver = 0;
271  auto st = GetProtocolVersion( url, protver );
272  if( !st.IsOK() ) return false;
273  return protver >= kXR_PROTPGRWVERSION;
274  }
#define kXR_PROTPGRWVERSION
Definition: XProtocol.hh:73
bool IsLocalFile() const
Definition: XrdClURL.cc:460
static XrdCl::XRootDStatus GetProtocolVersion(const XrdCl::URL url, int &protver)
Definition: XrdClUtils.hh:235

References GetProtocolVersion(), XrdCl::URL::IsLocalFile(), and kXR_PROTPGRWVERSION.

+ Here is the call graph for this function:

◆ HasXAttr()

static bool XrdCl::Utils::HasXAttr ( const XrdCl::URL url)
inlinestatic

Check if given server supports extended file attributes

Parameters
url: URL pointing to the server
Returns
: true if yes, false otherwise

Definition at line 253 of file XrdClUtils.hh.

254  {
255  if( url.IsLocalFile() ) return true;
256  int protver = 0;
257  auto st = GetProtocolVersion( url, protver );
258  if( !st.IsOK() ) return false;
259  return protver >= kXR_PROTXATTVERSION;
260  }
#define kXR_PROTXATTVERSION
Definition: XProtocol.hh:71

References GetProtocolVersion(), XrdCl::URL::IsLocalFile(), and kXR_PROTXATTVERSION.

Referenced by XrdCl::ClassicCopyJob::Run().

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

◆ InferChecksumType()

std::string XrdCl::Utils::InferChecksumType ( const XrdCl::URL source,
const XrdCl::URL destination,
bool  zip = false 
)
static

Automatically infer the right checksum type.

Automatically infer the right checksum type

Parameters
source: source URL
destination: destination URL
zip: true if the source file is being extracted from a ZIP archive, false otherwise
Returns
: checksum type

Definition at line 768 of file XrdClUtils.cc.

771  {
772  //--------------------------------------------------------------------------
773  // If both files are local we won't be checksumming at all
774  //--------------------------------------------------------------------------
775  if( source.IsLocalFile() && !source.IsMetalink() && destination.IsLocalFile() ) return std::string();
776 
777  // checksums supported by local files
778  std::set<std::string> local_supported;
779  local_supported.insert( "adler32" );
780  local_supported.insert( "crc32" );
781  local_supported.insert( "md5" );
782  local_supported.insert( "zcrc32" );
783 
784  std::vector<std::string> srccks;
785 
786  if( source.IsMetalink() )
787  {
788  int useMtlnCksum = DefaultZipMtlnCksum;
789  Env *env = DefaultEnv::GetEnv();
790  env->GetInt( "ZipMtlnCksum", useMtlnCksum );
791 
792  //------------------------------------------------------------------------
793  // In case of ZIP use other checksums than zcrc32 only if the user
794  // requested it explicitly.
795  //------------------------------------------------------------------------
796  if( !zip || ( zip && useMtlnCksum ) )
797  {
798  RedirectorRegistry &registry = RedirectorRegistry::Instance();
799  VirtualRedirector *redirector = registry.Get( source );
800  std::vector<std::string> cks = redirector->GetSupportedCheckSums();
801  srccks.insert( srccks.end(), cks.begin(), cks.end() );
802  }
803  }
804 
805  if( zip )
806  {
807  //------------------------------------------------------------------------
808  // In case of ZIP we can always extract the checksum from the archive
809  //------------------------------------------------------------------------
810  srccks.push_back( "zcrc32" );
811  }
812  else if( source.GetProtocol() == "root" || source.GetProtocol() == "xroot" )
813  {
814  //------------------------------------------------------------------------
815  // If the source is a remote endpoint query the supported checksums
816  //------------------------------------------------------------------------
817  std::vector<std::string> cks = GetSupportedCheckSums( source );
818  srccks.insert( srccks.end(), cks.begin(), cks.end() );
819  }
820 
821  std::vector<std::string> dstcks;
822 
823  if( destination.GetProtocol() == "root" ||
824  destination.GetProtocol() == "xroot" )
825  {
826  //------------------------------------------------------------------------
827  // If the destination is a remote endpoint query the supported checksums
828  //------------------------------------------------------------------------
829  std::vector<std::string> cks = GetSupportedCheckSums( destination );
830  dstcks.insert( dstcks.end(), cks.begin(), cks.end() );
831  }
832 
833  //--------------------------------------------------------------------------
834  // Now we have all the information we need, we can infer the right checksum
835  // type!!!
836  //
837  // First check if source is local
838  //--------------------------------------------------------------------------
839  if( source.IsLocalFile() && !source.IsMetalink() )
840  {
841  std::vector<std::string>::iterator itr = dstcks.begin();
842  for( ; itr != dstcks.end(); ++itr )
843  if( local_supported.count( *itr ) ) return *itr;
844  return std::string();
845  }
846 
847  //--------------------------------------------------------------------------
848  // then check if destination is local
849  //--------------------------------------------------------------------------
850  if( destination.IsLocalFile() )
851  {
852  std::vector<std::string>::iterator itr = srccks.begin();
853  for( ; itr != srccks.end(); ++itr )
854  if( local_supported.count( *itr ) ) return *itr;
855  return std::string();
856  }
857 
858  //--------------------------------------------------------------------------
859  // if both source and destination are remote look for a checksum that can
860  // satisfy both
861  //--------------------------------------------------------------------------
862  std::set<std::string> dst_supported( dstcks.begin(), dstcks.end() );
863  std::vector<std::string>::iterator itr = srccks.begin();
864  for( ; itr != srccks.end(); ++itr )
865  if( dst_supported.count( *itr ) ) return *itr;
866  return std::string();
867  }
static RedirectorRegistry & Instance()
Returns reference to the single instance.
bool IsMetalink() const
Is it a URL to a metalink.
Definition: XrdClURL.cc:451
const std::string & GetProtocol() const
Get the protocol.
Definition: XrdClURL.hh:113
static std::vector< std::string > GetSupportedCheckSums(const XrdCl::URL &url)
Get supported checksum types for given URL.
Definition: XrdClUtils.cc:662
const int DefaultZipMtlnCksum

References XrdCl::DefaultZipMtlnCksum, XrdCl::RedirectorRegistry::Get(), XrdCl::DefaultEnv::GetEnv(), XrdCl::Env::GetInt(), XrdCl::URL::GetProtocol(), XrdCl::VirtualRedirector::GetSupportedCheckSums(), GetSupportedCheckSums(), XrdCl::RedirectorRegistry::Instance(), XrdCl::URL::IsLocalFile(), and XrdCl::URL::IsMetalink().

Referenced by XrdCl::ClassicCopyJob::Run().

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

◆ LogHostAddresses()

void XrdCl::Utils::LogHostAddresses ( Log log,
uint64_t  type,
const std::string &  hostId,
std::vector< XrdNetAddr > &  addresses 
)
static

Log all the addresses on the list.

Definition at line 233 of file XrdClUtils.cc.

237  {
238  std::string addrStr;
239  std::vector<XrdNetAddr>::iterator it;
240  for( it = addresses.begin(); it != addresses.end(); ++it )
241  {
242  char nameBuff[256];
243  it->Format( nameBuff, 256, XrdNetAddrInfo::fmtAdv6 );
244  addrStr += nameBuff;
245  addrStr += ", ";
246  }
247  addrStr.erase( addrStr.length()-2, 2 );
248  log->Debug( type, "[%s] Found %d address(es): %s",
249  hostId.c_str(), addresses.size(), addrStr.c_str() );
250  }

References XrdCl::Log::Debug(), and XrdNetAddrInfo::fmtAdv6.

Referenced by XrdCl::Socket::Connect(), and XrdCl::Stream::EnableLink().

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

◆ LogPropertyList()

void XrdCl::Utils::LogPropertyList ( Log log,
uint64_t  topic,
const char *  format,
const PropertyList list 
)
static

Log property list.

Definition at line 616 of file XrdClUtils.cc.

620  {
621  PropertyList::PropertyMap::const_iterator it;
622  std::string keyVals;
623  for( it = list.begin(); it != list.end(); ++it )
624  keyVals += "'" + it->first + "' = '" + it->second + "', ";
625  keyVals.erase( keyVals.length()-2, 2 );
626  log->Dump( topic, format, keyVals.c_str() );
627  }

References XrdCl::PropertyList::begin(), XrdCl::Log::Dump(), and XrdCl::PropertyList::end().

Referenced by XrdCl::CopyProcess::AddJob().

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

◆ NormalizeChecksum()

std::string XrdCl::Utils::NormalizeChecksum ( const std::string &  name,
const std::string &  checksum 
)
static

Normalize checksum.

Definition at line 645 of file XrdClUtils.cc.

647  {
648  if( name == "adler32" || name == "crc32" )
649  {
650  size_t i;
651  for( i = 0; i < checksum.length(); ++i )
652  if( checksum[i] != '0' )
653  break;
654  return checksum.substr(i);
655  }
656  return checksum;
657  }

Referenced by XrdCl::CheckSumHelper::GetCheckSum(), GetLocalCheckSum(), GetRemoteCheckSum(), XrdCl::ClassicCopyJob::Run(), and XrdCl::ThirdPartyCopyJob::Run().

+ Here is the caller graph for this function:

◆ ProcessConfig()

Status XrdCl::Utils::ProcessConfig ( std::map< std::string, std::string > &  config,
const std::string &  file 
)
static

Process a config file and return key-value pairs.

Definition at line 533 of file XrdClUtils.cc.

535  {
536  config.clear();
537  std::ifstream inFile( file.c_str() );
538  if( !inFile.good() )
539  return Status( stError, errOSError, errno );
540 
541  errno = 0;
542  std::string line;
543  while( std::getline( inFile, line ) )
544  {
545  if( line.empty() || line[0] == '#' )
546  continue;
547 
548  std::vector<std::string> elems;
549  splitString( elems, line, "=" );
550  if( elems.size() != 2 )
551  return Status( stError, errConfig );
552  std::string key = elems[0]; Trim( key );
553  std::string value = elems[1]; Trim( value );
554  config[key] = value;
555  }
556 
557  if( errno )
558  return Status( stError, errOSError, errno );
559  return Status();
560  }
void getline(uchar *buff, int blen)
static void Trim(std::string &str)
Trim a string.
Definition: XrdClUtils.cc:605
const uint16_t errConfig
System misconfigured.
Definition: XrdClStatus.hh:55

References XrdCl::errConfig, XrdCl::errOSError, getline(), splitString(), XrdCl::stError, and Trim().

Referenced by ProcessConfigDir().

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

◆ ProcessConfigDir()

Status XrdCl::Utils::ProcessConfigDir ( std::map< std::string, std::string > &  config,
const std::string &  dir 
)
static

Process a config directory and return key-value pairs.

Definition at line 565 of file XrdClUtils.cc.

567  {
568  Log *log = DefaultEnv::GetLog();
569  log->Debug( UtilityMsg, "Processing configuration files in %s...",
570  dir.c_str());
571 
572  std::vector<std::string> entries;
573  Status st = Utils::GetDirectoryEntries( entries, dir );
574  if( !st.IsOK() )
575  {
576  log->Debug( UtilityMsg, "Unable to process directory %s: %s",
577  dir.c_str(), st.ToString().c_str() );
578  return st;
579  }
580 
581  static const std::string suffix = ".conf";
582  for( auto &entry : entries )
583  {
584  std::string confFile = dir + "/" + entry;
585 
586  if( confFile.length() <= suffix.length() )
587  continue;
588  if( !std::equal( suffix.rbegin(), suffix.rend(), confFile.rbegin() ) )
589  continue;
590 
591  st = ProcessConfig( config, confFile );
592  if( !st.IsOK() )
593  {
594  log->Debug( UtilityMsg, "Unable to process configuration file %s: %s",
595  confFile.c_str(), st.ToString().c_str() );
596  }
597  }
598 
599  return Status();
600  }
static Status ProcessConfig(std::map< std::string, std::string > &config, const std::string &file)
Process a config file and return key-value pairs.
Definition: XrdClUtils.cc:533
static Status GetDirectoryEntries(std::vector< std::string > &entries, const std::string &path)
Get directory entries.
Definition: XrdClUtils.cc:505

References XrdCl::Log::Debug(), GetDirectoryEntries(), XrdCl::DefaultEnv::GetLog(), XrdCl::Status::IsOK(), ProcessConfig(), XrdCl::Status::ToString(), and XrdCl::UtilityMsg.

+ Here is the call graph for this function:

◆ SplitChunks()

void XrdCl::Utils::SplitChunks ( std::vector< ChunkList > &  listsvec,
const ChunkList chunks,
const uint32_t  maxcs,
const size_t  maxc 
)
static

Split chunks in a ChunkList into one or more ChunkLists.

Split chunks in a ChunkList into one or more ChunkLists

Parameters
listsvec: output vector of ChunkLists
chunks: input ChunkLisits
maxcs: maximum size of a ChunkInfo in output
maxc: maximum number of ChunkInfo in each ChunkList

Definition at line 872 of file XrdClUtils.cc.

876  {
877  listsvec.clear();
878  if( !chunks.size() ) return;
879 
880  listsvec.emplace_back();
881  ChunkList *c = &listsvec.back();
882  const size_t cs = chunks.size();
883  size_t idx = 0;
884  size_t nc = 0;
885  ChunkInfo tmpc;
886 
887  c->reserve( cs );
888 
889  while( idx < cs )
890  {
891  if( maxc && nc >= maxc )
892  {
893  listsvec.emplace_back();
894  c = &listsvec.back();
895  c->reserve( cs - idx );
896  nc = 0;
897  }
898 
899  if( tmpc.length == 0 )
900  tmpc = chunks[idx];
901 
902  if( maxcs && tmpc.length > maxcs )
903  {
904  c->emplace_back( tmpc.offset, maxcs, tmpc.buffer );
905  tmpc.offset += maxcs;
906  tmpc.length -= maxcs;
907  tmpc.buffer = static_cast<char*>( tmpc.buffer ) + maxcs;
908  }
909  else
910  {
911  c->emplace_back( tmpc.offset, tmpc.length, tmpc.buffer );
912  tmpc.length = 0;
913  ++idx;
914  }
915  ++nc;
916  }
917  }
std::vector< ChunkInfo > ChunkList
List of chunks.

References XrdCl::ChunkInfo::buffer, XrdCl::ChunkInfo::length, and XrdCl::ChunkInfo::offset.

Referenced by XrdCl::ZipArchive::CloseArchive().

+ Here is the caller graph for this function:

◆ splitString()

template<class Container >
static void XrdCl::Utils::splitString ( Container &  result,
const std::string &  input,
const std::string &  delimiter 
)
inlinestatic

Split a string.

Definition at line 56 of file XrdClUtils.hh.

59  {
60  /*
61  * This was done in order to not duplicate code as this method
62  * is also used in XrdHttp
63  * TODO: Maybe this method could be collapsed
64  * to avoid this middle-man call here
65  */
66  XrdOucTUtils::splitString(result,input,delimiter);
67  }
static void splitString(Container &result, const std::string &input, const std::string &delimiter)
Split a string.
Definition: XrdOucTUtils.hh:51

References XrdOucTUtils::splitString().

Referenced by BuildPath(), CheckEC(), CheckTPCLite(), XrdCl::PollerFactory::CreatePoller(), FQDNToCC(), XrdCl::GetEcHandler(), GetRemoteCheckSum(), GetSupportedCheckSums(), main(), XrdCl::ParseInput(), XrdCl::StatInfoImpl::ParseServerResponse(), XrdCl::LocationInfo::ParseServerResponse(), XrdCl::StatInfoVFS::ParseServerResponse(), XrdCl::DirectoryList::ParseServerResponse(), XrdCl::XRootDMsgHandler::Process(), ProcessConfig(), ProcessStatQuery(), and XrdCl::URL::SetParams().

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

◆ String2AddressType()

Utils::AddressType XrdCl::Utils::String2AddressType ( const std::string &  addressType)
static

Interpret a string as address type, default to IPAll.

Definition at line 122 of file XrdClUtils.cc.

123  {
124  if( addressType == "IPv6" )
125  return IPv6;
126  else if( addressType == "IPv4" )
127  return IPv4;
128  else if( addressType == "IPv4Mapped6" )
129  return IPv4Mapped6;
130  else if( addressType == "IPAll" )
131  return IPAll;
132  else
133  return IPAuto;
134  }

References IPAll, IPAuto, IPv4, IPv4Mapped6, and IPv6.

Referenced by XrdCl::Stream::Stream().

+ Here is the caller graph for this function:

◆ TimeToString()

std::string XrdCl::Utils::TimeToString ( time_t  timestamp)
static

Convert timestamp to a string.

Definition at line 255 of file XrdClUtils.cc.

256  {
257  char now[30];
258  tm tsNow;
259  time_t ttNow = timestamp;
260  localtime_r( &ttNow, &tsNow );
261  strftime( now, 30, "%Y-%m-%d %H:%M:%S %z", &tsNow );
262  return now;
263  }

Referenced by XrdCl::XRootDTransport::IsStreamBroken(), XrdCl::TaskManager::RegisterTask(), and XrdCl::TaskManager::RunTasks().

+ Here is the caller graph for this function:

◆ Trim()

void XrdCl::Utils::Trim ( std::string &  str)
static

Trim a string.

Definition at line 605 of file XrdClUtils.cc.

606  {
607  str.erase( str.begin(),
608  std::find_if( str.begin(), str.end(), isNotSpace ) );
609  str.erase( std::find_if( str.rbegin(), str.rend(), isNotSpace ).base(),
610  str.end() );
611  }

Referenced by ProcessConfig().

+ Here is the caller graph for this function:

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