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