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