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 81 static TUrlCleanup cleanup(&fgSpecialProtocols,&fgHostFQDNs);
114 if (!url || !url[0]) {
134 defaultIsFile =
kTRUE;
139 char *u, *u0 =
Strip(url);
144 for (
int i = 0; i < GetSpecialProtocols()->GetEntriesFast(); i++) {
154 if (!strncmp(u, s1, l)) {
155 if (s1(0) ==
'/' && s1(l-1) ==
'/') {
157 fProtocol = s1(1, l-2);
164 fProtocol = s1(0, l-1);
166 if (!strncmp(u+l,
"//", 2))
183 if ((s = strstr(u,
":/")) && u+1 != s) {
185 Error(
"TUrl",
"%s malformed, URL must contain \"://\"", u0);
191 SetProtocol(u,
kTRUE);
197 char *newu =
new char [strlen(
"file:") + strlen(u0) + 1];
198 sprintf(newu,
"file:%s", u0);
210 if ((s = strchr(t,
'@')) && (
211 ((x = strchr(t,
'/')) && s < x) ||
212 ((x = strchr(t,
'?')) && s < x) ||
213 ((x = strchr(t,
'#')) && s < x) ||
216 if (*(s-1) ==
'\\') {
222 if ((s2 = strchr(u,
':'))) {
229 fPasswd.ReplaceAll(
"\\@",
"@");
240 if ((s = strchr(u,
':')) || (s = strchr(u,
'/')) || (s = strchr(u,
'?')) || (s = strchr(u,
'#'))) {
241 if ((strchr (u,
':') > strchr(u,
'/')) && (strchr (u,
'/')))
255 if ((s = strchr(u,
'/')) || (s = strchr(u,
'?')) || (s = strchr(u,
'#'))) {
270 if (!*s)
goto cleanup;
274 if (*u ==
'/' && fHost.Length())
291 char *opt = strchr(u,
'?');
292 char *anc = strchr(u,
'#');
295 if (opt && anc && opt > anc) {
300 if ((s = opt) || (s = anc)) {
304 if (stripDoubleSlash)
305 fFile.ReplaceAll(
"//",
"/");
315 if ((s = strchr(u,
'#'))) {
332 if (stripDoubleSlash)
333 fFile.ReplaceAll(
"//",
"/");
445 if (!deflt || withDeflt) {
447 sprintf(p,
"%d",
fPort);
523 if (setDefaultPort) {
549 if (
this == obj)
return 0;
594 const char *protos =
gEnv->
GetValue(
"Url.Special",
"file: rfio: hpss: castor: dcache: dcap:");
691 for (
int l = slash-1;
l >=0;
l--) {
virtual const char * GetTitle() const
Returns title of object.
Bool_t HasOption(const char *key) const
Returns true if the given key appears in the URL options list.
static THashList * fgHostFQDNs
void SetProtocol(const char *proto, Bool_t setDefaultPort=kFALSE)
Set protocol and, optionally, change the port accordingly.
Collectable string class.
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
TObject * FindObject(const char *name) const
Find object using its name.
This class represents a WWW compatible URL.
TString & ReplaceAll(const TString &s1, const TString &s2)
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
void SetUrl(const char *url, Bool_t defaultIsFile=kFALSE)
Parse url character string and split in its different subcomponents.
This class represents an Internet Protocol (IP) address.
This class implements a mutex interface.
void Add(TObject *obj)
This function may not be used (but we need to provide it since it is a pure virtual in TCollection)...
void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Int_t GetEntriesFast() const
const char * GetOptions() const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString fHostFQ
file with option and anchor
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
The TNamed class is the base class for all named ROOT classes.
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...
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
TObject & operator=(const TObject &rhs)
TObject assignment operator.
virtual TInetAddress GetHostByName(const char *server)
Get Internet Protocol (IP) address of host.
void Error(const char *location, const char *msgfmt,...)
TObject * FindObject(const char *keyname) const
Check if a (key,value) pair exists with keyname as name of the key.
TObject * UncheckedAt(Int_t i) const
virtual void SetOwnerKeyValue(Bool_t ownkeys=kTRUE, Bool_t ownvals=kTRUE)
Set ownership for keys and values.
const char * GetValueFromOptions(const char *key) const
Return a value for a given key from the URL options.
TString GetString() const
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
R__EXTERN TSystem * gSystem
TUrl & operator=(const TUrl &rhs)
TUrl assignment operator.
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
char * Strip(const char *str, char c= ' ')
Strip leading and trailing c (blanks by default) from a string.
const char * GetHostFQDN() const
Return fully qualified domain name of url host.
Bool_t TestBit(UInt_t f) const
const char * GetFileAndOptions() const
Return the file and its options (the string specified behind the ?).
Int_t fPort
fully qualified host name
TSubString Strip(EStripType s=kTrailing, char c= ' ') const
Return a substring of self stripped at beginning and/or end.
static TObjArray * GetSpecialProtocols()
Read the list of special protocols from the rootrc files.
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
char * StrDup(const char *str)
Duplicate the string str.
#define R__LOCKGUARD2(mutex)
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
TString & Remove(Ssiz_t pos)
virtual const char * GetName() const
Returns name of object.
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
TVirtualMutex * gURLMutex
Int_t GetEntries() const
Return the number of objects in array (i.e.
Mother of all ROOT objects.
virtual void Add(TObject *obj)
void Print(Option_t *option="") const
Print URL on stdout.
static TObjArray * fgSpecialProtocols
map containing options key/value pairs
void ParseOptions() const
Parse URL options into a key/value map.
void FindFile(char *u, Bool_t stripDoubleSlash=kTRUE)
Find file and optionally anchor and options.
TObject * At(Int_t idx) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
void CleanRelativePath()
Recompute the path removing all relative directory jumps via '..'.
Int_t Compare(const TObject *obj) const
Compare two urls as strings.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.