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 {
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
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, 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, ftp=20, news=119.
73/// Port #1094 has been assigned by IANA (www.iana.org) to rootd.
74
76{
78
79#ifdef R__COMPLETE_MEM_TERMINATION
81#endif
82}
83
84////////////////////////////////////////////////////////////////////////////////
85/// Cleanup.
86
88{
89 delete fOptionsMap;
90}
91
92////////////////////////////////////////////////////////////////////////////////
93/// Parse url character string and split in its different subcomponents.
94/// Use IsValid() to check if URL is legal.
95///~~~ {.cpp}
96/// url: [proto://][user[:passwd]@]host[:port]/file.ext[?options][#anchor]
97///~~~
98/// Known protocols: http, root, ftp, news and any special protocols
99/// defined in the rootrc Url.Special key.
100/// The default protocol is "http", unless defaultIsFile is true in which
101/// case the url is assumed to be of type "file".
102/// If a passwd contains a @ it must be escaped by a \\, e.g.
103/// "pip@" becomes "pip\\@".
104///
105/// Default ports: http=80, root=1094, ftp=20, news=119.
106/// Port #1094 has been assigned by IANA (www.iana.org) to rootd.
107
109{
110 delete fOptionsMap;
111 fOptionsMap = nullptr;
112
113 if (!url || !url[0]) {
114 fPort = -1;
115 return;
116 }
117
118 // Set defaults
119 fUrl = "";
120 fProtocol = "http";
121 fUser = "";
122 fPasswd = "";
123 fHost = "";
124 fPort = 80;
125 fFile = "";
126 fAnchor = "";
127 fOptions = "";
128 fFileOA = "";
129 fHostFQ = "";
130
131 // if url starts with a / consider it as a file url
132 if (url[0] == '/') {
134 // ROOT-5430: if url starts with two slashes but
135 // not three slashes, just remove the first of them
136 if (strlen(url) > 2 && url[1] == '/' && url[2] != '/') {
137 url = &url[1];
138 }
139 }
140
141 // Find protocol
142 char *s, sav;
143
144 TString surl = url;
145
146 char *u, *u0 = Strip(defaultIsFile && surl.EndsWith(":/") ? TString(surl(0,surl.Length()-2)).Data() : url);
147tryfile:
148 u = u0;
149
150 // Handle special protocol cases: "file:", etc.
151 for (int i = 0; i < GetSpecialProtocols()->GetEntriesFast(); i++) {
152 TObjString *os = (TObjString*) GetSpecialProtocols()->UncheckedAt(i);
153 TString s1 = os->GetString();
154 int l = s1.Length();
156 if (s1.EndsWith("/-")) {
157 stripoff = kTRUE;
158 s1 = s1.Strip(TString::kTrailing, '-');
159 l--;
160 }
161 if (!strncmp(u, s1, l)) {
162 if (s1(0) == '/' && s1(l-1) == '/') {
163 // case with file namespace like: /alien/user/file.root
164 fProtocol = s1(1, l-2);
165 if (stripoff)
166 l--; // strip off namespace prefix from file name
167 else
168 l = 0; // leave namespace prefix as part of file name
169 } else {
170 // case with protocol, like: file:/data/file.root
171 fProtocol = s1(0, l-1);
172 }
173 if (!strncmp(u+l, "//", 2))
174 u += l+2;
175 else
176 u += l;
177 fPort = 0;
178
179 FindFile(u, kFALSE);
180
181 delete [] u0;
182 return;
183 }
184 }
185
186 u = u0;
187
188 char *x, *t, *s2;
189 // allow x:/path as Windows filename
190 if ((s = strstr(u, ":/")) && u+1 != s) {
191 if (*(s+2) != '/') {
192 Error("TUrl", "%s malformed, URL must contain \"://\"", u0);
193 fPort = -1;
194 goto cleanup;
195 }
196 sav = *s;
197 *s = 0;
199 *s = sav;
200 s += 3;
201 // allow url of form: "proto://"
202 } else {
203 if (defaultIsFile) {
204 const std::size_t bufferSize = std::char_traits<char>::length("file:") + strlen(u0) + 1;
205 char *newu = new char [bufferSize];
206 snprintf(newu, bufferSize, "file:%s", u0);
207 delete [] u0;
208 u0 = newu;
209 goto tryfile;
210 }
211 s = u;
212 }
213
214 // Find user and passwd
215 u = s;
216 t = s;
217again:
218 if ((s = strchr(t, '@')) && (
219 ((x = strchr(t, '/')) && s < x) ||
220 ((x = strchr(t, '?')) && s < x) ||
221 ((x = strchr(t, '#')) && s < x) ||
222 (!strchr(t, '/'))
223 )) {
224 if (*(s-1) == '\\') {
225 t = s+1;
226 goto again;
227 }
228 sav = *s;
229 *s = 0;
230 if ((s2 = strchr(u, ':'))) {
231 *s2 = 0;
232 fUser = u;
233 *s2 = ':';
234 s2++;
235 if (*s2) {
236 fPasswd = s2;
237 fPasswd.ReplaceAll("\\@", "@");
238 }
239 } else
240 fUser = u;
241 *s = sav;
242 s++;
243 } else
244 s = u;
245
246 // Find host
247 u = s;
248 if ((s = strchr(u, ':')) || (s = strchr(u, '/')) || (s = strchr(u, '?')) || (s = strchr(u, '#'))) {
249 if ((strchr (u, ':') > strchr(u, '/')) && (strchr (u, '/')))
250 s = strchr(u, '/');
251 sav = *s;
252 *s = 0;
253 fHost = u;
254 *s = sav;
255 if (sav == ':') {
256 s++;
257 // Get port #
258 if (!*s) {
259 fPort = -1;
260 goto cleanup;
261 }
262 u = s;
263 if ((s = strchr(u, '/')) || (s = strchr(u, '?')) || (s = strchr(u, '#'))) {
264 sav = *s;
265 *s = 0;
266 fPort = atoi(u);
267 *s = sav;
268 } else {
269 fPort = atoi(u);
270 goto cleanup;
271 }
272 }
273 } else {
274 fHost = u;
275 goto cleanup;
276 }
277
278 if (!*s) goto cleanup;
279
280 // Find file
281 u = s;
282 if (*u == '/' && fHost.Length())
283 u++;
284
285 FindFile(u);
286
287cleanup:
288 delete [] u0;
289}
290
291////////////////////////////////////////////////////////////////////////////////
292/// Find file and optionally anchor and options.
293
295{
296 char *s, sav;
297
298 // Locate anchor and options, if any
299 char *opt = strchr(u, '?');
300 char *anc = strchr(u, '#');
301
302 // URL invalid if anchor is coming before the options
303 if (opt && anc && opt > anc) {
304 fPort = -1;
305 return;
306 }
307
308 if ((s = opt) || (s = anc)) {
309 sav = *s;
310 *s = 0;
311 fFile = u;
313 fFile.ReplaceAll("//", "/");
314 *s = sav;
315 s++;
316 if (sav == '?') {
317 // Get options
318 if (!*s) {
319 // options string is empty
320 return;
321 }
322 u = s;
323 if ((s = strchr(u, '#'))) {
324 sav = *s;
325 *s = 0;
326 fOptions = u;
327 *s = sav;
328 s++;
329 } else {
330 fOptions = u;
331 return;
332 }
333 }
334 if (!*s) {
335 // anchor string is empty
336 return;
337 }
338 } else {
339 fFile = u;
341 fFile.ReplaceAll("//", "/");
342 return;
343 }
344
345 // Set anchor
346 fAnchor = s;
347}
348
349////////////////////////////////////////////////////////////////////////////////
350/// TUrl copy ctor.
351
353{
354 fUrl = url.fUrl;
355 fProtocol = url.fProtocol;
356 fUser = url.fUser;
357 fPasswd = url.fPasswd;
358 fHost = url.fHost;
359 fFile = url.fFile;
360 fAnchor = url.fAnchor;
361 fOptions = url.fOptions;
362 fPort = url.fPort;
363 fFileOA = url.fFileOA;
364 fHostFQ = url.fHostFQ;
365 fOptionsMap = nullptr;
366}
367
368////////////////////////////////////////////////////////////////////////////////
369/// TUrl assignment operator.
370
372{
373 if (this != &rhs) {
375 fUrl = rhs.fUrl;
376 fProtocol = rhs.fProtocol;
377 fUser = rhs.fUser;
378 fPasswd = rhs.fPasswd;
379 fHost = rhs.fHost;
380 fFile = rhs.fFile;
381 fAnchor = rhs.fAnchor;
382 fOptions = rhs.fOptions;
383 fPort = rhs.fPort;
384 fFileOA = rhs.fFileOA;
385 fHostFQ = rhs.fHostFQ;
386 delete fOptionsMap;
387 fOptionsMap = nullptr;
388 }
389 return *this;
390}
391
392////////////////////////////////////////////////////////////////////////////////
393/// Return full URL. If withDflt is kTRUE, explicitly add the port even
394/// if it matches the default value for the URL protocol.
395
396const char *TUrl::GetUrl(Bool_t withDeflt) const
397{
401 fUrl = "";
402
403 if (IsValid() && fUrl == "") {
404 // Handle special protocol cases: file:, etc.
405 for (int i = 0; i < GetSpecialProtocols()->GetEntriesFast(); i++) {
406 TObjString *os = (TObjString*) GetSpecialProtocols()->UncheckedAt(i);
407 TString &s = os->String();
408 int l = s.Length();
409 if (fProtocol == s(0, l-1)) {
410 if (fFile[0] == '/')
411 fUrl = fProtocol + "://" + fFile;
412 else
413 fUrl = fProtocol + ":" + fFile;
414 if (fOptions != "") {
415 fUrl += "?";
416 fUrl += fOptions;
417 }
418 if (fAnchor != "") {
419 fUrl += "#";
420 fUrl += fAnchor;
421 }
422 return fUrl;
423 }
424 }
425
427 if ((!fProtocol.CompareTo("http") && fPort == 80) ||
428 (fProtocol.BeginsWith("root") && fPort == 1094) ||
429 (!fProtocol.CompareTo("ftp") && fPort == 20) ||
430 (!fProtocol.CompareTo("news") && fPort == 119) ||
431 (!fProtocol.CompareTo("https") && fPort == 443) ||
432 fPort == 0) {
433 deflt = kTRUE;
434 ((TUrl *)this)->SetBit(kUrlHasDefaultPort);
435 }
436
437 fUrl = fProtocol + "://";
438 if (fUser != "") {
439 fUrl += fUser;
440 if (fPasswd != "") {
441 fUrl += ":";
443 passwd.ReplaceAll("@", "\\@");
444 fUrl += passwd;
445 }
446 fUrl += "@";
447 }
448 if (withDeflt)
449 ((TUrl*)this)->SetBit(kUrlWithDefaultPort);
450 else
452
453 if (!deflt || withDeflt) {
454 char p[10];
455 snprintf(p, 10, "%d", fPort);
456 fUrl = fUrl + fHost + ":" + p + "/" + fFile;
457 } else
458 fUrl = fUrl + fHost + "/" + fFile;
459 if (fOptions != "") {
460 fUrl += "?";
461 fUrl += fOptions;
462 }
463 if (fAnchor != "") {
464 fUrl += "#";
465 fUrl += fAnchor;
466 }
467 }
468
469 fUrl.ReplaceAll("////", "///");
470 return fUrl;
471}
472
473////////////////////////////////////////////////////////////////////////////////
474/// Return fully qualified domain name of url host. If host cannot be
475/// resolved or not valid return the host name as originally specified.
476
477const char *TUrl::GetHostFQDN() const
478{
479 if (fHostFQ == "") {
480 // Check if we already resolved it
481 TNamed *fqdn = fgHostFQDNs ? (TNamed *) fgHostFQDNs->FindObject(fHost) : nullptr;
482 if (!fqdn) {
484 if (adr.IsValid()) {
485 fHostFQ = adr.GetHostName();
486 } else
487 fHostFQ = "-";
489 if (!fgHostFQDNs) {
491 fgHostFQDNs->SetOwner();
492 }
493 if (fgHostFQDNs && !fgHostFQDNs->FindObject(fHost))
494 fgHostFQDNs->Add(new TNamed(fHost,fHostFQ));
495 } else {
496 fHostFQ = fqdn->GetTitle();
497 }
498 }
499 if (fHostFQ == "-")
500 return fHost;
501 return fHostFQ;
502}
503
504////////////////////////////////////////////////////////////////////////////////
505/// Return the file and its options (the string specified behind the ?).
506/// Convenience function useful when the option is used to pass
507/// authentication/access information for the specified file.
508
509const char *TUrl::GetFileAndOptions() const
510{
511 if (fFileOA == "") {
512 fFileOA = fFile;
513 if (fOptions != "") {
514 fFileOA += "?";
515 fFileOA += fOptions;
516 }
517 if (fAnchor != "") {
518 fFileOA += "#";
519 fFileOA += fAnchor;
520 }
521 }
522 return fFileOA;
523}
524
525////////////////////////////////////////////////////////////////////////////////
526/// Set protocol and, optionally, change the port accordingly.
527
529{
531 if (setDefaultPort) {
532 if (!fProtocol.CompareTo("http"))
533 fPort = 80;
534 else if (!fProtocol.CompareTo("https"))
535 fPort = 443;
536 else if (fProtocol.BeginsWith("root")) // can also be roots or rootk
537 fPort = 1094;
538 else if (!fProtocol.CompareTo("ftp"))
539 fPort = 20;
540 else if (!fProtocol.CompareTo("news"))
541 fPort = 119;
542 else {
543 // generic protocol (no default port)
544 fPort = 0;
545 }
546 }
547 fUrl = "";
548}
549
550////////////////////////////////////////////////////////////////////////////////
551/// Compare two urls as strings.
552
553Int_t TUrl::Compare(const TObject *obj) const
554{
555 if (this == obj) return 0;
556 if (TUrl::Class() != obj->IsA()) return -1;
557 return TString(GetUrl()).CompareTo(((TUrl*)obj)->GetUrl(), TString::kExact);
558}
559
560////////////////////////////////////////////////////////////////////////////////
561/// Print URL on stdout.
562
564{
565 if (fPort == -1)
566 Printf("Illegal URL");
567
568 Printf("%s", GetUrl());
569}
570
571////////////////////////////////////////////////////////////////////////////////
572/// Read the list of special protocols from the rootrc files.
573/// These protocols will be parsed in a protocol and a file part,
574/// no host or other info will be determined. This is typically
575/// used for legacy file descriptions like: file:/path/file.root.
576
578{
579 static std::atomic_bool usedEnv { false };
580
581 if (!gEnv) {
585 if (fgSpecialProtocols->GetEntriesFast() == 0)
586 fgSpecialProtocols->Add(new TObjString("file:"));
587 return fgSpecialProtocols;
588 }
589
590 if (usedEnv)
591 return fgSpecialProtocols;
592
594
595 // Some other thread might have set it up in the meantime.
596 if (usedEnv)
597 return fgSpecialProtocols;
598
600 fgSpecialProtocols->Delete();
601
604
605 const char *protos = gEnv->GetValue("Url.Special", "file: hpss: dcache: dcap:");
606
607 if (protos) {
608 Int_t cnt = 0;
609 char *p = StrDup(protos);
610 while (1) {
611 TObjString *proto = new TObjString(strtok(!cnt ? p : nullptr, " "));
612 if (proto->String().IsNull()) {
613 delete proto;
614 break;
615 }
617 cnt++;
618 }
619 delete [] p;
620 }
621 usedEnv = true;
622 return fgSpecialProtocols;
623}
624
625
626////////////////////////////////////////////////////////////////////////////////
627/// Parse URL options into a key/value map.
628
630{
631 if (fOptionsMap) return;
632
634 if (urloptions.IsNull())
635 return;
636
637 TObjArray *objOptions = urloptions.Tokenize("&");
638 for (Int_t n = 0; n < objOptions->GetEntriesFast(); n++) {
640 TObjArray *objTags = loption.Tokenize("=");
641 if (!fOptionsMap) {
642 fOptionsMap = new TMap;
644 }
645 if (objTags->GetEntriesFast() == 2) {
646 TString key = ((TObjString *) objTags->At(0))->GetName();
647 TString value = ((TObjString *) objTags->At(1))->GetName();
648 fOptionsMap->Add(new TObjString(key), new TObjString(value));
649 } else {
650 TString key = ((TObjString *) objTags->At(0))->GetName();
651 fOptionsMap->Add(new TObjString(key), nullptr);
652 }
653 delete objTags;
654 }
655 delete objOptions;
656}
657
658
659////////////////////////////////////////////////////////////////////////////////
660/// Return a value for a given key from the URL options.
661/// Returns 0 in case key is not found.
662
663const char *TUrl::GetValueFromOptions(const char *key) const
664{
665 if (!key) return nullptr;
666 ParseOptions();
667 TObject *option = fOptionsMap ? fOptionsMap->GetValue(key) : nullptr;
668 return option ? option->GetName() : nullptr;
669}
670
671////////////////////////////////////////////////////////////////////////////////
672/// Return a value for a given key from the URL options as an Int_t,
673/// a missing key returns -1.
674
676{
677 if (!key) return -1;
678 ParseOptions();
679 TObject *option = fOptionsMap ? fOptionsMap->GetValue(key) : nullptr;
680 return option ? atoi(option->GetName()) : -1;
681}
682
683////////////////////////////////////////////////////////////////////////////////
684/// Returns true if the given key appears in the URL options list.
685
686Bool_t TUrl::HasOption(const char *key) const
687{
688 if (!key) return kFALSE;
689 ParseOptions();
690
691 return fOptionsMap && fOptionsMap->FindObject(key);
692}
693
694////////////////////////////////////////////////////////////////////////////////
695/// Recompute the path removing all relative directory jumps via '..'.
696
698{
699 Ssiz_t slash = 0;
700 while ( (slash = fFile.Index("/..") ) != kNPOS) {
701 // find backwards the next '/'
702 Bool_t found = kFALSE;
703 for (int l = slash-1; l >=0; l--) {
704 if (fFile[l] == '/') {
705 // found previous '/'
706 fFile.Remove(l, slash+3-l);
707 found = kTRUE;
708 break;
709 }
710 }
711 if (!found)
712 break;
713 }
714}
#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
#define ClassImp(name)
Definition Rtypes.h:376
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:2528
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2510
char * StrDup(const char *str)
Duplicate the string str.
Definition TString.cxx:2564
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:491
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:54
virtual void SetOwnerKeyValue(Bool_t ownkeys=kTRUE, Bool_t ownvals=kTRUE)
Set ownership for keys and values.
Definition TMap.cxx:352
TObject * FindObject(const char *keyname) const override
Check if a (key,value) pair exists with keyname as name of the key.
Definition TMap.cxx:215
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
Definition TMap.cxx:236
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:458
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:1072
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:465
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:2304
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:697
static TObjArray * GetSpecialProtocols()
Read the list of special protocols from the rootrc files.
Definition TUrl.cxx:577
@ 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:396
TString fHost
Definition TUrl.h:40
void FindFile(char *u, Bool_t stripDoubleSlash=kTRUE)
Find file and optionally anchor and options.
Definition TUrl.cxx:294
const char * GetFileAndOptions() const
Return the file and its options (the string specified behind the ?).
Definition TUrl.cxx:509
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:663
void SetUrl(const char *url, Bool_t defaultIsFile=kFALSE)
Parse url character string and split in its different subcomponents.
Definition TUrl.cxx:108
void SetProtocol(const char *proto, Bool_t setDefaultPort=kFALSE)
Set protocol and, optionally, change the port accordingly.
Definition TUrl.cxx:528
TString fOptions
Definition TUrl.h:43
TUrl & operator=(const TUrl &rhs)
TUrl assignment operator.
Definition TUrl.cxx:371
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:675
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:477
void Print(Option_t *option="") const override
Print URL on stdout.
Definition TUrl.cxx:563
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:629
const char * GetOptions() const
Definition TUrl.h:71
virtual ~TUrl()
Cleanup.
Definition TUrl.cxx:87
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:686
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:553
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