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