Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TUrl.cxx
Go to the documentation of this file.
1// @(#)root/base:$Id$
2// Author: Fons Rademakers 17/01/97
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/** \class TUrl
13\ingroup Base
14
15This class represents a WWW compatible URL.
16It provides member functions to return the different parts of
17an URL. The supported url format is:
18~~~ {.cpp}
19 [proto://][user[:passwd]@]host[:port]/file.ext[#anchor][?options]
20~~~
21*/
22
23#include <stdlib.h>
24#include "TUrl.h"
25#include "THashList.h"
26#include "TObjArray.h"
27#include "TObjString.h"
28#include "TEnv.h"
29#include "TSystem.h"
30#include "TMap.h"
31#include "TROOT.h"
32
33#include <atomic>
34
37
38#ifdef R__COMPLETE_MEM_TERMINATION
39namespace {
40 class TUrlCleanup {
41 TObjArray **fSpecialProtocols;
42 THashList **fHostFQDNs;
43 public:
44 TUrlCleanup(TObjArray **protocols, THashList **hosts) : fSpecialProtocols(protocols),fHostFQDNs(hosts) {}
45 ~TUrlCleanup() {
46 if (*fSpecialProtocols) (*fSpecialProtocols)->Delete();
47 delete *fSpecialProtocols;
48 *fSpecialProtocols = 0;
49 if (*fHostFQDNs) (*fHostFQDNs)->Delete();
50 delete *fHostFQDNs;
51 *fHostFQDNs = 0;
52 }
53 };
54}
55#endif
56
58
59////////////////////////////////////////////////////////////////////////////////
60/// Parse url character string and split in its different subcomponents.
61/// Use IsValid() to check if URL is legal.
62/// ~~~ {.cpp}
63/// url: [proto://][user[:passwd]@]host[:port]/file.ext[?options][#anchor]
64/// ~~~
65/// Known protocols: http, root, proof, ftp, news and any special protocols
66/// defined in the rootrc Url.Special key.
67/// The default protocol is "http", unless defaultIsFile is true in which
68/// case the url is assumed to be of type "file".
69/// If a passwd contains a @ it must be escaped by a \\, e.g.
70/// "pip@" becomes "pip\\@".
71///
72/// Default ports: http=80, root=1094, proof=1093, ftp=20, news=119.
73/// Port #1093 has been assigned by IANA (www.iana.org) to proofd.
74/// Port #1094 has been assigned by IANA (www.iana.org) to rootd.
75
76TUrl::TUrl(const char *url, Bool_t defaultIsFile)
77{
78 SetUrl(url, defaultIsFile);
79
80#ifdef R__COMPLETE_MEM_TERMINATION
81 static TUrlCleanup cleanup(&fgSpecialProtocols,&fgHostFQDNs);
82#endif
83}
84
85////////////////////////////////////////////////////////////////////////////////
86/// Cleanup.
87
89{
90 delete fOptionsMap;
91}
92
93////////////////////////////////////////////////////////////////////////////////
94/// Parse url character string and split in its different subcomponents.
95/// Use IsValid() to check if URL is legal.
96///~~~ {.cpp}
97/// url: [proto://][user[:passwd]@]host[:port]/file.ext[?options][#anchor]
98///~~~
99/// Known protocols: http, root, proof, ftp, news and any special protocols
100/// defined in the rootrc Url.Special key.
101/// The default protocol is "http", unless defaultIsFile is true in which
102/// case the url is assumed to be of type "file".
103/// If a passwd contains a @ it must be escaped by a \\, e.g.
104/// "pip@" becomes "pip\\@".
105///
106/// Default ports: http=80, root=1094, proof=1093, ftp=20, news=119.
107/// Port #1093 has been assigned by IANA (www.iana.org) to proofd.
108/// Port #1094 has been assigned by IANA (www.iana.org) to rootd.
109
110void TUrl::SetUrl(const char *url, Bool_t defaultIsFile)
111{
112 delete fOptionsMap;
113 fOptionsMap = nullptr;
114
115 if (!url || !url[0]) {
116 fPort = -1;
117 return;
118 }
119
120 // Set defaults
121 fUrl = "";
122 fProtocol = "http";
123 fUser = "";
124 fPasswd = "";
125 fHost = "";
126 fPort = 80;
127 fFile = "";
128 fAnchor = "";
129 fOptions = "";
130 fFileOA = "";
131 fHostFQ = "";
132
133 // if url starts with a / consider it as a file url
134 if (url[0] == '/')
135 defaultIsFile = kTRUE;
136
137 // Find protocol
138 char *s, sav;
139
140 char *u, *u0 = Strip(url);
141tryfile:
142 u = u0;
143
144 // Handle special protocol cases: "file:", etc.
145 for (int i = 0; i < GetSpecialProtocols()->GetEntriesFast(); i++) {
147 TString s1 = os->GetString();
148 int l = s1.Length();
149 Bool_t stripoff = kFALSE;
150 if (s1.EndsWith("/-")) {
151 stripoff = kTRUE;
152 s1 = s1.Strip(TString::kTrailing, '-');
153 l--;
154 }
155 if (!strncmp(u, s1, l)) {
156 if (s1(0) == '/' && s1(l-1) == '/') {
157 // case with file namespace like: /alien/user/file.root
158 fProtocol = s1(1, l-2);
159 if (stripoff)
160 l--; // strip off namespace prefix from file name
161 else
162 l = 0; // leave namespace prefix as part of file name
163 } else {
164 // case with protocol, like: file:/data/file.root
165 fProtocol = s1(0, l-1);
166 }
167 if (!strncmp(u+l, "//", 2))
168 u += l+2;
169 else
170 u += l;
171 fPort = 0;
172
173 FindFile(u, kFALSE);
174
175 delete [] u0;
176 return;
177 }
178 }
179
180 u = u0;
181
182 char *x, *t, *s2;
183 // allow x:/path as Windows filename
184 if ((s = strstr(u, ":/")) && u+1 != s) {
185 if (*(s+2) != '/') {
186 Error("TUrl", "%s malformed, URL must contain \"://\"", u0);
187 fPort = -1;
188 goto cleanup;
189 }
190 sav = *s;
191 *s = 0;
192 SetProtocol(u, kTRUE);
193 *s = sav;
194 s += 3;
195 // allow url of form: "proto://"
196 } else {
197 if (defaultIsFile) {
198 const std::size_t bufferSize = strlen("file:") + strlen(u0) + 1;
199 char *newu = new char [bufferSize];
200 snprintf(newu, bufferSize, "file:%s", u0);
201 delete [] u0;
202 u0 = newu;
203 goto tryfile;
204 }
205 s = u;
206 }
207
208 // Find user and passwd
209 u = s;
210 t = s;
211again:
212 if ((s = strchr(t, '@')) && (
213 ((x = strchr(t, '/')) && s < x) ||
214 ((x = strchr(t, '?')) && s < x) ||
215 ((x = strchr(t, '#')) && s < x) ||
216 (!strchr(t, '/'))
217 )) {
218 if (*(s-1) == '\\') {
219 t = s+1;
220 goto again;
221 }
222 sav = *s;
223 *s = 0;
224 if ((s2 = strchr(u, ':'))) {
225 *s2 = 0;
226 fUser = u;
227 *s2 = ':';
228 s2++;
229 if (*s2) {
230 fPasswd = s2;
231 fPasswd.ReplaceAll("\\@", "@");
232 }
233 } else
234 fUser = u;
235 *s = sav;
236 s++;
237 } else
238 s = u;
239
240 // Find host
241 u = s;
242 if ((s = strchr(u, ':')) || (s = strchr(u, '/')) || (s = strchr(u, '?')) || (s = strchr(u, '#'))) {
243 if ((strchr (u, ':') > strchr(u, '/')) && (strchr (u, '/')))
244 s = strchr(u, '/');
245 sav = *s;
246 *s = 0;
247 fHost = u;
248 *s = sav;
249 if (sav == ':') {
250 s++;
251 // Get port #
252 if (!*s) {
253 fPort = -1;
254 goto cleanup;
255 }
256 u = s;
257 if ((s = strchr(u, '/')) || (s = strchr(u, '?')) || (s = strchr(u, '#'))) {
258 sav = *s;
259 *s = 0;
260 fPort = atoi(u);
261 *s = sav;
262 } else {
263 fPort = atoi(u);
264 goto cleanup;
265 }
266 }
267 } else {
268 fHost = u;
269 goto cleanup;
270 }
271
272 if (!*s) goto cleanup;
273
274 // Find file
275 u = s;
276 if (*u == '/' && fHost.Length())
277 u++;
278
279 FindFile(u);
280
281cleanup:
282 delete [] u0;
283}
284
285////////////////////////////////////////////////////////////////////////////////
286/// Find file and optionally anchor and options.
287
288void TUrl::FindFile(char *u, Bool_t stripDoubleSlash)
289{
290 char *s, sav;
291
292 // Locate anchor and options, if any
293 char *opt = strchr(u, '?');
294 char *anc = strchr(u, '#');
295
296 // URL invalid if anchor is coming before the options
297 if (opt && anc && opt > anc) {
298 fPort = -1;
299 return;
300 }
301
302 if ((s = opt) || (s = anc)) {
303 sav = *s;
304 *s = 0;
305 fFile = u;
306 if (stripDoubleSlash)
307 fFile.ReplaceAll("//", "/");
308 *s = sav;
309 s++;
310 if (sav == '?') {
311 // Get options
312 if (!*s) {
313 // options string is empty
314 return;
315 }
316 u = s;
317 if ((s = strchr(u, '#'))) {
318 sav = *s;
319 *s = 0;
320 fOptions = u;
321 *s = sav;
322 s++;
323 } else {
324 fOptions = u;
325 return;
326 }
327 }
328 if (!*s) {
329 // anchor string is empty
330 return;
331 }
332 } else {
333 fFile = u;
334 if (stripDoubleSlash)
335 fFile.ReplaceAll("//", "/");
336 return;
337 }
338
339 // Set anchor
340 fAnchor = s;
341}
342
343////////////////////////////////////////////////////////////////////////////////
344/// TUrl copy ctor.
345
346TUrl::TUrl(const TUrl &url) : TObject(url)
347{
348 fUrl = url.fUrl;
349 fProtocol = url.fProtocol;
350 fUser = url.fUser;
351 fPasswd = url.fPasswd;
352 fHost = url.fHost;
353 fFile = url.fFile;
354 fAnchor = url.fAnchor;
355 fOptions = url.fOptions;
356 fPort = url.fPort;
357 fFileOA = url.fFileOA;
358 fHostFQ = url.fHostFQ;
359 fOptionsMap = nullptr;
360}
361
362////////////////////////////////////////////////////////////////////////////////
363/// TUrl assignment operator.
364
366{
367 if (this != &rhs) {
369 fUrl = rhs.fUrl;
370 fProtocol = rhs.fProtocol;
371 fUser = rhs.fUser;
372 fPasswd = rhs.fPasswd;
373 fHost = rhs.fHost;
374 fFile = rhs.fFile;
375 fAnchor = rhs.fAnchor;
376 fOptions = rhs.fOptions;
377 fPort = rhs.fPort;
378 fFileOA = rhs.fFileOA;
379 fHostFQ = rhs.fHostFQ;
380 delete fOptionsMap;
381 fOptionsMap = nullptr;
382 }
383 return *this;
384}
385
386////////////////////////////////////////////////////////////////////////////////
387/// Return full URL. If withDflt is kTRUE, explicitly add the port even
388/// if it matches the default value for the URL protocol.
389
390const char *TUrl::GetUrl(Bool_t withDeflt) const
391{
392 if (((TestBit(kUrlWithDefaultPort) && !withDeflt) ||
393 (!TestBit(kUrlWithDefaultPort) && withDeflt)) &&
395 fUrl = "";
396
397 if (IsValid() && fUrl == "") {
398 // Handle special protocol cases: file:, etc.
399 for (int i = 0; i < GetSpecialProtocols()->GetEntriesFast(); i++) {
401 TString &s = os->String();
402 int l = s.Length();
403 if (fProtocol == s(0, l-1)) {
404 if (fFile[0] == '/')
405 fUrl = fProtocol + "://" + fFile;
406 else
407 fUrl = fProtocol + ":" + fFile;
408 if (fOptions != "") {
409 fUrl += "?";
410 fUrl += fOptions;
411 }
412 if (fAnchor != "") {
413 fUrl += "#";
414 fUrl += fAnchor;
415 }
416 return fUrl;
417 }
418 }
419
420 Bool_t deflt = kFALSE;
421 if ((!fProtocol.CompareTo("http") && fPort == 80) ||
422 (fProtocol.BeginsWith("proof") && fPort == 1093) ||
423 (fProtocol.BeginsWith("root") && fPort == 1094) ||
424 (!fProtocol.CompareTo("ftp") && fPort == 20) ||
425 (!fProtocol.CompareTo("news") && fPort == 119) ||
426 (!fProtocol.CompareTo("https") && fPort == 443) ||
427 fPort == 0) {
428 deflt = kTRUE;
429 ((TUrl *)this)->SetBit(kUrlHasDefaultPort);
430 }
431
432 fUrl = fProtocol + "://";
433 if (fUser != "") {
434 fUrl += fUser;
435 if (fPasswd != "") {
436 fUrl += ":";
438 passwd.ReplaceAll("@", "\\@");
439 fUrl += passwd;
440 }
441 fUrl += "@";
442 }
443 if (withDeflt)
444 ((TUrl*)this)->SetBit(kUrlWithDefaultPort);
445 else
447
448 if (!deflt || withDeflt) {
449 char p[10];
450 snprintf(p, 10, "%d", fPort);
451 fUrl = fUrl + fHost + ":" + p + "/" + fFile;
452 } else
453 fUrl = fUrl + fHost + "/" + fFile;
454 if (fOptions != "") {
455 fUrl += "?";
456 fUrl += fOptions;
457 }
458 if (fAnchor != "") {
459 fUrl += "#";
460 fUrl += fAnchor;
461 }
462 }
463
464 fUrl.ReplaceAll("////", "///");
465 return fUrl;
466}
467
468////////////////////////////////////////////////////////////////////////////////
469/// Return fully qualified domain name of url host. If host cannot be
470/// resolved or not valid return the host name as originally specified.
471
472const char *TUrl::GetHostFQDN() const
473{
474 if (fHostFQ == "") {
475 // Check if we already resolved it
476 TNamed *fqdn = fgHostFQDNs ? (TNamed *) fgHostFQDNs->FindObject(fHost) : nullptr;
477 if (!fqdn) {
479 if (adr.IsValid()) {
480 fHostFQ = adr.GetHostName();
481 } else
482 fHostFQ = "-";
484 if (!fgHostFQDNs) {
487 }
490 } else {
491 fHostFQ = fqdn->GetTitle();
492 }
493 }
494 if (fHostFQ == "-")
495 return fHost;
496 return fHostFQ;
497}
498
499////////////////////////////////////////////////////////////////////////////////
500/// Return the file and its options (the string specified behind the ?).
501/// Convenience function useful when the option is used to pass
502/// authentication/access information for the specified file.
503
504const char *TUrl::GetFileAndOptions() const
505{
506 if (fFileOA == "") {
507 fFileOA = fFile;
508 if (fOptions != "") {
509 fFileOA += "?";
510 fFileOA += fOptions;
511 }
512 if (fAnchor != "") {
513 fFileOA += "#";
514 fFileOA += fAnchor;
515 }
516 }
517 return fFileOA;
518}
519
520////////////////////////////////////////////////////////////////////////////////
521/// Set protocol and, optionally, change the port accordingly.
522
523void TUrl::SetProtocol(const char *proto, Bool_t setDefaultPort)
524{
526 if (setDefaultPort) {
527 if (!fProtocol.CompareTo("http"))
528 fPort = 80;
529 else if (!fProtocol.CompareTo("https"))
530 fPort = 443;
531 else if (fProtocol.BeginsWith("proof")) // can also be proofs or proofk
532 fPort = 1093;
533 else if (fProtocol.BeginsWith("root")) // can also be roots or rootk
534 fPort = 1094;
535 else if (!fProtocol.CompareTo("ftp"))
536 fPort = 20;
537 else if (!fProtocol.CompareTo("news"))
538 fPort = 119;
539 else {
540 // generic protocol (no default port)
541 fPort = 0;
542 }
543 }
544 fUrl = "";
545}
546
547////////////////////////////////////////////////////////////////////////////////
548/// Compare two urls as strings.
549
550Int_t TUrl::Compare(const TObject *obj) const
551{
552 if (this == obj) return 0;
553 if (TUrl::Class() != obj->IsA()) return -1;
554 return TString(GetUrl()).CompareTo(((TUrl*)obj)->GetUrl(), TString::kExact);
555}
556
557////////////////////////////////////////////////////////////////////////////////
558/// Print URL on stdout.
559
561{
562 if (fPort == -1)
563 Printf("Illegal URL");
564
565 Printf("%s", GetUrl());
566}
567
568////////////////////////////////////////////////////////////////////////////////
569/// Read the list of special protocols from the rootrc files.
570/// These protocols will be parsed in a protocol and a file part,
571/// no host or other info will be determined. This is typically
572/// used for legacy file descriptions like: file:/path/file.root.
573
575{
576 static std::atomic_bool usedEnv = ATOMIC_VAR_INIT(false);
577
578 if (!gEnv) {
583 fgSpecialProtocols->Add(new TObjString("file:"));
584 return fgSpecialProtocols;
585 }
586
587 if (usedEnv)
588 return fgSpecialProtocols;
589
591
592 // Some other thread might have set it up in the meantime.
593 if (usedEnv)
594 return fgSpecialProtocols;
595
598
601
602 const char *protos = gEnv->GetValue("Url.Special", "file: hpss: dcache: dcap:");
603
604 if (protos) {
605 Int_t cnt = 0;
606 char *p = StrDup(protos);
607 while (1) {
608 TObjString *proto = new TObjString(strtok(!cnt ? p : nullptr, " "));
609 if (proto->String().IsNull()) {
610 delete proto;
611 break;
612 }
614 cnt++;
615 }
616 delete [] p;
617 }
618 usedEnv = true;
619 return fgSpecialProtocols;
620}
621
622
623////////////////////////////////////////////////////////////////////////////////
624/// Parse URL options into a key/value map.
625
627{
628 if (fOptionsMap) return;
629
630 TString urloptions = GetOptions();
631 if (urloptions.IsNull())
632 return;
633
634 TObjArray *objOptions = urloptions.Tokenize("&");
635 for (Int_t n = 0; n < objOptions->GetEntriesFast(); n++) {
636 TString loption = ((TObjString *) objOptions->At(n))->GetName();
637 TObjArray *objTags = loption.Tokenize("=");
638 if (!fOptionsMap) {
639 fOptionsMap = new TMap;
641 }
642 if (objTags->GetEntriesFast() == 2) {
643 TString key = ((TObjString *) objTags->At(0))->GetName();
644 TString value = ((TObjString *) objTags->At(1))->GetName();
645 fOptionsMap->Add(new TObjString(key), new TObjString(value));
646 } else {
647 TString key = ((TObjString *) objTags->At(0))->GetName();
648 fOptionsMap->Add(new TObjString(key), nullptr);
649 }
650 delete objTags;
651 }
652 delete objOptions;
653}
654
655
656////////////////////////////////////////////////////////////////////////////////
657/// Return a value for a given key from the URL options.
658/// Returns 0 in case key is not found.
659
660const char *TUrl::GetValueFromOptions(const char *key) const
661{
662 if (!key) return nullptr;
663 ParseOptions();
664 TObject *option = fOptionsMap ? fOptionsMap->GetValue(key) : nullptr;
665 return option ? option->GetName() : nullptr;
666}
667
668////////////////////////////////////////////////////////////////////////////////
669/// Return a value for a given key from the URL options as an Int_t,
670/// a missing key returns -1.
671
673{
674 if (!key) return -1;
675 ParseOptions();
676 TObject *option = fOptionsMap ? fOptionsMap->GetValue(key) : nullptr;
677 return option ? atoi(option->GetName()) : -1;
678}
679
680////////////////////////////////////////////////////////////////////////////////
681/// Returns true if the given key appears in the URL options list.
682
683Bool_t TUrl::HasOption(const char *key) const
684{
685 if (!key) return kFALSE;
686 ParseOptions();
687
688 return fOptionsMap && fOptionsMap->FindObject(key);
689}
690
691////////////////////////////////////////////////////////////////////////////////
692/// Recompute the path removing all relative directory jumps via '..'.
693
695{
696 Ssiz_t slash = 0;
697 while ( (slash = fFile.Index("/..") ) != kNPOS) {
698 // find backwards the next '/'
699 Bool_t found = kFALSE;
700 for (int l = slash-1; l >=0; l--) {
701 if (fFile[l] == '/') {
702 // found previous '/'
703 fFile.Remove(l, slash+3-l);
704 found = kTRUE;
705 break;
706 }
707 }
708 if (!found)
709 break;
710 }
711}
#define s1(x)
Definition RSha256.hxx:91
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Ssiz_t kNPOS
Definition RtypesCore.h:124
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
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: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:555
#define R__LOCKGUARD(mutex)
const char * proto
Definition civetweb.c:17536
#define snprintf
Definition civetweb.c:1540
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:491
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition THashList.h:34
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
TObject * FindObject(const char *name) const override
Find object using its name.
This class represents an Internet Protocol (IP) address.
const char * GetHostName() const
Bool_t IsValid() const
void Add(TObject *obj) override
Definition TList.h:81
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition TMap.h:40
void Add(TObject *obj) 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
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:48
An array of TObjects.
Definition TObjArray.h:31
Int_t GetEntriesFast() const
Definition TObjArray.h:58
void Delete(Option_t *option="") override
Remove all objects from the array AND delete all heap based objects.
TObject * At(Int_t idx) const override
Definition TObjArray.h:164
TObject * UncheckedAt(Int_t i) const
Definition TObjArray.h:84
void Add(TObject *obj) override
Definition TObjArray.h:68
Collectable string class.
Definition TObjString.h:28
const TString & GetString() const
Definition TObjString.h:46
TString & String()
Definition TObjString.h:48
Mother of all ROOT objects.
Definition TObject.h:41
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:439
TObject & operator=(const TObject &rhs)
TObject assignment operator.
Definition TObject.h:298
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:201
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:987
virtual TClass * IsA() const
Definition TObject.h:245
void ResetBit(UInt_t f)
Definition TObject.h:200
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
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:704
@ kTrailing
Definition TString.h:276
@ kExact
Definition TString.h:277
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Definition TString.cxx:2264
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition TString.h:623
Bool_t IsNull() const
Definition TString.h:414
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:2291
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:694
static TObjArray * GetSpecialProtocols()
Read the list of special protocols from the rootrc files.
Definition TUrl.cxx:574
@ 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:390
TString fHost
Definition TUrl.h:40
void FindFile(char *u, Bool_t stripDoubleSlash=kTRUE)
Find file and optionally anchor and options.
Definition TUrl.cxx:288
const char * GetFileAndOptions() const
Return the file and its options (the string specified behind the ?).
Definition TUrl.cxx:504
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:660
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:523
TString fOptions
Definition TUrl.h:43
TUrl & operator=(const TUrl &rhs)
TUrl assignment operator.
Definition TUrl.cxx:365
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:672
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:472
void Print(Option_t *option="") const override
Print URL on stdout.
Definition TUrl.cxx:560
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:626
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:683
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:550
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