Logo ROOT  
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 
15 The TEnv class reads config files, by default named `.rootrc`.
16 Three types of config files are read: global, user and local files. The
17 global file is `$ROOTSYS/etc/system<name>` (or `ROOTETCDIR/system<name>`)
18 the user file is `$HOME/<name>` and the local file is `./<name>`.
19 By setting the shell variable `ROOTENV_NO_HOME=1` the reading of
20 the `$HOME/<name>` resource file will be skipped. This might be useful
21 in case the home directory resides on an auto-mounted remote file
22 system and one wants to avoid this file system from being mounted.
23 
24 The format of the `.rootrc` file is similar to the `.Xdefaults` format:
25 ~~~ {.cpp}
26  [+]<SystemName>.<RootName|ProgName>.<name>[(type)]: <value>
27 ~~~
28 Where `<SystemName>` is either Unix, WinNT, MacOS or Vms,
29 `<RootName>` the name as given in the TApplication ctor (or "RootApp"
30 in case no explicit TApplication derived object was created),
31 `<ProgName>` the current program name and `<name>` the resource name,
32 with optionally a type specification. `<value>` can be either a
33 string, an integer, a float/double or a boolean with the values
34 TRUE, FALSE, ON, OFF, YES, NO, OK, NOT. Booleans will be returned as
35 an integer 0 or 1. The options [+] allows the concatenation of
36 values to the same resource name.
37 
38 E.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 "*".
46 A # in the first column starts comment line.
47 
48 Note that the environment variables (like $ROOTSYS) need to be
49 surrounded in parentheses in order to be expanded.
50 
51 For the currently defined resources (and their default values) see
52 `$ROOTSYS/etc/system.rootrc`.
53 
54 Note that the .rootrc config files contain the config for all ROOT
55 based applications.
56 
57 To add new entries to a TEnv:
58 ~~~ {.cpp}
59 TEnv env(".myfile");
60 env.SetValue("myname","value");
61 env.SaveLevel(kEnvLocal);
62 ~~~
63 All new entries will be saved in the file corresponding to the
64 first SaveLevel() command. If Save() is used, new entries go
65 into 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 
83 TEnv *gEnv; // main environment created in TROOT
84 
85 
86 static struct BoolNameTable_t {
87  const char *fName;
88  Int_t fValue;
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  { 0, 0 }
99 };
100 
101 
102 /** \class TEnvParser
103 TEnv Parser.
104 */
105 
106 class TEnvParser {
107 
108 private:
109  FILE *fIfp;
110 
111 protected:
112  TEnv *fEnv;
113 
114 public:
115  TEnvParser(TEnv *e, FILE *f) : fIfp(f), fEnv(e) { }
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 
126 void TEnvParser::Parse()
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) {
139  KeyValue(name, value, type);
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) {
218  KeyValue(name, value, type);
219  name.Clear();
220  value.Clear();
221  type.Clear();
222  }
223 }
224 
225 /** \class TReadEnvParser
226 */
227 
228 class TReadEnvParser : public TEnvParser {
229 
230 private:
231  EEnvLevel fLevel;
232 
233 public:
234  TReadEnvParser(TEnv *e, FILE *f, EEnvLevel l) : TEnvParser(e, f), fLevel(l) { }
235  void KeyValue(const TString &name, const TString &value, const TString &type)
236  { fEnv->SetValue(name, value, fLevel, type); }
237 };
238 
239 /** \class TWriteEnvParser
240 */
241 
242 class TWriteEnvParser : public TEnvParser {
243 
244 private:
245  FILE *fOfp;
246 
247 public:
248  TWriteEnvParser(TEnv *e, FILE *f, FILE *of) : TEnvParser(e, f), fOfp(of) { }
249  void KeyValue(const TString &name, const TString &value, const TString &type);
250  void Char(Int_t c) { fputc(c, fOfp); }
251 };
252 
253 ////////////////////////////////////////////////////////////////////////////////
254 /// Write resources out to a new file.
255 
256 void TWriteEnvParser::KeyValue(const TString &name, const TString &value,
257  const TString &)
258 {
259  TEnvRec *er = fEnv->Lookup(name);
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 
274 TEnvRec::TEnvRec(const char *n, const char *v, const char *t, EEnvLevel l)
275  : fName(n), fType(t), fLevel(l)
276 {
277  fValue = ExpandValue(v);
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 
293 void 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)
307  fModified = kTRUE;
308  else
309  fModified = kFALSE;
310  fLevel = l;
311  fValue = ExpandValue(v);
312  }
313  } else {
314  if (l == kEnvChange)
315  fModified = kTRUE;
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 
334 TString TEnvRec::ExpandValue(const char *value)
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 ClassImp(TEnv);
389 
390 ////////////////////////////////////////////////////////////////////////////////
391 /// Create a resource table and read the (possibly) three resource files, i.e
392 /// `$ROOTSYS/etc/system``<name>` (or `ROOTETCDIR/system``<name>`),
393 /// `$HOME/``<name>` and
394 /// `./``<name>`.
395 /// ROOT always reads ".rootrc" (in TROOT::InitSystem()). You can
396 /// read additional user defined resource files by creating additional TEnv
397 /// objects. By setting the shell variable ROOTENV_NO_HOME=1 the reading of
398 /// the `$HOME/<name>` resource file will be skipped. This might be useful in
399 /// case the home directory resides on an auto-mounted remote file system
400 /// and one wants to avoid the file system from being mounted.
401 
402 TEnv::TEnv(const char *name)
403 {
404  fIgnoreDup = kFALSE;
405 
406  if (!name || !name[0] || !gSystem)
407  fTable = 0;
408  else {
409  fTable = new THashList(1000);
410  fRcName = name;
411 
412  TString sname = "system";
413  sname += name;
414  char *s = gSystem->ConcatFileName(TROOT::GetEtcDir(), sname);
416  delete [] s;
417  if (!gSystem->Getenv("ROOTENV_NO_HOME")) {
419  ReadFile(s, kEnvUser);
420  delete [] s;
421  if (strcmp(gSystem->HomeDirectory(), gSystem->WorkingDirectory()))
423  } else
425  }
426 }
427 
428 ////////////////////////////////////////////////////////////////////////////////
429 /// Delete the resource table.
430 
432 {
433  if (fTable) {
434  fTable->Delete();
436  }
437 }
438 
439 ////////////////////////////////////////////////////////////////////////////////
440 /// Returns the character value for a named resource.
441 
442 const char *TEnv::Getvalue(const char *name) const
443 {
444  Bool_t haveProgName = kFALSE;
445  if (gProgName && strlen(gProgName) > 0)
446  haveProgName = kTRUE;
447 
448  TString aname;
449  TEnvRec *er = 0;
450  if (haveProgName && gSystem && gProgName) {
451  aname = gSystem->GetName(); aname += "."; aname += gProgName;
452  aname += "."; aname += name;
453  er = Lookup(aname);
454  }
455  if (er == 0 && gSystem && gROOT) {
456  aname = gSystem->GetName(); aname += "."; aname += gROOT->GetName();
457  aname += "."; aname += name;
458  er = Lookup(aname);
459  }
460  if (er == 0 && gSystem) {
461  aname = gSystem->GetName(); aname += ".*."; aname += name;
462  er = Lookup(aname);
463  }
464  if (er == 0 && haveProgName && gProgName) {
465  aname = gProgName; aname += "."; aname += name;
466  er = Lookup(aname);
467  }
468  if (er == 0 && gROOT) {
469  aname = gROOT->GetName(); aname += "."; aname += name;
470  er = Lookup(aname);
471  }
472  if (er == 0) {
473  aname = "*.*."; aname += name;
474  er = Lookup(aname);
475  }
476  if (er == 0) {
477  aname = "*."; aname += name;
478  er = Lookup(aname);
479  }
480  if (er == 0) {
481  er = Lookup(name);
482  }
483  if (er == 0)
484  return 0;
485  return er->fValue;
486 }
487 
488 ////////////////////////////////////////////////////////////////////////////////
489 /// Returns the integer value for a resource. If the resource is not found
490 /// return the default value.
491 
492 Int_t TEnv::GetValue(const char *name, Int_t dflt) const
493 {
494  const char *cp = TEnv::Getvalue(name);
495  if (cp) {
496  char buf2[512], *cp2 = buf2;
497 
498  while (isspace((int)*cp))
499  cp++;
500  if (*cp) {
501  BoolNameTable_t *bt;
502  if (isdigit((int)*cp) || *cp == '-' || *cp == '+')
503  return atoi(cp);
504  while (isalpha((int)*cp))
505  *cp2++ = toupper((int)*cp++);
506  *cp2 = 0;
507  for (bt = gBoolNames; bt->fName; bt++)
508  if (strcmp(buf2, bt->fName) == 0)
509  return bt->fValue;
510  }
511  }
512  return dflt;
513 }
514 
515 ////////////////////////////////////////////////////////////////////////////////
516 /// Returns the double value for a resource. If the resource is not found
517 /// return the default value.
518 
519 Double_t TEnv::GetValue(const char *name, Double_t dflt) const
520 {
521  const char *cp = TEnv::Getvalue(name);
522  if (cp) {
523  char *endptr;
524  Double_t val = strtod(cp, &endptr);
525  if (val == 0.0 && cp == endptr)
526  return dflt;
527  return val;
528  }
529  return dflt;
530 }
531 
532 ////////////////////////////////////////////////////////////////////////////////
533 /// Returns the character value for a named resource. If the resource is
534 /// not found the default value is returned.
535 
536 const char *TEnv::GetValue(const char *name, const char *dflt) const
537 {
538  const char *cp = TEnv::Getvalue(name);
539  if (cp)
540  return cp;
541  return dflt;
542 }
543 
544 ////////////////////////////////////////////////////////////////////////////////
545 /// Loop over all resource records and return the one with name.
546 /// Return 0 in case name is not in the resource table.
547 
548 TEnvRec *TEnv::Lookup(const char *name) const
549 {
550  if (!fTable) return 0;
551  return (TEnvRec*) fTable->FindObject(name);
552 }
553 
554 ////////////////////////////////////////////////////////////////////////////////
555 /// Print all resources or the global, user or local resources separately.
556 
557 void TEnv::Print(Option_t *opt) const
558 {
559  if (!opt || !opt[0]) {
560  PrintEnv();
561  return;
562  }
563 
564  if (!strcmp(opt, "global"))
566  if (!strcmp(opt, "user"))
568  if (!strcmp(opt, "local"))
570 }
571 
572 ////////////////////////////////////////////////////////////////////////////////
573 /// Print all resources for a certain level (global, user, local, changed).
574 
575 void TEnv::PrintEnv(EEnvLevel level) const
576 {
577  if (!fTable) return;
578 
579  TIter next(fTable);
580  TEnvRec *er;
581  static const char *lc[] = { "Global", "User", "Local", "Changed", "All" };
582 
583  while ((er = (TEnvRec*) next()))
584  if (er->fLevel == level || level == kEnvAll)
585  Printf("%-25s %-30s [%s]", Form("%s:", er->fName.Data()),
586  er->fValue.Data(), lc[er->fLevel]);
587 }
588 
589 ////////////////////////////////////////////////////////////////////////////////
590 /// Read and parse the resource file for a certain level.
591 /// Returns -1 on case of error, 0 in case of success.
592 
593 Int_t TEnv::ReadFile(const char *fname, EEnvLevel level)
594 {
595  if (!fname || !fname[0]) {
596  Error("ReadFile", "no file name specified");
597  return -1;
598  }
599 
600  FILE *ifp;
601  if ((ifp = fopen(fname, "r"))) {
602  TReadEnvParser rp(this, ifp, level);
603  rp.Parse();
604  fclose(ifp);
605  return 0;
606  }
607 
608  // no Error() here since we are allowed to try to read from a non-existing
609  // file (like ./.rootrc, $HOME/.rootrc, etc.)
610  return -1;
611 }
612 
613 ////////////////////////////////////////////////////////////////////////////////
614 /// Write resource records to file fname for a certain level. Use
615 /// level kEnvAll to write all resources. Returns -1 on case of error,
616 /// 0 in case of success.
617 
618 Int_t TEnv::WriteFile(const char *fname, EEnvLevel level)
619 {
620  if (!fname || !fname[0]) {
621  Error("WriteFile", "no file name specified");
622  return -1;
623  }
624 
625  if (!fTable) {
626  Error("WriteFile", "TEnv table is empty");
627  return -1;
628  }
629 
630  FILE *ofp;
631  if ((ofp = fopen(fname, "w"))) {
632  TIter next(fTable);
633  TEnvRec *er;
634  while ((er = (TEnvRec*) next()))
635  if (er->fLevel == level || level == kEnvAll)
636  fprintf(ofp, "%-40s %s\n", Form("%s:", er->fName.Data()),
637  er->fValue.Data());
638  fclose(ofp);
639  return 0;
640  }
641 
642  Error("WriteFile", "cannot open %s for writing", fname);
643  return -1;
644 }
645 
646 ////////////////////////////////////////////////////////////////////////////////
647 /// Write the resource files for each level. The new files have the same
648 /// name as the original files. The old files are renamed to *.bak.
649 
651 {
652  if (fRcName == "") {
653  Error("Save", "no resource file name specified");
654  return;
655  }
656 
657  SaveLevel(kEnvLocal); // Be default, new items will be put into Local.
660 }
661 
662 ////////////////////////////////////////////////////////////////////////////////
663 /// Write the resource file for a certain level.
664 
666 {
667  if (fRcName == "") {
668  Error("SaveLevel", "no resource file name specified");
669  return;
670  }
671 
672  if (!fTable) {
673  Error("SaveLevel", "TEnv table is empty");
674  return;
675  }
676 
677  TString rootrcdir;
678  FILE *ifp, *ofp;
679 
680  if (level == kEnvGlobal) {
681 
682  TString sname = "system";
683  sname += fRcName;
684  char *s = gSystem->ConcatFileName(TROOT::GetEtcDir(), sname);
685  rootrcdir = s;
686  delete [] s;
687  } else if (level == kEnvUser) {
689  rootrcdir = s;
690  delete [] s;
691  } else if (level == kEnvLocal)
692  rootrcdir = fRcName;
693  else
694  return;
695 
696  if ((ofp = fopen(Form("%s.new", rootrcdir.Data()), "w"))) {
697  ifp = fopen(rootrcdir.Data(), "r");
698  if (ifp == 0) { // try to create file
699  ifp = fopen(rootrcdir.Data(), "w");
700  if (ifp) {
701  fclose(ifp);
702  ifp = 0;
703  }
704  }
705  if (ifp || (ifp = fopen(rootrcdir.Data(), "r"))) {
706  TWriteEnvParser wp(this, ifp, ofp);
707  wp.Parse();
708 
709  TIter next(fTable);
710  TEnvRec *er;
711  while ((er = (TEnvRec*) next())) {
712  if (er->fModified) {
713 
714  // If it doesn't have a level yet, make it this one.
715  if (er->fLevel == kEnvChange) er->fLevel = level;
716  if (er->fLevel == level) {
717  er->fModified = kFALSE;
718  fprintf(ofp, "%-40s %s\n", Form("%s:", er->fName.Data()),
719  er->fValue.Data());
720  }
721  }
722  }
723  fclose(ifp);
724  fclose(ofp);
725  gSystem->Rename(rootrcdir.Data(), Form("%s.bak", rootrcdir.Data()));
726  gSystem->Rename(Form("%s.new", rootrcdir.Data()), rootrcdir.Data());
727  return;
728  }
729  fclose(ofp);
730  } else
731  Error("SaveLevel", "cannot write to file %s", rootrcdir.Data());
732 }
733 
734 ////////////////////////////////////////////////////////////////////////////////
735 /// Set the value of a resource or create a new resource.
736 
737 void TEnv::SetValue(const char *name, const char *value, EEnvLevel level,
738  const char *type)
739 {
740  if (!fTable)
741  fTable = new THashList(1000);
742 
743  const char *nam = name;
744  Bool_t append = kFALSE;
745  if (name[0] == '+') {
746  nam = &name[1];
747  append = kTRUE;
748  }
749 
750  TEnvRec *er = Lookup(nam);
751  if (er)
752  er->ChangeValue(value, type, level, append, fIgnoreDup);
753  else
754  fTable->Add(new TEnvRec(nam, value, type, level));
755 }
756 
757 ////////////////////////////////////////////////////////////////////////////////
758 /// Set the value of a resource or create a new resource.
759 /// Use this method to set a resource like, "name=val".
760 /// If just "name" is given it will be interpreted as "name=1".
761 
762 void TEnv::SetValue(const char *name, EEnvLevel level)
763 {
764  TString buf = name;
765  int l = buf.Index("=");
766  if (l > 0) {
767  TString nm = buf(0, l);
768  TString val = buf(l+1, buf.Length());
769  SetValue(nm, val, level);
770  } else
771  SetValue(name, "1", level);
772 }
773 
774 ////////////////////////////////////////////////////////////////////////////////
775 /// Set or create an integer resource value.
776 
777 void TEnv::SetValue(const char *name, Int_t value)
778 {
779  SetValue(name, Form("%d", value));
780 }
781 
782 ////////////////////////////////////////////////////////////////////////////////
783 /// Set or create a double resource value.
784 
785 void TEnv::SetValue(const char *name, double value)
786 {
787  SetValue(name, Form("%g", value));
788 }
789 
790 ////////////////////////////////////////////////////////////////////////////////
791 /// If set to true, no warnings in case of duplicates are issued.
792 /// Returns previous value.
793 
795 {
796  Bool_t ret = fIgnoreDup;
797  fIgnoreDup = ignore;
798  return ret;
799 }
c
#define c(i)
Definition: RSha256.hxx:119
l
auto * l
Definition: textangle.C:4
TEnv::TEnv
TEnv(const TEnv &)
n
const Int_t n
Definition: legend1.C:16
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
e
#define e(i)
Definition: RSha256.hxx:121
TEnv::IgnoreDuplicates
Bool_t IgnoreDuplicates(Bool_t ignore)
If set to true, no warnings in case of duplicates are issued.
Definition: TEnv.cxx:794
f
#define f(i)
Definition: RSha256.hxx:122
TEnv::Save
virtual void Save()
Write the resource files for each level.
Definition: TEnv.cxx:650
TString::Data
const char * Data() const
Definition: TString.h:369
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
Form
char * Form(const char *fmt,...)
kEnvGlobal
@ kEnvGlobal
Definition: TEnv.h:71
gProgName
const R__EXTERN char * gProgName
Definition: TSystem.h:242
TObject::Error
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:890
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:168
gEnv
TEnv * gEnv
Definition: TEnv.cxx:83
Int_t
int Int_t
Definition: RtypesCore.h:45
TEnv::SaveLevel
virtual void SaveLevel(EEnvLevel level)
Write the resource file for a certain level.
Definition: TEnv.cxx:665
TEnv::Getvalue
const char * Getvalue(const char *name) const
Returns the character value for a named resource.
Definition: TEnv.cxx:442
SafeDelete
#define SafeDelete(p)
Definition: RConfig.hxx:543
TString::Length
Ssiz_t Length() const
Definition: TString.h:410
TEnv::GetValue
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition: TEnv.cxx:492
TEnv.h
TString
Definition: TString.h:136
TEnvRec::fValue
TString fValue
Definition: TEnv.h:97
TEnv::fTable
THashList * fTable
Definition: TEnv.h:128
TEnv::fRcName
TString fRcName
Definition: TEnv.h:129
v
@ v
Definition: rootcling_impl.cxx:3635
bool
TSystem::WorkingDirectory
virtual const char * WorkingDirectory()
Return working directory.
Definition: TSystem.cxx:870
TEnvRec
Definition: TEnv.h:87
TROOT.h
TEnvRec::~TEnvRec
~TEnvRec()
TNamed destructor.
Definition: TEnv.cxx:284
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TEnv::fIgnoreDup
Bool_t fIgnoreDup
Definition: TEnv.h:130
kEnvLocal
@ kEnvLocal
Definition: TEnv.h:73
TSystem.h
TEnvRec::ExpandValue
TString ExpandValue(const char *v)
Replace all strings by the value defined in the shell (obtained via TSystem::Getenv()).
Definition: TEnv.cxx:334
THashList
Definition: THashList.h:34
kEnvAll
@ kEnvAll
Definition: TEnv.h:75
THashList::FindObject
TObject * FindObject(const char *name) const
Find object using its name.
Definition: THashList.cxx:262
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
s1
#define s1(x)
Definition: RSha256.hxx:109
TEnvRec::fModified
Bool_t fModified
Definition: TEnv.h:99
TSystem::Rename
virtual int Rename(const char *from, const char *to)
Rename a file.
Definition: TSystem.cxx:1348
StrDup
char * StrDup(const char *str)
Duplicate the string str.
Definition: TString.cxx:2490
EEnvLevel
EEnvLevel
Definition: TEnv.h:70
TObject::Warning
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:876
THashList.h
THashList::Delete
void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: THashList.cxx:207
TString::Index
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:639
TROOT::GetEtcDir
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
Definition: TROOT.cxx:2956
Printf
void Printf(const char *fmt,...)
gSystem
R__EXTERN TSystem * gSystem
Definition: TSystem.h:559
TSystem::Getenv
virtual const char * Getenv(const char *env)
Get environment variable.
Definition: TSystem.cxx:1661
TEnvRec::TEnvRec
TEnvRec()
Definition: TEnv.h:108
TString::CompareTo
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Definition: TString.cxx:418
Double_t
double Double_t
Definition: RtypesCore.h:59
TEnv
Definition: TEnv.h:125
TList::Add
virtual void Add(TObject *obj)
Definition: TList.h:87
TObject
Definition: TObject.h:37
name
char name[80]
Definition: TGX11.cxx:110
TEnv::WriteFile
virtual Int_t WriteFile(const char *fname, EEnvLevel level=kEnvAll)
Write resource records to file fname for a certain level.
Definition: TEnv.cxx:618
TEnv::ReadFile
virtual Int_t ReadFile(const char *fname, EEnvLevel level)
Read and parse the resource file for a certain level.
Definition: TEnv.cxx:593
TSystem::ConcatFileName
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name. User must delete returned string.
Definition: TSystem.cxx:1069
TIter
Definition: TCollection.h:233
kEnvUser
@ kEnvUser
Definition: TEnv.h:72
TEnvRec::fName
TString fName
Definition: TEnv.h:95
TEnv::SetValue
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:737
ROOT::CallRecursiveRemoveIfNeeded
void CallRecursiveRemoveIfNeeded(TObject &obj)
call RecursiveRemove for obj if gROOT is valid and obj.TestBit(kMustCleanup) is true.
Definition: TROOT.h:395
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:53
type
int type
Definition: TGX11.cxx:121
sqlio::Char
const char * Char
Definition: TSQLStructure.cxx:70
TGeant4Unit::nm
static constexpr double nm
Definition: TGeant4SystemOfUnits.h:111
TEnvRec::fLevel
EEnvLevel fLevel
Definition: TEnv.h:98
TEnv::PrintEnv
virtual void PrintEnv(EEnvLevel level=kEnvAll) const
Print all resources for a certain level (global, user, local, changed).
Definition: TEnv.cxx:575
TEnv::Lookup
virtual TEnvRec * Lookup(const char *n) const
Loop over all resource records and return the one with name.
Definition: TEnv.cxx:548
TSystem::HomeDirectory
virtual const char * HomeDirectory(const char *userName=nullptr)
Return the user's home directory.
Definition: TSystem.cxx:886
gBoolNames
static struct BoolNameTable_t gBoolNames[]
kEnvChange
@ kEnvChange
Definition: TEnv.h:74
TEnvRec::ChangeValue
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
gROOT
#define gROOT
Definition: TROOT.h:406
TEnv::Print
virtual void Print(Option_t *option="") const
Print all resources or the global, user or local resources separately.
Definition: TEnv.cxx:557
int
TEnvRec::Compare
Int_t Compare(const TObject *obj) const
Comparison function for resources.
Definition: TEnv.cxx:325
TEnv::~TEnv
virtual ~TEnv()
Delete the resource table.
Definition: TEnv.cxx:431
TError.h