Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TSystem.cxx
Go to the documentation of this file.
1// @(#)root/base:$Id: 8944840ba34631ec28efc779647618db43c0eee5 $
2// Author: Fons Rademakers 15/09/95
3
4/*************************************************************************
5 * Copyright (C) 1995-2019, 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 TSystem
13\ingroup Base
14
15Abstract base class defining a generic interface to the underlying
16Operating System.
17This is not an ABC in the strict sense of the (C++) word. For
18every member function there is an implementation (often not more
19than a call to AbstractMethod() which prints a warning saying
20that the method should be overridden in a derived class), which
21allows a simple partial implementation for new OS'es.
22*/
23
26#include "strlcpy.h"
27#include "TSystem.h"
28#include "TApplication.h"
29#include "TException.h"
30#include "TROOT.h"
31#include "TClass.h"
32#include "TClassTable.h"
33#include "TEnv.h"
34#include "TOrdCollection.h"
35#include "TObject.h"
36#include "TInterpreter.h"
37#include "TRegexp.h"
38#include "TObjString.h"
39#include "TObjArray.h"
40#include "TError.h"
41#include "TPluginManager.h"
42#include "TUrl.h"
43#include "TVirtualMutex.h"
44#include "TVersionCheck.h"
45#include "compiledata.h"
46#include "RConfigure.h"
47#include "THashList.h"
48#include "ThreadLocalStorage.h"
49
50#include <functional>
51#include <iostream>
52#include <fstream>
53#include <memory>
54#include <sstream>
55#include <string>
56#include <sys/stat.h>
57#include <set>
58
59#ifdef WIN32
60#include <io.h>
61#include "Windows4Root.h"
62#endif
63
64const char *gRootDir = nullptr;
65const char *gProgName = nullptr;
66const char *gProgPath = nullptr;
67
68TSystem *gSystem = nullptr;
69TFileHandler *gXDisplay = nullptr; // Display server event handler, set in TGClient
70
71static Int_t *gLibraryVersion = nullptr; // Set in TVersionCheck, used in Load()
72static Int_t gLibraryVersionIdx = 0; // Set in TVersionCheck, used in Load()
74
75// Pin vtable
77
78////////////////////////////////////////////////////////////////////////////////
79/// Create async event processor timer. Delay is in milliseconds.
80
86
87////////////////////////////////////////////////////////////////////////////////
88/// Process events if timer did time out. Returns kTRUE if interrupt
89/// flag is set (by hitting a key in the canvas or selecting the
90/// Interrupt menu item in canvas or some other action).
91
93{
94 if (fTimeout) {
95 if (gSystem->ProcessEvents()) {
96 Remove();
97 return kTRUE;
98 } else {
99 Reset();
100 return kFALSE;
101 }
102 }
103 return kFALSE;
104}
105
106
107
108
110
111
112
113////////////////////////////////////////////////////////////////////////////////
114/// Strip off protocol string from specified path
115
116const char *TSystem::StripOffProto(const char *path, const char *proto)
117{
118 return !strncmp(path, proto, strlen(proto)) ? path + strlen(proto) : path;
119}
120
121////////////////////////////////////////////////////////////////////////////////
122/// Create a new OS interface.
123
124TSystem::TSystem(const char *name, const char *title) : TNamed(name, title)
125{
126 if (gSystem && name[0] != '-' && strcmp(name, "Generic"))
127 Error("TSystem", "only one instance of TSystem allowed");
128
129 if (!gLibraryVersion) {
132 }
133}
134
135////////////////////////////////////////////////////////////////////////////////
136/// Delete the OS interface.
137
139{
140 if (fOnExitList) {
143 }
144
145 if (fSignalHandler) {
148 }
149
150 if (fFileHandler) {
153 }
154
158 }
159
160 if (fTimers) {
161 fTimers->Delete();
163 }
164
165 if (fCompiled) {
166 fCompiled->Delete();
168 }
169
170 if (fHelpers) {
171 fHelpers->Delete();
173 }
174
175 if (gSystem == this)
176 gSystem = nullptr;
177}
178
179////////////////////////////////////////////////////////////////////////////////
180/// Initialize the OS interface.
181
183{
184 fNfd = 0;
185 fMaxrfd = -1;
186 fMaxwfd = -1;
187
188 fSigcnt = 0;
189 fLevel = 0;
190
194 fTimers = new TList;
196
206 fSoExt = SOEXT;
207 fObjExt = OBJEXT;
212
213 if (gEnv && fBeepDuration == 0 && fBeepFreq == 0) {
214 fBeepDuration = gEnv->GetValue("Root.System.BeepDuration", 100);
215 fBeepFreq = gEnv->GetValue("Root.System.BeepFreq", 440);
216 }
217 if (!fName.CompareTo("Generic")) return kTRUE;
218 return kFALSE;
219}
220
221////////////////////////////////////////////////////////////////////////////////
222/// Set the application name (from command line, argv[0]) and copy it in
223/// gProgName.
224
225void TSystem::SetProgname(const char *name)
226{
227 delete [] gProgName;
229}
230
231////////////////////////////////////////////////////////////////////////////////
232/// Set DISPLAY environment variable based on utmp entry. Only for UNIX.
233
235{
236}
237
238////////////////////////////////////////////////////////////////////////////////
239/// Set the system error string. This string will be used by GetError().
240/// To be used in case one does not want or can use the system error
241/// string (e.g. because error is generated by a third party POSIX like
242/// library that does not use standard errno).
243
245{
246 ResetErrno(); // so GetError() uses the fLastErrorString
248}
249
250////////////////////////////////////////////////////////////////////////////////
251/// Return system error string.
252
253const char *TSystem::GetError()
254{
255 if (GetErrno() == 0 && !GetLastErrorString().IsNull())
256 return GetLastErrorString().Data();
257 return Form("errno: %d", GetErrno());
258}
259
260////////////////////////////////////////////////////////////////////////////////
261/// Return cryptographic random number
262/// Fill provided buffer with random values. The number of requested random bytes must not exceed 256.
263/// Returns number of bytes written to buffer or -1 in case of error
264
266{
267 if (len < 0) {
268 return -1;
269 }
270 const auto rv = ROOT::Internal::GetCryptoRandom(buf, len);
271 return rv ? len : -1;
272}
273
274
275////////////////////////////////////////////////////////////////////////////////
276/// Static function returning system error number.
277
279{
280 return errno;
281}
282
283////////////////////////////////////////////////////////////////////////////////
284/// Static function resetting system error number.
285
287{
288 errno = 0;
289}
290
291////////////////////////////////////////////////////////////////////////////////
292/// Objects that should be deleted on exit of the OS interface.
293
295{
296 if (!fOnExitList)
298 if (!fOnExitList->FindObject(obj))
299 fOnExitList->Add(obj);
300}
301
302////////////////////////////////////////////////////////////////////////////////
303/// Return the system's host name.
304
305const char *TSystem::HostName()
306{
307 return "Local host";
308}
309
310////////////////////////////////////////////////////////////////////////////////
311/// Hook to tell TSystem that the TApplication object has been created.
312
314{
315 // Currently needed only for WinNT interface.
316}
317
318////////////////////////////////////////////////////////////////////////////////
319/// Beep for duration milliseconds with a tone of frequency freq.
320/// Defaults to printing the `\a` character to stdout.
321/// If freq or duration is <0 respectively, use default value.
322/// If setDefault is set, only set the frequency and duration as
323/// new defaults, but don't beep.
324/// If default freq or duration is <0, never beep (silence)
325
326void TSystem::Beep(Int_t freq /*=-1*/, Int_t duration /*=-1*/,
327 Bool_t setDefault /*=kFALSE*/)
328{
329 if (setDefault) {
330 fBeepFreq = freq;
332 return;
333 }
334 if (fBeepDuration < 0 || fBeepFreq < 0) return; // silence
335 if (freq < 0) freq = fBeepFreq;
338}
339
340//---- EventLoop ---------------------------------------------------------------
341
342////////////////////////////////////////////////////////////////////////////////
343/// System event loop.
344
346{
348 fDone = kFALSE;
349
351 try {
352 RETRY {
353 while (!fDone) {
355 InnerLoop();
357 }
358 } ENDTRY;
359 }
360 catch (std::exception& exc) {
362 TStdExceptionHandler* eh = nullptr;
363 while ((eh = (TStdExceptionHandler*) next())) {
364 switch (eh->Handle(exc))
365 {
367 break;
369 goto loop_entry;
370 break;
372 Warning("Run", "instructed to abort");
373 goto loop_end;
374 break;
375 }
376 }
377 throw;
378 }
379 catch (const char *str) {
380 printf("%s\n", str);
381 }
382 // handle every exception
383 catch (...) {
384 Warning("Run", "handle uncaught exception, terminating");
385 }
386
389}
390
391////////////////////////////////////////////////////////////////////////////////
392/// Exit from event loop.
393
395{
396 fDone = kTRUE;
397}
398
399////////////////////////////////////////////////////////////////////////////////
400/// Inner event loop.
401
403{
404 fLevel++;
406 fLevel--;
407}
408
409////////////////////////////////////////////////////////////////////////////////
410/// Process pending events (GUI, timers, sockets). Returns the result of
411/// TROOT::IsInterrupted(). The interrupt flag (TROOT::SetInterrupt())
412/// can be set during the handling of the events. This mechanism allows
413/// macros running in tight calculating loops to be interrupted by some
414/// GUI event (depending on the interval with which this method is
415/// called). For example hitting ctrl-c in a canvas will set the
416/// interrupt flag.
417
419{
420 gROOT->SetInterrupt(kFALSE);
421
422 if (!gROOT->TestBit(TObject::kInvalidObject))
424
425 return gROOT->IsInterrupted();
426}
427
428////////////////////////////////////////////////////////////////////////////////
429/// Dispatch a single event.
430
432{
433 AbstractMethod("DispatchOneEvent");
434}
435
436////////////////////////////////////////////////////////////////////////////////
437/// Sleep milliSec milli seconds.
438
440{
441 AbstractMethod("Sleep");
442}
443
444////////////////////////////////////////////////////////////////////////////////
445/// Select on active file descriptors (called by TMonitor).
446
448{
449 AbstractMethod("Select");
450 return -1;
451}
452////////////////////////////////////////////////////////////////////////////////
453/// Select on active file descriptors (called by TMonitor).
454
456{
457 AbstractMethod("Select");
458 return -1;
459}
460
461//---- handling of system events -----------------------------------------------
462////////////////////////////////////////////////////////////////////////////////
463/// Get current time in milliseconds since 0:00 Jan 1 1995.
464
466{
467 return TTime(0);
468}
469
470////////////////////////////////////////////////////////////////////////////////
471/// Add timer to list of system timers.
472
474{
475 if (ti && fTimers && (fTimers->FindObject(ti) == nullptr))
476 fTimers->Add(ti);
477}
478
479////////////////////////////////////////////////////////////////////////////////
480/// Remove timer from list of system timers. Returns removed timer or 0
481/// if timer was not active.
482
484{
485 if (fTimers) {
487 return tr;
488 }
489 return nullptr;
490}
491
492////////////////////////////////////////////////////////////////////////////////
493/// Time when next timer of mode (synchronous=kTRUE or
494/// asynchronous=kFALSE) will time-out (in ms).
495
497{
498 if (!fTimers) return -1;
499
500 TListIter it(fTimers);
501 TTimer *t, *to = nullptr;
502 Long64_t tt, tnow = Now();
503 Long_t timeout = -1;
504
505 while ((t = (TTimer *) it.Next())) {
506 if (t->IsSync() == mode) {
507 tt = (Long64_t)t->GetAbsTime() - tnow;
508 if (tt < 0) tt = 0;
509 if (timeout == -1) {
510 timeout = (Long_t)tt;
511 to = t;
512 }
513 if (tt < timeout) {
514 timeout = (Long_t)tt;
515 to = t;
516 }
517 }
518 }
519
520 if (to && to->IsAsync() && timeout > 0) {
521 if (to->IsInterruptingSyscalls())
523 else
525 }
526
527 return timeout;
528}
529
530////////////////////////////////////////////////////////////////////////////////
531/// Add a signal handler to list of system signal handlers. Only adds
532/// the handler if it is not already in the list of signal handlers.
533
539
540////////////////////////////////////////////////////////////////////////////////
541/// Remove a signal handler from list of signal handlers. Returns
542/// the handler or 0 if the handler was not in the list of signal handlers.
543
551
552////////////////////////////////////////////////////////////////////////////////
553/// Add a file handler to the list of system file handlers. Only adds
554/// the handler if it is not already in the list of file handlers.
555
561
562////////////////////////////////////////////////////////////////////////////////
563/// Remove a file handler from the list of file handlers. Returns
564/// the handler or 0 if the handler was not in the list of file handlers.
565
567{
568 if (fFileHandler)
569 return (TFileHandler *)fFileHandler->Remove(h);
570
571 return nullptr;
572}
573
574////////////////////////////////////////////////////////////////////////////////
575/// If reset is true reset the signal handler for the specified signal
576/// to the default handler, else restore previous behaviour.
577
578void TSystem::ResetSignal(ESignals /*sig*/, Bool_t /*reset*/)
579{
580 AbstractMethod("ResetSignal");
581}
582
583////////////////////////////////////////////////////////////////////////////////
584/// Reset signals handlers to previous behaviour.
585
587{
588 AbstractMethod("ResetSignals");
589}
590
591////////////////////////////////////////////////////////////////////////////////
592/// If ignore is true ignore the specified signal, else restore previous
593/// behaviour.
594
595void TSystem::IgnoreSignal(ESignals /*sig*/, Bool_t /*ignore*/)
596{
597 AbstractMethod("IgnoreSignal");
598}
599
600////////////////////////////////////////////////////////////////////////////////
601/// If ignore is true ignore the interrupt signal, else restore previous
602/// behaviour. Typically call ignore interrupt before writing to disk.
603
608
609////////////////////////////////////////////////////////////////////////////////
610/// Add an exception handler to list of system exception handlers. Only adds
611/// the handler if it is not already in the list of exception handlers.
612
618
619////////////////////////////////////////////////////////////////////////////////
620/// Remove an exception handler from list of exception handlers. Returns
621/// the handler or 0 if the handler was not in the list of exception handlers.
622
630
631////////////////////////////////////////////////////////////////////////////////
632/// Return the bitmap of conditions that trigger a floating point exception.
633
635{
636 AbstractMethod("GetFPEMask");
637 return 0;
638}
639
640////////////////////////////////////////////////////////////////////////////////
641/// Set which conditions trigger a floating point exception.
642/// Return the previous set of conditions.
643
645{
646 AbstractMethod("SetFPEMask");
647 return 0;
648}
649
650//---- Processes ---------------------------------------------------------------
651
652////////////////////////////////////////////////////////////////////////////////
653/// Execute a command.
654
655int TSystem::Exec(const char *)
656{
657 AbstractMethod("Exec");
658 return -1;
659}
660
661////////////////////////////////////////////////////////////////////////////////
662/// Open a pipe.
663
664FILE *TSystem::OpenPipe(const char *, const char *)
665{
666 AbstractMethod("OpenPipe");
667 return nullptr;
668}
669
670////////////////////////////////////////////////////////////////////////////////
671/// Close the pipe.
672
674{
675 AbstractMethod("ClosePipe");
676 return -1;
677}
678
679////////////////////////////////////////////////////////////////////////////////
680/// Execute command and return output in TString.
681/// @param command the command to be executed
682/// @param ret pointer to the memory where to store the returned value of the
683/// command, i.e. the result of ClosePipe (p-close stream, the status of its child).
684/// If ret is nullptr, the returned value is not stored anywhere.
685/// @param redirectStderr if true, stderr will be redirected to stdout
686/// @return the stdout of the command as TString (from the p-opened FILE stream)
687
689{
690 TString out;
692 if (redirectStderr)
693 scommand += " 2>&1";
694 FILE *pipe = OpenPipe(scommand.Data(), "r");
695 if (!pipe) {
696 SysError("GetFromPipe", "cannot run command \"%s\"", scommand.Data());
697 return out;
698 }
699
701 while (line.Gets(pipe)) {
702 if (out != "")
703 out += "\n";
704 out += line;
705 }
706
708 if (r) {
709 Error("GetFromPipe", "command \"%s\" returned %d", scommand.Data(), r);
710 }
711 if (ret) {
712 *ret = r;
713 }
714 return out;
715}
716
717////////////////////////////////////////////////////////////////////////////////
718/// Get process id.
719
721{
722 AbstractMethod("GetPid");
723 return -1;
724}
725
726////////////////////////////////////////////////////////////////////////////////
727/// Exit the application.
728
730{
731 AbstractMethod("Exit");
732 throw; // unreachable
733}
734
735////////////////////////////////////////////////////////////////////////////////
736/// Abort the application.
737
739{
740 AbstractMethod("Abort");
741 throw; // unreachable
742}
743
744////////////////////////////////////////////////////////////////////////////////
745/// Print a stack trace.
746
748{
749 AbstractMethod("StackTrace");
750}
751
752
753//---- Directories -------------------------------------------------------------
754
755////////////////////////////////////////////////////////////////////////////////
756/// Create helper TSystem to handle file and directory operations that
757/// might be special for remote file access.
758
759TSystem *TSystem::FindHelper(const char *path, void *dirptr)
760{
761 TSystem *helper = nullptr;
762 {
764
765 if (!fHelpers) {
768 }
769
770 if (path) {
771 if (!GetDirPtr()) {
772 TUrl url(path, kTRUE);
773 if (!strcmp(url.GetProtocol(), "file"))
774 return nullptr;
775 }
776 }
777
778 // look for existing helpers
779 TIter next(fHelpers);
780 while ((helper = (TSystem*) next()))
781 if (helper->ConsistentWith(path, dirptr))
782 return helper;
783
784 if (!path)
785 return nullptr;
786 }
787
788 // create new helper
789 TRegexp re("^root.*:"); // also roots, rootk, etc
790 TString pname = path;
792 if (pname.BeginsWith("xroot:") || pname.Index(re) != kNPOS) {
793 // (x)rootd daemon ...
794 if ((h = gROOT->GetPluginManager()->FindHandler("TSystem", path))) {
795 if (h->LoadPlugin() == -1)
796 return nullptr;
797 helper = (TSystem*) h->ExecPlugin(2, path, kFALSE);
798 }
799 } else if ((h = gROOT->GetPluginManager()->FindHandler("TSystem", path))) {
800 if (h->LoadPlugin() == -1)
801 return nullptr;
802 helper = (TSystem*) h->ExecPlugin(0);
803 }
804
805 if (helper) {
808 }
809
810 return helper;
811}
812
813////////////////////////////////////////////////////////////////////////////////
814/// Check consistency of this helper with the one required
815/// by 'path' or 'dirptr'
816
817Bool_t TSystem::ConsistentWith(const char *path, void *dirptr)
818{
820 if (path) {
821 if (!GetDirPtr()) {
822 TUrl url(path, kTRUE);
823 if (!strncmp(url.GetProtocol(), GetName(), strlen(GetName())))
825 }
826 }
827
829 if (GetDirPtr() && GetDirPtr() == dirptr)
830 checkdir = kTRUE;
831
832 return (checkproto || checkdir);
833}
834
835////////////////////////////////////////////////////////////////////////////////
836/// Make a directory. Returns 0 in case of success and
837/// -1 if the directory could not be created (either already exists or
838/// illegal path name).
839
840int TSystem::MakeDirectory(const char *)
841{
842 AbstractMethod("MakeDirectory");
843 return 0;
844}
845
846////////////////////////////////////////////////////////////////////////////////
847/// Open a directory. Returns 0 if directory does not exist.
848/// \note Remember to call `TSystem::FreeDirectory(returned_pointer)` later, to prevent a memory leak
849
850void *TSystem::OpenDirectory(const char *)
851{
852 AbstractMethod("OpenDirectory");
853 return nullptr;
854}
855
856////////////////////////////////////////////////////////////////////////////////
857/// Free a directory.
858
860{
861 AbstractMethod("FreeDirectory");
862}
863
864////////////////////////////////////////////////////////////////////////////////
865/// Get a directory entry. Returns 0 if no more entries.
866
867const char *TSystem::GetDirEntry(void *)
868{
869 AbstractMethod("GetDirEntry");
870 return nullptr;
871}
872
873////////////////////////////////////////////////////////////////////////////////
874/// Change directory.
875
877{
878 AbstractMethod("ChangeDirectory");
879 return kFALSE;
880}
881
882////////////////////////////////////////////////////////////////////////////////
883/// Return working directory.
884
886{
887 return nullptr;
888}
889
890//////////////////////////////////////////////////////////////////////////////
891/// Return working directory.
892
894{
895 return std::string();
896}
897
898////////////////////////////////////////////////////////////////////////////////
899/// Return the user's home directory.
900
901const char *TSystem::HomeDirectory(const char *)
902{
903 return nullptr;
904}
905
906//////////////////////////////////////////////////////////////////////////////
907/// Return the user's home directory.
908
909std::string TSystem::GetHomeDirectory(const char *) const
910{
911 return std::string();
912}
913
914////////////////////////////////////////////////////////////////////////////////
915/// Make a file system directory. Returns 0 in case of success and
916/// -1 if the directory could not be created (either already exists or
917/// illegal path name).
918/// If 'recursive' is true, makes parent directories as needed.
919
921{
922 if (recursive) {
923 TString safeName = name; // local copy in case 'name' is output from
924 // TSystem::DirName as it uses static buffers
926 if (dirname.IsNull()) {
927 // well we should not have to make the root of the file system!
928 // (and this avoid infinite recursions!)
929 return -1;
930 }
931 if (AccessPathName(dirname.Data(), kFileExists)) {
932 int res = mkdir(dirname.Data(), kTRUE);
933 if (res) return res;
934 }
935 if (!AccessPathName(safeName.Data(), kFileExists)) {
936 return -1;
937 }
938 }
939
940 return MakeDirectory(name);
941}
942
943//---- Paths & Files -----------------------------------------------------------
944
945////////////////////////////////////////////////////////////////////////////////
946/// Base name of a file name. Base name of /user/root is root.
947
948const char *TSystem::BaseName(const char *name)
949{
950 if (name) {
951 if (name[0] == '/' && name[1] == '\0')
952 return name;
953 char *cp;
954 if ((cp = (char *)strrchr(name, '/')))
955 return ++cp;
956 return name;
957 }
958 Error("BaseName", "name = 0");
959 return nullptr;
960}
961
962////////////////////////////////////////////////////////////////////////////////
963/// Return true if dir is an absolute pathname.
964
966{
967 if (dir)
968 return dir[0] == '/';
969 return kFALSE;
970}
971
972////////////////////////////////////////////////////////////////////////////////
973/// Return true if 'name' is a file that can be found in the ROOT include
974/// path or the current directory.
975/// If 'name' contains any ACLiC style information (e.g. trailing +[+][g|O]),
976/// it will be striped off 'name'.
977/// If fullpath is != 0, the full path to the file is returned in *fullpath,
978/// which must be deleted by the caller.
979
981{
982 if (!name || !name[0]) return kFALSE;
983
985 TString arguments;
986 TString io;
988
990
991 TString incPath = gSystem->GetIncludePath(); // of the form -Idir1 -Idir2 -Idir3
992 incPath.Append(":").Prepend(" ");
993 incPath.ReplaceAll(" -I",":"); // of form :dir1 :dir2:dir3
994 while ( incPath.Index(" :") != -1 ) {
995 incPath.ReplaceAll(" :",":");
996 }
997 // Remove double quotes around path expressions.
998 incPath.ReplaceAll("\":", ":");
999 incPath.ReplaceAll(":\"", ":");
1000
1001 incPath.Prepend(fileLocation+":.:");
1002
1003 char *actual = Which(incPath,realname);
1004
1005 if (!actual) {
1006 return kFALSE;
1007 } else {
1008 if (fullpath)
1009 *fullpath = actual;
1010 else
1011 delete [] actual;
1012 return kTRUE;
1013 }
1014}
1015
1016////////////////////////////////////////////////////////////////////////////////
1017/// Return the directory name in pathname. DirName of /user/root is /user.
1018/// In case no dirname is specified "." is returned.
1019
1020const char *TSystem::DirName(const char *pathname)
1021{
1022 auto res = GetDirName(pathname);
1023 if (res.IsNull() || (res == "."))
1024 return ".";
1025
1027
1028 TTHREAD_TLS(Ssiz_t) len = 0;
1029 TTHREAD_TLS(char*) buf = nullptr;
1030 if (res.Length() >= len) {
1031 if (buf) delete [] buf;
1032 len = res.Length() + 50;
1033 buf = new char [len];
1034 }
1035 if (buf)
1036 strncpy(buf, res.Data(), len);
1037 return buf;
1038}
1039
1040////////////////////////////////////////////////////////////////////////////////
1041/// Return the directory name in pathname.
1042/// DirName of /user/root is /user.
1043/// DirName of /user/root/ is also /user.
1044/// In case no dirname is specified "." is returned.
1045
1047{
1048 if (!pathname || !strchr(pathname, '/'))
1049 return ".";
1050
1051 auto pathlen = strlen(pathname);
1052
1053 const char *r = pathname + pathlen - 1;
1054 // First skip the trailing '/'
1055 while ((r > pathname) && (*r == '/'))
1056 --r;
1057 // Then find the next non slash
1058 while ((r > pathname) && (*r != '/'))
1059 --r;
1060
1061 // Then skip duplicate slashes
1062 // Note the 'r>buf' is a strict comparison to allows '/topdir' to return '/'
1063 while ((r > pathname) && (*r == '/'))
1064 --r;
1065 // If all was cut away, we encountered a rel. path like 'subdir/'
1066 // and ended up at '.'.
1067 if ((r == pathname) && (*r != '/'))
1068 return ".";
1069
1070 return TString(pathname, r + 1 - pathname);
1071}
1072
1073////////////////////////////////////////////////////////////////////////////////
1074/// Convert from a local pathname to a Unix pathname. E.g. from `\user\root` to
1075/// `/user/root`.
1076
1077const char *TSystem::UnixPathName(const char *name)
1078{
1079 return name;
1080}
1081
1082////////////////////////////////////////////////////////////////////////////////
1083/// Concatenate a directory and a file name. User must delete returned string.
1084/// \deprecated Consider replacing with TSystem::PrependPathName
1085
1086char *TSystem::ConcatFileName(const char *dir, const char *name)
1087{
1090 return StrDup(nameString.Data());
1091}
1092
1093////////////////////////////////////////////////////////////////////////////////
1094/// Concatenate a directory and a file name.
1095
1096const char *TSystem::PrependPathName(const char *, TString&)
1097{
1098 AbstractMethod("PrependPathName");
1099 return nullptr;
1100}
1101
1102
1103//---- Paths & Files -----------------------------------------------------------
1104
1105////////////////////////////////////////////////////////////////////////////////
1106/// Expand a pathname getting rid of special shell characters like ~.$, etc.
1107/// For Unix/Win32 compatibility use $(XXX) instead of $XXX when using
1108/// environment variables in a pathname. If compatibility is not an issue
1109/// you can use on Unix directly $XXX. This is a protected function called
1110/// from the OS specific system classes, like TUnixSystem and TWinNTSystem.
1111/// Returns the expanded filename or 0 in case of error.
1112
1113const char *TSystem::ExpandFileName(const char *fname)
1114{
1115 const int kBufSize = kMAXPATHLEN;
1117
1119 if (res)
1120 return nullptr;
1121 else
1122 return xname;
1123}
1124
1125//////////////////////////////////////////////////////////////////////////////
1126/// Expand a pathname getting rid of special shell characters like ~.$, etc.
1127/// This function is analogous to ExpandFileName(const char *), except that
1128/// it receives a TString reference of the pathname to be expanded.
1129/// Returns kTRUE in case of error and kFALSE otherwise.
1130
1132{
1133 const int kBufSize = kMAXPATHLEN;
1134 char xname[kBufSize];
1135
1136 Bool_t res = ExpandFileName(fname.Data(), xname, kBufSize);
1137 if (!res)
1138 fname = xname;
1139
1140 return res;
1141}
1142
1143////////////////////////////////////////////////////////////////////////////
1144/// Private method for pathname expansion.
1145/// Returns kTRUE in case of error and kFALSE otherwise.
1146
1147Bool_t TSystem::ExpandFileName(const char *fname, char *xname, const int kBufSize)
1148{
1149 int n, ier, iter, lx, ncopy;
1150 char *inp, *out, *x, *t, *buff;
1151 const char *b, *c, *e;
1152 const char *p;
1153 buff = new char[kBufSize * 4];
1154
1155 iter = 0; xname[0] = 0; inp = buff + kBufSize; out = inp + kBufSize;
1156 inp[-1] = ' '; inp[0] = 0; out[-1] = ' ';
1157 c = fname + strspn(fname, " \t\f\r");
1158 //VP if (isalnum(c[0])) { strcpy(inp, WorkingDirectory()); strcat(inp, "/"); } // add $cwd
1159
1160 strlcat(inp, c, kBufSize);
1161
1162again:
1163 iter++; c = inp; ier = 0;
1164 x = out; x[0] = 0;
1165
1166 p = nullptr; e = nullptr;
1167 if (c[0] == '~' && c[1] == '/') { // ~/ case
1168 std::string hd = GetHomeDirectory();
1169 p = hd.c_str();
1170 e = c + 1;
1171 if (p) { // we have smth to copy
1172 strlcpy(x, p, kBufSize);
1173 x += strlen(p);
1174 c = e;
1175 } else {
1176 ++ier;
1177 ++c;
1178 }
1179 } else if (c[0] == '~' && c[1] != '/') { // ~user case
1180 n = strcspn(c+1, "/ ");
1181 assert((n+1) < kBufSize && "This should have been prevented by the truncation 'strlcat(inp, c, kBufSize)'");
1182 // There is no overlap here as the buffer is segment in 4 strings of at most kBufSize
1183 (void)strlcpy(buff, c+1, n+1); // strlcpy copy 'size-1' characters.
1184 std::string hd = GetHomeDirectory(buff);
1185 e = c+1+n;
1186 if (!hd.empty()) { // we have smth to copy
1187 p = hd.c_str();
1188 strlcpy(x, p, kBufSize);
1189 x += strlen(p);
1190 c = e;
1191 } else {
1192 x++[0] = c[0];
1193 //++ier;
1194 ++c;
1195 }
1196 }
1197
1198 for ( ; c[0]; c++) {
1199
1200 p = nullptr; e = nullptr;
1201
1202 if (c[0] == '.' && c[1] == '/' && c[-1] == ' ') { // $cwd
1203 std::string wd = GetWorkingDirectory();
1204 strlcpy(buff, wd.c_str(), kBufSize);
1205 p = buff;
1206 e = c + 1;
1207 }
1208 if (p) { // we have smth to copy */
1209 strlcpy(x, p, kBufSize); x += strlen(p); c = e-1; continue;
1210 }
1211
1212 if (c[0] != '$') { // not $, simple copy
1213 x++[0] = c[0];
1214 } else { // we have a $
1215 b = c+1;
1216 if (c[1] == '(') b++;
1217 if (c[1] == '{') b++;
1218 if (b[0] == '$')
1219 e = b+1;
1220 else
1221 for (e = b; isalnum(e[0]) || e[0] == '_'; e++) ;
1222 buff[0] = 0; strncat(buff, b, e-b);
1223 p = Getenv(buff);
1224 if (!p) { // too bad, try UPPER case
1225 for (t = buff; (t[0] = toupper(t[0])); t++) ;
1226 p = Getenv(buff);
1227 }
1228 if (!p) { // too bad, try Lower case
1229 for (t = buff; (t[0] = tolower(t[0])); t++) ;
1230 p = Getenv(buff);
1231 }
1232 if (!p && !strcmp(buff, "cwd")) { // it is $cwd
1233 std::string wd = GetWorkingDirectory();
1234 strlcpy(buff, wd.c_str(), kBufSize);
1235 p = buff;
1236 }
1237 if (!p && !strcmp(buff, "$")) { // it is $$ (replace by GetPid())
1238 snprintf(buff,kBufSize*4, "%d", GetPid());
1239 p = buff;
1240 }
1241 if (!p) { // too bad, nothing can help
1242#ifdef WIN32
1243 // if we're on windows, we can have \\SomeMachine\C$ - don't
1244 // complain about that, if '$' is followed by nothing or a
1245 // path delimiter.
1246 if (c[1] && c[1]!='\\' && c[1]!=';' && c[1]!='/')
1247 ier++;
1248#else
1249 ier++;
1250#endif
1251 x++[0] = c[0];
1252 } else { // It is OK, copy result
1253 int lp = strlen(p);
1254 if (lp >= kBufSize) {
1255 // make sure lx will be >= kBufSize (see below)
1256 strlcpy(x, p, kBufSize);
1257 x += kBufSize;
1258 break;
1259 }
1260 strcpy(x,p);
1261 x += lp;
1262 c = (b==c+1) ? e-1 : e;
1263 }
1264 }
1265 }
1266
1267 x[0] = 0; lx = x - out;
1268 if (ier && iter < 3) { strlcpy(inp, out, kBufSize); goto again; }
1269 ncopy = (lx >= kBufSize) ? kBufSize-1 : lx;
1270 xname[0] = 0; strncat(xname, out, ncopy);
1271
1272 delete[] buff;
1273
1274 if (ier || ncopy != lx) {
1275 ::Error("TSystem::ExpandFileName", "input: %s, output: %s", fname, xname);
1276 return kTRUE;
1277 }
1278
1279 return kFALSE;
1280}
1281
1282
1283////////////////////////////////////////////////////////////////////////////////
1284/// Expand a pathname getting rid of special shell characters like ~.$, etc.
1285/// For Unix/Win32 compatibility use $(XXX) instead of $XXX when using
1286/// environment variables in a pathname. If compatibility is not an issue
1287/// you can use on Unix directly $XXX.
1288
1293
1294////////////////////////////////////////////////////////////////////////////////
1295/// Expand a pathname getting rid of special shell characters like ~.$, etc.
1296/// For Unix/Win32 compatibility use $(XXX) instead of $XXX when using
1297/// environment variables in a pathname. If compatibility is not an issue
1298/// you can use on Unix directly $XXX. The user must delete returned string.
1299
1300char *TSystem::ExpandPathName(const char *)
1301{
1302 return nullptr;
1303}
1304
1305////////////////////////////////////////////////////////////////////////////////
1306/// Returns FALSE if one can access a file using the specified access mode.
1307/// The file name must not contain any special shell characters line ~ or $,
1308/// in those cases first call ExpandPathName().
1309/// Attention, bizarre convention of return value!!
1310
1312{
1313 return kFALSE;
1314}
1315
1316////////////////////////////////////////////////////////////////////////////////
1317/// Returns TRUE if the url in 'path' points to the local file system.
1318/// This is used to avoid going through the NIC card for local operations.
1319
1321{
1323
1324 TUrl url(path);
1325 if (strlen(url.GetHost()) > 0) {
1326 // Check locality
1327 localPath = kFALSE;
1328 TInetAddress a(gSystem->GetHostByName(url.GetHost()));
1330 if (!strcmp(a.GetHostName(), b.GetHostName()) ||
1331 !strcmp(a.GetHostAddress(), b.GetHostAddress())) {
1332 // Host OK
1333 localPath = kTRUE;
1334 // Check the user if specified
1335 if (strlen(url.GetUser()) > 0) {
1337 if (u) {
1338 if (strcmp(u->fUser, url.GetUser()))
1339 // Requested a different user
1340 localPath = kFALSE;
1341 delete u;
1342 }
1343 }
1344 }
1345 }
1346 // Done
1347 return localPath;
1348}
1349
1350////////////////////////////////////////////////////////////////////////////////
1351/// Copy a file. If overwrite is true and file already exists the
1352/// file will be overwritten. Returns 0 when successful, -1 in case
1353/// of file open failure, -2 in case the file already exists and overwrite
1354/// was false and -3 in case of error during copy.
1355
1356int TSystem::CopyFile(const char *, const char *, Bool_t)
1357{
1358 AbstractMethod("CopyFile");
1359 return -1;
1360}
1361
1362////////////////////////////////////////////////////////////////////////////////
1363/// Rename a file.
1364
1365int TSystem::Rename(const char *, const char *)
1366{
1367 AbstractMethod("Rename");
1368 return -1;
1369}
1370
1371////////////////////////////////////////////////////////////////////////////////
1372/// Create a link from file1 to file2.
1373
1374int TSystem::Link(const char *, const char *)
1375{
1376 AbstractMethod("Link");
1377 return -1;
1378}
1379
1380////////////////////////////////////////////////////////////////////////////////
1381/// Create a symbolic link from file1 to file2.
1382
1383int TSystem::Symlink(const char *, const char *)
1384{
1385 AbstractMethod("Symlink");
1386 return -1;
1387}
1388
1389////////////////////////////////////////////////////////////////////////////////
1390/// Unlink, i.e. remove, a file.
1391///
1392/// If the file is currently open by the current or another process, the behavior of this function is
1393/// implementation-defined (in particular, POSIX systems unlink the file name, while Windows does not allow the
1394/// file to be deleted and the operation is a no-op).
1395
1396int TSystem::Unlink(const char *)
1397{
1398 AbstractMethod("Unlink");
1399 return -1;
1400}
1401
1402////////////////////////////////////////////////////////////////////////////////
1403/// Get info about a file: id, size, flags, modification time.
1404/// - Id is (statbuf.st_dev << 24) + statbuf.st_ino
1405/// - Size is the file size
1406/// - Flags is file type: 0 is regular file, bit 0 set executable,
1407/// bit 1 set directory, bit 2 set special file
1408/// (socket, fifo, pipe, etc.)
1409/// Modtime is modification time.
1410/// The function returns 0 in case of success and 1 if the file could
1411/// not be stat'ed.
1412
1413int TSystem::GetPathInfo(const char *path, Long_t *id, Long_t *size,
1414 Long_t *flags, Long_t *modtime)
1415{
1417
1418 int res = GetPathInfo(path, id, &lsize, flags, modtime);
1419
1420 if (res == 0 && size) {
1421 if (sizeof(Long_t) == 4 && lsize > kMaxInt) {
1422 Error("GetPathInfo", "file %s > 2 GB, use GetPathInfo() with Long64_t size", path);
1423 *size = kMaxInt;
1424 } else {
1425 *size = (Long_t)lsize;
1426 }
1427 }
1428
1429 return res;
1430}
1431
1432////////////////////////////////////////////////////////////////////////////////
1433/// Get info about a file: id, size, flags, modification time.
1434/// - Id is (statbuf.st_dev << 24) + statbuf.st_ino
1435/// - Size is the file size
1436/// - Flags is file type: 0 is regular file, bit 0 set executable,
1437/// bit 1 set directory, bit 2 set special file
1438/// (socket, fifo, pipe, etc.)
1439/// Modtime is modification time.
1440/// The function returns 0 in case of success and 1 if the file could
1441/// not be stat'ed.
1442
1443int TSystem::GetPathInfo(const char *path, Long_t *id, Long64_t *size,
1444 Long_t *flags, Long_t *modtime)
1445{
1446 FileStat_t buf;
1447
1448 int res = GetPathInfo(path, buf);
1449
1450 if (res == 0) {
1451 if (id)
1452 *id = (buf.fDev << 24) + buf.fIno;
1453 if (size)
1454 *size = buf.fSize;
1455 if (modtime)
1456 *modtime = buf.fMtime;
1457 if (flags) {
1458 *flags = 0;
1459 if (buf.fMode & (kS_IXUSR|kS_IXGRP|kS_IXOTH))
1460 *flags |= 1;
1461 if (R_ISDIR(buf.fMode))
1462 *flags |= 2;
1463 if (!R_ISREG(buf.fMode) && !R_ISDIR(buf.fMode))
1464 *flags |= 4;
1465 }
1466 }
1467
1468 return res;
1469}
1470
1471////////////////////////////////////////////////////////////////////////////////
1472/// Get info about a file. Info is returned in the form of a FileStat_t
1473/// structure (see TSystem.h).
1474/// The function returns 0 in case of success and 1 if the file could
1475/// not be stat'ed.
1476
1478{
1479 AbstractMethod("GetPathInfo(const char *, FileStat_t&)");
1480 return 1;
1481}
1482
1483////////////////////////////////////////////////////////////////////////////////
1484/// Get info about a file system: fs type, block size, number of blocks,
1485/// number of free blocks.
1486
1487int TSystem::GetFsInfo(const char *, Long_t *, Long_t *, Long_t *, Long_t *)
1488{
1489 AbstractMethod("GetFsInfo");
1490 return 1;
1491}
1492
1493////////////////////////////////////////////////////////////////////////////////
1494/// Return a user configured or systemwide directory to create
1495/// temporary files in.
1496
1497const char *TSystem::TempDirectory() const
1498{
1499 AbstractMethod("TempDirectory");
1500 return nullptr;
1501}
1502
1503////////////////////////////////////////////////////////////////////////////////
1504/// Create a secure temporary file by appending a unique
1505/// 6 letter string to base. The file will be created in
1506/// a standard (system) directory or in the directory
1507/// provided in dir. Optionally one can provide suffix
1508/// append to the final name - like extension ".txt" or ".html".
1509/// The full filename is returned in base
1510/// and a filepointer is returned for safely writing to the file
1511/// (this avoids certain security problems). Returns 0 in case
1512/// of error.
1513
1514FILE *TSystem::TempFileName(TString &, const char *, const char *)
1515{
1516 AbstractMethod("TempFileName");
1517 return nullptr;
1518}
1519
1520////////////////////////////////////////////////////////////////////////////////
1521/// Set the file permission bits. Returns -1 in case or error, 0 otherwise.
1522
1523int TSystem::Chmod(const char *, UInt_t)
1524{
1525 AbstractMethod("Chmod");
1526 return -1;
1527}
1528
1529////////////////////////////////////////////////////////////////////////////////
1530/// Set the process file creation mode mask.
1531
1533{
1534 AbstractMethod("Umask");
1535 return -1;
1536}
1537
1538////////////////////////////////////////////////////////////////////////////////
1539/// Set the a files modification and access times. If actime = 0 it will be
1540/// set to the modtime. Returns 0 on success and -1 in case of error.
1541
1542int TSystem::Utime(const char *, Long_t, Long_t)
1543{
1544 AbstractMethod("Utime");
1545 return -1;
1546}
1547
1548////////////////////////////////////////////////////////////////////////////////
1549/// Find location of file in a search path. Return value points to TString for
1550/// compatibility with Which(const char *, const char *, EAccessMode).
1551/// Returns 0 in case file is not found.
1552
1553const char *TSystem::FindFile(const char *, TString&, EAccessMode)
1554{
1555 AbstractMethod("FindFile");
1556 return nullptr;
1557}
1558
1559////////////////////////////////////////////////////////////////////////////////
1560/// Find location of file in a search path. User must delete returned string.
1561/// Returns 0 in case file is not found.
1562
1563char *TSystem::Which(const char *search, const char *wfil, EAccessMode mode)
1564{
1567 if (wfilString.IsNull())
1568 return nullptr;
1569 return StrDup(wfilString.Data());
1570}
1571
1572//---- Users & Groups ----------------------------------------------------------
1573
1574////////////////////////////////////////////////////////////////////////////////
1575/// Returns the user's id. If user = 0, returns current user's id.
1576
1577Int_t TSystem::GetUid(const char * /*user*/)
1578{
1579 AbstractMethod("GetUid");
1580 return 0;
1581}
1582
1583////////////////////////////////////////////////////////////////////////////////
1584/// Returns the effective user id. The effective id corresponds to the
1585/// set id bit on the file being executed.
1586
1588{
1589 AbstractMethod("GetEffectiveUid");
1590 return 0;
1591}
1592
1593////////////////////////////////////////////////////////////////////////////////
1594/// Returns the group's id. If group = 0, returns current user's group.
1595
1596Int_t TSystem::GetGid(const char * /*group*/)
1597{
1598 AbstractMethod("GetGid");
1599 return 0;
1600}
1601
1602////////////////////////////////////////////////////////////////////////////////
1603/// Returns the effective group id. The effective group id corresponds
1604/// to the set id bit on the file being executed.
1605
1607{
1608 AbstractMethod("GetEffectiveGid");
1609 return 0;
1610}
1611
1612////////////////////////////////////////////////////////////////////////////////
1613/// Returns all user info in the UserGroup_t structure. The returned
1614/// structure must be deleted by the user. In case of error 0 is returned.
1615
1617{
1618 AbstractMethod("GetUserInfo");
1619 return nullptr;
1620}
1621
1622////////////////////////////////////////////////////////////////////////////////
1623/// Returns all user info in the UserGroup_t structure. If user = 0, returns
1624/// current user's id info. The returned structure must be deleted by the
1625/// user. In case of error 0 is returned.
1626
1627UserGroup_t *TSystem::GetUserInfo(const char * /*user*/)
1628{
1629 AbstractMethod("GetUserInfo");
1630 return nullptr;
1631}
1632
1633////////////////////////////////////////////////////////////////////////////////
1634/// Returns all group info in the UserGroup_t structure. The only active
1635/// fields in the UserGroup_t structure for this call are:
1636/// - fGid and fGroup
1637/// The returned structure must be deleted by the user. In case of
1638/// error 0 is returned.
1639
1641{
1642 AbstractMethod("GetGroupInfo");
1643 return nullptr;
1644}
1645
1646////////////////////////////////////////////////////////////////////////////////
1647/// Returns all group info in the UserGroup_t structure. The only active
1648/// fields in the UserGroup_t structure for this call are:
1649/// - fGid and fGroup
1650/// If group = 0, returns current user's group. The returned structure
1651/// must be deleted by the user. In case of error 0 is returned.
1652
1653UserGroup_t *TSystem::GetGroupInfo(const char * /*group*/)
1654{
1655 AbstractMethod("GetGroupInfo");
1656 return nullptr;
1657}
1658
1659//---- environment manipulation ------------------------------------------------
1660
1661////////////////////////////////////////////////////////////////////////////////
1662/// Set environment variable.
1663
1664void TSystem::Setenv(const char *, const char *)
1665{
1666 AbstractMethod("Setenv");
1667}
1668
1669////////////////////////////////////////////////////////////////////////////////
1670/// Unset environment variable.
1671
1672void TSystem::Unsetenv(const char *name)
1673{
1674 Setenv(name, "");
1675}
1676
1677////////////////////////////////////////////////////////////////////////////////
1678/// Get environment variable.
1679
1680const char *TSystem::Getenv(const char *)
1681{
1682 AbstractMethod("Getenv");
1683 return nullptr;
1684}
1685
1686//---- System Logging ----------------------------------------------------------
1687
1688////////////////////////////////////////////////////////////////////////////////
1689/// Open connection to system log daemon. For the use of the options and
1690/// facility see the Unix openlog man page.
1691
1693{
1694 AbstractMethod("Openlog");
1695}
1696
1697////////////////////////////////////////////////////////////////////////////////
1698/// Send mess to syslog daemon. Level is the logging level and mess the
1699/// message that will be written on the log.
1700
1701void TSystem::Syslog(ELogLevel, const char *)
1702{
1703 AbstractMethod("Syslog");
1704}
1705
1706////////////////////////////////////////////////////////////////////////////////
1707/// Close connection to system log daemon.
1708
1710{
1711 AbstractMethod("Closelog");
1712}
1713
1714//---- Standard output redirection ---------------------------------------------
1715
1716////////////////////////////////////////////////////////////////////////////////
1717/// Redirect standard output (stdout, stderr) to the specified file.
1718/// If the file argument is 0 the output is set again to stderr, stdout.
1719/// The second argument specifies whether the output should be added to the
1720/// file ("a", default) or the file be truncated before ("w").
1721/// The implementations of this function save internally the current state into
1722/// a static structure.
1723///
1724/// The call can be made reentrant by specifying the opaque structure pointed
1725/// by 'h', which is filled with the relevant information. The handle 'h'
1726/// obtained on the first call must then be used in any subsequent call,
1727/// included ShowOutput, to display the redirected output.
1728/// Returns 0 on success, -1 in case of error.
1729
1730Int_t TSystem::RedirectOutput(const char *, const char *, RedirectHandle_t *)
1731{
1732 AbstractMethod("RedirectOutput");
1733 return -1;
1734}
1735
1736////////////////////////////////////////////////////////////////////////////////
1737/// Display the content associated with the redirection described by the
1738/// opaque handle 'h'.
1739
1741{
1742 // Check input ...
1743 if (!h) {
1744 Error("ShowOutput", "handle not specified");
1745 return;
1746 }
1747
1748 // ... and file access
1749 if (gSystem->AccessPathName(h->fFile, kReadPermission)) {
1750 Error("ShowOutput", "file '%s' cannot be read", h->fFile.Data());
1751 return;
1752 }
1753
1754 // Open the file
1755 FILE *f = nullptr;
1756 if (!(f = fopen(h->fFile.Data(), "r"))) {
1757 Error("ShowOutput", "file '%s' cannot be open", h->fFile.Data());
1758 return;
1759 }
1760
1761 // Determine the number of bytes to be read from the file.
1762 off_t ltot = lseek(fileno(f), (off_t) 0, SEEK_END);
1763 Int_t begin = (h->fReadOffSet > 0 && h->fReadOffSet < ltot) ? h->fReadOffSet : 0;
1764 lseek(fileno(f), (off_t) begin, SEEK_SET);
1765 Int_t left = ltot - begin;
1766
1767 // Now readout from file
1768 const Int_t kMAXBUF = 16384;
1769 char buf[kMAXBUF];
1770 Int_t wanted = (left > kMAXBUF-1) ? kMAXBUF-1 : left;
1771 Int_t len;
1772 do {
1773 while ((len = read(fileno(f), buf, wanted)) < 0 &&
1776
1777 if (len < 0) {
1778 SysError("ShowOutput", "error reading log file");
1779 break;
1780 }
1781
1782 // Null-terminate
1783 buf[len] = 0;
1784 fprintf(stderr,"%s", buf);
1785
1786 // Update counters
1787 left -= len;
1788 wanted = (left > kMAXBUF) ? kMAXBUF : left;
1789
1790 } while (len > 0 && left > 0);
1791
1792 // Do not display twice the same thing
1793 h->fReadOffSet = ltot;
1794 fclose(f);
1795}
1796
1797//---- Dynamic Loading ---------------------------------------------------------
1798
1799////////////////////////////////////////////////////////////////////////////////
1800/// Add a new directory to the dynamic path.
1801
1802void TSystem::AddDynamicPath(const char *)
1803{
1804 AbstractMethod("AddDynamicPath");
1805}
1806
1807////////////////////////////////////////////////////////////////////////////////
1808/// Return the dynamic path (used to find shared libraries).
1809
1811{
1812 AbstractMethod("GetDynamicPath");
1813 return nullptr;
1814}
1815
1816////////////////////////////////////////////////////////////////////////////////
1817/// Set the dynamic path to a new value.
1818/// If the value of 'path' is zero, the dynamic path is reset to its
1819/// default value.
1820
1821void TSystem::SetDynamicPath(const char *)
1822{
1823 AbstractMethod("SetDynamicPath");
1824}
1825
1826
1827////////////////////////////////////////////////////////////////////////////////
1828/// Figure out if left and right points to the same
1829/// object in the file system.
1830
1831static bool R__MatchFilename(const char *left, const char *right)
1832{
1833 if (left == right) return kTRUE;
1834
1835 if (left==nullptr || right==nullptr) return kFALSE;
1836
1837 if ( (strcmp(right,left)==0) ) {
1838 return kTRUE;
1839 }
1840
1841#ifdef G__WIN32
1842
1843 char leftname[_MAX_PATH];
1844 char rightname[_MAX_PATH];
1845 _fullpath( leftname, left, _MAX_PATH );
1846 _fullpath( rightname, right, _MAX_PATH );
1847 return ((stricmp(leftname, rightname)==0));
1848#else
1849 struct stat rightBuf;
1850 struct stat leftBuf;
1851 return ( ( 0 == stat( left, & leftBuf ) )
1852 && ( 0 == stat( right, & rightBuf ) )
1853 && ( leftBuf.st_dev == rightBuf.st_dev ) // Files on same device
1854 && ( leftBuf.st_ino == rightBuf.st_ino ) // Files on same inode (but this is not unique on AFS so we need the next 2 test
1855 && ( leftBuf.st_size == rightBuf.st_size ) // Files of same size
1856 && ( leftBuf.st_mtime == rightBuf.st_mtime ) // Files modified at the same time
1857 );
1858#endif
1859}
1860
1861
1862////////////////////////////////////////////////////////////////////////////////
1863/// Load a shared library. Returns 0 on successful loading, 1 in
1864/// case lib was already loaded, -1 in case lib does not exist
1865/// or in case of error and -2 in case of version mismatch.
1866/// When entry is specified the loaded lib is
1867/// searched for this entry point (return -1 when entry does not exist,
1868/// 0 otherwise). When the system flag is kTRUE, the library is considered
1869/// a permanent system library that should not be unloaded during the
1870/// course of the session.
1871
1872int TSystem::Load(const char *module, const char *entry, Bool_t system)
1873{
1874 // don't load libraries that have already been loaded
1877
1878 Ssiz_t idx = l.Last('.');
1879 if (idx != kNPOS) {
1880 l.Remove(idx+1);
1881 }
1882 for (idx = libs.Index(l); idx != kNPOS; idx = libs.Index(l,idx+1)) {
1883 // The libs contains the sub-string 'l', let's make sure it is
1884 // not just part of a larger name.
1885 if (idx == 0 || libs[idx-1] == '/' || libs[idx-1] == '\\') {
1886 Ssiz_t len = libs.Length();
1887 idx += l.Length();
1888 if (!l.EndsWith(".") && libs[idx]=='.')
1889 idx++;
1890 // Skip the soversion.
1891 while (idx < len && isdigit(libs[idx])) {
1892 ++idx;
1893 // No need to test for len here, at worse idx==len and lib[idx]=='\0'
1894 if (libs[idx] == '.') {
1895 ++idx;
1896 }
1897 }
1898 while (idx < len && libs[idx] != '.') {
1899 if (libs[idx] == ' ' || idx+1 == len) {
1900 return 1;
1901 }
1902 ++idx;
1903 }
1904 }
1905 }
1906 if (l[l.Length()-1] == '.') {
1907 l.Remove(l.Length()-1);
1908 }
1909 if (l.BeginsWith("lib")) {
1910 l.Replace(0, 3, "-l");
1911 for(idx = libs.Index(l); idx != kNPOS; idx = libs.Index(l,idx+1)) {
1912 if ((idx == 0 || libs[idx-1] == ' ') &&
1913 (libs[idx+l.Length()] == ' ' || libs[idx+l.Length()] == 0)) {
1914 return 1;
1915 }
1916 }
1917 }
1918
1919 char *path = DynamicPathName(module);
1920
1921 int ret = -1;
1922 if (path) {
1923 // load any dependent libraries
1924 TString deplibs = gInterpreter->GetSharedLibDeps(path);
1925 if (!deplibs.IsNull()) {
1926 TString delim(" ");
1927 TObjArray *tokens = deplibs.Tokenize(delim);
1928 for (Int_t i = tokens->GetEntriesFast()-1; i > 0; i--) {
1929 const char *deplib = ((TObjString*)tokens->At(i))->GetName();
1930 if (strcmp(module,deplib)==0) {
1931 continue;
1932 }
1933 if (gDebug > 0)
1934 Info("Load", "loading dependent library %s for library %s",
1935 deplib, ((TObjString*)tokens->At(0))->GetName());
1936 if ((ret = Load(deplib, "", system)) < 0) {
1937 delete tokens;
1938 delete [] path;
1939 return ret;
1940 }
1941 }
1942 delete tokens;
1943 }
1944 if (!system) {
1945 // Mark the library in $ROOTSYS/lib as system.
1946 TString dirname = GetDirName(path);
1948
1949 if (!system) {
1951 }
1952 }
1953
1956 gLibraryVersionMax *= 2;
1958 }
1959 ret = gInterpreter->Load(path, system);
1960 if (ret < 0) ret = -1;
1961 if (gDebug > 0)
1962 Info("Load", "loaded library %s, status %d", path, ret);
1963 if (ret == 0 && gLibraryVersion[gLibraryVersionIdx]) {
1965 Error("Load", "version mismatch, %s = %d, ROOT = %d",
1966 path, v, gROOT->GetVersionInt());
1967 ret = -2;
1969 }
1971 delete [] path;
1972 }
1973
1974 if (!entry || !entry[0] || ret < 0) return ret;
1975
1977 if (f) return 0;
1978 return -1;
1979}
1980
1981///////////////////////////////////////////////////////////////////////////////
1982/// Load all libraries known to ROOT via the rootmap system.
1983/// Returns the number of top level libraries successfully loaded.
1984
1986{
1987 UInt_t nlibs = 0;
1988
1989 TEnv* mapfile = gInterpreter->GetMapfile();
1990 if (!mapfile || !mapfile->GetTable()) return 0;
1991
1992 std::set<std::string> loadedlibs;
1993 std::set<std::string> failedlibs;
1994
1995 TEnvRec* rec = nullptr;
1996 TIter iEnvRec(mapfile->GetTable());
1997 while ((rec = (TEnvRec*) iEnvRec())) {
1998 TString libs = rec->GetValue();
1999 TString lib;
2000 Ssiz_t pos = 0;
2001 while (libs.Tokenize(lib, pos)) {
2002 // check that none of the libs failed to load
2003 if (failedlibs.find(lib.Data()) != failedlibs.end()) {
2004 // don't load it or any of its dependencies
2005 libs = "";
2006 break;
2007 }
2008 }
2009 pos = 0;
2010 while (libs.Tokenize(lib, pos)) {
2011 // ignore libCore - it's already loaded
2012 if (lib.BeginsWith("libCore"))
2013 continue;
2014
2015 if (loadedlibs.find(lib.Data()) == loadedlibs.end()) {
2016 // just load the first library - TSystem will do the rest.
2017 auto res = gSystem->Load(lib);
2018 if (res >=0) {
2019 if (res == 0) ++nlibs;
2020 loadedlibs.insert(lib.Data());
2021 } else {
2022 failedlibs.insert(lib.Data());
2023 }
2024 }
2025 }
2026 }
2027 return nlibs;
2028}
2029
2030////////////////////////////////////////////////////////////////////////////////
2031/// Find a dynamic library called lib using the system search paths.
2032/// Appends known extensions if needed. Returned string must be deleted
2033/// by the user!
2034
2035char *TSystem::DynamicPathName(const char *lib, Bool_t quiet /*=kFALSE*/)
2036{
2037 TString sLib(lib);
2039 return StrDup(sLib);
2040 return nullptr;
2041}
2042
2043////////////////////////////////////////////////////////////////////////////////
2044/// Find a dynamic library using the system search paths. lib will be updated
2045/// to contain the absolute filename if found. Returns lib if found, or NULL
2046/// if a library called lib was not found.
2047/// This function does not open the library.
2048
2050{
2051 AbstractMethod("FindDynamicLibrary");
2052 return nullptr;
2053}
2054
2055////////////////////////////////////////////////////////////////////////////////
2056/// Find specific entry point in specified library. Specify "*" for lib
2057/// to search in all libraries.
2058
2059Func_t TSystem::DynFindSymbol(const char * /*lib*/, const char *entry)
2060{
2061 return (Func_t) gInterpreter->FindSym(entry);
2062}
2063
2064////////////////////////////////////////////////////////////////////////////////
2065/// Unload a shared library.
2066
2067void TSystem::Unload(const char *module)
2068{
2069 char *path;
2070 if ((path = DynamicPathName(module))) {
2071 gInterpreter->UnloadFile(path);
2072 delete [] path;
2073 }
2074}
2075
2076////////////////////////////////////////////////////////////////////////////////
2077/// List symbols in a shared library.
2078
2079void TSystem::ListSymbols(const char *, const char *)
2080{
2081 AbstractMethod("ListSymbols");
2082}
2083
2084////////////////////////////////////////////////////////////////////////////////
2085/// List the loaded shared libraries.
2086/// `regexp` is a regular expression allowing to filter the list.
2087///
2088/// Examples:
2089///
2090/// The following line lists all the libraries currently loaded:
2091/// ~~~ {.cpp}
2092/// gSystem->ListLibraries()
2093/// ~~~
2094///
2095/// The following line lists all the libraries currently loaded having "RIO" in their names:
2096/// ~~~ {.cpp}
2097/// gSystem->ListLibraries(".*RIO.*")
2098/// ~~~
2099
2100void TSystem::ListLibraries(const char *regexp) {
2101 if (!(regexp && regexp[0]))
2102 regexp = ".*";
2103 TRegexp pat(regexp, kFALSE);
2105 TString tok;
2106 Ssiz_t from = 0, ext;
2107 while (libs.Tokenize(tok, from, " ")) {
2108 if ((tok.Index(pat, &ext) != 0) || (ext != tok.Length()))
2109 continue;
2110 std::cout << tok << "\n";
2111 }
2112}
2113
2114////////////////////////////////////////////////////////////////////////////////
2115/// Return the thread local storage for the custom last error message
2116
2122
2123////////////////////////////////////////////////////////////////////////////////
2124/// Return the thread local storage for the custom last error message
2125
2127{
2128 return const_cast<TSystem*>(this)->GetLastErrorString();
2129}
2130
2131////////////////////////////////////////////////////////////////////////////////
2132/// Get list of shared libraries loaded at the start of the executable.
2133/// Returns 0 in case list cannot be obtained or in case of error.
2134
2136{
2137 return nullptr;
2138}
2139
2140////////////////////////////////////////////////////////////////////////////////
2141/// Return a space separated list of loaded shared libraries.
2142/// Regexp is a wildcard expression, see TRegexp::MakeWildcard.
2143/// This list is of a format suitable for a linker, i.e it may contain
2144/// -Lpathname and/or -lNameOfLib.
2145/// Option can be any of:
2146/// - S: shared libraries loaded at the start of the executable, because
2147/// they were specified on the link line.
2148/// - D: shared libraries dynamically loaded after the start of the program.
2149/// - L: this option is ignored, and available for backward compatibility.
2150
2151const char *TSystem::GetLibraries(const char *regexp, const char *options,
2153{
2154 fListLibs.Clear();
2155
2156 TString libs;
2157 TString opt(options);
2158 Bool_t so2dylib = (opt.First('L') != kNPOS);
2159 if (so2dylib)
2160 opt.ReplaceAll("L", "");
2161
2162 if (opt.IsNull() || opt.First('D') != kNPOS)
2163 libs += gInterpreter->GetSharedLibs();
2164
2165 // Cint currently register all libraries that
2166 // are loaded and have a dictionary in them, this
2167 // includes all the libraries that are included
2168 // in the list of (hard) linked libraries.
2169
2171 const char *linked;
2172 if ((linked = GetLinkedLibraries())) {
2173 if (fLinkedLibs != LINKEDLIBS) {
2174 // This is not the default value, we need to keep the custom part.
2176 custom.ReplaceAll(LINKEDLIBS,linked);
2177 if (custom == fLinkedLibs) {
2178 // no replacement done, let's append linked
2179 slinked.Append(linked);
2180 slinked.Append(" ");
2181 }
2182 slinked.Append(custom);
2183 } else {
2184 slinked.Append(linked);
2185 }
2186 } else {
2187 slinked.Append(fLinkedLibs);
2188 }
2189
2190 if (opt.IsNull() || opt.First('S') != kNPOS) {
2191 // We are done, the statically linked libraries are already included.
2192 if (libs.Length() == 0) {
2193 libs = slinked;
2194 } else {
2195 // We need to add the missing linked library
2196
2197 static TString lastLinked;
2198 static TString lastAddMissing;
2199 if ( lastLinked != slinked ) {
2200 // Recalculate only if there was a change.
2201 static TRegexp separator("[^ \\t\\s]+");
2203 lastAddMissing.Clear();
2204
2205 Ssiz_t start, index, end;
2206 start = index = end = 0;
2207
2208 while ((start < slinked.Length()) && (index != kNPOS)) {
2209 index = slinked.Index(separator,&end,start);
2210 if (index >= 0) {
2211 TString sub = slinked(index,end);
2212 if (sub[0]=='-' && sub[1]=='L') {
2213 lastAddMissing.Prepend(" ");
2214 lastAddMissing.Prepend(sub);
2215 } else {
2216 if (libs.Index(sub) == kNPOS) {
2217 lastAddMissing.Prepend(" ");
2218 lastAddMissing.Prepend(sub);
2219 }
2220 }
2221 }
2222 start += end+1;
2223 }
2224 }
2225 libs.Prepend(lastAddMissing);
2226 }
2227 } else if (libs.Length() != 0) {
2228 // Let remove the statically linked library
2229 // from the list.
2230 static TRegexp separator("[^ \\t\\s]+");
2231 Ssiz_t start, index, end;
2232 start = index = end = 0;
2233
2234 while ((start < slinked.Length()) && (index != kNPOS)) {
2235 index = slinked.Index(separator,&end,start);
2236 if (index >= 0) {
2237 TString sub = slinked(index,end);
2238 if (sub[0]!='-' && sub[1]!='L') {
2239 libs.ReplaceAll(sub,"");
2240 }
2241 }
2242 start += end+1;
2243 }
2244 libs = libs.Strip(TString::kBoth);
2245 }
2246
2247 // Select according to regexp
2248 if (regexp && *regexp) {
2249 static TRegexp separator("[^ \\t\\s]+");
2250 TRegexp user_re(regexp, kTRUE);
2251 TString s;
2252 Ssiz_t start, index, end;
2253 start = index = end = 0;
2254
2255 while ((start < libs.Length()) && (index != kNPOS)) {
2256 index = libs.Index(separator,&end,start);
2257 if (index >= 0) {
2258 s = libs(index,end);
2259 if ((isRegexp && s.Index(user_re) != kNPOS) ||
2260 (!isRegexp && s.Index(regexp) != kNPOS)) {
2261 if (!fListLibs.IsNull())
2262 fListLibs.Append(" ");
2263 fListLibs.Append(s);
2264 }
2265 }
2266 start += end+1;
2267 }
2268 } else
2269 fListLibs = libs;
2270
2271#if defined(R__MACOSX)
2272// We need to remove the libraries that are dynamically loaded and not linked
2273{
2276
2277 static TRegexp separator("[^ \\t\\s]+");
2278 static TRegexp dynload("/lib-dynload/");
2279
2280 Ssiz_t start, index, end;
2281 start = index = end = 0;
2282
2283 while ((start < libs2.Length()) && (index != kNPOS)) {
2284 index = libs2.Index(separator, &end, start);
2285 if (index >= 0) {
2286 TString s = libs2(index, end);
2287 if (s.Index(dynload) == kNPOS) {
2288 if (!maclibs.IsNull()) maclibs.Append(" ");
2289 maclibs.Append(s);
2290 }
2291 }
2292 start += end+1;
2293 }
2295}
2296#endif
2297
2298 return fListLibs.Data();
2299}
2300
2301//---- RPC ---------------------------------------------------------------------
2302
2303////////////////////////////////////////////////////////////////////////////////
2304/// Get Internet Protocol (IP) address of host.
2305
2307{
2308 AbstractMethod("GetHostByName");
2309 return TInetAddress();
2310}
2311
2312////////////////////////////////////////////////////////////////////////////////
2313/// Get Internet Protocol (IP) address of remote host and port #.
2314
2316{
2317 AbstractMethod("GetPeerName");
2318 return TInetAddress();
2319}
2320
2321////////////////////////////////////////////////////////////////////////////////
2322/// Get Internet Protocol (IP) address of host and port #.
2323
2325{
2326 AbstractMethod("GetSockName");
2327 return TInetAddress();
2328}
2329
2330////////////////////////////////////////////////////////////////////////////////
2331/// Get port # of internet service.
2332
2334{
2335 AbstractMethod("GetServiceByName");
2336 return -1;
2337}
2338
2339////////////////////////////////////////////////////////////////////////////////
2340/// Get name of internet service.
2341
2343{
2344 AbstractMethod("GetServiceByPort");
2345 return nullptr;
2346}
2347
2348////////////////////////////////////////////////////////////////////////////////
2349/// Open a connection to another host.
2350
2351int TSystem::OpenConnection(const char *, int, int, const char *)
2352{
2353 AbstractMethod("OpenConnection");
2354 return -1;
2355}
2356
2357////////////////////////////////////////////////////////////////////////////////
2358/// Announce TCP/IP service.
2359
2361{
2362 AbstractMethod("AnnounceTcpService");
2363 return -1;
2364}
2365
2366////////////////////////////////////////////////////////////////////////////////
2367/// Announce UDP service.
2368
2370{
2371 AbstractMethod("AnnounceUdpService");
2372 return -1;
2373}
2374
2375////////////////////////////////////////////////////////////////////////////////
2376/// Announce unix domain service.
2377
2379{
2380 AbstractMethod("AnnounceUnixService");
2381 return -1;
2382}
2383
2384////////////////////////////////////////////////////////////////////////////////
2385/// Announce unix domain service.
2386
2387int TSystem::AnnounceUnixService(const char *, int)
2388{
2389 AbstractMethod("AnnounceUnixService");
2390 return -1;
2391}
2392
2393////////////////////////////////////////////////////////////////////////////////
2394/// Accept a connection.
2395
2397{
2398 AbstractMethod("AcceptConnection");
2399 return -1;
2400}
2401
2402////////////////////////////////////////////////////////////////////////////////
2403/// Close socket connection.
2404
2406{
2407 AbstractMethod("CloseConnection");
2408}
2409
2410////////////////////////////////////////////////////////////////////////////////
2411/// Receive exactly length bytes into buffer. Use opt to receive out-of-band
2412/// data or to have a peek at what is in the buffer (see TSocket).
2413
2414int TSystem::RecvRaw(int, void *, int, int)
2415{
2416 AbstractMethod("RecvRaw");
2417 return -1;
2418}
2419
2420////////////////////////////////////////////////////////////////////////////////
2421/// Send exactly length bytes from buffer. Use opt to send out-of-band
2422/// data (see TSocket).
2423
2424int TSystem::SendRaw(int, const void *, int, int)
2425{
2426 AbstractMethod("SendRaw");
2427 return -1;
2428}
2429
2430////////////////////////////////////////////////////////////////////////////////
2431/// Receive a buffer headed by a length indicator.
2432
2433int TSystem::RecvBuf(int, void *, int)
2434{
2435 AbstractMethod("RecvBuf");
2436 return -1;
2437}
2438
2439////////////////////////////////////////////////////////////////////////////////
2440/// Send a buffer headed by a length indicator.
2441
2442int TSystem::SendBuf(int, const void *, int)
2443{
2444 AbstractMethod("SendBuf");
2445 return -1;
2446}
2447
2448////////////////////////////////////////////////////////////////////////////////
2449/// Set socket option.
2450
2451int TSystem::SetSockOpt(int, int, int)
2452{
2453 AbstractMethod("SetSockOpt");
2454 return -1;
2455}
2456
2457////////////////////////////////////////////////////////////////////////////////
2458/// Get socket option.
2459
2460int TSystem::GetSockOpt(int, int, int*)
2461{
2462 AbstractMethod("GetSockOpt");
2463 return -1;
2464}
2465
2466//---- System, CPU and Memory info ---------------------------------------------
2467
2468////////////////////////////////////////////////////////////////////////////////
2469/// Returns static system info, like OS type, CPU type, number of CPUs
2470/// RAM size, etc into the SysInfo_t structure. Returns -1 in case of error,
2471/// 0 otherwise.
2472
2474{
2475 AbstractMethod("GetSysInfo");
2476 return -1;
2477}
2478
2479////////////////////////////////////////////////////////////////////////////////
2480/// Returns cpu load average and load info into the CpuInfo_t structure.
2481/// Returns -1 in case of error, 0 otherwise. Use sampleTime to set the
2482/// interval over which the CPU load will be measured, in ms (default 1000).
2483
2485{
2486 AbstractMethod("GetCpuInfo");
2487 return -1;
2488}
2489
2490////////////////////////////////////////////////////////////////////////////////
2491/// Returns ram and swap memory usage info into the MemInfo_t structure.
2492/// Returns -1 in case of error, 0 otherwise.
2493
2495{
2496 AbstractMethod("GetMemInfo");
2497 return -1;
2498}
2499
2500////////////////////////////////////////////////////////////////////////////////
2501/// Returns cpu and memory used by this process into the ProcInfo_t structure.
2502/// Returns -1 in case of error, 0 otherwise.
2503
2505{
2506 AbstractMethod("GetProcInfo");
2507 return -1;
2508}
2509
2510//---- Script Compiler ---------------------------------------------------------
2511
2513{
2514 // Assign the char* value to the TString and then delete it.
2515
2517 delete [] tobedeleted;
2518}
2519
2520#ifdef WIN32
2521
2522static TString R__Exec(const char *cmd)
2523{
2524 // Execute a command and return the stdout in a string.
2525
2526 FILE * f = gSystem->OpenPipe(cmd,"r");
2527 if (!f) {
2528 return "";
2529 }
2531
2532 char x;
2533 while ((x = fgetc(f))!=EOF ) {
2534 if (x=='\n' || x=='\r') break;
2535 result += x;
2536 }
2537
2538 fclose(f);
2539 return result;
2540}
2541
2542static void R__FixLink(TString &cmd)
2543{
2544 // Replace the call to 'link' by a full path name call based on where cl.exe is.
2545 // This prevents us from using inadvertently the link.exe provided by cygwin.
2546
2547 // check if link is the microsoft one...
2548 TString res = R__Exec("link 2>&1");
2549 if (res.Length()) {
2550 if (res.Contains("Microsoft (R) Incremental Linker"))
2551 return;
2552 }
2553 // else check availability of cygpath...
2554 res = R__Exec("cygpath . 2>&1");
2555 if (res.Length()) {
2556 if (res != ".")
2557 return;
2558 }
2559
2560 res = R__Exec("which cl.exe 2>&1|grep cl|sed 's,cl\\.exe$,link\\.exe,' 2>&1");
2561 if (res.Length()) {
2562 res = R__Exec(Form("cygpath -w '%s' 2>&1",res.Data()));
2563 if (res.Length()) {
2564 cmd.ReplaceAll(" link ",Form(" \"%s\" ",res.Data()));
2565 }
2566 }
2567}
2568#endif
2569
2570#if defined(__CYGWIN__)
2571static void R__AddPath(TString &target, const TString &path) {
2572 if (path.Length() > 2 && path[1]==':') {
2573 target += TString::Format("/cygdrive/%c",path[0]) + path(2,path.Length()-2);
2574 } else {
2575 target += path;
2576 }
2577}
2578#else
2579static void R__AddPath(TString &target, const TString &path) {
2580 target += path;
2581}
2582#endif
2583
2585 const TString &extension, const char *version_var_prefix, const TString &includes, const TString &defines, const TString &incPath)
2586{
2587 // Generate the dependency via standard output, not searching the
2588 // standard include directories,
2589
2590#ifndef WIN32
2591 const char * stderrfile = "/dev/null";
2592#else
2595#endif
2597
2598#ifdef WIN32
2599 TString touch = "echo # > "; touch += "\"" + depfilename + "\"";
2600#else
2601 TString touch = "echo > "; touch += "\"" + depfilename + "\"";
2602#endif
2603 TString builddep = "rmkdepend";
2605 builddep += " \"-f";
2607 builddep += "\" -o_" + extension + "." + gSystem->GetSoExt() + " ";
2608 if (build_loc.BeginsWith(gSystem->WorkingDirectory())) {
2610 if ( build_loc.Length() > (len+1) ) {
2611 builddep += " \"-p";
2612 if (build_loc[len] == '/' || build_loc[len+1] != '\\' ) {
2613 // Since the path is now ran through TSystem::ExpandPathName the single \ is also possible.
2614 R__AddPath(builddep, build_loc.Data() + len + 1 );
2615 } else {
2616 // Case of dir\\name
2617 R__AddPath(builddep, build_loc.Data() + len + 2 );
2618 }
2619 builddep += "/\" ";
2620 }
2621 } else {
2622 builddep += " \"-p";
2624 builddep += "/\" ";
2625 }
2626 builddep += " -Y -- ";
2628 builddep += " \"-I"+rootsysInclude+"\" "; // cflags
2629 builddep += includes;
2630 builddep += defines;
2631 builddep += " -- \"";
2632 builddep += filename;
2633 builddep += "\" ";
2635 if (library.BeginsWith(gSystem->WorkingDirectory())) {
2637 if ( library.Length() > (len+1) ) {
2638 if (library[len] == '/' || library[len+1] != '\\' ) {
2639 targetname = library.Data() + len + 1;
2640 } else {
2641 targetname = library.Data() + len + 2;
2642 }
2643 } else {
2645 }
2646 } else {
2648 }
2649 builddep += " \"";
2650 builddep += "-t";
2652 builddep += "\" > ";
2654 builddep += " 2>&1 ";
2655
2656 TString adddictdep = "echo ";
2658 adddictdep += ": ";
2659#if defined(R__HAS_CLING_DICTVERSION)
2660 {
2661 char *clingdictversion = gSystem->Which(incPath,"clingdictversion.h");
2662 if (clingdictversion) {
2664 adddictdep += " ";
2665 delete [] clingdictversion;
2666 } else {
2667 R__AddPath(adddictdep,rootsysInclude+"/clingdictversion.h ");
2668 }
2669 }
2670#endif
2671 {
2672 const char *dictHeaders[] = { "RVersion.h", "ROOT/RConfig.hxx", "TClass.h",
2673 "TDictAttributeMap.h","TInterpreter.h","TROOT.h","TBuffer.h",
2674 "TMemberInspector.h","TError.h","RtypesImp.h","TIsAProxy.h",
2675 "TFileMergeInfo.h","TCollectionProxyInfo.h"};
2676
2677 for (unsigned int h=0; h < sizeof(dictHeaders)/sizeof(dictHeaders[0]); ++h)
2678 {
2680 if (rootVersion) {
2682 delete [] rootVersion;
2683 } else {
2685 }
2686 adddictdep += " ";
2687 }
2688 }
2689 {
2690 // Add dependency on rootcling.
2691 char *rootCling = gSystem->Which(gSystem->Getenv("PATH"),"rootcling");
2692 if (rootCling) {
2694 adddictdep += " ";
2695 delete [] rootCling;
2696 }
2697 }
2698 adddictdep += " >> \""+depfilename+"\"";
2699
2700 TString addversiondep( "echo ");
2701 addversiondep += libname + version_var_prefix + " \"" + ROOT_RELEASE + "\" >> \""+depfilename+"\"";
2702
2703 if (gDebug > 4) {
2704 ::Info("ACLiC", "%s", touch.Data());
2705 ::Info("ACLiC", "%s", builddep.Data());
2706 ::Info("ACLiC", "%s", adddictdep.Data());
2707 }
2708
2713
2714 if (!depbuilt) {
2715 ::Warning("ACLiC","Failed to generate the dependency file for %s",
2716 library.Data());
2717 } else {
2718#ifdef WIN32
2720#endif
2722 }
2723}
2724
2725////////////////////////////////////////////////////////////////////////////////
2726/// This method compiles and loads a shared library containing
2727/// the code from the file "filename".
2728///
2729/// The return value is true (1) in case of success and false (0)
2730/// in case of error.
2731///
2732/// The possible options are:
2733/// - k : keep the shared library after the session end.
2734/// - f : force recompilation.
2735/// - g : compile with debug symbol
2736/// - O : optimized the code
2737/// - c : compile only, do not attempt to load the library.
2738/// - s : silence all informational output
2739/// - v : output all information output
2740/// - d : debug ACLiC, keep all the output files.
2741/// - - : if buildir is set, use a flat structure (see buildir below)
2742///
2743/// If library_specified is specified, CompileMacro generates the file
2744/// "library_specified".soext where soext is the shared library extension for
2745/// the current platform.
2746///
2747/// If build_dir is specified, it is used as an alternative 'root' for the
2748/// generation of the shared library. The library is stored in a sub-directories
2749/// of 'build_dir' including the full pathname of the script unless a flat
2750/// directory structure is requested ('-' option). With the '-' option the libraries
2751/// are created directly in the directory 'build_dir'; in particular this means that
2752/// 2 scripts with the same name in different source directory will over-write each
2753/// other's library.
2754/// See also TSystem::SetBuildDir.
2755///
2756/// If dirmode is not zero and we need to create the target directory, the
2757/// file mode bit will be change to 'dirmode' using chmod.
2758///
2759/// If library_specified is not specified, CompileMacro generate a default name
2760/// for library by taking the name of the file "filename" but replacing the
2761/// dot before the extension by an underscore and by adding the shared
2762/// library extension for the current platform.
2763/// For example on most platform, hsimple.cxx will generate hsimple_cxx.so
2764///
2765/// It uses the directive fMakeSharedLibs to create a shared library.
2766/// If loading the shared library fails, it tries to output a list of missing
2767/// symbols by creating an executable (on some platforms like OSF, this does
2768/// not HAVE to be an executable) containing the script. It uses the
2769/// directive fMakeExe to do so.
2770/// For both directives, before passing them to TSystem::Exec, it expands the
2771/// variables $SourceFiles, $SharedLib, $LibName, $IncludePath, $LinkedLibs,
2772/// $DepLibs, $ExeName and $ObjectFiles. See SetMakeSharedLib() for more
2773/// information on those variables.
2774///
2775/// This method is used to implement the following feature:
2776///
2777/// Synopsis:
2778///
2779/// The purpose of this addition is to allow the user to use an external
2780/// compiler to create a shared library from its C++ macro (scripts).
2781/// Currently in order to execute a script, a user has to type at the root
2782/// prompt
2783/// ~~~ {.cpp}
2784/// .X myfunc.C(arg1,arg2)
2785/// ~~~
2786/// We allow them to type:
2787/// ~~~ {.cpp}
2788/// .X myfunc.C++(arg1,arg2)
2789/// ~~~
2790/// or
2791/// ~~~ {.cpp}
2792/// .X myfunc.C+(arg1,arg2)
2793/// ~~~
2794/// In which case an external compiler will be called to create a shared
2795/// library. This shared library will then be loaded and the function
2796/// myfunc will be called with the two arguments. With '++' the shared library
2797/// is always recompiled. With '+' the shared library is recompiled only
2798/// if it does not exist yet or the macro file is newer than the shared
2799/// library.
2800///
2801/// Of course the + and ++ notation is supported in similar way for .x and .L.
2802///
2803/// Through the function TSystem::SetMakeSharedLib(), the user will be able to
2804/// indicate, with shell commands, how to build a shared library (a good
2805/// default will be provided). The most common change, namely where to find
2806/// header files, will be available through the function
2807/// TSystem::SetIncludePath().
2808/// A good default will be provided so that a typical user session should be at
2809/// most:
2810/// ~~~ {.cpp}
2811/// root[1] gSystem->SetIncludePath("-I$ROOTSYS/include
2812/// -I$HOME/mypackage/include");
2813/// root[2] .x myfunc.C++(10,20);
2814/// ~~~
2815/// The user may sometimes try to compile a script before it has loaded all the
2816/// needed shared libraries. In this case we want to be helpful and output a
2817/// list of the unresolved symbols. So if the loading of the created shared
2818/// library fails, we will try to build a executable that contains the
2819/// script. The linker should then output a list of missing symbols.
2820///
2821/// To support this we provide a TSystem::SetMakeExe() function, that sets the
2822/// directive telling how to create an executable. The loader will need
2823/// to be informed of all the libraries available. The information about
2824/// the libraries that has been loaded by .L and TSystem::Load() is accessible
2825/// to the script compiler. However, the information about
2826/// the libraries that have been selected at link time by the application
2827/// builder (like the root libraries for root.exe) are not available and need
2828/// to be explicitly listed in fLinkedLibs (either by default or by a call to
2829/// TSystem::SetLinkedLibs()).
2830///
2831/// To simplify customization we could also add to the .rootrc support for the
2832/// variables
2833/// ~~~ {.cpp}
2834/// Unix.*.Root.IncludePath: -I$ROOTSYS/include
2835/// WinNT.*.Root.IncludePath: -I%ROOTSYS%/include
2836///
2837/// Unix.*.Root.LinkedLibs: -L$ROOTSYS/lib -lBase ....
2838/// WinNT.*.Root.LinkedLibs: %ROOTSYS%/lib/*.lib msvcrt.lib ....
2839/// ~~~
2840/// And also support for MakeSharedLibs() and MakeExe().
2841///
2842/// (the ... have to be replaced by the actual values and are here only to
2843/// shorten this comment).
2844///
2845/// Note that the default behavior is to remove libraries when closing ROOT,
2846/// ie TSystem::CleanCompiledMacros() is called in the TROOT destructor.
2847/// The default behavior of .L script.C+ is the opposite one, leaving things
2848/// after closing, without removing. In other words, .L always passes the 'k'
2849/// option behind the scenes.
2850
2852 const char *library_specified,
2853 const char *build_dir,
2855{
2856 static const char *version_var_prefix = "__ROOTBUILDVERSION=";
2857
2858 // ======= Analyze the options
2859 Bool_t keep = kFALSE;
2861 int mode = fAclicMode;
2864 Bool_t verbose = kFALSE;
2866 if (opt) {
2867 keep = (strchr(opt,'k')!=nullptr);
2868 recompile = (strchr(opt,'f')!=nullptr);
2869 if (strchr(opt,'O')!=nullptr) {
2870 mode |= kOpt;
2871 }
2872 if (strchr(opt,'g')!=nullptr) {
2873 mode |= kDebug;
2874 }
2875 if (strchr(opt,'c')!=nullptr) {
2876 loadLib = kFALSE;
2877 }
2878 withInfo = strchr(opt, 's') == nullptr;
2879 verbose = strchr(opt, 'v') != nullptr;
2880 internalDebug = strchr(opt, 'd') != nullptr;
2881 }
2882 if (mode==kDefault) {
2884 if (rootbuild.Index("debug",0,TString::kIgnoreCase)==kNPOS) {
2885 mode = kOpt;
2886 } else {
2887 mode = kDebug;
2888 }
2889 }
2890#if defined(_MSC_VER) && defined(_DEBUG)
2891 // if ROOT is build in debug mode, ACLiC must also build in debug mode
2892 // for compatibility reasons
2893 if (!(mode & kDebug))
2894 mode |= kDebug;
2895#endif
2896 UInt_t verboseLevel = verbose ? 7 : gDebug;
2897 Bool_t flatBuildDir = (fAclicProperties & kFlatBuildDir) || (opt && strchr(opt,'-')!=nullptr);
2898
2899 // if non-zero, build_loc indicates where to build the shared library.
2902 if (build_loc == ".") {
2904 } else if (build_loc.Length() && (!IsAbsoluteFileName(build_loc)) ) {
2906 }
2907
2908 // Get the include directory list in the dir1:dir2:dir3 format
2909 // [Used for generating the .d file and to look for header files for
2910 // the linkdef file]
2911 TString incPath = GetIncludePath(); // of the form -Idir1 -Idir2 -Idir3
2912 incPath.Append(":").Prepend(" ");
2913 if (gEnv) {
2914 TString fromConfig = gEnv->GetValue("ACLiC.IncludePaths","");
2915 incPath.Append(fromConfig);
2916 }
2917 incPath.ReplaceAll(" -I",":"); // of form :dir1 :dir2:dir3
2918 auto posISysRoot = incPath.Index(" -isysroot \"");
2919 if (posISysRoot != kNPOS) {
2920 auto posISysRootEnd = incPath.Index('"', posISysRoot + 12);
2921 if (posISysRootEnd != kNPOS) {
2922 // NOTE: should probably just skip isysroot for dependency analysis.
2923 // (And will, in the future - once we rely on compiler-generated .d files.)
2924 incPath.Insert(posISysRootEnd - 1, "/usr/include/");
2925 incPath.Replace(posISysRoot, 12, ":\"");
2926 }
2927 }
2928 while ( incPath.Index(" :") != -1 ) {
2929 incPath.ReplaceAll(" :",":");
2930 }
2931 incPath.Prepend(":.:");
2932 incPath.Prepend(WorkingDirectory());
2933
2934 // ======= Get the right file names for the dictionary and the shared library
2940 {
2941 const char *whichlibrary = Which(incPath,library);
2942 if (whichlibrary) {
2944 delete [] whichlibrary;
2945 } else {
2946 ::Error("ACLiC","The file %s can not be found in the include path: %s",filename,incPath.Data());
2947 return kFALSE;
2948 }
2949 } else {
2951 ::Error("ACLiC","The file %s can not be found.",filename);
2952 return kFALSE;
2953 }
2954 }
2955 { // Remove multiple '/' characters, rootcling treats them as comments.
2956 Ssiz_t pos = 0;
2957 while ((pos = library.Index("//", 2, pos, TString::kExact)) != kNPOS) {
2958 library.Remove(pos, 1);
2959 }
2960 }
2963
2965 // For some probably good reason, DirName on Windows returns the 'name' of
2966 // the directory, omitting the drive letter (even if there was one). In
2967 // consequence the result is not usable as a 'root directory', we need to
2968 // add the drive letter if there was one..
2969 if (library.Length()>1 && isalpha(library[0]) && library[1]==':') {
2970 file_dirname.Prepend(library(0,2));
2971 }
2972 TString file_location( file_dirname ); // Location of the script.
2973 incPath.Prepend( file_location + ":" );
2974
2975 Ssiz_t dot_pos = library.Last('.');
2977 if (dot_pos >= 0) {
2978 libname_noext.Remove(dot_pos);
2979 extension = library(dot_pos+1, library.Length()-dot_pos-1);
2980 }
2981
2982 // Extension of shared library is platform dependent!!
2983 TString suffix = TString("_") + extension + "." + fSoExt;
2984 if (dot_pos >= 0)
2985 library.Replace( dot_pos, library.Length()-dot_pos, suffix);
2986 else
2987 library.Append(suffix);
2988
2990 libname.Append("_").Append(extension);
2991
2993 // Use the specified name instead of the default
2997 if (! IsAbsoluteFileName(library) ) {
2999 }
3001 library = TString(library) + "." + fSoExt;
3002 }
3004
3006 libname_ext += "." + fSoExt;
3007
3009 // For some probably good reason, DirName on Windows returns the 'name' of
3010 // the directory, omitting the drive letter (even if there was one). In
3011 // consequence the result is not useable as a 'root directory', we need to
3012 // add the drive letter if there was one..
3013 if (library.Length()>1 && isalpha(library[0]) && library[1]==':') {
3014 lib_dirname.Prepend(library(0,2));
3015 }
3016 // Strip potential, somewhat redundant '/.' from the pathname ...
3017 if ( strncmp( &(lib_dirname[lib_dirname.Length()-2]), "/.", 2) == 0 ) {
3018 lib_dirname.Remove(lib_dirname.Length()-2);
3019 }
3020 if ( strncmp( &(lib_dirname[lib_dirname.Length()-2]), "\\.", 2) == 0 ) {
3021 lib_dirname.Remove(lib_dirname.Length()-2);
3022 }
3025
3026 if (build_loc.Length()==0) {
3028 } else {
3029 // Removes an existing disk specification from the names
3030 TRegexp disk_finder ("[A-z]:");
3031 Int_t pos = library.Index( disk_finder );
3032 if (pos==0) library.Remove(pos,3);
3033 pos = lib_location.Index( disk_finder );
3034 if (pos==0) lib_location.Remove(pos,3);
3035
3036 if (flatBuildDir) {
3038 } else {
3040 }
3041
3044 if (!flatBuildDir) {
3046 }
3047
3049 mkdirFailed = (0 != mkdir(build_loc, true));
3051 // The mkdir failed __and__ we can not write to the target directory,
3052 // let make sure the error message will be about the target directory
3055 } else if (!mkdirFailed && dirmode!=0) {
3057 }
3058 }
3059 }
3061
3062 // ======= Check if the library need to loaded or compiled
3063 if (!gInterpreter->IsLibraryLoaded(library) && gInterpreter->IsLoaded(expFileName)) {
3064 // the script has already been loaded in interpreted mode
3065 // Let's warn the user and unload it.
3066
3067 if (withInfo) {
3068 ::Info("ACLiC","script has already been loaded in interpreted mode");
3069 ::Info("ACLiC","unloading %s and compiling it", filename);
3070 }
3071
3072 if ( gInterpreter->UnloadFile( expFileName ) != 0 ) {
3073 // We can not unload it.
3074 return kFALSE;
3075 }
3076 }
3077
3078 // Calculate the -I lines
3080 includes.ReplaceAll("-I ", "-I");
3081 includes.Prepend(' ');
3082
3083 {
3084 // I need to replace the -Isomerelativepath by -I../ (or -I..\ on NT)
3085 TRegexp rel_inc(" -I[^\"/\\\\$\\%-][^:\\s]+");
3086 Int_t len,pos;
3087 pos = rel_inc.Index(includes,&len);
3088 while( len != 0 ) {
3089 TString sub = includes(pos,len);
3090 sub.Remove(0,3); // Remove ' -I'
3092 sub.Prepend(" -I\"");
3093 if (sub.EndsWith(" "))
3094 sub.Chop(); // Remove trailing space (i.e between the -Is ...
3095 sub.Append("\" ");
3096 includes.Replace(pos,len,sub);
3097 pos = rel_inc.Index(includes,&len);
3098 }
3099 }
3100 {
3101 // I need to replace the -I"somerelativepath" by -I"$cwd/ (or -I"$cwd\ on NT)
3102 TRegexp rel_inc(" -I\"[^/\\\\$\\%-][^:\\s]+");
3103 Int_t len,pos;
3104 pos = rel_inc.Index(includes,&len);
3105 while( len != 0 ) {
3106 TString sub = includes(pos,len);
3107 sub.Remove(0,4); // Remove ' -I"'
3109 sub.Prepend(" -I\"");
3110 includes.Replace(pos,len,sub);
3111 pos = rel_inc.Index(includes,&len);
3112 }
3113 }
3114 //includes += " -I\"" + build_loc;
3115 //includes += "\" -I\"";
3116 //includes += WorkingDirectory();
3117// if (includes[includes.Length()-1] == '\\') {
3118// // The current directory is (most likely) the root of a windows drive and
3119// // has a trailing \ which would espace the quote if left by itself.
3120// includes += '\\';
3121// }
3122// includes += "\"";
3123 if (gEnv) {
3124 TString fromConfig = gEnv->GetValue("ACLiC.IncludePaths","");
3125 includes.Append(" ").Append(fromConfig).Append(" ");
3126 }
3127
3128 // Extract the -D for the dependency generation.
3129 TString defines = " ";
3130 {
3132 TRegexp rel_def("-D[^\\s\\t\\n\\r]*");
3133 Int_t len,pos;
3134 pos = rel_def.Index(cmd,&len);
3135 while( len != 0 ) {
3136 defines += cmd(pos,len);
3137 defines += " ";
3138 pos = rel_def.Index(cmd,&len,pos+1);
3139 }
3140
3141 }
3142
3144 {
3146 if (ug) {
3148 delete ug;
3149 } else {
3151 }
3152 }
3153
3155
3157
3158 // Generate the dependency filename
3162 depfilename += "_" + extension + ".d";
3163
3164 if ( !recompile ) {
3165
3167
3168 if ((gSystem->GetPathInfo( library, nullptr, (Long_t*)nullptr, nullptr, &lib_time ) != 0) ||
3169 (gSystem->GetPathInfo( expFileName, nullptr, (Long_t*)nullptr, nullptr, &file_time ) == 0 &&
3170 (lib_time < file_time))) {
3171
3172 // the library does not exist or is older than the script.
3173 recompile = kTRUE;
3174 modified = kTRUE;
3175
3176 } else {
3177
3178 if ( gSystem->GetPathInfo( depfilename, nullptr,(Long_t*) nullptr, nullptr, &file_time ) != 0 ) {
3179 if (!canWrite) {
3182 depfilename += "_" + extension + ".d";
3183 }
3185 }
3186 }
3187
3188 if (!modified) {
3189
3190 // We need to check the dependencies
3191 FILE * depfile = fopen(depfilename.Data(),"r");
3192 if (depfile==nullptr) {
3193 // there is no accessible dependency file, let's assume the library has been
3194 // modified
3195 modified = kTRUE;
3196 recompile = kTRUE;
3197
3198 } else {
3199
3201
3202 Int_t sz = 256;
3203 char *line = new char[sz];
3204 line[0] = 0;
3205
3206 int c;
3207 Int_t current = 0;
3208 Int_t nested = 0;
3209 Bool_t hasversion = false;
3210
3211 while ((c = fgetc(depfile)) != EOF) {
3212 if (c=='#') {
3213 // skip comment
3214 while ((c = fgetc(depfile)) != EOF) {
3215 if (c=='\n') {
3216 break;
3217 }
3218 }
3219 continue;
3220 }
3221 if (current && line[current-1]=='=' && strncmp(version_var.Data(),line,current)==0) {
3222
3223 // The next word will be the version number.
3224 hasversion = kTRUE;
3225 line[0] = 0;
3226 current = 0;
3227 } else if (isspace(c) && !nested) {
3228 if (current) {
3229 if (line[current-1]!=':') {
3230 // ignore target
3231 line[current] = 0;
3232
3234 if (hasversion) {
3237 } else if ( gSystem->GetPathInfo( line, nullptr, (Long_t*)nullptr, nullptr, &filetime ) == 0 ) {
3238 modified |= ( lib_time <= filetime );
3239 }
3240 }
3241 }
3242 current = 0;
3243 line[0] = 0;
3244 } else {
3245 if (current==sz-1) {
3246 sz = 2*sz;
3247 char *newline = new char[sz];
3248 memcpy(newline,line, current);
3249 delete [] line;
3250 line = newline;
3251 }
3252 if (c=='"') nested = !nested;
3253 else {
3254 line[current] = c;
3255 current++;
3256 }
3257 }
3258 }
3259 delete [] line;
3260 fclose(depfile);
3262
3263 }
3264
3265 }
3266 }
3267
3268 if ( gInterpreter->IsLibraryLoaded(library)
3269 || strlen(GetLibraries(library,"D",kFALSE)) != 0 ) {
3270 // The library has already been built and loaded.
3271
3272 Bool_t reload = kFALSE;
3274 if (libinfo) {
3275 Long_t load_time = libinfo->GetUniqueID();
3277 if ( gSystem->GetPathInfo( library, nullptr, (Long_t*)nullptr, nullptr, &lib_time ) == 0
3278 && (lib_time>load_time)) {
3279 reload = kTRUE;
3280 }
3281 }
3282
3283 if ( !recompile && reload ) {
3284
3285 if (withInfo) {
3286 ::Info("ACLiC","%s has been modified and will be reloaded",
3287 libname.Data());
3288 }
3289 if ( gInterpreter->UnloadFile( library.Data() ) != 0 ) {
3290 // The library is being used. We can not unload it.
3291 return kFALSE;
3292 }
3293 if (libinfo) {
3295 delete libinfo;
3296 libinfo = nullptr;
3297 }
3298 TNamed *k = new TNamed(library,library);
3300 gSystem->GetPathInfo( library, nullptr, (Long_t*)nullptr, nullptr, &lib_time );
3302 if (!keep) k->SetBit(kMustCleanup);
3303 fCompiled->Add(k);
3304
3305 return !gSystem->Load(library);
3306 }
3307
3308 if (withInfo) {
3309 ::Info("ACLiC","%s script has already been compiled and loaded",
3310 modified ? "modified" : "unmodified");
3311 }
3312
3313 if ( !recompile ) {
3314 return kTRUE;
3315 } else {
3316 if (withInfo) {
3317 ::Info("ACLiC","it will be regenerated and reloaded!");
3318 }
3319 if ( gInterpreter->UnloadFile( library.Data() ) != 0 ) {
3320 // The library is being used. We can not unload it.
3321 return kFALSE;
3322 }
3323 if (libinfo) {
3325 delete libinfo;
3326 libinfo = nullptr;
3327 }
3328 Unlink(library);
3329 }
3330
3331 }
3332
3335 libmapfilename += ".rootmap";
3336#if (defined(R__MACOSX) && !defined(MAC_OS_X_VERSION_10_5)) || defined(R__WIN32)
3338#else
3340#endif
3342 if (gEnv) {
3343#if (defined(R__MACOSX) && !defined(MAC_OS_X_VERSION_10_5))
3344 Int_t linkLibs = gEnv->GetValue("ACLiC.LinkLibs",2);
3345#elif defined(R__WIN32)
3346 Int_t linkLibs = gEnv->GetValue("ACLiC.LinkLibs",3);
3347#else
3348 Int_t linkLibs = gEnv->GetValue("ACLiC.LinkLibs",1);
3349#endif
3350 produceRootmap = linkLibs & 0x2;
3351 linkDepLibraries = linkLibs & 0x1;
3352 }
3353
3354 // FIXME: Triggers clang false positive warning -Wunused-lambda-capture.
3355 /*constexpr const*/ bool useCxxModules =
3356#ifdef R__USE_CXXMODULES
3357 true;
3358#else
3359 false;
3360#endif
3361
3362 // FIXME: Switch to generic polymorphic when we make c++14 default.
3363 auto ForeachSharedLibDep = [](const char *lib, std::function<bool(const char *)> f) {
3364 using std::string, std::vector, std::istringstream, std::istream_iterator;
3365 string deps = gInterpreter->GetSharedLibDeps(lib, /*tryDyld*/ true);
3366 istringstream iss(deps);
3368 // Skip the first element: it is a relative path to `lib`.
3369 for (auto I = libs.begin() + 1, E = libs.end(); I != E; ++I)
3370 if (!f(I->c_str()))
3371 break;
3372 };
3374 // We have no rootmap files or modules to construct `-l` flags enabling
3375 // explicit linking. We have to resolve the dependencies by ourselves
3376 // taking the job of the dyld.
3377 // FIXME: This is a rare case where we have rootcling running with
3378 // modules disabled. Remove this code once we fully switch to modules,
3379 // or implement a special flag in rootcling which selective enables
3380 // modules for dependent libraries and does not produce a module for
3381 // the ACLiC library.
3382 if (useCxxModules && !produceRootmap) {
3383 std::function<bool(const char *)> LoadLibF = [](const char *dep) {
3384 return gInterpreter->Load(dep, /*skipReload*/ true) >= 0;
3385 };
3387 }
3388 return !gSystem->Load(lib);
3389 };
3390
3391 if (!recompile) {
3392 // The library already exist, let's just load it.
3393 if (loadLib) {
3394 TNamed *k = new TNamed(library,library);
3396 gSystem->GetPathInfo( library, nullptr, (Long_t*)nullptr, nullptr, &lib_time );
3398 if (!keep) k->SetBit(kMustCleanup);
3399 fCompiled->Add(k);
3400
3401 gInterpreter->GetSharedLibDeps(library);
3402
3403 return LoadLibrary(library);
3404 }
3405 else return kTRUE;
3406 }
3407
3408 if (!canWrite && recompile) {
3409
3410 if (mkdirFailed) {
3411 ::Warning("ACLiC","Could not create the directory: %s",
3412 build_loc.Data());
3413 } else {
3414 ::Warning("ACLiC","%s is not writable!",
3415 build_loc.Data());
3416 }
3417 if (emergency_loc == build_dir ) {
3418 ::Error("ACLiC","%s is the last resort location (i.e. temp location)",build_loc.Data());
3419 return kFALSE;
3420 }
3421 ::Warning("ACLiC","Output will be written to %s",
3422 emergency_loc.Data());
3424 }
3425
3426 if (withInfo) {
3427 Info("ACLiC","creating shared library %s",library.Data());
3428 }
3429
3431
3432 // ======= Select the dictionary name
3433 TString dict = libname + "_ACLiC_dict";
3434
3435 // the file name end up in the file produced
3436 // by rootcling as a variable name so all character need to be valid!
3437 static const int maxforbidden = 27;
3438 static const char *forbidden_chars[maxforbidden] =
3439 { "+","-","*","/","&","%","|","^",">","<",
3440 "=","~",".","(",")","[","]","!",",","$",
3441 " ",":","'","#","@","\\","\"" };
3442 for( int ic = 0; ic < maxforbidden; ic++ ) {
3443 dict.ReplaceAll( forbidden_chars[ic],"_" );
3444 }
3445 if ( dict.Last('.')!=dict.Length()-1 ) dict.Append(".");
3446 AssignAndDelete( dict, ConcatFileName( build_loc, dict ) );
3447 TString dicth = dict;
3448 TString dictObj = dict;
3449 dict += "cxx"; //no need to keep the extension of the original file, any extension will do
3450 dicth += "h";
3451 dictObj += fObjExt;
3452
3453 // ======= Generate a linkdef file
3454
3457 linkdef += "_ACLiC_linkdef.h";
3458 std::ofstream linkdefFile( linkdef, std::ios::out );
3459 linkdefFile << "// File Automatically generated by the ROOT Script Compiler "
3460 << std::endl;
3461 linkdefFile << std::endl;
3462 linkdefFile << "#ifdef __CINT__" << std::endl;
3463 linkdefFile << std::endl;
3464 linkdefFile << "#pragma link C++ nestedclasses;" << std::endl;
3465 linkdefFile << "#pragma link C++ nestedtypedefs;" << std::endl;
3466 linkdefFile << std::endl;
3467
3468 // We want to look for a header file that has the same name as the macro
3469
3470 const char * extensions[] = { ".h", ".hh", ".hpp", ".hxx", ".hPP", ".hXX" };
3471
3472 int i;
3473 for (i = 0; i < 6; i++ ) {
3474 char * name;
3477 extra_linkdef.Append(extensions[i]);
3479 if (name) {
3480 if (verboseLevel>4 && withInfo) {
3481 Info("ACLiC","including extra linkdef file: %s",name);
3482 }
3483 linkdefFile << "#include \"" << name << "\"" << std::endl;
3484 delete [] name;
3485 }
3486 }
3487
3488 if (verboseLevel>5 && withInfo) {
3489 Info("ACLiC","looking for header in: %s",incPath.Data());
3490 }
3491 for (i = 0; i < 6; i++ ) {
3492 char * name;
3493 TString lookup = BaseName( libname_noext );
3494 lookup.Append(extensions[i]);
3495 name = Which(incPath,lookup);
3496 if (name) {
3497 linkdefFile << "#pragma link C++ defined_in "<<gSystem->UnixPathName(name)<<";"<< std::endl;
3498 delete [] name;
3499 }
3500 }
3501 linkdefFile << "#pragma link C++ defined_in \""<<filename_fullpath << "\";" << std::endl;
3502 linkdefFile << std::endl;
3503 linkdefFile << "#endif" << std::endl;
3504 linkdefFile.close();
3505 // ======= Generate the list of rootmap files to be looked at
3506
3509 mapfile += "_ACLiC_map";
3510 TString mapfilein = mapfile + ".in";
3511 TString mapfileout = mapfile + ".out";
3512
3514 if (!useCxxModules) {
3515 if (gInterpreter->GetSharedLibDeps(library) != nullptr) {
3516 gInterpreter->UnloadLibraryMap(libname);
3518 }
3519 }
3520
3521 std::ofstream mapfileStream( mapfilein, std::ios::out );
3522 {
3523 TString name = ".rootmap";
3524 TString sname = "system.rootmap";
3525 TString file;
3527 if (gSystem->AccessPathName(file)) {
3528 // for backward compatibility check also $ROOTSYS/system<name> if
3529 // $ROOTSYS/etc/system<name> does not exist
3531 if (gSystem->AccessPathName(file)) {
3532 // for backward compatibility check also $ROOTSYS/<name> if
3533 // $ROOTSYS/system<name> does not exist
3535 }
3536 }
3537 mapfileStream << file << std::endl;
3539 mapfileStream << file << std::endl;
3540 mapfileStream << name << std::endl;
3541 if (gInterpreter->GetRootMapFiles()) {
3542 for (i = 0; i < gInterpreter->GetRootMapFiles()->GetEntriesFast(); i++) {
3543 mapfileStream << ((TNamed*)gInterpreter->GetRootMapFiles()->At(i))->GetTitle() << std::endl;
3544 }
3545 }
3546 }
3547 mapfileStream.close();
3548
3549 // ======= Generate the rootcling command line
3550 TString rcling = "rootcling";
3552 rcling += " \"--lib-list-prefix=";
3553 rcling += mapfile;
3554 rcling += "\" -f \"";
3555 rcling.Append(dict).Append("\" ");
3556
3557 if (produceRootmap && !useCxxModules) {
3558 rcling += " -rml " + libname + " -rmf \"" + libmapfilename + "\" ";
3559 rcling.Append("-DR__ACLIC_ROOTMAP ");
3560 }
3561 rcling.Append(GetIncludePath()).Append(" -D__ACLIC__ ");
3562 if (gEnv) {
3563 TString fromConfig = gEnv->GetValue("ACLiC.IncludePaths","");
3564 rcling.Append(fromConfig);
3565 TString extraFlags = gEnv->GetValue("ACLiC.ExtraRootclingFlags","");
3566 if (!extraFlags.IsNull()) {
3567 extraFlags.Prepend(" ");
3568 extraFlags.Append(" ");
3569 rcling.Append(extraFlags);
3570 }
3571 }
3572
3573 // Create a modulemap
3574 // FIXME: Merge the modulemap generation from cmake and here in rootcling.
3576 rcling += " -cxxmodule ";
3577 // TString moduleMapFileName = file_dirname + "/" + libname + ".modulemap";
3578 TString moduleName = libname + "_ACLiC_dict";
3579 if (moduleName.BeginsWith("lib"))
3580 moduleName = moduleName.Remove(0, 3);
3581 TString moduleMapName = moduleName + ".modulemap";
3583 // A modulemap may exist from previous runs, overwrite it.
3585 ::Info("ACLiC", "File %s already exists!", moduleMapFullPath.Data());
3586
3589 std::ofstream moduleMapFile(moduleMapFullPath, std::ios::out);
3590 moduleMapFile << "module \"" << moduleName << "\" {" << std::endl;
3591 moduleMapFile << " header \"" << relative_path << "\"" << std::endl;
3592 moduleMapFile << " export *" << std::endl;
3593 moduleMapFile << " link \"" << libname_ext << "\"" << std::endl;
3594 moduleMapFile << "}" << std::endl;
3595 moduleMapFile.close();
3596 gInterpreter->RegisterPrebuiltModulePath(build_loc.Data(), moduleMapName.Data());
3597 rcling.Append(" \"-moduleMapFile=" + moduleMapFullPath + "\" ");
3598 }
3599
3600 rcling.Append(" \"").Append(filename_fullpath).Append("\" ");
3601 rcling.Append("\"").Append(linkdef).Append("\"");
3602
3603 // ======= Run rootcling
3604 if (withInfo) {
3605 if (verboseLevel>3) {
3606 ::Info("ACLiC","creating the dictionary files");
3607 if (verboseLevel>4) ::Info("ACLiC", "%s", rcling.Data());
3608 }
3609 }
3610
3611 ///\returns true on success.
3612 auto ExecAndReport = [](TString cmd) -> bool {
3614 if (result) {
3615 if (result == 139)
3616 ::Error("ACLiC", "Executing '%s' failed with a core dump!", cmd.Data());
3617 else
3618 ::Error("ACLiC", "Executing '%s' failed!", cmd.Data());
3619 }
3620 return !result;
3621 };
3622
3625
3626 // ======= Load the library the script might depend on
3627 if (result) {
3628 TString linkedlibs = GetLibraries("", "S");
3631 std::ifstream liblist(mapfileout);
3632
3633 while ( liblist >> libtoload ) {
3634 // Load the needed library except for the library we are currently building!
3635 if (libtoload == "#") {
3636 // The comment terminates the list of libraries.
3637 std::string toskipcomment;
3638 std::getline(liblist,toskipcomment);
3639 break;
3640 }
3642 if (produceRootmap) {
3643 if (loadLib || linkDepLibraries /* For GetLibraries to Work */) {
3644 result = gROOT->LoadClass("", libtoload) >= 0;
3645 if (!result) {
3646 // We failed to load one of the dependency.
3647 break;
3648 }
3649 }
3650 if (!linkedlibs.Contains(libtoload)) {
3651 all_libtoload.Append(" ").Append(libtoload);
3652 depLibraries.Append(" ");
3654 depLibraries = depLibraries.Strip(); // Remove any trailing spaces.
3655 }
3656 } else {
3657 gROOT->LoadClass("", libtoload);
3658 }
3659 }
3660 unsigned char c = liblist.peek();
3661 if (c=='\n' || c=='\r') {
3662 // Consume the character
3663 liblist.get();
3664 break;
3665 }
3666 }
3667
3668// depLibraries = all_libtoload;
3669// depLibraries.ReplaceAll(" lib"," -l");
3670// depLibraries.ReplaceAll(TString::Format(".%s",fSoExt.Data()),"");
3671 }
3672
3673 // ======= Calculate the libraries for linking:
3675 /*
3676 this is intentionally disabled until it can become useful
3677 if (gEnv) {
3678 linkLibraries = gEnv->GetValue("ACLiC.Libraries","");
3679 linkLibraries.Prepend(" ");
3680 }
3681 */
3683 // We need to enclose the single paths in quotes to account for paths with spaces
3687 std::unique_ptr<TObjArray> tokens( linkLibrariesNoQuotes.Tokenize(" ") );
3688 for (auto tokenObj : *tokens) {
3689 singleLibrary = ((TObjString*)tokenObj)->GetString();
3690 if (singleLibrary[0]=='-' || !AccessPathName(singleLibrary)) {
3692 librariesWithQuotes.Chop();
3693 librariesWithQuotes += "\" \"" + singleLibrary + "\"";
3695 } else {
3696 librariesWithQuotes += " \"" + singleLibrary + "\"";
3697 }
3698 } else {
3701 } else {
3703 librariesWithQuotes += " \"" + singleLibrary + " ";
3704 }
3705 }
3706 }
3707
3708#ifdef _MSC_VER
3710#else
3712#endif
3713
3714 // ======= Generate the build command lines
3716 // we do not add filename because it is already included via the dictionary(in dicth) !
3717 // dict.Append(" ").Append(filename);
3718 cmd.ReplaceAll("$SourceFiles","-D__ACLIC__ \"$SourceFiles\"");
3719 cmd.ReplaceAll("$SourceFiles",dict);
3720 cmd.ReplaceAll("$ObjectFiles","\"$ObjectFiles\"");
3721 cmd.ReplaceAll("$ObjectFiles",dictObj);
3722 cmd.ReplaceAll("$IncludePath",includes);
3723 cmd.ReplaceAll("$SharedLib","\"$SharedLib\"");
3724 cmd.ReplaceAll("$SharedLib",library);
3725 if (linkDepLibraries) {
3726 if (produceRootmap) {
3727 cmd.ReplaceAll("$DepLibs",depLibraries);
3728 } else {
3729 cmd.ReplaceAll("$DepLibs",linkLibraries);
3730 }
3731 }
3732 cmd.ReplaceAll("$LinkedLibs",linkLibraries);
3733 cmd.ReplaceAll("$LibName",libname);
3734 cmd.ReplaceAll("\"$BuildDir","$BuildDir");
3735 cmd.ReplaceAll("$BuildDir","\"$BuildDir\"");
3736 cmd.ReplaceAll("$BuildDir",build_loc);
3738 if (mode & kDebug)
3739 optdebFlags = fFlagsDebug + " ";
3740#ifdef WIN32
3741 else
3742#endif
3743 if (mode & kOpt)
3745 cmd.ReplaceAll("$Opt", optdebFlags);
3746#ifdef WIN32
3747 R__FixLink(cmd);
3748 cmd.ReplaceAll("-std=", "-std:");
3749 if (mode & kDebug) {
3750 cmd.ReplaceAll(" && link ", "&& link /DEBUG ");
3751 }
3752#endif
3753
3757 fakeMain += "_ACLiC_main";
3759 std::ofstream fakeMainFile( fakeMain, std::ios::out );
3760 fakeMainFile << "// File Automatically generated by the ROOT Script Compiler "
3761 << std::endl;
3762 fakeMainFile << "int main(char*argc,char**argvv) {};" << std::endl;
3763 fakeMainFile.close();
3764 // We could append this fake main routine to the compilation line.
3765 // But in this case compiler may output the name of the dictionary file
3766 // and of the fakeMain file while it compiles it. (this would be useless
3767 // confusing output).
3768 // We could also the fake main routine to the end of the dictionary file
3769 // however compilation would fail if a main is already there
3770 // (like stress.cxx)
3771 // dict.Append(" ").Append(fakeMain);
3772 TString exec;
3774 exec += "_ACLiC_exec";
3775 testcmd.ReplaceAll("$SourceFiles","-D__ACLIC__ \"$SourceFiles\"");
3776 testcmd.ReplaceAll("$SourceFiles",dict);
3777 testcmd.ReplaceAll("$ObjectFiles","\"$ObjectFiles\"");
3778 testcmd.ReplaceAll("$ObjectFiles",dictObj);
3779 testcmd.ReplaceAll("$IncludePath",includes);
3780 testcmd.ReplaceAll("$ExeName",exec);
3781 testcmd.ReplaceAll("$LinkedLibs",linkLibraries);
3782 testcmd.ReplaceAll("$BuildDir",build_loc);
3783 if (mode==kDebug)
3784 testcmd.ReplaceAll("$Opt",fFlagsDebug);
3785 else
3786 testcmd.ReplaceAll("$Opt",fFlagsOpt);
3787
3788#ifdef WIN32
3790 testcmd.ReplaceAll("-std=", "-std:");
3791#endif
3792
3793 // ======= Build the library
3794 if (result) {
3796#ifdef R__MACOSX
3797 // Allow linking to succeed despite the missing symbols.
3798 cmdAllowUnresolved.ReplaceAll("-dynamiclib", "-dynamiclib -Wl,-w -Wl,-undefined,dynamic_lookup");
3799#endif
3800 if (verboseLevel > 3 && withInfo) {
3801 ::Info("ACLiC","compiling the dictionary and script files");
3802 if (verboseLevel>4)
3803 ::Info("ACLiC", "%s", cmdAllowUnresolved.Data());
3804 }
3806 if (!success) {
3807 if (produceRootmap) {
3809 }
3810 }
3811 result = success;
3812 }
3813
3814 if ( result ) {
3815 if (linkDepLibraries) {
3816 // We may have unresolved symbols. Use dyld to resolve the dependent
3817 // libraries and relink.
3818 // FIXME: We will likely have duplicated libraries as we are appending
3819 // FIXME: This likely makes rootcling --lib-list-prefix redundant.
3821 std::function<bool(const char *)> CollectF = [&depLibsFullPaths](const char *dep) {
3823 if (!gSystem->FindDynamicLibrary(LibFullPath, /*quiet=*/true)) {
3824 ::Error("TSystem::CompileMacro", "Cannot find library '%s'", dep);
3825 return false; // abort
3826 }
3828 return true;
3829 };
3831
3834 if (verboseLevel > 3 && withInfo) {
3835 ::Info("ACLiC", "relinking against all dependencies");
3836 if (verboseLevel > 4)
3837 ::Info("ACLiC", "%s", relink_cmd.Data());
3838 }
3840 }
3841
3842 TNamed *k = new TNamed(library,library);
3844 gSystem->GetPathInfo( library, nullptr, (Long_t*)nullptr, nullptr, &lib_time );
3846 if (!keep) k->SetBit(kMustCleanup);
3847 fCompiled->Add(k);
3848
3849 if (needLoadMap) {
3850 gInterpreter->LoadLibraryMap(libmapfilename);
3851 }
3852 if (verboseLevel>3 && withInfo) ::Info("ACLiC","loading the shared library");
3853 if (loadLib)
3855 else
3856 result = kTRUE;
3857
3858 if ( !result ) {
3859 if (verboseLevel>3 && withInfo) {
3860 ::Info("ACLiC","testing for missing symbols:");
3861 if (verboseLevel>4) ::Info("ACLiC", "%s", testcmd.Data());
3862 }
3864 gSystem->Unlink( exec );
3865 }
3866
3867 };
3868
3869 if (verboseLevel<=5 && !internalDebug) {
3870 gSystem->Unlink( dict );
3871 gSystem->Unlink( dicth );
3877 gSystem->Unlink( exec );
3878 }
3879 if (verboseLevel>6) {
3880 rcling.Prepend("echo ");
3881 cmd.Prepend("echo \" ").Append(" \" ");
3882 testcmd.Prepend("echo \" ").Append(" \" ");
3884 gSystem->Exec( cmd );
3886 }
3887
3888 return result;
3889}
3890
3891////////////////////////////////////////////////////////////////////////////////
3892/// Return the ACLiC properties field. See EAclicProperties for details
3893/// on the semantic of each bit.
3894
3896{
3897 return fAclicProperties;
3898}
3899
3900////////////////////////////////////////////////////////////////////////////////
3901/// Return the build architecture.
3902
3903const char *TSystem::GetBuildArch() const
3904{
3905 return fBuildArch;
3906}
3907
3908////////////////////////////////////////////////////////////////////////////////
3909/// Return the build compiler
3910
3911const char *TSystem::GetBuildCompiler() const
3912{
3913 return fBuildCompiler;
3914}
3915
3916////////////////////////////////////////////////////////////////////////////////
3917/// Return the build compiler version
3918
3920{
3921 return fBuildCompilerVersion;
3922}
3923
3924////////////////////////////////////////////////////////////////////////////////
3925/// Return the build compiler version identifier string
3926
3928{
3930}
3931
3932////////////////////////////////////////////////////////////////////////////////
3933/// Return the build node name.
3934
3935const char *TSystem::GetBuildNode() const
3936{
3937 return fBuildNode;
3938}
3939
3940////////////////////////////////////////////////////////////////////////////////
3941/// Return the path of the build directory.
3942
3943const char *TSystem::GetBuildDir() const
3944{
3945 if (fBuildDir.Length()==0) {
3946 if (!gEnv) return "";
3947 const_cast<TSystem*>(this)->fBuildDir = gEnv->GetValue("ACLiC.BuildDir","");
3948 }
3949 return fBuildDir;
3950}
3951
3952////////////////////////////////////////////////////////////////////////////////
3953/// Return the debug flags.
3954
3955const char *TSystem::GetFlagsDebug() const
3956{
3957 return fFlagsDebug;
3958}
3959
3960////////////////////////////////////////////////////////////////////////////////
3961/// Return the optimization flags.
3962
3963const char *TSystem::GetFlagsOpt() const
3964{
3965 return fFlagsOpt;
3966}
3967
3968////////////////////////////////////////////////////////////////////////////////
3969/// AclicMode indicates whether the library should be built in
3970/// debug mode or optimized. The values are:
3971/// - TSystem::kDefault : compile the same as the current ROOT
3972/// - TSystem::kDebug : compiled in debug mode
3973/// - TSystem::kOpt : optimized the library
3974
3979
3980////////////////////////////////////////////////////////////////////////////////
3981/// Return the command line use to make a shared library.
3982/// See TSystem::CompileMacro for more details.
3983
3984const char *TSystem::GetMakeSharedLib() const
3985{
3986 return fMakeSharedLib;
3987}
3988
3989////////////////////////////////////////////////////////////////////////////////
3990/// Return the command line use to make an executable.
3991/// See TSystem::CompileMacro for more details.
3992
3993const char *TSystem::GetMakeExe() const
3994{
3995 return fMakeExe;
3996}
3997
3998////////////////////////////////////////////////////////////////////////////////
3999/// Get the list of include path.
4000
4002{
4004#ifndef _MSC_VER
4005 // FIXME: This is a temporary fix for the following error with ACLiC
4006 // (and this is apparently not needed anyway):
4007 // 48: input_line_12:8:38: error: use of undeclared identifier 'IC'
4008 // 48: "C:/Users/bellenot/build/debug/etc" -IC:/Users/bellenot/build/debug/etc//cling -IC:/Users/bellenot/build/debug/include"",
4009 // 48: ^
4010 // 48: Error in <ACLiC>: Dictionary generation failed!
4011 fListPaths.Append(" ").Append(gInterpreter->GetIncludePath());
4012#endif
4013 return fListPaths;
4014}
4015
4016////////////////////////////////////////////////////////////////////////////////
4017/// Return the list of library linked to this executable.
4018/// See TSystem::CompileMacro for more details.
4019
4020const char *TSystem::GetLinkedLibs() const
4021{
4022 return fLinkedLibs;
4023}
4024
4025////////////////////////////////////////////////////////////////////////////////
4026/// Return the linkdef suffix chosen by the user for ACLiC.
4027/// See TSystem::CompileMacro for more details.
4028
4029const char *TSystem::GetLinkdefSuffix() const
4030{
4031 if (fLinkdefSuffix.Length()==0) {
4032 if (!gEnv) return "_linkdef";
4033 const_cast<TSystem*>(this)->fLinkdefSuffix = gEnv->GetValue("ACLiC.Linkdef","_linkdef");
4034 }
4035 return fLinkdefSuffix;
4036}
4037
4038////////////////////////////////////////////////////////////////////////////////
4039/// Get the shared library extension.
4040
4041const char *TSystem::GetSoExt() const
4042{
4043 return fSoExt;
4044}
4045
4046////////////////////////////////////////////////////////////////////////////////
4047/// Get the object file extension.
4048
4049const char *TSystem::GetObjExt() const
4050{
4051 return fObjExt;
4052}
4053
4054////////////////////////////////////////////////////////////////////////////////
4055/// Set the location where ACLiC will create libraries and use as
4056/// a scratch area. If unset, libraries will be created at the same
4057/// location than the script.
4058///
4059/// \param build_dir the name of the build directory
4060/// \param isflat If false (default), then the libraries are actually stored
4061/// in sub-directories of 'build_dir' including the full pathname
4062/// of the script. If the script is located at `/full/path/name/macro.C`
4063/// the library will be located at `build_dir+/full/path/name/macro_C.so`
4064/// If 'isflat' is true, then no subdirectory is created and the library
4065/// is created directly in the directory 'build_dir'. Note that in this
4066/// mode there is a risk than 2 script of the same in different source
4067/// directory will over-write each other.
4068/// \note This `build_dir` can also be controlled via `ACLiC.BuildDir` in
4069/// your `.rootrc`.
4070
4072{
4074 if (isflat)
4076 else
4078}
4079
4080////////////////////////////////////////////////////////////////////////////////
4081/// FlagsDebug should contain the options to pass to the C++ compiler
4082/// in order to compile the library in debug mode.
4083
4084void TSystem::SetFlagsDebug(const char *flags)
4085{
4086 fFlagsDebug = flags;
4087}
4088
4089////////////////////////////////////////////////////////////////////////////////
4090/// FlagsOpt should contain the options to pass to the C++ compiler
4091/// in order to compile the library in optimized mode.
4092
4093void TSystem::SetFlagsOpt(const char *flags)
4094{
4095 fFlagsOpt = flags;
4096}
4097
4098////////////////////////////////////////////////////////////////////////////////
4099/// AclicMode indicates whether the library should be built in
4100/// debug mode or optimized. The values are:
4101/// - TSystem::kDefault : compile the same as the current ROOT
4102/// - TSystem::kDebug : compiled in debug mode
4103/// - TSystem::kOpt : optimized the library
4104
4109
4110////////////////////////////////////////////////////////////////////////////////
4111/// Directives has the same syntax as the argument of SetMakeSharedLib but is
4112/// used to create an executable. This creation is used as a means to output
4113/// a list of unresolved symbols, when loading a shared library has failed.
4114/// The required variable is $ExeName rather than $SharedLib, e.g.:
4115/// ~~~ {.cpp}
4116/// gSystem->SetMakeExe(
4117/// "g++ -Wall -fPIC $IncludePath $SourceFiles
4118/// -o $ExeName $LinkedLibs -L/usr/X11R6/lib -lX11 -lm -ldl -rdynamic");
4119/// ~~~
4120
4122{
4124 // NOTE: add verification that the directives has the required variables
4125}
4126
4127////////////////////////////////////////////////////////////////////////////////
4128/// Directives should contain the description on how to compile and link a
4129/// shared lib. This description can be any valid shell command, including
4130/// the use of ';' to separate several instructions. However, shell specific
4131/// construct should be avoided. In particular this description can contain
4132/// environment variables, like $ROOTSYS (or %ROOTSYS% on windows).
4133/// ~~~ {.cpp}
4134/// Five special variables will be expanded before execution:
4135/// Variable name Expands to
4136/// ------------- ----------
4137/// $SourceFiles Name of source files to be compiled
4138/// $SharedLib Name of the shared library being created
4139/// $LibName Name of shared library without extension
4140/// $BuildDir Directory where the files will be created
4141/// $IncludePath value of fIncludePath
4142/// $LinkedLibs value of fLinkedLibs
4143/// $DepLibs libraries on which this library depends on
4144/// $ObjectFiles Name of source files to be compiler with
4145/// their extension changed to .o or .obj
4146/// $Opt location of the optimization/debug options
4147/// set fFlagsDebug and fFlagsOpt
4148/// ~~~
4149/// e.g.:
4150/// ~~~ {.cpp}
4151/// gSystem->SetMakeSharedLib(
4152/// "KCC -n32 --strict $IncludePath -K0 \$Opt $SourceFile
4153/// --no_exceptions --signed_chars --display_error_number
4154/// --diag_suppress 68 -o $SharedLib");
4155///
4156/// gSystem->setMakeSharedLib(
4157/// "Cxx $IncludePath -c $SourceFile;
4158/// ld -L/usr/lib/cmplrs/cxx -rpath /usr/lib/cmplrs/cxx -expect_unresolved
4159/// \$Opt -shared /usr/lib/cmplrs/cc/crt0.o /usr/lib/cmplrs/cxx/_main.o
4160/// -o $SharedLib $ObjectFile -lcxxstd -lcxx -lexc -lots -lc"
4161///
4162/// gSystem->SetMakeSharedLib(
4163/// "$HOME/mygcc/bin/g++ \$Opt -Wall -fPIC $IncludePath $SourceFile
4164/// -shared -o $SharedLib");
4165///
4166/// gSystem->SetMakeSharedLib(
4167/// "cl -DWIN32 -D_WIN32 -D_MT -D_DLL -MD /O2 /G5 /MD -DWIN32
4168/// -D_WINDOWS $IncludePath $SourceFile
4169/// /link -PDB:NONE /NODEFAULTLIB /INCREMENTAL:NO /RELEASE /NOLOGO
4170/// $LinkedLibs -entry:_DllMainCRTStartup@12 -dll /out:$SharedLib")
4171/// ~~~
4172
4174{
4176 // NOTE: add verification that the directives has the required variables
4177}
4178
4179////////////////////////////////////////////////////////////////////////////////
4180/// \brief Add a directory to the already set include path.
4181/// \param[in] includePath The path to the directory.
4182/// \note This interface is mostly relevant for ACLiC and it does *not* inform
4183/// gInterpreter for this include path. If the TInterpreter needs to know
4184/// about the include path please use TInterpreter::AddIncludePath() .
4185/// \warning The path should start with the \c -I prefix, i.e.
4186/// <tt>gSystem->AddIncludePath("-I /path/to/my/includes")</tt>.
4188{
4189 if (includePath) {
4190 fIncludePath += " ";
4192 }
4193}
4194
4195////////////////////////////////////////////////////////////////////////////////
4196/// Add linkedLib to already set linked libs.
4197
4199{
4200 if (linkedLib) {
4201 fLinkedLibs += " ";
4203 }
4204}
4205
4206////////////////////////////////////////////////////////////////////////////////
4207/// IncludePath should contain the list of compiler flags to indicate where
4208/// to find user defined header files. It is used to expand $IncludePath in
4209/// the directives given to SetMakeSharedLib() and SetMakeExe(), e.g.:
4210/// ~~~ {.cpp}
4211/// gSystem->SetInclude("-I$ROOTSYS/include -Imydirectory/include");
4212/// ~~~
4213/// the default value of IncludePath on Unix is:
4214/// ~~~ {.cpp}
4215/// "-I$ROOTSYS/include "
4216/// ~~~
4217/// and on Windows:
4218/// ~~~ {.cpp}
4219/// "/I%ROOTSYS%/include "
4220/// ~~~
4221
4223{
4225}
4226
4227////////////////////////////////////////////////////////////////////////////////
4228/// LinkedLibs should contain the library directory and list of libraries
4229/// needed to recreate the current executable. It is used to expand $LinkedLibs
4230/// in the directives given to SetMakeSharedLib() and SetMakeExe()
4231/// The default value on Unix is: `root-config --glibs`
4232
4234{
4236}
4237
4238////////////////////////////////////////////////////////////////////////////////
4239/// The 'suffix' will be appended to the name of a script loaded by ACLiC
4240/// and used to locate any eventual additional linkdef information that
4241/// ACLiC should used to produce the dictionary.
4242///
4243/// So by default, when doing .L MyScript.cxx, ACLiC will look
4244/// for a file name MyScript_linkdef and having one of the .h (.hpp,
4245/// etc.) extensions. If such a file exist, it will be added to
4246/// the end of the linkdef file used to created the ACLiC dictionary.
4247/// This effectively enable the full customization of the creation
4248/// of the dictionary. It should be noted that the file is intended
4249/// as a linkdef `fragment`, so usually you would not list the
4250/// typical:
4251/// ~~~ {.cpp}
4252/// #pragma link off ....
4253/// ~~~
4254
4256{
4258}
4259
4260
4261////////////////////////////////////////////////////////////////////////////////
4262/// Set shared library extension, should be either .so, .sl, .a, .dll, etc.
4263
4264void TSystem::SetSoExt(const char *SoExt)
4265{
4266 fSoExt = SoExt;
4267}
4268
4269////////////////////////////////////////////////////////////////////////////////
4270/// Set object files extension, should be either .o, .obj, etc.
4271
4273{
4274 fObjExt = ObjExt;
4275}
4276
4277////////////////////////////////////////////////////////////////////////////////
4278/// This method split a filename of the form:
4279/// ~~~ {.cpp}
4280/// [path/]macro.C[+|++[k|f|g|O|c|s|d|v|-]][(args)].
4281/// ~~~
4282/// It stores the ACliC mode [+|++[options]] in 'mode',
4283/// the arguments (including parenthesis) in arg
4284/// and the I/O indirection in io
4285
4287 TString &arguments, TString &io) const
4288{
4289 char *fname = Strip(filename);
4291 filenameCopy = filenameCopy.Strip();
4292
4293 if (filenameCopy.EndsWith(";")) {
4294 filenameCopy.Remove(filenameCopy.Length() - 1);
4295 filenameCopy = filenameCopy.Strip();
4296 }
4297 if (filenameCopy.EndsWith(")")) {
4298 Ssiz_t posArgEnd = filenameCopy.Length() - 1;
4299 // There is an argument; find its start!
4300 int parenNestCount = 1;
4301 bool inString = false;
4303 for (; parenNestCount && posArgBegin >= 0; --posArgBegin) {
4304 // Escaped if the previous character is a `\` - but not if it
4305 // itself is preceded by a `\`!
4306 if (posArgBegin > 0 && filenameCopy[posArgBegin] == '\\' &&
4307 (posArgBegin == 1 || filenameCopy[posArgBegin - 1] != '\\')) {
4308 // skip escape.
4309 --posArgBegin;
4310 continue;
4311 }
4312 switch (filenameCopy[posArgBegin]) {
4313 case ')':
4314 if (!inString)
4316 break;
4317 case '(':
4318 if (!inString)
4320 break;
4321 case '"': inString = !inString; break;
4322 }
4323 }
4324 if (parenNestCount || inString) {
4325 Error("SplitAclicMode", "Cannot parse argument in %s", filename);
4326 } else {
4327 arguments = filenameCopy(posArgBegin + 1, posArgEnd - 1);
4328 fname[posArgBegin + 1] = 0;
4329 }
4330 }
4331
4332 // strip off I/O redirect tokens from filename
4333 {
4334 char *s2 = nullptr;
4335 char *s3;
4336 s2 = strstr(fname, ">>");
4337 if (!s2) s2 = strstr(fname, "2>");
4338 if (!s2) s2 = strchr(fname, '>');
4339 s3 = strchr(fname, '<');
4340 if (s2 && s3) s2 = s2<s3 ? s2 : s3;
4341 if (s3 && !s2) s2 = s3;
4342 if (s2==fname) {
4343 io = fname;
4344 aclicMode = "";
4345 arguments = "";
4346 delete []fname;
4347 return "";
4348 } else if (s2) {
4349 if (s2 > fname) {
4350 // Skip/trim spaces
4351 s2--;
4352 while (s2 > fname && *s2 == ' ') s2--;
4353 s2++;
4354 }
4355 io = s2; // ssave = *s2;
4356 *s2 = 0;
4357 } else
4358 io = "";
4359 }
4360
4361 // remove the possible ACLiC + or ++ and g or O etc
4362 aclicMode.Clear();
4363 int len = strlen(fname);
4364 TString mode;
4365 while (len > 1) {
4366 if (strchr("kfgOcsdv-", fname[len - 1])) {
4367 mode += fname[len - 1];
4368 --len;
4369 } else {
4370 break;
4371 }
4372 }
4373 Bool_t compile = len && fname[len - 1] == '+';
4374 Bool_t remove = compile && len > 1 && fname[len - 2] == '+';
4375 if (compile) {
4376 if (mode.Length()) {
4377 fname[len] = 0;
4378 }
4379 if (remove) {
4380 fname[strlen(fname)-2] = 0;
4381 aclicMode = "++";
4382 } else {
4383 fname[strlen(fname)-1] = 0;
4384 aclicMode = "+";
4385 }
4386 if (mode.Length())
4387 aclicMode += mode;
4388 }
4389
4391
4392 delete []fname;
4393 return resFilename;
4394}
4395
4396////////////////////////////////////////////////////////////////////////////////
4397/// Remove the shared libs produced by the CompileMacro() function, together
4398/// with their rootmaps, linkdefs, and pcms (and some more on Windows).
4399
4401{
4402 TIter next(fCompiled);
4403 TNamed *lib;
4404 const char *extensions[] = {".lib", ".exp", ".d", ".def", ".rootmap", "_ACLiC_linkdef.h", "_ACLiC_dict_rdict.pcm"};
4405 while ((lib = (TNamed*)next())) {
4406 if (lib->TestBit(kMustCleanup)) {
4407 TString libname = lib->GetTitle();
4408#ifdef WIN32
4409 // On Windows, we need to unload the dll before deleting it
4410 if (gInterpreter->IsLibraryLoaded(libname))
4412#endif
4413 Unlink(libname);
4414 TString target, soExt = "." + fSoExt;
4415 libname.ReplaceAll(soExt, "");
4416 for (const char *ext : extensions) {
4417 target = libname + ext;
4418 Unlink(target);
4419 }
4420 }
4421 }
4422}
4423
4424////////////////////////////////////////////////////////////////////////////////
4425/// Register version of plugin library.
4426
The file contains utilities which are foundational and could be used across the core component of ROO...
#define SafeDelete(p)
Definition RConfig.hxx:533
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
#define ROOT_RELEASE
Definition RVersion.hxx:44
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
constexpr Int_t kMaxInt
Definition RtypesCore.h:119
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:68
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:131
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:83
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
@ kMAXPATHLEN
Definition Rtypes.h:61
R__EXTERN TApplication * gApplication
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Definition TError.cxx:241
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:252
#define ENDTRY
Definition TException.h:64
#define RETRY
Definition TException.h:44
winID h TVirtualViewer3D TVirtualGLPainter p
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 filename
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 target
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 r
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 result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
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 mode
char name[80]
Definition TGX11.cxx:110
#define gInterpreter
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
Definition TROOT.cxx:627
#define gROOT
Definition TROOT.h:411
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2495
char * Strip(const char *str, char c=' ')
Strip leading and trailing c (blanks by default) from a string.
Definition TString.cxx:2527
char * StrDup(const char *str)
Duplicate the string str.
Definition TString.cxx:2563
ESignals
@ kSigInterrupt
TSystem * gSystem
Definition TSystem.cxx:68
static Int_t gLibraryVersionIdx
Definition TSystem.cxx:72
TVirtualMutex * gSystemMutex
Definition TSystem.cxx:109
void AssignAndDelete(TString &target, char *tobedeleted)
Definition TSystem.cxx:2512
static void R__WriteDependencyFile(const TString &build_loc, const TString &depfilename, const TString &filename, const TString &library, const TString &libname, const TString &extension, const char *version_var_prefix, const TString &includes, const TString &defines, const TString &incPath)
Definition TSystem.cxx:2584
static bool R__MatchFilename(const char *left, const char *right)
Figure out if left and right points to the same object in the file system.
Definition TSystem.cxx:1831
static void R__AddPath(TString &target, const TString &path)
Definition TSystem.cxx:2579
static Int_t * gLibraryVersion
Definition TSystem.cxx:71
const char * gRootDir
Definition TSystem.cxx:64
static Int_t gLibraryVersionMax
Definition TSystem.cxx:73
TFileHandler * gXDisplay
Definition TSystem.cxx:69
const char * gProgPath
Definition TSystem.cxx:66
const char * gProgName
Definition TSystem.cxx:65
R__EXTERN const char * gProgName
Definition TSystem.h:252
R__EXTERN TVirtualMutex * gSystemMutex
Definition TSystem.h:254
void(* Func_t)()
Definition TSystem.h:249
EAccessMode
Definition TSystem.h:51
@ kFileExists
Definition TSystem.h:52
@ kReadPermission
Definition TSystem.h:55
@ kWritePermission
Definition TSystem.h:54
Bool_t R_ISREG(Int_t mode)
Definition TSystem.h:126
ELogFacility
Definition TSystem.h:74
ESocketBindOption
Options for binging the sockets created.
Definition TSystem.h:46
ELogLevel
Definition TSystem.h:63
Bool_t R_ISDIR(Int_t mode)
Definition TSystem.h:123
R__EXTERN TSystem * gSystem
Definition TSystem.h:572
@ kS_IXOTH
Definition TSystem.h:120
@ kS_IXUSR
Definition TSystem.h:112
@ kS_IXGRP
Definition TSystem.h:116
#define R__LOCKGUARD2(mutex)
#define R__WRITE_LOCKGUARD(mutex)
#define R__READ_LOCKGUARD(mutex)
const char * proto
Definition civetweb.c:18822
const char * extension
Definition civetweb.c:8515
#define snprintf
Definition civetweb.c:1579
const_iterator begin() const
const_iterator end() const
virtual void StopIdleing()
Called when system stops idleing.
virtual void StartIdleing()
Called when system starts idleing.
virtual TObject * Remove(TObject *obj)=0
virtual bool UseRWLock(Bool_t enable=true)
Set this collection to use a RW lock upon access, making it thread safe.
TObject * FindObject(const char *name) const override
Find an object in this collection using its name.
void Delete(Option_t *option="") override=0
Delete this object.
Definition TEnv.h:86
The TEnv class reads config files, by default named .rootrc.
Definition TEnv.h:124
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:505
This class represents an Internet Protocol (IP) address.
Iterator of linked list.
Definition TList.h:191
TObject * Next() override
Return next object in the list. Returns 0 when no more objects in list.
Definition TList.cxx:1110
A doubly linked list.
Definition TList.h:38
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
Definition TList.cxx:575
void Add(TObject *obj) override
Definition TList.h:81
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:819
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:467
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
TNamed()
Definition TNamed.h:38
TString fName
Definition TNamed.h:32
An array of TObjects.
Definition TObjArray.h:31
Collectable string class.
Definition TObjString.h:28
Mother of all ROOT objects.
Definition TObject.h:41
void AbstractMethod(const char *method) const
Call this function within a function that you don't want to define as purely virtual,...
Definition TObject.cxx:1122
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:202
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
Definition TObject.cxx:1085
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1057
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:864
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1071
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
Definition TObject.cxx:875
@ kInvalidObject
if object ctor succeeded but object should not be used
Definition TObject.h:78
@ kMustCleanup
if object destructor must call RecursiveRemove()
Definition TObject.h:70
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:1045
Ordered collection.
TProcessEventTimer(Long_t delay)
Create async event processor timer. Delay is in milliseconds.
Definition TSystem.cxx:81
Bool_t ProcessEvents()
Process events if timer did time out.
Definition TSystem.cxx:92
static const TString & GetBinDir()
Get the binary directory in the installation. Static utility function.
Definition TROOT.cxx:2998
static const TString & GetIncludeDir()
Get the include directory in the installation. Static utility function.
Definition TROOT.cxx:3197
static Int_t ConvertVersionCode2Int(Int_t code)
Convert version code to an integer, i.e. 331527 -> 51507.
Definition TROOT.cxx:2931
static const TString & GetRootSys()
Get the rootsys directory in the installation. Static utility function.
Definition TROOT.cxx:2988
static Int_t RootVersionCode()
Return ROOT version code as defined in RVersion.h.
Definition TROOT.cxx:2950
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
Definition TROOT.cxx:3207
static const TString & GetLibDir()
Get the library directory in the installation.
Definition TROOT.cxx:3026
Regular expression class.
Definition TRegexp.h:31
void Add(TObject *obj) override
static Int_t * ReAllocInt(Int_t *vp, size_t size, size_t oldsize)
Reallocate (i.e.
Definition TStorage.cxx:257
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
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition TString.cxx:2250
void Clear()
Clear string without changing its capacity.
Definition TString.cxx:1241
Ssiz_t First(char c) const
Find first occurrence of a character c.
Definition TString.cxx:545
const char * Data() const
Definition TString.h:384
TString & Chop()
Definition TString.h:700
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:713
@ kTrailing
Definition TString.h:284
@ kBoth
Definition TString.h:284
@ kIgnoreCase
Definition TString.h:285
@ kExact
Definition TString.h:285
Ssiz_t Last(char c) const
Find last occurrence of a character c.
Definition TString.cxx:938
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition TString.h:632
TString & Prepend(const char *cs)
Definition TString.h:682
Bool_t IsNull() const
Definition TString.h:422
TString & Remove(Ssiz_t pos)
Definition TString.h:694
TString & Append(const char *cs)
Definition TString.h:581
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
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:641
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:660
Abstract base class defining a generic interface to the underlying Operating System.
Definition TSystem.h:276
TString fListPaths
Definition TSystem.h:320
virtual void NotifyApplicationCreated()
Hook to tell TSystem that the TApplication object has been created.
Definition TSystem.cxx:313
virtual const char * GetBuildNode() const
Return the build node name.
Definition TSystem.cxx:3935
virtual int Umask(Int_t mask)
Set the process file creation mode mask.
Definition TSystem.cxx:1532
virtual int SendBuf(int sock, const void *buffer, int length)
Send a buffer headed by a length indicator.
Definition TSystem.cxx:2442
virtual int GetServiceByName(const char *service)
Get port # of internet service.
Definition TSystem.cxx:2333
virtual Bool_t IsFileInIncludePath(const char *name, char **fullpath=nullptr)
Return true if 'name' is a file that can be found in the ROOT include path or the current directory.
Definition TSystem.cxx:980
virtual void Unload(const char *module)
Unload a shared library.
Definition TSystem.cxx:2067
virtual FILE * TempFileName(TString &base, const char *dir=nullptr, const char *suffix=nullptr)
Create a secure temporary file by appending a unique 6 letter string to base.
Definition TSystem.cxx:1514
virtual const char * GetMakeSharedLib() const
Return the command line use to make a shared library.
Definition TSystem.cxx:3984
Bool_t fInControl
Definition TSystem.h:300
TSeqCollection * fFileHandler
Definition TSystem.h:306
Int_t fAclicProperties
Definition TSystem.h:329
Int_t fMaxrfd
Definition TSystem.h:291
virtual void AddFileHandler(TFileHandler *fh)
Add a file handler to the list of system file handlers.
Definition TSystem.cxx:556
TString & GetLastErrorString()
Return the thread local storage for the custom last error message.
Definition TSystem.cxx:2117
virtual void AddLinkedLibs(const char *linkedLib)
Add linkedLib to already set linked libs.
Definition TSystem.cxx:4198
virtual Int_t RedirectOutput(const char *name, const char *mode="a", RedirectHandle_t *h=nullptr)
Redirect standard output (stdout, stderr) to the specified file.
Definition TSystem.cxx:1730
virtual const char * GetBuildCompilerVersion() const
Return the build compiler version.
Definition TSystem.cxx:3919
virtual void ResetSignal(ESignals sig, Bool_t reset=kTRUE)
If reset is true reset the signal handler for the specified signal to the default handler,...
Definition TSystem.cxx:578
virtual TInetAddress GetSockName(int sock)
Get Internet Protocol (IP) address of host and port #.
Definition TSystem.cxx:2324
virtual int GetFsInfo(const char *path, Long_t *id, Long_t *bsize, Long_t *blocks, Long_t *bfree)
Get info about a file system: fs type, block size, number of blocks, number of free blocks.
Definition TSystem.cxx:1487
virtual Func_t DynFindSymbol(const char *module, const char *entry)
Find specific entry point in specified library.
Definition TSystem.cxx:2059
virtual const char * GetLinkedLibs() const
Return the list of library linked to this executable.
Definition TSystem.cxx:4020
void Beep(Int_t freq=-1, Int_t duration=-1, Bool_t setDefault=kFALSE)
Beep for duration milliseconds with a tone of frequency freq.
Definition TSystem.cxx:326
Int_t fBeepDuration
Definition TSystem.h:298
virtual void IgnoreInterrupt(Bool_t ignore=kTRUE)
If ignore is true ignore the interrupt signal, else restore previous behaviour.
Definition TSystem.cxx:604
virtual void Syslog(ELogLevel level, const char *mess)
Send mess to syslog daemon.
Definition TSystem.cxx:1701
virtual int Symlink(const char *from, const char *to)
Create a symbolic link from file1 to file2.
Definition TSystem.cxx:1383
virtual void SetAclicMode(EAclicMode mode)
AclicMode indicates whether the library should be built in debug mode or optimized.
Definition TSystem.cxx:4105
static void ResetErrno()
Static function resetting system error number.
Definition TSystem.cxx:286
virtual UInt_t LoadAllLibraries()
Load all libraries known to ROOT via the rootmap system.
Definition TSystem.cxx:1985
virtual void * GetDirPtr() const
Definition TSystem.h:426
virtual void SetObjExt(const char *objExt)
Set object files extension, should be either .o, .obj, etc.
Definition TSystem.cxx:4272
virtual void SetLinkdefSuffix(const char *suffix)
The 'suffix' will be appended to the name of a script loaded by ACLiC and used to locate any eventual...
Definition TSystem.cxx:4255
TSeqCollection * fHelpers
Definition TSystem.h:331
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1289
virtual const char * GetBuildDir() const
Return the path of the build directory.
Definition TSystem.cxx:3943
virtual void Openlog(const char *name, Int_t options, ELogFacility facility)
Open connection to system log daemon.
Definition TSystem.cxx:1692
static Int_t GetErrno()
Static function returning system error number.
Definition TSystem.cxx:278
virtual void AddIncludePath(const char *includePath)
Add a directory to the already set include path.
Definition TSystem.cxx:4187
virtual int Chmod(const char *file, UInt_t mode)
Set the file permission bits. Returns -1 in case or error, 0 otherwise.
Definition TSystem.cxx:1523
virtual Int_t GetEffectiveGid()
Returns the effective group id.
Definition TSystem.cxx:1606
@ kDefault
Definition TSystem.h:279
@ kDebug
Definition TSystem.h:279
virtual ~TSystem()
Delete the OS interface.
Definition TSystem.cxx:138
virtual void SetDisplay()
Set DISPLAY environment variable based on utmp entry. Only for UNIX.
Definition TSystem.cxx:234
virtual const char * DirName(const char *pathname)
Return the directory name in pathname.
Definition TSystem.cxx:1020
virtual void FreeDirectory(void *dirp)
Free a directory.
Definition TSystem.cxx:859
virtual void SetFlagsOpt(const char *)
FlagsOpt should contain the options to pass to the C++ compiler in order to compile the library in op...
Definition TSystem.cxx:4093
void RemoveOnExit(TObject *obj)
Objects that should be deleted on exit of the OS interface.
Definition TSystem.cxx:294
TSeqCollection * fStdExceptionHandler
Definition TSystem.h:307
virtual char * GetServiceByPort(int port)
Get name of internet service.
Definition TSystem.cxx:2342
virtual void * OpenDirectory(const char *name)
Open a directory.
Definition TSystem.cxx:850
virtual int GetPid()
Get process id.
Definition TSystem.cxx:720
virtual int RecvBuf(int sock, void *buffer, int length)
Receive a buffer headed by a length indicator.
Definition TSystem.cxx:2433
virtual int CopyFile(const char *from, const char *to, Bool_t overwrite=kFALSE)
Copy a file.
Definition TSystem.cxx:1356
virtual Long_t NextTimeOut(Bool_t mode)
Time when next timer of mode (synchronous=kTRUE or asynchronous=kFALSE) will time-out (in ms).
Definition TSystem.cxx:496
virtual int SetSockOpt(int sock, int kind, int val)
Set socket option.
Definition TSystem.cxx:2451
virtual const char * Getenv(const char *env)
Get environment variable.
Definition TSystem.cxx:1680
virtual TStdExceptionHandler * RemoveStdExceptionHandler(TStdExceptionHandler *eh)
Remove an exception handler from list of exception handlers.
Definition TSystem.cxx:623
virtual const char * GetIncludePath()
Get the list of include path.
Definition TSystem.cxx:4001
virtual int AcceptConnection(int sock)
Accept a connection.
Definition TSystem.cxx:2396
virtual Int_t GetAclicProperties() const
Return the ACLiC properties field.
Definition TSystem.cxx:3895
virtual TString SplitAclicMode(const char *filename, TString &mode, TString &args, TString &io) const
This method split a filename of the form:
Definition TSystem.cxx:4286
TString fListLibs
Definition TSystem.h:310
virtual void ShowOutput(RedirectHandle_t *h)
Display the content associated with the redirection described by the opaque handle 'h'.
Definition TSystem.cxx:1740
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name.
Definition TSystem.cxx:1086
virtual UserGroup_t * GetGroupInfo(Int_t gid)
Returns all group info in the UserGroup_t structure.
Definition TSystem.cxx:1640
virtual void CleanCompiledMacros()
Remove the shared libs produced by the CompileMacro() function, together with their rootmaps,...
Definition TSystem.cxx:4400
virtual Bool_t IsPathLocal(const char *path)
Returns TRUE if the url in 'path' points to the local file system.
Definition TSystem.cxx:1320
TString fMakeExe
Definition TSystem.h:327
virtual const char * FindFile(const char *search, TString &file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Definition TSystem.cxx:1553
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
Make a file system directory.
Definition TSystem.cxx:920
virtual int MakeDirectory(const char *name)
Make a directory.
Definition TSystem.cxx:840
TString fBuildCompilerVersionStr
Definition TSystem.h:315
virtual const char * ExpandFileName(const char *fname)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1113
TSystem(const TSystem &)=delete
EAclicMode fAclicMode
Definition TSystem.h:325
virtual TInetAddress GetPeerName(int sock)
Get Internet Protocol (IP) address of remote host and port #.
Definition TSystem.cxx:2315
virtual TTime Now()
Get current time in milliseconds since 0:00 Jan 1 1995.
Definition TSystem.cxx:465
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition TSystem.cxx:655
virtual int GetSysInfo(SysInfo_t *info) const
Returns static system info, like OS type, CPU type, number of CPUs RAM size, etc into the SysInfo_t s...
Definition TSystem.cxx:2473
TString fFlagsOpt
Definition TSystem.h:319
virtual int GetMemInfo(MemInfo_t *info) const
Returns ram and swap memory usage info into the MemInfo_t structure.
Definition TSystem.cxx:2494
virtual EAclicMode GetAclicMode() const
AclicMode indicates whether the library should be built in debug mode or optimized.
Definition TSystem.cxx:3975
virtual const char * GetLinkedLibraries()
Get list of shared libraries loaded at the start of the executable.
Definition TSystem.cxx:2135
virtual void SetIncludePath(const char *includePath)
IncludePath should contain the list of compiler flags to indicate where to find user defined header f...
Definition TSystem.cxx:4222
virtual TFileHandler * RemoveFileHandler(TFileHandler *fh)
Remove a file handler from the list of file handlers.
Definition TSystem.cxx:566
TString fLinkedLibs
Definition TSystem.h:322
Int_t fSigcnt
Definition TSystem.h:293
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition TSystem.cxx:1872
virtual void ListSymbols(const char *module, const char *re="")
List symbols in a shared library.
Definition TSystem.cxx:2079
virtual void DoBeep(Int_t=-1, Int_t=-1) const
Definition TSystem.h:342
TString fObjExt
Definition TSystem.h:324
TString fLinkdefSuffix
Definition TSystem.h:328
Int_t fBeepFreq
Definition TSystem.h:297
virtual int GetCpuInfo(CpuInfo_t *info, Int_t sampleTime=1000) const
Returns cpu load average and load info into the CpuInfo_t structure.
Definition TSystem.cxx:2484
@ kFlatBuildDir
Definition TSystem.h:281
virtual void ListLibraries(const char *regexp="")
List the loaded shared libraries.
Definition TSystem.cxx:2100
virtual FILE * OpenPipe(const char *command, const char *mode)
Open a pipe.
Definition TSystem.cxx:664
virtual void SetMakeSharedLib(const char *directives)
Directives should contain the description on how to compile and link a shared lib.
Definition TSystem.cxx:4173
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
Definition TSystem.cxx:1413
virtual void InnerLoop()
Inner event loop.
Definition TSystem.cxx:402
virtual const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
Definition TSystem.cxx:1096
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Definition TSystem.cxx:1311
virtual int OpenConnection(const char *server, int port, int tcpwindowsize=-1, const char *protocol="tcp")
Open a connection to another host.
Definition TSystem.cxx:2351
virtual const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
Definition TSystem.cxx:867
virtual void IgnoreSignal(ESignals sig, Bool_t ignore=kTRUE)
If ignore is true ignore the specified signal, else restore previous behaviour.
Definition TSystem.cxx:595
virtual void Run()
System event loop.
Definition TSystem.cxx:345
virtual int GetSockOpt(int sock, int kind, int *val)
Get socket option.
Definition TSystem.cxx:2460
virtual void ExitLoop()
Exit from event loop.
Definition TSystem.cxx:394
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
Definition TSystem.cxx:876
virtual std::string GetHomeDirectory(const char *userName=nullptr) const
Return the user's home directory.
Definition TSystem.cxx:909
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition TSystem.cxx:1077
virtual int RecvRaw(int sock, void *buffer, int length, int flag)
Receive exactly length bytes into buffer.
Definition TSystem.cxx:2414
virtual Bool_t Init()
Initialize the OS interface.
Definition TSystem.cxx:182
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
Definition TSystem.cxx:473
virtual int GetProcInfo(ProcInfo_t *info) const
Returns cpu and memory used by this process into the ProcInfo_t structure.
Definition TSystem.cxx:2504
virtual const char * GetBuildCompilerVersionStr() const
Return the build compiler version identifier string.
Definition TSystem.cxx:3927
static Int_t GetCryptoRandom(void *buf, Int_t len)
Return cryptographic random number Fill provided buffer with random values.
Definition TSystem.cxx:265
virtual void DispatchOneEvent(Bool_t pendingOnly=kFALSE)
Dispatch a single event.
Definition TSystem.cxx:431
virtual int Rename(const char *from, const char *to)
Rename a file.
Definition TSystem.cxx:1365
virtual int ClosePipe(FILE *pipe)
Close the pipe.
Definition TSystem.cxx:673
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
Definition TSystem.cxx:948
TString fBuildArch
Definition TSystem.h:312
virtual void AddSignalHandler(TSignalHandler *sh)
Add a signal handler to list of system signal handlers.
Definition TSystem.cxx:534
virtual const char * GetDynamicPath()
Return the dynamic path (used to find shared libraries).
Definition TSystem.cxx:1810
TSeqCollection * fSignalHandler
Definition TSystem.h:305
virtual const char * GetMakeExe() const
Return the command line use to make an executable.
Definition TSystem.cxx:3993
virtual const char * FindDynamicLibrary(TString &lib, Bool_t quiet=kFALSE)
Find a dynamic library using the system search paths.
Definition TSystem.cxx:2049
virtual TString GetFromPipe(const char *command, Int_t *ret=nullptr, Bool_t redirectStderr=kFALSE)
Execute command and return output in TString.
Definition TSystem.cxx:688
virtual void SetFlagsDebug(const char *)
FlagsDebug should contain the options to pass to the C++ compiler in order to compile the library in ...
Definition TSystem.cxx:4084
virtual void Exit(int code, Bool_t mode=kTRUE)
Exit the application.
Definition TSystem.cxx:729
virtual Int_t GetGid(const char *group=nullptr)
Returns the group's id. If group = 0, returns current user's group.
Definition TSystem.cxx:1596
virtual void SetMakeExe(const char *directives)
Directives has the same syntax as the argument of SetMakeSharedLib but is used to create an executabl...
Definition TSystem.cxx:4121
TSeqCollection * fCompiled
Definition TSystem.h:330
TString fBuildCompilerVersion
Definition TSystem.h:314
TSystem * FindHelper(const char *path, void *dirptr=nullptr)
Create helper TSystem to handle file and directory operations that might be special for remote file a...
Definition TSystem.cxx:759
virtual const char * GetFlagsDebug() const
Return the debug flags.
Definition TSystem.cxx:3955
virtual const char * HostName()
Return the system's host name.
Definition TSystem.cxx:305
Bool_t fDone
Definition TSystem.h:301
TList * fTimers
Definition TSystem.h:304
Int_t fNfd
Signals that were trapped.
Definition TSystem.h:290
virtual void Unsetenv(const char *name)
Unset environment variable.
Definition TSystem.cxx:1672
virtual Bool_t IsAbsoluteFileName(const char *dir)
Return true if dir is an absolute pathname.
Definition TSystem.cxx:965
virtual void AddDynamicPath(const char *pathname)
Add a new directory to the dynamic path.
Definition TSystem.cxx:1802
virtual Int_t Select(TList *active, Long_t timeout)
Select on active file descriptors (called by TMonitor).
Definition TSystem.cxx:447
TSeqCollection * fOnExitList
Definition TSystem.h:308
virtual const char * GetObjExt() const
Get the object file extension.
Definition TSystem.cxx:4049
virtual int AnnounceUnixService(int port, int backlog)
Announce unix domain service.
Definition TSystem.cxx:2378
TString fIncludePath
Definition TSystem.h:321
virtual Int_t GetUid(const char *user=nullptr)
Returns the user's id. If user = 0, returns current user's id.
Definition TSystem.cxx:1577
virtual Int_t GetEffectiveUid()
Returns the effective user id.
Definition TSystem.cxx:1587
TString fFlagsDebug
Definition TSystem.h:318
virtual const char * GetLinkdefSuffix() const
Return the linkdef suffix chosen by the user for ACLiC.
Definition TSystem.cxx:4029
virtual void SetDynamicPath(const char *pathname)
Set the dynamic path to a new value.
Definition TSystem.cxx:1821
TString fMakeSharedLib
Definition TSystem.h:326
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition TSystem.cxx:439
Int_t fMaxwfd
Definition TSystem.h:292
virtual int CompileMacro(const char *filename, Option_t *opt="", const char *library_name="", const char *build_dir="", UInt_t dirmode=0)
This method compiles and loads a shared library containing the code from the file "filename".
Definition TSystem.cxx:2851
virtual const char * WorkingDirectory()
Return working directory.
Definition TSystem.cxx:885
virtual void AddStdExceptionHandler(TStdExceptionHandler *eh)
Add an exception handler to list of system exception handlers.
Definition TSystem.cxx:613
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Definition TSystem.cxx:1563
virtual TInetAddress GetHostByName(const char *server)
Get Internet Protocol (IP) address of host.
Definition TSystem.cxx:2306
virtual void SetProgname(const char *name)
Set the application name (from command line, argv[0]) and copy it in gProgName.
Definition TSystem.cxx:225
virtual int SendRaw(int sock, const void *buffer, int length, int flag)
Send exactly length bytes from buffer.
Definition TSystem.cxx:2424
virtual Int_t SetFPEMask(Int_t mask=kDefaultMask)
Set which conditions trigger a floating point exception.
Definition TSystem.cxx:644
Int_t fLevel
Definition TSystem.h:302
virtual const char * GetBuildCompiler() const
Return the build compiler.
Definition TSystem.cxx:3911
virtual void CloseConnection(int sock, Bool_t force=kFALSE)
Close socket connection.
Definition TSystem.cxx:2405
virtual const char * GetLibraries(const char *regexp="", const char *option="", Bool_t isRegexp=kTRUE)
Return a space separated list of loaded shared libraries.
Definition TSystem.cxx:2151
TString fBuildDir
Definition TSystem.h:317
void SetErrorStr(const char *errstr)
Set the system error string.
Definition TSystem.cxx:244
virtual TSignalHandler * RemoveSignalHandler(TSignalHandler *sh)
Remove a signal handler from list of signal handlers.
Definition TSystem.cxx:544
virtual void SetSoExt(const char *soExt)
Set shared library extension, should be either .so, .sl, .a, .dll, etc.
Definition TSystem.cxx:4264
virtual void Closelog()
Close connection to system log daemon.
Definition TSystem.cxx:1709
TString fBuildCompiler
Definition TSystem.h:313
virtual void Setenv(const char *name, const char *value)
Set environment variable.
Definition TSystem.cxx:1664
virtual const char * GetBuildArch() const
Return the build architecture.
Definition TSystem.cxx:3903
virtual int Link(const char *from, const char *to)
Create a link from file1 to file2.
Definition TSystem.cxx:1374
virtual void SigAlarmInterruptsSyscalls(Bool_t)
Definition TSystem.h:340
virtual const char * HomeDirectory(const char *userName=nullptr)
Return the user's home directory.
Definition TSystem.cxx:901
virtual void SetLinkedLibs(const char *linkedLibs)
LinkedLibs should contain the library directory and list of libraries needed to recreate the current ...
Definition TSystem.cxx:4233
virtual std::string GetWorkingDirectory() const
Return working directory.
Definition TSystem.cxx:893
TString fSoExt
Definition TSystem.h:323
virtual void SetBuildDir(const char *build_dir, Bool_t isflat=kFALSE)
Set the location where ACLiC will create libraries and use as a scratch area.
Definition TSystem.cxx:4071
static const char * StripOffProto(const char *path, const char *proto)
Strip off protocol string from specified path.
Definition TSystem.cxx:116
virtual void Abort(int code=0)
Abort the application.
Definition TSystem.cxx:738
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition TSystem.cxx:418
virtual const char * GetSoExt() const
Get the shared library extension.
Definition TSystem.cxx:4041
virtual int Utime(const char *file, Long_t modtime, Long_t actime)
Set the a files modification and access times.
Definition TSystem.cxx:1542
virtual const char * GetError()
Return system error string.
Definition TSystem.cxx:253
virtual int AnnounceTcpService(int port, Bool_t reuse, int backlog, int tcpwindowsize=-1, ESocketBindOption socketBindOption=ESocketBindOption::kInaddrAny)
Announce TCP/IP service.
Definition TSystem.cxx:2360
virtual TTimer * RemoveTimer(TTimer *t)
Remove timer from list of system timers.
Definition TSystem.cxx:483
virtual TString GetDirName(const char *pathname)
Return the directory name in pathname.
Definition TSystem.cxx:1046
virtual Int_t GetFPEMask()
Return the bitmap of conditions that trigger a floating point exception.
Definition TSystem.cxx:634
virtual int Unlink(const char *name)
Unlink, i.e.
Definition TSystem.cxx:1396
virtual void StackTrace()
Print a stack trace.
Definition TSystem.cxx:747
virtual UserGroup_t * GetUserInfo(Int_t uid)
Returns all user info in the UserGroup_t structure.
Definition TSystem.cxx:1616
virtual int AnnounceUdpService(int port, int backlog, ESocketBindOption socketBindOption=ESocketBindOption::kInaddrAny)
Announce UDP service.
Definition TSystem.cxx:2369
virtual void ResetSignals()
Reset signals handlers to previous behaviour.
Definition TSystem.cxx:586
TString fBuildNode
Definition TSystem.h:316
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
Definition TSystem.cxx:1497
virtual const char * GetFlagsOpt() const
Return the optimization flags.
Definition TSystem.cxx:3963
virtual Bool_t ConsistentWith(const char *path, void *dirptr=nullptr)
Check consistency of this helper with the one required by 'path' or 'dirptr'.
Definition TSystem.cxx:817
char * DynamicPathName(const char *lib, Bool_t quiet=kFALSE)
Find a dynamic library called lib using the system search paths.
Definition TSystem.cxx:2035
Basic time type with millisecond precision.
Definition TTime.h:27
Handles synchronous and a-synchronous timer events.
Definition TTimer.h:51
TTime GetAbsTime() const
Definition TTimer.h:78
virtual void TurnOn()
Add the timer to the system timer list.
Definition TTimer.cxx:246
Bool_t IsAsync() const
Definition TTimer.h:81
void Reset()
Reset the timer.
Definition TTimer.cxx:162
Bool_t IsInterruptingSyscalls() const
Definition TTimer.h:82
void Remove() override
Definition TTimer.h:86
Bool_t fTimeout
Definition TTimer.h:56
Bool_t IsSync() const
Definition TTimer.h:80
This class represents a WWW compatible URL.
Definition TUrl.h:33
TVersionCheck(int versionCode)
Register version of plugin library.
Definition TSystem.cxx:4427
This class implements a mutex interface.
TLine * line
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
#define I(x, y, z)
std::string MakePathRelative(const std::string &path, const std::string &base, bool isBuildingROOT=false)
bool GetCryptoRandom(void *buf, unsigned int len)
Get random bytes from the operating system's cryptographic random number generator The requested numb...
R__EXTERN TVirtualRWMutex * gCoreMutex
Int_t fMode
Definition TSystem.h:135
Long64_t fSize
Definition TSystem.h:138
Long_t fDev
Definition TSystem.h:133
Long_t fMtime
Definition TSystem.h:139
Long_t fIno
Definition TSystem.h:134
virtual ~ProcInfo_t()
Definition TSystem.cxx:76
TLine l
Definition textangle.C:4
auto * tt
Definition textangle.C:16