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
204 // fIncludePath is set in TROOT::InitSystem()
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 bool needToUnlinkTempFile = false;
2591#ifndef WIN32
2592 const char * stderrfile = "/dev/null";
2593#else
2594 // Determine the null device based on the shell in use.
2595 // COMSPEC unset or pointing to cmd.exe -> NUL
2596 // COMSPEC pointing to powershell -> $null
2597 // Anything else (e.g. bash/sh on Windows) -> `depfilename`.stderr.tmp
2599 const char *comspec = gSystem->Getenv("COMSPEC");
2600 if (!comspec || !comspec[0]) {
2601 stderrfile = "NUL";
2602 } else {
2604 comspecStr.ToLower();
2605 if (comspecStr.EndsWith("cmd.exe")) {
2606 stderrfile = "NUL";
2607 } else if (comspecStr.Contains("powershell.exe")) {
2608 stderrfile = "$null";
2609 } else {
2610 needToUnlinkTempFile = true;
2611 stderrfile = depfilename + ".stderr.tmp";
2613 }
2614 }
2615#endif
2617
2618#ifdef WIN32
2619 TString touch = "echo # > "; touch += "\"" + depfilename + "\"";
2620#else
2621 TString touch = "echo > "; touch += "\"" + depfilename + "\"";
2622#endif
2623 TString builddep = "rmkdepend";
2625 builddep += " \"-f";
2627 builddep += "\" -o_" + extension + "." + gSystem->GetSoExt() + " ";
2628 if (build_loc.BeginsWith(gSystem->WorkingDirectory())) {
2630 if ( build_loc.Length() > (len+1) ) {
2631 builddep += " \"-p";
2632 if (build_loc[len] == '/' || build_loc[len+1] != '\\' ) {
2633 // Since the path is now ran through TSystem::ExpandPathName the single \ is also possible.
2634 R__AddPath(builddep, build_loc.Data() + len + 1 );
2635 } else {
2636 // Case of dir\\name
2637 R__AddPath(builddep, build_loc.Data() + len + 2 );
2638 }
2639 builddep += "/\" ";
2640 }
2641 } else {
2642 builddep += " \"-p";
2644 builddep += "/\" ";
2645 }
2646 builddep += " -Y -- ";
2648 builddep += " \"-I"+rootsysInclude+"\" "; // cflags
2649 builddep += includes;
2650 builddep += defines;
2651 builddep += " -- \"";
2652 builddep += filename;
2653 builddep += "\" ";
2655 if (library.BeginsWith(gSystem->WorkingDirectory())) {
2657 if ( library.Length() > (len+1) ) {
2658 if (library[len] == '/' || library[len+1] != '\\' ) {
2659 targetname = library.Data() + len + 1;
2660 } else {
2661 targetname = library.Data() + len + 2;
2662 }
2663 } else {
2665 }
2666 } else {
2668 }
2669 builddep += " \"";
2670 builddep += "-t";
2672 builddep += "\" > ";
2674 builddep += " 2>&1 ";
2675
2676 TString adddictdep = "echo ";
2678 adddictdep += ": ";
2679#if defined(R__HAS_CLING_DICTVERSION)
2680 {
2681 char *clingdictversion = gSystem->Which(incPath,"clingdictversion.h");
2682 if (clingdictversion) {
2684 adddictdep += " ";
2685 delete [] clingdictversion;
2686 } else {
2687 R__AddPath(adddictdep,rootsysInclude+"/clingdictversion.h ");
2688 }
2689 }
2690#endif
2691 {
2692 const char *dictHeaders[] = { "RVersion.h", "ROOT/RConfig.hxx", "TClass.h",
2693 "TDictAttributeMap.h","TInterpreter.h","TROOT.h","TBuffer.h",
2694 "TMemberInspector.h","TError.h","RtypesImp.h","TIsAProxy.h",
2695 "TFileMergeInfo.h","TCollectionProxyInfo.h"};
2696
2697 for (unsigned int h=0; h < sizeof(dictHeaders)/sizeof(dictHeaders[0]); ++h)
2698 {
2700 if (rootVersion) {
2702 delete [] rootVersion;
2703 } else {
2705 }
2706 adddictdep += " ";
2707 }
2708 }
2709 {
2710 // Add dependency on rootcling.
2711 char *rootCling = gSystem->Which(gSystem->Getenv("PATH"),"rootcling");
2712 if (rootCling) {
2714 adddictdep += " ";
2715 delete [] rootCling;
2716 }
2717 }
2718 adddictdep += " >> \""+depfilename+"\"";
2719
2720 TString addversiondep( "echo ");
2721 addversiondep += libname + version_var_prefix + " \"" + ROOT_RELEASE + "\" >> \""+depfilename+"\"";
2722
2723 if (gDebug > 4) {
2724 ::Info("ACLiC", "%s", touch.Data());
2725 ::Info("ACLiC", "%s", builddep.Data());
2726 ::Info("ACLiC", "%s", adddictdep.Data());
2727 }
2728
2733
2734 if (!depbuilt) {
2735 ::Warning("ACLiC","Failed to generate the dependency file for %s",
2736 library.Data());
2737 } else {
2739 // Remove the temporary stderr file if it was created.
2741 }
2743 }
2744}
2745
2746////////////////////////////////////////////////////////////////////////////////
2747/// This method compiles and loads a shared library containing
2748/// the code from the file "filename".
2749///
2750/// The return value is true (1) in case of success and false (0)
2751/// in case of error.
2752///
2753/// The possible options are:
2754/// - k : keep the shared library after the session end.
2755/// - f : force recompilation.
2756/// - g : compile with debug symbol
2757/// - O : optimized the code
2758/// - c : compile only, do not attempt to load the library.
2759/// - s : silence all informational output
2760/// - v : output all information output
2761/// - d : debug ACLiC, keep all the output files.
2762/// - - : if buildir is set, use a flat structure (see buildir below)
2763///
2764/// If library_specified is specified, CompileMacro generates the file
2765/// "library_specified".soext where soext is the shared library extension for
2766/// the current platform.
2767///
2768/// If build_dir is specified, it is used as an alternative 'root' for the
2769/// generation of the shared library. The library is stored in a sub-directories
2770/// of 'build_dir' including the full pathname of the script unless a flat
2771/// directory structure is requested ('-' option). With the '-' option the libraries
2772/// are created directly in the directory 'build_dir'; in particular this means that
2773/// 2 scripts with the same name in different source directory will over-write each
2774/// other's library.
2775/// See also TSystem::SetBuildDir.
2776///
2777/// If dirmode is not zero and we need to create the target directory, the
2778/// file mode bit will be change to 'dirmode' using chmod.
2779///
2780/// If library_specified is not specified, CompileMacro generate a default name
2781/// for library by taking the name of the file "filename" but replacing the
2782/// dot before the extension by an underscore and by adding the shared
2783/// library extension for the current platform.
2784/// For example on most platform, hsimple.cxx will generate hsimple_cxx.so
2785///
2786/// It uses the directive fMakeSharedLibs to create a shared library.
2787/// If loading the shared library fails, it tries to output a list of missing
2788/// symbols by creating an executable (on some platforms like OSF, this does
2789/// not HAVE to be an executable) containing the script. It uses the
2790/// directive fMakeExe to do so.
2791/// For both directives, before passing them to TSystem::Exec, it expands the
2792/// variables $SourceFiles, $SharedLib, $LibName, $IncludePath, $LinkedLibs,
2793/// $DepLibs, $ExeName and $ObjectFiles. See SetMakeSharedLib() for more
2794/// information on those variables.
2795///
2796/// This method is used to implement the following feature:
2797///
2798/// Synopsis:
2799///
2800/// The purpose of this addition is to allow the user to use an external
2801/// compiler to create a shared library from its C++ macro (scripts).
2802/// Currently in order to execute a script, a user has to type at the root
2803/// prompt
2804/// ~~~ {.cpp}
2805/// .X myfunc.C(arg1,arg2)
2806/// ~~~
2807/// We allow them to type:
2808/// ~~~ {.cpp}
2809/// .X myfunc.C++(arg1,arg2)
2810/// ~~~
2811/// or
2812/// ~~~ {.cpp}
2813/// .X myfunc.C+(arg1,arg2)
2814/// ~~~
2815/// In which case an external compiler will be called to create a shared
2816/// library. This shared library will then be loaded and the function
2817/// myfunc will be called with the two arguments. With '++' the shared library
2818/// is always recompiled. With '+' the shared library is recompiled only
2819/// if it does not exist yet or the macro file is newer than the shared
2820/// library.
2821///
2822/// Of course the + and ++ notation is supported in similar way for .x and .L.
2823///
2824/// Through the function TSystem::SetMakeSharedLib(), the user will be able to
2825/// indicate, with shell commands, how to build a shared library (a good
2826/// default will be provided). The most common change, namely where to find
2827/// header files, will be available through the function
2828/// TSystem::SetIncludePath().
2829/// A good default will be provided so that a typical user session should be at
2830/// most:
2831/// ~~~ {.cpp}
2832/// root[1] gSystem->SetIncludePath("-I$ROOTSYS/include
2833/// -I$HOME/mypackage/include");
2834/// root[2] .x myfunc.C++(10,20);
2835/// ~~~
2836/// The user may sometimes try to compile a script before it has loaded all the
2837/// needed shared libraries. In this case we want to be helpful and output a
2838/// list of the unresolved symbols. So if the loading of the created shared
2839/// library fails, we will try to build a executable that contains the
2840/// script. The linker should then output a list of missing symbols.
2841///
2842/// To support this we provide a TSystem::SetMakeExe() function, that sets the
2843/// directive telling how to create an executable. The loader will need
2844/// to be informed of all the libraries available. The information about
2845/// the libraries that has been loaded by .L and TSystem::Load() is accessible
2846/// to the script compiler. However, the information about
2847/// the libraries that have been selected at link time by the application
2848/// builder (like the root libraries for root.exe) are not available and need
2849/// to be explicitly listed in fLinkedLibs (either by default or by a call to
2850/// TSystem::SetLinkedLibs()).
2851///
2852/// To simplify customization we could also add to the .rootrc support for the
2853/// variables
2854/// ~~~ {.cpp}
2855/// Unix.*.Root.IncludePath: -I$ROOTSYS/include
2856/// WinNT.*.Root.IncludePath: -I%ROOTSYS%/include
2857///
2858/// Unix.*.Root.LinkedLibs: -L$ROOTSYS/lib -lBase ....
2859/// WinNT.*.Root.LinkedLibs: %ROOTSYS%/lib/*.lib msvcrt.lib ....
2860/// ~~~
2861/// And also support for MakeSharedLibs() and MakeExe().
2862///
2863/// (the ... have to be replaced by the actual values and are here only to
2864/// shorten this comment).
2865///
2866/// Note that the default behavior is to remove libraries when closing ROOT,
2867/// ie TSystem::CleanCompiledMacros() is called in the TROOT destructor.
2868/// The default behavior of .L script.C+ is the opposite one, leaving things
2869/// after closing, without removing. In other words, .L always passes the 'k'
2870/// option behind the scenes.
2871
2873 const char *library_specified,
2874 const char *build_dir,
2876{
2877 static const char *version_var_prefix = "__ROOTBUILDVERSION=";
2878
2879 // ======= Analyze the options
2880 Bool_t keep = kFALSE;
2882 int mode = fAclicMode;
2885 Bool_t verbose = kFALSE;
2887 if (opt) {
2888 keep = (strchr(opt,'k')!=nullptr);
2889 recompile = (strchr(opt,'f')!=nullptr);
2890 if (strchr(opt,'O')!=nullptr) {
2891 mode |= kOpt;
2892 }
2893 if (strchr(opt,'g')!=nullptr) {
2894 mode |= kDebug;
2895 }
2896 if (strchr(opt,'c')!=nullptr) {
2897 loadLib = kFALSE;
2898 }
2899 withInfo = strchr(opt, 's') == nullptr;
2900 verbose = strchr(opt, 'v') != nullptr;
2901 internalDebug = strchr(opt, 'd') != nullptr;
2902 }
2903 if (mode==kDefault) {
2905 if (rootbuild.Index("debug",0,TString::kIgnoreCase)==kNPOS) {
2906 mode = kOpt;
2907 } else {
2908 mode = kDebug;
2909 }
2910 }
2911#if defined(_MSC_VER) && defined(_DEBUG)
2912 // if ROOT is build in debug mode, ACLiC must also build in debug mode
2913 // for compatibility reasons
2914 if (!(mode & kDebug))
2915 mode |= kDebug;
2916#endif
2917 UInt_t verboseLevel = verbose ? 7 : gDebug;
2918 Bool_t flatBuildDir = (fAclicProperties & kFlatBuildDir) || (opt && strchr(opt,'-')!=nullptr);
2919
2920 // if non-zero, build_loc indicates where to build the shared library.
2923 if (build_loc == ".") {
2925 } else if (build_loc.Length() && (!IsAbsoluteFileName(build_loc)) ) {
2927 }
2928
2929 // Get the include directory list in the dir1:dir2:dir3 format
2930 // [Used for generating the .d file and to look for header files for
2931 // the linkdef file]
2932 TString incPath = GetIncludePath(); // of the form -Idir1 -Idir2 -Idir3
2933 incPath.Append(":").Prepend(" ");
2934 if (gEnv) {
2935 TString fromConfig = gEnv->GetValue("ACLiC.IncludePaths","");
2936 incPath.Append(fromConfig);
2937 }
2938 incPath.ReplaceAll(" -I",":"); // of form :dir1 :dir2:dir3
2939 auto posISysRoot = incPath.Index(" -isysroot \"");
2940 if (posISysRoot != kNPOS) {
2941 auto posISysRootEnd = incPath.Index('"', posISysRoot + 12);
2942 if (posISysRootEnd != kNPOS) {
2943 // NOTE: should probably just skip isysroot for dependency analysis.
2944 // (And will, in the future - once we rely on compiler-generated .d files.)
2945 incPath.Insert(posISysRootEnd - 1, "/usr/include/");
2946 incPath.Replace(posISysRoot, 12, ":\"");
2947 }
2948 }
2949 while ( incPath.Index(" :") != -1 ) {
2950 incPath.ReplaceAll(" :",":");
2951 }
2952 incPath.Prepend(":.:");
2953 incPath.Prepend(WorkingDirectory());
2954
2955 // ======= Get the right file names for the dictionary and the shared library
2961 {
2962 const char *whichlibrary = Which(incPath,library);
2963 if (whichlibrary) {
2965 delete [] whichlibrary;
2966 } else {
2967 ::Error("ACLiC","The file %s can not be found in the include path: %s",filename,incPath.Data());
2968 return kFALSE;
2969 }
2970 } else {
2972 ::Error("ACLiC","The file %s can not be found.",filename);
2973 return kFALSE;
2974 }
2975 }
2976 { // Remove multiple '/' characters, rootcling treats them as comments.
2977 Ssiz_t pos = 0;
2978 while ((pos = library.Index("//", 2, pos, TString::kExact)) != kNPOS) {
2979 library.Remove(pos, 1);
2980 }
2981 }
2984
2986 // For some probably good reason, DirName on Windows returns the 'name' of
2987 // the directory, omitting the drive letter (even if there was one). In
2988 // consequence the result is not usable as a 'root directory', we need to
2989 // add the drive letter if there was one..
2990 if (library.Length()>1 && isalpha(library[0]) && library[1]==':') {
2991 file_dirname.Prepend(library(0,2));
2992 }
2993 TString file_location( file_dirname ); // Location of the script.
2994 incPath.Prepend( file_location + ":" );
2995
2996 Ssiz_t dot_pos = library.Last('.');
2998 if (dot_pos >= 0) {
2999 libname_noext.Remove(dot_pos);
3000 extension = library(dot_pos+1, library.Length()-dot_pos-1);
3001 }
3002
3003 // Extension of shared library is platform dependent!!
3004 TString suffix = TString("_") + extension + "." + fSoExt;
3005 if (dot_pos >= 0)
3006 library.Replace( dot_pos, library.Length()-dot_pos, suffix);
3007 else
3008 library.Append(suffix);
3009
3011 libname.Append("_").Append(extension);
3012
3014 // Use the specified name instead of the default
3018 if (! IsAbsoluteFileName(library) ) {
3020 }
3022 library = TString(library) + "." + fSoExt;
3023 }
3025
3027 libname_ext += "." + fSoExt;
3028
3030 // For some probably good reason, DirName on Windows returns the 'name' of
3031 // the directory, omitting the drive letter (even if there was one). In
3032 // consequence the result is not useable as a 'root directory', we need to
3033 // add the drive letter if there was one..
3034 if (library.Length()>1 && isalpha(library[0]) && library[1]==':') {
3035 lib_dirname.Prepend(library(0,2));
3036 }
3037 // Strip potential, somewhat redundant '/.' from the pathname ...
3038 if ( strncmp( &(lib_dirname[lib_dirname.Length()-2]), "/.", 2) == 0 ) {
3039 lib_dirname.Remove(lib_dirname.Length()-2);
3040 }
3041 if ( strncmp( &(lib_dirname[lib_dirname.Length()-2]), "\\.", 2) == 0 ) {
3042 lib_dirname.Remove(lib_dirname.Length()-2);
3043 }
3046
3047 if (build_loc.Length()==0) {
3049 } else {
3050 // Removes an existing disk specification from the names
3051 TRegexp disk_finder ("[A-z]:");
3052 Int_t pos = library.Index( disk_finder );
3053 if (pos==0) library.Remove(pos,3);
3054 pos = lib_location.Index( disk_finder );
3055 if (pos==0) lib_location.Remove(pos,3);
3056
3057 if (flatBuildDir) {
3060 } else {
3062 }
3063
3066 if (!flatBuildDir) {
3069 }
3070
3072 mkdirFailed = (0 != mkdir(build_loc, true));
3074 // The mkdir failed __and__ we can not write to the target directory,
3075 // let make sure the error message will be about the target directory
3078 } else if (!mkdirFailed && dirmode!=0) {
3080 }
3081 }
3082 }
3084
3085 // ======= Check if the library need to loaded or compiled
3086 if (!gInterpreter->IsLibraryLoaded(library) && gInterpreter->IsLoaded(expFileName)) {
3087 // the script has already been loaded in interpreted mode
3088 // Let's warn the user and unload it.
3089
3090 if (withInfo) {
3091 ::Info("ACLiC","script has already been loaded in interpreted mode");
3092 ::Info("ACLiC","unloading %s and compiling it", filename);
3093 }
3094
3095 if ( gInterpreter->UnloadFile( expFileName ) != 0 ) {
3096 // We can not unload it.
3097 return kFALSE;
3098 }
3099 }
3100
3101 // Calculate the -I lines
3103 includes.ReplaceAll("-I ", "-I");
3104 includes.Prepend(' ');
3105
3106 {
3107 // I need to replace the -Isomerelativepath by -I../ (or -I..\ on NT)
3108 TRegexp rel_inc(" -I[^\"/\\\\$\\%-][^:\\s]+");
3109 Int_t len,pos;
3110 pos = rel_inc.Index(includes,&len);
3111 while( len != 0 ) {
3112 TString sub = includes(pos,len);
3113 sub.Remove(0,3); // Remove ' -I'
3115 sub.Prepend(" -I\"");
3116 if (sub.EndsWith(" "))
3117 sub.Chop(); // Remove trailing space (i.e between the -Is ...
3118 sub.Append("\" ");
3119 includes.Replace(pos,len,sub);
3120 pos = rel_inc.Index(includes,&len);
3121 }
3122 }
3123 {
3124 // I need to replace the -I"somerelativepath" by -I"$cwd/ (or -I"$cwd\ on NT)
3125 TRegexp rel_inc(" -I\"[^/\\\\$\\%-][^:\\s]+");
3126 Int_t len,pos;
3127 pos = rel_inc.Index(includes,&len);
3128 while( len != 0 ) {
3129 TString sub = includes(pos,len);
3130 sub.Remove(0,4); // Remove ' -I"'
3132 sub.Prepend(" -I\"");
3133 includes.Replace(pos,len,sub);
3134 pos = rel_inc.Index(includes,&len);
3135 }
3136 }
3137 //includes += " -I\"" + build_loc;
3138 //includes += "\" -I\"";
3139 //includes += WorkingDirectory();
3140// if (includes[includes.Length()-1] == '\\') {
3141// // The current directory is (most likely) the root of a windows drive and
3142// // has a trailing \ which would espace the quote if left by itself.
3143// includes += '\\';
3144// }
3145// includes += "\"";
3146 if (gEnv) {
3147 TString fromConfig = gEnv->GetValue("ACLiC.IncludePaths","");
3148 includes.Append(" ").Append(fromConfig).Append(" ");
3149 }
3150
3151 // Extract the -D for the dependency generation.
3152 TString defines = " ";
3153 {
3155 TRegexp rel_def("-D[^\\s\\t\\n\\r]*");
3156 Int_t len,pos;
3157 pos = rel_def.Index(cmd,&len);
3158 while( len != 0 ) {
3159 defines += cmd(pos,len);
3160 defines += " ";
3161 pos = rel_def.Index(cmd,&len,pos+1);
3162 }
3163
3164 }
3165
3167 {
3169 if (ug) {
3170 emergency_loc = (ug->fUser).Data();
3172 delete ug;
3173 } else {
3175 }
3176 }
3177
3179
3181
3182 // Generate the dependency filename
3186 depfilename += "_" + extension + ".d";
3187
3188 if ( !recompile ) {
3189
3191
3192 if ((gSystem->GetPathInfo( library, nullptr, (Long_t*)nullptr, nullptr, &lib_time ) != 0) ||
3193 (gSystem->GetPathInfo( expFileName, nullptr, (Long_t*)nullptr, nullptr, &file_time ) == 0 &&
3194 (lib_time < file_time))) {
3195
3196 // the library does not exist or is older than the script.
3197 recompile = kTRUE;
3198 modified = kTRUE;
3199
3200 } else {
3201
3202 if ( gSystem->GetPathInfo( depfilename, nullptr,(Long_t*) nullptr, nullptr, &file_time ) != 0 ) {
3203 if (!canWrite) {
3207 depfilename += "_" + extension + ".d";
3208 }
3210 }
3211 }
3212
3213 if (!modified) {
3214
3215 // We need to check the dependencies
3216 FILE * depfile = fopen(depfilename.Data(),"r");
3217 if (depfile==nullptr) {
3218 // there is no accessible dependency file, let's assume the library has been
3219 // modified
3220 modified = kTRUE;
3221 recompile = kTRUE;
3222
3223 } else {
3224
3226
3227 Int_t sz = 256;
3228 char *line = new char[sz];
3229 line[0] = 0;
3230
3231 int c;
3232 Int_t current = 0;
3233 Int_t nested = 0;
3234 Bool_t hasversion = false;
3235
3236 while ((c = fgetc(depfile)) != EOF) {
3237 if (c=='#') {
3238 // skip comment
3239 while ((c = fgetc(depfile)) != EOF) {
3240 if (c=='\n') {
3241 break;
3242 }
3243 }
3244 continue;
3245 }
3246 if (current && line[current-1]=='=' && strncmp(version_var.Data(),line,current)==0) {
3247
3248 // The next word will be the version number.
3249 hasversion = kTRUE;
3250 line[0] = 0;
3251 current = 0;
3252 } else if (isspace(c) && !nested) {
3253 if (current) {
3254 if (line[current-1]!=':') {
3255 // ignore target
3256 line[current] = 0;
3257
3259 if (hasversion) {
3262 } else if ( gSystem->GetPathInfo( line, nullptr, (Long_t*)nullptr, nullptr, &filetime ) == 0 ) {
3263 modified |= ( lib_time <= filetime );
3264 }
3265 }
3266 }
3267 current = 0;
3268 line[0] = 0;
3269 } else {
3270 if (current==sz-1) {
3271 sz = 2*sz;
3272 char *newline = new char[sz];
3273 memcpy(newline,line, current);
3274 delete [] line;
3275 line = newline;
3276 }
3277 if (c=='"') nested = !nested;
3278 else {
3279 line[current] = c;
3280 current++;
3281 }
3282 }
3283 }
3284 delete [] line;
3285 fclose(depfile);
3287
3288 }
3289
3290 }
3291 }
3292
3293 if ( gInterpreter->IsLibraryLoaded(library)
3294 || strlen(GetLibraries(library,"D",kFALSE)) != 0 ) {
3295 // The library has already been built and loaded.
3296
3297 Bool_t reload = kFALSE;
3299 if (libinfo) {
3300 Long_t load_time = libinfo->GetUniqueID();
3302 if ( gSystem->GetPathInfo( library, nullptr, (Long_t*)nullptr, nullptr, &lib_time ) == 0
3303 && (lib_time>load_time)) {
3304 reload = kTRUE;
3305 }
3306 }
3307
3308 if ( !recompile && reload ) {
3309
3310 if (withInfo) {
3311 ::Info("ACLiC","%s has been modified and will be reloaded",
3312 libname.Data());
3313 }
3314 if ( gInterpreter->UnloadFile( library.Data() ) != 0 ) {
3315 // The library is being used. We can not unload it.
3316 return kFALSE;
3317 }
3318 if (libinfo) {
3320 delete libinfo;
3321 libinfo = nullptr;
3322 }
3323 TNamed *k = new TNamed(library,library);
3325 gSystem->GetPathInfo( library, nullptr, (Long_t*)nullptr, nullptr, &lib_time );
3327 if (!keep) k->SetBit(kMustCleanup);
3328 fCompiled->Add(k);
3329
3330 return !gSystem->Load(library);
3331 }
3332
3333 if (withInfo) {
3334 ::Info("ACLiC","%s script has already been compiled and loaded",
3335 modified ? "modified" : "unmodified");
3336 }
3337
3338 if ( !recompile ) {
3339 return kTRUE;
3340 } else {
3341 if (withInfo) {
3342 ::Info("ACLiC","it will be regenerated and reloaded!");
3343 }
3344 if ( gInterpreter->UnloadFile( library.Data() ) != 0 ) {
3345 // The library is being used. We can not unload it.
3346 return kFALSE;
3347 }
3348 if (libinfo) {
3350 delete libinfo;
3351 libinfo = nullptr;
3352 }
3353 Unlink(library);
3354 }
3355
3356 }
3357
3360 libmapfilename += ".rootmap";
3361#if (defined(R__MACOSX) && !defined(MAC_OS_X_VERSION_10_5)) || defined(R__WIN32)
3363#else
3365#endif
3367 if (gEnv) {
3368#if (defined(R__MACOSX) && !defined(MAC_OS_X_VERSION_10_5))
3369 Int_t linkLibs = gEnv->GetValue("ACLiC.LinkLibs",2);
3370#elif defined(R__WIN32)
3371 Int_t linkLibs = gEnv->GetValue("ACLiC.LinkLibs",3);
3372#else
3373 Int_t linkLibs = gEnv->GetValue("ACLiC.LinkLibs",1);
3374#endif
3375 produceRootmap = linkLibs & 0x2;
3376 linkDepLibraries = linkLibs & 0x1;
3377 }
3378
3379 // FIXME: Triggers clang false positive warning -Wunused-lambda-capture.
3380 /*constexpr const*/ bool useCxxModules =
3381#ifdef R__USE_CXXMODULES
3382 true;
3383#else
3384 false;
3385#endif
3386
3387 // FIXME: Switch to generic polymorphic when we make c++14 default.
3388 auto ForeachSharedLibDep = [](const char *lib, std::function<bool(const char *)> f) {
3389 using std::string, std::vector, std::istringstream, std::istream_iterator;
3390 string deps = gInterpreter->GetSharedLibDeps(lib, /*tryDyld*/ true);
3391 istringstream iss(deps);
3393 // Skip the first element: it is a relative path to `lib`.
3394 for (auto I = libs.begin() + 1, E = libs.end(); I != E; ++I)
3395 if (!f(I->c_str()))
3396 break;
3397 };
3399 // We have no rootmap files or modules to construct `-l` flags enabling
3400 // explicit linking. We have to resolve the dependencies by ourselves
3401 // taking the job of the dyld.
3402 // FIXME: This is a rare case where we have rootcling running with
3403 // modules disabled. Remove this code once we fully switch to modules,
3404 // or implement a special flag in rootcling which selective enables
3405 // modules for dependent libraries and does not produce a module for
3406 // the ACLiC library.
3407 if (useCxxModules && !produceRootmap) {
3408 std::function<bool(const char *)> LoadLibF = [](const char *dep) {
3409 return gInterpreter->Load(dep, /*skipReload*/ true) >= 0;
3410 };
3412 }
3413 return !gSystem->Load(lib);
3414 };
3415
3416 if (!recompile) {
3417 // The library already exist, let's just load it.
3418 if (loadLib) {
3419 TNamed *k = new TNamed(library,library);
3421 gSystem->GetPathInfo( library, nullptr, (Long_t*)nullptr, nullptr, &lib_time );
3423 if (!keep) k->SetBit(kMustCleanup);
3424 fCompiled->Add(k);
3425
3426 gInterpreter->GetSharedLibDeps(library);
3427
3428 return LoadLibrary(library);
3429 }
3430 else return kTRUE;
3431 }
3432
3433 if (!canWrite && recompile) {
3434
3435 if (mkdirFailed) {
3436 ::Warning("ACLiC","Could not create the directory: %s",
3437 build_loc.Data());
3438 } else {
3439 ::Warning("ACLiC","%s is not writable!",
3440 build_loc.Data());
3441 }
3442 if (emergency_loc == build_dir ) {
3443 ::Error("ACLiC","%s is the last resort location (i.e. temp location)",build_loc.Data());
3444 return kFALSE;
3445 }
3446 ::Warning("ACLiC","Output will be written to %s",
3447 emergency_loc.Data());
3449 }
3450
3451 if (withInfo) {
3452 Info("ACLiC","creating shared library %s",library.Data());
3453 }
3454
3456
3457 // ======= Select the dictionary name
3458 TString dict = libname + "_ACLiC_dict";
3459
3460 // the file name end up in the file produced
3461 // by rootcling as a variable name so all character need to be valid!
3462 static const int maxforbidden = 27;
3463 static const char *forbidden_chars[maxforbidden] =
3464 { "+","-","*","/","&","%","|","^",">","<",
3465 "=","~",".","(",")","[","]","!",",","$",
3466 " ",":","'","#","@","\\","\"" };
3467 for( int ic = 0; ic < maxforbidden; ic++ ) {
3468 dict.ReplaceAll( forbidden_chars[ic],"_" );
3469 }
3470 if ( dict.Last('.')!=dict.Length()-1 ) dict.Append(".");
3471 PrependPathName( build_loc, dict ) ;
3472 TString dicth = dict;
3473 TString dictObj = dict;
3474 dict += "cxx"; //no need to keep the extension of the original file, any extension will do
3475 dicth += "h";
3476 dictObj += fObjExt;
3477
3478 // ======= Generate a linkdef file
3481 linkdef += "_ACLiC_linkdef.h";
3482 std::ofstream linkdefFile( linkdef, std::ios::out );
3483 linkdefFile << "// File Automatically generated by the ROOT Script Compiler "
3484 << std::endl;
3485 linkdefFile << std::endl;
3486 linkdefFile << "#ifdef __CLING__" << std::endl;
3487 linkdefFile << std::endl;
3488 linkdefFile << "#pragma link C++ nestedclasses;" << std::endl;
3489 linkdefFile << "#pragma link C++ nestedtypedefs;" << std::endl;
3490 linkdefFile << std::endl;
3491
3492 // We want to look for a header file that has the same name as the macro
3493
3494 const char * extensions[] = { ".h", ".hh", ".hpp", ".hxx", ".hPP", ".hXX" };
3495
3496 int i;
3497 for (i = 0; i < 6; i++ ) {
3498 char * name;
3501 extra_linkdef.Append(extensions[i]);
3503 if (name) {
3504 if (verboseLevel>4 && withInfo) {
3505 Info("ACLiC","including extra linkdef file: %s",name);
3506 }
3507 linkdefFile << "#include \"" << name << "\"" << std::endl;
3508 delete [] name;
3509 }
3510 }
3511
3512 if (verboseLevel>5 && withInfo) {
3513 Info("ACLiC","looking for header in: %s",incPath.Data());
3514 }
3515 for (i = 0; i < 6; i++ ) {
3516 char * name;
3517 TString lookup = BaseName( libname_noext );
3518 lookup.Append(extensions[i]);
3519 name = Which(incPath,lookup);
3520 if (name) {
3521 linkdefFile << "#pragma link C++ defined_in "<<gSystem->UnixPathName(name)<<";"<< std::endl;
3522 delete [] name;
3523 }
3524 }
3525 linkdefFile << "#pragma link C++ defined_in \""<<filename_fullpath << "\";" << std::endl;
3526 linkdefFile << std::endl;
3527 linkdefFile << "#endif" << std::endl;
3528 linkdefFile.close();
3529 // ======= Generate the list of rootmap files to be looked at
3530
3533 mapfile += "_ACLiC_map";
3534 TString mapfilein = mapfile + ".in";
3535 TString mapfileout = mapfile + ".out";
3536
3538 if (!useCxxModules) {
3539 if (gInterpreter->GetSharedLibDeps(library) != nullptr) {
3540 gInterpreter->UnloadLibraryMap(libname);
3542 }
3543 }
3544
3545 std::ofstream mapfileStream( mapfilein, std::ios::out );
3546 {
3547 TString name = ".rootmap";
3548 TString sname = "system.rootmap";
3549 TString file = sname;
3551 if (gSystem->AccessPathName(file)) {
3552 // for backward compatibility check also $ROOTSYS/system<name> if
3553 // $ROOTSYS/etc/system<name> does not exist
3554 file = sname;
3556 if (gSystem->AccessPathName(file)) {
3557 // for backward compatibility check also $ROOTSYS/<name> if
3558 // $ROOTSYS/system<name> does not exist
3559 file = name;
3561 }
3562 }
3563 mapfileStream << file << std::endl;
3564 file = name;
3566 mapfileStream << file << std::endl;
3567 mapfileStream << name << std::endl;
3568 if (gInterpreter->GetRootMapFiles()) {
3569 for (i = 0; i < gInterpreter->GetRootMapFiles()->GetEntriesFast(); i++) {
3570 mapfileStream << ((TNamed*)gInterpreter->GetRootMapFiles()->At(i))->GetTitle() << std::endl;
3571 }
3572 }
3573 }
3574 mapfileStream.close();
3575
3576 // ======= Generate the rootcling command line
3577 TString rcling = "rootcling";
3579 rcling += " \"--lib-list-prefix=";
3580 rcling += mapfile;
3581 rcling += "\" -f \"";
3582 rcling.Append(dict).Append("\" ");
3583
3584 if (produceRootmap && !useCxxModules) {
3585 rcling += " -rml " + libname + " -rmf \"" + libmapfilename + "\" ";
3586 rcling.Append("-DR__ACLIC_ROOTMAP ");
3587 }
3588 rcling.Append(GetIncludePath()).Append(" -D__ACLIC__ ");
3589 if (gEnv) {
3590 TString fromConfig = gEnv->GetValue("ACLiC.IncludePaths","");
3591 rcling.Append(fromConfig);
3592 TString extraFlags = gEnv->GetValue("ACLiC.ExtraRootclingFlags","");
3593 if (!extraFlags.IsNull()) {
3594 extraFlags.Prepend(" ");
3595 extraFlags.Append(" ");
3596 rcling.Append(extraFlags);
3597 }
3598 }
3599
3600 // Create a modulemap
3601 // FIXME: Merge the modulemap generation from cmake and here in rootcling.
3603 rcling += " -cxxmodule ";
3604 // TString moduleMapFileName = file_dirname + "/" + libname + ".modulemap";
3605 TString moduleName = libname + "_ACLiC_dict";
3606 if (moduleName.BeginsWith("lib"))
3607 moduleName = moduleName.Remove(0, 3);
3608 TString moduleMapName = moduleName + ".modulemap";
3610 // A modulemap may exist from previous runs, overwrite it.
3612 ::Info("ACLiC", "File %s already exists!", moduleMapFullPath.Data());
3613
3616 std::ofstream moduleMapFile(moduleMapFullPath, std::ios::out);
3617 moduleMapFile << "module \"" << moduleName << "\" {" << std::endl;
3618 moduleMapFile << " header \"" << relative_path << "\"" << std::endl;
3619 moduleMapFile << " export *" << std::endl;
3620 moduleMapFile << " link \"" << libname_ext << "\"" << std::endl;
3621 moduleMapFile << "}" << std::endl;
3622 moduleMapFile.close();
3623 gInterpreter->RegisterPrebuiltModulePath(build_loc.Data(), moduleMapName.Data());
3624 rcling.Append(" \"-moduleMapFile=" + moduleMapFullPath + "\" ");
3625 }
3626
3627 rcling.Append(" \"").Append(filename_fullpath).Append("\" ");
3628 rcling.Append("\"").Append(linkdef).Append("\"");
3629
3630 // ======= Run rootcling
3631 if (withInfo) {
3632 if (verboseLevel>3) {
3633 ::Info("ACLiC","creating the dictionary files");
3634 if (verboseLevel>4) ::Info("ACLiC", "%s", rcling.Data());
3635 }
3636 }
3637
3638 ///\returns true on success.
3639 auto ExecAndReport = [](TString cmd) -> bool {
3641 if (result) {
3642 if (result == 139)
3643 ::Error("ACLiC", "Executing '%s' failed with a core dump!", cmd.Data());
3644 else
3645 ::Error("ACLiC", "Executing '%s' failed!", cmd.Data());
3646 }
3647 return !result;
3648 };
3649
3652
3653 // ======= Load the library the script might depend on
3654 if (result) {
3655 TString linkedlibs = GetLibraries("", "S");
3658 std::ifstream liblist(mapfileout);
3659
3660 while ( liblist >> libtoload ) {
3661 // Load the needed library except for the library we are currently building!
3662 if (libtoload == "#") {
3663 // The comment terminates the list of libraries.
3664 std::string toskipcomment;
3665 std::getline(liblist,toskipcomment);
3666 break;
3667 }
3669 if (produceRootmap) {
3670 if (loadLib || linkDepLibraries /* For GetLibraries to Work */) {
3671 result = gROOT->LoadClass("", libtoload) >= 0;
3672 if (!result) {
3673 // We failed to load one of the dependency.
3674 break;
3675 }
3676 }
3677 if (!linkedlibs.Contains(libtoload)) {
3678 all_libtoload.Append(" ").Append(libtoload);
3679 depLibraries.Append(" ");
3681 depLibraries = depLibraries.Strip(); // Remove any trailing spaces.
3682 }
3683 } else {
3684 gROOT->LoadClass("", libtoload);
3685 }
3686 }
3687 unsigned char c = liblist.peek();
3688 if (c=='\n' || c=='\r') {
3689 // Consume the character
3690 liblist.get();
3691 break;
3692 }
3693 }
3694
3695// depLibraries = all_libtoload;
3696// depLibraries.ReplaceAll(" lib"," -l");
3697// depLibraries.ReplaceAll(TString::Format(".%s",fSoExt.Data()),"");
3698 }
3699
3700 // ======= Calculate the libraries for linking:
3702 /*
3703 this is intentionally disabled until it can become useful
3704 if (gEnv) {
3705 linkLibraries = gEnv->GetValue("ACLiC.Libraries","");
3706 linkLibraries.Prepend(" ");
3707 }
3708 */
3710 // We need to enclose the single paths in quotes to account for paths with spaces
3714 std::unique_ptr<TObjArray> tokens( linkLibrariesNoQuotes.Tokenize(" ") );
3715 for (auto tokenObj : *tokens) {
3716 singleLibrary = ((TObjString*)tokenObj)->GetString();
3717 if (singleLibrary[0]=='-' || !AccessPathName(singleLibrary)) {
3719 librariesWithQuotes.Chop();
3720 librariesWithQuotes += "\" \"" + singleLibrary + "\"";
3722 } else {
3723 librariesWithQuotes += " \"" + singleLibrary + "\"";
3724 }
3725 } else {
3728 } else {
3730 librariesWithQuotes += " \"" + singleLibrary + " ";
3731 }
3732 }
3733 }
3734
3735#ifdef _MSC_VER
3737#else
3739#endif
3740
3741 // ======= Generate the build command lines
3743 // we do not add filename because it is already included via the dictionary(in dicth) !
3744 // dict.Append(" ").Append(filename);
3745 cmd.ReplaceAll("$SourceFiles","-D__ACLIC__ \"$SourceFiles\"");
3746 cmd.ReplaceAll("$SourceFiles",dict);
3747 cmd.ReplaceAll("$ObjectFiles","\"$ObjectFiles\"");
3748 cmd.ReplaceAll("$ObjectFiles",dictObj);
3749 cmd.ReplaceAll("$IncludePath",includes);
3750 cmd.ReplaceAll("$SharedLib","\"$SharedLib\"");
3751 cmd.ReplaceAll("$SharedLib",library);
3752 if (linkDepLibraries) {
3753 if (produceRootmap) {
3754 cmd.ReplaceAll("$DepLibs",depLibraries);
3755 } else {
3756 cmd.ReplaceAll("$DepLibs",linkLibraries);
3757 }
3758 }
3759 cmd.ReplaceAll("$LinkedLibs",linkLibraries);
3760 cmd.ReplaceAll("$LibName",libname);
3761 cmd.ReplaceAll("\"$BuildDir","$BuildDir");
3762 cmd.ReplaceAll("$BuildDir","\"$BuildDir\"");
3763 cmd.ReplaceAll("$BuildDir",build_loc);
3764 // Add relevant directories to RPATH:
3765 // - Directory with all the ROOT libraries.
3766 // - Directory where this shared library is being created. This enables creating multiple
3767 // libraries via ACLiC in the same session and have them depend on each other without
3768 // the need to set further environment variables.
3769 cmd.ReplaceAll("$RPath", "-Wl,-rpath," + gROOT->GetSharedLibDir() + " -Wl,-rpath," + build_loc);
3771 if (mode & kDebug)
3772 optdebFlags = fFlagsDebug + " ";
3773#ifdef WIN32
3774 else
3775#endif
3776 if (mode & kOpt)
3778 cmd.ReplaceAll("$Opt", optdebFlags);
3779#ifdef WIN32
3780 R__FixLink(cmd);
3781 cmd.ReplaceAll("-std=", "-std:");
3782 if (mode & kDebug) {
3783 cmd.ReplaceAll(" && link ", "&& link /DEBUG ");
3784 }
3785#endif
3786
3790 fakeMain += "_ACLiC_main";
3792 std::ofstream fakeMainFile( fakeMain, std::ios::out );
3793 fakeMainFile << "// File Automatically generated by the ROOT Script Compiler "
3794 << std::endl;
3795 fakeMainFile << "int main(char*argc,char**argvv) {};" << std::endl;
3796 fakeMainFile.close();
3797 // We could append this fake main routine to the compilation line.
3798 // But in this case compiler may output the name of the dictionary file
3799 // and of the fakeMain file while it compiles it. (this would be useless
3800 // confusing output).
3801 // We could also the fake main routine to the end of the dictionary file
3802 // however compilation would fail if a main is already there
3803 // (like stress.cxx)
3804 // dict.Append(" ").Append(fakeMain);
3805 TString exec = libname;
3806 PrependPathName( build_loc, exec );
3807 exec += "_ACLiC_exec";
3808 testcmd.ReplaceAll("$SourceFiles","-D__ACLIC__ \"$SourceFiles\"");
3809 testcmd.ReplaceAll("$SourceFiles",dict);
3810 testcmd.ReplaceAll("$ObjectFiles","\"$ObjectFiles\"");
3811 testcmd.ReplaceAll("$ObjectFiles",dictObj);
3812 testcmd.ReplaceAll("$IncludePath",includes);
3813 testcmd.ReplaceAll("$ExeName",exec);
3814 testcmd.ReplaceAll("$LinkedLibs",linkLibraries);
3815 testcmd.ReplaceAll("$BuildDir",build_loc);
3816 if (mode==kDebug)
3817 testcmd.ReplaceAll("$Opt",fFlagsDebug);
3818 else
3819 testcmd.ReplaceAll("$Opt",fFlagsOpt);
3820
3821#ifdef WIN32
3823 testcmd.ReplaceAll("-std=", "-std:");
3824#endif
3825
3826 // ======= Build the library
3827 if (result) {
3829#ifdef R__MACOSX
3830 // Allow linking to succeed despite the missing symbols.
3831 cmdAllowUnresolved.ReplaceAll("-dynamiclib", "-dynamiclib -Wl,-w -Wl,-undefined,dynamic_lookup");
3832#endif
3833 if (verboseLevel > 3 && withInfo) {
3834 ::Info("ACLiC","compiling the dictionary and script files");
3835 if (verboseLevel>4)
3836 ::Info("ACLiC", "%s", cmdAllowUnresolved.Data());
3837 }
3839 if (!success) {
3840 if (produceRootmap) {
3842 }
3843 }
3844 result = success;
3845 }
3846
3847 if ( result ) {
3848 if (linkDepLibraries) {
3849 // We may have unresolved symbols. Use dyld to resolve the dependent
3850 // libraries and relink.
3851 // FIXME: We will likely have duplicated libraries as we are appending
3852 // FIXME: This likely makes rootcling --lib-list-prefix redundant.
3854 std::function<bool(const char *)> CollectF = [&depLibsFullPaths](const char *dep) {
3856 if (!gSystem->FindDynamicLibrary(LibFullPath, /*quiet=*/true)) {
3857 ::Error("TSystem::CompileMacro", "Cannot find library '%s'", dep);
3858 return false; // abort
3859 }
3861 return true;
3862 };
3864
3867 if (verboseLevel > 3 && withInfo) {
3868 ::Info("ACLiC", "relinking against all dependencies");
3869 if (verboseLevel > 4)
3870 ::Info("ACLiC", "%s", relink_cmd.Data());
3871 }
3873 }
3874
3875 TNamed *k = new TNamed(library,library);
3877 gSystem->GetPathInfo( library, nullptr, (Long_t*)nullptr, nullptr, &lib_time );
3879 if (!keep) k->SetBit(kMustCleanup);
3880 fCompiled->Add(k);
3881
3882 if (needLoadMap) {
3883 gInterpreter->LoadLibraryMap(libmapfilename);
3884 }
3885 if (verboseLevel>3 && withInfo) ::Info("ACLiC","loading the shared library");
3886 if (loadLib)
3888 else
3889 result = kTRUE;
3890
3891 if ( !result ) {
3892 if (verboseLevel>3 && withInfo) {
3893 ::Info("ACLiC","testing for missing symbols:");
3894 if (verboseLevel>4) ::Info("ACLiC", "%s", testcmd.Data());
3895 }
3897 gSystem->Unlink( exec );
3898 }
3899
3900 };
3901
3902 if (verboseLevel<=5 && !internalDebug) {
3903 gSystem->Unlink( dict );
3904 gSystem->Unlink( dicth );
3910 gSystem->Unlink( exec );
3911 }
3912 if (verboseLevel>6) {
3913 rcling.Prepend("echo ");
3914 cmd.Prepend("echo \" ").Append(" \" ");
3915 testcmd.Prepend("echo \" ").Append(" \" ");
3917 gSystem->Exec( cmd );
3919 }
3920
3921 return result;
3922}
3923
3924////////////////////////////////////////////////////////////////////////////////
3925/// Return the ACLiC properties field. See EAclicProperties for details
3926/// on the semantic of each bit.
3927
3929{
3930 return fAclicProperties;
3931}
3932
3933////////////////////////////////////////////////////////////////////////////////
3934/// Return the build architecture.
3935
3936const char *TSystem::GetBuildArch() const
3937{
3938 return fBuildArch;
3939}
3940
3941////////////////////////////////////////////////////////////////////////////////
3942/// Return the build compiler
3943
3944const char *TSystem::GetBuildCompiler() const
3945{
3946 return fBuildCompiler;
3947}
3948
3949////////////////////////////////////////////////////////////////////////////////
3950/// Return the build compiler version
3951
3953{
3954 return fBuildCompilerVersion;
3955}
3956
3957////////////////////////////////////////////////////////////////////////////////
3958/// Return the build compiler version identifier string
3959
3961{
3963}
3964
3965////////////////////////////////////////////////////////////////////////////////
3966/// Return the build node name.
3967
3968const char *TSystem::GetBuildNode() const
3969{
3970 return fBuildNode;
3971}
3972
3973////////////////////////////////////////////////////////////////////////////////
3974/// Return the path of the build directory.
3975
3976const char *TSystem::GetBuildDir() const
3977{
3978 if (fBuildDir.Length()==0) {
3979 if (!gEnv) return "";
3980 const_cast<TSystem*>(this)->fBuildDir = gEnv->GetValue("ACLiC.BuildDir","");
3981 }
3982 return fBuildDir;
3983}
3984
3985////////////////////////////////////////////////////////////////////////////////
3986/// Return the debug flags.
3987
3988const char *TSystem::GetFlagsDebug() const
3989{
3990 return fFlagsDebug;
3991}
3992
3993////////////////////////////////////////////////////////////////////////////////
3994/// Return the optimization flags.
3995
3996const char *TSystem::GetFlagsOpt() const
3997{
3998 return fFlagsOpt;
3999}
4000
4001////////////////////////////////////////////////////////////////////////////////
4002/// AclicMode indicates whether the library should be built in
4003/// debug mode or optimized. The values are:
4004/// - TSystem::kDefault : compile the same as the current ROOT
4005/// - TSystem::kDebug : compiled in debug mode
4006/// - TSystem::kOpt : optimized the library
4007
4012
4013////////////////////////////////////////////////////////////////////////////////
4014/// Return the command line use to make a shared library.
4015/// See TSystem::CompileMacro for more details.
4016
4017const char *TSystem::GetMakeSharedLib() const
4018{
4019 return fMakeSharedLib;
4020}
4021
4022////////////////////////////////////////////////////////////////////////////////
4023/// Return the command line use to make an executable.
4024/// See TSystem::CompileMacro for more details.
4025
4026const char *TSystem::GetMakeExe() const
4027{
4028 return fMakeExe;
4029}
4030
4031////////////////////////////////////////////////////////////////////////////////
4032/// Get the list of include path.
4033
4035{
4037#ifndef _MSC_VER
4038 // FIXME: This is a temporary fix for the following error with ACLiC
4039 // (and this is apparently not needed anyway):
4040 // 48: input_line_12:8:38: error: use of undeclared identifier 'IC'
4041 // 48: "C:/Users/bellenot/build/debug/etc" -IC:/Users/bellenot/build/debug/etc//cling -IC:/Users/bellenot/build/debug/include"",
4042 // 48: ^
4043 // 48: Error in <ACLiC>: Dictionary generation failed!
4044 fListPaths.Append(" ").Append(gInterpreter->GetIncludePath());
4045#endif
4046 return fListPaths;
4047}
4048
4049////////////////////////////////////////////////////////////////////////////////
4050/// Return the list of library linked to this executable.
4051/// See TSystem::CompileMacro for more details.
4052
4053const char *TSystem::GetLinkedLibs() const
4054{
4055 return fLinkedLibs;
4056}
4057
4058////////////////////////////////////////////////////////////////////////////////
4059/// Return the linkdef suffix chosen by the user for ACLiC.
4060/// See TSystem::CompileMacro for more details.
4061
4062const char *TSystem::GetLinkdefSuffix() const
4063{
4064 if (fLinkdefSuffix.Length()==0) {
4065 if (!gEnv) return "_linkdef";
4066 const_cast<TSystem*>(this)->fLinkdefSuffix = gEnv->GetValue("ACLiC.Linkdef","_linkdef");
4067 }
4068 return fLinkdefSuffix;
4069}
4070
4071////////////////////////////////////////////////////////////////////////////////
4072/// Get the shared library extension.
4073
4074const char *TSystem::GetSoExt() const
4075{
4076 return fSoExt;
4077}
4078
4079////////////////////////////////////////////////////////////////////////////////
4080/// Get the object file extension.
4081
4082const char *TSystem::GetObjExt() const
4083{
4084 return fObjExt;
4085}
4086
4087////////////////////////////////////////////////////////////////////////////////
4088/// Set the location where ACLiC will create libraries and use as
4089/// a scratch area. If unset, libraries will be created at the same
4090/// location than the script.
4091///
4092/// \param build_dir the name of the build directory
4093/// \param isflat If false (default), then the libraries are actually stored
4094/// in sub-directories of 'build_dir' including the full pathname
4095/// of the script. If the script is located at `/full/path/name/macro.C`
4096/// the library will be located at `build_dir+/full/path/name/macro_C.so`
4097/// If 'isflat' is true, then no subdirectory is created and the library
4098/// is created directly in the directory 'build_dir'. Note that in this
4099/// mode there is a risk than 2 script of the same in different source
4100/// directory will over-write each other.
4101/// \note This `build_dir` can also be controlled via `ACLiC.BuildDir` in
4102/// your `.rootrc`.
4103
4105{
4107 if (isflat)
4109 else
4111}
4112
4113////////////////////////////////////////////////////////////////////////////////
4114/// FlagsDebug should contain the options to pass to the C++ compiler
4115/// in order to compile the library in debug mode.
4116
4117void TSystem::SetFlagsDebug(const char *flags)
4118{
4119 fFlagsDebug = flags;
4120}
4121
4122////////////////////////////////////////////////////////////////////////////////
4123/// FlagsOpt should contain the options to pass to the C++ compiler
4124/// in order to compile the library in optimized mode.
4125
4126void TSystem::SetFlagsOpt(const char *flags)
4127{
4128 fFlagsOpt = flags;
4129}
4130
4131////////////////////////////////////////////////////////////////////////////////
4132/// AclicMode indicates whether the library should be built in
4133/// debug mode or optimized. The values are:
4134/// - TSystem::kDefault : compile the same as the current ROOT
4135/// - TSystem::kDebug : compiled in debug mode
4136/// - TSystem::kOpt : optimized the library
4137
4142
4143////////////////////////////////////////////////////////////////////////////////
4144/// Directives has the same syntax as the argument of SetMakeSharedLib but is
4145/// used to create an executable. This creation is used as a means to output
4146/// a list of unresolved symbols, when loading a shared library has failed.
4147/// The required variable is $ExeName rather than $SharedLib, e.g.:
4148/// ~~~ {.cpp}
4149/// gSystem->SetMakeExe(
4150/// "g++ -Wall -fPIC $IncludePath $SourceFiles
4151/// -o $ExeName $LinkedLibs -L/usr/X11R6/lib -lX11 -lm -ldl -rdynamic");
4152/// ~~~
4153
4155{
4157 // NOTE: add verification that the directives has the required variables
4158}
4159
4160////////////////////////////////////////////////////////////////////////////////
4161/// Directives should contain the description on how to compile and link a
4162/// shared lib. This description can be any valid shell command, including
4163/// the use of ';' to separate several instructions. However, shell specific
4164/// construct should be avoided. In particular this description can contain
4165/// environment variables, like $ROOTSYS (or %ROOTSYS% on windows).
4166/// ~~~ {.cpp}
4167/// The following special variables will be expanded before execution:
4168/// Variable name Expands to
4169/// ------------- ----------
4170/// $SourceFiles Name of source files to be compiled
4171/// $SharedLib Name of the shared library being created
4172/// $LibName Name of shared library without extension
4173/// $BuildDir Directory where the files will be created
4174/// $IncludePath value of fIncludePath
4175/// $LinkedLibs value of fLinkedLibs
4176/// $RPath ROOT's library directory is added as -rpath
4177/// $DepLibs libraries on which this library depends on
4178/// $ObjectFiles Name of source files to be compiler with
4179/// their extension changed to .o or .obj
4180/// $Opt location of the optimization/debug options
4181/// set fFlagsDebug and fFlagsOpt
4182/// ~~~
4183/// e.g.:
4184/// ~~~ {.cpp}
4185/// gSystem->SetMakeSharedLib(
4186/// "KCC -n32 --strict $IncludePath -K0 \$Opt $SourceFile
4187/// --no_exceptions --signed_chars --display_error_number
4188/// --diag_suppress 68 -o $SharedLib");
4189///
4190/// // Or adding an rpath to the generated libraries (ROOT's rpath is inserted automatically into $RPath):
4191/// gSystem->SetMakeSharedLib(
4192/// "Cxx $IncludePath -c $SourceFile;
4193/// ld -L/usr/lib/cmplrs/cxx -rpath /usr/lib/cmplrs/cxx -expect_unresolved
4194/// \$Opt \$RPath -shared /usr/lib/cmplrs/cc/crt0.o /usr/lib/cmplrs/cxx/_main.o
4195/// -o $SharedLib $ObjectFile -lcxxstd -lcxx -lexc -lots -lc"
4196///
4197/// gSystem->SetMakeSharedLib(
4198/// "$HOME/mygcc/bin/g++ \$Opt -Wall -fPIC $IncludePath $SourceFile
4199/// -shared -o $SharedLib");
4200///
4201/// gSystem->SetMakeSharedLib(
4202/// "cl -DWIN32 -D_WIN32 -D_MT -D_DLL -MD /O2 /G5 /MD -DWIN32
4203/// -D_WINDOWS $IncludePath $SourceFile
4204/// /link -PDB:NONE /NODEFAULTLIB /INCREMENTAL:NO /RELEASE /NOLOGO
4205/// $LinkedLibs -entry:_DllMainCRTStartup@12 -dll /out:$SharedLib")
4206/// ~~~
4207
4209{
4211 // NOTE: add verification that the directives has the required variables
4212}
4213
4214////////////////////////////////////////////////////////////////////////////////
4215/// \brief Add a directory to the already set include path.
4216/// \param[in] includePath The path to the directory.
4217/// \note This interface is mostly relevant for ACLiC and it does *not* inform
4218/// gInterpreter for this include path. If the TInterpreter needs to know
4219/// about the include path please use TInterpreter::AddIncludePath() .
4220/// \warning The path should start with the \c -I prefix, i.e.
4221/// <tt>gSystem->AddIncludePath("-I /path/to/my/includes")</tt>.
4223{
4224 if (includePath) {
4225 fIncludePath += " ";
4227 }
4228}
4229
4230////////////////////////////////////////////////////////////////////////////////
4231/// Add linkedLib to already set linked libs.
4232
4234{
4235 if (linkedLib) {
4236 fLinkedLibs += " ";
4238 }
4239}
4240
4241////////////////////////////////////////////////////////////////////////////////
4242/// IncludePath should contain the list of compiler flags to indicate where
4243/// to find user defined header files. It is used to expand $IncludePath in
4244/// the directives given to SetMakeSharedLib() and SetMakeExe(), e.g.:
4245/// ~~~ {.cpp}
4246/// gSystem->SetInclude("-I$ROOTSYS/include -Imydirectory/include");
4247/// ~~~
4248/// the default value of IncludePath on Unix is:
4249/// ~~~ {.cpp}
4250/// "-I$ROOTSYS/include "
4251/// ~~~
4252/// and on Windows:
4253/// ~~~ {.cpp}
4254/// "/I%ROOTSYS%/include "
4255/// ~~~
4256
4258{
4260}
4261
4262////////////////////////////////////////////////////////////////////////////////
4263/// LinkedLibs should contain the library directory and list of libraries
4264/// needed to recreate the current executable. It is used to expand $LinkedLibs
4265/// in the directives given to SetMakeSharedLib() and SetMakeExe()
4266/// The default value on Unix is: `root-config --glibs`
4267
4269{
4271}
4272
4273////////////////////////////////////////////////////////////////////////////////
4274/// The 'suffix' will be appended to the name of a script loaded by ACLiC
4275/// and used to locate any eventual additional linkdef information that
4276/// ACLiC should used to produce the dictionary.
4277///
4278/// So by default, when doing .L MyScript.cxx, ACLiC will look
4279/// for a file name MyScript_linkdef and having one of the .h (.hpp,
4280/// etc.) extensions. If such a file exist, it will be added to
4281/// the end of the linkdef file used to created the ACLiC dictionary.
4282/// This effectively enable the full customization of the creation
4283/// of the dictionary. It should be noted that the file is intended
4284/// as a linkdef `fragment`, so usually you would not list the
4285/// typical:
4286/// ~~~ {.cpp}
4287/// #pragma link off ....
4288/// ~~~
4289
4291{
4293}
4294
4295
4296////////////////////////////////////////////////////////////////////////////////
4297/// Set shared library extension, should be either .so, .sl, .a, .dll, etc.
4298
4299void TSystem::SetSoExt(const char *SoExt)
4300{
4301 fSoExt = SoExt;
4302}
4303
4304////////////////////////////////////////////////////////////////////////////////
4305/// Set object files extension, should be either .o, .obj, etc.
4306
4308{
4309 fObjExt = ObjExt;
4310}
4311
4312////////////////////////////////////////////////////////////////////////////////
4313/// This method split a filename of the form:
4314/// ~~~ {.cpp}
4315/// [path/]macro.C[+|++[k|f|g|O|c|s|d|v|-]][(args)].
4316/// ~~~
4317/// It stores the ACliC mode [+|++[options]] in 'mode',
4318/// the arguments (including parenthesis) in arg
4319/// and the I/O indirection in io
4320
4322 TString &arguments, TString &io) const
4323{
4324 char *fname = Strip(filename);
4326 filenameCopy = filenameCopy.Strip();
4327
4328 if (filenameCopy.EndsWith(";")) {
4329 filenameCopy.Remove(filenameCopy.Length() - 1);
4330 filenameCopy = filenameCopy.Strip();
4331 }
4332 if (filenameCopy.EndsWith(")")) {
4333 Ssiz_t posArgEnd = filenameCopy.Length() - 1;
4334 // There is an argument; find its start!
4335 int parenNestCount = 1;
4336 bool inString = false;
4338 for (; parenNestCount && posArgBegin >= 0; --posArgBegin) {
4339 // Escaped if the previous character is a `\` - but not if it
4340 // itself is preceded by a `\`!
4341 if (posArgBegin > 0 && filenameCopy[posArgBegin] == '\\' &&
4342 (posArgBegin == 1 || filenameCopy[posArgBegin - 1] != '\\')) {
4343 // skip escape.
4344 --posArgBegin;
4345 continue;
4346 }
4347 switch (filenameCopy[posArgBegin]) {
4348 case ')':
4349 if (!inString)
4351 break;
4352 case '(':
4353 if (!inString)
4355 break;
4356 case '"': inString = !inString; break;
4357 }
4358 }
4359 if (parenNestCount || inString) {
4360 Error("SplitAclicMode", "Cannot parse argument in %s", filename);
4361 } else {
4362 arguments = filenameCopy(posArgBegin + 1, posArgEnd - 1);
4363 fname[posArgBegin + 1] = 0;
4364 }
4365 }
4366
4367 // strip off I/O redirect tokens from filename
4368 {
4369 char *s2 = nullptr;
4370 char *s3;
4371 s2 = strstr(fname, ">>");
4372 if (!s2) s2 = strstr(fname, "2>");
4373 if (!s2) s2 = strchr(fname, '>');
4374 s3 = strchr(fname, '<');
4375 if (s2 && s3) s2 = s2<s3 ? s2 : s3;
4376 if (s3 && !s2) s2 = s3;
4377 if (s2==fname) {
4378 io = fname;
4379 aclicMode = "";
4380 arguments = "";
4381 delete []fname;
4382 return "";
4383 } else if (s2) {
4384 if (s2 > fname) {
4385 // Skip/trim spaces
4386 s2--;
4387 while (s2 > fname && *s2 == ' ') s2--;
4388 s2++;
4389 }
4390 io = s2; // ssave = *s2;
4391 *s2 = 0;
4392 } else
4393 io = "";
4394 }
4395
4396 // remove the possible ACLiC + or ++ and g or O etc
4397 aclicMode.Clear();
4398 int len = strlen(fname);
4399 TString mode;
4400 while (len > 1) {
4401 if (strchr("kfgOcsdv-", fname[len - 1])) {
4402 mode += fname[len - 1];
4403 --len;
4404 } else {
4405 break;
4406 }
4407 }
4408 Bool_t compile = len && fname[len - 1] == '+';
4409 Bool_t remove = compile && len > 1 && fname[len - 2] == '+';
4410 if (compile) {
4411 if (mode.Length()) {
4412 fname[len] = 0;
4413 }
4414 if (remove) {
4415 fname[strlen(fname)-2] = 0;
4416 aclicMode = "++";
4417 } else {
4418 fname[strlen(fname)-1] = 0;
4419 aclicMode = "+";
4420 }
4421 if (mode.Length())
4422 aclicMode += mode;
4423 }
4424
4426
4427 delete []fname;
4428 return resFilename;
4429}
4430
4431////////////////////////////////////////////////////////////////////////////////
4432/// Remove the shared libs produced by the CompileMacro() function, together
4433/// with their rootmaps, linkdefs, and pcms (and some more on Windows).
4434
4436{
4437 TIter next(fCompiled);
4438 TNamed *lib;
4439 const char *extensions[] = {".lib", ".exp", ".d", ".def", ".rootmap", "_ACLiC_linkdef.h", "_ACLiC_dict_rdict.pcm"};
4440 while ((lib = (TNamed*)next())) {
4441 if (lib->TestBit(kMustCleanup)) {
4442 TString libname = lib->GetTitle();
4443#ifdef WIN32
4444 // On Windows, we need to unload the dll before deleting it
4445 if (gInterpreter->IsLibraryLoaded(libname))
4447#endif
4448 Unlink(libname);
4449 TString target, soExt = "." + fSoExt;
4450 libname.ReplaceAll(soExt, "");
4451 for (const char *ext : extensions) {
4452 target = libname + ext;
4453 Unlink(target);
4454 }
4455 }
4456 }
4457}
4458
4459////////////////////////////////////////////////////////////////////////////////
4460/// Register version of plugin library.
4461
The file contains utilities which are foundational and could be used across the core component of ROO...
#define SafeDelete(p)
Definition RConfig.hxx:525
#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:148
#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:777
#define gROOT
Definition TROOT.h:417
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:582
@ 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:503
This class represents an Internet Protocol (IP) address.
Iterator of linked list.
Definition TList.h:196
TObject * Next() override
Return next object in the list. Returns 0 when no more objects in list.
Definition TList.cxx:1243
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:708
void Add(TObject *obj) override
Definition TList.h:81
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:952
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:600
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:42
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:1146
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:204
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
Definition TObject.cxx:1109
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1081
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:885
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1095
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
Definition TObject.cxx:896
@ kInvalidObject
if object ctor succeeded but object should not be used
Definition TObject.h:81
@ kMustCleanup
if object destructor must call RecursiveRemove()
Definition TObject.h:73
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:1069
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:3150
static const TString & GetIncludeDir()
Get the include directory in the installation. Static utility function.
Definition TROOT.cxx:3347
static Int_t ConvertVersionCode2Int(Int_t code)
Convert version code to an integer, i.e. 331527 -> 51507.
Definition TROOT.cxx:3083
static const TString & GetRootSys()
Get the rootsys directory in the installation. Static utility function.
Definition TROOT.cxx:3140
static Int_t RootVersionCode()
Return ROOT version code as defined in RVersion.h.
Definition TROOT.cxx:3102
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
Definition TROOT.cxx:3381
static const TString & GetLibDir()
Get the library directory in the installation.
Definition TROOT.cxx:3178
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:330
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:3968
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:4017
Bool_t fInControl
Definition TSystem.h:310
TSeqCollection * fFileHandler
Definition TSystem.h:316
Int_t fAclicProperties
Definition TSystem.h:339
Int_t fMaxrfd
Definition TSystem.h:301
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:4233
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:3952
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:4053
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:308
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:4138
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:436
virtual void SetObjExt(const char *objExt)
Set object files extension, should be either .o, .obj, etc.
Definition TSystem.cxx:4307
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:4290
TSeqCollection * fHelpers
Definition TSystem.h:341
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:3976
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:4222
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:285
@ kDebug
Definition TSystem.h:289
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:4126
void RemoveOnExit(TObject *obj)
Objects that should be deleted on exit of the OS interface.
Definition TSystem.cxx:294
TSeqCollection * fStdExceptionHandler
Definition TSystem.h:317
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:4034
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:3928
virtual TString SplitAclicMode(const char *filename, TString &mode, TString &args, TString &io) const
This method split a filename of the form:
Definition TSystem.cxx:4321
TString fListLibs
Definition TSystem.h:320
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:4435
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:337
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:325
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:335
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:329
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:4008
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:4257
virtual TFileHandler * RemoveFileHandler(TFileHandler *fh)
Remove a file handler from the list of file handlers.
Definition TSystem.cxx:566
TString fLinkedLibs
Definition TSystem.h:332
Int_t fSigcnt
Definition TSystem.h:303
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:352
TString fObjExt
Definition TSystem.h:334
TString fLinkdefSuffix
Definition TSystem.h:338
Int_t fBeepFreq
Definition TSystem.h:307
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:291
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:4208
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:3960
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:322
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:315
virtual const char * GetMakeExe() const
Return the command line use to make an executable.
Definition TSystem.cxx:4026
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:4117
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:4154
TSeqCollection * fCompiled
Definition TSystem.h:340
TString fBuildCompilerVersion
Definition TSystem.h:324
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:3988
virtual const char * HostName()
Return the system's host name.
Definition TSystem.cxx:305
Bool_t fDone
Definition TSystem.h:311
TList * fTimers
Definition TSystem.h:314
Int_t fNfd
Definition TSystem.h:300
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:318
virtual const char * GetObjExt() const
Get the object file extension.
Definition TSystem.cxx:4082
virtual int AnnounceUnixService(int port, int backlog)
Announce unix domain service.
Definition TSystem.cxx:2378
TString fIncludePath
Definition TSystem.h:331
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:328
virtual const char * GetLinkdefSuffix() const
Return the linkdef suffix chosen by the user for ACLiC.
Definition TSystem.cxx:4062
virtual void SetDynamicPath(const char *pathname)
Set the dynamic path to a new value.
Definition TSystem.cxx:1821
TString fMakeSharedLib
Definition TSystem.h:336
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition TSystem.cxx:439
Int_t fMaxwfd
Definition TSystem.h:302
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:2872
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:312
virtual const char * GetBuildCompiler() const
Return the build compiler.
Definition TSystem.cxx:3944
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:327
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:4299
virtual void Closelog()
Close connection to system log daemon.
Definition TSystem.cxx:1709
TString fBuildCompiler
Definition TSystem.h:323
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:3936
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:350
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:4268
virtual std::string GetWorkingDirectory() const
Return working directory.
Definition TSystem.cxx:893
TString fSoExt
Definition TSystem.h:333
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:4104
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:4074
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:326
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:3996
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:4462
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