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