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