42 #include <sys/utime.h>
43 #include <sys/timeb.h>
62 #if defined (_MSC_VER) && (_MSC_VER >= 1400)
64 #elif defined (_M_IX86)
65 static void __cpuid(
int* cpuid_data,
int info_type)
92 static void __cpuid(
int* cpuid_data,
int) {
93 cpuid_data[0] = 0x00000000;
94 cpuid_data[1] = 0x00000000;
95 cpuid_data[2] = 0x00000000;
96 cpuid_data[3] = 0x00000000;
111 TFdSet() { fds_bits =
new fd_set; fds_bits->fd_count = 0; }
112 virtual ~TFdSet() {
delete fds_bits; }
113 void Copy(TFdSet &fd)
const { memcpy((
void*)fd.fds_bits, fds_bits,
sizeof(fd_set)); }
114 TFdSet(
const TFdSet& fd) { fd.Copy(*
this); }
115 TFdSet&
operator=(
const TFdSet& fd) { fd.Copy(*
this);
return *
this; }
116 void Zero() { fds_bits->fd_count = 0; }
119 if (fds_bits->fd_count < FD_SETSIZE-1)
120 fds_bits->fd_array[fds_bits->fd_count++] = (
SOCKET)fd;
122 ::SysError(
"TFdSet::Set",
"fd_count will exeed FD_SETSIZE");
127 for (i=0; i<fds_bits->fd_count; i++) {
128 if (fds_bits->fd_array[i]==(
SOCKET)fd) {
129 while (i<fds_bits->fd_count-1) {
130 fds_bits->fd_array[i] = fds_bits->fd_array[i+1];
133 fds_bits->fd_count--;
139 Int_t *GetBits() {
return fds_bits && fds_bits->fd_count ? (
Int_t*)fds_bits : 0; }
140 UInt_t GetCount() {
return (
UInt_t)fds_bits->fd_count; }
141 Int_t GetFd(
Int_t i) {
return i<fds_bits->fd_count ? fds_bits->fd_array[i] : 0; }
145 const char *kProtocolName =
"tcp";
149 static HANDLE gGlobalEvent;
150 static HANDLE gTimerThreadHandle;
151 typedef NET_API_STATUS (WINAPI *pfn1)(LPVOID);
152 typedef NET_API_STATUS (WINAPI *pfn2)(LPCWSTR, LPCWSTR, DWORD, LPBYTE*);
153 typedef NET_API_STATUS (WINAPI *pfn3)(LPCWSTR, LPCWSTR, DWORD, LPBYTE*,
154 DWORD, LPDWORD, LPDWORD, PDWORD);
155 typedef NET_API_STATUS (WINAPI *pfn4)(LPCWSTR, DWORD, LPBYTE*, DWORD, LPDWORD,
157 static pfn1 p2NetApiBufferFree;
158 static pfn2 p2NetUserGetInfo;
159 static pfn3 p2NetLocalGroupGetMembers;
160 static pfn4 p2NetLocalGroupEnum;
162 static struct signal_map {
168 SIGSEGV, 0,
"segmentation violation",
169 -1 , 0,
"bad argument to system call",
170 -1 , 0,
"write on a pipe with no one to read it",
171 SIGILL, 0,
"illegal instruction",
173 SIGINT, 0,
"interrupt",
174 -1 , 0,
"window size change",
175 -1 , 0,
"alarm clock",
176 -1 , 0,
"death of a child",
177 -1 , 0,
"urgent data arrived on an I/O channel",
178 SIGFPE, 0,
"floating point exception",
179 SIGTERM, 0,
"termination signal",
180 -1 , 0,
"user-defined signal 1",
181 -1 , 0,
"user-defined signal 2"
202 static int WinNTRecv(
int socket,
void *buffer,
int length,
int flag)
204 if (socket == -1)
return -1;
212 if (flag == MSG_PEEK) {
217 char *buf = (
char *)buffer;
219 for (n = 0; n <
length; n += nrecv) {
220 if ((nrecv = ::recv(sock, buf+n, length-n, flag)) <= 0) {
224 if (flag == MSG_OOB) {
225 if (::WSAGetLastError() == WSAEWOULDBLOCK) {
227 }
else if (::WSAGetLastError() == WSAEINVAL) {
231 if (::WSAGetLastError() == WSAEWOULDBLOCK) {
234 if (::WSAGetLastError() != WSAEINTR)
235 ::
SysError(
"TWinNTSystem::WinNTRecv",
"recv");
236 if (::WSAGetLastError() == EPIPE ||
237 ::WSAGetLastError() == WSAECONNRESET)
256 static int WinNTSend(
int socket,
const void *buffer,
int length,
int flag)
258 if (socket < 0)
return -1;
268 const char *buf = (
const char *)buffer;
270 for (n = 0; n <
length; n += nsent) {
271 if ((nsent = ::send(sock, buf+n, length-n, flag)) <= 0) {
275 if (::WSAGetLastError() == WSAEWOULDBLOCK) {
278 if (::WSAGetLastError() != WSAEINTR)
279 ::
SysError(
"TWinNTSystem::WinNTSend",
"send");
280 if (::WSAGetLastError() == EPIPE ||
281 ::WSAGetLastError() == WSAECONNRESET)
298 static int WinNTSelect(TFdSet *readready, TFdSet *writeready,
Long_t timeout)
301 fd_set* rbits = readready ? (fd_set*)readready->GetBits() : 0;
302 fd_set* wbits = writeready ? (fd_set*)writeready->GetBits() : 0;
306 tv.tv_sec = timeout / 1000;
307 tv.tv_usec = (timeout % 1000) * 1000;
309 retcode =
::select(0, rbits, wbits, 0, &tv);
311 retcode =
::select(0, rbits, wbits, 0, 0);
314 if (retcode == SOCKET_ERROR) {
315 int errcode = ::WSAGetLastError();
319 if (errcode == WSAENOTSOCK) {
321 int result = _fstat64( readready->GetFd(0), &buf );
329 ::WaitForSingleObject(gGlobalEvent, 1);
330 ::ResetEvent(gGlobalEvent);
335 if ( errcode == WSAEINTR) {
339 if (errcode == EBADF) {
354 if (reset || newpath) {
361 }
else if (dynpath ==
"") {
364 if (rdynpath ==
"") {
366 rdynpath =
".;"; rdynpath += ROOTBINDIR;
368 rdynpath =
".;"; rdynpath +=
gRootDir; rdynpath +=
"/bin";
371 TString path = gSystem->Getenv(
"PATH");
375 dynpath = path; dynpath +=
";"; dynpath += rdynpath;
380 if (!dynpath.
Contains(ROOTLIBDIR)) {
381 dynpath +=
";"; dynpath += ROOTLIBDIR;
385 dynpath +=
";"; dynpath +=
gRootDir; dynpath +=
"/lib";
398 if (signal_map[i].code == sig) {
399 (*signal_map[i].handler)((
ESignals)i);
410 signal_map[sig].handler = handler;
411 if (signal_map[sig].code != -1)
418 static char *WinNTSigname(
ESignals sig)
420 return signal_map[sig].signame;
426 static BOOL ConsoleSigHandler(DWORD sig)
434 Break(
"TInterruptHandler::Notify",
"keyboard interrupt");
440 case CTRL_BREAK_EVENT:
441 case CTRL_LOGOFF_EVENT:
442 case CTRL_SHUTDOWN_EVENT:
443 case CTRL_CLOSE_EVENT:
445 printf(
"\n *** Break *** keyboard interrupt - ROOT is terminated\n");
451 static CONTEXT *fgXcptContext = 0;
465 LONG WINAPI ExceptionFilter(LPEXCEPTION_POINTERS pXcp)
467 fgXcptContext = pXcp->ContextRecord;
468 gSystem->StackTrace();
469 return EXCEPTION_CONTINUE_SEARCH;
473 #pragma intrinsic(_ReturnAddress)
474 #pragma auto_inline(off)
475 DWORD_PTR GetProgramCounter()
480 #pragma auto_inline(on)
491 static DWORD WINAPI GUIThreadMessageProcessingLoop(
void *p)
496 ::PeekMessage(&msg,
NULL, WM_USER, WM_USER, PM_NOREMOVE);
501 if (gGlobalEvent) ::SetEvent(gGlobalEvent);
503 if (erret <= 0) endLoop =
kTRUE;
504 if (gGUIThreadMsgFunc)
505 endLoop = (*gGUIThreadMsgFunc)(&msg);
512 erret = ::GetLastError();
513 Error(
"MsgLoop",
"Error in GetMessage");
527 typedef BOOL (__stdcall *SYMINITIALIZEPROC)( HANDLE, LPSTR, BOOL );
528 typedef BOOL (__stdcall *SYMCLEANUPPROC)( HANDLE );
529 typedef BOOL (__stdcall *STACKWALK64PROC)
530 ( DWORD, HANDLE, HANDLE, LPSTACKFRAME64, LPVOID,
531 PREAD_PROCESS_MEMORY_ROUTINE,PFUNCTION_TABLE_ACCESS_ROUTINE,
532 PGET_MODULE_BASE_ROUTINE, PTRANSLATE_ADDRESS_ROUTINE );
533 typedef LPVOID (__stdcall *SYMFUNCTIONTABLEACCESS64PROC)( HANDLE, DWORD64 );
534 typedef DWORD (__stdcall *SYMGETMODULEBASE64PROC)( HANDLE, DWORD64 );
535 typedef BOOL (__stdcall *SYMGETMODULEINFO64PROC)(HANDLE, DWORD64, PIMAGEHLP_MODULE64);
536 typedef BOOL (__stdcall *SYMGETSYMFROMADDR64PROC)( HANDLE, DWORD64, PDWORD64, PIMAGEHLP_SYMBOL64);
537 typedef BOOL (__stdcall *SYMGETLINEFROMADDR64PROC)(HANDLE, DWORD64, PDWORD, PIMAGEHLP_LINE64);
538 typedef DWORD (__stdcall *UNDECORATESYMBOLNAMEPROC)(PCSTR, PSTR, DWORD, DWORD);
541 static SYMINITIALIZEPROC _SymInitialize = 0;
542 static SYMCLEANUPPROC _SymCleanup = 0;
543 static STACKWALK64PROC _StackWalk64 = 0;
544 static SYMFUNCTIONTABLEACCESS64PROC _SymFunctionTableAccess64 = 0;
545 static SYMGETMODULEBASE64PROC _SymGetModuleBase64 = 0;
546 static SYMGETMODULEINFO64PROC _SymGetModuleInfo64 = 0;
547 static SYMGETSYMFROMADDR64PROC _SymGetSymFromAddr64 = 0;
548 static SYMGETLINEFROMADDR64PROC _SymGetLineFromAddr64 = 0;
549 static UNDECORATESYMBOLNAMEPROC _UnDecorateSymbolName = 0;
551 BOOL InitImagehlpFunctions()
559 HMODULE hModImagehlp = LoadLibrary(
"IMAGEHLP.DLL" );
563 _SymInitialize = (SYMINITIALIZEPROC) GetProcAddress( hModImagehlp,
"SymInitialize" );
567 _SymCleanup = (SYMCLEANUPPROC) GetProcAddress( hModImagehlp,
"SymCleanup" );
571 _StackWalk64 = (STACKWALK64PROC) GetProcAddress( hModImagehlp,
"StackWalk64" );
575 _SymFunctionTableAccess64 = (SYMFUNCTIONTABLEACCESS64PROC) GetProcAddress(hModImagehlp,
"SymFunctionTableAccess64" );
576 if (!_SymFunctionTableAccess64)
579 _SymGetModuleBase64=(SYMGETMODULEBASE64PROC)GetProcAddress(hModImagehlp,
"SymGetModuleBase64");
580 if (!_SymGetModuleBase64)
583 _SymGetModuleInfo64=(SYMGETMODULEINFO64PROC)GetProcAddress(hModImagehlp,
"SymGetModuleInfo64");
584 if (!_SymGetModuleInfo64)
587 _SymGetSymFromAddr64=(SYMGETSYMFROMADDR64PROC)GetProcAddress(hModImagehlp,
"SymGetSymFromAddr64");
588 if (!_SymGetSymFromAddr64)
591 _SymGetLineFromAddr64=(SYMGETLINEFROMADDR64PROC)GetProcAddress(hModImagehlp,
"SymGetLineFromAddr64");
592 if (!_SymGetLineFromAddr64)
595 _UnDecorateSymbolName=(UNDECORATESYMBOLNAMEPROC)GetProcAddress(hModImagehlp,
"UnDecorateSymbolName");
596 if (!_UnDecorateSymbolName)
599 if (!_SymInitialize(GetCurrentProcess(), 0, TRUE ))
615 std::string GetModuleName(DWORD64 address)
619 std::ostringstream
out;
620 HANDLE process = ::GetCurrentProcess();
622 DWORD lineDisplacement = 0;
623 IMAGEHLP_LINE64
line;
624 ::ZeroMemory(&line,
sizeof(line));
625 line.SizeOfStruct =
sizeof(
line);
626 if(_SymGetLineFromAddr64(process, address, &lineDisplacement, &line)) {
627 out << line.FileName <<
"(" << line.LineNumber <<
"): ";
629 IMAGEHLP_MODULE64 module;
630 ::ZeroMemory(&module,
sizeof(module));
631 module.SizeOfStruct =
sizeof(module);
632 if(_SymGetModuleInfo64(process, address, &module)) {
633 out << module.ModuleName <<
"!";
635 out <<
"0x" <<
std::hex << address << std::dec <<
" ";
642 std::string GetFunctionName(DWORD64 address)
646 DWORD64 symbolDisplacement = 0;
647 HANDLE process = ::GetCurrentProcess();
649 const unsigned int SYMBOL_BUFFER_SIZE = 8192;
650 char symbolBuffer[SYMBOL_BUFFER_SIZE];
651 PIMAGEHLP_SYMBOL64 symbol =
reinterpret_cast<PIMAGEHLP_SYMBOL64
>(symbolBuffer);
652 ::ZeroMemory(symbol, SYMBOL_BUFFER_SIZE);
653 symbol->SizeOfStruct = SYMBOL_BUFFER_SIZE;
654 symbol->MaxNameLength = SYMBOL_BUFFER_SIZE -
sizeof(IMAGEHLP_SYMBOL64);
656 if(_SymGetSymFromAddr64(process, address, &symbolDisplacement, symbol)) {
658 const unsigned int NAME_SIZE = 8192;
659 char name[NAME_SIZE];
660 _UnDecorateSymbolName(
665 UNDNAME_NO_THISTYPE |
666 UNDNAME_NO_SPECIAL_SYMS |
667 UNDNAME_NO_MEMBER_TYPE |
668 UNDNAME_NO_MS_KEYWORDS |
669 UNDNAME_NO_ACCESS_SPECIFIERS
687 static BOOL IsShortcut(
const char *filename)
690 const char *extLnk =
".lnk";
691 if (filename !=
NULL) {
694 if (strfilename.EndsWith(extLnk))
703 static BOOL ResolveShortCut(LPCSTR pszShortcutFile,
char *pszPath,
int maxbuf)
707 char szGotPath[MAX_PATH];
714 typedef HRESULT (__stdcall *COINITIALIZEPROC)( LPVOID );
715 static COINITIALIZEPROC _CoInitialize = 0;
716 typedef void (__stdcall *COUNINITIALIZEPROC)(
void );
717 static COUNINITIALIZEPROC _CoUninitialize = 0;
718 typedef HRESULT (__stdcall *COCREATEINSTANCEPROC)( REFCLSID, LPUNKNOWN,
719 DWORD, REFIID, LPVOID );
720 static COCREATEINSTANCEPROC _CoCreateInstance = 0;
722 HMODULE hModImagehlp = LoadLibrary(
"ole32.dll" );
726 _CoInitialize = (COINITIALIZEPROC) GetProcAddress( hModImagehlp,
"CoInitialize" );
729 _CoUninitialize = (COUNINITIALIZEPROC) GetProcAddress( hModImagehlp,
"CoUninitialize");
730 if (!_CoUninitialize)
732 _CoCreateInstance = (COCREATEINSTANCEPROC) GetProcAddress( hModImagehlp,
"CoCreateInstance" );
733 if (!_CoCreateInstance)
738 hres = _CoCreateInstance(CLSID_ShellLink,
NULL, CLSCTX_INPROC_SERVER,
739 IID_IShellLink, (
void **) &psl);
740 if (SUCCEEDED(hres)) {
743 hres = psl->QueryInterface(IID_IPersistFile, (
void **) &ppf);
744 if (SUCCEEDED(hres)) {
746 MultiByteToWideChar(CP_ACP, 0, pszShortcutFile, -1, wsz, MAX_PATH);
748 hres = ppf->Load(wsz, STGM_READ);
749 if (SUCCEEDED(hres)) {
750 hres = psl->Resolve(HWND_DESKTOP, SLR_ANY_MATCH | SLR_NO_UI | SLR_UPDATE);
751 if (SUCCEEDED(hres)) {
752 strlcpy(szGotPath, pszShortcutFile,MAX_PATH);
753 hres = psl->GetPath(szGotPath, MAX_PATH, (WIN32_FIND_DATA *)&wfd,
754 SLGP_UNCPRIORITY | SLGP_RAWPATH);
755 strlcpy(pszPath,szGotPath, maxbuf);
756 if (maxbuf) pszPath[maxbuf-1] = 0;
765 return SUCCEEDED(hres);
771 if (strcmp(sys->TWinNTSystem::BaseName(buf),
"root.exe"))
774 if (!::RegOpenKeyEx(HKEY_CURRENT_USER,
"Software", 0, KEY_READ, ®CUS) == ERROR_SUCCESS)
777 if (!::RegOpenKeyEx(regCUS,
"Classes", 0, KEY_READ, ®CUSC) == ERROR_SUCCESS) {
778 ::RegCloseKey(regCUS);
783 bool regROOTwrite =
false;
787 if (::RegOpenKeyEx(regCUSC,
"ROOTDEV.ROOT", 0, KEY_READ, ®ROOT) != ERROR_SUCCESS) {
788 ::RegCloseKey(regCUSC);
789 if (::RegOpenKeyEx(regCUS,
"Classes", 0, KEY_READ | KEY_WRITE, ®CUSC) == ERROR_SUCCESS &&
790 ::RegCreateKeyEx(regCUSC,
"ROOTDEV.ROOT", 0,
NULL, 0, KEY_READ | KEY_WRITE,
791 NULL, ®ROOT,
NULL) == ERROR_SUCCESS) {
796 if (::RegOpenKeyEx(regROOT,
"DefaultIcon", 0, KEY_READ, ®ROOTIcon) == ERROR_SUCCESS) {
797 char bufIconLoc[1024];
799 DWORD dwSize =
sizeof(bufIconLoc);
801 if (::RegQueryValueEx(regROOTIcon,
NULL,
NULL, &dwType, (BYTE*)bufIconLoc, &dwSize) == ERROR_SUCCESS)
802 regROOTwrite = (iconloc != bufIconLoc);
805 ::RegCloseKey(regROOTIcon);
810 ::RegCloseKey(regCUSC);
811 ::RegCloseKey(regROOT);
812 if (::RegOpenKeyEx(regCUS,
"Classes", 0, KEY_READ | KEY_WRITE, ®CUSC) != ERROR_SUCCESS) {
814 regROOTwrite =
false;
816 if (::RegOpenKeyEx(regCUSC,
"ROOTDEV.ROOT", 0, KEY_WRITE, ®ROOT) != ERROR_SUCCESS) {
818 regROOTwrite =
false;
819 ::RegCloseKey(regCUSC);
828 fileopen += sys->TWinNTSystem::DriveName(buf);
830 fileopen += sys->TWinNTSystem::DirName(sys->TWinNTSystem::DirName(buf));
831 fileopen +=
"\\macros";
833 fileopen += ROOTMACRODIR;
835 fileopen +=
"\\fileopen.C";
843 ::RegCloseKey(regROOT);
844 ::RegCloseKey(regCUSC);
845 ::RegCloseKey(regCUS);
849 static const char apptitle[] =
"ROOT data file";
850 ::RegSetValueEx(regROOT,
NULL, 0, REG_SZ, (BYTE*)apptitle,
sizeof(apptitle));
851 DWORD editflags = 0x00010000;
852 ::RegSetValueEx(regROOT,
"EditFlags", 0, REG_DWORD, (BYTE*)&editflags,
sizeof(editflags));
855 if (::RegCreateKeyEx(regROOT,
"DefaultIcon", 0,
NULL, 0, KEY_READ | KEY_WRITE,
856 NULL, ®ROOTIcon,
NULL) == ERROR_SUCCESS) {
859 ::RegSetValueEx(regROOTIcon,
NULL, 0, REG_SZ, (BYTE*)iconloc.Data(), iconloc.Length() + 1);
860 ::RegCloseKey(regROOTIcon);
865 if (::RegCreateKeyEx(regROOT,
"shell", 0,
NULL, 0, KEY_READ | KEY_WRITE,
866 NULL, ®ROOTshell,
NULL) == ERROR_SUCCESS) {
868 if (::RegCreateKeyEx(regROOTshell,
"open", 0,
NULL, 0, KEY_READ | KEY_WRITE,
869 NULL, ®ShellOpen,
NULL) == ERROR_SUCCESS) {
870 HKEY regShellOpenCmd;
871 if (::RegCreateKeyEx(regShellOpen,
"command", 0,
NULL, 0, KEY_READ | KEY_WRITE,
872 NULL, ®ShellOpenCmd,
NULL) == ERROR_SUCCESS) {
874 cmd +=
" -l \"%1\" \"";
877 ::RegSetValueEx(regShellOpenCmd,
NULL, 0, REG_SZ, (BYTE*)cmd.Data(), cmd.Length() + 1);
878 ::RegCloseKey(regShellOpenCmd);
880 ::RegCloseKey(regShellOpen);
882 ::RegCloseKey(regROOTshell);
884 ::RegCloseKey(regROOT);
886 if (::RegCreateKeyEx(regCUSC,
".root", 0,
NULL, 0, KEY_READ | KEY_WRITE,
887 NULL, ®ROOT,
NULL) == ERROR_SUCCESS) {
888 static const char appname[] =
"ROOTDEV.ROOT";
889 ::RegSetValueEx(regROOT,
NULL, 0, REG_SZ, (BYTE*)appname,
sizeof(appname));
891 ::RegCloseKey(regCUSC);
892 ::RegCloseKey(regCUS);
895 ::SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST,
NULL,
NULL);
903 static bool once =
true;
906 if ((arg !=
"root") && (arg !=
"rootn") &&
907 (arg !=
"root.exe") && (arg !=
"rootn.exe"))
return false;
911 if ((arg ==
"-l") || (arg ==
"-b")) {
924 static void SetConsoleWindowName()
926 char pszNewWindowTitle[1024];
927 char pszOldWindowTitle[1024];
929 CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
931 if (!::GetConsoleTitle(pszOldWindowTitle, 1024))
934 wsprintf(pszNewWindowTitle,
"%d/%d", ::GetTickCount(), ::GetCurrentProcessId());
936 if (!::SetConsoleTitle(pszNewWindowTitle))
946 ::SetConsoleTitle(
"ROOT session");
948 hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
949 ::SetConsoleMode(hStdout, ENABLE_PROCESSED_OUTPUT |
950 ENABLE_WRAP_AT_EOL_OUTPUT);
951 if (!::GetConsoleScreenBufferInfo(hStdout, &csbiInfo))
988 fGUIThreadHandle(0), fGUIThreadId(0)
996 if (initwinsock = ::WSAStartup(MAKEWORD(2, 0), &WSAData)) {
997 Error(
"TWinNTSystem()",
"Starting sockets failed");
1008 char *buf =
new char[MAX_MODULE_NAME32 + 1];
1012 HMODULE hModCore = ::GetModuleHandle(
"libCore.dll");
1015 char *pLibName = strstr(buf,
"libCore.dll");
1018 while (--pLibName >= buf && *pLibName !=
'\\' && *pLibName !=
'/');
1021 check_path +=
"\\etc";
1023 while (buf[0] && GetFileAttributes(check_path.
Data()) == INVALID_FILE_ATTRIBUTES) {
1024 while (--pLibName >= buf && *pLibName !=
'\\' && *pLibName !=
'/');
1027 check_path +=
"\\etc";
1040 UpdateRegistry(
this, buf);
1051 typedef UINT (WINAPI* LPTIMEENDPERIOD)( UINT uPeriod );
1052 HINSTANCE hInstWinMM = LoadLibrary(
"winmm.dll" );
1054 LPTIMEENDPERIOD pTimeEndPeriod = (LPTIMEENDPERIOD)GetProcAddress( hInstWinMM,
"timeEndPeriod" );
1055 if(
NULL != pTimeEndPeriod )
1057 FreeLibrary(hInstWinMM);
1068 ::ResetEvent(gGlobalEvent);
1069 ::CloseHandle(gGlobalEvent);
1072 if (gTimerThreadHandle) {
1073 ::TerminateThread(gTimerThreadHandle, 0);
1074 ::CloseHandle(gTimerThreadHandle);
1083 const char *
dir = 0;
1111 ::SetUnhandledExceptionFilter(ExceptionFilter);
1118 static char lpFilename[MAX_PATH];
1121 sizeof(lpFilename)))
1134 typedef UINT (WINAPI* LPTIMEBEGINPERIOD)( UINT uPeriod );
1135 HINSTANCE hInstWinMM = LoadLibrary(
"winmm.dll" );
1137 LPTIMEBEGINPERIOD pTimeBeginPeriod = (LPTIMEBEGINPERIOD)GetProcAddress( hInstWinMM,
"timeBeginPeriod" );
1138 if(
NULL != pTimeBeginPeriod )
1139 pTimeBeginPeriod(1);
1140 FreeLibrary(hInstWinMM);
1145 gGlobalEvent = ::CreateEvent(
NULL, TRUE, FALSE,
NULL);
1148 char *buf =
new char[MAX_MODULE_NAME32 + 1];
1149 HMODULE hModCore = ::GetModuleHandle(
"libCore.dll");
1152 char *pLibName = strstr(buf,
"libCore.dll");
1159 SetConsoleWindowName();
1183 const char *symbol=
name;
1186 while ( (*symbol ==
' ' || *symbol ==
'\t') && *symbol) symbol++;
1189 if (isalpha(symbol[idx]) && symbol[idx+1] ==
':') idx = 2;
1190 if ( (symbol[idx] ==
'/' || symbol[idx] ==
'\\') && symbol[idx+1] ==
'\0') {
1195 Error(
"BaseName",
"name = 0");
1199 char *bslash = (
char *)strrchr(&symbol[idx],
'\\');
1200 char *rslash = (
char *)strrchr(&symbol[idx],
'/');
1201 if (cp =
std::max(rslash, bslash)) {
1206 return &symbol[idx];
1208 Error(
"BaseName",
"name = 0");
1224 ULong_t namelen=name ? strlen(name) : 0;
1225 if (name && namelen > 0) {
1227 fullname =
new char[namelen+5];
1228 strlcpy(fullname, name,namelen+5);
1229 if ( !strrchr(fullname,
'.') )
1230 strlcat(fullname,
".exe",namelen+5);
1233 dot = strrchr(progname,
'.');
1234 idot = dot ? (
ULong_t)(dot - progname) : strlen(progname);
1239 which =
StrDup(fullname);
1250 dirname.
Form(
"%c:%s", driveletter, d);
1252 dirname.
Form(
"%s", d);
1265 progname[idot] =
'\0';
1267 if (which)
delete [] which;
1271 if (::NeedSplash()) {
1284 if (err < 0 || err >= sys_nerr) {
1286 error_msg.
Form(
"errno out of range %d", err);
1289 return sys_errlist[err];
1302 DWORD il =
sizeof(hn);
1303 ::GetComputerName(hn, &il);
1319 if (freq < 37) freq = 440;
1320 if (duration < 0) duration = 100;
1329 gGUIThreadMsgFunc =
func;
1352 int fd = h->
GetFd();
1390 set_console =
kTRUE;
1403 ::SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleSigHandler, TRUE);
1429 ::SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleSigHandler, FALSE);
1473 HANDLE snapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD,::GetCurrentProcessId());
1478 if (!InitImagehlpFunctions()) {
1479 std::cerr <<
"No stack trace: cannot find (functions in) dbghelp.dll!" << std::endl;
1484 SYSTEM_INFO sysInfo;
1485 ::GetSystemInfo(&sysInfo);
1486 DWORD machineType = IMAGE_FILE_MACHINE_I386;
1487 switch (sysInfo.wProcessorArchitecture) {
1488 case PROCESSOR_ARCHITECTURE_AMD64:
1489 machineType = IMAGE_FILE_MACHINE_AMD64;
1491 case PROCESSOR_ARCHITECTURE_IA64:
1492 machineType = IMAGE_FILE_MACHINE_IA64;
1496 DWORD currentThreadID = ::GetCurrentThreadId();
1497 DWORD currentProcessID = ::GetCurrentProcessId();
1501 THREADENTRY32 threadentry;
1502 threadentry.dwSize =
sizeof(THREADENTRY32);
1503 if (!::Thread32First(snapshot, &threadentry))
return;
1505 std::cerr << std::endl <<
"==========================================" << std::endl;
1506 std::cerr <<
"=============== STACKTRACE ===============" << std::endl;
1507 std::cerr <<
"==========================================" << std::endl << std::endl;
1510 if (threadentry.th32OwnerProcessID != currentProcessID)
1512 HANDLE thread = ::OpenThread(THREAD_GET_CONTEXT|THREAD_SUSPEND_RESUME|THREAD_QUERY_INFORMATION,
1513 FALSE, threadentry.th32ThreadID);
1515 memset(&context, 0,
sizeof(CONTEXT));
1517 if (threadentry.th32ThreadID != currentThreadID) {
1518 ::SuspendThread(thread);
1519 context.ContextFlags = CONTEXT_ALL;
1520 ::GetThreadContext(thread, &context);
1521 ::ResumeThread(thread);
1523 if (fgXcptContext) {
1524 context = *fgXcptContext;
1526 typedef void (WINAPI *RTLCCTXT)(PCONTEXT);
1527 RTLCCTXT p2RtlCCtxt = (RTLCCTXT) ::GetProcAddress(
1528 GetModuleHandle(
"kernel32.dll"),
"RtlCaptureContext");
1530 context.ContextFlags = CONTEXT_ALL;
1531 p2RtlCCtxt(&context);
1537 ::ZeroMemory(&frame,
sizeof(frame));
1539 frame.AddrPC.Mode = AddrModeFlat;
1540 frame.AddrFrame.Mode = AddrModeFlat;
1541 frame.AddrStack.Mode = AddrModeFlat;
1542 #if defined(_M_IX86)
1543 frame.AddrPC.Offset = context.Eip;
1544 frame.AddrFrame.Offset = context.Ebp;
1545 frame.AddrStack.Offset = context.Esp;
1546 #elif defined(_M_X64)
1547 frame.AddrPC.Offset = context.Rip;
1548 frame.AddrFrame.Offset = context.Rsp;
1549 frame.AddrStack.Offset = context.Rsp;
1550 #elif defined(_M_IA64)
1551 frame.AddrPC.Offset = context.StIIP;
1552 frame.AddrFrame.Offset = context.IntSp;
1553 frame.AddrStack.Offset = context.IntSp;
1554 frame.AddrBStore.Offset= context.RsBSP;
1556 std::cerr <<
"Stack traces not supported on your architecture yet." << std::endl;
1561 while (_StackWalk64(machineType, (HANDLE)::GetCurrentProcess(), thread, (LPSTACKFRAME64)&frame,
1562 (LPVOID)&context, (PREAD_PROCESS_MEMORY_ROUTINE)
NULL, (PFUNCTION_TABLE_ACCESS_ROUTINE)_SymFunctionTableAccess64,
1563 (PGET_MODULE_BASE_ROUTINE)_SymGetModuleBase64, NULL)) {
1565 std::cerr << std::endl <<
"================ Thread " << iThread++ <<
" ================" << std::endl;
1566 if (!bFirst || threadentry.th32ThreadID != currentThreadID) {
1567 const std::string moduleName = GetModuleName(frame.AddrPC.Offset);
1568 const std::string functionName = GetFunctionName(frame.AddrPC.Offset);
1569 std::cerr <<
" " << moduleName << functionName << std::endl;
1573 ::CloseHandle(thread);
1574 }
while (::Thread32Next(snapshot, &threadentry));
1576 std::cerr << std::endl <<
"==========================================" << std::endl;
1577 std::cerr <<
"============= END STACKTRACE =============" << std::endl;
1578 std::cerr <<
"==========================================" << std::endl << std::endl;
1579 ::CloseHandle(snapshot);
1580 _SymCleanup(GetCurrentProcess());
1589 UInt_t oldmask = _statusfp( );
1591 if (oldmask & _EM_INVALID ) mask |=
kInvalid;
1592 if (oldmask & _EM_ZERODIVIDE) mask |=
kDivByZero;
1593 if (oldmask & _EM_OVERFLOW ) mask |=
kOverflow;
1594 if (oldmask & _EM_UNDERFLOW) mask |=
kUnderflow;
1595 if (oldmask & _EM_INEXACT ) mask |=
kInexact;
1609 if (mask &
kInvalid ) newm |= _EM_INVALID;
1610 if (mask &
kDivByZero) newm |= _EM_ZERODIVIDE;
1611 if (mask &
kOverflow ) newm |= _EM_OVERFLOW;
1612 if (mask &
kUnderflow) newm |= _EM_UNDERFLOW;
1613 if (mask &
kInexact ) newm |= _EM_INEXACT;
1615 UInt_t cm = ::_statusfp();
1617 ::_controlfp(cm , _MCW_EM);
1636 if (pendingOnly && gGlobalEvent) ::SetEvent(gGlobalEvent);
1638 Bool_t pollOnce = pendingOnly;
1642 if (
gROOT->GetApplication()) {
1658 ::WaitForSingleObject(gGlobalEvent, 1);
1659 ::ResetEvent(gGlobalEvent);
1685 if (pendingOnly && !pollOnce)
1724 if (!pendingOnly && gGlobalEvent) {
1725 ::WaitForSingleObject(gGlobalEvent, 1);
1726 ::ResetEvent(gGlobalEvent);
1740 for (i = 0; i <
fReadmask->GetCount(); i++) {
1745 rc = WinNTSelect(&t, 0, 0);
1746 if (rc < 0 && rc != -2) {
1747 ::SysError(
"DispatchOneEvent",
"select: read error on %d\n", fd);
1753 for (i = 0; i <
fWritemask->GetCount(); i++) {
1759 rc = WinNTSelect(0, &t, 0);
1760 if (rc < 0 && rc != -2) {
1761 ::SysError(
"DispatchOneEvent",
"select: write error on %d\n", fd);
1813 if (sync == sh->
IsSync()) {
1815 if ((
fSignals->IsSet(sig) && sigdone == -1) || sigdone == sig) {
1816 if (sigdone == -1) {
1826 if (sigdone != -1)
return kTRUE;
1847 if ((
fReadready->IsSet(fd) && fddone == -1) ||
1848 (fddone == fd && read)) {
1858 (fddone == fd && !read)) {
1868 if (fddone != -1)
return kTRUE;
1885 if (dirname.
Length() == 0) {
1894 const char driveletter =
DriveName(name);
1902 if (res)
return res;
1922 const char *proto = (strstr(name,
"file:///")) ?
"file://" :
"file:";
1925 if (!name)
return 0;
1929 if (!name)
return 0;
1961 HANDLE searchFile = (HANDLE)dirp;
1995 return (psz[0] == TEXT(
'\\') && psz[1] == TEXT(
'\\'));
2015 #pragma data_seg(".text", "CODE")
2016 const TCHAR c_szColonSlash[] = TEXT(
":\\");
2030 if (!IsDBCSLeadByte(*pPath)) {
2031 if (!lstrcmpi(pPath + 1, c_szColonSlash))
2035 if ((*pPath == TEXT(
'\\')) && (*(pPath + 1) == 0))
2041 int cBackslashes = 0;
2042 for (p = pPath + 2; *p; p = CharNext(p)) {
2043 if (*p == TEXT(
'\\') && (++cBackslashes > 1))
2063 const char *proto = (strstr(fdir,
"file:///")) ?
"file://" :
"file:";
2066 char *
dir =
new char[MAX_PATH];
2067 if (IsShortcut(sdir)) {
2068 if (!ResolveShortCut(sdir, dir, MAX_PATH))
2069 strlcpy(dir, sdir,MAX_PATH);
2072 strlcpy(dir, sdir,MAX_PATH);
2074 int nche = strlen(dir)+3;
2075 char *
entry =
new char[nche];
2076 struct _stati64 finfo;
2079 strlcpy(entry, dir,nche);
2080 if ((entry[strlen(dir)-1] ==
'/') || (entry[strlen(dir)-1] ==
'\\' )) {
2081 entry[strlen(dir)-1] =
'\0';
2084 strlcat(entry,
"\\",nche);
2086 if (_stati64(entry, &finfo) < 0) {
2093 strlcpy(entry, dir,nche);
2094 if ((entry[strlen(dir)-1] ==
'/') || (entry[strlen(dir)-1] ==
'\\' )) {
2096 entry[strlen(dir)-1] =
'\0';
2098 if (_stati64(entry, &finfo) < 0) {
2105 if (finfo.st_mode & S_IFDIR) {
2106 strlcpy(entry, dir,nche);
2107 if (!(entry[strlen(dir)-1] ==
'/' || entry[strlen(dir)-1] ==
'\\' )) {
2108 strlcat(entry,
"\\",nche);
2110 strlcat(entry,
"*",nche);
2115 ((
TWinNTSystem *)gSystem)->Error(
"Unable to find' for reading:", entry);
2146 char drive = driveletter ? toupper( driveletter ) -
'A' + 1 : 0;
2152 if (!(wdpath = ::_getdcwd( (
int)drive, wdpath,
kMAXPATHLEN))) {
2154 Warning(
"WorkingDirectory",
"getcwd() failed");
2172 if (!(h = ::getenv(
"home"))) h = ::getenv(
"HOME");
2179 h = ::getenv(
"HOMESHARE");
2180 if (!h) h = ::getenv(
"HOMEDRIVE");
2183 h = ::getenv(
"HOMEPATH");
2188 h = ::getenv(
"USERPROFILE");
2193 if (mydir[1] ==
':')
2194 mydir[0] = toupper(mydir[0]);
2204 const char *
dir = gSystem->Getenv(
"TEMP");
2205 if (!dir) dir = gSystem->Getenv(
"TEMPDIR");
2206 if (!dir) dir = gSystem->Getenv(
"TEMP_DIR");
2207 if (!dir) dir = gSystem->Getenv(
"TMP");
2208 if (!dir) dir = gSystem->Getenv(
"TMPDIR");
2209 if (!dir) dir = gSystem->Getenv(
"TMP_DIR");
2210 if (!dir) dir =
"c:\\";
2226 char tmpName[MAX_PATH];
2230 FILE *fp = fopen(tmpName,
"w+");
2232 if (!fp)
::SysError(
"TempFileName",
"error opening %s", tmpName);
2250 if (!opt || !opt[0]) {
2255 UINT nOldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS);
2259 curdrive = _getdrive();
2260 if (strstr(opt,
"cur")) {
2262 sDrive.
Form(
"%c:", (curdrive +
'A' - 1));
2263 sType.
Form(
"Unknown Drive (%s)", sDrive.
Data());
2265 NULL, (LPSTR)szFs, 32);
2266 type = ::GetDriveType(sDrive.
Data());
2269 case DRIVE_NO_ROOT_DIR:
2271 case DRIVE_REMOVABLE:
2272 sType.
Form(
"Removable Disk (%s)", sDrive.
Data());
2275 sType.
Form(
"Local Disk (%s)", sDrive.
Data());
2278 sType.
Form(
"Network Drive (%s) (%s)", szFs, sDrive.
Data());
2281 sType.
Form(
"CD/DVD Drive (%s)", sDrive.
Data());
2284 sType.
Form(
"RAM Disk (%s)", sDrive.
Data());
2289 else if (strstr(opt,
"all")) {
2292 if (::GetLogicalDriveStrings(511, szTemp)) {
2293 TCHAR szDrive[3] = TEXT(
" :");
2299 sDrive.
Form(
"%s", szDrive);
2301 if ((sDrive ==
"A:") || (sDrive ==
"B:")) {
2305 sType.
Form(
"Unknown Drive (%s)", sDrive.
Data());
2308 type = ::GetDriveType(sDrive.
Data());
2311 case DRIVE_NO_ROOT_DIR:
2313 case DRIVE_REMOVABLE:
2314 sType.
Form(
"Removable Disk (%s)", sDrive.
Data());
2317 sType.
Form(
"Local Disk (%s)", sDrive.
Data());
2320 sType.
Form(
"Network Drive (%s) (%s)", szFs, sDrive.
Data());
2323 sType.
Form(
"CD/DVD Drive (%s)", sDrive.
Data());
2326 sType.
Form(
"RAM Disk (%s)", sDrive.
Data());
2336 ::SetErrorMode(nOldErrorMode);
2355 if (strchr(pathname,
'/') || strchr(pathname,
'\\')) {
2356 const char *rslash = strrchr(pathname,
'/');
2357 const char *bslash = strrchr(pathname,
'\\');
2358 const char *
r =
std::max(rslash, bslash);
2359 const char *ptr = pathname;
2369 int len = r - pathname;
2400 if (!pathname)
return 0;
2401 if (!pathname[0])
return 0;
2407 while(*lpchar ==
' ') lpchar++;
2409 if (isalpha((
int)*lpchar) && *(lpchar+1) ==
':') {
2413 if ( (*lpchar ==
'\\' || *lpchar ==
'/' ) &&
2414 (*(lpchar+1) ==
'\\' || *(lpchar+1) ==
'/') )
return 0;
2427 if (strchr(dir,
':')) idx = 2;
2428 return (dir[idx] ==
'/' || dir[idx] ==
'\\');
2461 static char temp[1024];
2462 strlcpy(temp, name,1024);
2463 char *currentChar = temp;
2465 while (*currentChar !=
'\0') {
2466 if (*currentChar ==
'\\') *currentChar =
'/';
2484 UINT nOldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS);
2488 const char *proto = (strstr(path,
"file:///")) ?
"file://" :
"file:";
2491 ::SetErrorMode(nOldErrorMode);
2496 ::SetErrorMode(nOldErrorMode);
2518 if (name ==
".") name =
"";
2519 if (dir && dir[0]) {
2521 char last = dir[strlen(dir) - 1];
2522 if (last !=
'/' && last !=
'\\') {
2543 if (!ret)
return -1;
2552 int ret = ::rename(f, t);
2569 struct _stati64 sbuf;
2572 const char *proto = (strstr(path,
"file:///")) ?
"file://" :
"file:";
2574 int l = strlen(newpath);
2576 if (newpath[--l] !=
'\\' || newpath[--l] !=
'/') {
2582 if (newpath && ::_stati64(newpath, &sbuf) >= 0) {
2584 buf.
fDev = sbuf.st_dev;
2585 buf.
fIno = sbuf.st_ino;
2586 buf.
fMode = sbuf.st_mode;
2587 buf.
fUid = sbuf.st_uid;
2588 buf.
fGid = sbuf.st_gid;
2589 buf.
fSize = sbuf.st_size;
2590 buf.
fMtime = sbuf.st_mtime;
2591 buf.
fIsLink = IsShortcut(newpath);
2593 char *lpath =
new char[MAX_PATH];
2594 if (IsShortcut(newpath)) {
2595 struct _stati64 sbuf2;
2596 if (ResolveShortCut(newpath, lpath, MAX_PATH)) {
2597 if (::_stati64(lpath, &sbuf2) >= 0) {
2598 buf.
fMode = sbuf2.st_mode;
2624 LPCTSTR lpRootPathName = path;
2627 LPTSTR lpVolumeNameBuffer = 0;
2628 DWORD nVolumeNameSize = 0;
2630 DWORD volumeSerialNumber;
2631 DWORD maximumComponentLength;
2634 DWORD fileSystemFlags;
2637 char fileSystemNameBuffer[512];
2638 DWORD nFileSystemNameSize =
sizeof(fileSystemNameBuffer);
2641 UINT nOldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS);
2642 if (!::GetVolumeInformation(lpRootPathName,
2643 lpVolumeNameBuffer, nVolumeNameSize,
2644 &volumeSerialNumber,
2645 &maximumComponentLength,
2647 fileSystemNameBuffer, nFileSystemNameSize)) {
2649 ::SetErrorMode(nOldErrorMode);
2653 const char *fsNames[] = {
"FAT",
"NTFS" };
2655 for (i = 0; i < 2; i++) {
2656 if (!strncmp(fileSystemNameBuffer, fsNames[i], nFileSystemNameSize))
2661 DWORD sectorsPerCluster;
2662 DWORD bytesPerSector;
2663 DWORD numberOfFreeClusters;
2664 DWORD totalNumberOfClusters;
2666 if (!::GetDiskFreeSpace(lpRootPathName,
2669 &numberOfFreeClusters,
2670 &totalNumberOfClusters)) {
2672 ::SetErrorMode(nOldErrorMode);
2676 ::SetErrorMode(nOldErrorMode);
2678 *bsize = sectorsPerCluster * bytesPerSector;
2679 *blocks = totalNumberOfClusters;
2680 *bfree = numberOfFreeClusters;
2690 struct _stati64 finfo;
2695 char linkname[1024];
2696 LPTSTR lpszFilePart;
2697 TCHAR szPath[MAX_PATH];
2700 typedef BOOL (__stdcall *CREATEHARDLINKPROC)( LPCTSTR, LPCTSTR, LPSECURITY_ATTRIBUTES );
2701 static CREATEHARDLINKPROC _CreateHardLink = 0;
2703 HMODULE hModImagehlp = LoadLibrary(
"Kernel32.dll" );
2708 _CreateHardLink = (CREATEHARDLINKPROC) GetProcAddress( hModImagehlp,
"CreateHardLinkW" );
2710 _CreateHardLink = (CREATEHARDLINKPROC) GetProcAddress( hModImagehlp,
"CreateHardLinkA" );
2712 if (!_CreateHardLink)
2715 dwRet = GetFullPathName(from,
sizeof(szPath) /
sizeof(TCHAR),
2716 szPath, &lpszFilePart);
2718 if (_stati64(szPath, &finfo) < 0)
2721 if (finfo.st_mode & S_IFDIR)
2724 snprintf(linkname,1024,
"%s",to);
2725 _splitpath(linkname,winDrive,winDir,winName,winExt);
2726 if ((!winDrive[0] ) &&
2728 _splitpath(szPath,winDrive,winDir,winName,winExt);
2729 snprintf(linkname,1024,
"%s\\%s\\%s", winDrive, winDir, to);
2731 else if (!winDrive[0]) {
2732 _splitpath(szPath,winDrive,winDir,winName,winExt);
2733 snprintf(linkname,1024,
"%s\\%s", winDrive, to);
2736 if (!_CreateHardLink(linkname, szPath,
NULL))
2749 IShellLink* pShellLink;
2750 IPersistFile* pPersistFile;
2751 WCHAR wszLinkfile[MAX_PATH];
2752 int iWideCharsWritten;
2754 LPTSTR lpszFilePart;
2755 TCHAR szPath[MAX_PATH];
2757 hRes = E_INVALIDARG;
2758 if ((from ==
NULL) || (!from[0]) || (to ==
NULL) ||
2764 typedef HRESULT (__stdcall *COINITIALIZEPROC)( LPVOID );
2765 static COINITIALIZEPROC _CoInitialize = 0;
2766 typedef void (__stdcall *COUNINITIALIZEPROC)(
void );
2767 static COUNINITIALIZEPROC _CoUninitialize = 0;
2768 typedef HRESULT (__stdcall *COCREATEINSTANCEPROC)( REFCLSID, LPUNKNOWN, DWORD, REFIID, LPVOID );
2769 static COCREATEINSTANCEPROC _CoCreateInstance = 0;
2771 HMODULE hModImagehlp = LoadLibrary(
"ole32.dll" );
2775 _CoInitialize = (COINITIALIZEPROC) GetProcAddress( hModImagehlp,
"CoInitialize" );
2778 _CoUninitialize = (COUNINITIALIZEPROC) GetProcAddress( hModImagehlp,
"CoUninitialize" );
2779 if (!_CoUninitialize)
2781 _CoCreateInstance = (COCREATEINSTANCEPROC) GetProcAddress( hModImagehlp,
"CoCreateInstance" );
2782 if (!_CoCreateInstance)
2789 _CoInitialize(
NULL);
2792 dwRet = GetFullPathName(from,
sizeof(szPath) /
sizeof(TCHAR),
2793 szPath, &lpszFilePart);
2794 hRes = _CoCreateInstance(CLSID_ShellLink,
NULL, CLSCTX_INPROC_SERVER,
2795 IID_IShellLink, (LPVOID *)&pShellLink);
2796 if (SUCCEEDED(hRes)) {
2798 hRes = pShellLink->SetPath(szPath);
2800 hRes = pShellLink->QueryInterface(IID_IPersistFile, (
void **)&pPersistFile);
2801 if (SUCCEEDED(hRes)){
2802 iWideCharsWritten = MultiByteToWideChar(CP_ACP, 0, linkname.
Data(), -1,
2803 wszLinkfile, MAX_PATH);
2804 hRes = pPersistFile->Save(wszLinkfile, TRUE);
2805 pPersistFile->Release();
2807 pShellLink->Release();
2820 return helper->
Unlink(name);
2822 struct _stati64 finfo;
2824 if (_stati64(name, &finfo) < 0) {
2828 if (finfo.st_mode & S_IFDIR) {
2829 return ::_rmdir(name);
2831 return ::_unlink(name);
2840 if (::ioctlsocket(fd, FIONBIO, (u_long *)1) == SOCKET_ERROR) {
2859 const char *patbuf = (
const char *)patbuf0;
2877 while (*patbuf ==
' ') {
2882 while (*patbuf ==
':') {
2887 while (*patbuf ==
';') {
2893 for (q = (
char*)patbuf; *
q; q++) {
2897 if ( (((q-2)>patbuf) && ( (*(q-2)!=
';') || !isalpha(*(q-1)) )) &&
2904 for (p = patbuf; *p; p++) {
2921 char replacement[4];
2924 for (
int k = 0; k<3; k++) replacement[k] = 0
x1;
2926 replacement[3] = 0x0;
2930 while ( (pos = patbuf0.
Index(TildaNum,pos)) !=
kNPOS ) {
2931 patbuf0.
Replace(pos, 1, replacement);
2937 Int_t lbuf = ::ExpandEnvironmentStrings(
2943 cmd =
new char[lbuf+1];
2944 ::ExpandEnvironmentStrings(
2963 char newpath[MAX_PATH];
2964 if (IsShortcut(path)) {
2965 if (!ResolveShortCut(path, newpath, MAX_PATH))
2966 strlcpy(newpath, path, MAX_PATH);
2969 strlcpy(newpath, path, MAX_PATH);
2984 return ::_chmod(file, mode);
2992 return ::umask(mask);
3002 Error(
"Utime",
"need write permission for %s to change utime", file);
3005 if (!actime) actime = modtime;
3008 t.actime = (time_t)actime;
3009 t.modtime = (time_t)modtime;
3010 return ::utime(file, &t);
3025 gSystem->ExpandPathName(infile);
3029 return infile.
Data();
3034 gSystem->ExpandPathName(exsearch);
3037 Int_t lastDelim = -1;
3038 for(
int i=0; i < exsearch.
Length(); ++i) {
3039 switch( exsearch[i] ) {
3042 if (i-lastDelim!=2) exsearch[i] =
';';
3045 case ';': lastDelim = i;
break;
3052 char *lpFilePart = 0;
3054 ::access(name, mode) == 0 && stat(name, &finfo) == 0 &&
3055 finfo.st_mode & S_IFREG) {
3057 Printf(
"Which: %s = %s", infile, name);
3060 return infile.
Data();
3074 if ((
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) && (::GetVersion() < 0x80000000)) {
3077 HINSTANCE netapi = ::LoadLibrary(
"netapi32.DLL");
3078 if (!netapi)
return kFALSE;
3080 p2NetApiBufferFree = (pfn1)::GetProcAddress(netapi,
"NetApiBufferFree");
3081 p2NetUserGetInfo = (pfn2)::GetProcAddress(netapi,
"NetUserGetInfo");
3082 p2NetLocalGroupGetMembers = (pfn3)::GetProcAddress(netapi,
"NetLocalGroupGetMembers");
3083 p2NetLocalGroupEnum = (pfn4)::GetProcAddress(netapi,
"NetLocalGroupEnum");
3085 if (!p2NetApiBufferFree || !p2NetUserGetInfo ||
3086 !p2NetLocalGroupGetMembers || !p2NetLocalGroupEnum)
return kFALSE;
3097 ::FreeLibrary(netapi);
3107 NET_API_STATUS NetStatus = NERR_Success;
3109 DWORD
Index = 0, ResumeHandle = 0, Total = 0;
3110 LOCALGROUP_MEMBERS_INFO_1 *MemberInfo;
3111 WCHAR wszGroupName[256];
3113 DWORD dwLastError = 0;
3115 iRetOp = MultiByteToWideChar (
3117 (DWORD)MB_PRECOMPOSED,
3118 (LPCSTR)lpszGroupName,
3120 (LPWSTR)wszGroupName,
3121 (
int)
sizeof(wszGroupName) );
3124 dwLastError = GetLastError();
3126 p2NetApiBufferFree(Data);
3132 NetStatus = p2NetLocalGroupGetMembers (
NULL, wszGroupName, 1,
3133 &Data, 8192, &Index, &Total, &ResumeHandle );
3135 if (NetStatus != NERR_Success || Data ==
NULL) {
3136 dwLastError = GetLastError();
3138 if (dwLastError == ERROR_ENVVAR_NOT_FOUND) {
3144 NetStatus = p2NetLocalGroupGetMembers (
NULL, wszGroupName, 0,
3145 &Data, 8192, &Index, &Total, &ResumeHandle );
3149 p2NetApiBufferFree(Data);
3154 MemberInfo = (LOCALGROUP_MEMBERS_INFO_1 *)Data;
3157 p2NetApiBufferFree(Data);
3166 NET_API_STATUS NetStatus = NERR_Success;
3168 DWORD
Index = 0, ResumeHandle = 0, Total = 0, i;
3169 LOCALGROUP_INFO_0 *GroupInfo;
3170 char szAnsiName[256];
3171 DWORD dwLastError = 0;
3174 NetStatus = p2NetLocalGroupEnum(
NULL, 0, &Data, 8192, &Index,
3175 &Total, &ResumeHandle );
3177 if (NetStatus != NERR_Success || Data ==
NULL) {
3178 dwLastError = GetLastError();
3180 p2NetApiBufferFree(Data);
3185 GroupInfo = (LOCALGROUP_INFO_0 *)Data;
3186 for (i=0; i < Total; i++) {
3188 iRetOp = WideCharToMultiByte (
3191 (LPCWSTR)(GroupInfo->lgrpi0_name),
3194 (
int)(
sizeof(szAnsiName)),
3206 p2NetApiBufferFree(Data);
3218 int &groupIdx,
int &memberIdx)
3220 BOOL bRetOp = FALSE;
3222 DWORD dwSidSize, dwDomainNameSize;
3225 SID_NAME_USE sidType;
3226 PUCHAR puchar_SubAuthCount =
NULL;
3227 SID_IDENTIFIER_AUTHORITY sid_identifier_authority;
3228 PSID_IDENTIFIER_AUTHORITY psid_identifier_authority =
NULL;
3229 unsigned char j = 0;
3230 DWORD dwLastError = 0;
3232 pSid = (PSID)bySidBuffer;
3233 dwSidSize =
sizeof(bySidBuffer);
3234 dwDomainNameSize =
sizeof(szDomainName);
3236 bRetOp = LookupAccountName (
3238 (LPCTSTR)lpszAccountName,
3240 (LPDWORD)&dwSidSize,
3241 (LPTSTR)szDomainName,
3242 (LPDWORD)&dwDomainNameSize,
3243 (PSID_NAME_USE)&sidType );
3245 if (bRetOp == FALSE) {
3246 dwLastError = GetLastError();
3250 bRetOp = IsValidSid((PSID)pSid);
3252 if (bRetOp == FALSE) {
3253 dwLastError = GetLastError();
3258 psid_identifier_authority = GetSidIdentifierAuthority ((PSID)pSid);
3261 memcpy (&sid_identifier_authority, psid_identifier_authority,
3262 sizeof(SID_IDENTIFIER_AUTHORITY));
3265 puchar_SubAuthCount = (PUCHAR)GetSidSubAuthorityCount((PSID)pSid);
3267 j = (
unsigned char)(*puchar_SubAuthCount);
3269 DWORD dwSubAuth = 0;
3270 PDWORD pdwSubAuth =
NULL;
3272 pdwSubAuth = (PDWORD)GetSidSubAuthority (
3275 dwSubAuth = *pdwSubAuth;
3294 NET_API_STATUS NetStatus = NERR_Success;
3296 DWORD
Index = 0, ResumeHandle = 0, Total = 0, i;
3297 LOCALGROUP_MEMBERS_INFO_1 *MemberInfo;
3298 char szAnsiMemberName[256];
3299 char szFullMemberName[256];
3300 char szMemberHomeDir[256];
3301 WCHAR wszGroupName[256];
3304 DWORD length =
sizeof (act_name);
3305 DWORD dwLastError = 0;
3306 LPUSER_INFO_11 pUI11Buf =
NULL;
3307 NET_API_STATUS nStatus;
3309 iRetOp = MultiByteToWideChar (
3311 (DWORD)MB_PRECOMPOSED,
3312 (LPCSTR)lpszGroupName,
3314 (LPWSTR)wszGroupName,
3315 (
int)
sizeof(wszGroupName) );
3318 dwLastError = GetLastError();
3320 p2NetApiBufferFree(Data);
3324 GetUserName (act_name, &length);
3328 NetStatus = p2NetLocalGroupGetMembers (
NULL, wszGroupName, 1,
3329 &Data, 8192, &Index, &Total, &ResumeHandle );
3331 if (NetStatus != NERR_Success || Data ==
NULL) {
3332 dwLastError = GetLastError();
3334 if (dwLastError == ERROR_ENVVAR_NOT_FOUND) {
3340 NetStatus = p2NetLocalGroupGetMembers (
NULL, wszGroupName, 0,
3341 &Data, 8192, &Index, &Total, &ResumeHandle );
3345 p2NetApiBufferFree(Data);
3349 MemberInfo = (LOCALGROUP_MEMBERS_INFO_1 *)Data;
3350 for (i=0; i < Total; i++) {
3351 iRetOp = WideCharToMultiByte (
3354 (LPCWSTR)(MemberInfo->lgrmi1_name),
3356 (LPSTR)szAnsiMemberName,
3357 (
int)(
sizeof(szAnsiMemberName)),
3362 dwLastError = GetLastError();
3373 TCHAR szUserName[255]=TEXT(
"");
3374 MultiByteToWideChar(CP_ACP, 0, szAnsiMemberName, -1, (LPWSTR)szUserName, 255);
3378 nStatus = p2NetUserGetInfo(NULL, (LPCWSTR)szUserName, 11, (LPBYTE *)&pUI11Buf);
3382 if (nStatus == NERR_Success) {
3383 if (pUI11Buf != NULL) {
3384 wsprintf(szFullMemberName,
"%S",pUI11Buf->usri11_full_name);
3386 wsprintf(szMemberHomeDir,
"%S",pUI11Buf->usri11_home_dir);
3397 if (pUI11Buf != NULL) {
3398 p2NetApiBufferFree(pUI11Buf);
3403 if (getenv(
"SHELL") == NULL)
3404 putenv ((GetVersion () & 0x80000000) ?
"SHELL=command" :
"SHELL=cmd");
3417 p2NetApiBufferFree(Data);
3427 NET_API_STATUS NetStatus = NERR_Success;
3429 DWORD
Index = 0, ResumeHandle = 0, Total = 0, i;
3430 LOCALGROUP_INFO_0 *GroupInfo;
3431 char szAnsiName[256];
3432 DWORD dwLastError = 0;
3433 int iRetOp = 0, iGroupIdx = 0, iMemberIdx = 0;
3435 NetStatus = p2NetLocalGroupEnum(
NULL, 0, &Data, 8192, &Index,
3436 &Total, &ResumeHandle );
3438 if (NetStatus != NERR_Success || Data ==
NULL) {
3439 dwLastError = GetLastError();
3441 p2NetApiBufferFree(Data);
3445 GroupInfo = (LOCALGROUP_INFO_0 *)Data;
3446 for (i=0; i < Total; i++) {
3448 iRetOp = WideCharToMultiByte (
3451 (LPCWSTR)(GroupInfo->lgrpi0_name),
3454 (
int)(
sizeof(szAnsiName)),
3472 p2NetApiBufferFree(Data);
3486 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3489 DWORD length =
sizeof (
name);
3490 if (::GetUserName (name, &length)) {
3491 if (stricmp (
"administrator", name) == 0)
3501 if (!user || !user[0])
3527 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3530 DWORD length =
sizeof (
name);
3531 if (::GetUserName (name, &length)) {
3532 if (stricmp (
"administrator", name) == 0)
3554 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3557 DWORD length =
sizeof (
name);
3558 if (::GetUserName (name, &length)) {
3559 if (stricmp (
"administrator", name) == 0)
3569 if (!group || !group[0])
3572 struct group *grp = 0;
3595 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3598 DWORD length =
sizeof (
name);
3599 if (::GetUserName (name, &length)) {
3600 if (stricmp (
"administrator", name) == 0)
3623 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3625 DWORD length =
sizeof (
name);
3627 if (::GetUserName (name, &length)) {
3629 if (stricmp (
"administrator", name) == 0) {
3631 ug->
fGroup =
"administrators";
3640 ug->
fUser =
"unknown";
3653 for (
int i = 0; i <
fNbUsers; i++) {
3697 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3699 DWORD length =
sizeof (
name);
3701 if (::GetUserName (name, &length)) {
3702 if (stricmp (
"administrator", name) == 0) {
3703 gr->
fGroup =
"administrators";
3718 struct group *grp = 0;
3763 const char *env = ::getenv(name);
3765 if (::_stricmp(name,
"home") == 0 ) {
3767 }
else if (::_stricmp(name,
"rootsys") == 0 ) {
3781 return ::system(shellcmd);
3789 return ::_popen(command, mode);
3797 return ::_pclose(pipe);
3824 gROOT->CloseFiles();
3825 if (
gROOT->GetListOfBrowsers()) {
3832 gROOT->ProcessLine(
TString::Format(
"((TBrowser*)0x%lx)->GetBrowserImp()->GetMainFrame()->CloseWindow();",
3874 static int fd1=0, fd2=0;
3875 static fpos_t pos1=0, pos2=0;
3885 const char *
m = (mode[0] ==
'a' || mode[0] ==
'w') ? mode :
"a";
3892 if (!gSystem->GetPathInfo(file, st))
3898 fgetpos(stdout, &pos1);
3899 fd1 = _dup(fileno(stdout));
3901 if ((fout = freopen(file, m, stdout)) == 0) {
3902 SysError(
"RedirectOutput",
"could not freopen stdout");
3904 _dup2(fd1, fileno(stdout));
3908 fsetpos(stdout, &pos1);
3913 fgetpos(stderr, &pos2);
3914 fd2 = _dup(fileno(stderr));
3915 if ((ferr = freopen(file, m, stderr)) == 0) {
3916 SysError(
"RedirectOutput",
"could not freopen stderr");
3918 _dup2(fd1, fileno(stdout));
3922 fsetpos(stdout, &pos1);
3924 _dup2(fd2, fileno(stderr));
3928 fsetpos(stderr, &pos2);
3933 fseek(fout, 0, SEEK_END);
3934 fseek(ferr, 0, SEEK_END);
3941 if (_dup2(fd1, fileno(stdout))) {
3942 SysError(
"RedirectOutput",
"could not restore stdout");
3948 fsetpos(stdout, &pos1);
3955 if (_dup2(fd2, fileno(stderr))) {
3956 SysError(
"RedirectOutput",
"could not restore stderr");
3962 fsetpos(stderr, &pos2);
4017 if (len > 4 && (!stricmp(sLib.
Data()+len-4,
".dll"))) {
4030 Error(
"DynamicPathName",
4031 "%s does not exist in %s,\nor has wrong file extension (.dll)",
4048 #pragma warning(push)
4049 #pragma warning(disable:4200)
4066 if (!linkedLibs.
IsNull())
4079 HANDLE hFile, hMapping;
4082 if((hFile = CreateFile(exe,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,0))==
INVALID_HANDLE_VALUE) {
4086 if(!(hMapping = CreateFileMapping(hFile,0,PAGE_READONLY|SEC_COMMIT,0,0,0))) {
4091 if(!(basepointer = MapViewOfFile(hMapping,FILE_MAP_READ,0,0,0))) {
4092 CloseHandle(hMapping);
4099 IMAGE_DOS_HEADER *dos_head = (IMAGE_DOS_HEADER *)basepointer;
4102 IMAGE_FILE_HEADER _head;
4103 IMAGE_OPTIONAL_HEADER opt_head;
4104 IMAGE_SECTION_HEADER section_header[];
4106 struct header *pheader;
4107 const IMAGE_SECTION_HEADER * section_header;
4109 if(dos_head->e_magic!=
'ZM') {
4114 pheader = (
struct header *)((
char*)dos_head + dos_head->e_lfanew);
4116 if(IsBadReadPtr(pheader,
sizeof(
struct header))) {
4120 if(pheader->signature!=IMAGE_NT_SIGNATURE) {
4121 switch((
unsigned short)pheader->signature) {
4122 case IMAGE_DOS_SIGNATURE:
4125 case IMAGE_OS2_SIGNATURE:
4128 case IMAGE_OS2_SIGNATURE_LE:
4136 #define isin(address,start,length) ((address)>=(start) && (address)<(start)+(length))
4139 for(sect=0,section_header=pheader->section_header;
4140 sect<pheader->_head.NumberOfSections;sect++,section_header++) {
4142 const void *
const section_data =
4143 (
char*)basepointer + section_header->PointerToRawData;
4144 for(directory=0;directory<IMAGE_NUMBEROF_DIRECTORY_ENTRIES;directory++) {
4145 if(
isin(pheader->opt_head.DataDirectory[directory].VirtualAddress,
4146 section_header->VirtualAddress,
4147 section_header->SizeOfRawData)) {
4148 const IMAGE_IMPORT_DESCRIPTOR *stuff_start =
4149 (IMAGE_IMPORT_DESCRIPTOR *)((
char*)section_data +
4150 (pheader->opt_head.DataDirectory[directory].VirtualAddress -
4151 section_header->VirtualAddress));
4154 const unsigned stuff_length =
4155 pheader->opt_head.DataDirectory[directory].Size;
4156 if(directory == IMAGE_DIRECTORY_ENTRY_IMPORT) {
4157 while(!IsBadReadPtr(stuff_start,
sizeof(*stuff_start)) &&
4158 stuff_start->Name) {
4159 TString dll = (
char*)section_data +
4160 ((DWORD)(stuff_start->Name)) -
4161 section_header->VirtualAddress;
4165 char *winPath = getenv(
"windir");
4166 _splitpath(winPath,winDrive,winDir,winName,winExt);
4167 if(!strstr(dllPath, winDir)) {
4168 if (!linkedLibs.
IsNull())
4170 linkedLibs += dllPath;
4182 UnmapViewOfFile(basepointer);
4183 CloseHandle(hMapping);
4195 #pragma warning(pop)
4222 start = index = end = 0;
4224 while ((start < libs.
Length()) && (index !=
kNPOS)) {
4225 index = libs.
Index(separator, &end, start);
4229 s = libs(index, end);
4306 if (mode && t->
IsSync()) {
4310 }
else if (!mode && t->
IsAsync()) {
4328 FILETIME ftFileTime;
4332 ::GetSystemTimeAsFileTime(&ftRealTime.ftFileTime);
4341 OSVERSIONINFO OsVersionInfo;
4350 OsVersionInfo.dwOSVersionInfoSize =
sizeof(OSVERSIONINFO);
4351 GetVersionEx(&OsVersionInfo);
4352 if (OsVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) {
4358 FILETIME ftFileTime;
4363 FILETIME ftFileTime;
4367 HANDLE hThread = GetCurrentThread();
4368 ret = GetThreadTimes (hThread, &ftCreate, &ftExit,
4369 &ftKernel.ftFileTime,
4370 &ftUser.ftFileTime);
4372 ret = ::GetLastError();
4373 ::Error(
"GetCPUTime",
" Error on GetProcessTimes 0x%lx", (
int)ret);
4382 return (
Double_t) (ftKernel.ftInt64 + ftUser.ftInt64) * gTicks;
4393 static time_t jan95 = 0;
4404 jan95 = mktime(&tp);
4405 if ((
int)jan95 == -1) {
4406 ::SysError(
"TWinNTSystem::Now",
"error converting 950001 0:00 to time_t");
4413 return TTime((now.time-(
Long_t)jan95)*1000 + now.millitm);
4445 rc = WinNTSelect(&rd, &wr, to);
4479 rc = WinNTSelect(&rd, &wr, to);
4501 if ((sp = ::getservbyname(servicename, kProtocolName)) == 0) {
4502 Error(
"GetServiceByName",
"no service \"%s\" with protocol \"%s\"\n",
4503 servicename, kProtocolName);
4506 return ::ntohs(sp->s_port);
4517 if ((sp = ::getservbyport(::htons(port), kProtocolName)) == 0) {
4518 return Form(
"%d", port);
4528 struct hostent *host_ptr;
4533 if ((addr = ::inet_addr(hostname)) != INADDR_NONE) {
4535 if ((host_ptr = ::gethostbyaddr((
const char *)&addr,
4536 sizeof(addr), AF_INET))) {
4537 host = host_ptr->h_name;
4541 for (i = 1; host_ptr->h_addr_list[i]; i++) {
4542 memcpy(&addr2, host_ptr->h_addr_list[i], host_ptr->h_length);
4545 for (i = 0; host_ptr->h_aliases[i]; i++)
4546 a.
AddAlias(host_ptr->h_aliases[i]);
4549 host =
"UnNamedHost";
4551 }
else if ((host_ptr = ::gethostbyname(hostname))) {
4553 if (host_ptr->h_addrtype != AF_INET) {
4554 Error(
"GetHostByName",
"%s is not an internet host\n", hostname);
4557 memcpy(&addr, host_ptr->h_addr, host_ptr->h_length);
4558 host = host_ptr->h_name;
4559 type = host_ptr->h_addrtype;
4563 for (i = 1; host_ptr->h_addr_list[i]; i++) {
4564 memcpy(&addr2, host_ptr->h_addr_list[i], host_ptr->h_length);
4567 for (i = 0; host_ptr->h_aliases[i]; i++)
4568 a.
AddAlias(host_ptr->h_aliases[i]);
4571 if (
gDebug > 0)
Error(
"GetHostByName",
"unknown host %s", hostname);
4584 struct sockaddr_in addr;
4585 int len =
sizeof(addr);
4587 if (::getpeername(sock, (
struct sockaddr *)&addr, &len) == SOCKET_ERROR) {
4592 struct hostent *host_ptr;
4593 const char *hostname;
4597 if ((host_ptr = ::gethostbyaddr((
const char *)&addr.sin_addr,
4598 sizeof(addr.sin_addr), AF_INET))) {
4599 memcpy(&iaddr, host_ptr->h_addr, host_ptr->h_length);
4600 hostname = host_ptr->h_name;
4601 family = host_ptr->h_addrtype;
4603 memcpy(&iaddr, &addr.sin_addr,
sizeof(addr.sin_addr));
4608 return TInetAddress(hostname, ::ntohl(iaddr), family, ::ntohs(addr.sin_port));
4617 struct sockaddr_in addr;
4618 int len =
sizeof(addr);
4620 if (::getsockname(sock, (
struct sockaddr *)&addr, &len) == SOCKET_ERROR) {
4625 struct hostent *host_ptr;
4626 const char *hostname;
4630 if ((host_ptr = ::gethostbyaddr((
const char *)&addr.sin_addr,
4631 sizeof(addr.sin_addr), AF_INET))) {
4632 memcpy(&iaddr, host_ptr->h_addr, host_ptr->h_length);
4633 hostname = host_ptr->h_name;
4634 family = host_ptr->h_addrtype;
4636 memcpy(&iaddr, &addr.sin_addr,
sizeof(addr.sin_addr));
4641 return TInetAddress(hostname, ::ntohl(iaddr), family, ::ntohs(addr.sin_port));
4652 if ((sock = ::socket(AF_INET, SOCK_STREAM, 0)) ==
INVALID_SOCKET) {
4653 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"socket");
4657 struct sockaddr_in inserver;
4658 memset(&inserver, 0,
sizeof(inserver));
4659 inserver.sin_family = AF_INET;
4660 inserver.sin_addr.s_addr = ::htonl(INADDR_LOOPBACK);
4661 inserver.sin_port = port;
4665 if (::bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver)) == SOCKET_ERROR) {
4666 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"bind");
4671 if (::listen(sock, backlog)) {
4672 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"listen");
4684 if (!sockpath || strlen(sockpath) <= 0) {
4685 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"socket path undefined");
4689 struct sockaddr_in myaddr;
4691 int len =
sizeof myaddr;
4696 if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
4697 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"socket");
4701 memset(&myaddr, 0,
sizeof(myaddr));
4702 myaddr.sin_port = 0;
4703 myaddr.sin_family = AF_INET;
4704 myaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
4706 rc = bind(sock, (
struct sockaddr *)&myaddr, len);
4708 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"bind");
4711 rc = getsockname(sock, (
struct sockaddr *)&myaddr, &len);
4713 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"getsockname");
4716 TString socketpath = sockpath;
4718 fp = fopen(socketpath,
"wb");
4720 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"fopen");
4723 fprintf(fp,
"%d", myaddr.sin_port);
4727 if (listen(sock, backlog)) {
4728 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"listen");
4740 if (socket == -1)
return;
4744 ::shutdown(sock, 2);
4746 struct linger linger = {0, 0};
4747 ::setsockopt(sock, SOL_SOCKET, SO_LINGER, (
char *) &linger,
sizeof(linger));
4748 while (::
closesocket(sock) == SOCKET_ERROR && WSAGetLastError() == WSAEINTR) {
4762 if (WinNTRecv(sock, &header,
sizeof(header), 0) > 0) {
4763 int count = ::ntohl(header);
4765 if (count > length) {
4766 Error(
"RecvBuf",
"record header exceeds buffer size");
4768 }
else if (count > 0) {
4769 if (WinNTRecv(sock, buf, count, 0) < 0) {
4770 Error(
"RecvBuf",
"cannot receive buffer");
4785 Int_t header = ::htonl(length);
4787 if (WinNTSend(sock, &header,
sizeof(header), 0) < 0) {
4788 Error(
"SendBuf",
"cannot send header");
4792 if (WinNTSend(sock, buf, length, 0) < 0) {
4793 Error(
"SendBuf",
"cannot send buffer");
4833 if ((n = WinNTRecv(sock, buf, length, flag)) <= 0) {
4835 Error(
"RecvRaw",
"cannot receive buffer");
4869 if ((n = WinNTSend(sock, buf, length, flag)) <= 0) {
4870 if (n == -1 &&
GetErrno() != EINTR) {
4871 Error(
"SendRaw",
"cannot send buffer");
4884 if (socket == -1)
return -1;
4889 if (::setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4890 ::SysError(
"SetSockOpt",
"setsockopt(SO_SNDBUF)");
4895 if (::setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4896 ::SysError(
"SetSockOpt",
"setsockopt(SO_RCVBUF)");
4901 if (::setsockopt(sock, SOL_SOCKET, SO_OOBINLINE, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4902 SysError(
"SetSockOpt",
"setsockopt(SO_OOBINLINE)");
4907 if (::setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4908 ::SysError(
"SetSockOpt",
"setsockopt(SO_KEEPALIVE)");
4913 if (::setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4914 ::SysError(
"SetSockOpt",
"setsockopt(SO_REUSEADDR)");
4919 if (::setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4920 ::SysError(
"SetSockOpt",
"setsockopt(TCP_NODELAY)");
4925 if (::ioctlsocket(sock, FIONBIO, &val) == SOCKET_ERROR) {
4932 if (::ioctl(sock, SIOCSPGRP, &val) == -1) {
4933 ::SysError(
"SetSockOpt",
"ioctl(SIOCSPGRP)");
4941 Error(
"SetSockOpt",
"illegal option (%d)", opt);
4953 if (socket == -1)
return -1;
4956 int optlen =
sizeof(*val);
4960 if (::getsockopt(sock, SOL_SOCKET, SO_SNDBUF, (
char*)val, &optlen) == SOCKET_ERROR) {
4961 ::SysError(
"GetSockOpt",
"getsockopt(SO_SNDBUF)");
4966 if (::getsockopt(sock, SOL_SOCKET, SO_RCVBUF, (
char*)val, &optlen) == SOCKET_ERROR) {
4967 ::SysError(
"GetSockOpt",
"getsockopt(SO_RCVBUF)");
4972 if (::getsockopt(sock, SOL_SOCKET, SO_OOBINLINE, (
char*)val, &optlen) == SOCKET_ERROR) {
4973 ::SysError(
"GetSockOpt",
"getsockopt(SO_OOBINLINE)");
4978 if (::getsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (
char*)val, &optlen) == SOCKET_ERROR) {
4979 ::SysError(
"GetSockOpt",
"getsockopt(SO_KEEPALIVE)");
4984 if (::getsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (
char*)val, &optlen) == SOCKET_ERROR) {
4985 ::SysError(
"GetSockOpt",
"getsockopt(SO_REUSEADDR)");
4990 if (::getsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (
char*)val, &optlen) == SOCKET_ERROR) {
4991 ::SysError(
"GetSockOpt",
"getsockopt(TCP_NODELAY)");
5007 if (::ioctlsocket(sock, SIOCGPGRP, (u_long*)val) == SOCKET_ERROR) {
5008 ::SysError(
"GetSockOpt",
"ioctl(SIOCGPGRP)");
5014 if (::ioctlsocket(sock, SIOCATMARK, (u_long*)val) == SOCKET_ERROR) {
5015 ::SysError(
"GetSockOpt",
"ioctl(SIOCATMARK)");
5020 if (::ioctlsocket(sock, FIONREAD, (u_long*)val) == SOCKET_ERROR) {
5026 Error(
"GetSockOpt",
"illegal option (%d)", opt);
5038 int tcpwindowsize,
const char *protocol)
5043 if (!strcmp(servername,
"unix")) {
5046 else if (!gSystem->AccessPathName(servername) || servername[0] ==
'/' ||
5047 (servername[1] ==
':' && servername[2] ==
'/')) {
5051 if (!strcmp(protocol,
"udp")){
5055 if ((sp = ::getservbyport(::htons(port), kProtocolName))) {
5058 sport = ::htons(port);
5061 TInetAddress addr = gSystem->GetHostByName(servername);
5062 if (!addr.
IsValid())
return -1;
5065 struct sockaddr_in server;
5066 memset(&server, 0,
sizeof(server));
5067 memcpy(&server.sin_addr, &adr,
sizeof(adr));
5069 server.sin_port = sport;
5073 if ((sock = ::socket(AF_INET, SOCK_STREAM, 0)) ==
INVALID_SOCKET) {
5074 ::SysError(
"TWinNTSystem::WinNTConnectTcp",
"socket");
5078 if (tcpwindowsize > 0) {
5079 gSystem->SetSockOpt((
int)sock,
kRecvBuffer, tcpwindowsize);
5080 gSystem->SetSockOpt((
int)sock,
kSendBuffer, tcpwindowsize);
5083 if (::connect(sock, (
struct sockaddr*) &server,
sizeof(server)) ==
INVALID_SOCKET) {
5096 struct sockaddr_in myaddr;
5099 memset(&myaddr, 0,
sizeof(myaddr));
5100 myaddr.sin_family = AF_INET;
5101 myaddr.sin_port = port;
5102 myaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
5105 if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
5106 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"socket");
5110 while ((connect(sock, (
struct sockaddr *)&myaddr,
sizeof myaddr)) == -1) {
5114 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"connect");
5130 if (!sockpath || strlen(sockpath) <= 0) {
5131 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"socket path undefined");
5134 TString socketpath = sockpath;
5136 fp = fopen(socketpath.
Data(),
"rb");
5138 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"fopen");
5141 fscanf(fp,
"%d", &port);
5144 if (port < 0 || port > 65535) {
5145 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"invalid port");
5160 if ((sp = getservbyport(htons(port), kProtocolName)))
5163 sport = htons(port);
5166 if (!addr.
IsValid())
return -1;
5169 struct sockaddr_in server;
5170 memset(&server, 0,
sizeof(server));
5171 memcpy(&server.sin_addr, &adr,
sizeof(adr));
5173 server.sin_port = sport;
5177 if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
5178 ::SysError(
"TWinNTSystem::WinNTUdpConnect",
"socket (%s:%d)",
5183 while (connect(sock, (
struct sockaddr*) &server,
sizeof(server)) == -1) {
5187 ::SysError(
"TWinNTSystem::WinNTUdpConnect",
"connect (%s:%d)",
5205 const char *protocol)
5226 const short kSOCKET_MINPORT = 5000, kSOCKET_MAXPORT = 15000;
5227 short tryport = kSOCKET_MINPORT;
5229 if ((sp = ::getservbyport(::htons(port), kProtocolName))) {
5232 sport = ::htons(port);
5235 if (port == 0 && reuse) {
5236 ::Error(
"TWinNTSystem::WinNTTcpService",
"cannot do a port scan while reuse is true");
5240 if ((sp = ::getservbyport(::htons(port), kProtocolName))) {
5243 sport = ::htons(port);
5248 if ((sock = ::socket(AF_INET, SOCK_STREAM, 0)) < 0) {
5249 ::SysError(
"TWinNTSystem::WinNTTcpService",
"socket");
5254 gSystem->SetSockOpt((
int)sock,
kReuseAddr, 1);
5257 if (tcpwindowsize > 0) {
5258 gSystem->SetSockOpt((
int)sock,
kRecvBuffer, tcpwindowsize);
5259 gSystem->SetSockOpt((
int)sock,
kSendBuffer, tcpwindowsize);
5262 struct sockaddr_in inserver;
5263 memset(&inserver, 0,
sizeof(inserver));
5264 inserver.sin_family = AF_INET;
5265 inserver.sin_addr.s_addr = ::htonl(INADDR_ANY);
5266 inserver.sin_port = sport;
5270 if (::bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver)) == SOCKET_ERROR) {
5271 ::SysError(
"TWinNTSystem::WinNTTcpService",
"bind");
5277 inserver.sin_port = ::htons(tryport++);
5278 bret = ::bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver));
5279 }
while (bret == SOCKET_ERROR && WSAGetLastError() == WSAEADDRINUSE &&
5280 tryport < kSOCKET_MAXPORT);
5281 if (bret == SOCKET_ERROR) {
5282 ::SysError(
"TWinNTSystem::WinNTTcpService",
"bind (port scan)");
5288 if (::listen(sock, backlog) == SOCKET_ERROR) {
5289 ::SysError(
"TWinNTSystem::WinNTTcpService",
"listen");
5306 const short kSOCKET_MINPORT = 5000, kSOCKET_MAXPORT = 15000;
5307 short sport, tryport = kSOCKET_MINPORT;
5310 if ((sp = getservbyport(htons(port), kProtocolName)))
5313 sport = htons(port);
5317 if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
5318 ::SysError(
"TUnixSystem::UnixUdpService",
"socket");
5322 struct sockaddr_in inserver;
5323 memset(&inserver, 0,
sizeof(inserver));
5324 inserver.sin_family = AF_INET;
5325 inserver.sin_addr.s_addr = htonl(INADDR_ANY);
5326 inserver.sin_port = sport;
5330 if (bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver))) {
5331 ::SysError(
"TWinNTSystem::AnnounceUdpService",
"bind");
5337 inserver.sin_port = htons(tryport++);
5338 bret = bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver));
5339 }
while (bret == SOCKET_ERROR && WSAGetLastError() == WSAEADDRINUSE &&
5340 tryport < kSOCKET_MAXPORT);
5342 ::SysError(
"TWinNTSystem::AnnounceUdpService",
"bind (port scan)");
5348 if (listen(sock, backlog)) {
5349 ::SysError(
"TWinNTSystem::AnnounceUdpService",
"listen");
5367 (::WSAGetLastError() == WSAEINTR)) {
5372 if (::WSAGetLastError() == WSAEWOULDBLOCK) {
5386 #define SystemBasicInformation 0
5387 #define SystemPerformanceInformation 2
5392 ULONG uKeMaximumIncrement;
5394 ULONG uMmNumberOfPhysicalPages;
5395 ULONG uMmLowestPhysicalPage;
5396 ULONG UMmHighestPhysicalPage;
5397 ULONG uAllocationGranularity;
5398 PVOID pLowestUserAddress;
5399 PVOID pMmHighestUserAddress;
5400 ULONG uKeActiveProcessors;
5401 BYTE bKeNumberProcessors;
5404 } SYSTEM_BASIC_INFORMATION;
5408 LARGE_INTEGER liIdleTime;
5410 } SYSTEM_PERFORMANCE_INFORMATION;
5412 typedef struct _PROCESS_MEMORY_COUNTERS {
5414 DWORD PageFaultCount;
5415 SIZE_T PeakWorkingSetSize;
5416 SIZE_T WorkingSetSize;
5417 SIZE_T QuotaPeakPagedPoolUsage;
5418 SIZE_T QuotaPagedPoolUsage;
5419 SIZE_T QuotaPeakNonPagedPoolUsage;
5420 SIZE_T QuotaNonPagedPoolUsage;
5421 SIZE_T PagefileUsage;
5422 SIZE_T PeakPagefileUsage;
5427 #define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 + (double)((x).LowPart))
5435 LARGE_INTEGER ulFreq, ulTicks, ulValue, ulStartCounter;
5439 if (QueryPerformanceFrequency(&ulFreq)) {
5441 QueryPerformanceCounter(&ulTicks);
5444 ulValue.QuadPart = ulTicks.QuadPart + ulFreq.QuadPart/10;
5445 ulStartCounter.QuadPart =
__rdtsc();
5449 QueryPerformanceCounter(&ulTicks);
5450 }
while (ulTicks.QuadPart <= ulValue.QuadPart);
5452 return (DWORD)((
__rdtsc() - ulStartCounter.QuadPart)/100000);
5460 #define SM_SERVERR2 89
5467 OSVERSIONINFOEX osvi;
5470 BOOL bOsVersionInfoEx;
5471 static char *strReturn = 0;
5475 strReturn =
new char[2048];
5479 ZeroMemory(&si,
sizeof(SYSTEM_INFO));
5480 ZeroMemory(&osvi,
sizeof(OSVERSIONINFOEX));
5485 osvi.dwOSVersionInfoSize =
sizeof(OSVERSIONINFOEX);
5487 if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
5489 osvi.dwOSVersionInfoSize =
sizeof (OSVERSIONINFO);
5490 if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
5495 pGNSI = (
PGNSI) GetProcAddress( GetModuleHandle(
"kernel32.dll"),
5496 "GetNativeSystemInfo");
5499 else GetSystemInfo(&si);
5501 switch (osvi.dwPlatformId)
5504 case VER_PLATFORM_WIN32_NT:
5507 if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 )
5509 if( osvi.wProductType == VER_NT_WORKSTATION )
5510 strlcpy(strReturn,
"Microsoft Windows Vista ",2048);
5511 else strlcpy(strReturn,
"Windows Server \"Longhorn\" " ,2048);
5513 if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
5516 strlcpy(strReturn,
"Microsoft Windows Server 2003 \"R2\" ",2048);
5517 else if( osvi.wProductType == VER_NT_WORKSTATION &&
5518 si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
5520 strlcpy(strReturn,
"Microsoft Windows XP Professional x64 Edition ",2048);
5522 else strlcpy(strReturn,
"Microsoft Windows Server 2003, ",2048);
5524 if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
5525 strlcpy(strReturn,
"Microsoft Windows XP ",2048);
5527 if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
5528 strlcpy(strReturn,
"Microsoft Windows 2000 ",2048);
5530 if ( osvi.dwMajorVersion <= 4 )
5531 strlcpy(strReturn,
"Microsoft Windows NT ",2048);
5534 if( bOsVersionInfoEx )
5537 if ( osvi.wProductType == VER_NT_WORKSTATION &&
5538 si.wProcessorArchitecture!=PROCESSOR_ARCHITECTURE_AMD64)
5540 if( osvi.dwMajorVersion == 4 )
5541 strlcat(strReturn,
"Workstation 4.0 ",2048 );
5542 else if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
5543 strlcat(strReturn,
"Home Edition " ,2048);
5544 else strlcat(strReturn,
"Professional " ,2048);
5547 else if ( osvi.wProductType == VER_NT_SERVER ||
5548 osvi.wProductType == VER_NT_DOMAIN_CONTROLLER )
5550 if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==2)
5552 if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_IA64 )
5554 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
5555 strlcat(strReturn,
"Datacenter Edition for Itanium-based Systems",2048 );
5556 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5557 strlcat(strReturn,
"Enterprise Edition for Itanium-based Systems" ,2048);
5559 else if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 )
5561 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
5562 strlcat(strReturn,
"Datacenter x64 Edition ",2048 );
5563 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5564 strlcat(strReturn,
"Enterprise x64 Edition ",2048 );
5565 else strlcat(strReturn,
"Standard x64 Edition ",2048 );
5569 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
5570 strlcat(strReturn,
"Datacenter Edition ",2048 );
5571 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5572 strlcat(strReturn,
"Enterprise Edition ",2048 );
5573 else if ( osvi.wSuiteMask == VER_SUITE_BLADE )
5574 strlcat(strReturn,
"Web Edition " ,2048);
5575 else strlcat(strReturn,
"Standard Edition ",2048 );
5578 else if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==0)
5580 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
5581 strlcat(strReturn,
"Datacenter Server ",2048 );
5582 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5583 strlcat(strReturn,
"Advanced Server ",2048 );
5584 else strlcat(strReturn,
"Server ",2048 );
5588 if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5589 strlcat(strReturn,
"Server 4.0, Enterprise Edition " ,2048);
5590 else strlcat(strReturn,
"Server 4.0 ",2048 );
5599 DWORD dwBufLen=
BUFSIZE*
sizeof(TCHAR);
5602 lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
5603 "SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
5604 0, KEY_QUERY_VALUE, &hKey );
5605 if( lRet != ERROR_SUCCESS )
5608 lRet = RegQueryValueEx( hKey,
"ProductType",
NULL,
NULL,
5609 (LPBYTE) szProductType, &dwBufLen);
5610 RegCloseKey( hKey );
5612 if( (lRet != ERROR_SUCCESS) || (dwBufLen >
BUFSIZE*
sizeof(TCHAR)) )
5615 if ( lstrcmpi(
"WINNT", szProductType) == 0 )
5616 strlcat(strReturn,
"Workstation " ,2048);
5617 if ( lstrcmpi(
"LANMANNT", szProductType) == 0 )
5618 strlcat(strReturn,
"Server " ,2048);
5619 if ( lstrcmpi(
"SERVERNT", szProductType) == 0 )
5620 strlcat(strReturn,
"Advanced Server " ,2048);
5621 snprintf(temp,512,
"%d.%d ", osvi.dwMajorVersion, osvi.dwMinorVersion);
5622 strlcat(strReturn, temp,2048);
5627 if( osvi.dwMajorVersion == 4 &&
5628 lstrcmpi( osvi.szCSDVersion,
"Service Pack 6" ) == 0 )
5634 lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
5635 "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009",
5636 0, KEY_QUERY_VALUE, &hKey );
5637 if( lRet == ERROR_SUCCESS ) {
5638 snprintf(temp, 512,
"Service Pack 6a (Build %d)", osvi.dwBuildNumber & 0xFFFF );
5639 strlcat(strReturn, temp,2048 );
5643 snprintf(temp,512,
"%s (Build %d)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF);
5644 strlcat(strReturn, temp,2048 );
5647 RegCloseKey( hKey );
5651 snprintf(temp, 512,
"%s (Build %d)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF);
5652 strlcat(strReturn, temp,2048 );
5658 case VER_PLATFORM_WIN32_WINDOWS:
5660 if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
5662 strlcpy(strReturn,
"Microsoft Windows 95 ",2048);
5663 if (osvi.szCSDVersion[1]==
'C' || osvi.szCSDVersion[1]==
'B')
5664 strlcat(strReturn,
"OSR2 " ,2048);
5667 if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
5669 strlcpy(strReturn,
"Microsoft Windows 98 ",2048);
5670 if ( osvi.szCSDVersion[1]==
'A' || osvi.szCSDVersion[1]==
'B')
5671 strlcat(strReturn,
"SE ",2048 );
5674 if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
5676 strlcpy(strReturn,
"Microsoft Windows Millennium Edition",2048);
5680 case VER_PLATFORM_WIN32s:
5681 strlcpy(strReturn,
"Microsoft Win32s",2048);
5692 unsigned nHighestFeatureEx;
5696 nHighestFeatureEx = (unsigned)nBuff[0];
5698 if (nHighestFeatureEx >= 0x80000006) {
5700 return (((
unsigned)nBuff[2])>>16);
5710 SYSTEM_PERFORMANCE_INFORMATION SysPerfInfo;
5711 SYSTEM_INFO sysInfo;
5712 MEMORYSTATUSEX statex;
5713 OSVERSIONINFO OsVersionInfo;
5715 char szKeyValueString[80];
5716 DWORD szKeyValueDword;
5719 PROCNTQSI NtQuerySystemInformation;
5721 NtQuerySystemInformation = (PROCNTQSI)GetProcAddress(
5722 GetModuleHandle(
"ntdll"),
"NtQuerySystemInformation");
5724 if (!NtQuerySystemInformation) {
5726 "Error on GetProcAddress(NtQuerySystemInformation)");
5731 &SysPerfInfo,
sizeof(SysPerfInfo),
5733 OsVersionInfo.dwOSVersionInfoSize =
sizeof(OSVERSIONINFO);
5734 GetVersionEx(&OsVersionInfo);
5735 GetSystemInfo(&sysInfo);
5736 statex.dwLength =
sizeof(statex);
5737 if (!GlobalMemoryStatusEx(&statex)) {
5738 ::Error(
"GetWinNTSysInfo",
"Error on GlobalMemoryStatusEx()");
5741 sysinfo->
fCpus = sysInfo.dwNumberOfProcessors;
5750 status = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"HARDWARE\\DESCRIPTION\\System",
5751 0, KEY_QUERY_VALUE, &hKey);
5752 if (status == ERROR_SUCCESS) {
5753 dwBufLen =
sizeof(szKeyValueString);
5754 RegQueryValueEx(hKey,
"Identifier",
NULL,
NULL,(LPBYTE)szKeyValueString,
5756 sysinfo->
fModel = szKeyValueString;
5759 status = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
5760 "Hardware\\Description\\System\\CentralProcessor\\0",
5761 0, KEY_QUERY_VALUE, &hKey);
5762 if (status == ERROR_SUCCESS) {
5763 dwBufLen =
sizeof(szKeyValueString);
5764 status = RegQueryValueEx(hKey,
"ProcessorNameString",
NULL,
NULL,
5765 (LPBYTE)szKeyValueString, &dwBufLen);
5766 if (status == ERROR_SUCCESS)
5767 sysinfo->
fCpuType = szKeyValueString;
5768 dwBufLen =
sizeof(DWORD);
5769 status = RegQueryValueEx(hKey,
"~MHz",
NULL,
NULL,(LPBYTE)&szKeyValueDword,
5771 if ((status == ERROR_SUCCESS) && ((sysinfo->
fCpuSpeed <= 0) ||
5772 (sysinfo->
fCpuSpeed < (szKeyValueDword >> 1))))
5786 SYSTEM_INFO sysInfo;
5787 Float_t idle_ratio, kernel_ratio, user_ratio, total_ratio;
5788 FILETIME ft_sys_idle, ft_sys_kernel, ft_sys_user, ft_fun_time;
5789 SYSTEMTIME st_fun_time;
5791 ULARGE_INTEGER ul_sys_idle, ul_sys_kernel, ul_sys_user;
5792 static ULARGE_INTEGER ul_sys_idleold = {0, 0};
5793 static ULARGE_INTEGER ul_sys_kernelold = {0, 0};
5794 static ULARGE_INTEGER ul_sys_userold = {0, 0};
5795 ULARGE_INTEGER ul_sys_idle_diff, ul_sys_kernel_diff, ul_sys_user_diff;
5797 ULARGE_INTEGER ul_fun_time;
5798 ULARGE_INTEGER ul_fun_timeold = {0, 0};
5799 ULARGE_INTEGER ul_fun_time_diff;
5801 typedef BOOL (__stdcall *GetSystemTimesProc)( LPFILETIME lpIdleTime,
5802 LPFILETIME lpKernelTime, LPFILETIME lpUserTime );
5803 static GetSystemTimesProc pGetSystemTimes = 0;
5805 HMODULE hModImagehlp = LoadLibrary(
"Kernel32.dll" );
5806 if (!hModImagehlp) {
5807 ::Error(
"GetWinNTCpuInfo",
"Error on LoadLibrary(Kernel32.dll)");
5811 pGetSystemTimes = (GetSystemTimesProc) GetProcAddress( hModImagehlp,
5813 if (!pGetSystemTimes) {
5814 ::Error(
"GetWinNTCpuInfo",
"Error on GetProcAddress(GetSystemTimes)");
5817 GetSystemInfo(&sysInfo);
5820 pGetSystemTimes(&ft_sys_idle,&ft_sys_kernel,&ft_sys_user);
5821 GetSystemTime(&st_fun_time);
5822 SystemTimeToFileTime(&st_fun_time,&ft_fun_time);
5824 memcpy(&ul_sys_idle, &ft_sys_idle,
sizeof(FILETIME));
5825 memcpy(&ul_sys_kernel, &ft_sys_kernel,
sizeof(FILETIME));
5826 memcpy(&ul_sys_user, &ft_sys_user,
sizeof(FILETIME));
5827 memcpy(&ul_fun_time, &ft_fun_time,
sizeof(FILETIME));
5829 ul_sys_idle_diff.QuadPart = ul_sys_idle.QuadPart -
5830 ul_sys_idleold.QuadPart;
5831 ul_sys_kernel_diff.QuadPart = ul_sys_kernel.QuadPart -
5832 ul_sys_kernelold.QuadPart;
5833 ul_sys_user_diff.QuadPart = ul_sys_user.QuadPart -
5834 ul_sys_userold.QuadPart;
5836 ul_fun_time_diff.QuadPart = ul_fun_time.QuadPart -
5837 ul_fun_timeold.QuadPart;
5839 ul_sys_idleold.QuadPart = ul_sys_idle.QuadPart;
5840 ul_sys_kernelold.QuadPart = ul_sys_kernel.QuadPart;
5841 ul_sys_userold.QuadPart = ul_sys_user.QuadPart;
5843 if (ul_fun_timeold.QuadPart == 0) {
5845 ul_fun_timeold.QuadPart = ul_fun_time.QuadPart;
5848 ul_fun_timeold.QuadPart = ul_fun_time.QuadPart;
5856 idle_ratio /= (
Float_t)sysInfo.dwNumberOfProcessors;
5857 user_ratio /= (
Float_t)sysInfo.dwNumberOfProcessors;
5858 kernel_ratio /= (
Float_t)sysInfo.dwNumberOfProcessors;
5859 total_ratio = 100.0 - idle_ratio;
5864 cpuinfo->
fUser = user_ratio;
5865 cpuinfo->
fSys = kernel_ratio;
5866 cpuinfo->
fTotal = total_ratio;
5867 cpuinfo->
fIdle = idle_ratio;
5876 MEMORYSTATUSEX statex;
5877 statex.dwLength =
sizeof(statex);
5878 if (!GlobalMemoryStatusEx(&statex)) {
5879 ::Error(
"GetWinNTMemInfo",
"Error on GlobalMemoryStatusEx()");
5882 used = (
Long64_t)(statex.ullTotalPhys - statex.ullAvailPhys);
5883 free = (
Long64_t) statex.ullAvailPhys;
5884 total = (
Long64_t) statex.ullTotalPhys;
5890 swap_total = (
Long64_t)(statex.ullTotalPageFile - statex.ullTotalPhys);
5891 swap_avail = (
Long64_t)(statex.ullAvailPageFile - statex.ullAvailPhys);
5892 swap_used = swap_total - swap_avail;
5905 FILETIME starttime, exittime, kerneltime, usertime;
5906 timeval ru_stime, ru_utime;
5909 typedef BOOL (__stdcall *GetProcessMemoryInfoProc)( HANDLE Process,
5910 PPROCESS_MEMORY_COUNTERS ppsmemCounters, DWORD cb );
5911 static GetProcessMemoryInfoProc pGetProcessMemoryInfo = 0;
5913 HMODULE hModImagehlp = LoadLibrary(
"Psapi.dll" );
5914 if (!hModImagehlp) {
5915 ::Error(
"GetWinNTProcInfo",
"Error on LoadLibrary(Psapi.dll)");
5919 pGetProcessMemoryInfo = (GetProcessMemoryInfoProc) GetProcAddress(
5920 hModImagehlp,
"GetProcessMemoryInfo" );
5921 if (!pGetProcessMemoryInfo) {
5923 "Error on GetProcAddress(GetProcessMemoryInfo)");
5927 if ( pGetProcessMemoryInfo( GetCurrentProcess(), &pmc,
sizeof(pmc)) ) {
5931 if ( GetProcessTimes(GetCurrentProcess(), &starttime, &exittime,
5932 &kerneltime, &usertime)) {
5935 memcpy(&li, &kerneltime,
sizeof(FILETIME));
5937 ru_stime.tv_sec = li.QuadPart / 1000000
L;
5938 ru_stime.tv_usec = li.QuadPart % 1000000
L;
5940 memcpy(&li, &usertime,
sizeof(FILETIME));
5942 ru_utime.tv_sec = li.QuadPart / 1000000
L;
5943 ru_utime.tv_usec = li.QuadPart % 1000000
L;
5946 ((
Float_t)(ru_utime.tv_usec) / 1000000.);
5948 ((
Float_t)(ru_stime.tv_usec) / 1000000.);
5959 if (!info)
return -1;
5971 if (!info)
return -1;
5982 if (!info)
return -1;
5993 if (!info)
return -1;
Int_t GetGid(const char *group=0)
Returns the group's id. If group = 0, returns current user's group.
void DispatchOneEvent(Bool_t pendingOnly=kFALSE)
Dispatch a single event in TApplication::Run() loop.
const char * FindFile(const char *search, TString &file, EAccessMode mode=kFileExists)
Find location of file in a search path.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
int GetSockOpt(int sock, int opt, int *val)
Get socket option.
FILE * OpenPipe(const char *shellcmd, const char *mode)
Open a pipe.
double read(const std::string &file_name)
reading
Ssiz_t Last(char c) const
Find last occurrence of a character c.
static void GetWinNTProcInfo(ProcInfo_t *procinfo)
Get process info for this process on Windows NT.
virtual void SetWriteReady()
Int_t GetEffectiveGid()
Returns the effective group id.
static void __cpuid(int *cpuid_data, int)
UserGroup_t * GetUserInfo(Int_t uid)
Returns all user info in the UserGroup_t structure.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
const char * HomeDirectory(const char *userName=0)
Return the user's home directory.
virtual Bool_t Notify()
Notify when event occurred on descriptor associated with this handler.
int RecvRaw(int sock, void *buffer, int length, int flag)
Receive exactly length bytes into buffer.
const char * HostName()
Return the system's host name.
WIN32_FIND_DATA fFindFileData
virtual Bool_t IsPathLocal(const char *path)
Returns TRUE if the url in 'path' points to the local file system.
void SetDynamicPath(const char *path)
Set the dynamic path to a new value.
R__EXTERN Int_t gErrorIgnoreLevel
static DWORD GetCPUSpeed()
Calculate the CPU clock speed using the 'rdtsc' instruction.
int Link(const char *from, const char *to)
Create a link from file1 to file2.
const char * GetError()
Return system error string.
BOOL PathIsUNC(LPCTSTR pszPath)
Returns TRUE if the given string is a UNC path.
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
const char * GetLinkedLibraries()
Get list of shared libraries loaded at the start of the executable.
#define INVALID_HANDLE_VALUE
int Unlink(const char *name)
Unlink, i.e. remove, a file or directory.
HANDLE GetProcess()
Get current process handle.
void DoBeep(Int_t freq=-1, Int_t duration=-1) const
Beep.
TTime Now()
Get current time in milliseconds since 0:00 Jan 1 1995.
void CloseConnection(int sock, Bool_t force=kFALSE)
Close socket.
int CopyFile(const char *from, const char *to, Bool_t overwrite=kFALSE)
Copy a file.
void * _ReturnAddress(void)
RooArgList L(const RooAbsArg &v1)
const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
This class represents a WWW compatible URL.
TString & ReplaceAll(const TString &s1, const TString &s2)
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.
static char * GetWindowsVersion()
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
const char * GetProtocol() const
void AddDynamicPath(const char *dir)
Add a new directory to the dynamic path.
TTimer * RemoveTimer(TTimer *ti)
Remove timer from list of system timers.
ClassImp(TWinNTSystem) ULong_t gConsoleWindow=0
This class represents an Internet Protocol (IP) address.
virtual int MakeDirectory(const char *name)
Make a directory.
int GetPathInfo(const char *path, FileStat_t &buf)
Get info about a file.
virtual void AddSignalHandler(TSignalHandler *sh)
Add a signal handler to list of system signal handlers.
Int_t 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...
Regular expression class.
int Umask(Int_t mask)
Set the process file creation mode mask.
char * GetServiceByPort(int port)
Get name of internet service.
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
int SendRaw(int sock, const void *buffer, int length, int flag)
Send exactly length bytes from buffer.
TSeqCollection * fSignalHandler
Int_t GetMemInfo(MemInfo_t *info) const
Returns ram and swap memory usage info into the MemInfo_t structure.
void IgnoreSignal(ESignals sig, Bool_t ignore=kTRUE)
If ignore is true ignore the specified signal, else restore previous behaviour.
virtual TTimer * RemoveTimer(TTimer *t)
Remove timer from list of system timers.
Bool_t IsAbsoluteFileName(const char *dir)
Return true if dir is an absolute pathname.
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
void Break(const char *location, const char *msgfmt,...)
Bool_t CheckDescriptors()
Check if there is activity on some file descriptors and call their Notify() member.
const char * DirName(const char *pathname)
Return the directory name in pathname.
static void ThreadStub(void *Parameter)
virtual void ResetReadyMask()
TString & Prepend(const char *cs)
R__EXTERN TApplication * gApplication
Basic time type with millisecond precision.
int ClosePipe(FILE *pipe)
Close the pipe.
Bool_t IsPathLocal(const char *path)
Returns TRUE if the url in 'path' points to the local file system.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
typedef LONG(WINAPI *PROCNTQSI)(UINT
Int_t GetEffectiveUid()
Returns the effective user id.
virtual TFileHandler * RemoveFileHandler(TFileHandler *fh)
Remove a file handler from the list of file handlers.
void NotifyApplicationCreated()
Hook to tell TSystem that the TApplication object has been created.
void SysError(const char *location, const char *msgfmt,...)
virtual Bool_t HandleTermInput()
Bool_t DispatchTimers(Bool_t mode)
Handle and dispatch timers.
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
static Int_t GetErrno()
Static function returning system error number.
Int_t GetCpuInfo(CpuInfo_t *info, Int_t sampleTime=1000) const
Returns cpu load average and load info into the CpuInfo_t structure.
void Abort(int code=0)
Abort the application.
const char * Data() const
static int GetL2CacheSize()
Use assembly to retrieve the L2 cache information ...
void AddSignalHandler(TSignalHandler *sh)
Add a signal handler to list of system signal handlers.
virtual Bool_t Notify()
Notify when signal occurs.
virtual const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
virtual int Unlink(const char *name)
Unlink, i.e. remove, a file.
Bool_t ChangeDirectory(const char *path)
Change directory.
Double_t dot(const TVector2 &v1, const TVector2 &v2)
static int WinNTUnixConnect(int port)
Connect to a Unix domain socket.
BOOL PathIsRoot(LPCTSTR pPath)
check if a path is a root
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
TSignalHandler * RemoveSignalHandler(TSignalHandler *sh)
Remove a signal handler from list of signal handlers.
TPaveText exe(6, 5.5, 12, 8)
Int_t GetProcInfo(ProcInfo_t *info) const
Returns cpu and memory used by this process into the ProcInfo_t structure.
Int_t SetFPEMask(Int_t mask=kDefaultMask)
Set which conditions trigger a floating point exception.
int AcceptConnection(int sock)
Accept a connection.
static Bool_t Initialized()
Return kTRUE if the TROOT object has been initialized.
static const char * DynamicPath(const char *newpath=0, Bool_t reset=kFALSE)
Get shared library search path. Static utility function.
const char * FindDynamicLibrary(TString &lib, Bool_t quiet=kFALSE)
Returns and updates sLib to the path of a dynamic library (searches for library in the dynamic librar...
int GetPid()
Get process id.
TObject * Next()
Return next object in collection.
R__EXTERN TFileHandler * gXDisplay
Int_t fNfd
Signals that were trapped.
void AddTimer(TTimer *ti)
Add timer to list of system timers.
const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
TString & Append(const char *cs)
std::vector< std::vector< double > > Data
virtual void ExitLoop()
Exit from event loop.
R__EXTERN ULong_t gConsoleWindow
struct _PROCESS_MEMORY_COUNTERS PROCESS_MEMORY_COUNTERS
const char * WorkingDirectory()
Return the working directory for the default drive.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
int GetServiceByName(const char *service)
Get port # of internet service.
int OpenConnection(const char *server, int port, int tcpwindowsize=-1, const char *protocol="tcp")
Open a connection to a service on a server.
void Error(const char *location, const char *msgfmt,...)
UInt_t GetAddress() const
const char * GetDynamicPath()
Return the dynamic path (used to find shared libraries).
TSeqCollection * fFileHandler
TString & GetLastErrorString()
Return the thread local storage for the custom last error message.
struct _PROCESS_MEMORY_COUNTERS * PPROCESS_MEMORY_COUNTERS
Bool_t InitUsersGroups()
Collect local users and groups accounts information.
static void SigHandler(ESignals sig)
Unix signal handler.
virtual ~TWinNTSystem()
dtor
int MakeDirectory(const char *name)
Make a WinNT file system directory.
Using a TBrowser one can browse all ROOT objects.
virtual Bool_t WriteNotify()
Notify when something can be written to the descriptor associated with this handler.
const char * GetDirEntry(void *dirp)
Returns the next directory entry.
R__EXTERN const char * gProgName
static int WinNTUdpConnect(const char *hostname, int port)
Creates a UDP socket connection Is called via the TSocket constructor.
Bool_t Init()
Initialize WinNT system interface.
static void sighandler(int sig)
Call the signal handler associated with the signal.
void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
virtual Bool_t HasWriteInterest()
True if handler is interested in write events.
const char * BaseName(const char *name)
Base name of a file name.
Bool_t ProcessEvents()
process pending events, i.e. DispatchOneEvent(kTRUE)
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Double_t length(const TVector2 &v)
virtual Bool_t Init()
Initialize the OS interface.
Int_t GetFPEMask()
Return the bitmap of conditions that trigger a floating point exception.
Bool_t EqualTo(const char *cs, ECaseCompare cmp=kExact) const
virtual const char * GetLibraries(const char *regexp="", const char *option="", Bool_t isRegexp=kTRUE)
Return a space separated list of loaded shared libraries.
#define SystemPerformanceInformation
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
int ConnectService(const char *servername, int port, int tcpwindowsize, const char *protocol="tcp")
Connect to service servicename on server servername.
virtual void SetReadReady()
virtual Long_t NextTimeOut(Bool_t mode)
Time when next timer of mode (synchronous=kTRUE or asynchronous=kFALSE) will time-out (in ms)...
void AddFileHandler(TFileHandler *fh)
Add a file handler to the list of system file handlers.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
#define isin(address, start, length)
char * Form(const char *fmt,...)
void Exit(int code, Bool_t mode=kTRUE)
Exit the application.
int Utime(const char *file, Long_t modtime, Long_t actime)
Set a files modification and access times.
void ResetSignal(ESignals sig, Bool_t reset=kTRUE)
If reset is true reset the signal handler for the specified signal to the default handler...
static const char * StripOffProto(const char *path, const char *proto)
struct passwd * fPasswords
const char * UnixPathName(const char *unixpathname)
Convert a pathname to a unix pathname.
static void GetWinNTSysInfo(SysInfo_t *sysinfo)
Get system info for Windows NT.
Handles synchronous and a-synchronous timer events.
Bool_t CheckTimer(const TTime &now)
Check if timer timed out.
TSubString Strip(EStripType s=kTrailing, char c= ' ') const
Return a substring of self stripped at beginning and/or end.
void ResetSignals()
Reset signals handlers to previous behaviour.
static void GetWinNTCpuInfo(CpuInfo_t *cpuinfo, Int_t sampleTime)
Get CPU stat for Window.
void DispatchSignals(ESignals sig)
Handle and dispatch signals.
void AddAlias(const char *alias)
Add alias to list of aliases.
virtual void FreeDirectory(void *dirp)
Free a directory.
const char * GetLibraries(const char *regexp="", const char *option="", Bool_t isRegexp=kTRUE)
Return a space separated list of loaded shared libraries.
const char DriveName(const char *pathname="/")
Return the drive letter in pathname.
char * StrDup(const char *str)
Duplicate the string str.
void ExitLoop()
Exit from event loop.
int Exec(const char *shellcmd)
Execute a command.
UserGroup_t * GetGroupInfo(Int_t gid)
Returns all group info in the UserGroup_t structure.
TString & Remove(Ssiz_t pos)
RooCmdArg Index(RooCategory &icat)
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
int SendBuf(int sock, const void *buffer, int length)
Send a buffer headed by a length indicator.
virtual TSignalHandler * RemoveSignalHandler(TSignalHandler *sh)
Remove a signal handler from list of signal handlers.
virtual Int_t GetSize() const
TFdSet * fReadready
Files that should be checked for write events.
void AddAddress(UInt_t addr)
Add alternative address to list of addresses.
R__EXTERN const char * gProgPath
void Copy(void *source, void *dest)
static const double x1[5]
TString & Swap(TString &other)
void(* SigHandler_t)(ESignals)
int AnnounceTcpService(int port, Bool_t reuse, int backlog, int tcpwindowsize=-1)
Announce TCP/IP service.
R__EXTERN TWin32SplashThread * gSplash
void select(Int_t replica=1, Int_t color=kGreen)
char * DynamicPathName(const char *lib, Bool_t quiet=kFALSE)
Find a dynamic library called lib using the system search paths.
int AnnounceUnixService(int port, int backlog)
Announce unix domain service.
int RecvBuf(int sock, void *buffer, int length)
Receive a buffer headed by a length indicator.
int Chmod(const char *file, UInt_t mode)
Set the file permission bits.
virtual const char * ExpandFileName(const char *fname)
Expand a pathname getting rid of special shell characters like ~.
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
double func(double *x, double *p)
int AnnounceUdpService(int port, int backlog)
Announce UDP service.
void TimerThread()
Special Thread to check asynchronous timers.
TFdSet * fSignals
Files with writes waiting.
void Beep(Int_t freq=-1, Int_t duration=-1, Bool_t setDefault=kFALSE)
Beep for duration milliseconds with a tone of frequency freq.
__inline BOOL DBL_BSLASH(LPCTSTR psz)
Inline function to check for a double-backslash at the beginning of a string.
int Symlink(const char *from, const char *to)
Create a symlink from file1 to file2.
void Gl_setwidth(int width)
void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
int mkdir(const char *name, Bool_t recursive=kFALSE)
Make a file system directory.
TInetAddress GetPeerName(int sock)
Get Internet Protocol (IP) address of remote host and port #.
TFileHandler * RemoveFileHandler(TFileHandler *fh)
Remove a file handler from the list of file handlers.
Bool_t ExpandPathName(TString &patbuf)
Expand a pathname getting rid of special shell characaters like ~.$, etc.
Binding & operator=(OUT(*fun)(void))
void Throw(int code)
If an exception context has been set (using the TRY and RETRY macros) jump back to where it was set...
void FreeDirectory(void *dirp)
Close a WinNT file system directory.
Int_t Select(TList *active, Long_t timeout)
Select on file descriptors. The timeout to is in millisec.
int SetSockOpt(int sock, int opt, int val)
Set socket option.
TInetAddress GetSockName(int sock)
Get Internet Protocol (IP) address of host and port #.
typedef void((*Func_t)())
Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
TInetAddress GetHostByName(const char *server)
Get Internet Protocol (IP) address of host.
Bool_t CountMembers(const char *lpszGroupName)
Int_t GetUid(const char *user=0)
Returns the user's id. If user = 0, returns current user's id.
virtual void Add(TObject *obj)
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
R__EXTERN const char * gRootDir
ESignals GetSignal() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
int SetNonBlock(int fd)
Make descriptor fd non-blocking.
int GetFsInfo(const char *path, Long_t *id, Long_t *bsize, Long_t *blocks, Long_t *bfree)
Get info about a file system: id, bsize, bfree, blocks.
FILE * TempFileName(TString &base, const char *dir=0)
Create a secure temporary file by appending a unique 6 letter string to base.
Long_t LookupSID(const char *lpszAccountName, int what, int &groupIdx, int &memberIdx)
Take the name and look up a SID so that we can get full domain/user information.
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
ClassImp(TSlaveInfo) Int_t TSlaveInfo const TSlaveInfo * si
Used to sort slaveinfos by ordinal.
Bool_t(* ThreadMsgFunc_t)(MSG *)
Iterator of ordered collection.
virtual Bool_t ReadNotify()
Notify when something can be read from the descriptor associated with this handler.
Bool_t CollectMembers(const char *lpszGroupName, int &groupIdx, int &memberIdx)
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...
virtual void AddFileHandler(TFileHandler *fh)
Add a file handler to the list of system file handlers.
static void ResetErrno()
Static function resetting system error number.
void SetProgname(const char *name)
Set the application name (from command line, argv[0]) and copy it in gProgName.
Bool_t CheckSignals(Bool_t sync)
Check if some signals were raised and call their Notify() member.
void Setenv(const char *name, const char *value)
Set environment variable.
TFdSet * fWriteready
Files with reads waiting.
void(WINAPI * PGNSI)(LPSYSTEM_INFO)
static void GetWinNTMemInfo(MemInfo_t *meminfo)
Get VM stat for Windows NT.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Abstract base class defining a generic interface to the underlying Operating System.
TFdSet * fWritemask
Files that should be checked for read events.
static int64_t push(FILE *fp, SOCKET sock, SSL *ssl, const char *buf, int64_t len)
void StackTrace()
Print a stack trace, if gEnv entry "Root.Stacktrace" is unset or 1, and if the image helper functions...
TList * GetVolumes(Option_t *opt="") const
Get list of volumes (drives) mounted on the system.
Ssiz_t First(char c) const
Find first occurrence of a character c.
const char * Getenv(const char *name)
Get environment variable.
void SetGUIThreadMsgHandler(ThreadMsgFunc_t func)
Set the (static part of) the event handler func for GUI messages.
Int_t RedirectOutput(const char *name, const char *mode="a", RedirectHandle_t *h=0)
Redirect standard output (stdout, stderr) to the specified file.
int Rename(const char *from, const char *to)
Rename a file. Returns 0 when successful, -1 in case of failure.
virtual Bool_t HasReadInterest()
True if handler is interested in read events.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.