Logo ROOT  
Reference Guide
TUrl.cxx
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Fons Rademakers 17/01/97
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 /** \class TUrl
13 \ingroup Base
14 
15 This class represents a WWW compatible URL.
16 It provides member functions to return the different parts of
17 an URL. The supported url format is:
18 ~~~ {.cpp}
19  [proto://][user[:passwd]@]host[:port]/file.ext[#anchor][?options]
20 ~~~
21 */
22 
23 #include <stdlib.h>
24 #include "TUrl.h"
25 #include "THashList.h"
26 #include "TObjArray.h"
27 #include "TObjString.h"
28 #include "TEnv.h"
29 #include "TSystem.h"
30 #include "TMap.h"
31 #include "TROOT.h"
32 
33 #include <atomic>
34 
36 THashList *TUrl::fgHostFQDNs = nullptr;
37 
38 #ifdef R__COMPLETE_MEM_TERMINATION
39 namespace {
40  class TUrlCleanup {
41  TObjArray **fSpecialProtocols;
42  THashList **fHostFQDNs;
43  public:
44  TUrlCleanup(TObjArray **protocols, THashList **hosts) : fSpecialProtocols(protocols),fHostFQDNs(hosts) {}
45  ~TUrlCleanup() {
46  if (*fSpecialProtocols) (*fSpecialProtocols)->Delete();
47  delete *fSpecialProtocols;
48  *fSpecialProtocols = 0;
49  if (*fHostFQDNs) (*fHostFQDNs)->Delete();
50  delete *fHostFQDNs;
51  *fHostFQDNs = 0;
52  }
53  };
54 }
55 #endif
56 
57 ClassImp(TUrl);
58 
59 ////////////////////////////////////////////////////////////////////////////////
60 /// Parse url character string and split in its different subcomponents.
61 /// Use IsValid() to check if URL is legal.
62 /// ~~~ {.cpp}
63 /// url: [proto://][user[:passwd]@]host[:port]/file.ext[?options][#anchor]
64 /// ~~~
65 /// Known protocols: http, root, proof, ftp, news and any special protocols
66 /// defined in the rootrc Url.Special key.
67 /// The default protocol is "http", unless defaultIsFile is true in which
68 /// case the url is assumed to be of type "file".
69 /// If a passwd contains a @ it must be escaped by a \\, e.g.
70 /// "pip@" becomes "pip\\@".
71 ///
72 /// Default ports: http=80, root=1094, proof=1093, ftp=20, news=119.
73 /// Port #1093 has been assigned by IANA (www.iana.org) to proofd.
74 /// Port #1094 has been assigned by IANA (www.iana.org) to rootd.
75 
76 TUrl::TUrl(const char *url, Bool_t defaultIsFile)
77 {
78  SetUrl(url, defaultIsFile);
79 
80 #ifdef R__COMPLETE_MEM_TERMINATION
81  static TUrlCleanup cleanup(&fgSpecialProtocols,&fgHostFQDNs);
82 #endif
83 }
84 
85 ////////////////////////////////////////////////////////////////////////////////
86 /// Cleanup.
87 
89 {
90  delete fOptionsMap;
91 }
92 
93 ////////////////////////////////////////////////////////////////////////////////
94 /// Parse url character string and split in its different subcomponents.
95 /// Use IsValid() to check if URL is legal.
96 ///~~~ {.cpp}
97 /// url: [proto://][user[:passwd]@]host[:port]/file.ext[?options][#anchor]
98 ///~~~
99 /// Known protocols: http, root, proof, ftp, news and any special protocols
100 /// defined in the rootrc Url.Special key.
101 /// The default protocol is "http", unless defaultIsFile is true in which
102 /// case the url is assumed to be of type "file".
103 /// If a passwd contains a @ it must be escaped by a \\, e.g.
104 /// "pip@" becomes "pip\\@".
105 ///
106 /// Default ports: http=80, root=1094, proof=1093, ftp=20, news=119.
107 /// Port #1093 has been assigned by IANA (www.iana.org) to proofd.
108 /// Port #1094 has been assigned by IANA (www.iana.org) to rootd.
109 
110 void TUrl::SetUrl(const char *url, Bool_t defaultIsFile)
111 {
112  delete fOptionsMap;
113  fOptionsMap = nullptr;
114 
115  if (!url || !url[0]) {
116  fPort = -1;
117  return;
118  }
119 
120  // Set defaults
121  fUrl = "";
122  fProtocol = "http";
123  fUser = "";
124  fPasswd = "";
125  fHost = "";
126  fPort = 80;
127  fFile = "";
128  fAnchor = "";
129  fOptions = "";
130  fFileOA = "";
131  fHostFQ = "";
132 
133  // if url starts with a / consider it as a file url
134  if (url[0] == '/')
135  defaultIsFile = kTRUE;
136 
137  // Find protocol
138  char *s, sav;
139 
140  char *u, *u0 = Strip(url);
141 tryfile:
142  u = u0;
143 
144  // Handle special protocol cases: "file:", etc.
145  for (int i = 0; i < GetSpecialProtocols()->GetEntriesFast(); i++) {
147  TString s1 = os->GetString();
148  int l = s1.Length();
149  Bool_t stripoff = kFALSE;
150  if (s1.EndsWith("/-")) {
151  stripoff = kTRUE;
152  s1 = s1.Strip(TString::kTrailing, '-');
153  l--;
154  }
155  if (!strncmp(u, s1, l)) {
156  if (s1(0) == '/' && s1(l-1) == '/') {
157  // case with file namespace like: /alien/user/file.root
158  fProtocol = s1(1, l-2);
159  if (stripoff)
160  l--; // strip off namespace prefix from file name
161  else
162  l = 0; // leave namespace prefix as part of file name
163  } else {
164  // case with protocol, like: file:/data/file.root
165  fProtocol = s1(0, l-1);
166  }
167  if (!strncmp(u+l, "//", 2))
168  u += l+2;
169  else
170  u += l;
171  fPort = 0;
172 
173  FindFile(u, kFALSE);
174 
175  delete [] u0;
176  return;
177  }
178  }
179 
180  u = u0;
181 
182  char *x, *t, *s2;
183  // allow x:/path as Windows filename
184  if ((s = strstr(u, ":/")) && u+1 != s) {
185  if (*(s+2) != '/') {
186  Error("TUrl", "%s malformed, URL must contain \"://\"", u0);
187  fPort = -1;
188  goto cleanup;
189  }
190  sav = *s;
191  *s = 0;
192  SetProtocol(u, kTRUE);
193  *s = sav;
194  s += 3;
195  // allow url of form: "proto://"
196  } else {
197  if (defaultIsFile) {
198  char *newu = new char [strlen("file:") + strlen(u0) + 1];
199  sprintf(newu, "file:%s", u0);
200  delete [] u0;
201  u0 = newu;
202  goto tryfile;
203  }
204  s = u;
205  }
206 
207  // Find user and passwd
208  u = s;
209  t = s;
210 again:
211  if ((s = strchr(t, '@')) && (
212  ((x = strchr(t, '/')) && s < x) ||
213  ((x = strchr(t, '?')) && s < x) ||
214  ((x = strchr(t, '#')) && s < x) ||
215  (!strchr(t, '/'))
216  )) {
217  if (*(s-1) == '\\') {
218  t = s+1;
219  goto again;
220  }
221  sav = *s;
222  *s = 0;
223  if ((s2 = strchr(u, ':'))) {
224  *s2 = 0;
225  fUser = u;
226  *s2 = ':';
227  s2++;
228  if (*s2) {
229  fPasswd = s2;
230  fPasswd.ReplaceAll("\\@", "@");
231  }
232  } else
233  fUser = u;
234  *s = sav;
235  s++;
236  } else
237  s = u;
238 
239  // Find host
240  u = s;
241  if ((s = strchr(u, ':')) || (s = strchr(u, '/')) || (s = strchr(u, '?')) || (s = strchr(u, '#'))) {
242  if ((strchr (u, ':') > strchr(u, '/')) && (strchr (u, '/')))
243  s = strchr(u, '/');
244  sav = *s;
245  *s = 0;
246  fHost = u;
247  *s = sav;
248  if (sav == ':') {
249  s++;
250  // Get port #
251  if (!*s) {
252  fPort = -1;
253  goto cleanup;
254  }
255  u = s;
256  if ((s = strchr(u, '/')) || (s = strchr(u, '?')) || (s = strchr(u, '#'))) {
257  sav = *s;
258  *s = 0;
259  fPort = atoi(u);
260  *s = sav;
261  } else {
262  fPort = atoi(u);
263  goto cleanup;
264  }
265  }
266  } else {
267  fHost = u;
268  goto cleanup;
269  }
270 
271  if (!*s) goto cleanup;
272 
273  // Find file
274  u = s;
275  if (*u == '/' && fHost.Length())
276  u++;
277 
278  FindFile(u);
279 
280 cleanup:
281  delete [] u0;
282 }
283 
284 ////////////////////////////////////////////////////////////////////////////////
285 /// Find file and optionally anchor and options.
286 
287 void TUrl::FindFile(char *u, Bool_t stripDoubleSlash)
288 {
289  char *s, sav;
290 
291  // Locate anchor and options, if any
292  char *opt = strchr(u, '?');
293  char *anc = strchr(u, '#');
294 
295  // URL invalid if anchor is coming before the options
296  if (opt && anc && opt > anc) {
297  fPort = -1;
298  return;
299  }
300 
301  if ((s = opt) || (s = anc)) {
302  sav = *s;
303  *s = 0;
304  fFile = u;
305  if (stripDoubleSlash)
306  fFile.ReplaceAll("//", "/");
307  *s = sav;
308  s++;
309  if (sav == '?') {
310  // Get options
311  if (!*s) {
312  // options string is empty
313  return;
314  }
315  u = s;
316  if ((s = strchr(u, '#'))) {
317  sav = *s;
318  *s = 0;
319  fOptions = u;
320  *s = sav;
321  s++;
322  } else {
323  fOptions = u;
324  return;
325  }
326  }
327  if (!*s) {
328  // anchor string is empty
329  return;
330  }
331  } else {
332  fFile = u;
333  if (stripDoubleSlash)
334  fFile.ReplaceAll("//", "/");
335  return;
336  }
337 
338  // Set anchor
339  fAnchor = s;
340 }
341 
342 ////////////////////////////////////////////////////////////////////////////////
343 /// TUrl copy ctor.
344 
345 TUrl::TUrl(const TUrl &url) : TObject(url)
346 {
347  fUrl = url.fUrl;
348  fProtocol = url.fProtocol;
349  fUser = url.fUser;
350  fPasswd = url.fPasswd;
351  fHost = url.fHost;
352  fFile = url.fFile;
353  fAnchor = url.fAnchor;
354  fOptions = url.fOptions;
355  fPort = url.fPort;
356  fFileOA = url.fFileOA;
357  fHostFQ = url.fHostFQ;
358  fOptionsMap = nullptr;
359 }
360 
361 ////////////////////////////////////////////////////////////////////////////////
362 /// TUrl assignment operator.
363 
365 {
366  if (this != &rhs) {
367  TObject::operator=(rhs);
368  fUrl = rhs.fUrl;
369  fProtocol = rhs.fProtocol;
370  fUser = rhs.fUser;
371  fPasswd = rhs.fPasswd;
372  fHost = rhs.fHost;
373  fFile = rhs.fFile;
374  fAnchor = rhs.fAnchor;
375  fOptions = rhs.fOptions;
376  fPort = rhs.fPort;
377  fFileOA = rhs.fFileOA;
378  fHostFQ = rhs.fHostFQ;
379  delete fOptionsMap;
380  fOptionsMap = nullptr;
381  }
382  return *this;
383 }
384 
385 ////////////////////////////////////////////////////////////////////////////////
386 /// Return full URL. If withDflt is kTRUE, explicitly add the port even
387 /// if it matches the default value for the URL protocol.
388 
389 const char *TUrl::GetUrl(Bool_t withDeflt) const
390 {
391  if (((TestBit(kUrlWithDefaultPort) && !withDeflt) ||
392  (!TestBit(kUrlWithDefaultPort) && withDeflt)) &&
394  fUrl = "";
395 
396  if (IsValid() && fUrl == "") {
397  // Handle special protocol cases: file:, etc.
398  for (int i = 0; i < GetSpecialProtocols()->GetEntriesFast(); i++) {
400  TString &s = os->String();
401  int l = s.Length();
402  if (fProtocol == s(0, l-1)) {
403  if (fFile[0] == '/')
404  fUrl = fProtocol + "://" + fFile;
405  else
406  fUrl = fProtocol + ":" + fFile;
407  if (fOptions != "") {
408  fUrl += "?";
409  fUrl += fOptions;
410  }
411  if (fAnchor != "") {
412  fUrl += "#";
413  fUrl += fAnchor;
414  }
415  return fUrl;
416  }
417  }
418 
419  Bool_t deflt = kFALSE;
420  if ((!fProtocol.CompareTo("http") && fPort == 80) ||
421  (fProtocol.BeginsWith("proof") && fPort == 1093) ||
422  (fProtocol.BeginsWith("root") && fPort == 1094) ||
423  (!fProtocol.CompareTo("ftp") && fPort == 20) ||
424  (!fProtocol.CompareTo("news") && fPort == 119) ||
425  (!fProtocol.CompareTo("https") && fPort == 443) ||
426  fPort == 0) {
427  deflt = kTRUE;
428  ((TUrl *)this)->SetBit(kUrlHasDefaultPort);
429  }
430 
431  fUrl = fProtocol + "://";
432  if (fUser != "") {
433  fUrl += fUser;
434  if (fPasswd != "") {
435  fUrl += ":";
437  passwd.ReplaceAll("@", "\\@");
438  fUrl += passwd;
439  }
440  fUrl += "@";
441  }
442  if (withDeflt)
443  ((TUrl*)this)->SetBit(kUrlWithDefaultPort);
444  else
445  ((TUrl*)this)->ResetBit(kUrlWithDefaultPort);
446 
447  if (!deflt || withDeflt) {
448  char p[10];
449  sprintf(p, "%d", fPort);
450  fUrl = fUrl + fHost + ":" + p + "/" + fFile;
451  } else
452  fUrl = fUrl + fHost + "/" + fFile;
453  if (fOptions != "") {
454  fUrl += "?";
455  fUrl += fOptions;
456  }
457  if (fAnchor != "") {
458  fUrl += "#";
459  fUrl += fAnchor;
460  }
461  }
462 
463  fUrl.ReplaceAll("////", "///");
464  return fUrl;
465 }
466 
467 ////////////////////////////////////////////////////////////////////////////////
468 /// Return fully qualified domain name of url host. If host cannot be
469 /// resolved or not valid return the host name as originally specified.
470 
471 const char *TUrl::GetHostFQDN() const
472 {
473  if (fHostFQ == "") {
474  // Check if we already resolved it
475  TNamed *fqdn = fgHostFQDNs ? (TNamed *) fgHostFQDNs->FindObject(fHost) : 0;
476  if (!fqdn) {
478  if (adr.IsValid()) {
479  fHostFQ = adr.GetHostName();
480  } else
481  fHostFQ = "-";
483  if (!fgHostFQDNs) {
484  fgHostFQDNs = new THashList;
486  }
489  } else {
490  fHostFQ = fqdn->GetTitle();
491  }
492  }
493  if (fHostFQ == "-")
494  return fHost;
495  return fHostFQ;
496 }
497 
498 ////////////////////////////////////////////////////////////////////////////////
499 /// Return the file and its options (the string specified behind the ?).
500 /// Convenience function useful when the option is used to pass
501 /// authentication/access information for the specified file.
502 
503 const char *TUrl::GetFileAndOptions() const
504 {
505  if (fFileOA == "") {
506  fFileOA = fFile;
507  if (fOptions != "") {
508  fFileOA += "?";
509  fFileOA += fOptions;
510  }
511  if (fAnchor != "") {
512  fFileOA += "#";
513  fFileOA += fAnchor;
514  }
515  }
516  return fFileOA;
517 }
518 
519 ////////////////////////////////////////////////////////////////////////////////
520 /// Set protocol and, optionally, change the port accordingly.
521 
522 void TUrl::SetProtocol(const char *proto, Bool_t setDefaultPort)
523 {
524  fProtocol = proto;
525  if (setDefaultPort) {
526  if (!fProtocol.CompareTo("http"))
527  fPort = 80;
528  else if (!fProtocol.CompareTo("https"))
529  fPort = 443;
530  else if (fProtocol.BeginsWith("proof")) // can also be proofs or proofk
531  fPort = 1093;
532  else if (fProtocol.BeginsWith("root")) // can also be roots or rootk
533  fPort = 1094;
534  else if (!fProtocol.CompareTo("ftp"))
535  fPort = 20;
536  else if (!fProtocol.CompareTo("news"))
537  fPort = 119;
538  else {
539  // generic protocol (no default port)
540  fPort = 0;
541  }
542  }
543  fUrl = "";
544 }
545 
546 ////////////////////////////////////////////////////////////////////////////////
547 /// Compare two urls as strings.
548 
549 Int_t TUrl::Compare(const TObject *obj) const
550 {
551  if (this == obj) return 0;
552  if (TUrl::Class() != obj->IsA()) return -1;
553  return TString(GetUrl()).CompareTo(((TUrl*)obj)->GetUrl(), TString::kExact);
554 }
555 
556 ////////////////////////////////////////////////////////////////////////////////
557 /// Print URL on stdout.
558 
559 void TUrl::Print(Option_t *) const
560 {
561  if (fPort == -1)
562  Printf("Illegal URL");
563 
564  Printf("%s", GetUrl());
565 }
566 
567 ////////////////////////////////////////////////////////////////////////////////
568 /// Read the list of special protocols from the rootrc files.
569 /// These protocols will be parsed in a protocol and a file part,
570 /// no host or other info will be determined. This is typically
571 /// used for legacy file descriptions like: file:/path/file.root.
572 
574 {
575  static std::atomic_bool usedEnv = ATOMIC_VAR_INIT(false);
576 
577  if (!gEnv) {
579  if (!fgSpecialProtocols)
582  fgSpecialProtocols->Add(new TObjString("file:"));
583  return fgSpecialProtocols;
584  }
585 
586  if (usedEnv)
587  return fgSpecialProtocols;
588 
590 
591  // Some other thread might have set it up in the meantime.
592  if (usedEnv)
593  return fgSpecialProtocols;
594 
595  if (fgSpecialProtocols)
597 
598  if (!fgSpecialProtocols)
600 
601  const char *protos = gEnv->GetValue("Url.Special", "file: hpss: dcache: dcap:");
602 
603  if (protos) {
604  Int_t cnt = 0;
605  char *p = StrDup(protos);
606  while (1) {
607  TObjString *proto = new TObjString(strtok(!cnt ? p : 0, " "));
608  if (proto->String().IsNull()) {
609  delete proto;
610  break;
611  }
613  cnt++;
614  }
615  delete [] p;
616  }
617  usedEnv = true;
618  return fgSpecialProtocols;
619 }
620 
621 
622 ////////////////////////////////////////////////////////////////////////////////
623 /// Parse URL options into a key/value map.
624 
625 void TUrl::ParseOptions() const
626 {
627  if (fOptionsMap) return;
628 
629  TString urloptions = GetOptions();
630  if (urloptions.IsNull())
631  return;
632 
633  TObjArray *objOptions = urloptions.Tokenize("&");
634  for (Int_t n = 0; n < objOptions->GetEntries(); n++) {
635  TString loption = ((TObjString *) objOptions->At(n))->GetName();
636  TObjArray *objTags = loption.Tokenize("=");
637  if (!fOptionsMap) {
638  fOptionsMap = new TMap;
640  }
641  if (objTags->GetEntries() == 2) {
642  TString key = ((TObjString *) objTags->At(0))->GetName();
643  TString value = ((TObjString *) objTags->At(1))->GetName();
644  fOptionsMap->Add(new TObjString(key), new TObjString(value));
645  } else {
646  TString key = ((TObjString *) objTags->At(0))->GetName();
647  fOptionsMap->Add(new TObjString(key), nullptr);
648  }
649  delete objTags;
650  }
651  delete objOptions;
652 }
653 
654 
655 ////////////////////////////////////////////////////////////////////////////////
656 /// Return a value for a given key from the URL options.
657 /// Returns 0 in case key is not found.
658 
659 const char *TUrl::GetValueFromOptions(const char *key) const
660 {
661  if (!key) return nullptr;
662  ParseOptions();
663  TObject *option = fOptionsMap ? fOptionsMap->GetValue(key) : nullptr;
664  return option ? option->GetName() : nullptr;
665 }
666 
667 ////////////////////////////////////////////////////////////////////////////////
668 /// Return a value for a given key from the URL options as an Int_t,
669 /// a missing key returns -1.
670 
671 Int_t TUrl::GetIntValueFromOptions(const char *key) const
672 {
673  if (!key) return -1;
674  ParseOptions();
675  TObject *option = fOptionsMap ? fOptionsMap->GetValue(key) : nullptr;
676  return option ? atoi(option->GetName()) : -1;
677 }
678 
679 ////////////////////////////////////////////////////////////////////////////////
680 /// Returns true if the given key appears in the URL options list.
681 
682 Bool_t TUrl::HasOption(const char *key) const
683 {
684  if (!key) return kFALSE;
685  ParseOptions();
686 
687  return fOptionsMap && fOptionsMap->FindObject(key);
688 }
689 
690 ////////////////////////////////////////////////////////////////////////////////
691 /// Recompute the path removing all relative directory jumps via '..'.
692 
694 {
695  Ssiz_t slash = 0;
696  while ( (slash = fFile.Index("/..") ) != kNPOS) {
697  // find backwards the next '/'
698  Bool_t found = kFALSE;
699  for (int l = slash-1; l >=0; l--) {
700  if (fFile[l] == '/') {
701  // found previous '/'
702  fFile.Remove(l, slash+3-l);
703  found = kTRUE;
704  break;
705  }
706  }
707  if (!found)
708  break;
709  }
710 }
l
auto * l
Definition: textangle.C:4
n
const Int_t n
Definition: legend1.C:16
TUrl::fUser
TString fUser
Definition: TUrl.h:38
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TObjArray::Delete
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
Definition: TObjArray.cxx:356
TObject::TestBit
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
TUrl::fPort
Int_t fPort
fully qualified host name
Definition: TUrl.h:46
TObjArray
An array of TObjects.
Definition: TObjArray.h:37
TUrl::GetValueFromOptions
const char * GetValueFromOptions(const char *key) const
Return a value for a given key from the URL options.
Definition: TUrl.cxx:659
TUrl::fFileOA
TString fFileOA
Definition: TUrl.h:44
Option_t
const char Option_t
Definition: RtypesCore.h:66
kNPOS
const Ssiz_t kNPOS
Definition: RtypesCore.h:115
gEnv
R__EXTERN TEnv * gEnv
Definition: TEnv.h:171
TSystem::GetHostByName
virtual TInetAddress GetHostByName(const char *server)
Get Internet Protocol (IP) address of host.
Definition: TSystem.cxx:2295
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TNamed::GetTitle
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
TObjString.h
TInetAddress::GetHostName
const char * GetHostName() const
Definition: TInetAddress.h:71
TObject::Error
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:890
TCollection::SetOwner
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
Definition: TCollection.cxx:746
TUrl::fgSpecialProtocols
static TObjArray * fgSpecialProtocols
map containing options key/value pairs
Definition: TUrl.h:49
TUrl::Compare
Int_t Compare(const TObject *obj) const
Compare two urls as strings.
Definition: TUrl.cxx:549
TUrl::fProtocol
TString fProtocol
Definition: TUrl.h:37
TMap::GetValue
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
Definition: TMap.cxx:236
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:162
TObjString::GetString
const TString & GetString() const
Definition: TObjString.h:46
TMap::SetOwnerKeyValue
virtual void SetOwnerKeyValue(Bool_t ownkeys=kTRUE, Bool_t ownvals=kTRUE)
Set ownership for keys and values.
Definition: TMap.cxx:352
TObjArray::GetEntries
Int_t GetEntries() const
Return the number of objects in array (i.e.
Definition: TObjArray.cxx:523
x
Double_t x[n]
Definition: legend1.C:17
TString::Length
Ssiz_t Length() const
Definition: TString.h:410
TString::kExact
@ kExact
Definition: TString.h:268
TEnv::GetValue
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition: TEnv.cxx:491
passwd
Definition: TWinNTSystem.h:47
TObjArray::UncheckedAt
TObject * UncheckedAt(Int_t i) const
Definition: TObjArray.h:90
TObjArray::At
TObject * At(Int_t idx) const
Definition: TObjArray.h:166
TMap::Add
void Add(TObject *obj)
This function may not be used (but we need to provide it since it is a pure virtual in TCollection).
Definition: TMap.cxx:54
TEnv.h
TUrl::ParseOptions
void ParseOptions() const
Parse URL options into a key/value map.
Definition: TUrl.cxx:625
TString
Basic string class.
Definition: TString.h:136
TUrl::CleanRelativePath
void CleanRelativePath()
Recompute the path removing all relative directory jumps via '..'.
Definition: TUrl.cxx:693
TUrl::FindFile
void FindFile(char *u, Bool_t stripDoubleSlash=kTRUE)
Find file and optionally anchor and options.
Definition: TUrl.cxx:287
bool
TString::ReplaceAll
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:692
TObjArray::Add
void Add(TObject *obj)
Definition: TObjArray.h:74
TObjString::String
TString & String()
Definition: TObjString.h:48
TUrl::HasOption
Bool_t HasOption(const char *key) const
Returns true if the given key appears in the URL options list.
Definition: TUrl.cxx:682
TROOT.h
TUrl::fAnchor
TString fAnchor
Definition: TUrl.h:42
TObjString
Collectable string class.
Definition: TObjString.h:28
TUrl::kUrlWithDefaultPort
@ kUrlWithDefaultPort
Definition: TUrl.h:54
TObject::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:359
TUrl::fgHostFQDNs
static THashList * fgHostFQDNs
Definition: TUrl.h:50
TUrl::fOptions
TString fOptions
Definition: TUrl.h:43
TUrl::GetIntValueFromOptions
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.
Definition: TUrl.cxx:671
TString::Tokenize
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Definition: TString.cxx:2197
TObject::ResetBit
void ResetBit(UInt_t f)
Definition: TObject.h:171
slash
TCanvas * slash()
Definition: slash.C:1
TSystem.h
TString::kTrailing
@ kTrailing
Definition: TString.h:267
THashList
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:34
gROOTMutex
R__EXTERN TVirtualMutex * gROOTMutex
Definition: TROOT.h:61
THashList::FindObject
TObject * FindObject(const char *name) const
Find object using its name.
Definition: THashList.cxx:262
TObjArray::GetEntriesFast
Int_t GetEntriesFast() const
Definition: TObjArray.h:64
TString::Remove
TString & Remove(Ssiz_t pos)
Definition: TString.h:673
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
s1
#define s1(x)
Definition: RSha256.hxx:91
TMap::FindObject
TObject * FindObject(const char *keyname) const
Check if a (key,value) pair exists with keyname as name of the key.
Definition: TMap.cxx:215
TUrl::fOptionsMap
TMap * fOptionsMap
Definition: TUrl.h:47
StrDup
char * StrDup(const char *str)
Duplicate the string str.
Definition: TString.cxx:2490
R__LOCKGUARD
#define R__LOCKGUARD(mutex)
Definition: TVirtualMutex.h:104
TUrl::fFile
TString fFile
Definition: TUrl.h:41
TString::BeginsWith
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:615
TUrl::SetUrl
void SetUrl(const char *url, Bool_t defaultIsFile=kFALSE)
Parse url character string and split in its different subcomponents.
Definition: TUrl.cxx:110
TUrl::SetProtocol
void SetProtocol(const char *proto, Bool_t setDefaultPort=kFALSE)
Set protocol and, optionally, change the port accordingly.
Definition: TUrl.cxx:522
TUrl::GetUrl
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
Definition: TUrl.cxx:389
TUrl
This class represents a WWW compatible URL.
Definition: TUrl.h:33
THashList.h
THashList::Delete
void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: THashList.cxx:207
TString::Index
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:639
Printf
void Printf(const char *fmt,...)
gSystem
R__EXTERN TSystem * gSystem
Definition: TSystem.h:559
proto
const char * proto
Definition: civetweb.c:16604
TUrl::IsValid
Bool_t IsValid() const
Definition: TUrl.h:79
TUrl::fUrl
TString fUrl
Definition: TUrl.h:36
TString::CompareTo
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Definition: TString.cxx:418
TString::IsNull
Bool_t IsNull() const
Definition: TString.h:407
TObject::operator=
TObject & operator=(const TObject &rhs)
TObject assignment operator.
Definition: TObject.h:268
TObjArray.h
TUrl::fHost
TString fHost
Definition: TUrl.h:40
TList::Add
virtual void Add(TObject *obj)
Definition: TList.h:87
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
TMap.h
TUrl::TUrl
TUrl()
Definition: TUrl.h:57
TUrl::kUrlHasDefaultPort
@ kUrlHasDefaultPort
Definition: TUrl.h:54
TUrl::GetFileAndOptions
const char * GetFileAndOptions() const
Return the file and its options (the string specified behind the ?).
Definition: TUrl.cxx:503
TUrl::GetOptions
const char * GetOptions() const
Definition: TUrl.h:71
xmlio::cnt
const char * cnt
Definition: TXMLSetup.cxx:75
Class
void Class()
Definition: Class.C:29
TUrl::operator=
TUrl & operator=(const TUrl &rhs)
TUrl assignment operator.
Definition: TUrl.cxx:364
TInetAddress
This class represents an Internet Protocol (IP) address.
Definition: TInetAddress.h:36
TInetAddress::IsValid
Bool_t IsValid() const
Definition: TInetAddress.h:76
TUrl::Print
void Print(Option_t *option="") const
Print URL on stdout.
Definition: TUrl.cxx:559
TUrl::GetHostFQDN
const char * GetHostFQDN() const
Return fully qualified domain name of url host.
Definition: TUrl.cxx:471
TUrl.h
TUrl::fHostFQ
TString fHostFQ
file with option and anchor
Definition: TUrl.h:45
TUrl::fPasswd
TString fPasswd
Definition: TUrl.h:39
Strip
char * Strip(const char *str, char c=' ')
Strip leading and trailing c (blanks by default) from a string.
Definition: TString.cxx:2454
TUrl::~TUrl
virtual ~TUrl()
Cleanup.
Definition: TUrl.cxx:88
TUrl::GetSpecialProtocols
static TObjArray * GetSpecialProtocols()
Read the list of special protocols from the rootrc files.
Definition: TUrl.cxx:573
int
TMap
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition: TMap.h:40