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 367 of file XrdClUtils.cc.

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

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 635 of file XrdClUtils.cc.

636  {
637  char *hex = new char[2*size+1];
638  for( uint16_t i = 0; i < size; ++i )
639  snprintf( hex+(2*i), 3, "%02x", (int)array[i] );
640  std::string result = hex;
641  delete [] hex;
642  return result;
643  }
@ 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 703 of file XrdClUtils.cc.

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

383  {
384  Log *log = DefaultEnv::GetLog();
385  log->Debug( UtilityMsg, "Checking if the data server %s supports tpc",
386  server.c_str() );
387 
388  FileSystem sourceDSFS( server );
389  Buffer queryArg; queryArg.FromString( "tpc" );
390  Buffer *queryResponse = 0;
391  XRootDStatus st;
392  st = sourceDSFS.Query( QueryCode::Config, queryArg, queryResponse,
393  timeout );
394  if( !st.IsOK() )
395  {
396  log->Error( UtilityMsg, "Cannot query source data server %s: %s",
397  server.c_str(), st.ToStr().c_str() );
398  st.status = stFatal;
399  return st;
400  }
401 
402  if( !queryResponse )
403  {
404  log->Error( UtilityMsg, "Cannot query source data server: empty response." );
405  st.status = stFatal;
406  return st;
407  }
408 
409  std::string answer = queryResponse->ToString();
410  delete queryResponse;
411  if( answer.length() == 1 || !isdigit( answer[0] ) || atoi(answer.c_str()) == 0)
412  {
413  log->Debug( UtilityMsg, "Third party copy not supported at: %s",
414  server.c_str() );
415  return XRootDStatus( stError, errNotSupported );
416  }
417  log->Debug( UtilityMsg, "Third party copy supported at: %s",
418  server.c_str() );
419 
420  return XRootDStatus();
421  }
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:112
@ 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 426 of file XrdClUtils.cc.

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

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

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 506 of file XrdClUtils.cc.

508  {
509  DIR *dp = opendir( path.c_str() );
510  if( !dp )
511  return Status( stError, errOSError, errno );
512 
513  dirent *dirEntry;
514 
515  while( (dirEntry = readdir(dp)) != 0 )
516  {
517  std::string entryName = dirEntry->d_name;
518  if( !entryName.compare( 0, 2, "..") )
519  continue;
520  if( !entryName.compare( 0, 1, ".") )
521  continue;
522 
523  entries.push_back( dirEntry->d_name );
524  }
525 
526  closedir(dp);
527 
528  return Status();
529  }
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 269 of file XrdClUtils.cc.

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

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 140 of file XrdClUtils.cc.

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

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

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 330 of file XrdClUtils.cc.

333  {
334  Log *log = DefaultEnv::GetLog();
335  CheckSumManager *cksMan = DefaultEnv::GetCheckSumManager();
336 
337  if( !cksMan )
338  {
339  log->Error( UtilityMsg, "Unable to get the checksum manager" );
340  return XRootDStatus( stError, errInternal );
341  }
342 
343  XrdCksData ckSum; ckSum.Set( checkSumType.c_str() );
344  bool status = cksMan->Calculate( ckSum, checkSumType, path.c_str() );
345  if( !status )
346  {
347  log->Error( UtilityMsg, "Error while calculating checksum for %s",
348  path.c_str() );
349  return XRootDStatus( stError, errCheckSumError );
350  }
351 
352  char *cksBuffer = new char[265];
353  ckSum.Get( cksBuffer, 256 );
354  checkSum = checkSumType + ":";
355  checkSum += NormalizeChecksum( checkSumType, cksBuffer );
356  delete [] cksBuffer;
357 
358  log->Dump( UtilityMsg, "Checksum for %s is: %s", path.c_str(),
359  checkSum.c_str() );
360 
361  return XRootDStatus();
362  }
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:648
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 279 of file XrdClUtils.cc.

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

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

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 665 of file XrdClUtils.cc.

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

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:467
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 771 of file XrdClUtils.cc.

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

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

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 617 of file XrdClUtils.cc.

621  {
622  if( unlikely(log->GetLevel() >= Log::DumpMsg) ) {
623  PropertyList::PropertyMap::const_iterator it;
624  std::string keyVals;
625  for (it = list.begin(); it != list.end(); ++it)
626  keyVals += "'" + it->first + "' = '" + obfuscateAuth(it->second) + "', ";
627  keyVals.erase(keyVals.length() - 2, 2);
628  log->Dump(topic, format, keyVals.c_str());
629  }
630  }
#define unlikely(x)
std::string obfuscateAuth(const std::string &input)
@ DumpMsg
print details of the request and responses
Definition: XrdClLog.hh:113

References XrdCl::PropertyList::begin(), XrdCl::Log::Dump(), XrdCl::Log::DumpMsg, XrdCl::PropertyList::end(), XrdCl::Log::GetLevel(), obfuscateAuth(), and unlikely.

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 648 of file XrdClUtils.cc.

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

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 534 of file XrdClUtils.cc.

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

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

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 875 of file XrdClUtils.cc.

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

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

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 256 of file XrdClUtils.cc.

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

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 606 of file XrdClUtils.cc.

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

Referenced by ProcessConfig().

+ Here is the caller graph for this function:

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