Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
15This class represents a WWW compatible URL.
16It provides member functions to return the different parts of
17an 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
37
38#ifdef R__COMPLETE_MEM_TERMINATION
39namespace {
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
76TUrl::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
110void 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);
141tryfile:
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;
210again:
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
280cleanup:
281 delete [] u0;
282}
283
284////////////////////////////////////////////////////////////////////////////////
285/// Find file and optionally anchor and options.
286
287void 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
345TUrl::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) {
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
389const 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
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
471const char *TUrl::GetHostFQDN() const
472{
473 if (fHostFQ == "") {
474 // Check if we already resolved it
475 TNamed *fqdn = fgHostFQDNs ? (TNamed *) fgHostFQDNs->FindObject(fHost) : nullptr;
476 if (!fqdn) {
478 if (adr.IsValid()) {
479 fHostFQ = adr.GetHostName();
480 } else
481 fHostFQ = "-";
483 if (!fgHostFQDNs) {
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
503const 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
522void TUrl::SetProtocol(const char *proto, Bool_t setDefaultPort)
523{
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
549Int_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
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) {
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
597
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 : nullptr, " "));
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
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->GetEntriesFast(); 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->GetEntriesFast() == 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
659const 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
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
682Bool_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}
#define s1(x)
Definition RSha256.hxx:91
const Ssiz_t kNPOS
Definition RtypesCore.h:124
const Bool_t kFALSE
Definition RtypesCore.h:101
const Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:364
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
R__EXTERN TVirtualMutex * gROOTMutex
Definition TROOT.h:63
char * Strip(const char *str, char c=' ')
Strip leading and trailing c (blanks by default) from a string.
Definition TString.cxx:2479
void Printf(const char *fmt,...)
char * StrDup(const char *str)
Duplicate the string str.
Definition TString.cxx:2515
R__EXTERN TSystem * gSystem
Definition TSystem.h:559
#define R__LOCKGUARD(mutex)
const char * proto
Definition civetweb.c:16613
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:491
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition THashList.h:34
TObject * FindObject(const char *name) const
Find object using its name.
void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
This class represents an Internet Protocol (IP) address.
const char * GetHostName() const
Bool_t IsValid() const
virtual void Add(TObject *obj)
Definition TList.h:81
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition TMap.h:40
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
virtual void SetOwnerKeyValue(Bool_t ownkeys=kTRUE, Bool_t ownvals=kTRUE)
Set ownership for keys and values.
Definition TMap.cxx:352
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
Definition TMap.cxx:236
TObject * FindObject(const char *keyname) const
Check if a (key,value) pair exists with keyname as name of the key.
Definition TMap.cxx:215
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
virtual const char * GetTitle() const
Returns title of object.
Definition TNamed.h:48
An array of TObjects.
Definition TObjArray.h:31
Int_t GetEntriesFast() const
Definition TObjArray.h:58
void Add(TObject *obj)
Definition TObjArray.h:68
TObject * UncheckedAt(Int_t i) const
Definition TObjArray.h:84
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
TObject * At(Int_t idx) const
Definition TObjArray.h:164
Collectable string class.
Definition TObjString.h:28
const TString & GetString() const
Definition TObjString.h:46
TString & String()
Definition TObjString.h:48
Mother of all ROOT objects.
Definition TObject.h:41
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:429
TObject & operator=(const TObject &rhs)
TObject assignment operator.
Definition TObject.h:298
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:201
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:963
void ResetBit(UInt_t f)
Definition TObject.h:200
Basic string class.
Definition TString.h:136
Ssiz_t Length() const
Definition TString.h:410
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Definition TString.cxx:442
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:692
@ kTrailing
Definition TString.h:267
@ kExact
Definition TString.h:268
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Definition TString.cxx:2222
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition TString.h:615
Bool_t IsNull() const
Definition TString.h:407
TString & Remove(Ssiz_t pos)
Definition TString.h:673
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:639
virtual TInetAddress GetHostByName(const char *server)
Get Internet Protocol (IP) address of host.
Definition TSystem.cxx:2297
This class represents a WWW compatible URL.
Definition TUrl.h:33
TString fUrl
Definition TUrl.h:36
TString fAnchor
Definition TUrl.h:42
void CleanRelativePath()
Recompute the path removing all relative directory jumps via '..'.
Definition TUrl.cxx:693
static TObjArray * GetSpecialProtocols()
Read the list of special protocols from the rootrc files.
Definition TUrl.cxx:573
@ kUrlWithDefaultPort
Definition TUrl.h:54
@ kUrlHasDefaultPort
Definition TUrl.h:54
TUrl()
Definition TUrl.h:57
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
Definition TUrl.cxx:389
TString fHost
Definition TUrl.h:40
void FindFile(char *u, Bool_t stripDoubleSlash=kTRUE)
Find file and optionally anchor and options.
Definition TUrl.cxx:287
const char * GetFileAndOptions() const
Return the file and its options (the string specified behind the ?).
Definition TUrl.cxx:503
TString fPasswd
Definition TUrl.h:39
TString fFileOA
Definition TUrl.h:44
const char * GetValueFromOptions(const char *key) const
Return a value for a given key from the URL options.
Definition TUrl.cxx:659
void SetUrl(const char *url, Bool_t defaultIsFile=kFALSE)
Parse url character string and split in its different subcomponents.
Definition TUrl.cxx:110
void SetProtocol(const char *proto, Bool_t setDefaultPort=kFALSE)
Set protocol and, optionally, change the port accordingly.
Definition TUrl.cxx:522
TString fOptions
Definition TUrl.h:43
TUrl & operator=(const TUrl &rhs)
TUrl assignment operator.
Definition TUrl.cxx:364
Bool_t IsValid() const
Definition TUrl.h:79
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 fProtocol
Definition TUrl.h:37
Int_t Compare(const TObject *obj) const
Compare two urls as strings.
Definition TUrl.cxx:549
TMap * fOptionsMap
Definition TUrl.h:47
Int_t fPort
fully qualified host name
Definition TUrl.h:46
const char * GetHostFQDN() const
Return fully qualified domain name of url host.
Definition TUrl.cxx:471
TString fFile
Definition TUrl.h:41
void Print(Option_t *option="") const
Print URL on stdout.
Definition TUrl.cxx:559
static THashList * fgHostFQDNs
Definition TUrl.h:50
void ParseOptions() const
Parse URL options into a key/value map.
Definition TUrl.cxx:625
const char * GetOptions() const
Definition TUrl.h:71
virtual ~TUrl()
Cleanup.
Definition TUrl.cxx:88
TString fHostFQ
file with option and anchor
Definition TUrl.h:45
TString fUser
Definition TUrl.h:38
Bool_t HasOption(const char *key) const
Returns true if the given key appears in the URL options list.
Definition TUrl.cxx:682
static TObjArray * fgSpecialProtocols
map containing options key/value pairs
Definition TUrl.h:49
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
TCanvas * slash()
Definition slash.C:1
auto * l
Definition textangle.C:4