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