Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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
1083char *TSystem::ConcatFileName(const char *dir, const char *name)
1084{
1087 return StrDup(nameString.Data());
1088}
1089
1090////////////////////////////////////////////////////////////////////////////////
1091/// Concatenate a directory and a file name.
1092
1093const char *TSystem::PrependPathName(const char *, TString&)
1094{
1095 AbstractMethod("PrependPathName");
1096 return nullptr;
1097}
1098
1099
1100//---- Paths & Files -----------------------------------------------------------
1101
1102////////////////////////////////////////////////////////////////////////////////
1103/// Expand a pathname getting rid of special shell characters like ~.$, etc.
1104/// For Unix/Win32 compatibility use $(XXX) instead of $XXX when using
1105/// environment variables in a pathname. If compatibility is not an issue
1106/// you can use on Unix directly $XXX. This is a protected function called
1107/// from the OS specific system classes, like TUnixSystem and TWinNTSystem.
1108/// Returns the expanded filename or 0 in case of error.
1109
1110const char *TSystem::ExpandFileName(const char *fname)
1111{
1112 const int kBufSize = kMAXPATHLEN;
1114
1116 if (res)
1117 return nullptr;
1118 else
1119 return xname;
1120}
1121
1122//////////////////////////////////////////////////////////////////////////////
1123/// Expand a pathname getting rid of special shell characters like ~.$, etc.
1124/// This function is analogous to ExpandFileName(const char *), except that
1125/// it receives a TString reference of the pathname to be expanded.
1126/// Returns kTRUE in case of error and kFALSE otherwise.
1127
1129{
1130 const int kBufSize = kMAXPATHLEN;
1131 char xname[kBufSize];
1132
1133 Bool_t res = ExpandFileName(fname.Data(), xname, kBufSize);
1134 if (!res)
1135 fname = xname;
1136
1137 return res;
1138}
1139
1140////////////////////////////////////////////////////////////////////////////
1141/// Private method for pathname expansion.
1142/// Returns kTRUE in case of error and kFALSE otherwise.
1143
1144Bool_t TSystem::ExpandFileName(const char *fname, char *xname, const int kBufSize)
1145{
1146 int n, ier, iter, lx, ncopy;
1147 char *inp, *out, *x, *t, *buff;
1148 const char *b, *c, *e;
1149 const char *p;
1150 buff = new char[kBufSize * 4];
1151
1152 iter = 0; xname[0] = 0; inp = buff + kBufSize; out = inp + kBufSize;
1153 inp[-1] = ' '; inp[0] = 0; out[-1] = ' ';
1154 c = fname + strspn(fname, " \t\f\r");
1155 //VP if (isalnum(c[0])) { strcpy(inp, WorkingDirectory()); strcat(inp, "/"); } // add $cwd
1156
1157 strlcat(inp, c, kBufSize);
1158
1159again:
1160 iter++; c = inp; ier = 0;
1161 x = out; x[0] = 0;
1162
1163 p = nullptr; e = nullptr;
1164 if (c[0] == '~' && c[1] == '/') { // ~/ case
1165 std::string hd = GetHomeDirectory();
1166 p = hd.c_str();
1167 e = c + 1;
1168 if (p) { // we have smth to copy
1169 strlcpy(x, p, kBufSize);
1170 x += strlen(p);
1171 c = e;
1172 } else {
1173 ++ier;
1174 ++c;
1175 }
1176 } else if (c[0] == '~' && c[1] != '/') { // ~user case
1177 n = strcspn(c+1, "/ ");
1178 assert((n+1) < kBufSize && "This should have been prevented by the truncation 'strlcat(inp, c, kBufSize)'");
1179 // There is no overlap here as the buffer is segment in 4 strings of at most kBufSize
1180 (void)strlcpy(buff, c+1, n+1); // strlcpy copy 'size-1' characters.
1181 std::string hd = GetHomeDirectory(buff);
1182 e = c+1+n;
1183 if (!hd.empty()) { // we have smth to copy
1184 p = hd.c_str();
1185 strlcpy(x, p, kBufSize);
1186 x += strlen(p);
1187 c = e;
1188 } else {
1189 x++[0] = c[0];
1190 //++ier;
1191 ++c;
1192 }
1193 }
1194
1195 for ( ; c[0]; c++) {
1196
1197 p = nullptr; e = nullptr;
1198
1199 if (c[0] == '.' && c[1] == '/' && c[-1] == ' ') { // $cwd
1200 std::string wd = GetWorkingDirectory();
1201 strlcpy(buff, wd.c_str(), kBufSize);
1202 p = buff;
1203 e = c + 1;
1204 }
1205 if (p) { // we have smth to copy */
1206 strlcpy(x, p, kBufSize); x += strlen(p); c = e-1; continue;
1207 }
1208
1209 if (c[0] != '$') { // not $, simple copy
1210 x++[0] = c[0];
1211 } else { // we have a $
1212 b = c+1;
1213 if (c[1] == '(') b++;
1214 if (c[1] == '{') b++;
1215 if (b[0] == '$')
1216 e = b+1;
1217 else
1218 for (e = b; isalnum(e[0]) || e[0] == '_'; e++) ;
1219 buff[0] = 0; strncat(buff, b, e-b);
1220 p = Getenv(buff);
1221 if (!p) { // too bad, try UPPER case
1222 for (t = buff; (t[0] = toupper(t[0])); t++) ;
1223 p = Getenv(buff);
1224 }
1225 if (!p) { // too bad, try Lower case
1226 for (t = buff; (t[0] = tolower(t[0])); t++) ;
1227 p = Getenv(buff);
1228 }
1229 if (!p && !strcmp(buff, "cwd")) { // it is $cwd
1230 std::string wd = GetWorkingDirectory();
1231 strlcpy(buff, wd.c_str(), kBufSize);
1232 p = buff;
1233 }
1234 if (!p && !strcmp(buff, "$")) { // it is $$ (replace by GetPid())
1235 snprintf(buff,kBufSize*4, "%d", GetPid());
1236 p = buff;
1237 }
1238 if (!p) { // too bad, nothing can help
1239#ifdef WIN32
1240 // if we're on windows, we can have \SomeMachine\C$ - don't
1241 // complain about that, if '$' is followed by nothing or a
1242 // path delimiter.
1243 if (c[1] && c[1]!='\' && c[1]!=';' && c[1]!='/')
1244 ier++;
1245#else
1246 ier++;
1247#endif
1248 x++[0] = c[0];
1249 } else { // It is OK, copy result
1250 int lp = strlen(p);
1251 if (lp >= kBufSize) {
1252 // make sure lx will be >= kBufSize (see below)
1253 strlcpy(x, p, kBufSize);
1254 x += kBufSize;
1255 break;
1256 }
1257 strcpy(x,p);
1258 x += lp;
1259 c = (b==c+1) ? e-1 : e;
1260 }
1261 }
1262 }
1263
1264 x[0] = 0; lx = x - out;
1265 if (ier && iter < 3) { strlcpy(inp, out, kBufSize); goto again; }
1266 ncopy = (lx >= kBufSize) ? kBufSize-1 : lx;
1267 xname[0] = 0; strncat(xname, out, ncopy);
1268
1269 delete[] buff;
1270
1271 if (ier || ncopy != lx) {
1272 ::Error("TSystem::ExpandFileName", "input: %s, output: %s", fname, xname);
1273 return kTRUE;
1274 }
1275
1276 return kFALSE;
1277}
1278
1279
1280////////////////////////////////////////////////////////////////////////////////
1281/// Expand a pathname getting rid of special shell characters like ~.$, etc.
1282/// For Unix/Win32 compatibility use $(XXX) instead of $XXX when using
1283/// environment variables in a pathname. If compatibility is not an issue
1284/// you can use on Unix directly $XXX.
1285
1290
1291////////////////////////////////////////////////////////////////////////////////
1292/// Expand a pathname getting rid of special shell characters like ~.$, etc.
1293/// For Unix/Win32 compatibility use $(XXX) instead of $XXX when using
1294/// environment variables in a pathname. If compatibility is not an issue
1295/// you can use on Unix directly $XXX. The user must delete returned string.
1296
1297char *TSystem::ExpandPathName(const char *)
1298{
1299 return nullptr;
1300}
1301
1302////////////////////////////////////////////////////////////////////////////////
1303/// Returns FALSE if one can access a file using the specified access mode.
1304/// The file name must not contain any special shell characters line ~ or $,
1305/// in those cases first call ExpandPathName().
1306/// Attention, bizarre convention of return value!!
1307
1309{
1310 return kFALSE;
1311}
1312
1313////////////////////////////////////////////////////////////////////////////////
1314/// Returns TRUE if the url in 'path' points to the local file system.
1315/// This is used to avoid going through the NIC card for local operations.
1316
1318{
1320
1321 TUrl url(path);
1322 if (strlen(url.GetHost()) > 0) {
1323 // Check locality
1324 localPath = kFALSE;
1325 TInetAddress a(gSystem->GetHostByName(url.GetHost()));
1327 if (!strcmp(a.GetHostName(), b.GetHostName()) ||
1328 !strcmp(a.GetHostAddress(), b.GetHostAddress())) {
1329 // Host OK
1330 localPath = kTRUE;
1331 // Check the user if specified
1332 if (strlen(url.GetUser()) > 0) {
1334 if (u) {
1335 if (strcmp(u->fUser, url.GetUser()))
1336 // Requested a different user
1337 localPath = kFALSE;
1338 delete u;
1339 }
1340 }
1341 }
1342 }
1343 // Done
1344 return localPath;
1345}
1346
1347////////////////////////////////////////////////////////////////////////////////
1348/// Copy a file. If overwrite is true and file already exists the
1349/// file will be overwritten. Returns 0 when successful, -1 in case
1350/// of file open failure, -2 in case the file already exists and overwrite
1351/// was false and -3 in case of error during copy.
1352
1353int TSystem::CopyFile(const char *, const char *, Bool_t)
1354{
1355 AbstractMethod("CopyFile");
1356 return -1;
1357}
1358
1359////////////////////////////////////////////////////////////////////////////////
1360/// Rename a file.
1361
1362int TSystem::Rename(const char *, const char *)
1363{
1364 AbstractMethod("Rename");
1365 return -1;
1366}
1367
1368////////////////////////////////////////////////////////////////////////////////
1369/// Create a link from file1 to file2.
1370
1371int TSystem::Link(const char *, const char *)
1372{
1373 AbstractMethod("Link");
1374 return -1;
1375}
1376
1377////////////////////////////////////////////////////////////////////////////////
1378/// Create a symbolic link from file1 to file2.
1379
1380int TSystem::Symlink(const char *, const char *)
1381{
1382 AbstractMethod("Symlink");
1383 return -1;
1384}
1385
1386////////////////////////////////////////////////////////////////////////////////
1387/// Unlink, i.e. remove, a file.
1388///
1389/// If the file is currently open by the current or another process, the behavior of this function is
1390/// implementation-defined (in particular, POSIX systems unlink the file name, while Windows does not allow the
1391/// file to be deleted and the operation is a no-op).
1392
1393int TSystem::Unlink(const char *)
1394{
1395 AbstractMethod("Unlink");
1396 return -1;
1397}
1398
1399////////////////////////////////////////////////////////////////////////////////
1400/// Get info about a file: id, size, flags, modification time.
1401/// - Id is (statbuf.st_dev << 24) + statbuf.st_ino
1402/// - Size is the file size
1403/// - Flags is file type: 0 is regular file, bit 0 set executable,
1404/// bit 1 set directory, bit 2 set special file
1405/// (socket, fifo, pipe, etc.)
1406/// Modtime is modification time.
1407/// The function returns 0 in case of success and 1 if the file could
1408/// not be stat'ed.
1409
1410int TSystem::GetPathInfo(const char *path, Long_t *id, Long_t *size,
1411 Long_t *flags, Long_t *modtime)
1412{
1414
1415 int res = GetPathInfo(path, id, &lsize, flags, modtime);
1416
1417 if (res == 0 && size) {
1418 if (sizeof(Long_t) == 4 && lsize > kMaxInt) {
1419 Error("GetPathInfo", "file %s > 2 GB, use GetPathInfo() with Long64_t size", path);
1420 *size = kMaxInt;
1421 } else {
1422 *size = (Long_t)lsize;
1423 }
1424 }
1425
1426 return res;
1427}
1428
1429////////////////////////////////////////////////////////////////////////////////
1430/// Get info about a file: id, size, flags, modification time.
1431/// - Id is (statbuf.st_dev << 24) + statbuf.st_ino
1432/// - Size is the file size
1433/// - Flags is file type: 0 is regular file, bit 0 set executable,
1434/// bit 1 set directory, bit 2 set special file
1435/// (socket, fifo, pipe, etc.)
1436/// Modtime is modification time.
1437/// The function returns 0 in case of success and 1 if the file could
1438/// not be stat'ed.
1439
1440int TSystem::GetPathInfo(const char *path, Long_t *id, Long64_t *size,
1441 Long_t *flags, Long_t *modtime)
1442{
1443 FileStat_t buf;
1444
1445 int res = GetPathInfo(path, buf);
1446
1447 if (res == 0) {
1448 if (id)
1449 *id = (buf.fDev << 24) + buf.fIno;
1450 if (size)
1451 *size = buf.fSize;
1452 if (modtime)
1453 *modtime = buf.fMtime;
1454 if (flags) {
1455 *flags = 0;
1456 if (buf.fMode & (kS_IXUSR|kS_IXGRP|kS_IXOTH))
1457 *flags |= 1;
1458 if (R_ISDIR(buf.fMode))
1459 *flags |= 2;
1460 if (!R_ISREG(buf.fMode) && !R_ISDIR(buf.fMode))
1461 *flags |= 4;
1462 }
1463 }
1464
1465 return res;
1466}
1467
1468////////////////////////////////////////////////////////////////////////////////
1469/// Get info about a file. Info is returned in the form of a FileStat_t
1470/// structure (see TSystem.h).
1471/// The function returns 0 in case of success and 1 if the file could
1472/// not be stat'ed.
1473
1475{
1476 AbstractMethod("GetPathInfo(const char *, FileStat_t&)");
1477 return 1;
1478}
1479
1480////////////////////////////////////////////////////////////////////////////////
1481/// Get info about a file system: fs type, block size, number of blocks,
1482/// number of free blocks.
1483
1484int TSystem::GetFsInfo(const char *, Long_t *, Long_t *, Long_t *, Long_t *)
1485{
1486 AbstractMethod("GetFsInfo");
1487 return 1;
1488}
1489
1490////////////////////////////////////////////////////////////////////////////////
1491/// Return a user configured or systemwide directory to create
1492/// temporary files in.
1493
1494const char *TSystem::TempDirectory() const
1495{
1496 AbstractMethod("TempDirectory");
1497 return nullptr;
1498}
1499
1500////////////////////////////////////////////////////////////////////////////////
1501/// Create a secure temporary file by appending a unique
1502/// 6 letter string to base. The file will be created in
1503/// a standard (system) directory or in the directory
1504/// provided in dir. Optionally one can provide suffix
1505/// append to the final name - like extension ".txt" or ".html".
1506/// The full filename is returned in base
1507/// and a filepointer is returned for safely writing to the file
1508/// (this avoids certain security problems). Returns 0 in case
1509/// of error.
1510
1511FILE *TSystem::TempFileName(TString &, const char *, const char *)
1512{
1513 AbstractMethod("TempFileName");
1514 return nullptr;
1515}
1516
1517////////////////////////////////////////////////////////////////////////////////
1518/// Set the file permission bits. Returns -1 in case or error, 0 otherwise.
1519
1520int TSystem::Chmod(const char *, UInt_t)
1521{
1522 AbstractMethod("Chmod");
1523 return -1;
1524}
1525
1526////////////////////////////////////////////////////////////////////////////////
1527/// Set the process file creation mode mask.
1528
1530{
1531 AbstractMethod("Umask");
1532 return -1;
1533}
1534
1535////////////////////////////////////////////////////////////////////////////////
1536/// Set the a files modification and access times. If actime = 0 it will be
1537/// set to the modtime. Returns 0 on success and -1 in case of error.
1538
1539int TSystem::Utime(const char *, Long_t, Long_t)
1540{
1541 AbstractMethod("Utime");
1542 return -1;
1543}
1544
1545////////////////////////////////////////////////////////////////////////////////
1546/// Find location of file in a search path. Return value points to TString for
1547/// compatibility with Which(const char *, const char *, EAccessMode).
1548/// Returns 0 in case file is not found.
1549
1550const char *TSystem::FindFile(const char *, TString&, EAccessMode)
1551{
1552 AbstractMethod("FindFile");
1553 return nullptr;
1554}
1555
1556////////////////////////////////////////////////////////////////////////////////
1557/// Find location of file in a search path. User must delete returned string.
1558/// Returns 0 in case file is not found.
1559
1560char *TSystem::Which(const char *search, const char *wfil, EAccessMode mode)
1561{
1564 if (wfilString.IsNull())
1565 return nullptr;
1566 return StrDup(wfilString.Data());
1567}
1568
1569//---- Users & Groups ----------------------------------------------------------
1570
1571////////////////////////////////////////////////////////////////////////////////
1572/// Returns the user's id. If user = 0, returns current user's id.
1573
1574Int_t TSystem::GetUid(const char * /*user*/)
1575{
1576 AbstractMethod("GetUid");
1577 return 0;
1578}
1579
1580////////////////////////////////////////////////////////////////////////////////
1581/// Returns the effective user id. The effective id corresponds to the
1582/// set id bit on the file being executed.
1583
1585{
1586 AbstractMethod("GetEffectiveUid");
1587 return 0;
1588}
1589
1590////////////////////////////////////////////////////////////////////////////////
1591/// Returns the group's id. If group = 0, returns current user's group.
1592
1593Int_t TSystem::GetGid(const char * /*group*/)
1594{
1595 AbstractMethod("GetGid");
1596 return 0;
1597}
1598
1599////////////////////////////////////////////////////////////////////////////////
1600/// Returns the effective group id. The effective group id corresponds
1601/// to the set id bit on the file being executed.
1602
1604{
1605 AbstractMethod("GetEffectiveGid");
1606 return 0;
1607}
1608
1609////////////////////////////////////////////////////////////////////////////////
1610/// Returns all user info in the UserGroup_t structure. The returned
1611/// structure must be deleted by the user. In case of error 0 is returned.
1612
1614{
1615 AbstractMethod("GetUserInfo");
1616 return nullptr;
1617}
1618
1619////////////////////////////////////////////////////////////////////////////////
1620/// Returns all user info in the UserGroup_t structure. If user = 0, returns
1621/// current user's id info. The returned structure must be deleted by the
1622/// user. In case of error 0 is returned.
1623
1624UserGroup_t *TSystem::GetUserInfo(const char * /*user*/)
1625{
1626 AbstractMethod("GetUserInfo");
1627 return nullptr;
1628}
1629
1630////////////////////////////////////////////////////////////////////////////////
1631/// Returns all group info in the UserGroup_t structure. The only active
1632/// fields in the UserGroup_t structure for this call are:
1633/// - fGid and fGroup
1634/// The returned structure must be deleted by the user. In case of
1635/// error 0 is returned.
1636
1638{
1639 AbstractMethod("GetGroupInfo");
1640 return nullptr;
1641}
1642
1643////////////////////////////////////////////////////////////////////////////////
1644/// Returns all group info in the UserGroup_t structure. The only active
1645/// fields in the UserGroup_t structure for this call are:
1646/// - fGid and fGroup
1647/// If group = 0, returns current user's group. The returned structure
1648/// must be deleted by the user. In case of error 0 is returned.
1649
1650UserGroup_t *TSystem::GetGroupInfo(const char * /*group*/)
1651{
1652 AbstractMethod("GetGroupInfo");
1653 return nullptr;
1654}
1655
1656//---- environment manipulation ------------------------------------------------
1657
1658////////////////////////////////////////////////////////////////////////////////
1659/// Set environment variable.
1660
1661void TSystem::Setenv(const char *, const char *)
1662{
1663 AbstractMethod("Setenv");
1664}
1665
1666////////////////////////////////////////////////////////////////////////////////
1667/// Unset environment variable.
1668
1669void TSystem::Unsetenv(const char *name)
1670{
1671 Setenv(name, "");
1672}
1673
1674////////////////////////////////////////////////////////////////////////////////
1675/// Get environment variable.
1676
1677const char *TSystem::Getenv(const char *)
1678{
1679 AbstractMethod("Getenv");
1680 return nullptr;
1681}
1682
1683//---- System Logging ----------------------------------------------------------
1684
1685////////////////////////////////////////////////////////////////////////////////
1686/// Open connection to system log daemon. For the use of the options and
1687/// facility see the Unix openlog man page.
1688
1690{
1691 AbstractMethod("Openlog");
1692}
1693
1694////////////////////////////////////////////////////////////////////////////////
1695/// Send mess to syslog daemon. Level is the logging level and mess the
1696/// message that will be written on the log.
1697
1698void TSystem::Syslog(ELogLevel, const char *)
1699{
1700 AbstractMethod("Syslog");
1701}
1702
1703////////////////////////////////////////////////////////////////////////////////
1704/// Close connection to system log daemon.
1705
1707{
1708 AbstractMethod("Closelog");
1709}
1710
1711//---- Standard output redirection ---------------------------------------------
1712
1713////////////////////////////////////////////////////////////////////////////////
1714/// Redirect standard output (stdout, stderr) to the specified file.
1715/// If the file argument is 0 the output is set again to stderr, stdout.
1716/// The second argument specifies whether the output should be added to the
1717/// file ("a", default) or the file be truncated before ("w").
1718/// The implementations of this function save internally the current state into
1719/// a static structure.
1720///
1721/// The call can be made reentrant by specifying the opaque structure pointed
1722/// by 'h', which is filled with the relevant information. The handle 'h'
1723/// obtained on the first call must then be used in any subsequent call,
1724/// included ShowOutput, to display the redirected output.
1725/// Returns 0 on success, -1 in case of error.
1726
1727Int_t TSystem::RedirectOutput(const char *, const char *, RedirectHandle_t *)
1728{
1729 AbstractMethod("RedirectOutput");
1730 return -1;
1731}
1732
1733////////////////////////////////////////////////////////////////////////////////
1734/// Display the content associated with the redirection described by the
1735/// opaque handle 'h'.
1736
1738{
1739 // Check input ...
1740 if (!h) {
1741 Error("ShowOutput", "handle not specified");
1742 return;
1743 }
1744
1745 // ... and file access
1746 if (gSystem->AccessPathName(h->fFile, kReadPermission)) {
1747 Error("ShowOutput", "file '%s' cannot be read", h->fFile.Data());
1748 return;
1749 }
1750
1751 // Open the file
1752 FILE *f = nullptr;
1753 if (!(f = fopen(h->fFile.Data(), "r"))) {
1754 Error("ShowOutput", "file '%s' cannot be open", h->fFile.Data());
1755 return;
1756 }
1757
1758 // Determine the number of bytes to be read from the file.
1759 off_t ltot = lseek(fileno(f), (off_t) 0, SEEK_END);
1760 Int_t begin = (h->fReadOffSet > 0 && h->fReadOffSet < ltot) ? h->fReadOffSet : 0;
1761 lseek(fileno(f), (off_t) begin, SEEK_SET);
1762 Int_t left = ltot - begin;
1763
1764 // Now readout from file
1765 const Int_t kMAXBUF = 16384;
1766 char buf[kMAXBUF];
1767 Int_t wanted = (left > kMAXBUF-1) ? kMAXBUF-1 : left;
1768 Int_t len;
1769 do {
1770 while ((len = read(fileno(f), buf, wanted)) < 0 &&
1773
1774 if (len < 0) {
1775 SysError("ShowOutput", "error reading log file");
1776 break;
1777 }
1778
1779 // Null-terminate
1780 buf[len] = 0;
1781 fprintf(stderr,"%s", buf);
1782
1783 // Update counters
1784 left -= len;
1785 wanted = (left > kMAXBUF) ? kMAXBUF : left;
1786
1787 } while (len > 0 && left > 0);
1788
1789 // Do not display twice the same thing
1790 h->fReadOffSet = ltot;
1791 fclose(f);
1792}
1793
1794//---- Dynamic Loading ---------------------------------------------------------
1795
1796////////////////////////////////////////////////////////////////////////////////
1797/// Add a new directory to the dynamic path.
1798
1799void TSystem::AddDynamicPath(const char *)
1800{
1801 AbstractMethod("AddDynamicPath");
1802}
1803
1804////////////////////////////////////////////////////////////////////////////////
1805/// Return the dynamic path (used to find shared libraries).
1806
1808{
1809 AbstractMethod("GetDynamicPath");
1810 return nullptr;
1811}
1812
1813////////////////////////////////////////////////////////////////////////////////
1814/// Set the dynamic path to a new value.
1815/// If the value of 'path' is zero, the dynamic path is reset to its
1816/// default value.
1817
1818void TSystem::SetDynamicPath(const char *)
1819{
1820 AbstractMethod("SetDynamicPath");
1821}
1822
1823
1824////////////////////////////////////////////////////////////////////////////////
1825/// Figure out if left and right points to the same
1826/// object in the file system.
1827
1828static bool R__MatchFilename(const char *left, const char *right)
1829{
1830 if (left == right) return kTRUE;
1831
1832 if (left==nullptr || right==nullptr) return kFALSE;
1833
1834 if ( (strcmp(right,left)==0) ) {
1835 return kTRUE;
1836 }
1837
1838#ifdef G__WIN32
1839
1840 char leftname[_MAX_PATH];
1841 char rightname[_MAX_PATH];
1842 _fullpath( leftname, left, _MAX_PATH );
1843 _fullpath( rightname, right, _MAX_PATH );
1844 return ((stricmp(leftname, rightname)==0));
1845#else
1846 struct stat rightBuf;
1847 struct stat leftBuf;
1848 return ( ( 0 == stat( left, & leftBuf ) )
1849 && ( 0 == stat( right, & rightBuf ) )
1850 && ( leftBuf.st_dev == rightBuf.st_dev ) // Files on same device
1851 && ( leftBuf.st_ino == rightBuf.st_ino ) // Files on same inode (but this is not unique on AFS so we need the next 2 test
1852 && ( leftBuf.st_size == rightBuf.st_size ) // Files of same size
1853 && ( leftBuf.st_mtime == rightBuf.st_mtime ) // Files modified at the same time
1854 );
1855#endif
1856}
1857
1858
1859////////////////////////////////////////////////////////////////////////////////
1860/// Load a shared library. Returns 0 on successful loading, 1 in
1861/// case lib was already loaded, -1 in case lib does not exist
1862/// or in case of error and -2 in case of version mismatch.
1863/// When entry is specified the loaded lib is
1864/// searched for this entry point (return -1 when entry does not exist,
1865/// 0 otherwise). When the system flag is kTRUE, the library is considered
1866/// a permanent system library that should not be unloaded during the
1867/// course of the session.
1868
1869int TSystem::Load(const char *module, const char *entry, Bool_t system)
1870{
1871 // don't load libraries that have already been loaded
1874
1875 Ssiz_t idx = l.Last('.');
1876 if (idx != kNPOS) {
1877 l.Remove(idx+1);
1878 }
1879 for (idx = libs.Index(l); idx != kNPOS; idx = libs.Index(l,idx+1)) {
1880 // The libs contains the sub-string 'l', let's make sure it is
1881 // not just part of a larger name.
1882 if (idx == 0 || libs[idx-1] == '/' || libs[idx-1] == '\') {
1883 Ssiz_t len = libs.Length();
1884 idx += l.Length();
1885 if (!l.EndsWith(".") && libs[idx]=='.')
1886 idx++;
1887 // Skip the soversion.
1888 while (idx < len && isdigit(libs[idx])) {
1889 ++idx;
1890 // No need to test for len here, at worse idx==len and lib[idx]=='\0'
1891 if (libs[idx] == '.') {
1892 ++idx;
1893 }
1894 }
1895 while (idx < len && libs[idx] != '.') {
1896 if (libs[idx] == ' ' || idx+1 == len) {
1897 return 1;
1898 }
1899 ++idx;
1900 }
1901 }
1902 }
1903 if (l[l.Length()-1] == '.') {
1904 l.Remove(l.Length()-1);
1905 }
1906 if (l.BeginsWith("lib")) {
1907 l.Replace(0, 3, "-l");
1908 for(idx = libs.Index(l); idx != kNPOS; idx = libs.Index(l,idx+1)) {
1909 if ((idx == 0 || libs[idx-1] == ' ') &&
1910 (libs[idx+l.Length()] == ' ' || libs[idx+l.Length()] == 0)) {
1911 return 1;
1912 }
1913 }
1914 }
1915
1916 char *path = DynamicPathName(module);
1917
1918 int ret = -1;
1919 if (path) {
1920 // load any dependent libraries
1921 TString deplibs = gInterpreter->GetSharedLibDeps(path);
1922 if (!deplibs.IsNull()) {
1923 TString delim(" ");
1924 TObjArray *tokens = deplibs.Tokenize(delim);
1925 for (Int_t i = tokens->GetEntriesFast()-1; i > 0; i--) {
1926 const char *deplib = ((TObjString*)tokens->At(i))->GetName();
1927 if (strcmp(module,deplib)==0) {
1928 continue;
1929 }
1930 if (gDebug > 0)
1931 Info("Load", "loading dependent library %s for library %s",
1932 deplib, ((TObjString*)tokens->At(0))->GetName());
1933 if ((ret = Load(deplib, "", system)) < 0) {
1934 delete tokens;
1935 delete [] path;
1936 return ret;
1937 }
1938 }
1939 delete tokens;
1940 }
1941 if (!system) {
1942 // Mark the library in $ROOTSYS/lib as system.
1943 TString dirname = GetDirName(path);
1945
1946 if (!system) {
1948 }
1949 }
1950
1953 gLibraryVersionMax *= 2;
1955 }
1956 ret = gInterpreter->Load(path, system);
1957 if (ret < 0) ret = -1;
1958 if (gDebug > 0)
1959 Info("Load", "loaded library %s, status %d", path, ret);
1960 if (ret == 0 && gLibraryVersion[gLibraryVersionIdx]) {
1962 Error("Load", "version mismatch, %s = %d, ROOT = %d",
1963 path, v, gROOT->GetVersionInt());
1964 ret = -2;
1966 }
1968 delete [] path;
1969 }
1970
1971 if (!entry || !entry[0] || ret < 0) return ret;
1972
1974 if (f) return 0;
1975 return -1;
1976}
1977
1978///////////////////////////////////////////////////////////////////////////////
1979/// Load all libraries known to ROOT via the rootmap system.
1980/// Returns the number of top level libraries successfully loaded.
1981
1983{
1984 UInt_t nlibs = 0;
1985
1986 TEnv* mapfile = gInterpreter->GetMapfile();
1987 if (!mapfile || !mapfile->GetTable()) return 0;
1988
1989 std::set<std::string> loadedlibs;
1990 std::set<std::string> failedlibs;
1991
1992 TEnvRec* rec = nullptr;
1993 TIter iEnvRec(mapfile->GetTable());
1994 while ((rec = (TEnvRec*) iEnvRec())) {
1995 TString libs = rec->GetValue();
1996 TString lib;
1997 Ssiz_t pos = 0;
1998 while (libs.Tokenize(lib, pos)) {
1999 // check that none of the libs failed to load
2000 if (failedlibs.find(lib.Data()) != failedlibs.end()) {
2001 // don't load it or any of its dependencies
2002 libs = "";
2003 break;
2004 }
2005 }
2006 pos = 0;
2007 while (libs.Tokenize(lib, pos)) {
2008 // ignore libCore - it's already loaded
2009 if (lib.BeginsWith("libCore"))
2010 continue;
2011
2012 if (loadedlibs.find(lib.Data()) == loadedlibs.end()) {
2013 // just load the first library - TSystem will do the rest.
2014 auto res = gSystem->Load(lib);
2015 if (res >=0) {
2016 if (res == 0) ++nlibs;
2017 loadedlibs.insert(lib.Data());
2018 } else {
2019 failedlibs.insert(lib.Data());
2020 }
2021 }
2022 }
2023 }
2024 return nlibs;
2025}
2026
2027////////////////////////////////////////////////////////////////////////////////
2028/// Find a dynamic library called lib using the system search paths.
2029/// Appends known extensions if needed. Returned string must be deleted
2030/// by the user!
2031
2032char *TSystem::DynamicPathName(const char *lib, Bool_t quiet /*=kFALSE*/)
2033{
2034 TString sLib(lib);
2036 return StrDup(sLib);
2037 return nullptr;
2038}
2039
2040////////////////////////////////////////////////////////////////////////////////
2041/// Find a dynamic library using the system search paths. lib will be updated
2042/// to contain the absolute filename if found. Returns lib if found, or NULL
2043/// if a library called lib was not found.
2044/// This function does not open the library.
2045
2047{
2048 AbstractMethod("FindDynamicLibrary");
2049 return nullptr;
2050}
2051
2052////////////////////////////////////////////////////////////////////////////////
2053/// Find specific entry point in specified library. Specify "*" for lib
2054/// to search in all libraries.
2055
2056Func_t TSystem::DynFindSymbol(const char * /*lib*/, const char *entry)
2057{
2058 return (Func_t) gInterpreter->FindSym(entry);
2059}
2060
2061////////////////////////////////////////////////////////////////////////////////
2062/// Unload a shared library.
2063
2064void TSystem::Unload(const char *module)
2065{
2066 char *path;
2067 if ((path = DynamicPathName(module))) {
2068 gInterpreter->UnloadFile(path);
2069 delete [] path;
2070 }
2071}
2072
2073////////////////////////////////////////////////////////////////////////////////
2074/// List symbols in a shared library.
2075
2076void TSystem::ListSymbols(const char *, const char *)
2077{
2078 AbstractMethod("ListSymbols");
2079}
2080
2081////////////////////////////////////////////////////////////////////////////////
2082/// List the loaded shared libraries.
2083/// `regexp` is a regular expression allowing to filter the list.
2084///
2085/// Examples:
2086///
2087/// The following line lists all the libraries currently loaded:
2088/// ~~~ {.cpp}
2089/// gSystem->ListLibraries()
2090/// ~~~
2091///
2092/// The following line lists all the libraries currently loaded having "RIO" in their names:
2093/// ~~~ {.cpp}
2094/// gSystem->ListLibraries(".*RIO.*")
2095/// ~~~
2096
2097void TSystem::ListLibraries(const char *regexp) {
2098 if (!(regexp && regexp[0]))
2099 regexp = ".*";
2100 TRegexp pat(regexp, kFALSE);
2102 TString tok;
2103 Ssiz_t from = 0, ext;
2104 while (libs.Tokenize(tok, from, " ")) {
2105 if ((tok.Index(pat, &ext) != 0) || (ext != tok.Length()))
2106 continue;
2107 std::cout << tok << "\n";
2108 }
2109}
2110
2111////////////////////////////////////////////////////////////////////////////////
2112/// Return the thread local storage for the custom last error message
2113
2119
2120////////////////////////////////////////////////////////////////////////////////
2121/// Return the thread local storage for the custom last error message
2122
2124{
2125 return const_cast<TSystem*>(this)->GetLastErrorString();
2126}
2127
2128////////////////////////////////////////////////////////////////////////////////
2129/// Get list of shared libraries loaded at the start of the executable.
2130/// Returns 0 in case list cannot be obtained or in case of error.
2131
2133{
2134 return nullptr;
2135}
2136
2137////////////////////////////////////////////////////////////////////////////////
2138/// Return a space separated list of loaded shared libraries.
2139/// Regexp is a wildcard expression, see TRegexp::MakeWildcard.
2140/// This list is of a format suitable for a linker, i.e it may contain
2141/// -Lpathname and/or -lNameOfLib.
2142/// Option can be any of:
2143/// - S: shared libraries loaded at the start of the executable, because
2144/// they were specified on the link line.
2145/// - D: shared libraries dynamically loaded after the start of the program.
2146/// - L: this option is ignored, and available for backward compatibility.
2147
2148const char *TSystem::GetLibraries(const char *regexp, const char *options,
2150{
2151 fListLibs.Clear();
2152
2153 TString libs;
2154 TString opt(options);
2155 Bool_t so2dylib = (opt.First('L') != kNPOS);
2156 if (so2dylib)
2157 opt.ReplaceAll("L", "");
2158
2159 if (opt.IsNull() || opt.First('D') != kNPOS)
2160 libs += gInterpreter->GetSharedLibs();
2161
2162 // Cint currently register all libraries that
2163 // are loaded and have a dictionary in them, this
2164 // includes all the libraries that are included
2165 // in the list of (hard) linked libraries.
2166
2168 const char *linked;
2169 if ((linked = GetLinkedLibraries())) {
2170 if (fLinkedLibs != LINKEDLIBS) {
2171 // This is not the default value, we need to keep the custom part.
2173 custom.ReplaceAll(LINKEDLIBS,linked);
2174 if (custom == fLinkedLibs) {
2175 // no replacement done, let's append linked
2176 slinked.Append(linked);
2177 slinked.Append(" ");
2178 }
2179 slinked.Append(custom);
2180 } else {
2181 slinked.Append(linked);
2182 }
2183 } else {
2184 slinked.Append(fLinkedLibs);
2185 }
2186
2187 if (opt.IsNull() || opt.First('S') != kNPOS) {
2188 // We are done, the statically linked libraries are already included.
2189 if (libs.Length() == 0) {
2190 libs = slinked;
2191 } else {
2192 // We need to add the missing linked library
2193
2194 static TString lastLinked;
2195 static TString lastAddMissing;
2196 if ( lastLinked != slinked ) {
2197 // Recalculate only if there was a change.
2198 static TRegexp separator("[^ \t\s]+");
2200 lastAddMissing.Clear();
2201
2202 Ssiz_t start, index, end;
2203 start = index = end = 0;
2204
2205 while ((start < slinked.Length()) && (index != kNPOS)) {
2206 index = slinked.Index(separator,&end,start);
2207 if (index >= 0) {
2208 TString sub = slinked(index,end);
2209 if (sub[0]=='-' && sub[1]=='L') {
2210 lastAddMissing.Prepend(" ");
2211 lastAddMissing.Prepend(sub);
2212 } else {
2213 if (libs.Index(sub) == kNPOS) {
2214 lastAddMissing.Prepend(" ");
2215 lastAddMissing.Prepend(sub);
2216 }
2217 }
2218 }
2219 start += end+1;
2220 }
2221 }
2222 libs.Prepend(lastAddMissing);
2223 }
2224 } else if (libs.Length() != 0) {
2225 // Let remove the statically linked library
2226 // from the list.
2227 static TRegexp separator("[^ \t\s]+");
2228 Ssiz_t start, index, end;
2229 start = index = end = 0;
2230
2231 while ((start < slinked.Length()) && (index != kNPOS)) {
2232 index = slinked.Index(separator,&end,start);
2233 if (index >= 0) {
2234 TString sub = slinked(index,end);
2235 if (sub[0]!='-' && sub[1]!='L') {
2236 libs.ReplaceAll(sub,"");
2237 }
2238 }
2239 start += end+1;
2240 }
2241 libs = libs.Strip(TString::kBoth);
2242 }
2243
2244 // Select according to regexp
2245 if (regexp && *regexp) {
2246 static TRegexp separator("[^ \t\s]+");
2247 TRegexp user_re(regexp, kTRUE);
2248 TString s;
2249 Ssiz_t start, index, end;
2250 start = index = end = 0;
2251
2252 while ((start < libs.Length()) && (index != kNPOS)) {
2253 index = libs.Index(separator,&end,start);
2254 if (index >= 0) {
2255 s = libs(index,end);
2256 if ((isRegexp && s.Index(user_re) != kNPOS) ||
2257 (!isRegexp && s.Index(regexp) != kNPOS)) {
2258 if (!fListLibs.IsNull())
2259 fListLibs.Append(" ");
2260 fListLibs.Append(s);
2261 }
2262 }
2263 start += end+1;
2264 }
2265 } else
2266 fListLibs = libs;
2267
2268#if defined(R__MACOSX)
2269// We need to remove the libraries that are dynamically loaded and not linked
2270{
2273
2274 static TRegexp separator("[^ \t\s]+");
2275 static TRegexp dynload("/lib-dynload/");
2276
2277 Ssiz_t start, index, end;
2278 start = index = end = 0;
2279
2280 while ((start < libs2.Length()) && (index != kNPOS)) {
2281 index = libs2.Index(separator, &end, start);
2282 if (index >= 0) {
2283 TString s = libs2(index, end);
2284 if (s.Index(dynload) == kNPOS) {
2285 if (!maclibs.IsNull()) maclibs.Append(" ");
2286 maclibs.Append(s);
2287 }
2288 }
2289 start += end+1;
2290 }
2292}
2293#endif
2294
2295 return fListLibs.Data();
2296}
2297
2298//---- RPC ---------------------------------------------------------------------
2299
2300////////////////////////////////////////////////////////////////////////////////
2301/// Get Internet Protocol (IP) address of host.
2302
2304{
2305 AbstractMethod("GetHostByName");
2306 return TInetAddress();
2307}
2308
2309////////////////////////////////////////////////////////////////////////////////
2310/// Get Internet Protocol (IP) address of remote host and port #.
2311
2313{
2314 AbstractMethod("GetPeerName");
2315 return TInetAddress();
2316}
2317
2318////////////////////////////////////////////////////////////////////////////////
2319/// Get Internet Protocol (IP) address of host and port #.
2320
2322{
2323 AbstractMethod("GetSockName");
2324 return TInetAddress();
2325}
2326
2327////////////////////////////////////////////////////////////////////////////////
2328/// Get port # of internet service.
2329
2331{
2332 AbstractMethod("GetServiceByName");
2333 return -1;
2334}
2335
2336////////////////////////////////////////////////////////////////////////////////
2337/// Get name of internet service.
2338
2340{
2341 AbstractMethod("GetServiceByPort");
2342 return nullptr;
2343}
2344
2345////////////////////////////////////////////////////////////////////////////////
2346/// Open a connection to another host.
2347
2348int TSystem::OpenConnection(const char *, int, int, const char *)
2349{
2350 AbstractMethod("OpenConnection");
2351 return -1;
2352}
2353
2354////////////////////////////////////////////////////////////////////////////////
2355/// Announce TCP/IP service.
2356
2358{
2359 AbstractMethod("AnnounceTcpService");
2360 return -1;
2361}
2362
2363////////////////////////////////////////////////////////////////////////////////
2364/// Announce UDP service.
2365
2367{
2368 AbstractMethod("AnnounceUdpService");
2369 return -1;
2370}
2371
2372////////////////////////////////////////////////////////////////////////////////
2373/// Announce unix domain service.
2374
2376{
2377 AbstractMethod("AnnounceUnixService");
2378 return -1;
2379}
2380
2381////////////////////////////////////////////////////////////////////////////////
2382/// Announce unix domain service.
2383
2384int TSystem::AnnounceUnixService(const char *, int)
2385{
2386 AbstractMethod("AnnounceUnixService");
2387 return -1;
2388}
2389
2390////////////////////////////////////////////////////////////////////////////////
2391/// Accept a connection.
2392
2394{
2395 AbstractMethod("AcceptConnection");
2396 return -1;
2397}
2398
2399////////////////////////////////////////////////////////////////////////////////
2400/// Close socket connection.
2401
2403{
2404 AbstractMethod("CloseConnection");
2405}
2406
2407////////////////////////////////////////////////////////////////////////////////
2408/// Receive exactly length bytes into buffer. Use opt to receive out-of-band
2409/// data or to have a peek at what is in the buffer (see TSocket).
2410
2411int TSystem::RecvRaw(int, void *, int, int)
2412{
2413 AbstractMethod("RecvRaw");
2414 return -1;
2415}
2416
2417////////////////////////////////////////////////////////////////////////////////
2418/// Send exactly length bytes from buffer. Use opt to send out-of-band
2419/// data (see TSocket).
2420
2421int TSystem::SendRaw(int, const void *, int, int)
2422{
2423 AbstractMethod("SendRaw");
2424 return -1;
2425}
2426
2427////////////////////////////////////////////////////////////////////////////////
2428/// Receive a buffer headed by a length indicator.
2429
2430int TSystem::RecvBuf(int, void *, int)
2431{
2432 AbstractMethod("RecvBuf");
2433 return -1;
2434}
2435
2436////////////////////////////////////////////////////////////////////////////////
2437/// Send a buffer headed by a length indicator.
2438
2439int TSystem::SendBuf(int, const void *, int)
2440{
2441 AbstractMethod("SendBuf");
2442 return -1;
2443}
2444
2445////////////////////////////////////////////////////////////////////////////////
2446/// Set socket option.
2447
2448int TSystem::SetSockOpt(int, int, int)
2449{
2450 AbstractMethod("SetSockOpt");
2451 return -1;
2452}
2453
2454////////////////////////////////////////////////////////////////////////////////
2455/// Get socket option.
2456
2457int TSystem::GetSockOpt(int, int, int*)
2458{
2459 AbstractMethod("GetSockOpt");
2460 return -1;
2461}
2462
2463//---- System, CPU and Memory info ---------------------------------------------
2464
2465////////////////////////////////////////////////////////////////////////////////
2466/// Returns static system info, like OS type, CPU type, number of CPUs
2467/// RAM size, etc into the SysInfo_t structure. Returns -1 in case of error,
2468/// 0 otherwise.
2469
2471{
2472 AbstractMethod("GetSysInfo");
2473 return -1;
2474}
2475
2476////////////////////////////////////////////////////////////////////////////////
2477/// Returns cpu load average and load info into the CpuInfo_t structure.
2478/// Returns -1 in case of error, 0 otherwise. Use sampleTime to set the
2479/// interval over which the CPU load will be measured, in ms (default 1000).
2480
2482{
2483 AbstractMethod("GetCpuInfo");
2484 return -1;
2485}
2486
2487////////////////////////////////////////////////////////////////////////////////
2488/// Returns ram and swap memory usage info into the MemInfo_t structure.
2489/// Returns -1 in case of error, 0 otherwise.
2490
2492{
2493 AbstractMethod("GetMemInfo");
2494 return -1;
2495}
2496
2497////////////////////////////////////////////////////////////////////////////////
2498/// Returns cpu and memory used by this process into the ProcInfo_t structure.
2499/// Returns -1 in case of error, 0 otherwise.
2500
2502{
2503 AbstractMethod("GetProcInfo");
2504 return -1;
2505}
2506
2507//---- Script Compiler ---------------------------------------------------------
2508
2510{
2511 // Assign the char* value to the TString and then delete it.
2512
2514 delete [] tobedeleted;
2515}
2516
2517#ifdef WIN32
2518
2519static TString R__Exec(const char *cmd)
2520{
2521 // Execute a command and return the stdout in a string.
2522
2523 FILE * f = gSystem->OpenPipe(cmd,"r");
2524 if (!f) {
2525 return "";
2526 }
2528
2529 char x;
2530 while ((x = fgetc(f))!=EOF ) {
2531 if (x=='\n' || x=='\r') break;
2532 result += x;
2533 }
2534
2535 fclose(f);
2536 return result;
2537}
2538
2539static void R__FixLink(TString &cmd)
2540{
2541 // Replace the call to 'link' by a full path name call based on where cl.exe is.
2542 // This prevents us from using inadvertently the link.exe provided by cygwin.
2543
2544 // check if link is the microsoft one...
2545 TString res = R__Exec("link 2>&1");
2546 if (res.Length()) {
2547 if (res.Contains("Microsoft (R) Incremental Linker"))
2548 return;
2549 }
2550 // else check availability of cygpath...
2551 res = R__Exec("cygpath . 2>&1");
2552 if (res.Length()) {
2553 if (res != ".")
2554 return;
2555 }
2556
2557 res = R__Exec("which cl.exe 2>&1|grep cl|sed 's,cl\.exe$,link\.exe,' 2>&1");
2558 if (res.Length()) {
2559 res = R__Exec(Form("cygpath -w '%s' 2>&1",res.Data()));
2560 if (res.Length()) {
2561 cmd.ReplaceAll(" link ",Form(" \"%s\" ",res.Data()));
2562 }
2563 }
2564}
2565#endif
2566
2567#if defined(__CYGWIN__)
2568static void R__AddPath(TString &target, const TString &path) {
2569 if (path.Length() > 2 && path[1]==':') {
2570 target += TString::Format("/cygdrive/%c",path[0]) + path(2,path.Length()-2);
2571 } else {
2572 target += path;
2573 }
2574}
2575#else
2576static void R__AddPath(TString &target, const TString &path) {
2577 target += path;
2578}
2579#endif
2580
2582 const TString &extension, const char *version_var_prefix, const TString &includes, const TString &defines, const TString &incPath)
2583{
2584 // Generate the dependency via standard output, not searching the
2585 // standard include directories,
2586
2587#ifndef WIN32
2588 const char * stderrfile = "/dev/null";
2589#else
2592#endif
2594
2595#ifdef WIN32
2596 TString touch = "echo # > "; touch += "\"" + depfilename + "\"";
2597#else
2598 TString touch = "echo > "; touch += "\"" + depfilename + "\"";
2599#endif
2600 TString builddep = "rmkdepend";
2602 builddep += " \"-f";
2604 builddep += "\" -o_" + extension + "." + gSystem->GetSoExt() + " ";
2605 if (build_loc.BeginsWith(gSystem->WorkingDirectory())) {
2607 if ( build_loc.Length() > (len+1) ) {
2608 builddep += " \"-p";
2609 if (build_loc[len] == '/' || build_loc[len+1] != '\' ) {
2610 // Since the path is now ran through TSystem::ExpandPathName the single \ is also possible.
2611 R__AddPath(builddep, build_loc.Data() + len + 1 );
2612 } else {
2613 // Case of dir\name
2614 R__AddPath(builddep, build_loc.Data() + len + 2 );
2615 }
2616 builddep += "/\" ";
2617 }
2618 } else {
2619 builddep += " \"-p";
2621 builddep += "/\" ";
2622 }
2623 builddep += " -Y -- ";
2625 builddep += " \"-I"+rootsysInclude+"\" "; // cflags
2626 builddep += includes;
2627 builddep += defines;
2628 builddep += " -- \"";
2629 builddep += filename;
2630 builddep += "\" ";
2632 if (library.BeginsWith(gSystem->WorkingDirectory())) {
2634 if ( library.Length() > (len+1) ) {
2635 if (library[len] == '/' || library[len+1] != '\' ) {
2636 targetname = library.Data() + len + 1;
2637 } else {
2638 targetname = library.Data() + len + 2;
2639 }
2640 } else {
2642 }
2643 } else {
2645 }
2646 builddep += " \"";
2647 builddep += "-t";
2649 builddep += "\" > ";
2651 builddep += " 2>&1 ";
2652
2653 TString adddictdep = "echo ";
2655 adddictdep += ": ";
2656#if defined(R__HAS_CLING_DICTVERSION)
2657 {
2658 char *clingdictversion = gSystem->Which(incPath,"clingdictversion.h");
2659 if (clingdictversion) {
2661 adddictdep += " ";
2662 delete [] clingdictversion;
2663 } else {
2664 R__AddPath(adddictdep,rootsysInclude+"/clingdictversion.h ");
2665 }
2666 }
2667#endif
2668 {
2669 const char *dictHeaders[] = { "RVersion.h", "ROOT/RConfig.hxx", "TClass.h",
2670 "TDictAttributeMap.h","TInterpreter.h","TROOT.h","TBuffer.h",
2671 "TMemberInspector.h","TError.h","RtypesImp.h","TIsAProxy.h",
2672 "TFileMergeInfo.h","TCollectionProxyInfo.h"};
2673
2674 for (unsigned int h=0; h < sizeof(dictHeaders)/sizeof(dictHeaders[0]); ++h)
2675 {
2677 if (rootVersion) {
2679 delete [] rootVersion;
2680 } else {
2682 }
2683 adddictdep += " ";
2684 }
2685 }
2686 {
2687 // Add dependency on rootcling.
2688 char *rootCling = gSystem->Which(gSystem->Getenv("PATH"),"rootcling");
2689 if (rootCling) {
2691 adddictdep += " ";
2692 delete [] rootCling;
2693 }
2694 }
2695 adddictdep += " >> \""+depfilename+"\"";
2696
2697 TString addversiondep( "echo ");
2698 addversiondep += libname + version_var_prefix + " \"" + ROOT_RELEASE + "\" >> \""+depfilename+"\"";
2699
2700 if (gDebug > 4) {
2701 ::Info("ACLiC", "%s", touch.Data());
2702 ::Info("ACLiC", "%s", builddep.Data());
2703 ::Info("ACLiC", "%s", adddictdep.Data());
2704 }
2705
2710
2711 if (!depbuilt) {
2712 ::Warning("ACLiC","Failed to generate the dependency file for %s",
2713 library.Data());
2714 } else {
2715#ifdef WIN32
2717#endif
2719 }
2720}
2721
2722////////////////////////////////////////////////////////////////////////////////
2723/// This method compiles and loads a shared library containing
2724/// the code from the file "filename".
2725///
2726/// The return value is true (1) in case of success and false (0)
2727/// in case of error.
2728///
2729/// The possible options are:
2730/// - k : keep the shared library after the session end.
2731/// - f : force recompilation.
2732/// - g : compile with debug symbol
2733/// - O : optimized the code
2734/// - c : compile only, do not attempt to load the library.
2735/// - s : silence all informational output
2736/// - v : output all information output
2737/// - d : debug ACLiC, keep all the output files.
2738/// - - : if buildir is set, use a flat structure (see buildir below)
2739///
2740/// If library_specified is specified, CompileMacro generates the file
2741/// "library_specified".soext where soext is the shared library extension for
2742/// the current platform.
2743///
2744/// If build_dir is specified, it is used as an alternative 'root' for the
2745/// generation of the shared library. The library is stored in a sub-directories
2746/// of 'build_dir' including the full pathname of the script unless a flat
2747/// directory structure is requested ('-' option). With the '-' option the libraries
2748/// are created directly in the directory 'build_dir'; in particular this means that
2749/// 2 scripts with the same name in different source directory will over-write each
2750/// other's library.
2751/// See also TSystem::SetBuildDir.
2752///
2753/// If dirmode is not zero and we need to create the target directory, the
2754/// file mode bit will be change to 'dirmode' using chmod.
2755///
2756/// If library_specified is not specified, CompileMacro generate a default name
2757/// for library by taking the name of the file "filename" but replacing the
2758/// dot before the extension by an underscore and by adding the shared
2759/// library extension for the current platform.
2760/// For example on most platform, hsimple.cxx will generate hsimple_cxx.so
2761///
2762/// It uses the directive fMakeSharedLibs to create a shared library.
2763/// If loading the shared library fails, it tries to output a list of missing
2764/// symbols by creating an executable (on some platforms like OSF, this does
2765/// not HAVE to be an executable) containing the script. It uses the
2766/// directive fMakeExe to do so.
2767/// For both directives, before passing them to TSystem::Exec, it expands the
2768/// variables $SourceFiles, $SharedLib, $LibName, $IncludePath, $LinkedLibs,
2769/// $DepLibs, $ExeName and $ObjectFiles. See SetMakeSharedLib() for more
2770/// information on those variables.
2771///
2772/// This method is used to implement the following feature:
2773///
2774/// Synopsis:
2775///
2776/// The purpose of this addition is to allow the user to use an external
2777/// compiler to create a shared library from its C++ macro (scripts).
2778/// Currently in order to execute a script, a user has to type at the root
2779/// prompt
2780/// ~~~ {.cpp}
2781/// .X myfunc.C(arg1,arg2)
2782/// ~~~
2783/// We allow them to type:
2784/// ~~~ {.cpp}
2785/// .X myfunc.C++(arg1,arg2)
2786/// ~~~
2787/// or
2788/// ~~~ {.cpp}
2789/// .X myfunc.C+(arg1,arg2)
2790/// ~~~
2791/// In which case an external compiler will be called to create a shared
2792/// library. This shared library will then be loaded and the function
2793/// myfunc will be called with the two arguments. With '++' the shared library
2794/// is always recompiled. With '+' the shared library is recompiled only
2795/// if it does not exist yet or the macro file is newer than the shared
2796/// library.
2797///
2798/// Of course the + and ++ notation is supported in similar way for .x and .L.
2799///
2800/// Through the function TSystem::SetMakeSharedLib(), the user will be able to
2801/// indicate, with shell commands, how to build a shared library (a good
2802/// default will be provided). The most common change, namely where to find
2803/// header files, will be available through the function
2804/// TSystem::SetIncludePath().
2805/// A good default will be provided so that a typical user session should be at
2806/// most:
2807/// ~~~ {.cpp}
2808/// root[1] gSystem->SetIncludePath("-I$ROOTSYS/include
2809/// -I$HOME/mypackage/include");
2810/// root[2] .x myfunc.C++(10,20);
2811/// ~~~
2812/// The user may sometimes try to compile a script before it has loaded all the
2813/// needed shared libraries. In this case we want to be helpful and output a
2814/// list of the unresolved symbols. So if the loading of the created shared
2815/// library fails, we will try to build a executable that contains the
2816/// script. The linker should then output a list of missing symbols.
2817///
2818/// To support this we provide a TSystem::SetMakeExe() function, that sets the
2819/// directive telling how to create an executable. The loader will need
2820/// to be informed of all the libraries available. The information about
2821/// the libraries that has been loaded by .L and TSystem::Load() is accessible
2822/// to the script compiler. However, the information about
2823/// the libraries that have been selected at link time by the application
2824/// builder (like the root libraries for root.exe) are not available and need
2825/// to be explicitly listed in fLinkedLibs (either by default or by a call to
2826/// TSystem::SetLinkedLibs()).
2827///
2828/// To simplify customization we could also add to the .rootrc support for the
2829/// variables
2830/// ~~~ {.cpp}
2831/// Unix.*.Root.IncludePath: -I$ROOTSYS/include
2832/// WinNT.*.Root.IncludePath: -I%ROOTSYS%/include
2833///
2834/// Unix.*.Root.LinkedLibs: -L$ROOTSYS/lib -lBase ....
2835/// WinNT.*.Root.LinkedLibs: %ROOTSYS%/lib/*.lib msvcrt.lib ....
2836/// ~~~
2837/// And also support for MakeSharedLibs() and MakeExe().
2838///
2839/// (the ... have to be replaced by the actual values and are here only to
2840/// shorten this comment).
2841///
2842/// Note that the default behavior is to remove libraries when closing ROOT,
2843/// ie TSystem::CleanCompiledMacros() is called in the TROOT destructor.
2844/// The default behavior of .L script.C+ is the opposite one, leaving things
2845/// after closing, without removing. In other words, .L always passes the 'k'
2846/// option behind the scenes.
2847
2849 const char *library_specified,
2850 const char *build_dir,
2852{
2853 static const char *version_var_prefix = "__ROOTBUILDVERSION=";
2854
2855 // ======= Analyze the options
2856 Bool_t keep = kFALSE;
2858 int mode = fAclicMode;
2861 Bool_t verbose = kFALSE;
2863 if (opt) {
2864 keep = (strchr(opt,'k')!=nullptr);
2865 recompile = (strchr(opt,'f')!=nullptr);
2866 if (strchr(opt,'O')!=nullptr) {
2867 mode |= kOpt;
2868 }
2869 if (strchr(opt,'g')!=nullptr) {
2870 mode |= kDebug;
2871 }
2872 if (strchr(opt,'c')!=nullptr) {
2873 loadLib = kFALSE;
2874 }
2875 withInfo = strchr(opt, 's') == nullptr;
2876 verbose = strchr(opt, 'v') != nullptr;
2877 internalDebug = strchr(opt, 'd') != nullptr;
2878 }
2879 if (mode==kDefault) {
2881 if (rootbuild.Index("debug",0,TString::kIgnoreCase)==kNPOS) {
2882 mode = kOpt;
2883 } else {
2884 mode = kDebug;
2885 }
2886 }
2887 UInt_t verboseLevel = verbose ? 7 : gDebug;
2888 Bool_t flatBuildDir = (fAclicProperties & kFlatBuildDir) || (opt && strchr(opt,'-')!=nullptr);
2889
2890 // if non-zero, build_loc indicates where to build the shared library.
2893 if (build_loc == ".") {
2895 } else if (build_loc.Length() && (!IsAbsoluteFileName(build_loc)) ) {
2897 }
2898
2899 // Get the include directory list in the dir1:dir2:dir3 format
2900 // [Used for generating the .d file and to look for header files for
2901 // the linkdef file]
2902 TString incPath = GetIncludePath(); // of the form -Idir1 -Idir2 -Idir3
2903 incPath.Append(":").Prepend(" ");
2904 if (gEnv) {
2905 TString fromConfig = gEnv->GetValue("ACLiC.IncludePaths","");
2906 incPath.Append(fromConfig);
2907 }
2908 incPath.ReplaceAll(" -I",":"); // of form :dir1 :dir2:dir3
2909 auto posISysRoot = incPath.Index(" -isysroot \"");
2910 if (posISysRoot != kNPOS) {
2911 auto posISysRootEnd = incPath.Index('"', posISysRoot + 12);
2912 if (posISysRootEnd != kNPOS) {
2913 // NOTE: should probably just skip isysroot for dependency analysis.
2914 // (And will, in the future - once we rely on compiler-generated .d files.)
2915 incPath.Insert(posISysRootEnd - 1, "/usr/include/");
2916 incPath.Replace(posISysRoot, 12, ":\"");
2917 }
2918 }
2919 while ( incPath.Index(" :") != -1 ) {
2920 incPath.ReplaceAll(" :",":");
2921 }
2922 incPath.Prepend(":.:");
2923 incPath.Prepend(WorkingDirectory());
2924
2925 // ======= Get the right file names for the dictionary and the shared library
2931 {
2932 const char *whichlibrary = Which(incPath,library);
2933 if (whichlibrary) {
2935 delete [] whichlibrary;
2936 } else {
2937 ::Error("ACLiC","The file %s can not be found in the include path: %s",filename,incPath.Data());
2938 return kFALSE;
2939 }
2940 } else {
2942 ::Error("ACLiC","The file %s can not be found.",filename);
2943 return kFALSE;
2944 }
2945 }
2946 { // Remove multiple '/' characters, rootcling treats them as comments.
2947 Ssiz_t pos = 0;
2948 while ((pos = library.Index("//", 2, pos, TString::kExact)) != kNPOS) {
2949 library.Remove(pos, 1);
2950 }
2951 }
2954
2956 // For some probably good reason, DirName on Windows returns the 'name' of
2957 // the directory, omitting the drive letter (even if there was one). In
2958 // consequence the result is not usable as a 'root directory', we need to
2959 // add the drive letter if there was one..
2960 if (library.Length()>1 && isalpha(library[0]) && library[1]==':') {
2961 file_dirname.Prepend(library(0,2));
2962 }
2963 TString file_location( file_dirname ); // Location of the script.
2964 incPath.Prepend( file_location + ":" );
2965
2966 Ssiz_t dot_pos = library.Last('.');
2968 if (dot_pos >= 0) {
2969 libname_noext.Remove(dot_pos);
2970 extension = library(dot_pos+1, library.Length()-dot_pos-1);
2971 }
2972
2973 // Extension of shared library is platform dependent!!
2974 TString suffix = TString("_") + extension + "." + fSoExt;
2975 if (dot_pos >= 0)
2976 library.Replace( dot_pos, library.Length()-dot_pos, suffix);
2977 else
2978 library.Append(suffix);
2979
2981 libname.Append("_").Append(extension);
2982
2984 // Use the specified name instead of the default
2988 if (! IsAbsoluteFileName(library) ) {
2990 }
2992 library = TString(library) + "." + fSoExt;
2993 }
2995
2997 libname_ext += "." + fSoExt;
2998
3000 // For some probably good reason, DirName on Windows returns the 'name' of
3001 // the directory, omitting the drive letter (even if there was one). In
3002 // consequence the result is not useable as a 'root directory', we need to
3003 // add the drive letter if there was one..
3004 if (library.Length()>1 && isalpha(library[0]) && library[1]==':') {
3005 lib_dirname.Prepend(library(0,2));
3006 }
3007 // Strip potential, somewhat redundant '/.' from the pathname ...
3008 if ( strncmp( &(lib_dirname[lib_dirname.Length()-2]), "/.", 2) == 0 ) {
3009 lib_dirname.Remove(lib_dirname.Length()-2);
3010 }
3011 if ( strncmp( &(lib_dirname[lib_dirname.Length()-2]), "\.", 2) == 0 ) {
3012 lib_dirname.Remove(lib_dirname.Length()-2);
3013 }
3016
3017 if (build_loc.Length()==0) {
3019 } else {
3020 // Removes an existing disk specification from the names
3021 TRegexp disk_finder ("[A-z]:");
3022 Int_t pos = library.Index( disk_finder );
3023 if (pos==0) library.Remove(pos,3);
3024 pos = lib_location.Index( disk_finder );
3025 if (pos==0) lib_location.Remove(pos,3);
3026
3027 if (flatBuildDir) {
3029 } else {
3031 }
3032
3035 if (!flatBuildDir) {
3037 }
3038
3040 mkdirFailed = (0 != mkdir(build_loc, true));
3042 // The mkdir failed __and__ we can not write to the target directory,
3043 // let make sure the error message will be about the target directory
3046 } else if (!mkdirFailed && dirmode!=0) {
3048 }
3049 }
3050 }
3052
3053 // ======= Check if the library need to loaded or compiled
3054 if (!gInterpreter->IsLibraryLoaded(library) && gInterpreter->IsLoaded(expFileName)) {
3055 // the script has already been loaded in interpreted mode
3056 // Let's warn the user and unload it.
3057
3058 if (withInfo) {
3059 ::Info("ACLiC","script has already been loaded in interpreted mode");
3060 ::Info("ACLiC","unloading %s and compiling it", filename);
3061 }
3062
3063 if ( gInterpreter->UnloadFile( expFileName ) != 0 ) {
3064 // We can not unload it.
3065 return kFALSE;
3066 }
3067 }
3068
3069 // Calculate the -I lines
3071 includes.ReplaceAll("-I ", "-I");
3072 includes.Prepend(' ');
3073
3074 {
3075 // I need to replace the -Isomerelativepath by -I../ (or -I..\ on NT)
3076 TRegexp rel_inc(" -I[^\"/\\$\%-][^:\s]+");
3077 Int_t len,pos;
3078 pos = rel_inc.Index(includes,&len);
3079 while( len != 0 ) {
3080 TString sub = includes(pos,len);
3081 sub.Remove(0,3); // Remove ' -I'
3083 sub.Prepend(" -I\"");
3084 if (sub.EndsWith(" "))
3085 sub.Chop(); // Remove trailing space (i.e between the -Is ...
3086 sub.Append("\" ");
3087 includes.Replace(pos,len,sub);
3088 pos = rel_inc.Index(includes,&len);
3089 }
3090 }
3091 {
3092 // I need to replace the -I"somerelativepath" by -I"$cwd/ (or -I"$cwd\ on NT)
3093 TRegexp rel_inc(" -I\"[^/\\$\%-][^:\s]+");
3094 Int_t len,pos;
3095 pos = rel_inc.Index(includes,&len);
3096 while( len != 0 ) {
3097 TString sub = includes(pos,len);
3098 sub.Remove(0,4); // Remove ' -I"'
3100 sub.Prepend(" -I\"");
3101 includes.Replace(pos,len,sub);
3102 pos = rel_inc.Index(includes,&len);
3103 }
3104 }
3105 //includes += " -I\"" + build_loc;
3106 //includes += "\" -I\"";
3107 //includes += WorkingDirectory();
3108// if (includes[includes.Length()-1] == '\') {
3109// // The current directory is (most likely) the root of a windows drive and
3110// // has a trailing \ which would espace the quote if left by itself.
3111// includes += '\';
3112// }
3113// includes += "\"";
3114 if (gEnv) {
3115 TString fromConfig = gEnv->GetValue("ACLiC.IncludePaths","");
3116 includes.Append(" ").Append(fromConfig).Append(" ");
3117 }
3118
3119 // Extract the -D for the dependency generation.
3120 TString defines = " ";
3121 {
3123 TRegexp rel_def("-D[^\s\t\n\r]*");
3124 Int_t len,pos;
3125 pos = rel_def.Index(cmd,&len);
3126 while( len != 0 ) {
3127 defines += cmd(pos,len);
3128 defines += " ";
3129 pos = rel_def.Index(cmd,&len,pos+1);
3130 }
3131
3132 }
3133
3135 {
3137 if (ug) {
3139 delete ug;
3140 } else {
3142 }
3143 }
3144
3146
3148
3149 // Generate the dependency filename
3153 depfilename += "_" + extension + ".d";
3154
3155 if ( !recompile ) {
3156
3158
3159 if ((gSystem->GetPathInfo( library, nullptr, (Long_t*)nullptr, nullptr, &lib_time ) != 0) ||
3160 (gSystem->GetPathInfo( expFileName, nullptr, (Long_t*)nullptr, nullptr, &file_time ) == 0 &&
3161 (lib_time < file_time))) {
3162
3163 // the library does not exist or is older than the script.
3164 recompile = kTRUE;
3165 modified = kTRUE;
3166
3167 } else {
3168
3169 if ( gSystem->GetPathInfo( depfilename, nullptr,(Long_t*) nullptr, nullptr, &file_time ) != 0 ) {
3170 if (!canWrite) {
3173 depfilename += "_" + extension + ".d";
3174 }
3176 }
3177 }
3178
3179 if (!modified) {
3180
3181 // We need to check the dependencies
3182 FILE * depfile = fopen(depfilename.Data(),"r");
3183 if (depfile==nullptr) {
3184 // there is no accessible dependency file, let's assume the library has been
3185 // modified
3186 modified = kTRUE;
3187 recompile = kTRUE;
3188
3189 } else {
3190
3192
3193 Int_t sz = 256;
3194 char *line = new char[sz];
3195 line[0] = 0;
3196
3197 int c;
3198 Int_t current = 0;
3199 Int_t nested = 0;
3200 Bool_t hasversion = false;
3201
3202 while ((c = fgetc(depfile)) != EOF) {
3203 if (c=='#') {
3204 // skip comment
3205 while ((c = fgetc(depfile)) != EOF) {
3206 if (c=='\n') {
3207 break;
3208 }
3209 }
3210 continue;
3211 }
3212 if (current && line[current-1]=='=' && strncmp(version_var.Data(),line,current)==0) {
3213
3214 // The next word will be the version number.
3215 hasversion = kTRUE;
3216 line[0] = 0;
3217 current = 0;
3218 } else if (isspace(c) && !nested) {
3219 if (current) {
3220 if (line[current-1]!=':') {
3221 // ignore target
3222 line[current] = 0;
3223
3225 if (hasversion) {
3228 } else if ( gSystem->GetPathInfo( line, nullptr, (Long_t*)nullptr, nullptr, &filetime ) == 0 ) {
3229 modified |= ( lib_time <= filetime );
3230 }
3231 }
3232 }
3233 current = 0;
3234 line[0] = 0;
3235 } else {
3236 if (current==sz-1) {
3237 sz = 2*sz;
3238 char *newline = new char[sz];
3239 memcpy(newline,line, current);
3240 delete [] line;
3241 line = newline;
3242 }
3243 if (c=='"') nested = !nested;
3244 else {
3245 line[current] = c;
3246 current++;
3247 }
3248 }
3249 }
3250 delete [] line;
3251 fclose(depfile);
3253
3254 }
3255
3256 }
3257 }
3258
3259 if ( gInterpreter->IsLibraryLoaded(library)
3260 || strlen(GetLibraries(library,"D",kFALSE)) != 0 ) {
3261 // The library has already been built and loaded.
3262
3263 Bool_t reload = kFALSE;
3265 if (libinfo) {
3266 Long_t load_time = libinfo->GetUniqueID();
3268 if ( gSystem->GetPathInfo( library, nullptr, (Long_t*)nullptr, nullptr, &lib_time ) == 0
3269 && (lib_time>load_time)) {
3270 reload = kTRUE;
3271 }
3272 }
3273
3274 if ( !recompile && reload ) {
3275
3276 if (withInfo) {
3277 ::Info("ACLiC","%s has been modified and will be reloaded",
3278 libname.Data());
3279 }
3280 if ( gInterpreter->UnloadFile( library.Data() ) != 0 ) {
3281 // The library is being used. We can not unload it.
3282 return kFALSE;
3283 }
3284 if (libinfo) {
3286 delete libinfo;
3287 libinfo = nullptr;
3288 }
3289 TNamed *k = new TNamed(library,library);
3291 gSystem->GetPathInfo( library, nullptr, (Long_t*)nullptr, nullptr, &lib_time );
3293 if (!keep) k->SetBit(kMustCleanup);
3294 fCompiled->Add(k);
3295
3296 return !gSystem->Load(library);
3297 }
3298
3299 if (withInfo) {
3300 ::Info("ACLiC","%s script has already been compiled and loaded",
3301 modified ? "modified" : "unmodified");
3302 }
3303
3304 if ( !recompile ) {
3305 return kTRUE;
3306 } else {
3307 if (withInfo) {
3308 ::Info("ACLiC","it will be regenerated and reloaded!");
3309 }
3310 if ( gInterpreter->UnloadFile( library.Data() ) != 0 ) {
3311 // The library is being used. We can not unload it.
3312 return kFALSE;
3313 }
3314 if (libinfo) {
3316 delete libinfo;
3317 libinfo = nullptr;
3318 }
3319 Unlink(library);
3320 }
3321
3322 }
3323
3326 libmapfilename += ".rootmap";
3327#if (defined(R__MACOSX) && !defined(MAC_OS_X_VERSION_10_5)) || defined(R__WIN32)
3329#else
3331#endif
3333 if (gEnv) {
3334#if (defined(R__MACOSX) && !defined(MAC_OS_X_VERSION_10_5))
3335 Int_t linkLibs = gEnv->GetValue("ACLiC.LinkLibs",2);
3336#elif defined(R__WIN32)
3337 Int_t linkLibs = gEnv->GetValue("ACLiC.LinkLibs",3);
3338#else
3339 Int_t linkLibs = gEnv->GetValue("ACLiC.LinkLibs",1);
3340#endif
3341 produceRootmap = linkLibs & 0x2;
3342 linkDepLibraries = linkLibs & 0x1;
3343 }
3344
3345 // FIXME: Triggers clang false positive warning -Wunused-lambda-capture.
3346 /*constexpr const*/ bool useCxxModules =
3347#ifdef R__USE_CXXMODULES
3348 true;
3349#else
3350 false;
3351#endif
3352
3353 // FIXME: Switch to generic polymorphic when we make c++14 default.
3354 auto ForeachSharedLibDep = [](const char *lib, std::function<bool(const char *)> f) {
3355 using std::string, std::vector, std::istringstream, std::istream_iterator;
3356 string deps = gInterpreter->GetSharedLibDeps(lib, /*tryDyld*/ true);
3357 istringstream iss(deps);
3359 // Skip the first element: it is a relative path to `lib`.
3360 for (auto I = libs.begin() + 1, E = libs.end(); I != E; ++I)
3361 if (!f(I->c_str()))
3362 break;
3363 };
3365 // We have no rootmap files or modules to construct `-l` flags enabling
3366 // explicit linking. We have to resolve the dependencies by ourselves
3367 // taking the job of the dyld.
3368 // FIXME: This is a rare case where we have rootcling running with
3369 // modules disabled. Remove this code once we fully switch to modules,
3370 // or implement a special flag in rootcling which selective enables
3371 // modules for dependent libraries and does not produce a module for
3372 // the ACLiC library.
3373 if (useCxxModules && !produceRootmap) {
3374 std::function<bool(const char *)> LoadLibF = [](const char *dep) {
3375 return gInterpreter->Load(dep, /*skipReload*/ true) >= 0;
3376 };
3378 }
3379 return !gSystem->Load(lib);
3380 };
3381
3382 if (!recompile) {
3383 // The library already exist, let's just load it.
3384 if (loadLib) {
3385 TNamed *k = new TNamed(library,library);
3387 gSystem->GetPathInfo( library, nullptr, (Long_t*)nullptr, nullptr, &lib_time );
3389 if (!keep) k->SetBit(kMustCleanup);
3390 fCompiled->Add(k);
3391
3392 gInterpreter->GetSharedLibDeps(library);
3393
3394 return LoadLibrary(library);
3395 }
3396 else return kTRUE;
3397 }
3398
3399 if (!canWrite && recompile) {
3400
3401 if (mkdirFailed) {
3402 ::Warning("ACLiC","Could not create the directory: %s",
3403 build_loc.Data());
3404 } else {
3405 ::Warning("ACLiC","%s is not writable!",
3406 build_loc.Data());
3407 }
3408 if (emergency_loc == build_dir ) {
3409 ::Error("ACLiC","%s is the last resort location (i.e. temp location)",build_loc.Data());
3410 return kFALSE;
3411 }
3412 ::Warning("ACLiC","Output will be written to %s",
3413 emergency_loc.Data());
3415 }
3416
3417 if (withInfo) {
3418 Info("ACLiC","creating shared library %s",library.Data());
3419 }
3420
3422
3423 // ======= Select the dictionary name
3424 TString dict = libname + "_ACLiC_dict";
3425
3426 // the file name end up in the file produced
3427 // by rootcling as a variable name so all character need to be valid!
3428 static const int maxforbidden = 27;
3429 static const char *forbidden_chars[maxforbidden] =
3430 { "+","-","*","/","&","%","|","^",">","<",
3431 "=","~",".","(",")","[","]","!",",","$",
3432 " ",":","'","#","@","\","\"" };
3433 for( int ic = 0; ic < maxforbidden; ic++ ) {
3434 dict.ReplaceAll( forbidden_chars[ic],"_" );
3435 }
3436 if ( dict.Last('.')!=dict.Length()-1 ) dict.Append(".");
3437 AssignAndDelete( dict, ConcatFileName( build_loc, dict ) );
3438 TString dicth = dict;
3439 TString dictObj = dict;
3440 dict += "cxx"; //no need to keep the extension of the original file, any extension will do
3441 dicth += "h";
3442 dictObj += fObjExt;
3443
3444 // ======= Generate a linkdef file
3445
3448 linkdef += "_ACLiC_linkdef.h";
3449 std::ofstream linkdefFile( linkdef, std::ios::out );
3450 linkdefFile << "// File Automatically generated by the ROOT Script Compiler "
3451 << std::endl;
3452 linkdefFile << std::endl;
3453 linkdefFile << "#ifdef __CINT__" << std::endl;
3454 linkdefFile << std::endl;
3455 linkdefFile << "#pragma link C++ nestedclasses;" << std::endl;
3456 linkdefFile << "#pragma link C++ nestedtypedefs;" << std::endl;
3457 linkdefFile << std::endl;
3458
3459 // We want to look for a header file that has the same name as the macro
3460
3461 const char * extensions[] = { ".h", ".hh", ".hpp", ".hxx", ".hPP", ".hXX" };
3462
3463 int i;
3464 for (i = 0; i < 6; i++ ) {
3465 char * name;
3468 extra_linkdef.Append(extensions[i]);
3470 if (name) {
3471 if (verboseLevel>4 && withInfo) {
3472 Info("ACLiC","including extra linkdef file: %s",name);
3473 }
3474 linkdefFile << "#include \"" << name << "\"" << std::endl;
3475 delete [] name;
3476 }
3477 }
3478
3479 if (verboseLevel>5 && withInfo) {
3480 Info("ACLiC","looking for header in: %s",incPath.Data());
3481 }
3482 for (i = 0; i < 6; i++ ) {
3483 char * name;
3484 TString lookup = BaseName( libname_noext );
3485 lookup.Append(extensions[i]);
3486 name = Which(incPath,lookup);
3487 if (name) {
3488 linkdefFile << "#pragma link C++ defined_in "<<gSystem->UnixPathName(name)<<";"<< std::endl;
3489 delete [] name;
3490 }
3491 }
3492 linkdefFile << "#pragma link C++ defined_in \""<<filename_fullpath << "\";" << std::endl;
3493 linkdefFile << std::endl;
3494 linkdefFile << "#endif" << std::endl;
3495 linkdefFile.close();
3496 // ======= Generate the list of rootmap files to be looked at
3497
3500 mapfile += "_ACLiC_map";
3501 TString mapfilein = mapfile + ".in";
3502 TString mapfileout = mapfile + ".out";
3503
3505 if (!useCxxModules) {
3506 if (gInterpreter->GetSharedLibDeps(library) != nullptr) {
3507 gInterpreter->UnloadLibraryMap(libname);
3509 }
3510 }
3511
3512 std::ofstream mapfileStream( mapfilein, std::ios::out );
3513 {
3514 TString name = ".rootmap";
3515 TString sname = "system.rootmap";
3516 TString file;
3518 if (gSystem->AccessPathName(file)) {
3519 // for backward compatibility check also $ROOTSYS/system<name> if
3520 // $ROOTSYS/etc/system<name> does not exist
3522 if (gSystem->AccessPathName(file)) {
3523 // for backward compatibility check also $ROOTSYS/<name> if
3524 // $ROOTSYS/system<name> does not exist
3526 }
3527 }
3528 mapfileStream << file << std::endl;
3530 mapfileStream << file << std::endl;
3531 mapfileStream << name << std::endl;
3532 if (gInterpreter->GetRootMapFiles()) {
3533 for (i = 0; i < gInterpreter->GetRootMapFiles()->GetEntriesFast(); i++) {
3534 mapfileStream << ((TNamed*)gInterpreter->GetRootMapFiles()->At(i))->GetTitle() << std::endl;
3535 }
3536 }
3537 }
3538 mapfileStream.close();
3539
3540 // ======= Generate the rootcling command line
3541 TString rcling = "rootcling";
3543 rcling += " \"--lib-list-prefix=";
3544 rcling += mapfile;
3545 rcling += "\" -f \"";
3546 rcling.Append(dict).Append("\" ");
3547
3548 if (produceRootmap && !useCxxModules) {
3549 rcling += " -rml " + libname + " -rmf \"" + libmapfilename + "\" ";
3550 rcling.Append("-DR__ACLIC_ROOTMAP ");
3551 }
3552 rcling.Append(GetIncludePath()).Append(" -D__ACLIC__ ");
3553 if (gEnv) {
3554 TString fromConfig = gEnv->GetValue("ACLiC.IncludePaths","");
3555 rcling.Append(fromConfig);
3556 TString extraFlags = gEnv->GetValue("ACLiC.ExtraRootclingFlags","");
3557 if (!extraFlags.IsNull()) {
3558 extraFlags.Prepend(" ");
3559 extraFlags.Append(" ");
3560 rcling.Append(extraFlags);
3561 }
3562 }
3563
3564 // Create a modulemap
3565 // FIXME: Merge the modulemap generation from cmake and here in rootcling.
3567 rcling += " -cxxmodule ";
3568 // TString moduleMapFileName = file_dirname + "/" + libname + ".modulemap";
3569 TString moduleName = libname + "_ACLiC_dict";
3570 if (moduleName.BeginsWith("lib"))
3571 moduleName = moduleName.Remove(0, 3);
3572 TString moduleMapName = moduleName + ".modulemap";
3574 // A modulemap may exist from previous runs, overwrite it.
3576 ::Info("ACLiC", "File %s already exists!", moduleMapFullPath.Data());
3577
3580 std::ofstream moduleMapFile(moduleMapFullPath, std::ios::out);
3581 moduleMapFile << "module \"" << moduleName << "\" {" << std::endl;
3582 moduleMapFile << " header \"" << relative_path << "\"" << std::endl;
3583 moduleMapFile << " export *" << std::endl;
3584 moduleMapFile << " link \"" << libname_ext << "\"" << std::endl;
3585 moduleMapFile << "}" << std::endl;
3586 moduleMapFile.close();
3587 gInterpreter->RegisterPrebuiltModulePath(build_loc.Data(), moduleMapName.Data());
3588 rcling.Append(" \"-moduleMapFile=" + moduleMapFullPath + "\" ");
3589 }
3590
3591 rcling.Append(" \"").Append(filename_fullpath).Append("\" ");
3592 rcling.Append("\"").Append(linkdef).Append("\"");
3593
3594 // ======= Run rootcling
3595 if (withInfo) {
3596 if (verboseLevel>3) {
3597 ::Info("ACLiC","creating the dictionary files");
3598 if (verboseLevel>4) ::Info("ACLiC", "%s", rcling.Data());
3599 }
3600 }
3601
3602 ///\returns true on success.
3603 auto ExecAndReport = [](TString cmd) -> bool {
3605 if (result) {
3606 if (result == 139)
3607 ::Error("ACLiC", "Executing '%s' failed with a core dump!", cmd.Data());
3608 else
3609 ::Error("ACLiC", "Executing '%s' failed!", cmd.Data());
3610 }
3611 return !result;
3612 };
3613
3616
3617 // ======= Load the library the script might depend on
3618 if (result) {
3619 TString linkedlibs = GetLibraries("", "S");
3622 std::ifstream liblist(mapfileout);
3623
3624 while ( liblist >> libtoload ) {
3625 // Load the needed library except for the library we are currently building!
3626 if (libtoload == "#") {
3627 // The comment terminates the list of libraries.
3628 std::string toskipcomment;
3629 std::getline(liblist,toskipcomment);
3630 break;
3631 }
3633 if (produceRootmap) {
3634 if (loadLib || linkDepLibraries /* For GetLibraries to Work */) {
3635 result = gROOT->LoadClass("", libtoload) >= 0;
3636 if (!result) {
3637 // We failed to load one of the dependency.
3638 break;
3639 }
3640 }
3641 if (!linkedlibs.Contains(libtoload)) {
3642 all_libtoload.Append(" ").Append(libtoload);
3643 depLibraries.Append(" ");
3645 depLibraries = depLibraries.Strip(); // Remove any trailing spaces.
3646 }
3647 } else {
3648 gROOT->LoadClass("", libtoload);
3649 }
3650 }
3651 unsigned char c = liblist.peek();
3652 if (c=='\n' || c=='\r') {
3653 // Consume the character
3654 liblist.get();
3655 break;
3656 }
3657 }
3658
3659// depLibraries = all_libtoload;
3660// depLibraries.ReplaceAll(" lib"," -l");
3661// depLibraries.ReplaceAll(TString::Format(".%s",fSoExt.Data()),"");
3662 }
3663
3664 // ======= Calculate the libraries for linking:
3666 /*
3667 this is intentionally disabled until it can become useful
3668 if (gEnv) {
3669 linkLibraries = gEnv->GetValue("ACLiC.Libraries","");
3670 linkLibraries.Prepend(" ");
3671 }
3672 */
3674 // We need to enclose the single paths in quotes to account for paths with spaces
3678 std::unique_ptr<TObjArray> tokens( linkLibrariesNoQuotes.Tokenize(" ") );
3679 for (auto tokenObj : *tokens) {
3680 singleLibrary = ((TObjString*)tokenObj)->GetString();
3681 if (singleLibrary[0]=='-' || !AccessPathName(singleLibrary)) {
3683 librariesWithQuotes.Chop();
3684 librariesWithQuotes += "\" \"" + singleLibrary + "\"";
3686 } else {
3687 librariesWithQuotes += " \"" + singleLibrary + "\"";
3688 }
3689 } else {
3692 } else {
3694 librariesWithQuotes += " \"" + singleLibrary + " ";
3695 }
3696 }
3697 }
3698
3699#ifdef _MSC_VER
3701#else
3703#endif
3704
3705 // ======= Generate the build command lines
3707 // we do not add filename because it is already included via the dictionary(in dicth) !
3708 // dict.Append(" ").Append(filename);
3709 cmd.ReplaceAll("$SourceFiles","-D__ACLIC__ \"$SourceFiles\"");
3710 cmd.ReplaceAll("$SourceFiles",dict);
3711 cmd.ReplaceAll("$ObjectFiles","\"$ObjectFiles\"");
3712 cmd.ReplaceAll("$ObjectFiles",dictObj);
3713 cmd.ReplaceAll("$IncludePath",includes);
3714 cmd.ReplaceAll("$SharedLib","\"$SharedLib\"");
3715 cmd.ReplaceAll("$SharedLib",library);
3716 if (linkDepLibraries) {
3717 if (produceRootmap) {
3718 cmd.ReplaceAll("$DepLibs",depLibraries);
3719 } else {
3720 cmd.ReplaceAll("$DepLibs",linkLibraries);
3721 }
3722 }
3723 cmd.ReplaceAll("$LinkedLibs",linkLibraries);
3724 cmd.ReplaceAll("$LibName",libname);
3725 cmd.ReplaceAll("\"$BuildDir","$BuildDir");
3726 cmd.ReplaceAll("$BuildDir","\"$BuildDir\"");
3727 cmd.ReplaceAll("$BuildDir",build_loc);
3729 if (mode & kDebug)
3730 optdebFlags = fFlagsDebug + " ";
3731 if (mode & kOpt)
3733 cmd.ReplaceAll("$Opt", optdebFlags);
3734#ifdef WIN32
3735 R__FixLink(cmd);
3736 cmd.ReplaceAll("-std=", "-std:");
3737#endif
3738
3742 fakeMain += "_ACLiC_main";
3744 std::ofstream fakeMainFile( fakeMain, std::ios::out );
3745 fakeMainFile << "// File Automatically generated by the ROOT Script Compiler "
3746 << std::endl;
3747 fakeMainFile << "int main(char*argc,char**argvv) {};" << std::endl;
3748 fakeMainFile.close();
3749 // We could append this fake main routine to the compilation line.
3750 // But in this case compiler may output the name of the dictionary file
3751 // and of the fakeMain file while it compiles it. (this would be useless
3752 // confusing output).
3753 // We could also the fake main routine to the end of the dictionary file
3754 // however compilation would fail if a main is already there
3755 // (like stress.cxx)
3756 // dict.Append(" ").Append(fakeMain);
3757 TString exec;
3759 exec += "_ACLiC_exec";
3760 testcmd.ReplaceAll("$SourceFiles","-D__ACLIC__ \"$SourceFiles\"");
3761 testcmd.ReplaceAll("$SourceFiles",dict);
3762 testcmd.ReplaceAll("$ObjectFiles","\"$ObjectFiles\"");
3763 testcmd.ReplaceAll("$ObjectFiles",dictObj);
3764 testcmd.ReplaceAll("$IncludePath",includes);
3765 testcmd.ReplaceAll("$ExeName",exec);
3766 testcmd.ReplaceAll("$LinkedLibs",linkLibraries);
3767 testcmd.ReplaceAll("$BuildDir",build_loc);
3768 if (mode==kDebug)
3769 testcmd.ReplaceAll("$Opt",fFlagsDebug);
3770 else
3771 testcmd.ReplaceAll("$Opt",fFlagsOpt);
3772
3773#ifdef WIN32
3775 testcmd.ReplaceAll("-std=", "-std:");
3776#endif
3777
3778 // ======= Build the library
3779 if (result) {
3781#ifdef R__MACOSX
3782 // Allow linking to succeed despite the missing symbols.
3783 cmdAllowUnresolved.ReplaceAll("-dynamiclib", "-dynamiclib -Wl,-w -Wl,-undefined,dynamic_lookup");
3784#endif
3785 if (verboseLevel > 3 && withInfo) {
3786 ::Info("ACLiC","compiling the dictionary and script files");
3787 if (verboseLevel>4)
3788 ::Info("ACLiC", "%s", cmdAllowUnresolved.Data());
3789 }
3791 if (!success) {
3792 if (produceRootmap) {
3794 }
3795 }
3796 result = success;
3797 }
3798
3799 if ( result ) {
3800 if (linkDepLibraries) {
3801 // We may have unresolved symbols. Use dyld to resolve the dependent
3802 // libraries and relink.
3803 // FIXME: We will likely have duplicated libraries as we are appending
3804 // FIXME: This likely makes rootcling --lib-list-prefix redundant.
3806 std::function<bool(const char *)> CollectF = [&depLibsFullPaths](const char *dep) {
3808 if (!gSystem->FindDynamicLibrary(LibFullPath, /*quiet=*/true)) {
3809 ::Error("TSystem::CompileMacro", "Cannot find library '%s'", dep);
3810 return false; // abort
3811 }
3813 return true;
3814 };
3816
3819 if (verboseLevel > 3 && withInfo) {
3820 ::Info("ACLiC", "relinking against all dependencies");
3821 if (verboseLevel > 4)
3822 ::Info("ACLiC", "%s", relink_cmd.Data());
3823 }
3825 }
3826
3827 TNamed *k = new TNamed(library,library);
3829 gSystem->GetPathInfo( library, nullptr, (Long_t*)nullptr, nullptr, &lib_time );
3831 if (!keep) k->SetBit(kMustCleanup);
3832 fCompiled->Add(k);
3833
3834 if (needLoadMap) {
3835 gInterpreter->LoadLibraryMap(libmapfilename);
3836 }
3837 if (verboseLevel>3 && withInfo) ::Info("ACLiC","loading the shared library");
3838 if (loadLib)
3840 else
3841 result = kTRUE;
3842
3843 if ( !result ) {
3844 if (verboseLevel>3 && withInfo) {
3845 ::Info("ACLiC","testing for missing symbols:");
3846 if (verboseLevel>4) ::Info("ACLiC", "%s", testcmd.Data());
3847 }
3849 gSystem->Unlink( exec );
3850 }
3851
3852 };
3853
3854 if (verboseLevel<=5 && !internalDebug) {
3855 gSystem->Unlink( dict );
3856 gSystem->Unlink( dicth );
3862 gSystem->Unlink( exec );
3863 }
3864 if (verboseLevel>6) {
3865 rcling.Prepend("echo ");
3866 cmd.Prepend("echo \" ").Append(" \" ");
3867 testcmd.Prepend("echo \" ").Append(" \" ");
3869 gSystem->Exec( cmd );
3871 }
3872
3873 return result;
3874}
3875
3876////////////////////////////////////////////////////////////////////////////////
3877/// Return the ACLiC properties field. See EAclicProperties for details
3878/// on the semantic of each bit.
3879
3881{
3882 return fAclicProperties;
3883}
3884
3885////////////////////////////////////////////////////////////////////////////////
3886/// Return the build architecture.
3887
3888const char *TSystem::GetBuildArch() const
3889{
3890 return fBuildArch;
3891}
3892
3893////////////////////////////////////////////////////////////////////////////////
3894/// Return the build compiler
3895
3896const char *TSystem::GetBuildCompiler() const
3897{
3898 return fBuildCompiler;
3899}
3900
3901////////////////////////////////////////////////////////////////////////////////
3902/// Return the build compiler version
3903
3905{
3906 return fBuildCompilerVersion;
3907}
3908
3909////////////////////////////////////////////////////////////////////////////////
3910/// Return the build compiler version identifier string
3911
3913{
3915}
3916
3917////////////////////////////////////////////////////////////////////////////////
3918/// Return the build node name.
3919
3920const char *TSystem::GetBuildNode() const
3921{
3922 return fBuildNode;
3923}
3924
3925////////////////////////////////////////////////////////////////////////////////
3926/// Return the path of the build directory.
3927
3928const char *TSystem::GetBuildDir() const
3929{
3930 if (fBuildDir.Length()==0) {
3931 if (!gEnv) return "";
3932 const_cast<TSystem*>(this)->fBuildDir = gEnv->GetValue("ACLiC.BuildDir","");
3933 }
3934 return fBuildDir;
3935}
3936
3937////////////////////////////////////////////////////////////////////////////////
3938/// Return the debug flags.
3939
3940const char *TSystem::GetFlagsDebug() const
3941{
3942 return fFlagsDebug;
3943}
3944
3945////////////////////////////////////////////////////////////////////////////////
3946/// Return the optimization flags.
3947
3948const char *TSystem::GetFlagsOpt() const
3949{
3950 return fFlagsOpt;
3951}
3952
3953////////////////////////////////////////////////////////////////////////////////
3954/// AclicMode indicates whether the library should be built in
3955/// debug mode or optimized. The values are:
3956/// - TSystem::kDefault : compile the same as the current ROOT
3957/// - TSystem::kDebug : compiled in debug mode
3958/// - TSystem::kOpt : optimized the library
3959
3964
3965////////////////////////////////////////////////////////////////////////////////
3966/// Return the command line use to make a shared library.
3967/// See TSystem::CompileMacro for more details.
3968
3969const char *TSystem::GetMakeSharedLib() const
3970{
3971 return fMakeSharedLib;
3972}
3973
3974////////////////////////////////////////////////////////////////////////////////
3975/// Return the command line use to make an executable.
3976/// See TSystem::CompileMacro for more details.
3977
3978const char *TSystem::GetMakeExe() const
3979{
3980 return fMakeExe;
3981}
3982
3983////////////////////////////////////////////////////////////////////////////////
3984/// Get the list of include path.
3985
3987{
3989#ifndef _MSC_VER
3990 // FIXME: This is a temporary fix for the following error with ACLiC
3991 // (and this is apparently not needed anyway):
3992 // 48: input_line_12:8:38: error: use of undeclared identifier 'IC'
3993 // 48: "C:/Users/bellenot/build/debug/etc" -IC:/Users/bellenot/build/debug/etc//cling -IC:/Users/bellenot/build/debug/include"",
3994 // 48: ^
3995 // 48: Error in <ACLiC>: Dictionary generation failed!
3996 fListPaths.Append(" ").Append(gInterpreter->GetIncludePath());
3997#endif
3998 return fListPaths;
3999}
4000
4001////////////////////////////////////////////////////////////////////////////////
4002/// Return the list of library linked to this executable.
4003/// See TSystem::CompileMacro for more details.
4004
4005const char *TSystem::GetLinkedLibs() const
4006{
4007 return fLinkedLibs;
4008}
4009
4010////////////////////////////////////////////////////////////////////////////////
4011/// Return the linkdef suffix chosen by the user for ACLiC.
4012/// See TSystem::CompileMacro for more details.
4013
4014const char *TSystem::GetLinkdefSuffix() const
4015{
4016 if (fLinkdefSuffix.Length()==0) {
4017 if (!gEnv) return "_linkdef";
4018 const_cast<TSystem*>(this)->fLinkdefSuffix = gEnv->GetValue("ACLiC.Linkdef","_linkdef");
4019 }
4020 return fLinkdefSuffix;
4021}
4022
4023////////////////////////////////////////////////////////////////////////////////
4024/// Get the shared library extension.
4025
4026const char *TSystem::GetSoExt() const
4027{
4028 return fSoExt;
4029}
4030
4031////////////////////////////////////////////////////////////////////////////////
4032/// Get the object file extension.
4033
4034const char *TSystem::GetObjExt() const
4035{
4036 return fObjExt;
4037}
4038
4039////////////////////////////////////////////////////////////////////////////////
4040/// Set the location where ACLiC will create libraries and use as
4041/// a scratch area. If unset, libraries will be created at the same
4042/// location than the script.
4043///
4044/// \param build_dir the name of the build directory
4045/// \param isflat If false (default), then the libraries are actually stored
4046/// in sub-directories of 'build_dir' including the full pathname
4047/// of the script. If the script is located at `/full/path/name/macro.C`
4048/// the library will be located at `build_dir+/full/path/name/macro_C.so`
4049/// If 'isflat' is true, then no subdirectory is created and the library
4050/// is created directly in the directory 'build_dir'. Note that in this
4051/// mode there is a risk than 2 script of the same in different source
4052/// directory will over-write each other.
4053/// \note This `build_dir` can also be controlled via `ACLiC.BuildDir` in
4054/// your `.rootrc`.
4055
4057{
4059 if (isflat)
4061 else
4063}
4064
4065////////////////////////////////////////////////////////////////////////////////
4066/// FlagsDebug should contain the options to pass to the C++ compiler
4067/// in order to compile the library in debug mode.
4068
4069void TSystem::SetFlagsDebug(const char *flags)
4070{
4071 fFlagsDebug = flags;
4072}
4073
4074////////////////////////////////////////////////////////////////////////////////
4075/// FlagsOpt should contain the options to pass to the C++ compiler
4076/// in order to compile the library in optimized mode.
4077
4078void TSystem::SetFlagsOpt(const char *flags)
4079{
4080 fFlagsOpt = flags;
4081}
4082
4083////////////////////////////////////////////////////////////////////////////////
4084/// AclicMode indicates whether the library should be built in
4085/// debug mode or optimized. The values are:
4086/// - TSystem::kDefault : compile the same as the current ROOT
4087/// - TSystem::kDebug : compiled in debug mode
4088/// - TSystem::kOpt : optimized the library
4089
4094
4095////////////////////////////////////////////////////////////////////////////////
4096/// Directives has the same syntax as the argument of SetMakeSharedLib but is
4097/// used to create an executable. This creation is used as a means to output
4098/// a list of unresolved symbols, when loading a shared library has failed.
4099/// The required variable is $ExeName rather than $SharedLib, e.g.:
4100/// ~~~ {.cpp}
4101/// gSystem->SetMakeExe(
4102/// "g++ -Wall -fPIC $IncludePath $SourceFiles
4103/// -o $ExeName $LinkedLibs -L/usr/X11R6/lib -lX11 -lm -ldl -rdynamic");
4104/// ~~~
4105
4107{
4109 // NOTE: add verification that the directives has the required variables
4110}
4111
4112////////////////////////////////////////////////////////////////////////////////
4113/// Directives should contain the description on how to compile and link a
4114/// shared lib. This description can be any valid shell command, including
4115/// the use of ';' to separate several instructions. However, shell specific
4116/// construct should be avoided. In particular this description can contain
4117/// environment variables, like $ROOTSYS (or %ROOTSYS% on windows).
4118/// ~~~ {.cpp}
4119/// Five special variables will be expanded before execution:
4120/// Variable name Expands to
4121/// ------------- ----------
4122/// $SourceFiles Name of source files to be compiled
4123/// $SharedLib Name of the shared library being created
4124/// $LibName Name of shared library without extension
4125/// $BuildDir Directory where the files will be created
4126/// $IncludePath value of fIncludePath
4127/// $LinkedLibs value of fLinkedLibs
4128/// $DepLibs libraries on which this library depends on
4129/// $ObjectFiles Name of source files to be compiler with
4130/// their extension changed to .o or .obj
4131/// $Opt location of the optimization/debug options
4132/// set fFlagsDebug and fFlagsOpt
4133/// ~~~
4134/// e.g.:
4135/// ~~~ {.cpp}
4136/// gSystem->SetMakeSharedLib(
4137/// "KCC -n32 --strict $IncludePath -K0 $Opt $SourceFile
4138/// --no_exceptions --signed_chars --display_error_number
4139/// --diag_suppress 68 -o $SharedLib");
4140///
4141/// gSystem->setMakeSharedLib(
4142/// "Cxx $IncludePath -c $SourceFile;
4143/// ld -L/usr/lib/cmplrs/cxx -rpath /usr/lib/cmplrs/cxx -expect_unresolved
4144/// $Opt -shared /usr/lib/cmplrs/cc/crt0.o /usr/lib/cmplrs/cxx/_main.o
4145/// -o $SharedLib $ObjectFile -lcxxstd -lcxx -lexc -lots -lc"
4146///
4147/// gSystem->SetMakeSharedLib(
4148/// "$HOME/mygcc/bin/g++ $Opt -Wall -fPIC $IncludePath $SourceFile
4149/// -shared -o $SharedLib");
4150///
4151/// gSystem->SetMakeSharedLib(
4152/// "cl -DWIN32 -D_WIN32 -D_MT -D_DLL -MD /O2 /G5 /MD -DWIN32
4153/// -D_WINDOWS $IncludePath $SourceFile
4154/// /link -PDB:NONE /NODEFAULTLIB /INCREMENTAL:NO /RELEASE /NOLOGO
4155/// $LinkedLibs -entry:_DllMainCRTStartup@12 -dll /out:$SharedLib")
4156/// ~~~
4157
4159{
4161 // NOTE: add verification that the directives has the required variables
4162}
4163
4164////////////////////////////////////////////////////////////////////////////////
4165/// \brief Add a directory to the already set include path.
4166/// \param[in] includePath The path to the directory.
4167/// \note This interface is mostly relevant for ACLiC and it does *not* inform
4168/// gInterpreter for this include path. If the TInterpreter needs to know
4169/// about the include path please use TInterpreter::AddIncludePath() .
4170/// \warning The path should start with the \c -I prefix, i.e.
4171/// <tt>gSystem->AddIncludePath("-I /path/to/my/includes")</tt>.
4173{
4174 if (includePath) {
4175 fIncludePath += " ";
4177 }
4178}
4179
4180////////////////////////////////////////////////////////////////////////////////
4181/// Add linkedLib to already set linked libs.
4182
4184{
4185 if (linkedLib) {
4186 fLinkedLibs += " ";
4188 }
4189}
4190
4191////////////////////////////////////////////////////////////////////////////////
4192/// IncludePath should contain the list of compiler flags to indicate where
4193/// to find user defined header files. It is used to expand $IncludePath in
4194/// the directives given to SetMakeSharedLib() and SetMakeExe(), e.g.:
4195/// ~~~ {.cpp}
4196/// gSystem->SetInclude("-I$ROOTSYS/include -Imydirectory/include");
4197/// ~~~
4198/// the default value of IncludePath on Unix is:
4199/// ~~~ {.cpp}
4200/// "-I$ROOTSYS/include "
4201/// ~~~
4202/// and on Windows:
4203/// ~~~ {.cpp}
4204/// "/I%ROOTSYS%/include "
4205/// ~~~
4206
4208{
4210}
4211
4212////////////////////////////////////////////////////////////////////////////////
4213/// LinkedLibs should contain the library directory and list of libraries
4214/// needed to recreate the current executable. It is used to expand $LinkedLibs
4215/// in the directives given to SetMakeSharedLib() and SetMakeExe()
4216/// The default value on Unix is: `root-config --glibs`
4217
4219{
4221}
4222
4223////////////////////////////////////////////////////////////////////////////////
4224/// The 'suffix' will be appended to the name of a script loaded by ACLiC
4225/// and used to locate any eventual additional linkdef information that
4226/// ACLiC should used to produce the dictionary.
4227///
4228/// So by default, when doing .L MyScript.cxx, ACLiC will look
4229/// for a file name MyScript_linkdef and having one of the .h (.hpp,
4230/// etc.) extensions. If such a file exist, it will be added to
4231/// the end of the linkdef file used to created the ACLiC dictionary.
4232/// This effectively enable the full customization of the creation
4233/// of the dictionary. It should be noted that the file is intended
4234/// as a linkdef `fragment`, so usually you would not list the
4235/// typical:
4236/// ~~~ {.cpp}
4237/// #pragma link off ....
4238/// ~~~
4239
4241{
4243}
4244
4245
4246////////////////////////////////////////////////////////////////////////////////
4247/// Set shared library extension, should be either .so, .sl, .a, .dll, etc.
4248
4249void TSystem::SetSoExt(const char *SoExt)
4250{
4251 fSoExt = SoExt;
4252}
4253
4254////////////////////////////////////////////////////////////////////////////////
4255/// Set object files extension, should be either .o, .obj, etc.
4256
4258{
4259 fObjExt = ObjExt;
4260}
4261
4262////////////////////////////////////////////////////////////////////////////////
4263/// This method split a filename of the form:
4264/// ~~~ {.cpp}
4265/// [path/]macro.C[+|++[k|f|g|O|c|s|d|v|-]][(args)].
4266/// ~~~
4267/// It stores the ACliC mode [+|++[options]] in 'mode',
4268/// the arguments (including parenthesis) in arg
4269/// and the I/O indirection in io
4270
4272 TString &arguments, TString &io) const
4273{
4274 char *fname = Strip(filename);
4276 filenameCopy = filenameCopy.Strip();
4277
4278 if (filenameCopy.EndsWith(";")) {
4279 filenameCopy.Remove(filenameCopy.Length() - 1);
4280 filenameCopy = filenameCopy.Strip();
4281 }
4282 if (filenameCopy.EndsWith(")")) {
4283 Ssiz_t posArgEnd = filenameCopy.Length() - 1;
4284 // There is an argument; find its start!
4285 int parenNestCount = 1;
4286 bool inString = false;
4288 for (; parenNestCount && posArgBegin >= 0; --posArgBegin) {
4289 // Escaped if the previous character is a `\` - but not if it
4290 // itself is preceded by a `\`!
4291 if (posArgBegin > 0 && filenameCopy[posArgBegin] == '\' &&
4292 (posArgBegin == 1 || filenameCopy[posArgBegin - 1] != '\')) {
4293 // skip escape.
4294 --posArgBegin;
4295 continue;
4296 }
4297 switch (filenameCopy[posArgBegin]) {
4298 case ')':
4299 if (!inString)
4301 break;
4302 case '(':
4303 if (!inString)
4305 break;
4306 case '"': inString = !inString; break;
4307 }
4308 }
4309 if (parenNestCount || inString) {
4310 Error("SplitAclicMode", "Cannot parse argument in %s", filename);
4311 } else {
4312 arguments = filenameCopy(posArgBegin + 1, posArgEnd - 1);
4313 fname[posArgBegin + 1] = 0;
4314 }
4315 }
4316
4317 // strip off I/O redirect tokens from filename
4318 {
4319 char *s2 = nullptr;
4320 char *s3;
4321 s2 = strstr(fname, ">>");
4322 if (!s2) s2 = strstr(fname, "2>");
4323 if (!s2) s2 = strchr(fname, '>');
4324 s3 = strchr(fname, '<');
4325 if (s2 && s3) s2 = s2<s3 ? s2 : s3;
4326 if (s3 && !s2) s2 = s3;
4327 if (s2==fname) {
4328 io = fname;
4329 aclicMode = "";
4330 arguments = "";
4331 delete []fname;
4332 return "";
4333 } else if (s2) {
4334 if (s2 > fname) {
4335 // Skip/trim spaces
4336 s2--;
4337 while (s2 > fname && *s2 == ' ') s2--;
4338 s2++;
4339 }
4340 io = s2; // ssave = *s2;
4341 *s2 = 0;
4342 } else
4343 io = "";
4344 }
4345
4346 // remove the possible ACLiC + or ++ and g or O etc
4347 aclicMode.Clear();
4348 int len = strlen(fname);
4349 TString mode;
4350 while (len > 1) {
4351 if (strchr("kfgOcsdv-", fname[len - 1])) {
4352 mode += fname[len - 1];
4353 --len;
4354 } else {
4355 break;
4356 }
4357 }
4358 Bool_t compile = len && fname[len - 1] == '+';
4359 Bool_t remove = compile && len > 1 && fname[len - 2] == '+';
4360 if (compile) {
4361 if (mode.Length()) {
4362 fname[len] = 0;
4363 }
4364 if (remove) {
4365 fname[strlen(fname)-2] = 0;
4366 aclicMode = "++";
4367 } else {
4368 fname[strlen(fname)-1] = 0;
4369 aclicMode = "+";
4370 }
4371 if (mode.Length())
4372 aclicMode += mode;
4373 }
4374
4376
4377 delete []fname;
4378 return resFilename;
4379}
4380
4381////////////////////////////////////////////////////////////////////////////////
4382/// Remove the shared libs produced by the CompileMacro() function, together
4383/// with their rootmaps, linkdefs, and pcms (and some more on Windows).
4384
4386{
4387 TIter next(fCompiled);
4388 TNamed *lib;
4389 const char *extensions[] = {".lib", ".exp", ".d", ".def", ".rootmap", "_ACLiC_linkdef.h", "_ACLiC_dict_rdict.pcm"};
4390 while ((lib = (TNamed*)next())) {
4391 if (lib->TestBit(kMustCleanup)) {
4392 TString libname = lib->GetTitle();
4393#ifdef WIN32
4394 // On Windows, we need to unload the dll before deleting it
4395 if (gInterpreter->IsLibraryLoaded(libname))
4397#endif
4398 Unlink(libname);
4399 TString target, soExt = "." + fSoExt;
4400 libname.ReplaceAll(soExt, "");
4401 for (const char *ext : extensions) {
4402 target = libname + ext;
4403 Unlink(target);
4404 }
4405 }
4406 }
4407}
4408
4409////////////////////////////////////////////////////////////////////////////////
4410/// Register version of plugin library.
4411
The file contains utilities which are foundational and could be used across the core component of ROO...
#define SafeDelete(p)
Definition RConfig.hxx:533
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
#define ROOT_RELEASE
Definition RVersion.hxx:44
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Definition RtypesCore.h:45
constexpr Int_t kMaxInt
Definition RtypesCore.h:105
long Long_t
Definition RtypesCore.h:54
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Ssiz_t kNPOS
Definition RtypesCore.h:117
long long Long64_t
Definition RtypesCore.h:69
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:374
@ kMAXPATHLEN
Definition Rtypes.h:60
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
Definition TROOT.cxx:597
#define gROOT
Definition TROOT.h:406
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:2509
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:2581
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:1828
static void R__AddPath(TString &target, const TString &path)
Definition TSystem.cxx:2576
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:17535
const char * extension
Definition civetweb.c:8025
#define snprintf
Definition civetweb.c:1540
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:205
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:2992
static const TString & GetIncludeDir()
Get the include directory in the installation. Static utility function.
Definition TROOT.cxx:3045
static Int_t ConvertVersionCode2Int(Int_t code)
Convert version code to an integer, i.e. 331527 -> 51507.
Definition TROOT.cxx:2925
static const TString & GetRootSys()
Get the rootsys directory in the installation. Static utility function.
Definition TROOT.cxx:2982
static Int_t RootVersionCode()
Return ROOT version code as defined in RVersion.h.
Definition TROOT.cxx:2944
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
Definition TROOT.cxx:3055
static const TString & GetLibDir()
Get the library directory in the installation. Static utility function.
Definition TROOT.cxx:3013
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:3920
virtual int Umask(Int_t mask)
Set the process file creation mode mask.
Definition TSystem.cxx:1529
virtual int SendBuf(int sock, const void *buffer, int length)
Send a buffer headed by a length indicator.
Definition TSystem.cxx:2439
virtual int GetServiceByName(const char *service)
Get port # of internet service.
Definition TSystem.cxx:2330
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:2064
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:1511
virtual const char * GetMakeSharedLib() const
Return the command line use to make a shared library.
Definition TSystem.cxx:3969
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:2114
virtual void AddLinkedLibs(const char *linkedLib)
Add linkedLib to already set linked libs.
Definition TSystem.cxx:4183
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:1727
virtual const char * GetBuildCompilerVersion() const
Return the build compiler version.
Definition TSystem.cxx:3904
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:2321
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:1484
virtual Func_t DynFindSymbol(const char *module, const char *entry)
Find specific entry point in specified library.
Definition TSystem.cxx:2056
virtual const char * GetLinkedLibs() const
Return the list of library linked to this executable.
Definition TSystem.cxx:4005
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:1698
virtual int Symlink(const char *from, const char *to)
Create a symbolic link from file1 to file2.
Definition TSystem.cxx:1380
virtual void SetAclicMode(EAclicMode mode)
AclicMode indicates whether the library should be built in debug mode or optimized.
Definition TSystem.cxx:4090
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:1982
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:4257
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:4240
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:1286
virtual const char * GetBuildDir() const
Return the path of the build directory.
Definition TSystem.cxx:3928
virtual void Openlog(const char *name, Int_t options, ELogFacility facility)
Open connection to system log daemon.
Definition TSystem.cxx:1689
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:4172
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:1520
virtual Int_t GetEffectiveGid()
Returns the effective group id.
Definition TSystem.cxx:1603
@ 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:4078
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:2339
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:2430
virtual int CopyFile(const char *from, const char *to, Bool_t overwrite=kFALSE)
Copy a file.
Definition TSystem.cxx:1353
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:2448
virtual const char * Getenv(const char *env)
Get environment variable.
Definition TSystem.cxx:1677
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:3986
virtual int AcceptConnection(int sock)
Accept a connection.
Definition TSystem.cxx:2393
virtual Int_t GetAclicProperties() const
Return the ACLiC properties field.
Definition TSystem.cxx:3880
virtual TString SplitAclicMode(const char *filename, TString &mode, TString &args, TString &io) const
This method split a filename of the form:
Definition TSystem.cxx:4271
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:1737
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name. User must delete returned string.
Definition TSystem.cxx:1083
virtual UserGroup_t * GetGroupInfo(Int_t gid)
Returns all group info in the UserGroup_t structure.
Definition TSystem.cxx:1637
virtual void CleanCompiledMacros()
Remove the shared libs produced by the CompileMacro() function, together with their rootmaps,...
Definition TSystem.cxx:4385
virtual Bool_t IsPathLocal(const char *path)
Returns TRUE if the url in 'path' points to the local file system.
Definition TSystem.cxx:1317
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:1550
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:1110
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:2312
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:2470
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:2491
virtual EAclicMode GetAclicMode() const
AclicMode indicates whether the library should be built in debug mode or optimized.
Definition TSystem.cxx:3960
virtual const char * GetLinkedLibraries()
Get list of shared libraries loaded at the start of the executable.
Definition TSystem.cxx:2132
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:4207
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:1869
virtual void ListSymbols(const char *module, const char *re="")
List symbols in a shared library.
Definition TSystem.cxx:2076
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:2481
@ kFlatBuildDir
Definition TSystem.h:281
virtual void ListLibraries(const char *regexp="")
List the loaded shared libraries.
Definition TSystem.cxx:2097
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:4158
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:1410
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:1093
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:1308
virtual int OpenConnection(const char *server, int port, int tcpwindowsize=-1, const char *protocol="tcp")
Open a connection to another host.
Definition TSystem.cxx:2348
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:2457
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:2411
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:2501
virtual const char * GetBuildCompilerVersionStr() const
Return the build compiler version identifier string.
Definition TSystem.cxx:3912
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:1362
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:1807
TSeqCollection * fSignalHandler
Definition TSystem.h:305
virtual const char * GetMakeExe() const
Return the command line use to make an executable.
Definition TSystem.cxx:3978
virtual const char * FindDynamicLibrary(TString &lib, Bool_t quiet=kFALSE)
Find a dynamic library using the system search paths.
Definition TSystem.cxx:2046
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:4069
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:1593
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:4106
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:3940
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:1669
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:1799
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:4034
virtual int AnnounceUnixService(int port, int backlog)
Announce unix domain service.
Definition TSystem.cxx:2375
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:1574
virtual Int_t GetEffectiveUid()
Returns the effective user id.
Definition TSystem.cxx:1584
TString fFlagsDebug
Definition TSystem.h:318
virtual const char * GetLinkdefSuffix() const
Return the linkdef suffix chosen by the user for ACLiC.
Definition TSystem.cxx:4014
virtual void SetDynamicPath(const char *pathname)
Set the dynamic path to a new value.
Definition TSystem.cxx:1818
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:2848
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:1560
virtual TInetAddress GetHostByName(const char *server)
Get Internet Protocol (IP) address of host.
Definition TSystem.cxx:2303
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:2421
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:3896
virtual void CloseConnection(int sock, Bool_t force=kFALSE)
Close socket connection.
Definition TSystem.cxx:2402
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:2148
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:4249
virtual void Closelog()
Close connection to system log daemon.
Definition TSystem.cxx:1706
TString fBuildCompiler
Definition TSystem.h:313
virtual void Setenv(const char *name, const char *value)
Set environment variable.
Definition TSystem.cxx:1661
virtual const char * GetBuildArch() const
Return the build architecture.
Definition TSystem.cxx:3888
virtual int Link(const char *from, const char *to)
Create a link from file1 to file2.
Definition TSystem.cxx:1371
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:4218
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:4056
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:4026
virtual int Utime(const char *file, Long_t modtime, Long_t actime)
Set the a files modification and access times.
Definition TSystem.cxx:1539
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:2357
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:1393
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:1613
virtual int AnnounceUdpService(int port, int backlog, ESocketBindOption socketBindOption=ESocketBindOption::kInaddrAny)
Announce UDP service.
Definition TSystem.cxx:2366
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:1494
virtual const char * GetFlagsOpt() const
Return the optimization flags.
Definition TSystem.cxx:3948
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:2032
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:4412
This class implements a mutex interface.
TLine * line
std::ostream & Info()
Definition hadd.cxx:171
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