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