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, 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
77{
79
80#ifdef R__COMPLETE_MEM_TERMINATION
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
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] == '/')
136
137 // Find protocol
138 char *s, sav;
139
140 TString surl = url;
141 char *u, *u0 = Strip(defaultIsFile && surl.EndsWith(":/") ? TString(surl(0,surl.Length()-2)).Data() : url);
142tryfile:
143 u = u0;
144
145 // Handle special protocol cases: "file:", etc.
146 for (int i = 0; i < GetSpecialProtocols()->GetEntriesFast(); i++) {
147 TObjString *os = (TObjString*) GetSpecialProtocols()->UncheckedAt(i);
148 TString s1 = os->GetString();
149 int l = s1.Length();
151 if (s1.EndsWith("/-")) {
152 stripoff = kTRUE;
153 s1 = s1.Strip(TString::kTrailing, '-');
154 l--;
155 }
156 if (!strncmp(u, s1, l)) {
157 if (s1(0) == '/' && s1(l-1) == '/') {
158 // case with file namespace like: /alien/user/file.root
159 fProtocol = s1(1, l-2);
160 if (stripoff)
161 l--; // strip off namespace prefix from file name
162 else
163 l = 0; // leave namespace prefix as part of file name
164 } else {
165 // case with protocol, like: file:/data/file.root
166 fProtocol = s1(0, l-1);
167 }
168 if (!strncmp(u+l, "//", 2))
169 u += l+2;
170 else
171 u += l;
172 fPort = 0;
173
174 FindFile(u, kFALSE);
175
176 delete [] u0;
177 return;
178 }
179 }
180
181 u = u0;
182
183 char *x, *t, *s2;
184 // allow x:/path as Windows filename
185 if ((s = strstr(u, ":/")) && u+1 != s) {
186 if (*(s+2) != '/') {
187 Error("TUrl", "%s malformed, URL must contain \"://\"", u0);
188 fPort = -1;
189 goto cleanup;
190 }
191 sav = *s;
192 *s = 0;
194 *s = sav;
195 s += 3;
196 // allow url of form: "proto://"
197 } else {
198 if (defaultIsFile) {
199 const std::size_t bufferSize = std::char_traits<char>::length("file:") + strlen(u0) + 1;
200 char *newu = new char [bufferSize];
201 snprintf(newu, bufferSize, "file:%s", u0);
202 delete [] u0;
203 u0 = newu;
204 goto tryfile;
205 }
206 s = u;
207 }
208
209 // Find user and passwd
210 u = s;
211 t = s;
212again:
213 if ((s = strchr(t, '@')) && (
214 ((x = strchr(t, '/')) && s < x) ||
215 ((x = strchr(t, '?')) && s < x) ||
216 ((x = strchr(t, '#')) && s < x) ||
217 (!strchr(t, '/'))
218 )) {
219 if (*(s-1) == '\\') {
220 t = s+1;
221 goto again;
222 }
223 sav = *s;
224 *s = 0;
225 if ((s2 = strchr(u, ':'))) {
226 *s2 = 0;
227 fUser = u;
228 *s2 = ':';
229 s2++;
230 if (*s2) {
231 fPasswd = s2;
232 fPasswd.ReplaceAll("\\@", "@");
233 }
234 } else
235 fUser = u;
236 *s = sav;
237 s++;
238 } else
239 s = u;
240
241 // Find host
242 u = s;
243 if ((s = strchr(u, ':')) || (s = strchr(u, '/')) || (s = strchr(u, '?')) || (s = strchr(u, '#'))) {
244 if ((strchr (u, ':') > strchr(u, '/')) && (strchr (u, '/')))
245 s = strchr(u, '/');
246 sav = *s;
247 *s = 0;
248 fHost = u;
249 *s = sav;
250 if (sav == ':') {
251 s++;
252 // Get port #
253 if (!*s) {
254 fPort = -1;
255 goto cleanup;
256 }
257 u = s;
258 if ((s = strchr(u, '/')) || (s = strchr(u, '?')) || (s = strchr(u, '#'))) {
259 sav = *s;
260 *s = 0;
261 fPort = atoi(u);
262 *s = sav;
263 } else {
264 fPort = atoi(u);
265 goto cleanup;
266 }
267 }
268 } else {
269 fHost = u;
270 goto cleanup;
271 }
272
273 if (!*s) goto cleanup;
274
275 // Find file
276 u = s;
277 if (*u == '/' && fHost.Length())
278 u++;
279
280 FindFile(u);
281
282cleanup:
283 delete [] u0;
284}
285
286////////////////////////////////////////////////////////////////////////////////
287/// Find file and optionally anchor and options.
288
290{
291 char *s, sav;
292
293 // Locate anchor and options, if any
294 char *opt = strchr(u, '?');
295 char *anc = strchr(u, '#');
296
297 // URL invalid if anchor is coming before the options
298 if (opt && anc && opt > anc) {
299 fPort = -1;
300 return;
301 }
302
303 if ((s = opt) || (s = anc)) {
304 sav = *s;
305 *s = 0;
306 fFile = u;
308 fFile.ReplaceAll("//", "/");
309 *s = sav;
310 s++;
311 if (sav == '?') {
312 // Get options
313 if (!*s) {
314 // options string is empty
315 return;
316 }
317 u = s;
318 if ((s = strchr(u, '#'))) {
319 sav = *s;
320 *s = 0;
321 fOptions = u;
322 *s = sav;
323 s++;
324 } else {
325 fOptions = u;
326 return;
327 }
328 }
329 if (!*s) {
330 // anchor string is empty
331 return;
332 }
333 } else {
334 fFile = u;
336 fFile.ReplaceAll("//", "/");
337 return;
338 }
339
340 // Set anchor
341 fAnchor = s;
342}
343
344////////////////////////////////////////////////////////////////////////////////
345/// TUrl copy ctor.
346
348{
349 fUrl = url.fUrl;
350 fProtocol = url.fProtocol;
351 fUser = url.fUser;
352 fPasswd = url.fPasswd;
353 fHost = url.fHost;
354 fFile = url.fFile;
355 fAnchor = url.fAnchor;
356 fOptions = url.fOptions;
357 fPort = url.fPort;
358 fFileOA = url.fFileOA;
359 fHostFQ = url.fHostFQ;
360 fOptionsMap = nullptr;
361}
362
363////////////////////////////////////////////////////////////////////////////////
364/// TUrl assignment operator.
365
367{
368 if (this != &rhs) {
370 fUrl = rhs.fUrl;
371 fProtocol = rhs.fProtocol;
372 fUser = rhs.fUser;
373 fPasswd = rhs.fPasswd;
374 fHost = rhs.fHost;
375 fFile = rhs.fFile;
376 fAnchor = rhs.fAnchor;
377 fOptions = rhs.fOptions;
378 fPort = rhs.fPort;
379 fFileOA = rhs.fFileOA;
380 fHostFQ = rhs.fHostFQ;
381 delete fOptionsMap;
382 fOptionsMap = nullptr;
383 }
384 return *this;
385}
386
387////////////////////////////////////////////////////////////////////////////////
388/// Return full URL. If withDflt is kTRUE, explicitly add the port even
389/// if it matches the default value for the URL protocol.
390
391const char *TUrl::GetUrl(Bool_t withDeflt) const
392{
396 fUrl = "";
397
398 if (IsValid() && fUrl == "") {
399 // Handle special protocol cases: file:, etc.
400 for (int i = 0; i < GetSpecialProtocols()->GetEntriesFast(); i++) {
401 TObjString *os = (TObjString*) GetSpecialProtocols()->UncheckedAt(i);
402 TString &s = os->String();
403 int l = s.Length();
404 if (fProtocol == s(0, l-1)) {
405 if (fFile[0] == '/')
406 fUrl = fProtocol + "://" + fFile;
407 else
408 fUrl = fProtocol + ":" + fFile;
409 if (fOptions != "") {
410 fUrl += "?";
411 fUrl += fOptions;
412 }
413 if (fAnchor != "") {
414 fUrl += "#";
415 fUrl += fAnchor;
416 }
417 return fUrl;
418 }
419 }
420
422 if ((!fProtocol.CompareTo("http") && fPort == 80) ||
423 (fProtocol.BeginsWith("proof") && fPort == 1093) ||
424 (fProtocol.BeginsWith("root") && fPort == 1094) ||
425 (!fProtocol.CompareTo("ftp") && fPort == 20) ||
426 (!fProtocol.CompareTo("news") && fPort == 119) ||
427 (!fProtocol.CompareTo("https") && fPort == 443) ||
428 fPort == 0) {
429 deflt = kTRUE;
430 ((TUrl *)this)->SetBit(kUrlHasDefaultPort);
431 }
432
433 fUrl = fProtocol + "://";
434 if (fUser != "") {
435 fUrl += fUser;
436 if (fPasswd != "") {
437 fUrl += ":";
439 passwd.ReplaceAll("@", "\\@");
440 fUrl += passwd;
441 }
442 fUrl += "@";
443 }
444 if (withDeflt)
445 ((TUrl*)this)->SetBit(kUrlWithDefaultPort);
446 else
448
449 if (!deflt || withDeflt) {
450 char p[10];
451 snprintf(p, 10, "%d", fPort);
452 fUrl = fUrl + fHost + ":" + p + "/" + fFile;
453 } else
454 fUrl = fUrl + fHost + "/" + fFile;
455 if (fOptions != "") {
456 fUrl += "?";
457 fUrl += fOptions;
458 }
459 if (fAnchor != "") {
460 fUrl += "#";
461 fUrl += fAnchor;
462 }
463 }
464
465 fUrl.ReplaceAll("////", "///");
466 return fUrl;
467}
468
469////////////////////////////////////////////////////////////////////////////////
470/// Return fully qualified domain name of url host. If host cannot be
471/// resolved or not valid return the host name as originally specified.
472
473const char *TUrl::GetHostFQDN() const
474{
475 if (fHostFQ == "") {
476 // Check if we already resolved it
477 TNamed *fqdn = fgHostFQDNs ? (TNamed *) fgHostFQDNs->FindObject(fHost) : nullptr;
478 if (!fqdn) {
480 if (adr.IsValid()) {
481 fHostFQ = adr.GetHostName();
482 } else
483 fHostFQ = "-";
485 if (!fgHostFQDNs) {
487 fgHostFQDNs->SetOwner();
488 }
489 if (fgHostFQDNs && !fgHostFQDNs->FindObject(fHost))
490 fgHostFQDNs->Add(new TNamed(fHost,fHostFQ));
491 } else {
492 fHostFQ = fqdn->GetTitle();
493 }
494 }
495 if (fHostFQ == "-")
496 return fHost;
497 return fHostFQ;
498}
499
500////////////////////////////////////////////////////////////////////////////////
501/// Return the file and its options (the string specified behind the ?).
502/// Convenience function useful when the option is used to pass
503/// authentication/access information for the specified file.
504
505const char *TUrl::GetFileAndOptions() const
506{
507 if (fFileOA == "") {
508 fFileOA = fFile;
509 if (fOptions != "") {
510 fFileOA += "?";
511 fFileOA += fOptions;
512 }
513 if (fAnchor != "") {
514 fFileOA += "#";
515 fFileOA += fAnchor;
516 }
517 }
518 return fFileOA;
519}
520
521////////////////////////////////////////////////////////////////////////////////
522/// Set protocol and, optionally, change the port accordingly.
523
525{
527 if (setDefaultPort) {
528 if (!fProtocol.CompareTo("http"))
529 fPort = 80;
530 else if (!fProtocol.CompareTo("https"))
531 fPort = 443;
532 else if (fProtocol.BeginsWith("proof")) // can also be proofs or proofk
533 fPort = 1093;
534 else if (fProtocol.BeginsWith("root")) // can also be roots or rootk
535 fPort = 1094;
536 else if (!fProtocol.CompareTo("ftp"))
537 fPort = 20;
538 else if (!fProtocol.CompareTo("news"))
539 fPort = 119;
540 else {
541 // generic protocol (no default port)
542 fPort = 0;
543 }
544 }
545 fUrl = "";
546}
547
548////////////////////////////////////////////////////////////////////////////////
549/// Compare two urls as strings.
550
551Int_t TUrl::Compare(const TObject *obj) const
552{
553 if (this == obj) return 0;
554 if (TUrl::Class() != obj->IsA()) return -1;
555 return TString(GetUrl()).CompareTo(((TUrl*)obj)->GetUrl(), TString::kExact);
556}
557
558////////////////////////////////////////////////////////////////////////////////
559/// Print URL on stdout.
560
562{
563 if (fPort == -1)
564 Printf("Illegal URL");
565
566 Printf("%s", GetUrl());
567}
568
569////////////////////////////////////////////////////////////////////////////////
570/// Read the list of special protocols from the rootrc files.
571/// These protocols will be parsed in a protocol and a file part,
572/// no host or other info will be determined. This is typically
573/// used for legacy file descriptions like: file:/path/file.root.
574
576{
577 static std::atomic_bool usedEnv { false };
578
579 if (!gEnv) {
583 if (fgSpecialProtocols->GetEntriesFast() == 0)
584 fgSpecialProtocols->Add(new TObjString("file:"));
585 return fgSpecialProtocols;
586 }
587
588 if (usedEnv)
589 return fgSpecialProtocols;
590
592
593 // Some other thread might have set it up in the meantime.
594 if (usedEnv)
595 return fgSpecialProtocols;
596
598 fgSpecialProtocols->Delete();
599
602
603 const char *protos = gEnv->GetValue("Url.Special", "file: hpss: dcache: dcap:");
604
605 if (protos) {
606 Int_t cnt = 0;
607 char *p = StrDup(protos);
608 while (1) {
609 TObjString *proto = new TObjString(strtok(!cnt ? p : nullptr, " "));
610 if (proto->String().IsNull()) {
611 delete proto;
612 break;
613 }
615 cnt++;
616 }
617 delete [] p;
618 }
619 usedEnv = true;
620 return fgSpecialProtocols;
621}
622
623
624////////////////////////////////////////////////////////////////////////////////
625/// Parse URL options into a key/value map.
626
628{
629 if (fOptionsMap) return;
630
632 if (urloptions.IsNull())
633 return;
634
635 TObjArray *objOptions = urloptions.Tokenize("&");
636 for (Int_t n = 0; n < objOptions->GetEntriesFast(); n++) {
638 TObjArray *objTags = loption.Tokenize("=");
639 if (!fOptionsMap) {
640 fOptionsMap = new TMap;
642 }
643 if (objTags->GetEntriesFast() == 2) {
644 TString key = ((TObjString *) objTags->At(0))->GetName();
645 TString value = ((TObjString *) objTags->At(1))->GetName();
646 fOptionsMap->Add(new TObjString(key), new TObjString(value));
647 } else {
648 TString key = ((TObjString *) objTags->At(0))->GetName();
649 fOptionsMap->Add(new TObjString(key), nullptr);
650 }
651 delete objTags;
652 }
653 delete objOptions;
654}
655
656
657////////////////////////////////////////////////////////////////////////////////
658/// Return a value for a given key from the URL options.
659/// Returns 0 in case key is not found.
660
661const char *TUrl::GetValueFromOptions(const char *key) const
662{
663 if (!key) return nullptr;
664 ParseOptions();
665 TObject *option = fOptionsMap ? fOptionsMap->GetValue(key) : nullptr;
666 return option ? option->GetName() : nullptr;
667}
668
669////////////////////////////////////////////////////////////////////////////////
670/// Return a value for a given key from the URL options as an Int_t,
671/// a missing key returns -1.
672
674{
675 if (!key) return -1;
676 ParseOptions();
677 TObject *option = fOptionsMap ? fOptionsMap->GetValue(key) : nullptr;
678 return option ? atoi(option->GetName()) : -1;
679}
680
681////////////////////////////////////////////////////////////////////////////////
682/// Returns true if the given key appears in the URL options list.
683
684Bool_t TUrl::HasOption(const char *key) const
685{
686 if (!key) return kFALSE;
687 ParseOptions();
688
689 return fOptionsMap && fOptionsMap->FindObject(key);
690}
691
692////////////////////////////////////////////////////////////////////////////////
693/// Recompute the path removing all relative directory jumps via '..'.
694
696{
697 Ssiz_t slash = 0;
698 while ( (slash = fFile.Index("/..") ) != kNPOS) {
699 // find backwards the next '/'
700 Bool_t found = kFALSE;
701 for (int l = slash-1; l >=0; l--) {
702 if (fFile[l] == '/') {
703 // found previous '/'
704 fFile.Remove(l, slash+3-l);
705 found = kTRUE;
706 break;
707 }
708 }
709 if (!found)
710 break;
711 }
712}
#define s1(x)
Definition RSha256.hxx:91
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Ssiz_t kNPOS
Definition RtypesCore.h:117
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:374
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
const char * GetUrl()
Definition TProof.h:594
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:2521
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2503
char * StrDup(const char *str)
Duplicate the string str.
Definition TString.cxx:2557
R__EXTERN TSystem * gSystem
Definition TSystem.h:572
#define R__LOCKGUARD(mutex)
const char * proto
Definition civetweb.c:17535
#define snprintf
Definition civetweb.c:1540
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
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:457
TObject & operator=(const TObject &rhs)
TObject assignment operator.
Definition TObject.h:302
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:205
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1071
virtual TClass * IsA() const
Definition TObject.h:249
void ResetBit(UInt_t f)
Definition TObject.h:204
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:417
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Definition TString.cxx:457
const char * Data() const
Definition TString.h:376
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:704
@ kTrailing
Definition TString.h:276
@ kExact
Definition TString.h:277
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition TString.h:623
TString & Remove(Ssiz_t pos)
Definition TString.h:685
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:651
virtual TInetAddress GetHostByName(const char *server)
Get Internet Protocol (IP) address of host.
Definition TSystem.cxx:2303
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:695
static TObjArray * GetSpecialProtocols()
Read the list of special protocols from the rootrc files.
Definition TUrl.cxx:575
@ 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:391
TString fHost
Definition TUrl.h:40
void FindFile(char *u, Bool_t stripDoubleSlash=kTRUE)
Find file and optionally anchor and options.
Definition TUrl.cxx:289
const char * GetFileAndOptions() const
Return the file and its options (the string specified behind the ?).
Definition TUrl.cxx:505
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:661
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:524
TString fOptions
Definition TUrl.h:43
TUrl & operator=(const TUrl &rhs)
TUrl assignment operator.
Definition TUrl.cxx:366
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:673
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:473
void Print(Option_t *option="") const override
Print URL on stdout.
Definition TUrl.cxx:561
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:627
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:684
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:551
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