Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TEnv.cxx
Go to the documentation of this file.
1// @(#)root/base:$Id: 0daf41ec24086ee7af29fdc2f9f2f848b150dcc8 $
2// Author: Fons Rademakers 22/09/95
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 TEnv
13\ingroup Base
14
15The TEnv class reads config files, by default named `.rootrc`.
16Three types of config files are read: global, user and local files. The
17global file is `$ROOTSYS/etc/system<name>` (or `ROOTETCDIR/system<name>`)
18the user file is `$HOME/<name>` and the local file is `./<name>`.
19
20By setting the shell variable `ROOTENV_NO_HOME=1` the reading of
21the `$HOME/<name>` resource file will be skipped. This might be useful
22in case the home directory resides on an auto-mounted remote file
23system and one wants to avoid this file system from being mounted.
24
25By setting ROOTENV_USER_PATH=<path>, the user-level configuration can
26be read from a custom path instead of from $HOME.
27
28The format of the `.rootrc` file is similar to the `.Xdefaults` format:
29~~~ {.cpp}
30 [+]<SystemName>.<RootName|ProgName>.<name>[(type)]: <value>
31~~~
32Where `<SystemName>` is either Unix, WinNT, MacOS or Vms,
33`<RootName>` the name as given in the TApplication ctor (or "RootApp"
34in case no explicit TApplication derived object was created),
35`<ProgName>` the current program name and `<name>` the resource name,
36with optionally a type specification. `<value>` can be either a
37string, an integer, a float/double or a boolean with the values
38TRUE, FALSE, ON, OFF, YES, NO, OK, NOT. Booleans will be returned as
39an integer 0 or 1. The options [+] allows the concatenation of
40values to the same resource name.
41
42E.g.:
43~~~ {.cpp}
44 Unix.Rint.Root.DynamicPath: .:$(ROOTSYS)/lib:~/lib
45 myapp.Root.Debug: FALSE
46 TH.Root.Debug: YES
47 *.Root.ObjStat: 1
48~~~
49`<SystemName>` and `<ProgName>` or `<RootName>` may be the wildcard "*".
50A # in the first column starts comment line.
51
52Note that the environment variables (like $ROOTSYS) need to be
53surrounded in parentheses in order to be expanded.
54
55For the currently defined resources (and their default values) see
56`$ROOTSYS/etc/system.rootrc`.
57
58Note that the .rootrc config files contain the config for all ROOT
59based applications.
60
61To add new entries to a TEnv:
62~~~ {.cpp}
63TEnv env(".myfile");
64env.SetValue("myname","value");
65env.SaveLevel(kEnvLocal);
66~~~
67All new entries will be saved in the file corresponding to the
68first SaveLevel() command. If Save() is used, new entries go
69into the local file by default.
70*/
71
72#include "RConfigure.h"
73
74#include <cstring>
75#include <cstdio>
76#include <cstdlib>
77#include <cctype>
78
79#include "strlcpy.h"
80#include "TEnv.h"
81#include "TROOT.h"
82#include "TSystem.h"
83#include "THashList.h"
84#include "TError.h"
85
86
87TEnv *gEnv; // main environment created in TROOT
88
89
90static struct BoolNameTable_t {
91 const char *fName;
93} gBoolNames[]= {
94 { "TRUE", 1 },
95 { "FALSE", 0 },
96 { "ON", 1 },
97 { "OFF", 0 },
98 { "YES", 1 },
99 { "NO", 0 },
100 { "OK", 1 },
101 { "NOT", 0 },
102 { nullptr, 0 }
104
105
106/** \class TEnvParser
107TEnv Parser.
108*/
109
111
112private:
114
115protected:
117
118public:
120 virtual ~TEnvParser() { }
121 virtual void KeyValue(const TString&, const TString&, const TString&) { }
122 virtual void Char(Int_t) { }
123 void Parse();
124};
125
126////////////////////////////////////////////////////////////////////////////////
127/// Parse a line of the env file and create an entry in the resource
128/// dictionary (i.e. add a KeyValue pair).
129
131{
132 TString name(1024);
133 TString type(1024);
134 TString value(1024);
135 int c, state = 0;
136
137 while ((c = fgetc(fIfp)) != EOF) {
138 if (c == 13) // ignore CR
139 continue;
140 if (c == '\n') {
141 state = 0;
142 if (name.Length() > 0) {
144 name.Clear();
145 value.Clear();
146 type.Clear();
147 }
148 Char(c);
149 continue;
150 }
151 switch (state) {
152 case 0: // start of line
153 switch (c) {
154 case ' ':
155 case '\t':
156 break;
157 case '#':
158 state = 1;
159 break;
160 default:
161 state = 2;
162 break;
163 }
164 break;
165
166 case 1: // comment
167 break;
168
169 case 2: // name
170 switch (c) {
171 case ' ':
172 case '\t':
173 case ':':
174 state = 3;
175 break;
176 case '(':
177 state = 7;
178 break;
179 default:
180 break;
181 }
182 break;
183
184 case 3: // ws before value
185 if (c != ' ' && c != '\t')
186 state = 4;
187 break;
188
189 case 4: // value
190 break;
191
192 case 5: // type
193 if (c == ')')
194 state = 6;
195 break;
196
197 case 6: // optional ':'
198 state = (c == ':') ? 3 : 4;
199 break;
200
201 case 7:
202 state = (c == ')') ? 6 : 5;
203 break;
204
205 }
206 switch (state) {
207 case 2:
208 name.Append(c);
209 break;
210 case 4:
211 value.Append(c);
212 break;
213 case 5:
214 type.Append(c);
215 break;
216 }
217 if (state != 4)
218 Char(c);
219 }
220 // In case EOF is reach before '\n'
221 if (name.Length() > 0) {
223 name.Clear();
224 value.Clear();
225 type.Clear();
226 }
227}
228
229/** \class TReadEnvParser
230*/
231
233
234private:
236
237public:
239 void KeyValue(const TString &name, const TString &value, const TString &type) override
241};
242
243/** \class TWriteEnvParser
244*/
245
247
248private:
250
251public:
253 void KeyValue(const TString &name, const TString &value, const TString &type) override;
254 void Char(Int_t c) override { fputc(c, fOfp); }
255};
256
257////////////////////////////////////////////////////////////////////////////////
258/// Write resources out to a new file.
259
261 const TString &)
262{
264 if (er && er->fModified) {
265 er->fModified = kFALSE;
266 fprintf(fOfp, "%s", er->fValue.Data());
267 } else
268 fprintf(fOfp, "%s", value.Data());
269}
270
271
272/** \class TEnvRec
273*/
274
275////////////////////////////////////////////////////////////////////////////////
276/// Ctor of a single resource.
277
278TEnvRec::TEnvRec(const char *n, const char *v, const char *t, EEnvLevel l)
279 : fName(n), fType(t), fLevel(l)
280{
282 fModified = (l == kEnvChange);
283}
284
285////////////////////////////////////////////////////////////////////////////////
286/// TNamed destructor.
287
289{
290 // Required since we overload TObject::Hash.
292}
293
294////////////////////////////////////////////////////////////////////////////////
295/// Change the value of a resource.
296
297void TEnvRec::ChangeValue(const char *v, const char *, EEnvLevel l,
298 Bool_t append, Bool_t ignoredup)
299{
300 if (l != kEnvChange && fLevel == l && !append) {
301 // use global Warning() since interpreter might not yet be initialized
302 // at this stage (called from TROOT ctor)
303 if (fValue != v && !ignoredup)
304 ::Warning("TEnvRec::ChangeValue",
305 "duplicate entry <%s=%s> for level %d; ignored", fName.Data(), v, l);
306 return;
307 }
308 if (!append) {
309 if (fValue != v) {
310 if (l == kEnvChange)
312 else
314 fLevel = l;
316 }
317 } else {
318 if (l == kEnvChange)
320 fLevel = l;
321 fValue += " ";
322 fValue += ExpandValue(v);
323 }
324}
325
326////////////////////////////////////////////////////////////////////////////////
327/// Comparison function for resources.
328
330{
331 return fName.CompareTo(((TEnvRec*)op)->fName);
332}
333
334////////////////////////////////////////////////////////////////////////////////
335/// Replace all $(XXX) strings by the value defined in the shell
336/// (obtained via TSystem::Getenv()).
337
339{
340 const char *vv;
341 char *v, *vorg = StrDup(value);
342 v = vorg;
343
344 char *s1, *s2;
345 int len = 0;
346 while ((s1 = (char*)strstr(v, "$("))) {
347 s1 += 2;
348 s2 = (char*)strchr(s1, ')');
349 if (!s2) {
350 len = 0;
351 break;
352 }
353 *s2 = 0;
354 vv = gSystem->Getenv(s1);
355 if (vv) len += strlen(vv);
356 *s2 = ')';
357 v = s2 + 1;
358 }
359
360 if (!len) {
361 delete [] vorg;
362 return TString(value);
363 }
364
365 v = vorg;
366 int nch = strlen(v) + len;
367 char *nv = new char[nch];
368 *nv = 0;
369
370 while ((s1 = (char*)strstr(v, "$("))) {
371 *s1 = 0;
372 strlcat(nv, v,nch);
373 *s1 = '$';
374 s1 += 2;
375 s2 = (char*)strchr(s1, ')');
376 *s2 = 0;
377 vv = gSystem->Getenv(s1);
378 if (vv) strlcat(nv, vv,nch);
379 *s2 = ')';
380 v = s2 + 1;
381 }
382
383 if (*v) strlcat(nv, v,nch);
384
385 TString val = nv;
386 delete [] nv;
387 delete [] vorg;
388
389 return val;
390}
391
392////////////////////////////////////////////////////////////////////////////////
393/// Returns the home directory or, if set, the value of the environment variable
394/// ROOTENV_USER_PATH.
395const char *TEnv::GetUserDirectory() const
396{
397 const auto customPath = gSystem->Getenv("ROOTENV_USER_PATH");
398 if (customPath)
399 return customPath;
400 return gSystem->HomeDirectory();
401}
402
403////////////////////////////////////////////////////////////////////////////////
404/// Create a resource table and read the (possibly) three resource files,
405/// i.e.\ `$ROOTSYS/etc/system<name>` or `ROOTETCDIR/system<name>`
406/// (kEnvGlobal), `$HOME/<name>` or (kEnvUser), and `$PWD/<name>` (kEnvLocal).
407/// ROOT always reads ".rootrc" (in TROOT::InitSystem()). You can
408/// read additional user defined resource files by creating additional TEnv
409/// objects. By setting the shell variable ROOTENV_NO_HOME=1 the reading of
410/// the `$HOME/<name>` resource file will be skipped. This might be useful in
411/// case the home directory resides on an auto-mounted remote file system
412/// and one wants to avoid the file system from being mounted.
413/// In case the environment variable ROOTENV_USER_PATH is specified,
414/// and ROOTENV_NO_HOME is not set, then `$ROOTENV_USER_PATH/<name>`
415/// is considered instead of `$HOME/<name>`.
416/// If environment variables have to be avoided, a `rootlogon.C` script
417/// can be created where where the environment can be set through an
418/// invocation of TEnv::ReadFile.
419
420TEnv::TEnv(const char *name)
421{
423
424 if (!name || !name[0] || !gSystem)
425 fTable = nullptr;
426 else {
427 fTable = new THashList(1000);
428 fRcName = name;
429
430 TString sname = "system";
431 sname += name;
432 const char *s = gSystem->PrependPathName(TROOT::GetEtcDir(), sname);
434 if (!gSystem->Getenv("ROOTENV_NO_HOME")) {
435 TString temp(name);
437 ReadFile(temp.Data(), kEnvUser);
440 }
441 } else {
443 }
444 }
445}
446
447////////////////////////////////////////////////////////////////////////////////
448/// Delete the resource table.
449
451{
452 if (fTable) {
453 fTable->Delete();
455 }
456}
457
458////////////////////////////////////////////////////////////////////////////////
459/// Returns the character value for a named resource.
460
461const char *TEnv::Getvalue(const char *name) const
462{
464 if (gProgName && strlen(gProgName) > 0)
466
468 TEnvRec *er = nullptr;
469 if (haveProgName && gSystem && gProgName) {
470 aname = gSystem->GetName(); aname += "."; aname += gProgName;
471 aname += "."; aname += name;
472 er = Lookup(aname);
473 }
474 if (er == nullptr && gSystem && gROOT) {
475 aname = gSystem->GetName(); aname += "."; aname += gROOT->GetName();
476 aname += "."; aname += name;
477 er = Lookup(aname);
478 }
479 if (er == nullptr && gSystem) {
480 aname = gSystem->GetName(); aname += ".*."; aname += name;
481 er = Lookup(aname);
482 }
483 if (er == nullptr && haveProgName && gProgName) {
484 aname = gProgName; aname += "."; aname += name;
485 er = Lookup(aname);
486 }
487 if (er == nullptr && gROOT) {
488 aname = gROOT->GetName(); aname += "."; aname += name;
489 er = Lookup(aname);
490 }
491 if (er == nullptr) {
492 aname = "*.*."; aname += name;
493 er = Lookup(aname);
494 }
495 if (er == nullptr) {
496 aname = "*."; aname += name;
497 er = Lookup(aname);
498 }
499 if (er == nullptr) {
500 er = Lookup(name);
501 }
502 if (er == nullptr)
503 return nullptr;
504 return er->fValue;
505}
506
507////////////////////////////////////////////////////////////////////////////////
508/// Returns the integer value for a resource. If the resource is not found
509/// return the default value.
510
511Int_t TEnv::GetValue(const char *name, Int_t dflt) const
512{
513 const char *cp = TEnv::Getvalue(name);
514 if (cp) {
515 char buf2[512], *cp2 = buf2;
516
517 while (isspace((int)*cp))
518 cp++;
519 if (*cp) {
521 if (isdigit((int)*cp) || *cp == '-' || *cp == '+')
522 return atoi(cp);
523 while (isalpha((int)*cp))
524 *cp2++ = toupper((int)*cp++);
525 *cp2 = 0;
526 for (bt = gBoolNames; bt->fName; bt++)
527 if (strcmp(buf2, bt->fName) == 0)
528 return bt->fValue;
529 }
530 }
531 return dflt;
532}
533
534////////////////////////////////////////////////////////////////////////////////
535/// Returns the double value for a resource. If the resource is not found
536/// return the default value.
537
539{
540 const char *cp = TEnv::Getvalue(name);
541 if (cp) {
542 char *endptr;
543 Double_t val = strtod(cp, &endptr);
544 if (val == 0.0 && cp == endptr)
545 return dflt;
546 return val;
547 }
548 return dflt;
549}
550
551////////////////////////////////////////////////////////////////////////////////
552/// Returns the character value for a named resource. If the resource is
553/// not found the default value is returned.
554
555const char *TEnv::GetValue(const char *name, const char *dflt) const
556{
557 const char *cp = TEnv::Getvalue(name);
558 if (cp)
559 return cp;
560 return dflt;
561}
562
563////////////////////////////////////////////////////////////////////////////////
564/// Loop over all resource records and return the one with name.
565/// Return 0 in case name is not in the resource table.
566
567TEnvRec *TEnv::Lookup(const char *name) const
568{
569 if (!fTable) return nullptr;
570 return (TEnvRec*) fTable->FindObject(name);
571}
572
573////////////////////////////////////////////////////////////////////////////////
574/// Print all resources or the global, user or local resources separately.
575
576void TEnv::Print(Option_t *opt) const
577{
578 if (!opt || !opt[0]) {
579 PrintEnv();
580 return;
581 }
582
583 if (!strcmp(opt, "global"))
585 if (!strcmp(opt, "user"))
587 if (!strcmp(opt, "local"))
589}
590
591////////////////////////////////////////////////////////////////////////////////
592/// Print all resources for a certain level (global, user, local, changed).
593
594void TEnv::PrintEnv(EEnvLevel level) const
595{
596 if (!fTable) return;
597
598 TIter next(fTable);
599 TEnvRec *er;
600 static const char *lc[] = { "Global", "User", "Local", "Changed", "All" };
601
602 while ((er = (TEnvRec*) next()))
603 if (er->fLevel == level || level == kEnvAll)
604 Printf("%-25s %-30s [%s]", TString::Format("%s:", er->fName.Data()).Data(),
605 er->fValue.Data(), lc[er->fLevel]);
606}
607
608////////////////////////////////////////////////////////////////////////////////
609/// Read and parse the resource file for a certain level.
610/// Returns -1 on case of error, 0 in case of success.
611
613{
614 if (!fname || !fname[0]) {
615 Error("ReadFile", "no file name specified");
616 return -1;
617 }
618
619 FILE *ifp;
620 if ((ifp = fopen(fname, "r"))) {
621 TReadEnvParser rp(this, ifp, level);
622 rp.Parse();
623 fclose(ifp);
624 return 0;
625 }
626
627 // no Error() here since we are allowed to try to read from a non-existing
628 // file (like ./.rootrc, $HOME/.rootrc, etc.)
629 return -1;
630}
631
632////////////////////////////////////////////////////////////////////////////////
633/// Write resource records to file fname for a certain level. Use
634/// level kEnvAll to write all resources. Returns -1 on case of error,
635/// 0 in case of success.
636
638{
639 if (!fname || !fname[0]) {
640 Error("WriteFile", "no file name specified");
641 return -1;
642 }
643
644 if (!fTable) {
645 Error("WriteFile", "TEnv table is empty");
646 return -1;
647 }
648
649 FILE *ofp;
650 if ((ofp = fopen(fname, "w"))) {
651 TIter next(fTable);
652 TEnvRec *er;
653 while ((er = (TEnvRec*) next()))
654 if (er->fLevel == level || level == kEnvAll)
655 fprintf(ofp, "%-40s %s\n", TString::Format("%s:", er->fName.Data()).Data(),
656 er->fValue.Data());
657 fclose(ofp);
658 return 0;
659 }
660
661 Error("WriteFile", "cannot open %s for writing", fname);
662 return -1;
663}
664
665////////////////////////////////////////////////////////////////////////////////
666/// Write the resource files for each level. The new files have the same
667/// name as the original files. The old files are renamed to *.bak.
668
670{
671 if (fRcName == "") {
672 Error("Save", "no resource file name specified");
673 return;
674 }
675
676 SaveLevel(kEnvLocal); // Be default, new items will be put into Local.
679}
680
681////////////////////////////////////////////////////////////////////////////////
682/// Write the resource file for a certain level.
683
685{
686 if (fRcName == "") {
687 Error("SaveLevel", "no resource file name specified");
688 return;
689 }
690
691 if (!fTable) {
692 Error("SaveLevel", "TEnv table is empty");
693 return;
694 }
695
697 FILE *ifp, *ofp;
698
699 if (level == kEnvGlobal) {
700 TString sname = "system";
701 sname += fRcName;
703 } else if (level == kEnvUser) {
705 } else if (level == kEnvLocal) {
707 } else {
708 return;
709 }
710
711 if ((ofp = fopen(TString::Format("%s.new", rootrcdir.Data()).Data(), "w"))) {
712 ifp = fopen(rootrcdir.Data(), "r");
713 if (ifp == nullptr) { // try to create file
714 ifp = fopen(rootrcdir.Data(), "w");
715 if (ifp) {
716 fclose(ifp);
717 ifp = nullptr;
718 }
719 }
720 if (ifp || (ifp = fopen(rootrcdir.Data(), "r"))) {
721 TWriteEnvParser wp(this, ifp, ofp);
722 wp.Parse();
723
724 TIter next(fTable);
725 TEnvRec *er;
726 while ((er = (TEnvRec*) next())) {
727 if (er->fModified) {
728
729 // If it doesn't have a level yet, make it this one.
730 if (er->fLevel == kEnvChange) er->fLevel = level;
731 if (er->fLevel == level) {
732 er->fModified = kFALSE;
733 fprintf(ofp, "%-40s %s\n", TString::Format("%s:", er->fName.Data()).Data(),
734 er->fValue.Data());
735 }
736 }
737 }
738 fclose(ifp);
739 fclose(ofp);
740 gSystem->Rename(rootrcdir.Data(), TString::Format("%s.bak", rootrcdir.Data()).Data());
741 gSystem->Rename(TString::Format("%s.new", rootrcdir.Data()).Data(), rootrcdir.Data());
742 return;
743 }
744 fclose(ofp);
745 } else
746 Error("SaveLevel", "cannot write to file %s", rootrcdir.Data());
747}
748
749////////////////////////////////////////////////////////////////////////////////
750/// Set the value of a resource or create a new resource.
751
752void TEnv::SetValue(const char *name, const char *value, EEnvLevel level,
753 const char *type)
754{
755 if (!fTable)
756 fTable = new THashList(1000);
757
758 const char *nam = name;
759 Bool_t append = kFALSE;
760 if (name[0] == '+') {
761 nam = &name[1];
762 append = kTRUE;
763 }
764
765 TEnvRec *er = Lookup(nam);
766 if (er)
767 er->ChangeValue(value, type, level, append, fIgnoreDup);
768 else
769 fTable->Add(new TEnvRec(nam, value, type, level));
770}
771
772////////////////////////////////////////////////////////////////////////////////
773/// Set the value of a resource or create a new resource.
774/// Use this method to set a resource like, "name=val".
775/// If just "name" is given it will be interpreted as "name=1".
776
777void TEnv::SetValue(const char *name, EEnvLevel level)
778{
779 TString buf = name;
780 int l = buf.Index("=");
781 if (l > 0) {
782 TString nm = buf(0, l);
783 TString val = buf(l+1, buf.Length());
784 SetValue(nm, val, level);
785 } else
786 SetValue(name, "1", level);
787}
788
789////////////////////////////////////////////////////////////////////////////////
790/// Set or create an integer resource value.
791
792void TEnv::SetValue(const char *name, Int_t value)
793{
794 SetValue(name, TString::Format("%d", value).Data());
795}
796
797////////////////////////////////////////////////////////////////////////////////
798/// Set or create a double resource value.
799
801{
802 SetValue(name, TString::Format("%g", value).Data());
803}
804
805////////////////////////////////////////////////////////////////////////////////
806/// If set to true, no warnings in case of duplicates are issued.
807/// Returns previous value.
808
#define SafeDelete(p)
Definition RConfig.hxx:525
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define s1(x)
Definition RSha256.hxx:91
#define e(i)
Definition RSha256.hxx:103
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
TEnv * gEnv
Definition TEnv.cxx:87
static struct BoolNameTable_t gBoolNames[]
EEnvLevel
Definition TEnv.h:24
@ kEnvUser
Definition TEnv.h:26
@ kEnvChange
Definition TEnv.h:28
@ kEnvAll
Definition TEnv.h:29
@ kEnvGlobal
Definition TEnv.h:25
@ kEnvLocal
Definition TEnv.h:27
winID h TVirtualViewer3D vv
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
Definition TGX11.cxx:148
#define gROOT
Definition TROOT.h:417
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2510
char * StrDup(const char *str)
Duplicate the string str.
Definition TString.cxx:2564
R__EXTERN const char * gProgName
Definition TSystem.h:252
R__EXTERN TSystem * gSystem
Definition TSystem.h:582
TEnv Parser.
Definition TEnv.cxx:110
virtual ~TEnvParser()
Definition TEnv.cxx:120
virtual void Char(Int_t)
Definition TEnv.cxx:122
void Parse()
Parse a line of the env file and create an entry in the resource dictionary (i.e.
Definition TEnv.cxx:130
TEnvParser(TEnv *e, FILE *f)
Definition TEnv.cxx:119
TEnv * fEnv
Definition TEnv.cxx:116
virtual void KeyValue(const TString &, const TString &, const TString &)
Definition TEnv.cxx:121
FILE * fIfp
Definition TEnv.cxx:113
Definition TEnv.h:41
TString fValue
Definition TEnv.h:51
void ChangeValue(const char *v, const char *t, EEnvLevel l, Bool_t append=kFALSE, Bool_t ignoredup=kFALSE)
Change the value of a resource.
Definition TEnv.cxx:297
EEnvLevel fLevel
Definition TEnv.h:52
TEnvRec()
Definition TEnv.h:62
TString ExpandValue(const char *v)
Replace all strings by the value defined in the shell (obtained via TSystem::Getenv()).
Definition TEnv.cxx:338
TString fName
Definition TEnv.h:49
Bool_t fModified
Definition TEnv.h:53
~TEnvRec()
TNamed destructor.
Definition TEnv.cxx:288
Int_t Compare(const TObject *obj) const override
Comparison function for resources.
Definition TEnv.cxx:329
The TEnv class reads config files, by default named .rootrc.
Definition TEnv.h:79
THashList * fTable
Definition TEnv.h:82
void Print(Option_t *option="") const override
Print all resources or the global, user or local resources separately.
Definition TEnv.cxx:576
const char * GetUserDirectory() const
Returns the home directory or, if set, the value of the environment variable ROOTENV_USER_PATH.
Definition TEnv.cxx:395
virtual void PrintEnv(EEnvLevel level=kEnvAll) const
Print all resources for a certain level (global, user, local, changed).
Definition TEnv.cxx:594
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:511
TString fRcName
Definition TEnv.h:83
virtual Int_t WriteFile(const char *fname, EEnvLevel level=kEnvAll)
Write resource records to file fname for a certain level.
Definition TEnv.cxx:637
Bool_t IgnoreDuplicates(Bool_t ignore)
If set to true, no warnings in case of duplicates are issued.
Definition TEnv.cxx:809
virtual Int_t ReadFile(const char *fname, EEnvLevel level)
Read and parse the resource file for a certain level.
Definition TEnv.cxx:612
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=nullptr)
Set the value of a resource or create a new resource.
Definition TEnv.cxx:752
virtual TEnvRec * Lookup(const char *n) const
Loop over all resource records and return the one with name.
Definition TEnv.cxx:567
virtual void Save()
Write the resource files for each level.
Definition TEnv.cxx:669
Bool_t fIgnoreDup
Definition TEnv.h:84
const char * Getvalue(const char *name) const
Returns the character value for a named resource.
Definition TEnv.cxx:461
virtual void SaveLevel(EEnvLevel level)
Write the resource file for a certain level.
Definition TEnv.cxx:684
virtual ~TEnv()
Delete the resource table.
Definition TEnv.cxx:450
TEnv(const TEnv &)=delete
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.
void Add(TObject *obj) override
Definition TList.h:81
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
Mother of all ROOT objects.
Definition TObject.h:42
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1084
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1098
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
Definition TROOT.cxx:3381
void KeyValue(const TString &name, const TString &value, const TString &type) override
Definition TEnv.cxx:239
TReadEnvParser(TEnv *e, FILE *f, EEnvLevel l)
Definition TEnv.cxx:238
EEnvLevel fLevel
Definition TEnv.cxx:235
Basic string class.
Definition TString.h:138
Ssiz_t Length() const
Definition TString.h:425
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Definition TString.cxx:464
const char * Data() const
Definition TString.h:384
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2385
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:660
virtual const char * Getenv(const char *env)
Get environment variable.
Definition TSystem.cxx:1680
virtual const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
Definition TSystem.cxx:1096
virtual int Rename(const char *from, const char *to)
Rename a file.
Definition TSystem.cxx:1365
virtual const char * WorkingDirectory()
Return working directory.
Definition TSystem.cxx:885
virtual const char * HomeDirectory(const char *userName=nullptr)
Return the user's home directory.
Definition TSystem.cxx:901
void KeyValue(const TString &name, const TString &value, const TString &type) override
Write resources out to a new file.
Definition TEnv.cxx:260
void Char(Int_t c) override
Definition TEnv.cxx:254
TWriteEnvParser(TEnv *e, FILE *f, FILE *of)
Definition TEnv.cxx:252
FILE * fOfp
Definition TEnv.cxx:249
const Int_t n
Definition legend1.C:16
void CallRecursiveRemoveIfNeeded(TObject &obj)
call RecursiveRemove for obj if gROOT is valid and obj.TestBit(kMustCleanup) is true.
Definition TROOT.h:406
Int_t fValue
Definition TEnv.cxx:92
const char * fName
Definition TEnv.cxx:91
TLine l
Definition textangle.C:4