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