38#ifdef R__COMPLETE_MEM_TERMINATION
41 TObjArray **fSpecialProtocols;
42 THashList **fHostFQDNs;
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();
76 SetUrl(url, defaultIsFile);
78#ifdef R__COMPLETE_MEM_TERMINATION
112 if (!url || !url[0]) {
132 defaultIsFile =
kTRUE;
135 if (strlen(url) > 2 && url[1] ==
'/' && url[2] !=
'/') {
155 if (
s1.EndsWith(
"/-")) {
160 if (!strncmp(u,
s1,
l)) {
161 if (
s1(0) ==
'/' &&
s1(
l-1) ==
'/') {
172 if (!strncmp(u+
l,
"//", 2))
189 if ((s = strstr(u,
":/")) && u+1 != s) {
191 Error(
"TUrl",
"%s malformed, URL must contain \"://\"", u0);
203 const std::size_t bufferSize = std::char_traits<char>::length(
"file:") + strlen(u0) + 1;
204 char *newu =
new char [bufferSize];
205 snprintf(newu, bufferSize,
"file:%s", u0);
217 if ((s = strchr(t,
'@')) && (
218 ((
x = strchr(t,
'/')) && s <
x) ||
219 ((
x = strchr(t,
'?')) && s <
x) ||
220 ((
x = strchr(t,
'#')) && s <
x) ||
223 if (*(s-1) ==
'\\') {
229 if ((s2 = strchr(u,
':'))) {
236 fPasswd.ReplaceAll(
"\\@",
"@");
247 if ((s = strchr(u,
':')) || (s = strchr(u,
'/')) || (s = strchr(u,
'?')) || (s = strchr(u,
'#'))) {
248 if ((strchr (u,
':') > strchr(u,
'/')) && (strchr (u,
'/')))
262 if ((s = strchr(u,
'/')) || (s = strchr(u,
'?')) || (s = strchr(u,
'#'))) {
277 if (!*s)
goto cleanup;
281 if (*u ==
'/' &&
fHost.Length())
298 char *opt = strchr(u,
'?');
299 char *anc = strchr(u,
'#');
302 if (opt && anc && opt > anc) {
307 if ((s = opt) || (s = anc)) {
311 if (stripDoubleSlash)
312 fFile.ReplaceAll(
"//",
"/");
322 if ((s = strchr(u,
'#'))) {
339 if (stripDoubleSlash)
340 fFile.ReplaceAll(
"//",
"/");
442 passwd.ReplaceAll(
"@",
"\\@");
452 if (!deflt || withDeflt) {
468 fUrl.ReplaceAll(
"////",
"///");
530 if (setDefaultPort) {
554 if (
this == obj)
return 0;
578 static std::atomic_bool usedEnv {
false };
604 const char *protos =
gEnv->GetValue(
"Url.Special",
"file: hpss: dcache: dcap:");
611 if (
proto->String().IsNull()) {
664 if (!key)
return nullptr;
667 return option ? option->
GetName() :
nullptr;
679 return option ? atoi(option->
GetName()) : -1;
int Int_t
Signed integer 4 bytes (int).
int Ssiz_t
String size (currently int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
const char Option_t
Option string (const char).
externTVirtualMutex * gROOTMutex
char * Strip(const char *str, char c=' ')
Strip leading and trailing c (blanks by default) from a string.
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
char * StrDup(const char *str)
Duplicate the string str.
#define R__LOCKGUARD(mutex)
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
This class represents an Internet Protocol (IP) address.
const char * GetHostName() const
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
The TNamed class is the base class for all named ROOT classes.
const char * GetTitle() const override
Returns title of object.
Int_t GetEntriesFast() const
void Delete(Option_t *option="") override
Remove all objects from the array AND delete all heap based objects.
TObject * At(Int_t idx) const override
TObject * UncheckedAt(Int_t i) const
Collectable string class.
const TString & GetString() const
TObject & operator=(const TObject &rhs) noexcept
TObject assignment operator.
Bool_t TestBit(UInt_t f) const
virtual const char * GetName() const
Returns name of object.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual TClass * IsA() const
TObject()
TObject constructor.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
const char * Data() const
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
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 ?).
TString fFileOA
!file with option and anchor
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.
TMap * fOptionsMap
!map containing options key/value pairs
const char * GetHostFQDN() const
Return fully qualified domain name of url host.
void Print(Option_t *option="") const override
Print URL on stdout.
static THashList * fgHostFQDNs
void ParseOptions() const
Parse URL options into a key/value map.
const char * GetOptions() const
TString fHostFQ
!fully qualified host name
Bool_t HasOption(const char *key) const
Returns true if the given key appears in the URL options list.
static TObjArray * fgSpecialProtocols
Int_t Compare(const TObject *obj) const override
Compare two urls as strings.