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