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