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