38#ifdef R__COMPLETE_MEM_TERMINATION
44 TUrlCleanup(
TObjArray **protocols,
THashList **hosts) : fSpecialProtocols(protocols),fHostFQDNs(hosts) {}
46 if (*fSpecialProtocols) (*fSpecialProtocols)->
Delete();
47 delete *fSpecialProtocols;
48 *fSpecialProtocols = 0;
49 if (*fHostFQDNs) (*fHostFQDNs)->
Delete();
78 SetUrl(url, defaultIsFile);
80#ifdef R__COMPLETE_MEM_TERMINATION
115 if (!url || !url[0]) {
135 defaultIsFile =
kTRUE;
140 char *u, *u0 =
Strip(url);
150 if (
s1.EndsWith(
"/-")) {
155 if (!strncmp(u,
s1,
l)) {
156 if (
s1(0) ==
'/' &&
s1(
l-1) ==
'/') {
167 if (!strncmp(u+
l,
"//", 2))
184 if ((s = strstr(u,
":/")) && u+1 != s) {
186 Error(
"TUrl",
"%s malformed, URL must contain \"://\"", u0);
198 char *newu =
new char [strlen(
"file:") + strlen(u0) + 1];
199 sprintf(newu,
"file:%s", u0);
211 if ((s = strchr(t,
'@')) && (
212 ((
x = strchr(t,
'/')) && s <
x) ||
213 ((
x = strchr(t,
'?')) && s <
x) ||
214 ((
x = strchr(t,
'#')) && s <
x) ||
217 if (*(s-1) ==
'\\') {
223 if ((s2 = strchr(u,
':'))) {
241 if ((s = strchr(u,
':')) || (s = strchr(u,
'/')) || (s = strchr(u,
'?')) || (s = strchr(u,
'#'))) {
242 if ((strchr (u,
':') > strchr(u,
'/')) && (strchr (u,
'/')))
256 if ((s = strchr(u,
'/')) || (s = strchr(u,
'?')) || (s = strchr(u,
'#'))) {
271 if (!*s)
goto cleanup;
292 char *opt = strchr(u,
'?');
293 char *anc = strchr(u,
'#');
296 if (opt && anc && opt > anc) {
301 if ((s = opt) || (s = anc)) {
305 if (stripDoubleSlash)
316 if ((s = strchr(u,
'#'))) {
333 if (stripDoubleSlash)
437 passwd.ReplaceAll(
"@",
"\\@");
447 if (!deflt || withDeflt) {
449 sprintf(p,
"%d",
fPort);
525 if (setDefaultPort) {
551 if (
this == obj)
return 0;
552 if (TUrl::Class() != obj->IsA())
return -1;
575 static std::atomic_bool usedEnv = ATOMIC_VAR_INIT(
false);
601 const char *protos =
gEnv->
GetValue(
"Url.Special",
"file: hpss: dcache: dcap:");
608 if (
proto->String().IsNull()) {
661 if (!key)
return nullptr;
664 return option ? option->
GetName() :
nullptr;
676 return option ? atoi(option->
GetName()) : -1;
R__EXTERN TVirtualMutex * gROOTMutex
char * Strip(const char *str, char c=' ')
Strip leading and trailing c (blanks by default) from a string.
void Printf(const char *fmt,...)
char * StrDup(const char *str)
Duplicate the string str.
R__EXTERN TSystem * gSystem
#define R__LOCKGUARD(mutex)
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
TObject * FindObject(const char *name) const
Find object using its name.
void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
This class represents an Internet Protocol (IP) address.
const char * GetHostName() const
virtual void Add(TObject *obj)
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
void Add(TObject *obj)
This function may not be used (but we need to provide it since it is a pure virtual in TCollection).
virtual void SetOwnerKeyValue(Bool_t ownkeys=kTRUE, Bool_t ownvals=kTRUE)
Set ownership for keys and values.
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
TObject * FindObject(const char *keyname) const
Check if a (key,value) pair exists with keyname as name of the key.
The TNamed class is the base class for all named ROOT classes.
virtual const char * GetTitle() const
Returns title of object.
Int_t GetEntriesFast() const
TObject * UncheckedAt(Int_t i) const
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
TObject * At(Int_t idx) const
Collectable string class.
const TString & GetString() const
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
TObject & operator=(const TObject &rhs)
TObject assignment operator.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
TString & ReplaceAll(const TString &s1, const TString &s2)
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString & Remove(Ssiz_t pos)
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
virtual TInetAddress GetHostByName(const char *server)
Get Internet Protocol (IP) address of host.
This class represents a WWW compatible URL.
void CleanRelativePath()
Recompute the path removing all relative directory jumps via '..'.
static TObjArray * GetSpecialProtocols()
Read the list of special protocols from the rootrc files.
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
void FindFile(char *u, Bool_t stripDoubleSlash=kTRUE)
Find file and optionally anchor and options.
const char * GetFileAndOptions() const
Return the file and its options (the string specified behind the ?).
const char * GetValueFromOptions(const char *key) const
Return a value for a given key from the URL options.
void SetUrl(const char *url, Bool_t defaultIsFile=kFALSE)
Parse url character string and split in its different subcomponents.
void SetProtocol(const char *proto, Bool_t setDefaultPort=kFALSE)
Set protocol and, optionally, change the port accordingly.
TUrl & operator=(const TUrl &rhs)
TUrl assignment operator.
Int_t GetIntValueFromOptions(const char *key) const
Return a value for a given key from the URL options as an Int_t, a missing key returns -1.
Int_t Compare(const TObject *obj) const
Compare two urls as strings.
Int_t fPort
fully qualified host name
const char * GetHostFQDN() const
Return fully qualified domain name of url host.
void Print(Option_t *option="") const
Print URL on stdout.
static THashList * fgHostFQDNs
void ParseOptions() const
Parse URL options into a key/value map.
const char * GetOptions() const
TString fHostFQ
file with option and anchor
Bool_t HasOption(const char *key) const
Returns true if the given key appears in the URL options list.
static TObjArray * fgSpecialProtocols
map containing options key/value pairs