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; }
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 ==
"") {
371 dynpath = path; dynpath +=
";"; dynpath += rdynpath;
389 if (signal_map[i].code == sig) {
390 (*signal_map[i].handler)((
ESignals)i);
401 signal_map[sig].handler = handler;
402 if (signal_map[sig].code != -1)
409 static const char *WinNTSigname(
ESignals sig)
411 return signal_map[sig].signame;
417 static BOOL ConsoleSigHandler(DWORD sig)
425 Break(
"TInterruptHandler::Notify",
"keyboard interrupt");
431 case CTRL_BREAK_EVENT:
432 case CTRL_LOGOFF_EVENT:
433 case CTRL_SHUTDOWN_EVENT:
434 case CTRL_CLOSE_EVENT:
436 printf(
"\n *** Break *** keyboard interrupt - ROOT is terminated\n");
442 static CONTEXT *fgXcptContext = 0;
456 LONG WINAPI ExceptionFilter(LPEXCEPTION_POINTERS pXcp)
458 fgXcptContext = pXcp->ContextRecord;
460 return EXCEPTION_CONTINUE_SEARCH;
464#pragma intrinsic(_ReturnAddress)
465#pragma auto_inline(off)
466 DWORD_PTR GetProgramCounter()
471#pragma auto_inline(on)
482 static DWORD WINAPI GUIThreadMessageProcessingLoop(
void *p)
487 ::PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
492 if (gGlobalEvent) ::SetEvent(gGlobalEvent);
493 erret = ::GetMessage(&msg, NULL, NULL, NULL);
494 if (erret <= 0) endLoop =
kTRUE;
495 if (gGUIThreadMsgFunc)
496 endLoop = (*gGUIThreadMsgFunc)(&msg);
503 erret = ::GetLastError();
504 Error(
"MsgLoop",
"Error in GetMessage");
518 typedef BOOL (__stdcall *SYMINITIALIZEPROC)( HANDLE, LPSTR, BOOL );
519 typedef BOOL (__stdcall *SYMCLEANUPPROC)( HANDLE );
520 typedef BOOL (__stdcall *STACKWALK64PROC)
521 ( DWORD, HANDLE, HANDLE, LPSTACKFRAME64, LPVOID,
522 PREAD_PROCESS_MEMORY_ROUTINE,PFUNCTION_TABLE_ACCESS_ROUTINE,
523 PGET_MODULE_BASE_ROUTINE, PTRANSLATE_ADDRESS_ROUTINE );
524 typedef LPVOID (__stdcall *SYMFUNCTIONTABLEACCESS64PROC)( HANDLE, DWORD64 );
525 typedef DWORD (__stdcall *SYMGETMODULEBASE64PROC)( HANDLE, DWORD64 );
526 typedef BOOL (__stdcall *SYMGETMODULEINFO64PROC)(HANDLE, DWORD64, PIMAGEHLP_MODULE64);
527 typedef BOOL (__stdcall *SYMGETSYMFROMADDR64PROC)( HANDLE, DWORD64, PDWORD64, PIMAGEHLP_SYMBOL64);
528 typedef BOOL (__stdcall *SYMGETLINEFROMADDR64PROC)(HANDLE, DWORD64, PDWORD, PIMAGEHLP_LINE64);
529 typedef DWORD (__stdcall *UNDECORATESYMBOLNAMEPROC)(PCSTR, PSTR, DWORD, DWORD);
532 static SYMINITIALIZEPROC _SymInitialize = 0;
533 static SYMCLEANUPPROC _SymCleanup = 0;
534 static STACKWALK64PROC _StackWalk64 = 0;
535 static SYMFUNCTIONTABLEACCESS64PROC _SymFunctionTableAccess64 = 0;
536 static SYMGETMODULEBASE64PROC _SymGetModuleBase64 = 0;
537 static SYMGETMODULEINFO64PROC _SymGetModuleInfo64 = 0;
538 static SYMGETSYMFROMADDR64PROC _SymGetSymFromAddr64 = 0;
539 static SYMGETLINEFROMADDR64PROC _SymGetLineFromAddr64 = 0;
540 static UNDECORATESYMBOLNAMEPROC _UnDecorateSymbolName = 0;
542 BOOL InitImagehlpFunctions()
550 HMODULE hModImagehlp = LoadLibrary(
"IMAGEHLP.DLL" );
554 _SymInitialize = (SYMINITIALIZEPROC) GetProcAddress( hModImagehlp,
"SymInitialize" );
558 _SymCleanup = (SYMCLEANUPPROC) GetProcAddress( hModImagehlp,
"SymCleanup" );
562 _StackWalk64 = (STACKWALK64PROC) GetProcAddress( hModImagehlp,
"StackWalk64" );
566 _SymFunctionTableAccess64 = (SYMFUNCTIONTABLEACCESS64PROC) GetProcAddress(hModImagehlp,
"SymFunctionTableAccess64" );
567 if (!_SymFunctionTableAccess64)
570 _SymGetModuleBase64=(SYMGETMODULEBASE64PROC)GetProcAddress(hModImagehlp,
"SymGetModuleBase64");
571 if (!_SymGetModuleBase64)
574 _SymGetModuleInfo64=(SYMGETMODULEINFO64PROC)GetProcAddress(hModImagehlp,
"SymGetModuleInfo64");
575 if (!_SymGetModuleInfo64)
578 _SymGetSymFromAddr64=(SYMGETSYMFROMADDR64PROC)GetProcAddress(hModImagehlp,
"SymGetSymFromAddr64");
579 if (!_SymGetSymFromAddr64)
582 _SymGetLineFromAddr64=(SYMGETLINEFROMADDR64PROC)GetProcAddress(hModImagehlp,
"SymGetLineFromAddr64");
583 if (!_SymGetLineFromAddr64)
586 _UnDecorateSymbolName=(UNDECORATESYMBOLNAMEPROC)GetProcAddress(hModImagehlp,
"UnDecorateSymbolName");
587 if (!_UnDecorateSymbolName)
590 if (!_SymInitialize(GetCurrentProcess(), 0,
TRUE ))
606 std::string GetModuleName(DWORD64 address)
610 std::ostringstream out;
611 HANDLE process = ::GetCurrentProcess();
613 DWORD lineDisplacement = 0;
614 IMAGEHLP_LINE64
line;
617 if(_SymGetLineFromAddr64(process, address, &lineDisplacement, &
line)) {
618 out <<
line.FileName <<
"(" <<
line.LineNumber <<
"): ";
620 IMAGEHLP_MODULE64 module;
621 ::ZeroMemory(&module,
sizeof(module));
622 module.SizeOfStruct =
sizeof(module);
623 if(_SymGetModuleInfo64(process, address, &module)) {
624 out << module.ModuleName <<
"!";
626 out <<
"0x" << std::hex << address << std::dec <<
" ";
633 std::string GetFunctionName(DWORD64 address)
637 DWORD64 symbolDisplacement = 0;
638 HANDLE process = ::GetCurrentProcess();
640 const unsigned int SYMBOL_BUFFER_SIZE = 8192;
641 char symbolBuffer[SYMBOL_BUFFER_SIZE];
642 PIMAGEHLP_SYMBOL64 symbol =
reinterpret_cast<PIMAGEHLP_SYMBOL64
>(symbolBuffer);
643 ::ZeroMemory(symbol, SYMBOL_BUFFER_SIZE);
644 symbol->SizeOfStruct = SYMBOL_BUFFER_SIZE;
645 symbol->MaxNameLength = SYMBOL_BUFFER_SIZE -
sizeof(IMAGEHLP_SYMBOL64);
647 if(_SymGetSymFromAddr64(process, address, &symbolDisplacement, symbol)) {
649 const unsigned int NAME_SIZE = 8192;
650 char name[NAME_SIZE];
651 _UnDecorateSymbolName(
656 UNDNAME_NO_THISTYPE |
657 UNDNAME_NO_SPECIAL_SYMS |
658 UNDNAME_NO_MEMBER_TYPE |
659 UNDNAME_NO_MS_KEYWORDS |
660 UNDNAME_NO_ACCESS_SPECIFIERS
678 static BOOL IsShortcut(
const char *filename)
681 const char *extLnk =
".lnk";
682 if (filename != NULL) {
685 if (strfilename.EndsWith(extLnk))
694 static BOOL ResolveShortCut(LPCSTR pszShortcutFile,
char *pszPath,
int maxbuf)
698 char szGotPath[MAX_PATH];
705 typedef HRESULT (__stdcall *COINITIALIZEPROC)( LPVOID );
706 static COINITIALIZEPROC _CoInitialize = 0;
707 typedef void (__stdcall *COUNINITIALIZEPROC)(
void );
708 static COUNINITIALIZEPROC _CoUninitialize = 0;
709 typedef HRESULT (__stdcall *COCREATEINSTANCEPROC)( REFCLSID, LPUNKNOWN,
710 DWORD, REFIID, LPVOID );
711 static COCREATEINSTANCEPROC _CoCreateInstance = 0;
713 HMODULE hModImagehlp = LoadLibrary(
"ole32.dll" );
717 _CoInitialize = (COINITIALIZEPROC) GetProcAddress( hModImagehlp,
"CoInitialize" );
720 _CoUninitialize = (COUNINITIALIZEPROC) GetProcAddress( hModImagehlp,
"CoUninitialize");
721 if (!_CoUninitialize)
723 _CoCreateInstance = (COCREATEINSTANCEPROC) GetProcAddress( hModImagehlp,
"CoCreateInstance" );
724 if (!_CoCreateInstance)
729 hres = _CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
730 IID_IShellLink, (
void **) &psl);
731 if (SUCCEEDED(hres)) {
734 hres = psl->QueryInterface(IID_IPersistFile, (
void **) &ppf);
735 if (SUCCEEDED(hres)) {
737 MultiByteToWideChar(CP_ACP, 0, pszShortcutFile, -1, wsz, MAX_PATH);
739 hres = ppf->Load(wsz, STGM_READ);
740 if (SUCCEEDED(hres)) {
741 hres = psl->Resolve(HWND_DESKTOP, SLR_ANY_MATCH | SLR_NO_UI | SLR_UPDATE);
742 if (SUCCEEDED(hres)) {
743 strlcpy(szGotPath, pszShortcutFile,MAX_PATH);
744 hres = psl->GetPath(szGotPath, MAX_PATH, (WIN32_FIND_DATA *)&wfd,
745 SLGP_UNCPRIORITY | SLGP_RAWPATH);
746 strlcpy(pszPath,szGotPath, maxbuf);
747 if (maxbuf) pszPath[maxbuf-1] = 0;
756 return SUCCEEDED(hres);
761 GetModuleFileName(0, buf, MAX_MODULE_NAME32 + 1);
762 if (strcmp(sys->TWinNTSystem::BaseName(buf),
"root.exe"))
765 if (!::RegOpenKeyEx(HKEY_CURRENT_USER,
"Software", 0, KEY_READ, ®CUS) == ERROR_SUCCESS)
768 if (!::RegOpenKeyEx(regCUS,
"Classes", 0, KEY_READ, ®CUSC) == ERROR_SUCCESS) {
769 ::RegCloseKey(regCUS);
774 bool regROOTwrite =
false;
778 if (::RegOpenKeyEx(regCUSC,
"ROOTDEV.ROOT", 0, KEY_READ, ®ROOT) != ERROR_SUCCESS) {
779 ::RegCloseKey(regCUSC);
780 if (::RegOpenKeyEx(regCUS,
"Classes", 0, KEY_READ | KEY_WRITE, ®CUSC) == ERROR_SUCCESS &&
781 ::RegCreateKeyEx(regCUSC,
"ROOTDEV.ROOT", 0, NULL, 0, KEY_READ | KEY_WRITE,
782 NULL, ®ROOT, NULL) == ERROR_SUCCESS) {
787 if (::RegOpenKeyEx(regROOT,
"DefaultIcon", 0, KEY_READ, ®ROOTIcon) == ERROR_SUCCESS) {
788 char bufIconLoc[1024];
790 DWORD dwSize =
sizeof(bufIconLoc);
792 if (::RegQueryValueEx(regROOTIcon, NULL, NULL, &dwType, (BYTE*)bufIconLoc, &dwSize) == ERROR_SUCCESS)
793 regROOTwrite = (iconloc != bufIconLoc);
796 ::RegCloseKey(regROOTIcon);
801 ::RegCloseKey(regCUSC);
802 ::RegCloseKey(regROOT);
803 if (::RegOpenKeyEx(regCUS,
"Classes", 0, KEY_READ | KEY_WRITE, ®CUSC) != ERROR_SUCCESS) {
805 regROOTwrite =
false;
807 if (::RegOpenKeyEx(regCUSC,
"ROOTDEV.ROOT", 0, KEY_WRITE, ®ROOT) != ERROR_SUCCESS) {
809 regROOTwrite =
false;
810 ::RegCloseKey(regCUSC);
817 TString fileopen =
"fileopen.C";
818 TString rootmacrodir =
"macros";
828 ::RegCloseKey(regROOT);
829 ::RegCloseKey(regCUSC);
830 ::RegCloseKey(regCUS);
834 static const char apptitle[] =
"ROOT data file";
835 ::RegSetValueEx(regROOT, NULL, 0, REG_SZ, (BYTE*)apptitle,
sizeof(apptitle));
836 DWORD editflags = 0x00010000;
837 ::RegSetValueEx(regROOT,
"EditFlags", 0, REG_DWORD, (BYTE*)&editflags,
sizeof(editflags));
840 if (::RegCreateKeyEx(regROOT,
"DefaultIcon", 0, NULL, 0, KEY_READ | KEY_WRITE,
841 NULL, ®ROOTIcon, NULL) == ERROR_SUCCESS) {
844 ::RegSetValueEx(regROOTIcon, NULL, 0, REG_SZ, (BYTE*)iconloc.Data(), iconloc.Length() + 1);
845 ::RegCloseKey(regROOTIcon);
850 if (::RegCreateKeyEx(regROOT,
"shell", 0, NULL, 0, KEY_READ | KEY_WRITE,
851 NULL, ®ROOTshell, NULL) == ERROR_SUCCESS) {
853 if (::RegCreateKeyEx(regROOTshell,
"open", 0, NULL, 0, KEY_READ | KEY_WRITE,
854 NULL, ®ShellOpen, NULL) == ERROR_SUCCESS) {
855 HKEY regShellOpenCmd;
856 if (::RegCreateKeyEx(regShellOpen,
"command", 0, NULL, 0, KEY_READ | KEY_WRITE,
857 NULL, ®ShellOpenCmd, NULL) == ERROR_SUCCESS) {
859 cmd +=
" -l \"%1\" \"";
862 ::RegSetValueEx(regShellOpenCmd, NULL, 0, REG_SZ, (BYTE*)cmd.Data(), cmd.Length() + 1);
863 ::RegCloseKey(regShellOpenCmd);
865 ::RegCloseKey(regShellOpen);
867 ::RegCloseKey(regROOTshell);
869 ::RegCloseKey(regROOT);
871 if (::RegCreateKeyEx(regCUSC,
".root", 0, NULL, 0, KEY_READ | KEY_WRITE,
872 NULL, ®ROOT, NULL) == ERROR_SUCCESS) {
873 static const char appname[] =
"ROOTDEV.ROOT";
874 ::RegSetValueEx(regROOT, NULL, 0, REG_SZ, (BYTE*)appname,
sizeof(appname));
876 ::RegCloseKey(regCUSC);
877 ::RegCloseKey(regCUS);
880 ::SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
888 static bool once =
true;
891 if (!once ||
gROOT->IsBatch())
return false;
892 TString cmdline(::GetCommandLine());
893 Int_t i = 0, from = 0;
894 while (cmdline.Tokenize(arg, from,
" ")) {
896 if (i == 0 && ((arg !=
"root") && (arg !=
"rootn") &&
897 (arg !=
"root.exe") && (arg !=
"rootn.exe")))
return false;
898 else if ((arg ==
"-l") || (arg ==
"-b"))
return false;
910 static void SetConsoleWindowName()
912 char pszNewWindowTitle[1024];
913 char pszOldWindowTitle[1024];
915 CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
917 if (!::GetConsoleTitle(pszOldWindowTitle, 1024))
920 wsprintf(pszNewWindowTitle,
"%d/%d", ::GetTickCount(), ::GetCurrentProcessId());
922 if (!::SetConsoleTitle(pszNewWindowTitle))
932 ::SetConsoleTitle(
"ROOT session");
934 hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
935 ::SetConsoleMode(hStdout, ENABLE_PROCESSED_OUTPUT |
936 ENABLE_WRAP_AT_EOL_OUTPUT);
937 if (!::GetConsoleScreenBufferInfo(hStdout, &csbiInfo))
974fGUIThreadHandle(0), fGUIThreadId(0)
982 if (initwinsock = ::WSAStartup(MAKEWORD(2, 0), &WSAData)) {
983 Error(
"TWinNTSystem()",
"Starting sockets failed");
994 char *buf =
new char[MAX_MODULE_NAME32 + 1];
1000 HMODULE hModCore = ::GetModuleHandle(
"libCore.dll");
1002 ::GetModuleFileName(hModCore, buf, MAX_MODULE_NAME32 + 1);
1003 char *pLibName = strstr(buf,
"libCore.dll");
1006 while (--pLibName >= buf && *pLibName !=
'\\' && *pLibName !=
'/');
1009 check_path +=
"\\etc";
1011 while (buf[0] && GetFileAttributes(check_path.
Data()) == INVALID_FILE_ATTRIBUTES) {
1012 while (--pLibName >= buf && *pLibName !=
'\\' && *pLibName !=
'/');
1015 check_path +=
"\\etc";
1030 UpdateRegistry(
this, buf);
1041 typedef UINT (WINAPI* LPTIMEENDPERIOD)( UINT uPeriod );
1042 HINSTANCE hInstWinMM = LoadLibrary(
"winmm.dll" );
1044 LPTIMEENDPERIOD pTimeEndPeriod = (LPTIMEENDPERIOD)GetProcAddress( hInstWinMM,
"timeEndPeriod" );
1045 if( NULL != pTimeEndPeriod )
1047 FreeLibrary(hInstWinMM);
1058 ::ResetEvent(gGlobalEvent);
1059 ::CloseHandle(gGlobalEvent);
1062 if (gTimerThreadHandle) {
1063 ::TerminateThread(gTimerThreadHandle, 0);
1064 ::CloseHandle(gTimerThreadHandle);
1073 const char *dir = 0;
1101 ::SetUnhandledExceptionFilter(ExceptionFilter);
1109 typedef UINT (WINAPI* LPTIMEBEGINPERIOD)( UINT uPeriod );
1110 HINSTANCE hInstWinMM = LoadLibrary(
"winmm.dll" );
1112 LPTIMEBEGINPERIOD pTimeBeginPeriod = (LPTIMEBEGINPERIOD)GetProcAddress( hInstWinMM,
"timeBeginPeriod" );
1113 if( NULL != pTimeBeginPeriod )
1114 pTimeBeginPeriod(1);
1115 FreeLibrary(hInstWinMM);
1117 gTimerThreadHandle = ::CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)
ThreadStub,
1120 gGlobalEvent = ::CreateEvent(NULL,
TRUE,
FALSE, NULL);
1123 char *buf =
new char[MAX_MODULE_NAME32 + 1];
1124 HMODULE hModCore = ::GetModuleHandle(
"libCore.dll");
1126 ::GetModuleFileName(hModCore, buf, MAX_MODULE_NAME32 + 1);
1127 char *pLibName = strstr(buf,
"libCore.dll");
1134 SetConsoleWindowName();
1158 const char *symbol=
name;
1161 while ( (*symbol ==
' ' || *symbol ==
'\t') && *symbol) symbol++;
1164 if (isalpha(symbol[idx]) && symbol[idx+1] ==
':') idx = 2;
1165 if ( (symbol[idx] ==
'/' || symbol[idx] ==
'\\') && symbol[idx+1] ==
'\0') {
1170 Error(
"BaseName",
"name = 0");
1174 char *bslash = (
char *)strrchr(&symbol[idx],
'\\');
1175 char *rslash = (
char *)strrchr(&symbol[idx],
'/');
1176 if (cp = (std::max)(rslash, bslash)) {
1181 return &symbol[idx];
1183 Error(
"BaseName",
"name = 0");
1200 if (
name && namelen > 0) {
1202 fullname =
new char[namelen+5];
1203 strlcpy(fullname,
name,namelen+5);
1204 if ( !strrchr(fullname,
'.') )
1205 strlcat(fullname,
".exe",namelen+5);
1208 dot = strrchr(progname,
'.');
1209 idot = dot ? (
ULong_t)(dot - progname) : strlen(progname);
1214 which =
StrDup(fullname);
1225 dirname.
Form(
"%c:%s", driveletter,
d);
1227 dirname.
Form(
"%s",
d);
1240 progname[idot] =
'\0';
1242 if (which)
delete [] which;
1246 if (::NeedSplash()) {
1259 if (err < 0 || err >= sys_nerr) {
1261 error_msg.
Form(
"errno out of range %d", err);
1264 return sys_errlist[err];
1277 DWORD il =
sizeof(hn);
1278 ::GetComputerName(hn, &il);
1294 if (freq < 37) freq = 440;
1295 if (duration < 0) duration = 100;
1304 gGUIThreadMsgFunc = func;
1327 int fd =
h->GetFd();
1330 if (
h->HasReadInterest()) {
1333 if (
h->HasWriteInterest()) {
1365 set_console =
kTRUE;
1378 ::SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleSigHandler,
TRUE);
1391 int sig =
h->GetSignal();
1404 ::SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleSigHandler,
FALSE);
1448 HANDLE snapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD,::GetCurrentProcessId());
1453 if (!InitImagehlpFunctions()) {
1454 std::cerr <<
"No stack trace: cannot find (functions in) dbghelp.dll!" << std::endl;
1459 SYSTEM_INFO sysInfo;
1460 ::GetSystemInfo(&sysInfo);
1461 DWORD machineType = IMAGE_FILE_MACHINE_I386;
1462 switch (sysInfo.wProcessorArchitecture) {
1463 case PROCESSOR_ARCHITECTURE_AMD64:
1464 machineType = IMAGE_FILE_MACHINE_AMD64;
1466 case PROCESSOR_ARCHITECTURE_IA64:
1467 machineType = IMAGE_FILE_MACHINE_IA64;
1471 DWORD currentThreadID = ::GetCurrentThreadId();
1472 DWORD currentProcessID = ::GetCurrentProcessId();
1476 THREADENTRY32 threadentry;
1477 threadentry.dwSize =
sizeof(THREADENTRY32);
1478 if (!::Thread32First(snapshot, &threadentry))
return;
1480 std::cerr << std::endl <<
"==========================================" << std::endl;
1481 std::cerr <<
"=============== STACKTRACE ===============" << std::endl;
1482 std::cerr <<
"==========================================" << std::endl << std::endl;
1485 if (threadentry.th32OwnerProcessID != currentProcessID)
1487 HANDLE thread = ::OpenThread(THREAD_GET_CONTEXT|THREAD_SUSPEND_RESUME|THREAD_QUERY_INFORMATION,
1488 FALSE, threadentry.th32ThreadID);
1490 memset(&context, 0,
sizeof(CONTEXT));
1492 if (threadentry.th32ThreadID != currentThreadID) {
1493 ::SuspendThread(thread);
1494 context.ContextFlags = CONTEXT_ALL;
1495 ::GetThreadContext(thread, &context);
1496 ::ResumeThread(thread);
1498 if (fgXcptContext) {
1499 context = *fgXcptContext;
1501 typedef void (WINAPI *RTLCCTXT)(PCONTEXT);
1502 RTLCCTXT p2RtlCCtxt = (RTLCCTXT) ::GetProcAddress(
1503 GetModuleHandle(
"kernel32.dll"),
"RtlCaptureContext");
1505 context.ContextFlags = CONTEXT_ALL;
1506 p2RtlCCtxt(&context);
1512 ::ZeroMemory(&frame,
sizeof(frame));
1514 frame.AddrPC.Mode = AddrModeFlat;
1515 frame.AddrFrame.Mode = AddrModeFlat;
1516 frame.AddrStack.Mode = AddrModeFlat;
1518 frame.AddrPC.Offset = context.Eip;
1519 frame.AddrFrame.Offset = context.Ebp;
1520 frame.AddrStack.Offset = context.Esp;
1521#elif defined(_M_X64)
1522 frame.AddrPC.Offset = context.Rip;
1523 frame.AddrFrame.Offset = context.Rsp;
1524 frame.AddrStack.Offset = context.Rsp;
1525#elif defined(_M_IA64)
1526 frame.AddrPC.Offset = context.StIIP;
1527 frame.AddrFrame.Offset = context.IntSp;
1528 frame.AddrStack.Offset = context.IntSp;
1529 frame.AddrBStore.Offset= context.RsBSP;
1531 std::cerr <<
"Stack traces not supported on your architecture yet." << std::endl;
1536 while (_StackWalk64(machineType, (HANDLE)::GetCurrentProcess(), thread, (LPSTACKFRAME64)&frame,
1537 (LPVOID)&context, (PREAD_PROCESS_MEMORY_ROUTINE)NULL, (PFUNCTION_TABLE_ACCESS_ROUTINE)_SymFunctionTableAccess64,
1538 (PGET_MODULE_BASE_ROUTINE)_SymGetModuleBase64, NULL)) {
1540 std::cerr << std::endl <<
"================ Thread " << iThread++ <<
" ================" << std::endl;
1541 if (!bFirst || threadentry.th32ThreadID != currentThreadID) {
1542 const std::string moduleName = GetModuleName(frame.AddrPC.Offset);
1543 const std::string functionName = GetFunctionName(frame.AddrPC.Offset);
1544 std::cerr <<
" " << moduleName << functionName << std::endl;
1548 ::CloseHandle(thread);
1549 }
while (::Thread32Next(snapshot, &threadentry));
1551 std::cerr << std::endl <<
"==========================================" << std::endl;
1552 std::cerr <<
"============= END STACKTRACE =============" << std::endl;
1553 std::cerr <<
"==========================================" << std::endl << std::endl;
1554 ::CloseHandle(snapshot);
1555 _SymCleanup(GetCurrentProcess());
1564 UInt_t oldmask = _statusfp( );
1566 if (oldmask & _EM_INVALID ) mask |=
kInvalid;
1567 if (oldmask & _EM_ZERODIVIDE) mask |=
kDivByZero;
1568 if (oldmask & _EM_OVERFLOW ) mask |=
kOverflow;
1569 if (oldmask & _EM_UNDERFLOW) mask |=
kUnderflow;
1570 if (oldmask & _EM_INEXACT ) mask |=
kInexact;
1584 if (mask &
kInvalid ) newm |= _EM_INVALID;
1585 if (mask &
kDivByZero) newm |= _EM_ZERODIVIDE;
1586 if (mask &
kOverflow ) newm |= _EM_OVERFLOW;
1587 if (mask &
kUnderflow) newm |= _EM_UNDERFLOW;
1588 if (mask &
kInexact ) newm |= _EM_INEXACT;
1592 ::_controlfp(
cm , _MCW_EM);
1611 if (pendingOnly && gGlobalEvent) ::SetEvent(gGlobalEvent);
1613 Bool_t pollOnce = pendingOnly;
1617 if (
gROOT->GetApplication()) {
1633 ::WaitForSingleObject(gGlobalEvent, 1);
1634 ::ResetEvent(gGlobalEvent);
1660 if (pendingOnly && !pollOnce)
1699 if (!pendingOnly && gGlobalEvent) {
1700 ::WaitForSingleObject(gGlobalEvent, 1);
1701 ::ResetEvent(gGlobalEvent);
1715 for (i = 0; i <
fReadmask->GetCount(); i++) {
1720 rc = WinNTSelect(&t, 0, 0);
1721 if (rc < 0 && rc != -2) {
1722 ::SysError(
"DispatchOneEvent",
"select: read error on %d\n", fd);
1728 for (i = 0; i <
fWritemask->GetCount(); i++) {
1734 rc = WinNTSelect(0, &t, 0);
1735 if (rc < 0 && rc != -2) {
1736 ::SysError(
"DispatchOneEvent",
"select: write error on %d\n", fd);
1788 if (sync == sh->
IsSync()) {
1790 if ((
fSignals->IsSet(sig) && sigdone == -1) || sigdone == sig) {
1791 if (sigdone == -1) {
1801 if (sigdone != -1)
return kTRUE;
1822 if ((
fReadready->IsSet(fd) && fddone == -1) ||
1823 (fddone == fd && read)) {
1833 (fddone == fd && !read)) {
1843 if (fddone != -1)
return kTRUE;
1860 if (dirname.
Length() == 0) {
1877 if (res)
return res;
1897 const char *
proto = (strstr(
name,
"file:///")) ?
"file://" :
"file:";
1900 if (!
name)
return 0;
1904 if (!
name)
return 0;
1936 HANDLE searchFile = (HANDLE)dirp;
1970 return (psz[0] == TEXT(
'\\') && psz[1] == TEXT(
'\\'));
1990#pragma data_seg(".text", "CODE")
2005 if (!IsDBCSLeadByte(*pPath)) {
2010 if ((*pPath == TEXT(
'\\')) && (*(pPath + 1) == 0))
2016 int cBackslashes = 0;
2017 for (p = pPath + 2; *p; p = CharNext(p)) {
2018 if (*p == TEXT(
'\\') && (++cBackslashes > 1))
2038 const char *
proto = (strstr(fdir,
"file:///")) ?
"file://" :
"file:";
2041 char *dir =
new char[MAX_PATH];
2042 if (IsShortcut(sdir)) {
2043 if (!ResolveShortCut(sdir, dir, MAX_PATH))
2044 strlcpy(dir, sdir,MAX_PATH);
2047 strlcpy(dir, sdir,MAX_PATH);
2049 int nche = strlen(dir)+3;
2050 char *entry =
new char[nche];
2051 struct _stati64 finfo;
2054 strlcpy(entry, dir,nche);
2055 if ((entry[strlen(dir)-1] ==
'/') || (entry[strlen(dir)-1] ==
'\\' )) {
2056 entry[strlen(dir)-1] =
'\0';
2059 strlcat(entry,
"\\",nche);
2061 if (_stati64(entry, &finfo) < 0) {
2068 strlcpy(entry, dir,nche);
2069 if ((entry[strlen(dir)-1] ==
'/') || (entry[strlen(dir)-1] ==
'\\' )) {
2071 entry[strlen(dir)-1] =
'\0';
2073 if (_stati64(entry, &finfo) < 0) {
2080 if (finfo.st_mode & S_IFDIR) {
2081 strlcpy(entry, dir,nche);
2082 if (!(entry[strlen(dir)-1] ==
'/' || entry[strlen(dir)-1] ==
'\\' )) {
2083 strlcat(entry,
"\\",nche);
2085 if (entry[strlen(dir)-1] ==
' ')
2086 entry[strlen(dir)-1] =
'\0';
2087 strlcat(entry,
"*",nche);
2156 char drive = driveletter ? toupper( driveletter ) -
'A' + 1 : 0;
2162 if (!(wdpath = ::_getdcwd( (
int)drive, wdpath,
kMAXPATHLEN))) {
2164 Warning(
"WorkingDirectory",
"getcwd() failed");
2188 return std::string(mydir);
2197 if (!(
h = ::getenv(
"home")))
h = ::getenv(
"HOME");
2204 h = ::getenv(
"HOMESHARE");
2205 if (!
h)
h = ::getenv(
"HOMEDRIVE");
2208 h = ::getenv(
"HOMEPATH");
2213 h = ::getenv(
"USERPROFILE");
2218 if (mydir[1] ==
':')
2219 mydir[0] = toupper(mydir[0]);
2235 if (!dir) dir =
"c:\\";
2251 char tmpName[MAX_PATH];
2255 FILE *fp = fopen(tmpName,
"w+");
2257 if (!fp)
::SysError(
"TempFileName",
"error opening %s", tmpName);
2275 if (!opt || !opt[0]) {
2280 UINT nOldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS);
2284 curdrive = _getdrive();
2285 if (strstr(opt,
"cur")) {
2287 sDrive.
Form(
"%c:", (curdrive +
'A' - 1));
2288 sType.
Form(
"Unknown Drive (%s)", sDrive.
Data());
2289 ::GetVolumeInformation(
Form(
"%s\\", sDrive.
Data()), NULL, 0, NULL, NULL,
2290 NULL, (LPSTR)szFs, 32);
2291 type = ::GetDriveType(sDrive.
Data());
2294 case DRIVE_NO_ROOT_DIR:
2296 case DRIVE_REMOVABLE:
2297 sType.
Form(
"Removable Disk (%s)", sDrive.
Data());
2300 sType.
Form(
"Local Disk (%s)", sDrive.
Data());
2303 sType.
Form(
"Network Drive (%s) (%s)", szFs, sDrive.
Data());
2306 sType.
Form(
"CD/DVD Drive (%s)", sDrive.
Data());
2309 sType.
Form(
"RAM Disk (%s)", sDrive.
Data());
2314 else if (strstr(opt,
"all")) {
2317 if (::GetLogicalDriveStrings(511, szTemp)) {
2318 TCHAR szDrive[3] = TEXT(
" :");
2324 sDrive.
Form(
"%s", szDrive);
2326 if ((sDrive ==
"A:") || (sDrive ==
"B:")) {
2330 sType.
Form(
"Unknown Drive (%s)", sDrive.
Data());
2331 ::GetVolumeInformation(
Form(
"%s\\", sDrive.
Data()), NULL, 0, NULL,
2332 NULL, NULL, (LPSTR)szFs, 32);
2333 type = ::GetDriveType(sDrive.
Data());
2336 case DRIVE_NO_ROOT_DIR:
2338 case DRIVE_REMOVABLE:
2339 sType.
Form(
"Removable Disk (%s)", sDrive.
Data());
2342 sType.
Form(
"Local Disk (%s)", sDrive.
Data());
2345 sType.
Form(
"Network Drive (%s) (%s)", szFs, sDrive.
Data());
2348 sType.
Form(
"CD/DVD Drive (%s)", sDrive.
Data());
2351 sType.
Form(
"RAM Disk (%s)", sDrive.
Data());
2361 ::SetErrorMode(nOldErrorMode);
2380 if (strchr(pathname,
'/') || strchr(pathname,
'\\')) {
2381 const char *rslash = strrchr(pathname,
'/');
2382 const char *bslash = strrchr(pathname,
'\\');
2383 const char *
r = (std::max)(rslash, bslash);
2384 const char *ptr = pathname;
2394 int len =
r - pathname;
2426 if (!pathname)
return 0;
2427 if (!pathname[0])
return 0;
2433 while(*lpchar ==
' ') lpchar++;
2435 if (isalpha((
int)*lpchar) && *(lpchar+1) ==
':') {
2439 if ( (*lpchar ==
'\\' || *lpchar ==
'/' ) &&
2440 (*(lpchar+1) ==
'\\' || *(lpchar+1) ==
'/') )
return 0;
2453 if (strchr(dir,
':')) idx = 2;
2454 return (dir[idx] ==
'/' || dir[idx] ==
'\\');
2487 const int kBufSize = 1024;
2488 TTHREAD_TLS_ARRAY(
char, kBufSize, temp);
2490 strlcpy(temp,
name, kBufSize);
2491 char *currentChar = temp;
2494 while (*currentChar !=
'\0') {
2495 if (*currentChar ==
'\\') *currentChar =
'/';
2513 UINT nOldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS);
2517 const char *
proto = (strstr(path,
"file:///")) ?
"file://" :
"file:";
2520 ::SetErrorMode(nOldErrorMode);
2525 ::SetErrorMode(nOldErrorMode);
2548 if (dir && dir[0]) {
2550 char last = dir[strlen(dir) - 1];
2551 if (last !=
'/' && last !=
'\\') {
2555 name.ReplaceAll(
"/",
"\\");
2572 if (!ret)
return -1;
2581 int ret = ::rename(
f, t);
2598 struct _stati64 sbuf;
2601 const char *
proto = (strstr(path,
"file:///")) ?
"file://" :
"file:";
2603 int l = strlen(newpath);
2605 if (newpath[--
l] !=
'\\' || newpath[--
l] !=
'/') {
2611 if (newpath && ::_stati64(newpath, &sbuf) >= 0) {
2613 buf.
fDev = sbuf.st_dev;
2614 buf.
fIno = sbuf.st_ino;
2615 buf.
fMode = sbuf.st_mode;
2616 buf.
fUid = sbuf.st_uid;
2617 buf.
fGid = sbuf.st_gid;
2618 buf.
fSize = sbuf.st_size;
2619 buf.
fMtime = sbuf.st_mtime;
2620 buf.
fIsLink = IsShortcut(newpath);
2622 char *lpath =
new char[MAX_PATH];
2623 if (IsShortcut(newpath)) {
2624 struct _stati64 sbuf2;
2625 if (ResolveShortCut(newpath, lpath, MAX_PATH)) {
2626 if (::_stati64(lpath, &sbuf2) >= 0) {
2627 buf.
fMode = sbuf2.st_mode;
2653 LPCTSTR lpRootPathName = path;
2656 LPTSTR lpVolumeNameBuffer = 0;
2657 DWORD nVolumeNameSize = 0;
2659 DWORD volumeSerialNumber;
2660 DWORD maximumComponentLength;
2663 DWORD fileSystemFlags;
2666 char fileSystemNameBuffer[512];
2667 DWORD nFileSystemNameSize =
sizeof(fileSystemNameBuffer);
2670 UINT nOldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS);
2671 if (!::GetVolumeInformation(lpRootPathName,
2672 lpVolumeNameBuffer, nVolumeNameSize,
2673 &volumeSerialNumber,
2674 &maximumComponentLength,
2676 fileSystemNameBuffer, nFileSystemNameSize)) {
2678 ::SetErrorMode(nOldErrorMode);
2682 const char *fsNames[] = {
"FAT",
"NTFS" };
2684 for (i = 0; i < 2; i++) {
2685 if (!strncmp(fileSystemNameBuffer, fsNames[i], nFileSystemNameSize))
2690 DWORD sectorsPerCluster;
2691 DWORD bytesPerSector;
2692 DWORD numberOfFreeClusters;
2693 DWORD totalNumberOfClusters;
2695 if (!::GetDiskFreeSpace(lpRootPathName,
2698 &numberOfFreeClusters,
2699 &totalNumberOfClusters)) {
2701 ::SetErrorMode(nOldErrorMode);
2705 ::SetErrorMode(nOldErrorMode);
2707 *bsize = sectorsPerCluster * bytesPerSector;
2708 *blocks = totalNumberOfClusters;
2709 *bfree = numberOfFreeClusters;
2719 struct _stati64 finfo;
2724 char linkname[1024];
2725 LPTSTR lpszFilePart;
2726 TCHAR szPath[MAX_PATH];
2729 typedef BOOL (__stdcall *CREATEHARDLINKPROC)( LPCTSTR, LPCTSTR, LPSECURITY_ATTRIBUTES );
2730 static CREATEHARDLINKPROC _CreateHardLink = 0;
2732 HMODULE hModImagehlp = LoadLibrary(
"Kernel32.dll" );
2737 _CreateHardLink = (CREATEHARDLINKPROC) GetProcAddress( hModImagehlp,
"CreateHardLinkW" );
2739 _CreateHardLink = (CREATEHARDLINKPROC) GetProcAddress( hModImagehlp,
"CreateHardLinkA" );
2741 if (!_CreateHardLink)
2744 dwRet = GetFullPathName(from,
sizeof(szPath) /
sizeof(TCHAR),
2745 szPath, &lpszFilePart);
2747 if (_stati64(szPath, &finfo) < 0)
2750 if (finfo.st_mode & S_IFDIR)
2754 _splitpath(linkname,winDrive,winDir,winName,winExt);
2755 if ((!winDrive[0] ) &&
2757 _splitpath(szPath,winDrive,winDir,winName,winExt);
2758 snprintf(linkname,1024,
"%s\\%s\\%s", winDrive, winDir, to);
2760 else if (!winDrive[0]) {
2761 _splitpath(szPath,winDrive,winDir,winName,winExt);
2762 snprintf(linkname,1024,
"%s\\%s", winDrive, to);
2765 if (!_CreateHardLink(linkname, szPath, NULL))
2778 IShellLink* pShellLink;
2779 IPersistFile* pPersistFile;
2780 WCHAR wszLinkfile[MAX_PATH];
2781 int iWideCharsWritten;
2783 LPTSTR lpszFilePart;
2784 TCHAR szPath[MAX_PATH];
2786 hRes = E_INVALIDARG;
2787 if ((from == NULL) || (!from[0]) || (to == NULL) ||
2793 typedef HRESULT (__stdcall *COINITIALIZEPROC)( LPVOID );
2794 static COINITIALIZEPROC _CoInitialize = 0;
2795 typedef void (__stdcall *COUNINITIALIZEPROC)(
void );
2796 static COUNINITIALIZEPROC _CoUninitialize = 0;
2797 typedef HRESULT (__stdcall *COCREATEINSTANCEPROC)( REFCLSID, LPUNKNOWN, DWORD, REFIID, LPVOID );
2798 static COCREATEINSTANCEPROC _CoCreateInstance = 0;
2800 HMODULE hModImagehlp = LoadLibrary(
"ole32.dll" );
2804 _CoInitialize = (COINITIALIZEPROC) GetProcAddress( hModImagehlp,
"CoInitialize" );
2807 _CoUninitialize = (COUNINITIALIZEPROC) GetProcAddress( hModImagehlp,
"CoUninitialize" );
2808 if (!_CoUninitialize)
2810 _CoCreateInstance = (COCREATEINSTANCEPROC) GetProcAddress( hModImagehlp,
"CoCreateInstance" );
2811 if (!_CoCreateInstance)
2818 _CoInitialize(NULL);
2821 dwRet = GetFullPathName(from,
sizeof(szPath) /
sizeof(TCHAR),
2822 szPath, &lpszFilePart);
2823 hRes = _CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
2824 IID_IShellLink, (LPVOID *)&pShellLink);
2825 if (SUCCEEDED(hRes)) {
2827 hRes = pShellLink->SetPath(szPath);
2829 hRes = pShellLink->QueryInterface(IID_IPersistFile, (
void **)&pPersistFile);
2830 if (SUCCEEDED(hRes)){
2831 iWideCharsWritten = MultiByteToWideChar(CP_ACP, 0, linkname.
Data(), -1,
2832 wszLinkfile, MAX_PATH);
2833 hRes = pPersistFile->Save(wszLinkfile,
TRUE);
2834 pPersistFile->Release();
2836 pShellLink->Release();
2854 struct _stati64 finfo;
2856 if (_stati64(
name, &finfo) < 0) {
2860 if (finfo.st_mode & S_IFDIR) {
2861 return ::_rmdir(
name);
2863 return ::_unlink(
name);
2872 if (::ioctlsocket(fd, FIONBIO, (u_long *)1) == SOCKET_ERROR) {
2891 const char *patbuf = (
const char *)patbuf0;
2899 const char driveletter =
DriveName(patbuf);
2908 if (!
proto.EqualTo(
"file"))
2916 while (*patbuf ==
' ') {
2921 while (*patbuf ==
':') {
2926 while (*patbuf ==
';') {
2932 for (
q = (
char*)patbuf; *
q;
q++) {
2936 if ( (((
q-2)>patbuf) && ( (*(
q-2)!=
';') || !isalpha(*(
q-1)) )) &&
2943 for (p = patbuf; *p; p++) {
2960 char replacement[4];
2963 for (
int k = 0; k<3; k++) replacement[k] = 0x1;
2965 replacement[3] = 0x0;
2969 while ( (pos = patbuf0.
Index(TildaNum,pos)) !=
kNPOS ) {
2970 patbuf0.
Replace(pos, 1, replacement);
2976 Int_t lbuf = ::ExpandEnvironmentStrings(
2982 cmd =
new char[lbuf+1];
2983 ::ExpandEnvironmentStrings(
3002 char newpath[MAX_PATH];
3003 if (IsShortcut(path)) {
3004 if (!ResolveShortCut(path, newpath, MAX_PATH))
3005 strlcpy(newpath, path, MAX_PATH);
3008 strlcpy(newpath, path, MAX_PATH);
3023 return ::_chmod(
file, mode);
3031 return ::umask(mask);
3041 Error(
"Utime",
"need write permission for %s to change utime",
file);
3044 if (!actime) actime = modtime;
3047 t.actime = (time_t)actime;
3048 t.modtime = (time_t)modtime;
3049 return ::utime(
file, &t);
3068 return infile.
Data();
3076 Int_t lastDelim = -1;
3077 for(
int i=0; i < exsearch.
Length(); ++i) {
3078 switch( exsearch[i] ) {
3081 if (i-lastDelim!=2) exsearch[i] =
';';
3084 case ';': lastDelim = i;
break;
3091 char *lpFilePart = 0;
3093 ::access(
name, mode) == 0 && stat(
name, &finfo) == 0 &&
3094 finfo.st_mode & S_IFREG) {
3099 return infile.
Data();
3113 if ((
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) && (::GetVersion() < 0x80000000)) {
3116 HINSTANCE netapi = ::LoadLibrary(
"netapi32.DLL");
3117 if (!netapi)
return kFALSE;
3119 p2NetApiBufferFree = (pfn1)::GetProcAddress(netapi,
"NetApiBufferFree");
3120 p2NetUserGetInfo = (pfn2)::GetProcAddress(netapi,
"NetUserGetInfo");
3121 p2NetLocalGroupGetMembers = (pfn3)::GetProcAddress(netapi,
"NetLocalGroupGetMembers");
3122 p2NetLocalGroupEnum = (pfn4)::GetProcAddress(netapi,
"NetLocalGroupEnum");
3124 if (!p2NetApiBufferFree || !p2NetUserGetInfo ||
3125 !p2NetLocalGroupGetMembers || !p2NetLocalGroupEnum)
return kFALSE;
3136 ::FreeLibrary(netapi);
3146 NET_API_STATUS NetStatus = NERR_Success;
3148 DWORD
Index = 0, ResumeHandle = 0, Total = 0;
3149 LOCALGROUP_MEMBERS_INFO_1 *MemberInfo;
3150 WCHAR wszGroupName[256];
3152 DWORD dwLastError = 0;
3154 iRetOp = MultiByteToWideChar (
3156 (DWORD)MB_PRECOMPOSED,
3157 (LPCSTR)lpszGroupName,
3159 (LPWSTR)wszGroupName,
3160 (
int)
sizeof(wszGroupName) );
3163 dwLastError = GetLastError();
3165 p2NetApiBufferFree(Data);
3171 NetStatus = p2NetLocalGroupGetMembers (NULL, wszGroupName, 1,
3172 &Data, 8192, &
Index, &Total, &ResumeHandle );
3174 if (NetStatus != NERR_Success || Data == NULL) {
3175 dwLastError = GetLastError();
3177 if (dwLastError == ERROR_ENVVAR_NOT_FOUND) {
3183 NetStatus = p2NetLocalGroupGetMembers ( NULL, wszGroupName, 0,
3184 &Data, 8192, &
Index, &Total, &ResumeHandle );
3188 p2NetApiBufferFree(Data);
3193 MemberInfo = (LOCALGROUP_MEMBERS_INFO_1 *)Data;
3196 p2NetApiBufferFree(Data);
3205 NET_API_STATUS NetStatus = NERR_Success;
3207 DWORD
Index = 0, ResumeHandle = 0, Total = 0, i;
3208 LOCALGROUP_INFO_0 *GroupInfo;
3209 char szAnsiName[256];
3210 DWORD dwLastError = 0;
3213 NetStatus = p2NetLocalGroupEnum(NULL, 0, &Data, 8192, &
Index,
3214 &Total, &ResumeHandle );
3216 if (NetStatus != NERR_Success || Data == NULL) {
3217 dwLastError = GetLastError();
3219 p2NetApiBufferFree(Data);
3224 GroupInfo = (LOCALGROUP_INFO_0 *)Data;
3225 for (i=0; i < Total; i++) {
3227 iRetOp = WideCharToMultiByte (
3230 (LPCWSTR)(GroupInfo->lgrpi0_name),
3233 (
int)(
sizeof(szAnsiName)),
3245 p2NetApiBufferFree(Data);
3257 int &groupIdx,
int &memberIdx)
3259 BOOL bRetOp =
FALSE;
3261 DWORD dwSidSize, dwDomainNameSize;
3264 SID_NAME_USE sidType;
3265 PUCHAR puchar_SubAuthCount = NULL;
3266 SID_IDENTIFIER_AUTHORITY sid_identifier_authority;
3267 PSID_IDENTIFIER_AUTHORITY psid_identifier_authority = NULL;
3268 unsigned char j = 0;
3269 DWORD dwLastError = 0;
3271 pSid = (PSID)bySidBuffer;
3272 dwSidSize =
sizeof(bySidBuffer);
3273 dwDomainNameSize =
sizeof(szDomainName);
3275 bRetOp = LookupAccountName (
3277 (LPCTSTR)lpszAccountName,
3279 (LPDWORD)&dwSidSize,
3280 (LPTSTR)szDomainName,
3281 (LPDWORD)&dwDomainNameSize,
3282 (PSID_NAME_USE)&sidType );
3284 if (bRetOp ==
FALSE) {
3285 dwLastError = GetLastError();
3289 bRetOp = IsValidSid((PSID)pSid);
3291 if (bRetOp ==
FALSE) {
3292 dwLastError = GetLastError();
3297 psid_identifier_authority = GetSidIdentifierAuthority ((PSID)pSid);
3300 memcpy (&sid_identifier_authority, psid_identifier_authority,
3301 sizeof(SID_IDENTIFIER_AUTHORITY));
3304 puchar_SubAuthCount = (PUCHAR)GetSidSubAuthorityCount((PSID)pSid);
3306 j = (
unsigned char)(*puchar_SubAuthCount);
3308 DWORD dwSubAuth = 0;
3309 PDWORD pdwSubAuth = NULL;
3311 pdwSubAuth = (PDWORD)GetSidSubAuthority (
3314 dwSubAuth = *pdwSubAuth;
3333 NET_API_STATUS NetStatus = NERR_Success;
3335 DWORD
Index = 0, ResumeHandle = 0, Total = 0, i;
3336 LOCALGROUP_MEMBERS_INFO_1 *MemberInfo;
3337 char szAnsiMemberName[256];
3338 char szFullMemberName[256];
3339 char szMemberHomeDir[256];
3340 WCHAR wszGroupName[256];
3343 DWORD length =
sizeof (act_name);
3344 DWORD dwLastError = 0;
3345 LPUSER_INFO_11 pUI11Buf = NULL;
3346 NET_API_STATUS nStatus;
3348 iRetOp = MultiByteToWideChar (
3350 (DWORD)MB_PRECOMPOSED,
3351 (LPCSTR)lpszGroupName,
3353 (LPWSTR)wszGroupName,
3354 (
int)
sizeof(wszGroupName) );
3357 dwLastError = GetLastError();
3359 p2NetApiBufferFree(Data);
3363 GetUserName (act_name, &length);
3367 NetStatus = p2NetLocalGroupGetMembers (NULL, wszGroupName, 1,
3368 &Data, 8192, &
Index, &Total, &ResumeHandle );
3370 if (NetStatus != NERR_Success || Data == NULL) {
3371 dwLastError = GetLastError();
3373 if (dwLastError == ERROR_ENVVAR_NOT_FOUND) {
3379 NetStatus = p2NetLocalGroupGetMembers ( NULL, wszGroupName, 0,
3380 &Data, 8192, &
Index, &Total, &ResumeHandle );
3384 p2NetApiBufferFree(Data);
3388 MemberInfo = (LOCALGROUP_MEMBERS_INFO_1 *)Data;
3389 for (i=0; i < Total; i++) {
3390 iRetOp = WideCharToMultiByte (
3393 (LPCWSTR)(MemberInfo->lgrmi1_name),
3395 (LPSTR)szAnsiMemberName,
3396 (
int)(
sizeof(szAnsiMemberName)),
3401 dwLastError = GetLastError();
3412 TCHAR szUserName[255]=TEXT(
"");
3413 MultiByteToWideChar(CP_ACP, 0, szAnsiMemberName, -1, (LPWSTR)szUserName, 255);
3417 nStatus = p2NetUserGetInfo(NULL, (LPCWSTR)szUserName, 11, (LPBYTE *)&pUI11Buf);
3421 if (nStatus == NERR_Success) {
3422 if (pUI11Buf != NULL) {
3423 wsprintf(szFullMemberName,
"%S",pUI11Buf->usri11_full_name);
3425 wsprintf(szMemberHomeDir,
"%S",pUI11Buf->usri11_home_dir);
3436 if (pUI11Buf != NULL) {
3437 p2NetApiBufferFree(pUI11Buf);
3442 if (getenv(
"SHELL") == NULL)
3443 putenv ((GetVersion () & 0x80000000) ?
"SHELL=command" :
"SHELL=cmd");
3456 p2NetApiBufferFree(Data);
3466 NET_API_STATUS NetStatus = NERR_Success;
3468 DWORD
Index = 0, ResumeHandle = 0, Total = 0, i;
3469 LOCALGROUP_INFO_0 *GroupInfo;
3470 char szAnsiName[256];
3471 DWORD dwLastError = 0;
3472 int iRetOp = 0, iGroupIdx = 0, iMemberIdx = 0;
3474 NetStatus = p2NetLocalGroupEnum(NULL, 0, &Data, 8192, &
Index,
3475 &Total, &ResumeHandle );
3477 if (NetStatus != NERR_Success || Data == NULL) {
3478 dwLastError = GetLastError();
3480 p2NetApiBufferFree(Data);
3484 GroupInfo = (LOCALGROUP_INFO_0 *)Data;
3485 for (i=0; i < Total; i++) {
3487 iRetOp = WideCharToMultiByte (
3490 (LPCWSTR)(GroupInfo->lgrpi0_name),
3493 (
int)(
sizeof(szAnsiName)),
3511 p2NetApiBufferFree(Data);
3525 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3528 DWORD length =
sizeof (
name);
3529 if (::GetUserName (
name, &length)) {
3530 if (stricmp (
"administrator",
name) == 0)
3540 if (!user || !user[0])
3566 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3569 DWORD length =
sizeof (
name);
3570 if (::GetUserName (
name, &length)) {
3571 if (stricmp (
"administrator",
name) == 0)
3593 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3596 DWORD length =
sizeof (
name);
3597 if (::GetUserName (
name, &length)) {
3598 if (stricmp (
"administrator",
name) == 0)
3611 struct group *grp = 0;
3634 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3637 DWORD length =
sizeof (
name);
3638 if (::GetUserName (
name, &length)) {
3639 if (stricmp (
"administrator",
name) == 0)
3662 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3664 DWORD length =
sizeof (
name);
3666 if (::GetUserName (
name, &length)) {
3668 if (stricmp (
"administrator",
name) == 0) {
3670 ug->
fGroup =
"administrators";
3679 ug->
fUser =
"unknown";
3692 for (
int i = 0; i <
fNbUsers; i++) {
3736 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3738 DWORD length =
sizeof (
name);
3740 if (::GetUserName (
name, &length)) {
3741 if (stricmp (
"administrator",
name) == 0) {
3742 gr->fGroup =
"administrators";
3746 gr->fGroup =
"users";
3751 gr->fGroup =
"unknown";
3757 struct group *grp = 0;
3802 const char *env = ::getenv(
name);
3804 if (::_stricmp(
name,
"home") == 0 ) {
3806 }
else if (::_stricmp(
name,
"rootsys") == 0 ) {
3820 return ::system(shellcmd);
3828 return ::_popen(command, mode);
3836 return ::_pclose(pipe);
3864 gROOT->CloseFiles();
3865 if (
gROOT->GetListOfBrowsers()) {
3868 if (
gROOT->IsBatch())
3869 gROOT->GetListOfBrowsers()->Delete();
3875 if (((TBrowser*)0x%lx)->GetBrowserImp() &&\
3876 ((TBrowser*)0x%lx)->GetBrowserImp()->GetMainFrame()) \
3877 ((TBrowser*)0x%lx)->GetBrowserImp()->GetMainFrame()->CloseWindow();\
3881 gROOT->EndOfProcessCleanups();
3921 static int fd1=0, fd2=0;
3922 static fpos_t pos1=0, pos2=0;
3932 const char *
m = (mode[0] ==
'a' || mode[0] ==
'w') ? mode :
"a";
3945 fgetpos(stdout, &pos1);
3946 fd1 = _dup(fileno(stdout));
3948 if ((fout = freopen(
file,
m, stdout)) == 0) {
3949 SysError(
"RedirectOutput",
"could not freopen stdout");
3951 _dup2(fd1, fileno(stdout));
3955 fsetpos(stdout, &pos1);
3960 fgetpos(stderr, &pos2);
3961 fd2 = _dup(fileno(stderr));
3962 if ((ferr = freopen(
file,
m, stderr)) == 0) {
3963 SysError(
"RedirectOutput",
"could not freopen stderr");
3965 _dup2(fd1, fileno(stdout));
3969 fsetpos(stdout, &pos1);
3971 _dup2(fd2, fileno(stderr));
3975 fsetpos(stderr, &pos2);
3980 fseek(fout, 0, SEEK_END);
3981 fseek(ferr, 0, SEEK_END);
3988 if (_dup2(fd1, fileno(stdout))) {
3989 SysError(
"RedirectOutput",
"could not restore stdout");
3995 fsetpos(stdout, &pos1);
4002 if (_dup2(fd2, fileno(stderr))) {
4003 SysError(
"RedirectOutput",
"could not restore stderr");
4009 fsetpos(stderr, &pos2);
4064 if (len > 4 && (!stricmp(sLib.
Data()+len-4,
".dll"))) {
4077 Error(
"DynamicPathName",
4078 "%s does not exist in %s,\nor has wrong file extension (.dll)",
4095#pragma warning(push)
4096#pragma warning(disable:4200)
4113 if (!linkedLibs.
IsNull())
4126 HANDLE hFile, hMapping;
4129 if((hFile = CreateFile(exe,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,0))==
INVALID_HANDLE_VALUE) {
4133 if(!(hMapping = CreateFileMapping(hFile,0,PAGE_READONLY|SEC_COMMIT,0,0,0))) {
4138 if(!(basepointer = MapViewOfFile(hMapping,FILE_MAP_READ,0,0,0))) {
4139 CloseHandle(hMapping);
4146 IMAGE_DOS_HEADER *dos_head = (IMAGE_DOS_HEADER *)basepointer;
4149 IMAGE_FILE_HEADER _head;
4150 IMAGE_OPTIONAL_HEADER opt_head;
4151 IMAGE_SECTION_HEADER section_header[];
4153 struct header *pheader;
4154 const IMAGE_SECTION_HEADER * section_header;
4156 if(dos_head->e_magic!=
'ZM') {
4161 pheader = (
struct header *)((
char*)dos_head + dos_head->e_lfanew);
4163 if(IsBadReadPtr(pheader,
sizeof(
struct header))) {
4167 if(pheader->signature!=IMAGE_NT_SIGNATURE) {
4168 switch((
unsigned short)pheader->signature) {
4169 case IMAGE_DOS_SIGNATURE:
4172 case IMAGE_OS2_SIGNATURE:
4175 case IMAGE_OS2_SIGNATURE_LE:
4183#define isin(address,start,length) ((address)>=(start) && (address)<(start)+(length))
4186 for(sect=0,section_header=pheader->section_header;
4187 sect<pheader->_head.NumberOfSections;sect++,section_header++) {
4189 const void *
const section_data =
4190 (
char*)basepointer + section_header->PointerToRawData;
4191 for(directory=0;directory<IMAGE_NUMBEROF_DIRECTORY_ENTRIES;directory++) {
4192 if(
isin(pheader->opt_head.DataDirectory[directory].VirtualAddress,
4193 section_header->VirtualAddress,
4194 section_header->SizeOfRawData)) {
4195 const IMAGE_IMPORT_DESCRIPTOR *stuff_start =
4196 (IMAGE_IMPORT_DESCRIPTOR *)((
char*)section_data +
4197 (pheader->opt_head.DataDirectory[directory].VirtualAddress -
4198 section_header->VirtualAddress));
4201 const unsigned stuff_length =
4202 pheader->opt_head.DataDirectory[directory].Size;
4203 if(directory == IMAGE_DIRECTORY_ENTRY_IMPORT) {
4204 while(!IsBadReadPtr(stuff_start,
sizeof(*stuff_start)) &&
4205 stuff_start->Name) {
4206 TString dll = (
char*)section_data +
4207 ((DWORD)(stuff_start->Name)) -
4208 section_header->VirtualAddress;
4212 char *winPath = getenv(
"windir");
4213 _splitpath(winPath,winDrive,winDir,winName,winExt);
4214 if(!strstr(dllPath, winDir)) {
4215 if (!linkedLibs.
IsNull())
4217 linkedLibs += dllPath;
4229 UnmapViewOfFile(basepointer);
4230 CloseHandle(hMapping);
4263 TRegexp separator(
"[^ \\t\\s]+");
4268 Ssiz_t start, index, end;
4269 start = index = end = 0;
4271 while ((start < libs.
Length()) && (index !=
kNPOS)) {
4272 index = libs.
Index(separator, &end, start);
4276 s = libs(index, end);
4278 if ((
s.Index(
"c:/windows/") !=
kNPOS) ||
4279 (
s.Index(
"python") !=
kNPOS)) {
4283 if (
s.Index(user_dll) !=
kNPOS) {
4284 s.ReplaceAll(
".dll",
".lib");
4286 s.Replace( 0,
s.Last(
'/')+1, 0, 0);
4287 s.Replace( 0,
s.Last(
'\\')+1, 0, 0);
4289 }
else if (
s.Index(user_lib) !=
kNPOS) {
4291 s.Replace( 0,
s.Last(
'/')+1, 0, 0);
4292 s.Replace( 0,
s.Last(
'\\')+1, 0, 0);
4296 if ((
s.Index(
"python") ==
kNPOS) && (
s.Index(
"cppyy") ==
kNPOS) &&
4297 (
s.Index(
"vcruntime") ==
kNPOS) && (
s.Index(
".pyd") ==
kNPOS) &&
4298 (
s.Index(
"msvcp") ==
kNPOS))
4362 if (mode && t->
IsSync()) {
4366 }
else if (!mode && t->
IsAsync()) {
4384 FILETIME ftFileTime;
4388 ::GetSystemTimeAsFileTime(&ftRealTime.ftFileTime);
4397 OSVERSIONINFO OsVersionInfo;
4406 OsVersionInfo.dwOSVersionInfoSize =
sizeof(OSVERSIONINFO);
4407 GetVersionEx(&OsVersionInfo);
4408 if (OsVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) {
4414 FILETIME ftFileTime;
4419 FILETIME ftFileTime;
4423 HANDLE hThread = GetCurrentThread();
4424 ret = GetThreadTimes (hThread, &ftCreate, &ftExit,
4425 &ftKernel.ftFileTime,
4426 &ftUser.ftFileTime);
4428 ret = ::GetLastError();
4429 ::Error(
"GetCPUTime",
" Error on GetProcessTimes 0x%lx", (
int)ret);
4449 static time_t jan95 = 0;
4460 jan95 = mktime(&tp);
4461 if ((
int)jan95 == -1) {
4462 ::SysError(
"TWinNTSystem::Now",
"error converting 950001 0:00 to time_t");
4469 return TTime((now.time-(
Long_t)jan95)*1000 + now.millitm);
4495 if (
h->HasReadInterest())
4497 if (
h->HasWriteInterest())
4499 h->ResetReadyMask();
4501 rc = WinNTSelect(&rd, &wr, to);
4530 if (
h->HasReadInterest())
4532 if (
h->HasWriteInterest())
4534 h->ResetReadyMask();
4535 rc = WinNTSelect(&rd, &wr, to);
4557 if ((sp = ::getservbyname(servicename,
kProtocolName)) == 0) {
4558 Error(
"GetServiceByName",
"no service \"%s\" with protocol \"%s\"\n",
4562 return ::ntohs(sp->s_port);
4573 if ((sp = ::getservbyport(::htons(port),
kProtocolName)) == 0) {
4574 return Form(
"%d", port);
4584 struct hostent *host_ptr;
4589 if ((addr = ::inet_addr(hostname)) != INADDR_NONE) {
4591 if ((host_ptr = ::gethostbyaddr((
const char *)&addr,
4592 sizeof(addr), AF_INET))) {
4593 host = host_ptr->h_name;
4597 for (i = 1; host_ptr->h_addr_list[i]; i++) {
4598 memcpy(&addr2, host_ptr->h_addr_list[i], host_ptr->h_length);
4599 a.AddAddress(ntohl(addr2));
4601 for (i = 0; host_ptr->h_aliases[i]; i++)
4602 a.AddAlias(host_ptr->h_aliases[i]);
4605 host =
"UnNamedHost";
4607 }
else if ((host_ptr = ::gethostbyname(hostname))) {
4609 if (host_ptr->h_addrtype != AF_INET) {
4610 Error(
"GetHostByName",
"%s is not an internet host\n", hostname);
4613 memcpy(&addr, host_ptr->h_addr, host_ptr->h_length);
4614 host = host_ptr->h_name;
4615 type = host_ptr->h_addrtype;
4619 for (i = 1; host_ptr->h_addr_list[i]; i++) {
4620 memcpy(&addr2, host_ptr->h_addr_list[i], host_ptr->h_length);
4621 a.AddAddress(ntohl(addr2));
4623 for (i = 0; host_ptr->h_aliases[i]; i++)
4624 a.AddAlias(host_ptr->h_aliases[i]);
4627 if (
gDebug > 0)
Error(
"GetHostByName",
"unknown host %s", hostname);
4640 struct sockaddr_in addr;
4641 int len =
sizeof(addr);
4643 if (::getpeername(sock, (
struct sockaddr *)&addr, &len) == SOCKET_ERROR) {
4648 struct hostent *host_ptr;
4649 const char *hostname;
4653 if ((host_ptr = ::gethostbyaddr((
const char *)&addr.sin_addr,
4654 sizeof(addr.sin_addr), AF_INET))) {
4655 memcpy(&iaddr, host_ptr->h_addr, host_ptr->h_length);
4656 hostname = host_ptr->h_name;
4657 family = host_ptr->h_addrtype;
4659 memcpy(&iaddr, &addr.sin_addr,
sizeof(addr.sin_addr));
4664 return TInetAddress(hostname, ::ntohl(iaddr), family, ::ntohs(addr.sin_port));
4673 struct sockaddr_in addr;
4674 int len =
sizeof(addr);
4676 if (::getsockname(sock, (
struct sockaddr *)&addr, &len) == SOCKET_ERROR) {
4681 struct hostent *host_ptr;
4682 const char *hostname;
4686 if ((host_ptr = ::gethostbyaddr((
const char *)&addr.sin_addr,
4687 sizeof(addr.sin_addr), AF_INET))) {
4688 memcpy(&iaddr, host_ptr->h_addr, host_ptr->h_length);
4689 hostname = host_ptr->h_name;
4690 family = host_ptr->h_addrtype;
4692 memcpy(&iaddr, &addr.sin_addr,
sizeof(addr.sin_addr));
4697 return TInetAddress(hostname, ::ntohl(iaddr), family, ::ntohs(addr.sin_port));
4708 if ((sock = ::socket(AF_INET, SOCK_STREAM, 0)) ==
INVALID_SOCKET) {
4709 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"socket");
4713 struct sockaddr_in inserver;
4714 memset(&inserver, 0,
sizeof(inserver));
4715 inserver.sin_family = AF_INET;
4716 inserver.sin_addr.s_addr = ::htonl(INADDR_LOOPBACK);
4717 inserver.sin_port = port;
4721 if (::bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver)) == SOCKET_ERROR) {
4722 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"bind");
4727 if (::listen(sock, backlog)) {
4728 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"listen");
4740 if (!sockpath || strlen(sockpath) <= 0) {
4741 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"socket path undefined");
4745 struct sockaddr_in myaddr;
4747 int len =
sizeof myaddr;
4752 if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
4753 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"socket");
4757 memset(&myaddr, 0,
sizeof(myaddr));
4758 myaddr.sin_port = 0;
4759 myaddr.sin_family = AF_INET;
4760 myaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
4762 rc = bind(sock, (
struct sockaddr *)&myaddr, len);
4764 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"bind");
4767 rc = getsockname(sock, (
struct sockaddr *)&myaddr, &len);
4769 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"getsockname");
4772 TString socketpath = sockpath;
4774 fp = fopen(socketpath,
"wb");
4776 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"fopen");
4779 fprintf(fp,
"%d", myaddr.sin_port);
4783 if (listen(sock, backlog)) {
4784 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"listen");
4796 if (socket == -1)
return;
4800 ::shutdown(sock, 2);
4802 struct linger linger = {0, 0};
4803 ::setsockopt(sock, SOL_SOCKET, SO_LINGER, (
char *) &linger,
sizeof(linger));
4804 while (
::closesocket(sock) == SOCKET_ERROR && WSAGetLastError() == WSAEINTR) {
4818 if (WinNTRecv(sock, &header,
sizeof(header), 0) > 0) {
4819 int count = ::ntohl(header);
4821 if (count > length) {
4822 Error(
"RecvBuf",
"record header exceeds buffer size");
4824 }
else if (count > 0) {
4825 if (WinNTRecv(sock, buf, count, 0) < 0) {
4826 Error(
"RecvBuf",
"cannot receive buffer");
4841 Int_t header = ::htonl(length);
4843 if (WinNTSend(sock, &header,
sizeof(header), 0) < 0) {
4844 Error(
"SendBuf",
"cannot send header");
4848 if (WinNTSend(sock, buf, length, 0) < 0) {
4849 Error(
"SendBuf",
"cannot send buffer");
4889 if ((
n = WinNTRecv(sock, buf, length, flag)) <= 0) {
4891 Error(
"RecvRaw",
"cannot receive buffer");
4925 if ((
n = WinNTSend(sock, buf, length, flag)) <= 0) {
4927 Error(
"SendRaw",
"cannot send buffer");
4940 if (socket == -1)
return -1;
4945 if (::setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4946 ::SysError(
"SetSockOpt",
"setsockopt(SO_SNDBUF)");
4951 if (::setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4952 ::SysError(
"SetSockOpt",
"setsockopt(SO_RCVBUF)");
4957 if (::setsockopt(sock, SOL_SOCKET, SO_OOBINLINE, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4958 SysError(
"SetSockOpt",
"setsockopt(SO_OOBINLINE)");
4963 if (::setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4964 ::SysError(
"SetSockOpt",
"setsockopt(SO_KEEPALIVE)");
4969 if (::setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4970 ::SysError(
"SetSockOpt",
"setsockopt(SO_REUSEADDR)");
4975 if (::setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4976 ::SysError(
"SetSockOpt",
"setsockopt(TCP_NODELAY)");
4981 if (::ioctlsocket(sock, FIONBIO, &val) == SOCKET_ERROR) {
4988 if (::ioctl(sock, SIOCSPGRP, &val) == -1) {
4989 ::SysError(
"SetSockOpt",
"ioctl(SIOCSPGRP)");
4997 Error(
"SetSockOpt",
"illegal option (%d)", opt);
5009 if (socket == -1)
return -1;
5012 int optlen =
sizeof(*val);
5016 if (::getsockopt(sock, SOL_SOCKET, SO_SNDBUF, (
char*)val, &optlen) == SOCKET_ERROR) {
5017 ::SysError(
"GetSockOpt",
"getsockopt(SO_SNDBUF)");
5022 if (::getsockopt(sock, SOL_SOCKET, SO_RCVBUF, (
char*)val, &optlen) == SOCKET_ERROR) {
5023 ::SysError(
"GetSockOpt",
"getsockopt(SO_RCVBUF)");
5028 if (::getsockopt(sock, SOL_SOCKET, SO_OOBINLINE, (
char*)val, &optlen) == SOCKET_ERROR) {
5029 ::SysError(
"GetSockOpt",
"getsockopt(SO_OOBINLINE)");
5034 if (::getsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (
char*)val, &optlen) == SOCKET_ERROR) {
5035 ::SysError(
"GetSockOpt",
"getsockopt(SO_KEEPALIVE)");
5040 if (::getsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (
char*)val, &optlen) == SOCKET_ERROR) {
5041 ::SysError(
"GetSockOpt",
"getsockopt(SO_REUSEADDR)");
5046 if (::getsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (
char*)val, &optlen) == SOCKET_ERROR) {
5047 ::SysError(
"GetSockOpt",
"getsockopt(TCP_NODELAY)");
5063 if (::ioctlsocket(sock, SIOCGPGRP, (u_long*)val) == SOCKET_ERROR) {
5064 ::SysError(
"GetSockOpt",
"ioctl(SIOCGPGRP)");
5070 if (::ioctlsocket(sock, SIOCATMARK, (u_long*)val) == SOCKET_ERROR) {
5071 ::SysError(
"GetSockOpt",
"ioctl(SIOCATMARK)");
5076 if (::ioctlsocket(sock, FIONREAD, (u_long*)val) == SOCKET_ERROR) {
5082 Error(
"GetSockOpt",
"illegal option (%d)", opt);
5094 int tcpwindowsize,
const char *protocol)
5099 if (!strcmp(servername,
"unix")) {
5103 (servername[1] ==
':' && servername[2] ==
'/')) {
5107 if (!strcmp(protocol,
"udp")){
5114 sport = ::htons(port);
5118 if (!addr.
IsValid())
return -1;
5121 struct sockaddr_in server;
5122 memset(&server, 0,
sizeof(server));
5123 memcpy(&server.sin_addr, &adr,
sizeof(adr));
5125 server.sin_port = sport;
5129 if ((sock = ::socket(AF_INET, SOCK_STREAM, 0)) ==
INVALID_SOCKET) {
5130 ::SysError(
"TWinNTSystem::WinNTConnectTcp",
"socket");
5134 if (tcpwindowsize > 0) {
5139 if (::connect(sock, (
struct sockaddr*) &server,
sizeof(server)) ==
INVALID_SOCKET) {
5152 struct sockaddr_in myaddr;
5155 memset(&myaddr, 0,
sizeof(myaddr));
5156 myaddr.sin_family = AF_INET;
5157 myaddr.sin_port = port;
5158 myaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
5161 if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
5162 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"socket");
5166 while ((connect(sock, (
struct sockaddr *)&myaddr,
sizeof myaddr)) == -1) {
5170 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"connect");
5186 if (!sockpath || strlen(sockpath) <= 0) {
5187 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"socket path undefined");
5190 TString socketpath = sockpath;
5192 fp = fopen(socketpath.
Data(),
"rb");
5194 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"fopen");
5197 fscanf(fp,
"%d", &port);
5200 if (port < 0 || port > 65535) {
5201 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"invalid port");
5219 sport = htons(port);
5222 if (!addr.
IsValid())
return -1;
5225 struct sockaddr_in server;
5226 memset(&server, 0,
sizeof(server));
5227 memcpy(&server.sin_addr, &adr,
sizeof(adr));
5229 server.sin_port = sport;
5233 if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
5234 ::SysError(
"TWinNTSystem::WinNTUdpConnect",
"socket (%s:%d)",
5239 while (connect(sock, (
struct sockaddr*) &server,
sizeof(server)) == -1) {
5243 ::SysError(
"TWinNTSystem::WinNTUdpConnect",
"connect (%s:%d)",
5261 const char *protocol)
5282 const short kSOCKET_MINPORT = 5000, kSOCKET_MAXPORT = 15000;
5283 short tryport = kSOCKET_MINPORT;
5288 sport = ::htons(port);
5291 if (port == 0 && reuse) {
5292 ::Error(
"TWinNTSystem::WinNTTcpService",
"cannot do a port scan while reuse is true");
5299 sport = ::htons(port);
5304 if ((sock = ::socket(AF_INET, SOCK_STREAM, 0)) < 0) {
5305 ::SysError(
"TWinNTSystem::WinNTTcpService",
"socket");
5313 if (tcpwindowsize > 0) {
5318 struct sockaddr_in inserver;
5319 memset(&inserver, 0,
sizeof(inserver));
5320 inserver.sin_family = AF_INET;
5321 inserver.sin_addr.s_addr = ::htonl(INADDR_ANY);
5322 inserver.sin_port = sport;
5326 if (::bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver)) == SOCKET_ERROR) {
5327 ::SysError(
"TWinNTSystem::WinNTTcpService",
"bind");
5333 inserver.sin_port = ::htons(tryport);
5334 bret = ::bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver));
5336 }
while (bret == SOCKET_ERROR && WSAGetLastError() == WSAEADDRINUSE &&
5337 tryport < kSOCKET_MAXPORT);
5338 if (bret == SOCKET_ERROR) {
5339 ::SysError(
"TWinNTSystem::WinNTTcpService",
"bind (port scan)");
5345 if (::listen(sock, backlog) == SOCKET_ERROR) {
5346 ::SysError(
"TWinNTSystem::WinNTTcpService",
"listen");
5363 const short kSOCKET_MINPORT = 5000, kSOCKET_MAXPORT = 15000;
5364 short sport, tryport = kSOCKET_MINPORT;
5370 sport = htons(port);
5374 if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
5375 ::SysError(
"TUnixSystem::UnixUdpService",
"socket");
5379 struct sockaddr_in inserver;
5380 memset(&inserver, 0,
sizeof(inserver));
5381 inserver.sin_family = AF_INET;
5382 inserver.sin_addr.s_addr = htonl(INADDR_ANY);
5383 inserver.sin_port = sport;
5387 if (bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver))) {
5388 ::SysError(
"TWinNTSystem::AnnounceUdpService",
"bind");
5394 inserver.sin_port = htons(tryport);
5395 bret = bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver));
5397 }
while (bret == SOCKET_ERROR && WSAGetLastError() == WSAEADDRINUSE &&
5398 tryport < kSOCKET_MAXPORT);
5400 ::SysError(
"TWinNTSystem::AnnounceUdpService",
"bind (port scan)");
5406 if (listen(sock, backlog)) {
5407 ::SysError(
"TWinNTSystem::AnnounceUdpService",
"listen");
5425 (::WSAGetLastError() == WSAEINTR)) {
5430 if (::WSAGetLastError() == WSAEWOULDBLOCK) {
5444#define SystemBasicInformation 0
5445#define SystemPerformanceInformation 2
5450 ULONG uKeMaximumIncrement;
5452 ULONG uMmNumberOfPhysicalPages;
5453 ULONG uMmLowestPhysicalPage;
5454 ULONG UMmHighestPhysicalPage;
5455 ULONG uAllocationGranularity;
5456 PVOID pLowestUserAddress;
5457 PVOID pMmHighestUserAddress;
5458 ULONG uKeActiveProcessors;
5459 BYTE bKeNumberProcessors;
5462} SYSTEM_BASIC_INFORMATION;
5466 LARGE_INTEGER liIdleTime;
5468} SYSTEM_PERFORMANCE_INFORMATION;
5470typedef struct _PROCESS_MEMORY_COUNTERS {
5472 DWORD PageFaultCount;
5473 SIZE_T PeakWorkingSetSize;
5474 SIZE_T WorkingSetSize;
5475 SIZE_T QuotaPeakPagedPoolUsage;
5476 SIZE_T QuotaPagedPoolUsage;
5477 SIZE_T QuotaPeakNonPagedPoolUsage;
5478 SIZE_T QuotaNonPagedPoolUsage;
5479 SIZE_T PagefileUsage;
5480 SIZE_T PeakPagefileUsage;
5485#define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 + (double)((x).LowPart))
5493 LARGE_INTEGER ulFreq, ulTicks, ulValue, ulStartCounter;
5497 if (QueryPerformanceFrequency(&ulFreq)) {
5499 QueryPerformanceCounter(&ulTicks);
5502 ulValue.QuadPart = ulTicks.QuadPart + ulFreq.QuadPart/10;
5503 ulStartCounter.QuadPart =
__rdtsc();
5507 QueryPerformanceCounter(&ulTicks);
5508 }
while (ulTicks.QuadPart <= ulValue.QuadPart);
5510 return (DWORD)((
__rdtsc() - ulStartCounter.QuadPart)/100000);
5518#define SM_SERVERR2 89
5525 OSVERSIONINFOEX osvi;
5528 BOOL bOsVersionInfoEx;
5529 static char *strReturn = 0;
5533 strReturn =
new char[2048];
5537 ZeroMemory(&si,
sizeof(SYSTEM_INFO));
5538 ZeroMemory(&osvi,
sizeof(OSVERSIONINFOEX));
5543 osvi.dwOSVersionInfoSize =
sizeof(OSVERSIONINFOEX);
5545 if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
5547 osvi.dwOSVersionInfoSize =
sizeof (OSVERSIONINFO);
5548 if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
5553 pGNSI = (
PGNSI) GetProcAddress( GetModuleHandle(
"kernel32.dll"),
5554 "GetNativeSystemInfo");
5557 else GetSystemInfo(&si);
5559 switch (osvi.dwPlatformId)
5562 case VER_PLATFORM_WIN32_NT:
5565 if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 )
5567 if( osvi.wProductType == VER_NT_WORKSTATION )
5568 strlcpy(strReturn,
"Microsoft Windows Vista ",2048);
5569 else strlcpy(strReturn,
"Windows Server \"Longhorn\" " ,2048);
5571 if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
5574 strlcpy(strReturn,
"Microsoft Windows Server 2003 \"R2\" ",2048);
5575 else if( osvi.wProductType == VER_NT_WORKSTATION &&
5576 si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
5578 strlcpy(strReturn,
"Microsoft Windows XP Professional x64 Edition ",2048);
5580 else strlcpy(strReturn,
"Microsoft Windows Server 2003, ",2048);
5582 if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
5583 strlcpy(strReturn,
"Microsoft Windows XP ",2048);
5585 if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
5586 strlcpy(strReturn,
"Microsoft Windows 2000 ",2048);
5588 if ( osvi.dwMajorVersion <= 4 )
5589 strlcpy(strReturn,
"Microsoft Windows NT ",2048);
5592 if( bOsVersionInfoEx )
5595 if ( osvi.wProductType == VER_NT_WORKSTATION &&
5596 si.wProcessorArchitecture!=PROCESSOR_ARCHITECTURE_AMD64)
5598 if( osvi.dwMajorVersion == 4 )
5599 strlcat(strReturn,
"Workstation 4.0 ",2048 );
5600 else if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
5601 strlcat(strReturn,
"Home Edition " ,2048);
5602 else strlcat(strReturn,
"Professional " ,2048);
5605 else if ( osvi.wProductType == VER_NT_SERVER ||
5606 osvi.wProductType == VER_NT_DOMAIN_CONTROLLER )
5608 if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==2)
5610 if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_IA64 )
5612 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
5613 strlcat(strReturn,
"Datacenter Edition for Itanium-based Systems",2048 );
5614 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5615 strlcat(strReturn,
"Enterprise Edition for Itanium-based Systems" ,2048);
5617 else if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 )
5619 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
5620 strlcat(strReturn,
"Datacenter x64 Edition ",2048 );
5621 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5622 strlcat(strReturn,
"Enterprise x64 Edition ",2048 );
5623 else strlcat(strReturn,
"Standard x64 Edition ",2048 );
5627 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
5628 strlcat(strReturn,
"Datacenter Edition ",2048 );
5629 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5630 strlcat(strReturn,
"Enterprise Edition ",2048 );
5631 else if ( osvi.wSuiteMask == VER_SUITE_BLADE )
5632 strlcat(strReturn,
"Web Edition " ,2048);
5633 else strlcat(strReturn,
"Standard Edition ",2048 );
5636 else if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==0)
5638 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
5639 strlcat(strReturn,
"Datacenter Server ",2048 );
5640 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5641 strlcat(strReturn,
"Advanced Server ",2048 );
5642 else strlcat(strReturn,
"Server ",2048 );
5646 if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5647 strlcat(strReturn,
"Server 4.0, Enterprise Edition " ,2048);
5648 else strlcat(strReturn,
"Server 4.0 ",2048 );
5657 DWORD dwBufLen=
BUFSIZE*
sizeof(TCHAR);
5660 lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
5661 "SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
5662 0, KEY_QUERY_VALUE, &hKey );
5663 if( lRet != ERROR_SUCCESS )
5666 lRet = RegQueryValueEx( hKey,
"ProductType", NULL, NULL,
5667 (LPBYTE) szProductType, &dwBufLen);
5668 RegCloseKey( hKey );
5670 if( (lRet != ERROR_SUCCESS) || (dwBufLen >
BUFSIZE*
sizeof(TCHAR)) )
5673 if ( lstrcmpi(
"WINNT", szProductType) == 0 )
5674 strlcat(strReturn,
"Workstation " ,2048);
5675 if ( lstrcmpi(
"LANMANNT", szProductType) == 0 )
5676 strlcat(strReturn,
"Server " ,2048);
5677 if ( lstrcmpi(
"SERVERNT", szProductType) == 0 )
5678 strlcat(strReturn,
"Advanced Server " ,2048);
5679 snprintf(temp,512,
"%d.%d ", osvi.dwMajorVersion, osvi.dwMinorVersion);
5680 strlcat(strReturn, temp,2048);
5685 if( osvi.dwMajorVersion == 4 &&
5686 lstrcmpi( osvi.szCSDVersion,
"Service Pack 6" ) == 0 )
5692 lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
5693 "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009",
5694 0, KEY_QUERY_VALUE, &hKey );
5695 if( lRet == ERROR_SUCCESS ) {
5696 snprintf(temp, 512,
"Service Pack 6a (Build %d)", osvi.dwBuildNumber & 0xFFFF );
5697 strlcat(strReturn, temp,2048 );
5701 snprintf(temp,512,
"%s (Build %d)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF);
5702 strlcat(strReturn, temp,2048 );
5705 RegCloseKey( hKey );
5709 snprintf(temp, 512,
"%s (Build %d)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF);
5710 strlcat(strReturn, temp,2048 );
5716 case VER_PLATFORM_WIN32_WINDOWS:
5718 if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
5720 strlcpy(strReturn,
"Microsoft Windows 95 ",2048);
5721 if (osvi.szCSDVersion[1]==
'C' || osvi.szCSDVersion[1]==
'B')
5722 strlcat(strReturn,
"OSR2 " ,2048);
5725 if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
5727 strlcpy(strReturn,
"Microsoft Windows 98 ",2048);
5728 if ( osvi.szCSDVersion[1]==
'A' || osvi.szCSDVersion[1]==
'B')
5729 strlcat(strReturn,
"SE ",2048 );
5732 if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
5734 strlcpy(strReturn,
"Microsoft Windows Millennium Edition",2048);
5738 case VER_PLATFORM_WIN32s:
5739 strlcpy(strReturn,
"Microsoft Win32s",2048);
5750 unsigned nHighestFeatureEx;
5754 nHighestFeatureEx = (unsigned)nBuff[0];
5756 if (nHighestFeatureEx >= 0x80000006) {
5758 return (((
unsigned)nBuff[2])>>16);
5768 SYSTEM_PERFORMANCE_INFORMATION SysPerfInfo;
5769 SYSTEM_INFO sysInfo;
5770 MEMORYSTATUSEX statex;
5771 OSVERSIONINFO OsVersionInfo;
5773 char szKeyValueString[80];
5774 DWORD szKeyValueDword;
5779 NtQuerySystemInformation = (
PROCNTQSI)GetProcAddress(
5780 GetModuleHandle(
"ntdll"),
"NtQuerySystemInformation");
5782 if (!NtQuerySystemInformation) {
5784 "Error on GetProcAddress(NtQuerySystemInformation)");
5789 &SysPerfInfo,
sizeof(SysPerfInfo),
5791 OsVersionInfo.dwOSVersionInfoSize =
sizeof(OSVERSIONINFO);
5792 GetVersionEx(&OsVersionInfo);
5793 GetSystemInfo(&sysInfo);
5794 statex.dwLength =
sizeof(statex);
5795 if (!GlobalMemoryStatusEx(&statex)) {
5796 ::Error(
"GetWinNTSysInfo",
"Error on GlobalMemoryStatusEx()");
5799 sysinfo->
fCpus = sysInfo.dwNumberOfProcessors;
5808 status = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"HARDWARE\\DESCRIPTION\\System",
5809 0, KEY_QUERY_VALUE, &hKey);
5810 if (status == ERROR_SUCCESS) {
5811 dwBufLen =
sizeof(szKeyValueString);
5812 RegQueryValueEx(hKey,
"Identifier", NULL, NULL,(LPBYTE)szKeyValueString,
5814 sysinfo->
fModel = szKeyValueString;
5817 status = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
5818 "Hardware\\Description\\System\\CentralProcessor\\0",
5819 0, KEY_QUERY_VALUE, &hKey);
5820 if (status == ERROR_SUCCESS) {
5821 dwBufLen =
sizeof(szKeyValueString);
5822 status = RegQueryValueEx(hKey,
"ProcessorNameString", NULL, NULL,
5823 (LPBYTE)szKeyValueString, &dwBufLen);
5824 if (status == ERROR_SUCCESS)
5825 sysinfo->
fCpuType = szKeyValueString;
5826 dwBufLen =
sizeof(DWORD);
5827 status = RegQueryValueEx(hKey,
"~MHz",NULL,NULL,(LPBYTE)&szKeyValueDword,
5829 if ((status == ERROR_SUCCESS) && ((sysinfo->
fCpuSpeed <= 0) ||
5830 (sysinfo->
fCpuSpeed < (szKeyValueDword >> 1))))
5844 SYSTEM_INFO sysInfo;
5845 Float_t idle_ratio, kernel_ratio, user_ratio, total_ratio;
5846 FILETIME ft_sys_idle, ft_sys_kernel, ft_sys_user, ft_fun_time;
5847 SYSTEMTIME st_fun_time;
5849 ULARGE_INTEGER ul_sys_idle, ul_sys_kernel, ul_sys_user;
5850 static ULARGE_INTEGER ul_sys_idleold = {0, 0};
5851 static ULARGE_INTEGER ul_sys_kernelold = {0, 0};
5852 static ULARGE_INTEGER ul_sys_userold = {0, 0};
5853 ULARGE_INTEGER ul_sys_idle_diff, ul_sys_kernel_diff, ul_sys_user_diff;
5855 ULARGE_INTEGER ul_fun_time;
5856 ULARGE_INTEGER ul_fun_timeold = {0, 0};
5857 ULARGE_INTEGER ul_fun_time_diff;
5859 typedef BOOL (__stdcall *GetSystemTimesProc)( LPFILETIME lpIdleTime,
5860 LPFILETIME lpKernelTime, LPFILETIME lpUserTime );
5861 static GetSystemTimesProc pGetSystemTimes = 0;
5863 HMODULE hModImagehlp = LoadLibrary(
"Kernel32.dll" );
5864 if (!hModImagehlp) {
5865 ::Error(
"GetWinNTCpuInfo",
"Error on LoadLibrary(Kernel32.dll)");
5869 pGetSystemTimes = (GetSystemTimesProc) GetProcAddress( hModImagehlp,
5871 if (!pGetSystemTimes) {
5872 ::Error(
"GetWinNTCpuInfo",
"Error on GetProcAddress(GetSystemTimes)");
5875 GetSystemInfo(&sysInfo);
5878 pGetSystemTimes(&ft_sys_idle,&ft_sys_kernel,&ft_sys_user);
5879 GetSystemTime(&st_fun_time);
5880 SystemTimeToFileTime(&st_fun_time,&ft_fun_time);
5882 memcpy(&ul_sys_idle, &ft_sys_idle,
sizeof(FILETIME));
5883 memcpy(&ul_sys_kernel, &ft_sys_kernel,
sizeof(FILETIME));
5884 memcpy(&ul_sys_user, &ft_sys_user,
sizeof(FILETIME));
5885 memcpy(&ul_fun_time, &ft_fun_time,
sizeof(FILETIME));
5887 ul_sys_idle_diff.QuadPart = ul_sys_idle.QuadPart -
5888 ul_sys_idleold.QuadPart;
5889 ul_sys_kernel_diff.QuadPart = ul_sys_kernel.QuadPart -
5890 ul_sys_kernelold.QuadPart;
5891 ul_sys_user_diff.QuadPart = ul_sys_user.QuadPart -
5892 ul_sys_userold.QuadPart;
5894 ul_fun_time_diff.QuadPart = ul_fun_time.QuadPart -
5895 ul_fun_timeold.QuadPart;
5897 ul_sys_idleold.QuadPart = ul_sys_idle.QuadPart;
5898 ul_sys_kernelold.QuadPart = ul_sys_kernel.QuadPart;
5899 ul_sys_userold.QuadPart = ul_sys_user.QuadPart;
5901 if (ul_fun_timeold.QuadPart == 0) {
5903 ul_fun_timeold.QuadPart = ul_fun_time.QuadPart;
5906 ul_fun_timeold.QuadPart = ul_fun_time.QuadPart;
5914 idle_ratio /= (
Float_t)sysInfo.dwNumberOfProcessors;
5915 user_ratio /= (
Float_t)sysInfo.dwNumberOfProcessors;
5916 kernel_ratio /= (
Float_t)sysInfo.dwNumberOfProcessors;
5917 total_ratio = 100.0 - idle_ratio;
5922 cpuinfo->
fUser = user_ratio;
5923 cpuinfo->
fSys = kernel_ratio;
5924 cpuinfo->
fTotal = total_ratio;
5925 cpuinfo->
fIdle = idle_ratio;
5934 MEMORYSTATUSEX statex;
5935 statex.dwLength =
sizeof(statex);
5936 if (!GlobalMemoryStatusEx(&statex)) {
5937 ::Error(
"GetWinNTMemInfo",
"Error on GlobalMemoryStatusEx()");
5940 used = (
Long64_t)(statex.ullTotalPhys - statex.ullAvailPhys);
5948 swap_total = (
Long64_t)(statex.ullTotalPageFile - statex.ullTotalPhys);
5949 swap_avail = (
Long64_t)(statex.ullAvailPageFile - statex.ullAvailPhys);
5950 swap_used = swap_total - swap_avail;
5963 FILETIME starttime, exittime, kerneltime, usertime;
5964 timeval ru_stime, ru_utime;
5967 typedef BOOL (__stdcall *GetProcessMemoryInfoProc)( HANDLE Process,
5969 static GetProcessMemoryInfoProc pGetProcessMemoryInfo = 0;
5971 HMODULE hModImagehlp = LoadLibrary(
"Psapi.dll" );
5972 if (!hModImagehlp) {
5973 ::Error(
"GetWinNTProcInfo",
"Error on LoadLibrary(Psapi.dll)");
5977 pGetProcessMemoryInfo = (GetProcessMemoryInfoProc) GetProcAddress(
5978 hModImagehlp,
"GetProcessMemoryInfo" );
5979 if (!pGetProcessMemoryInfo) {
5981 "Error on GetProcAddress(GetProcessMemoryInfo)");
5985 if ( pGetProcessMemoryInfo( GetCurrentProcess(), &pmc,
sizeof(pmc)) ) {
5989 if ( GetProcessTimes(GetCurrentProcess(), &starttime, &exittime,
5990 &kerneltime, &usertime)) {
5993 memcpy(&li, &kerneltime,
sizeof(FILETIME));
5995 ru_stime.tv_sec = li.QuadPart / 1000000L;
5996 ru_stime.tv_usec = li.QuadPart % 1000000L;
5998 memcpy(&li, &usertime,
sizeof(FILETIME));
6000 ru_utime.tv_sec = li.QuadPart / 1000000L;
6001 ru_utime.tv_usec = li.QuadPart % 1000000L;
6004 ((
Float_t)(ru_utime.tv_usec) / 1000000.);
6006 ((
Float_t)(ru_stime.tv_usec) / 1000000.);
6017 if (!info)
return -1;
6029 if (!info)
return -1;
6040 if (!info)
return -1;
6051 if (!info)
return -1;
The file contains utilities which are foundational and could be used across the core component of ROO...
R__EXTERN TApplication * gApplication
include TDocParser_001 C image html pict1_TDocParser_001 png width
void Error(const char *location, const char *msgfmt,...)
void SysError(const char *location, const char *msgfmt,...)
void Break(const char *location, const char *msgfmt,...)
R__EXTERN Int_t gErrorIgnoreLevel
void Throw(int code)
If an exception context has been set (using the TRY and RETRY macros) jump back to where it was set.
static unsigned int total
#define INVALID_HANDLE_VALUE
Binding & operator=(OUT(*fun)(void))
char * Form(const char *fmt,...)
void Printf(const char *fmt,...)
char * StrDup(const char *str)
Duplicate the string str.
R__EXTERN const char * gProgName
typedef void((*Func_t)())
R__EXTERN const char * gRootDir
R__EXTERN TSystem * gSystem
R__EXTERN TFileHandler * gXDisplay
R__EXTERN const char * gProgPath
static void sighandler(int sig)
Call the signal handler associated with the signal.
static void SigHandler(ESignals sig)
Unix signal handler.
const char * kProtocolName
static const char * DynamicPath(const char *newpath=0, Bool_t reset=kFALSE)
Get shared library search path. Static utility function.
void(* SigHandler_t)(ESignals)
R__EXTERN TWin32SplashThread * gSplash
static void __cpuid(int *cpuid_data, int)
static const char * shellMeta
BOOL PathIsRoot(LPCTSTR pPath)
check if a path is a root
static void GetWinNTProcInfo(ProcInfo_t *procinfo)
Get process info for this process on Windows NT.
static int GetL2CacheSize()
Use assembly to retrieve the L2 cache information ...
struct _PROCESS_MEMORY_COUNTERS * PPROCESS_MEMORY_COUNTERS
static void GetWinNTCpuInfo(CpuInfo_t *cpuinfo, Int_t sampleTime)
Get CPU stat for Window.
void Gl_setwidth(int width)
void(WINAPI * PGNSI)(LPSYSTEM_INFO)
#define SystemPerformanceInformation
BOOL PathIsUNC(LPCTSTR pszPath)
Returns TRUE if the given string is a UNC path.
static const char shellEscape
const TCHAR c_szColonSlash[]
static void GetWinNTMemInfo(MemInfo_t *meminfo)
Get VM stat for Windows NT.
static DWORD GetCPUSpeed()
Calculate the CPU clock speed using the 'rdtsc' instruction.
struct _PROCESS_MEMORY_COUNTERS PROCESS_MEMORY_COUNTERS
#define isin(address, start, length)
static const char * shellStuff
__inline BOOL DBL_BSLASH(LPCTSTR psz)
Inline function to check for a double-backslash at the beginning of a string.
static void GetWinNTSysInfo(SysInfo_t *sysinfo)
Get system info for Windows NT.
static const char * GetWindowsVersion()
void * _ReturnAddress(void)
LONG(WINAPI * PROCNTQSI)(UINT, PVOID, ULONG, PULONG)
virtual Bool_t HandleTermInput()
Using a TBrowser one can browse all ROOT objects.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
virtual Bool_t Notify()
Notify when event occurred on descriptor associated with this handler.
virtual Bool_t WriteNotify()
Notify when something can be written to the descriptor associated with this handler.
virtual Bool_t ReadNotify()
Notify when something can be read from the descriptor associated with this handler.
This class represents an Internet Protocol (IP) address.
UInt_t GetAddress() const
virtual void Add(TObject *obj)
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Iterator of ordered collection.
TObject * Next()
Return next object in collection.
static const TString & GetBinDir()
Get the binary directory in the installation. Static utility function.
static Bool_t Initialized()
Return kTRUE if the TROOT object has been initialized.
static const TString & GetLibDir()
Get the library directory in the installation. Static utility function.
Regular expression class.
virtual Bool_t Notify()
Notify when signal occurs.
ESignals GetSignal() const
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
Ssiz_t First(char c) const
Find first occurrence of a character c.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString & Prepend(const char *cs)
TString & Swap(TString &other)
TString & Remove(Ssiz_t pos)
TString & Append(const char *cs)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
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.
TSeqCollection * fFileHandler
virtual void AddFileHandler(TFileHandler *fh)
Add a file handler to the list of system file handlers.
TString & GetLastErrorString()
Return the thread local storage for the custom last error message.
void Beep(Int_t freq=-1, Int_t duration=-1, Bool_t setDefault=kFALSE)
Beep for duration milliseconds with a tone of frequency freq.
static void ResetErrno()
Static function resetting system error number.
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
static Int_t GetErrno()
Static function returning system error number.
virtual void FreeDirectory(void *dirp)
Free a directory.
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
virtual Long_t NextTimeOut(Bool_t mode)
Time when next timer of mode (synchronous=kTRUE or asynchronous=kFALSE) will time-out (in ms).
virtual int SetSockOpt(int sock, int kind, int val)
Set socket option.
virtual const char * Getenv(const char *env)
Get environment variable.
TFdSet * fWritemask
Files that should be checked for read events.
TFdSet * fSignals
Files with writes waiting.
virtual Bool_t IsPathLocal(const char *path)
Returns TRUE if the url in 'path' points to the local file system.
virtual const char * FindFile(const char *search, TString &file, EAccessMode mode=kFileExists)
Find location of file in a search path.
virtual int MakeDirectory(const char *name)
Make a directory.
virtual const char * ExpandFileName(const char *fname)
Expand a pathname getting rid of special shell characters like ~.
virtual TFileHandler * RemoveFileHandler(TFileHandler *fh)
Remove a file handler from the list of file handlers.
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
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.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
virtual void ExitLoop()
Exit from event loop.
virtual Bool_t Init()
Initialize the OS interface.
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
TFdSet * fWriteready
Files with reads waiting.
virtual void AddSignalHandler(TSignalHandler *sh)
Add a signal handler to list of system signal handlers.
TSeqCollection * fSignalHandler
virtual void Exit(int code, Bool_t mode=kTRUE)
Exit the application.
TFdSet * fReadready
Files that should be checked for write events.
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...
Int_t fNfd
Signals that were trapped.
static const char * StripOffProto(const char *path, const char *proto)
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
virtual TInetAddress GetHostByName(const char *server)
Get Internet Protocol (IP) address of host.
virtual const char * GetLibraries(const char *regexp="", const char *option="", Bool_t isRegexp=kTRUE)
Return a space separated list of loaded shared libraries.
virtual TSignalHandler * RemoveSignalHandler(TSignalHandler *sh)
Remove a signal handler from list of signal handlers.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
virtual TTimer * RemoveTimer(TTimer *t)
Remove timer from list of system timers.
virtual int Unlink(const char *name)
Unlink, i.e.
virtual void StackTrace()
Print a stack trace.
char * DynamicPathName(const char *lib, Bool_t quiet=kFALSE)
Find a dynamic library called lib using the system search paths.
Basic time type with millisecond precision.
Handles synchronous and a-synchronous timer events.
Bool_t CheckTimer(const TTime &now)
Check if timer timed out.
This class represents a WWW compatible URL.
const char * GetProtocol() const
void Setenv(const char *name, const char *value)
Set environment variable.
Bool_t HandleConsoleEvent()
const char * HomeDirectory(const char *userName=0)
Return the user's home directory.
int GetServiceByName(const char *service)
Get port # of internet service.
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...
virtual ~TWinNTSystem()
dtor
UserGroup_t * GetGroupInfo(Int_t gid)
Returns all group info in the UserGroup_t structure.
FILE * TempFileName(TString &base, const char *dir=0)
Create a secure temporary file by appending a unique 6 letter string to base.
Int_t GetFPEMask()
Return the bitmap of conditions that trigger a floating point exception.
std::string GetHomeDirectory(const char *userName=0) const
Return the user's home directory.
int SetNonBlock(int fd)
Make descriptor fd non-blocking.
void Exit(int code, Bool_t mode=kTRUE)
Exit the application.
void AddSignalHandler(TSignalHandler *sh)
Add a signal handler to list of system signal handlers.
int Link(const char *from, const char *to)
Create a link from file1 to file2.
TSignalHandler * RemoveSignalHandler(TSignalHandler *sh)
Remove a signal handler from list of signal handlers.
void SetGUIThreadMsgHandler(ThreadMsgFunc_t func)
Set the (static part of) the event handler func for GUI messages.
const char DriveName(const char *pathname="/")
Return the drive letter in pathname.
void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
int Exec(const char *shellcmd)
Execute a command.
TTime Now()
Get current time in milliseconds since 0:00 Jan 1 1995.
const char * GetDirEntry(void *dirp)
Returns the next directory entry.
Bool_t Init()
Initialize WinNT system interface.
const char * GetLinkedLibraries()
Get list of shared libraries loaded at the start of the executable.
FILE * OpenPipe(const char *shellcmd, const char *mode)
Open a pipe.
struct passwd * fPasswords
const char * HostName()
Return the system's host name.
const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
static void ThreadStub(void *Parameter)
static int WinNTUdpConnect(const char *hostname, int port)
Creates a UDP socket connection Is called via the TSocket constructor.
const char * Getenv(const char *name)
Get environment variable.
Int_t GetCpuInfo(CpuInfo_t *info, Int_t sampleTime=1000) const
Returns cpu load average and load info into the CpuInfo_t structure.
int SetSockOpt(int sock, int opt, int val)
Set socket option.
Bool_t IsPathLocal(const char *path)
Returns TRUE if the url in 'path' points to the local file system.
int ClosePipe(FILE *pipe)
Close the pipe.
const char * GetError()
Return system error string.
UserGroup_t * GetUserInfo(Int_t uid)
Returns all user info in the UserGroup_t structure.
void AddDynamicPath(const char *dir)
Add a new directory to the dynamic path.
int AnnounceTcpService(int port, Bool_t reuse, int backlog, int tcpwindowsize=-1)
Announce TCP/IP service.
void SetDynamicPath(const char *path)
Set the dynamic path to a new value.
Bool_t ChangeDirectory(const char *path)
Change directory.
void ExitLoop()
Exit from event loop.
int MakeDirectory(const char *name)
Make a WinNT file system directory.
int GetPid()
Get process id.
void TimerThread()
Special Thread to check asynchronous timers.
int GetPathInfo(const char *path, FileStat_t &buf)
Get info about a file.
void Abort(int code=0)
Abort the application.
TFileHandler * RemoveFileHandler(TFileHandler *fh)
Remove a file handler from the list of file handlers.
int ConnectService(const char *servername, int port, int tcpwindowsize, const char *protocol="tcp")
Connect to service servicename on server servername.
std::string GetWorkingDirectory() const
Return the working directory for the default drive.
TInetAddress GetSockName(int sock)
Get Internet Protocol (IP) address of host and port #.
const char * BaseName(const char *name)
Base name of a file name.
Int_t GetMemInfo(MemInfo_t *info) const
Returns ram and swap memory usage info into the MemInfo_t structure.
int Unlink(const char *name)
Unlink, i.e.
int GetSockOpt(int sock, int opt, int *val)
Get socket option.
void DispatchSignals(ESignals sig)
Handle and dispatch signals.
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.
const char * WorkingDirectory()
Return the working directory for the default drive.
void IgnoreSignal(ESignals sig, Bool_t ignore=kTRUE)
If ignore is true ignore the specified signal, else restore previous behaviour.
Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
TList * GetVolumes(Option_t *opt="") const
Get list of volumes (drives) mounted on the system.
Int_t GetEffectiveGid()
Returns the effective group id.
Bool_t DispatchTimers(Bool_t mode)
Handle and dispatch timers.
void ResetSignal(ESignals sig, Bool_t reset=kTRUE)
If reset is true reset the signal handler for the specified signal to the default handler,...
int AnnounceUdpService(int port, int backlog)
Announce UDP service.
void FreeDirectory(void *dirp)
Close a WinNT file system directory.
void ResetSignals()
Reset signals handlers to previous behaviour.
Bool_t ProcessEvents()
process pending events, i.e. DispatchOneEvent(kTRUE)
int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Int_t RedirectOutput(const char *name, const char *mode="a", RedirectHandle_t *h=0)
Redirect standard output (stdout, stderr) to the specified file.
Bool_t CheckSignals(Bool_t sync)
Check if some signals were raised and call their Notify() member.
int OpenConnection(const char *server, int port, int tcpwindowsize=-1, const char *protocol="tcp")
Open a connection to a service on a server.
void DoBeep(Int_t freq=-1, Int_t duration=-1) const
Beep.
void SetProgname(const char *name)
Set the application name (from command line, argv[0]) and copy it in gProgName.
Int_t GetUid(const char *user=0)
Returns the user's id. If user = 0, returns current user's id.
Bool_t IsAbsoluteFileName(const char *dir)
Return true if dir is an absolute pathname.
int Chmod(const char *file, UInt_t mode)
Set the file permission bits.
int SendRaw(int sock, const void *buffer, int length, int flag)
Send exactly length bytes from buffer.
void AddFileHandler(TFileHandler *fh)
Add a file handler to the list of system file handlers.
int mkdir(const char *name, Bool_t recursive=kFALSE)
Make a file system directory.
const char * GetLibraries(const char *regexp="", const char *option="", Bool_t isRegexp=kTRUE)
Return a space separated list of loaded shared libraries.
int AcceptConnection(int sock)
Accept a connection.
Bool_t CheckDescriptors()
Check if there is activity on some file descriptors and call their Notify() member.
static int WinNTUnixConnect(int port)
Connect to a Unix domain socket.
const char * FindFile(const char *search, TString &file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Bool_t ExpandPathName(TString &patbuf)
Expand a pathname getting rid of special shell characaters like ~.$, etc.
void CloseConnection(int sock, Bool_t force=kFALSE)
Close socket.
void NotifyApplicationCreated()
Hook to tell TSystem that the TApplication object has been created.
Bool_t(* ThreadMsgFunc_t)(MSG *)
WIN32_FIND_DATA fFindFileData
int Utime(const char *file, Long_t modtime, Long_t actime)
Set a files modification and access times.
int RecvBuf(int sock, void *buffer, int length)
Receive a buffer headed by a length indicator.
Int_t GetGid(const char *group=0)
Returns the group's id. If group = 0, returns current user's group.
int RecvRaw(int sock, void *buffer, int length, int flag)
Receive exactly length bytes into buffer.
Bool_t CollectMembers(const char *lpszGroupName, int &groupIdx, int &memberIdx)
const char * DirName(const char *pathname)
Return the directory name in pathname.
TInetAddress GetPeerName(int sock)
Get Internet Protocol (IP) address of remote host and port #.
Bool_t CountMembers(const char *lpszGroupName)
void FillWithHomeDirectory(const char *userName, char *mydir) const
Fill buffer with user's home directory.
TTimer * RemoveTimer(TTimer *ti)
Remove timer from list of system timers.
Bool_t InitUsersGroups()
Collect local users and groups accounts information.
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 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.
const char * GetDynamicPath()
Return the dynamic path (used to find shared libraries).
char * GetServiceByPort(int port)
Get name of internet service.
int SendBuf(int sock, const void *buffer, int length)
Send a buffer headed by a length indicator.
int CopyFile(const char *from, const char *to, Bool_t overwrite=kFALSE)
Copy a file.
const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
Int_t Select(TList *active, Long_t timeout)
Select on file descriptors. The timeout to is in millisec.
TInetAddress GetHostByName(const char *server)
Get Internet Protocol (IP) address of host.
Int_t GetProcInfo(ProcInfo_t *info) const
Returns cpu and memory used by this process into the ProcInfo_t structure.
int AnnounceUnixService(int port, int backlog)
Announce unix domain service.
HANDLE GetProcess()
Get current process handle.
void DispatchOneEvent(Bool_t pendingOnly=kFALSE)
Dispatch a single event in TApplication::Run() loop.
Int_t SetFPEMask(Int_t mask=kDefaultMask)
Set which conditions trigger a floating point exception.
Int_t GetEffectiveUid()
Returns the effective user id.
void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
const char * UnixPathName(const char *unixpathname)
Convert a pathname to a unix pathname.
int Symlink(const char *from, const char *to)
Create a symlink from file1 to file2.
void AddTimer(TTimer *ti)
Add timer to list of system timers.
int Rename(const char *from, const char *to)
Rename a file. Returns 0 when successful, -1 in case of failure.
int Umask(Int_t mask)
Set the process file creation mode mask.
void StackTrace()
Print a stack trace, if gEnv entry "Root.Stacktrace" is unset or 1, and if the image helper functions...
const std::string & GetFallbackRootSys()
void Copy(void *source, void *dest)
RooCmdArg Index(RooCategory &icat)
static constexpr double s
static constexpr double cm
static constexpr double L