68#include "RConfigure.h"
133 while ((
c = fgetc(
fIfp)) != EOF) {
138 if (
name.Length() > 0) {
181 if (
c !=
' ' &&
c !=
'\t')
194 state = (
c ==
':') ? 3 : 4;
198 state = (
c ==
')') ? 6 : 5;
217 if (
name.Length() > 0) {
275 : fName(
n), fType(t), fLevel(
l)
301 "duplicate entry <%s=%s> for level %d; ignored",
fName.
Data(),
v,
l);
342 while ((
s1 = (
char*)strstr(
v,
"$("))) {
344 s2 = (
char*)strchr(
s1,
')');
362 int nch = strlen(
v) +
len;
363 char *nv =
new char[nch];
366 while ((
s1 = (
char*)strstr(
v,
"$("))) {
371 s2 = (
char*)strchr(
s1,
')');
374 if (
vv) strlcat(nv,
vv,nch);
379 if (*
v) strlcat(nv,
v,nch);
445 haveProgName =
kTRUE;
451 aname +=
"."; aname +=
name;
456 aname +=
"."; aname +=
name;
459 if (er ==
nullptr &&
gSystem) {
463 if (er ==
nullptr && haveProgName &&
gProgName) {
467 if (er ==
nullptr &&
gROOT) {
468 aname =
gROOT->GetName(); aname +=
"."; aname +=
name;
472 aname =
"*.*."; aname +=
name;
476 aname =
"*."; aname +=
name;
495 char buf2[512], *cp2 = buf2;
497 while (isspace((
int)*cp))
501 if (isdigit((
int)*cp) || *cp ==
'-' || *cp ==
'+')
503 while (isalpha((
int)*cp))
504 *cp2++ = toupper((
int)*cp++);
507 if (strcmp(buf2, bt->
fName) == 0)
524 if (val == 0.0 && cp == endptr)
549 if (!
fTable)
return nullptr;
558 if (!opt || !opt[0]) {
563 if (!strcmp(opt,
"global"))
565 if (!strcmp(opt,
"user"))
567 if (!strcmp(opt,
"local"))
580 static const char *lc[] = {
"Global",
"User",
"Local",
"Changed",
"All" };
582 while ((er = (
TEnvRec*) next()))
594 if (!fname || !fname[0]) {
595 Error(
"ReadFile",
"no file name specified");
600 if ((ifp = fopen(fname,
"r"))) {
619 if (!fname || !fname[0]) {
620 Error(
"WriteFile",
"no file name specified");
625 Error(
"WriteFile",
"TEnv table is empty");
630 if ((ofp = fopen(fname,
"w"))) {
633 while ((er = (
TEnvRec*) next()))
641 Error(
"WriteFile",
"cannot open %s for writing", fname);
652 Error(
"Save",
"no resource file name specified");
667 Error(
"SaveLevel",
"no resource file name specified");
672 Error(
"SaveLevel",
"TEnv table is empty");
696 ifp = fopen(rootrcdir.
Data(),
"r");
697 if (ifp ==
nullptr) {
698 ifp = fopen(rootrcdir.
Data(),
"w");
704 if (ifp || (ifp = fopen(rootrcdir.
Data(),
"r"))) {
710 while ((er = (
TEnvRec*) next())) {
715 if (er->
fLevel == level) {
730 Error(
"SaveLevel",
"cannot write to file %s", rootrcdir.
Data());
742 const char *nam =
name;
744 if (
name[0] ==
'+') {
static struct BoolNameTable_t gBoolNames[]
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
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
char * StrDup(const char *str)
Duplicate the string str.
R__EXTERN const char * gProgName
R__EXTERN TSystem * gSystem
void Parse()
Parse a line of the env file and create an entry in the resource dictionary (i.e.
TEnvParser(TEnv *e, FILE *f)
virtual void KeyValue(const TString &, const TString &, const TString &)
void ChangeValue(const char *v, const char *t, EEnvLevel l, Bool_t append=kFALSE, Bool_t ignoredup=kFALSE)
Change the value of a resource.
TString ExpandValue(const char *v)
Replace all strings by the value defined in the shell (obtained via TSystem::Getenv()).
~TEnvRec()
TNamed destructor.
Int_t Compare(const TObject *obj) const override
Comparison function for resources.
The TEnv class reads config files, by default named .rootrc.
void Print(Option_t *option="") const override
Print all resources or the global, user or local resources separately.
virtual void PrintEnv(EEnvLevel level=kEnvAll) const
Print all resources for a certain level (global, user, local, changed).
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
virtual Int_t WriteFile(const char *fname, EEnvLevel level=kEnvAll)
Write resource records to file fname for a certain level.
Bool_t IgnoreDuplicates(Bool_t ignore)
If set to true, no warnings in case of duplicates are issued.
virtual Int_t ReadFile(const char *fname, EEnvLevel level)
Read and parse the resource file for a certain level.
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.
virtual TEnvRec * Lookup(const char *n) const
Loop over all resource records and return the one with name.
virtual void Save()
Write the resource files for each level.
const char * Getvalue(const char *name) const
Returns the character value for a named resource.
virtual void SaveLevel(EEnvLevel level)
Write the resource file for a certain level.
virtual ~TEnv()
Delete the resource table.
TEnv(const TEnv &)=delete
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
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
const char * GetName() const override
Returns name of object.
Mother of all ROOT objects.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
void KeyValue(const TString &name, const TString &value, const TString &type) override
TReadEnvParser(TEnv *e, FILE *f, EEnvLevel l)
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
const char * Data() const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
virtual const char * Getenv(const char *env)
Get environment variable.
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name. User must delete returned string.
virtual int Rename(const char *from, const char *to)
Rename a file.
virtual const char * WorkingDirectory()
Return working directory.
virtual const char * HomeDirectory(const char *userName=nullptr)
Return the user's home directory.
void KeyValue(const TString &name, const TString &value, const TString &type) override
Write resources out to a new file.
void Char(Int_t c) override
TWriteEnvParser(TEnv *e, FILE *f, FILE *of)
void CallRecursiveRemoveIfNeeded(TObject &obj)
call RecursiveRemove for obj if gROOT is valid and obj.TestBit(kMustCleanup) is true.