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 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);
1106 static char lpFilename[MAX_PATH];
1107 if (::GetModuleFileName(
1110 sizeof(lpFilename))) {
1118 typedef UINT (WINAPI* LPTIMEBEGINPERIOD)( UINT uPeriod );
1119 HINSTANCE hInstWinMM = LoadLibrary(
"winmm.dll" );
1121 LPTIMEBEGINPERIOD pTimeBeginPeriod = (LPTIMEBEGINPERIOD)GetProcAddress( hInstWinMM,
"timeBeginPeriod" );
1122 if( NULL != pTimeBeginPeriod )
1123 pTimeBeginPeriod(1);
1124 FreeLibrary(hInstWinMM);
1126 gTimerThreadHandle = ::CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)
ThreadStub,
1129 gGlobalEvent = ::CreateEvent(NULL,
TRUE,
FALSE, NULL);
1132 char *buf =
new char[MAX_MODULE_NAME32 + 1];
1133 HMODULE hModCore = ::GetModuleHandle(
"libCore.dll");
1135 ::GetModuleFileName(hModCore, buf, MAX_MODULE_NAME32 + 1);
1136 char *pLibName = strstr(buf,
"libCore.dll");
1143 SetConsoleWindowName();
1167 const char *symbol=
name;
1170 while ( (*symbol ==
' ' || *symbol ==
'\t') && *symbol) symbol++;
1173 if (isalpha(symbol[idx]) && symbol[idx+1] ==
':') idx = 2;
1174 if ( (symbol[idx] ==
'/' || symbol[idx] ==
'\\') && symbol[idx+1] ==
'\0') {
1179 Error(
"BaseName",
"name = 0");
1183 char *bslash = (
char *)strrchr(&symbol[idx],
'\\');
1184 char *rslash = (
char *)strrchr(&symbol[idx],
'/');
1185 if (cp = (std::max)(rslash, bslash)) {
1190 return &symbol[idx];
1192 Error(
"BaseName",
"name = 0");
1209 if (
name && namelen > 0) {
1211 fullname =
new char[namelen+5];
1212 strlcpy(fullname,
name,namelen+5);
1213 if ( !strrchr(fullname,
'.') )
1214 strlcat(fullname,
".exe",namelen+5);
1217 dot = strrchr(progname,
'.');
1218 idot = dot ? (
ULong_t)(dot - progname) : strlen(progname);
1223 which =
StrDup(fullname);
1234 dirname.
Form(
"%c:%s", driveletter,
d);
1236 dirname.
Form(
"%s",
d);
1249 progname[idot] =
'\0';
1251 if (which)
delete [] which;
1255 if (::NeedSplash()) {
1268 if (err < 0 || err >= sys_nerr) {
1270 error_msg.
Form(
"errno out of range %d", err);
1273 return sys_errlist[err];
1286 DWORD il =
sizeof(hn);
1287 ::GetComputerName(hn, &il);
1303 if (freq < 37) freq = 440;
1304 if (duration < 0) duration = 100;
1313 gGUIThreadMsgFunc = func;
1336 int fd =
h->GetFd();
1339 if (
h->HasReadInterest()) {
1342 if (
h->HasWriteInterest()) {
1374 set_console =
kTRUE;
1387 ::SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleSigHandler,
TRUE);
1400 int sig =
h->GetSignal();
1413 ::SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleSigHandler,
FALSE);
1457 HANDLE snapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD,::GetCurrentProcessId());
1462 if (!InitImagehlpFunctions()) {
1463 std::cerr <<
"No stack trace: cannot find (functions in) dbghelp.dll!" << std::endl;
1468 SYSTEM_INFO sysInfo;
1469 ::GetSystemInfo(&sysInfo);
1470 DWORD machineType = IMAGE_FILE_MACHINE_I386;
1471 switch (sysInfo.wProcessorArchitecture) {
1472 case PROCESSOR_ARCHITECTURE_AMD64:
1473 machineType = IMAGE_FILE_MACHINE_AMD64;
1475 case PROCESSOR_ARCHITECTURE_IA64:
1476 machineType = IMAGE_FILE_MACHINE_IA64;
1480 DWORD currentThreadID = ::GetCurrentThreadId();
1481 DWORD currentProcessID = ::GetCurrentProcessId();
1485 THREADENTRY32 threadentry;
1486 threadentry.dwSize =
sizeof(THREADENTRY32);
1487 if (!::Thread32First(snapshot, &threadentry))
return;
1489 std::cerr << std::endl <<
"==========================================" << std::endl;
1490 std::cerr <<
"=============== STACKTRACE ===============" << std::endl;
1491 std::cerr <<
"==========================================" << std::endl << std::endl;
1494 if (threadentry.th32OwnerProcessID != currentProcessID)
1496 HANDLE thread = ::OpenThread(THREAD_GET_CONTEXT|THREAD_SUSPEND_RESUME|THREAD_QUERY_INFORMATION,
1497 FALSE, threadentry.th32ThreadID);
1499 memset(&context, 0,
sizeof(CONTEXT));
1501 if (threadentry.th32ThreadID != currentThreadID) {
1502 ::SuspendThread(thread);
1503 context.ContextFlags = CONTEXT_ALL;
1504 ::GetThreadContext(thread, &context);
1505 ::ResumeThread(thread);
1507 if (fgXcptContext) {
1508 context = *fgXcptContext;
1510 typedef void (WINAPI *RTLCCTXT)(PCONTEXT);
1511 RTLCCTXT p2RtlCCtxt = (RTLCCTXT) ::GetProcAddress(
1512 GetModuleHandle(
"kernel32.dll"),
"RtlCaptureContext");
1514 context.ContextFlags = CONTEXT_ALL;
1515 p2RtlCCtxt(&context);
1521 ::ZeroMemory(&frame,
sizeof(frame));
1523 frame.AddrPC.Mode = AddrModeFlat;
1524 frame.AddrFrame.Mode = AddrModeFlat;
1525 frame.AddrStack.Mode = AddrModeFlat;
1527 frame.AddrPC.Offset = context.Eip;
1528 frame.AddrFrame.Offset = context.Ebp;
1529 frame.AddrStack.Offset = context.Esp;
1530#elif defined(_M_X64)
1531 frame.AddrPC.Offset = context.Rip;
1532 frame.AddrFrame.Offset = context.Rsp;
1533 frame.AddrStack.Offset = context.Rsp;
1534#elif defined(_M_IA64)
1535 frame.AddrPC.Offset = context.StIIP;
1536 frame.AddrFrame.Offset = context.IntSp;
1537 frame.AddrStack.Offset = context.IntSp;
1538 frame.AddrBStore.Offset= context.RsBSP;
1540 std::cerr <<
"Stack traces not supported on your architecture yet." << std::endl;
1545 while (_StackWalk64(machineType, (HANDLE)::GetCurrentProcess(), thread, (LPSTACKFRAME64)&frame,
1546 (LPVOID)&context, (PREAD_PROCESS_MEMORY_ROUTINE)NULL, (PFUNCTION_TABLE_ACCESS_ROUTINE)_SymFunctionTableAccess64,
1547 (PGET_MODULE_BASE_ROUTINE)_SymGetModuleBase64, NULL)) {
1549 std::cerr << std::endl <<
"================ Thread " << iThread++ <<
" ================" << std::endl;
1550 if (!bFirst || threadentry.th32ThreadID != currentThreadID) {
1551 const std::string moduleName = GetModuleName(frame.AddrPC.Offset);
1552 const std::string functionName = GetFunctionName(frame.AddrPC.Offset);
1553 std::cerr <<
" " << moduleName << functionName << std::endl;
1557 ::CloseHandle(thread);
1558 }
while (::Thread32Next(snapshot, &threadentry));
1560 std::cerr << std::endl <<
"==========================================" << std::endl;
1561 std::cerr <<
"============= END STACKTRACE =============" << std::endl;
1562 std::cerr <<
"==========================================" << std::endl << std::endl;
1563 ::CloseHandle(snapshot);
1564 _SymCleanup(GetCurrentProcess());
1573 UInt_t oldmask = _statusfp( );
1575 if (oldmask & _EM_INVALID ) mask |=
kInvalid;
1576 if (oldmask & _EM_ZERODIVIDE) mask |=
kDivByZero;
1577 if (oldmask & _EM_OVERFLOW ) mask |=
kOverflow;
1578 if (oldmask & _EM_UNDERFLOW) mask |=
kUnderflow;
1579 if (oldmask & _EM_INEXACT ) mask |=
kInexact;
1593 if (mask &
kInvalid ) newm |= _EM_INVALID;
1594 if (mask &
kDivByZero) newm |= _EM_ZERODIVIDE;
1595 if (mask &
kOverflow ) newm |= _EM_OVERFLOW;
1596 if (mask &
kUnderflow) newm |= _EM_UNDERFLOW;
1597 if (mask &
kInexact ) newm |= _EM_INEXACT;
1601 ::_controlfp(
cm , _MCW_EM);
1620 if (pendingOnly && gGlobalEvent) ::SetEvent(gGlobalEvent);
1622 Bool_t pollOnce = pendingOnly;
1626 if (
gROOT->GetApplication()) {
1642 ::WaitForSingleObject(gGlobalEvent, 1);
1643 ::ResetEvent(gGlobalEvent);
1669 if (pendingOnly && !pollOnce)
1708 if (!pendingOnly && gGlobalEvent) {
1709 ::WaitForSingleObject(gGlobalEvent, 1);
1710 ::ResetEvent(gGlobalEvent);
1724 for (i = 0; i <
fReadmask->GetCount(); i++) {
1729 rc = WinNTSelect(&t, 0, 0);
1730 if (rc < 0 && rc != -2) {
1731 ::SysError(
"DispatchOneEvent",
"select: read error on %d\n", fd);
1737 for (i = 0; i <
fWritemask->GetCount(); i++) {
1743 rc = WinNTSelect(0, &t, 0);
1744 if (rc < 0 && rc != -2) {
1745 ::SysError(
"DispatchOneEvent",
"select: write error on %d\n", fd);
1797 if (sync == sh->
IsSync()) {
1799 if ((
fSignals->IsSet(sig) && sigdone == -1) || sigdone == sig) {
1800 if (sigdone == -1) {
1810 if (sigdone != -1)
return kTRUE;
1831 if ((
fReadready->IsSet(fd) && fddone == -1) ||
1832 (fddone == fd && read)) {
1842 (fddone == fd && !read)) {
1852 if (fddone != -1)
return kTRUE;
1869 if (dirname.
Length() == 0) {
1886 if (res)
return res;
1906 const char *
proto = (strstr(
name,
"file:///")) ?
"file://" :
"file:";
1909 if (!
name)
return 0;
1913 if (!
name)
return 0;
1945 HANDLE searchFile = (HANDLE)dirp;
1979 return (psz[0] == TEXT(
'\\') && psz[1] == TEXT(
'\\'));
1999#pragma data_seg(".text", "CODE")
2014 if (!IsDBCSLeadByte(*pPath)) {
2019 if ((*pPath == TEXT(
'\\')) && (*(pPath + 1) == 0))
2025 int cBackslashes = 0;
2026 for (p = pPath + 2; *p; p = CharNext(p)) {
2027 if (*p == TEXT(
'\\') && (++cBackslashes > 1))
2047 const char *
proto = (strstr(fdir,
"file:///")) ?
"file://" :
"file:";
2050 char *dir =
new char[MAX_PATH];
2051 if (IsShortcut(sdir)) {
2052 if (!ResolveShortCut(sdir, dir, MAX_PATH))
2053 strlcpy(dir, sdir,MAX_PATH);
2056 strlcpy(dir, sdir,MAX_PATH);
2058 int nche = strlen(dir)+3;
2059 char *entry =
new char[nche];
2060 struct _stati64 finfo;
2063 strlcpy(entry, dir,nche);
2064 if ((entry[strlen(dir)-1] ==
'/') || (entry[strlen(dir)-1] ==
'\\' )) {
2065 entry[strlen(dir)-1] =
'\0';
2068 strlcat(entry,
"\\",nche);
2070 if (_stati64(entry, &finfo) < 0) {
2077 strlcpy(entry, dir,nche);
2078 if ((entry[strlen(dir)-1] ==
'/') || (entry[strlen(dir)-1] ==
'\\' )) {
2080 entry[strlen(dir)-1] =
'\0';
2082 if (_stati64(entry, &finfo) < 0) {
2089 if (finfo.st_mode & S_IFDIR) {
2090 strlcpy(entry, dir,nche);
2091 if (!(entry[strlen(dir)-1] ==
'/' || entry[strlen(dir)-1] ==
'\\' )) {
2092 strlcat(entry,
"\\",nche);
2094 if (entry[strlen(dir)-1] ==
' ')
2095 entry[strlen(dir)-1] =
'\0';
2096 strlcat(entry,
"*",nche);
2165 char drive = driveletter ? toupper( driveletter ) -
'A' + 1 : 0;
2171 if (!(wdpath = ::_getdcwd( (
int)drive, wdpath,
kMAXPATHLEN))) {
2173 Warning(
"WorkingDirectory",
"getcwd() failed");
2197 return std::string(mydir);
2206 if (!(
h = ::getenv(
"home")))
h = ::getenv(
"HOME");
2213 h = ::getenv(
"HOMESHARE");
2214 if (!
h)
h = ::getenv(
"HOMEDRIVE");
2217 h = ::getenv(
"HOMEPATH");
2222 h = ::getenv(
"USERPROFILE");
2227 if (mydir[1] ==
':')
2228 mydir[0] = toupper(mydir[0]);
2244 if (!dir) dir =
"c:\\";
2260 char tmpName[MAX_PATH];
2264 FILE *fp = fopen(tmpName,
"w+");
2266 if (!fp)
::SysError(
"TempFileName",
"error opening %s", tmpName);
2284 if (!opt || !opt[0]) {
2289 UINT nOldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS);
2293 curdrive = _getdrive();
2294 if (strstr(opt,
"cur")) {
2296 sDrive.
Form(
"%c:", (curdrive +
'A' - 1));
2297 sType.
Form(
"Unknown Drive (%s)", sDrive.
Data());
2298 ::GetVolumeInformation(
Form(
"%s\\", sDrive.
Data()), NULL, 0, NULL, NULL,
2299 NULL, (LPSTR)szFs, 32);
2300 type = ::GetDriveType(sDrive.
Data());
2303 case DRIVE_NO_ROOT_DIR:
2305 case DRIVE_REMOVABLE:
2306 sType.
Form(
"Removable Disk (%s)", sDrive.
Data());
2309 sType.
Form(
"Local Disk (%s)", sDrive.
Data());
2312 sType.
Form(
"Network Drive (%s) (%s)", szFs, sDrive.
Data());
2315 sType.
Form(
"CD/DVD Drive (%s)", sDrive.
Data());
2318 sType.
Form(
"RAM Disk (%s)", sDrive.
Data());
2323 else if (strstr(opt,
"all")) {
2326 if (::GetLogicalDriveStrings(511, szTemp)) {
2327 TCHAR szDrive[3] = TEXT(
" :");
2333 sDrive.
Form(
"%s", szDrive);
2335 if ((sDrive ==
"A:") || (sDrive ==
"B:")) {
2339 sType.
Form(
"Unknown Drive (%s)", sDrive.
Data());
2340 ::GetVolumeInformation(
Form(
"%s\\", sDrive.
Data()), NULL, 0, NULL,
2341 NULL, NULL, (LPSTR)szFs, 32);
2342 type = ::GetDriveType(sDrive.
Data());
2345 case DRIVE_NO_ROOT_DIR:
2347 case DRIVE_REMOVABLE:
2348 sType.
Form(
"Removable Disk (%s)", sDrive.
Data());
2351 sType.
Form(
"Local Disk (%s)", sDrive.
Data());
2354 sType.
Form(
"Network Drive (%s) (%s)", szFs, sDrive.
Data());
2357 sType.
Form(
"CD/DVD Drive (%s)", sDrive.
Data());
2360 sType.
Form(
"RAM Disk (%s)", sDrive.
Data());
2370 ::SetErrorMode(nOldErrorMode);
2389 if (strchr(pathname,
'/') || strchr(pathname,
'\\')) {
2390 const char *rslash = strrchr(pathname,
'/');
2391 const char *bslash = strrchr(pathname,
'\\');
2392 const char *
r = (std::max)(rslash, bslash);
2393 const char *ptr = pathname;
2403 int len =
r - pathname;
2435 if (!pathname)
return 0;
2436 if (!pathname[0])
return 0;
2442 while(*lpchar ==
' ') lpchar++;
2444 if (isalpha((
int)*lpchar) && *(lpchar+1) ==
':') {
2448 if ( (*lpchar ==
'\\' || *lpchar ==
'/' ) &&
2449 (*(lpchar+1) ==
'\\' || *(lpchar+1) ==
'/') )
return 0;
2462 if (strchr(dir,
':')) idx = 2;
2463 return (dir[idx] ==
'/' || dir[idx] ==
'\\');
2496 const int kBufSize = 1024;
2497 TTHREAD_TLS_ARRAY(
char, kBufSize, temp);
2499 strlcpy(temp,
name, kBufSize);
2500 char *currentChar = temp;
2503 while (*currentChar !=
'\0') {
2504 if (*currentChar ==
'\\') *currentChar =
'/';
2522 UINT nOldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS);
2526 const char *
proto = (strstr(path,
"file:///")) ?
"file://" :
"file:";
2529 ::SetErrorMode(nOldErrorMode);
2534 ::SetErrorMode(nOldErrorMode);
2557 if (dir && dir[0]) {
2559 char last = dir[strlen(dir) - 1];
2560 if (last !=
'/' && last !=
'\\') {
2564 name.ReplaceAll(
"/",
"\\");
2581 if (!ret)
return -1;
2590 int ret = ::rename(
f, t);
2607 struct _stati64 sbuf;
2610 const char *
proto = (strstr(path,
"file:///")) ?
"file://" :
"file:";
2612 int l = strlen(newpath);
2614 if (newpath[--
l] !=
'\\' || newpath[--
l] !=
'/') {
2620 if (newpath && ::_stati64(newpath, &sbuf) >= 0) {
2622 buf.
fDev = sbuf.st_dev;
2623 buf.
fIno = sbuf.st_ino;
2624 buf.
fMode = sbuf.st_mode;
2625 buf.
fUid = sbuf.st_uid;
2626 buf.
fGid = sbuf.st_gid;
2627 buf.
fSize = sbuf.st_size;
2628 buf.
fMtime = sbuf.st_mtime;
2629 buf.
fIsLink = IsShortcut(newpath);
2631 char *lpath =
new char[MAX_PATH];
2632 if (IsShortcut(newpath)) {
2633 struct _stati64 sbuf2;
2634 if (ResolveShortCut(newpath, lpath, MAX_PATH)) {
2635 if (::_stati64(lpath, &sbuf2) >= 0) {
2636 buf.
fMode = sbuf2.st_mode;
2662 LPCTSTR lpRootPathName = path;
2665 LPTSTR lpVolumeNameBuffer = 0;
2666 DWORD nVolumeNameSize = 0;
2668 DWORD volumeSerialNumber;
2669 DWORD maximumComponentLength;
2672 DWORD fileSystemFlags;
2675 char fileSystemNameBuffer[512];
2676 DWORD nFileSystemNameSize =
sizeof(fileSystemNameBuffer);
2679 UINT nOldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS);
2680 if (!::GetVolumeInformation(lpRootPathName,
2681 lpVolumeNameBuffer, nVolumeNameSize,
2682 &volumeSerialNumber,
2683 &maximumComponentLength,
2685 fileSystemNameBuffer, nFileSystemNameSize)) {
2687 ::SetErrorMode(nOldErrorMode);
2691 const char *fsNames[] = {
"FAT",
"NTFS" };
2693 for (i = 0; i < 2; i++) {
2694 if (!strncmp(fileSystemNameBuffer, fsNames[i], nFileSystemNameSize))
2699 DWORD sectorsPerCluster;
2700 DWORD bytesPerSector;
2701 DWORD numberOfFreeClusters;
2702 DWORD totalNumberOfClusters;
2704 if (!::GetDiskFreeSpace(lpRootPathName,
2707 &numberOfFreeClusters,
2708 &totalNumberOfClusters)) {
2710 ::SetErrorMode(nOldErrorMode);
2714 ::SetErrorMode(nOldErrorMode);
2716 *bsize = sectorsPerCluster * bytesPerSector;
2717 *blocks = totalNumberOfClusters;
2718 *bfree = numberOfFreeClusters;
2728 struct _stati64 finfo;
2733 char linkname[1024];
2734 LPTSTR lpszFilePart;
2735 TCHAR szPath[MAX_PATH];
2738 typedef BOOL (__stdcall *CREATEHARDLINKPROC)( LPCTSTR, LPCTSTR, LPSECURITY_ATTRIBUTES );
2739 static CREATEHARDLINKPROC _CreateHardLink = 0;
2741 HMODULE hModImagehlp = LoadLibrary(
"Kernel32.dll" );
2746 _CreateHardLink = (CREATEHARDLINKPROC) GetProcAddress( hModImagehlp,
"CreateHardLinkW" );
2748 _CreateHardLink = (CREATEHARDLINKPROC) GetProcAddress( hModImagehlp,
"CreateHardLinkA" );
2750 if (!_CreateHardLink)
2753 dwRet = GetFullPathName(from,
sizeof(szPath) /
sizeof(TCHAR),
2754 szPath, &lpszFilePart);
2756 if (_stati64(szPath, &finfo) < 0)
2759 if (finfo.st_mode & S_IFDIR)
2763 _splitpath(linkname,winDrive,winDir,winName,winExt);
2764 if ((!winDrive[0] ) &&
2766 _splitpath(szPath,winDrive,winDir,winName,winExt);
2767 snprintf(linkname,1024,
"%s\\%s\\%s", winDrive, winDir, to);
2769 else if (!winDrive[0]) {
2770 _splitpath(szPath,winDrive,winDir,winName,winExt);
2771 snprintf(linkname,1024,
"%s\\%s", winDrive, to);
2774 if (!_CreateHardLink(linkname, szPath, NULL))
2787 IShellLink* pShellLink;
2788 IPersistFile* pPersistFile;
2789 WCHAR wszLinkfile[MAX_PATH];
2790 int iWideCharsWritten;
2792 LPTSTR lpszFilePart;
2793 TCHAR szPath[MAX_PATH];
2795 hRes = E_INVALIDARG;
2796 if ((from == NULL) || (!from[0]) || (to == NULL) ||
2802 typedef HRESULT (__stdcall *COINITIALIZEPROC)( LPVOID );
2803 static COINITIALIZEPROC _CoInitialize = 0;
2804 typedef void (__stdcall *COUNINITIALIZEPROC)(
void );
2805 static COUNINITIALIZEPROC _CoUninitialize = 0;
2806 typedef HRESULT (__stdcall *COCREATEINSTANCEPROC)( REFCLSID, LPUNKNOWN, DWORD, REFIID, LPVOID );
2807 static COCREATEINSTANCEPROC _CoCreateInstance = 0;
2809 HMODULE hModImagehlp = LoadLibrary(
"ole32.dll" );
2813 _CoInitialize = (COINITIALIZEPROC) GetProcAddress( hModImagehlp,
"CoInitialize" );
2816 _CoUninitialize = (COUNINITIALIZEPROC) GetProcAddress( hModImagehlp,
"CoUninitialize" );
2817 if (!_CoUninitialize)
2819 _CoCreateInstance = (COCREATEINSTANCEPROC) GetProcAddress( hModImagehlp,
"CoCreateInstance" );
2820 if (!_CoCreateInstance)
2827 _CoInitialize(NULL);
2830 dwRet = GetFullPathName(from,
sizeof(szPath) /
sizeof(TCHAR),
2831 szPath, &lpszFilePart);
2832 hRes = _CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
2833 IID_IShellLink, (LPVOID *)&pShellLink);
2834 if (SUCCEEDED(hRes)) {
2836 hRes = pShellLink->SetPath(szPath);
2838 hRes = pShellLink->QueryInterface(IID_IPersistFile, (
void **)&pPersistFile);
2839 if (SUCCEEDED(hRes)){
2840 iWideCharsWritten = MultiByteToWideChar(CP_ACP, 0, linkname.
Data(), -1,
2841 wszLinkfile, MAX_PATH);
2842 hRes = pPersistFile->Save(wszLinkfile,
TRUE);
2843 pPersistFile->Release();
2845 pShellLink->Release();
2863 struct _stati64 finfo;
2865 if (_stati64(
name, &finfo) < 0) {
2869 if (finfo.st_mode & S_IFDIR) {
2870 return ::_rmdir(
name);
2872 return ::_unlink(
name);
2881 if (::ioctlsocket(fd, FIONBIO, (u_long *)1) == SOCKET_ERROR) {
2900 const char *patbuf = (
const char *)patbuf0;
2908 const char driveletter =
DriveName(patbuf);
2917 if (!
proto.EqualTo(
"file"))
2925 while (*patbuf ==
' ') {
2930 while (*patbuf ==
':') {
2935 while (*patbuf ==
';') {
2941 for (
q = (
char*)patbuf; *
q;
q++) {
2945 if ( (((
q-2)>patbuf) && ( (*(
q-2)!=
';') || !isalpha(*(
q-1)) )) &&
2952 for (p = patbuf; *p; p++) {
2969 char replacement[4];
2972 for (
int k = 0; k<3; k++) replacement[k] = 0x1;
2974 replacement[3] = 0x0;
2978 while ( (pos = patbuf0.
Index(TildaNum,pos)) !=
kNPOS ) {
2979 patbuf0.
Replace(pos, 1, replacement);
2985 Int_t lbuf = ::ExpandEnvironmentStrings(
2991 cmd =
new char[lbuf+1];
2992 ::ExpandEnvironmentStrings(
3011 char newpath[MAX_PATH];
3012 if (IsShortcut(path)) {
3013 if (!ResolveShortCut(path, newpath, MAX_PATH))
3014 strlcpy(newpath, path, MAX_PATH);
3017 strlcpy(newpath, path, MAX_PATH);
3032 return ::_chmod(
file, mode);
3040 return ::umask(mask);
3050 Error(
"Utime",
"need write permission for %s to change utime",
file);
3053 if (!actime) actime = modtime;
3056 t.actime = (time_t)actime;
3057 t.modtime = (time_t)modtime;
3058 return ::utime(
file, &t);
3077 return infile.
Data();
3085 Int_t lastDelim = -1;
3086 for(
int i=0; i < exsearch.
Length(); ++i) {
3087 switch( exsearch[i] ) {
3090 if (i-lastDelim!=2) exsearch[i] =
';';
3093 case ';': lastDelim = i;
break;
3100 char *lpFilePart = 0;
3102 ::access(
name, mode) == 0 && stat(
name, &finfo) == 0 &&
3103 finfo.st_mode & S_IFREG) {
3108 return infile.
Data();
3122 if ((
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) && (::GetVersion() < 0x80000000)) {
3125 HINSTANCE netapi = ::LoadLibrary(
"netapi32.DLL");
3126 if (!netapi)
return kFALSE;
3128 p2NetApiBufferFree = (pfn1)::GetProcAddress(netapi,
"NetApiBufferFree");
3129 p2NetUserGetInfo = (pfn2)::GetProcAddress(netapi,
"NetUserGetInfo");
3130 p2NetLocalGroupGetMembers = (pfn3)::GetProcAddress(netapi,
"NetLocalGroupGetMembers");
3131 p2NetLocalGroupEnum = (pfn4)::GetProcAddress(netapi,
"NetLocalGroupEnum");
3133 if (!p2NetApiBufferFree || !p2NetUserGetInfo ||
3134 !p2NetLocalGroupGetMembers || !p2NetLocalGroupEnum)
return kFALSE;
3145 ::FreeLibrary(netapi);
3155 NET_API_STATUS NetStatus = NERR_Success;
3157 DWORD
Index = 0, ResumeHandle = 0, Total = 0;
3158 LOCALGROUP_MEMBERS_INFO_1 *MemberInfo;
3159 WCHAR wszGroupName[256];
3161 DWORD dwLastError = 0;
3163 iRetOp = MultiByteToWideChar (
3165 (DWORD)MB_PRECOMPOSED,
3166 (LPCSTR)lpszGroupName,
3168 (LPWSTR)wszGroupName,
3169 (
int)
sizeof(wszGroupName) );
3172 dwLastError = GetLastError();
3174 p2NetApiBufferFree(Data);
3180 NetStatus = p2NetLocalGroupGetMembers (NULL, wszGroupName, 1,
3181 &Data, 8192, &
Index, &Total, &ResumeHandle );
3183 if (NetStatus != NERR_Success || Data == NULL) {
3184 dwLastError = GetLastError();
3186 if (dwLastError == ERROR_ENVVAR_NOT_FOUND) {
3192 NetStatus = p2NetLocalGroupGetMembers ( NULL, wszGroupName, 0,
3193 &Data, 8192, &
Index, &Total, &ResumeHandle );
3197 p2NetApiBufferFree(Data);
3202 MemberInfo = (LOCALGROUP_MEMBERS_INFO_1 *)Data;
3205 p2NetApiBufferFree(Data);
3214 NET_API_STATUS NetStatus = NERR_Success;
3216 DWORD
Index = 0, ResumeHandle = 0, Total = 0, i;
3217 LOCALGROUP_INFO_0 *GroupInfo;
3218 char szAnsiName[256];
3219 DWORD dwLastError = 0;
3222 NetStatus = p2NetLocalGroupEnum(NULL, 0, &Data, 8192, &
Index,
3223 &Total, &ResumeHandle );
3225 if (NetStatus != NERR_Success || Data == NULL) {
3226 dwLastError = GetLastError();
3228 p2NetApiBufferFree(Data);
3233 GroupInfo = (LOCALGROUP_INFO_0 *)Data;
3234 for (i=0; i < Total; i++) {
3236 iRetOp = WideCharToMultiByte (
3239 (LPCWSTR)(GroupInfo->lgrpi0_name),
3242 (
int)(
sizeof(szAnsiName)),
3254 p2NetApiBufferFree(Data);
3266 int &groupIdx,
int &memberIdx)
3268 BOOL bRetOp =
FALSE;
3270 DWORD dwSidSize, dwDomainNameSize;
3273 SID_NAME_USE sidType;
3274 PUCHAR puchar_SubAuthCount = NULL;
3275 SID_IDENTIFIER_AUTHORITY sid_identifier_authority;
3276 PSID_IDENTIFIER_AUTHORITY psid_identifier_authority = NULL;
3277 unsigned char j = 0;
3278 DWORD dwLastError = 0;
3280 pSid = (PSID)bySidBuffer;
3281 dwSidSize =
sizeof(bySidBuffer);
3282 dwDomainNameSize =
sizeof(szDomainName);
3284 bRetOp = LookupAccountName (
3286 (LPCTSTR)lpszAccountName,
3288 (LPDWORD)&dwSidSize,
3289 (LPTSTR)szDomainName,
3290 (LPDWORD)&dwDomainNameSize,
3291 (PSID_NAME_USE)&sidType );
3293 if (bRetOp ==
FALSE) {
3294 dwLastError = GetLastError();
3298 bRetOp = IsValidSid((PSID)pSid);
3300 if (bRetOp ==
FALSE) {
3301 dwLastError = GetLastError();
3306 psid_identifier_authority = GetSidIdentifierAuthority ((PSID)pSid);
3309 memcpy (&sid_identifier_authority, psid_identifier_authority,
3310 sizeof(SID_IDENTIFIER_AUTHORITY));
3313 puchar_SubAuthCount = (PUCHAR)GetSidSubAuthorityCount((PSID)pSid);
3315 j = (
unsigned char)(*puchar_SubAuthCount);
3317 DWORD dwSubAuth = 0;
3318 PDWORD pdwSubAuth = NULL;
3320 pdwSubAuth = (PDWORD)GetSidSubAuthority (
3323 dwSubAuth = *pdwSubAuth;
3342 NET_API_STATUS NetStatus = NERR_Success;
3344 DWORD
Index = 0, ResumeHandle = 0, Total = 0, i;
3345 LOCALGROUP_MEMBERS_INFO_1 *MemberInfo;
3346 char szAnsiMemberName[256];
3347 char szFullMemberName[256];
3348 char szMemberHomeDir[256];
3349 WCHAR wszGroupName[256];
3352 DWORD length =
sizeof (act_name);
3353 DWORD dwLastError = 0;
3354 LPUSER_INFO_11 pUI11Buf = NULL;
3355 NET_API_STATUS nStatus;
3357 iRetOp = MultiByteToWideChar (
3359 (DWORD)MB_PRECOMPOSED,
3360 (LPCSTR)lpszGroupName,
3362 (LPWSTR)wszGroupName,
3363 (
int)
sizeof(wszGroupName) );
3366 dwLastError = GetLastError();
3368 p2NetApiBufferFree(Data);
3372 GetUserName (act_name, &length);
3376 NetStatus = p2NetLocalGroupGetMembers (NULL, wszGroupName, 1,
3377 &Data, 8192, &
Index, &Total, &ResumeHandle );
3379 if (NetStatus != NERR_Success || Data == NULL) {
3380 dwLastError = GetLastError();
3382 if (dwLastError == ERROR_ENVVAR_NOT_FOUND) {
3388 NetStatus = p2NetLocalGroupGetMembers ( NULL, wszGroupName, 0,
3389 &Data, 8192, &
Index, &Total, &ResumeHandle );
3393 p2NetApiBufferFree(Data);
3397 MemberInfo = (LOCALGROUP_MEMBERS_INFO_1 *)Data;
3398 for (i=0; i < Total; i++) {
3399 iRetOp = WideCharToMultiByte (
3402 (LPCWSTR)(MemberInfo->lgrmi1_name),
3404 (LPSTR)szAnsiMemberName,
3405 (
int)(
sizeof(szAnsiMemberName)),
3410 dwLastError = GetLastError();
3421 TCHAR szUserName[255]=TEXT(
"");
3422 MultiByteToWideChar(CP_ACP, 0, szAnsiMemberName, -1, (LPWSTR)szUserName, 255);
3426 nStatus = p2NetUserGetInfo(NULL, (LPCWSTR)szUserName, 11, (LPBYTE *)&pUI11Buf);
3430 if (nStatus == NERR_Success) {
3431 if (pUI11Buf != NULL) {
3432 wsprintf(szFullMemberName,
"%S",pUI11Buf->usri11_full_name);
3434 wsprintf(szMemberHomeDir,
"%S",pUI11Buf->usri11_home_dir);
3445 if (pUI11Buf != NULL) {
3446 p2NetApiBufferFree(pUI11Buf);
3451 if (getenv(
"SHELL") == NULL)
3452 putenv ((GetVersion () & 0x80000000) ?
"SHELL=command" :
"SHELL=cmd");
3465 p2NetApiBufferFree(Data);
3475 NET_API_STATUS NetStatus = NERR_Success;
3477 DWORD
Index = 0, ResumeHandle = 0, Total = 0, i;
3478 LOCALGROUP_INFO_0 *GroupInfo;
3479 char szAnsiName[256];
3480 DWORD dwLastError = 0;
3481 int iRetOp = 0, iGroupIdx = 0, iMemberIdx = 0;
3483 NetStatus = p2NetLocalGroupEnum(NULL, 0, &Data, 8192, &
Index,
3484 &Total, &ResumeHandle );
3486 if (NetStatus != NERR_Success || Data == NULL) {
3487 dwLastError = GetLastError();
3489 p2NetApiBufferFree(Data);
3493 GroupInfo = (LOCALGROUP_INFO_0 *)Data;
3494 for (i=0; i < Total; i++) {
3496 iRetOp = WideCharToMultiByte (
3499 (LPCWSTR)(GroupInfo->lgrpi0_name),
3502 (
int)(
sizeof(szAnsiName)),
3520 p2NetApiBufferFree(Data);
3534 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3537 DWORD length =
sizeof (
name);
3538 if (::GetUserName (
name, &length)) {
3539 if (stricmp (
"administrator",
name) == 0)
3549 if (!user || !user[0])
3575 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3578 DWORD length =
sizeof (
name);
3579 if (::GetUserName (
name, &length)) {
3580 if (stricmp (
"administrator",
name) == 0)
3602 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3605 DWORD length =
sizeof (
name);
3606 if (::GetUserName (
name, &length)) {
3607 if (stricmp (
"administrator",
name) == 0)
3620 struct group *grp = 0;
3643 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3646 DWORD length =
sizeof (
name);
3647 if (::GetUserName (
name, &length)) {
3648 if (stricmp (
"administrator",
name) == 0)
3671 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3673 DWORD length =
sizeof (
name);
3675 if (::GetUserName (
name, &length)) {
3677 if (stricmp (
"administrator",
name) == 0) {
3679 ug->
fGroup =
"administrators";
3688 ug->
fUser =
"unknown";
3701 for (
int i = 0; i <
fNbUsers; i++) {
3745 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3747 DWORD length =
sizeof (
name);
3749 if (::GetUserName (
name, &length)) {
3750 if (stricmp (
"administrator",
name) == 0) {
3751 gr->fGroup =
"administrators";
3755 gr->fGroup =
"users";
3760 gr->fGroup =
"unknown";
3766 struct group *grp = 0;
3811 const char *env = ::getenv(
name);
3813 if (::_stricmp(
name,
"home") == 0 ) {
3815 }
else if (::_stricmp(
name,
"rootsys") == 0 ) {
3829 return ::system(shellcmd);
3837 return ::_popen(command, mode);
3845 return ::_pclose(pipe);
3872 gROOT->CloseFiles();
3873 if (
gROOT->GetListOfBrowsers()) {
3876 if (
gROOT->IsBatch())
3877 gROOT->GetListOfBrowsers()->Delete();
3883 if (((TBrowser*)0x%lx)->GetBrowserImp() &&\
3884 ((TBrowser*)0x%lx)->GetBrowserImp()->GetMainFrame()) \
3885 ((TBrowser*)0x%lx)->GetBrowserImp()->GetMainFrame()->CloseWindow();\
3889 gROOT->EndOfProcessCleanups();
3929 static int fd1=0, fd2=0;
3930 static fpos_t pos1=0, pos2=0;
3940 const char *
m = (mode[0] ==
'a' || mode[0] ==
'w') ? mode :
"a";
3953 fgetpos(stdout, &pos1);
3954 fd1 = _dup(fileno(stdout));
3956 if ((fout = freopen(
file,
m, stdout)) == 0) {
3957 SysError(
"RedirectOutput",
"could not freopen stdout");
3959 _dup2(fd1, fileno(stdout));
3963 fsetpos(stdout, &pos1);
3968 fgetpos(stderr, &pos2);
3969 fd2 = _dup(fileno(stderr));
3970 if ((ferr = freopen(
file,
m, stderr)) == 0) {
3971 SysError(
"RedirectOutput",
"could not freopen stderr");
3973 _dup2(fd1, fileno(stdout));
3977 fsetpos(stdout, &pos1);
3979 _dup2(fd2, fileno(stderr));
3983 fsetpos(stderr, &pos2);
3988 fseek(fout, 0, SEEK_END);
3989 fseek(ferr, 0, SEEK_END);
3996 if (_dup2(fd1, fileno(stdout))) {
3997 SysError(
"RedirectOutput",
"could not restore stdout");
4003 fsetpos(stdout, &pos1);
4010 if (_dup2(fd2, fileno(stderr))) {
4011 SysError(
"RedirectOutput",
"could not restore stderr");
4017 fsetpos(stderr, &pos2);
4072 if (len > 4 && (!stricmp(sLib.
Data()+len-4,
".dll"))) {
4085 Error(
"DynamicPathName",
4086 "%s does not exist in %s,\nor has wrong file extension (.dll)",
4103#pragma warning(push)
4104#pragma warning(disable:4200)
4121 if (!linkedLibs.
IsNull())
4134 HANDLE hFile, hMapping;
4137 if((hFile = CreateFile(exe,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,0))==
INVALID_HANDLE_VALUE) {
4141 if(!(hMapping = CreateFileMapping(hFile,0,PAGE_READONLY|SEC_COMMIT,0,0,0))) {
4146 if(!(basepointer = MapViewOfFile(hMapping,FILE_MAP_READ,0,0,0))) {
4147 CloseHandle(hMapping);
4154 IMAGE_DOS_HEADER *dos_head = (IMAGE_DOS_HEADER *)basepointer;
4157 IMAGE_FILE_HEADER _head;
4158 IMAGE_OPTIONAL_HEADER opt_head;
4159 IMAGE_SECTION_HEADER section_header[];
4161 struct header *pheader;
4162 const IMAGE_SECTION_HEADER * section_header;
4164 if(dos_head->e_magic!=
'ZM') {
4169 pheader = (
struct header *)((
char*)dos_head + dos_head->e_lfanew);
4171 if(IsBadReadPtr(pheader,
sizeof(
struct header))) {
4175 if(pheader->signature!=IMAGE_NT_SIGNATURE) {
4176 switch((
unsigned short)pheader->signature) {
4177 case IMAGE_DOS_SIGNATURE:
4180 case IMAGE_OS2_SIGNATURE:
4183 case IMAGE_OS2_SIGNATURE_LE:
4191#define isin(address,start,length) ((address)>=(start) && (address)<(start)+(length))
4194 for(sect=0,section_header=pheader->section_header;
4195 sect<pheader->_head.NumberOfSections;sect++,section_header++) {
4197 const void *
const section_data =
4198 (
char*)basepointer + section_header->PointerToRawData;
4199 for(directory=0;directory<IMAGE_NUMBEROF_DIRECTORY_ENTRIES;directory++) {
4200 if(
isin(pheader->opt_head.DataDirectory[directory].VirtualAddress,
4201 section_header->VirtualAddress,
4202 section_header->SizeOfRawData)) {
4203 const IMAGE_IMPORT_DESCRIPTOR *stuff_start =
4204 (IMAGE_IMPORT_DESCRIPTOR *)((
char*)section_data +
4205 (pheader->opt_head.DataDirectory[directory].VirtualAddress -
4206 section_header->VirtualAddress));
4209 const unsigned stuff_length =
4210 pheader->opt_head.DataDirectory[directory].Size;
4211 if(directory == IMAGE_DIRECTORY_ENTRY_IMPORT) {
4212 while(!IsBadReadPtr(stuff_start,
sizeof(*stuff_start)) &&
4213 stuff_start->Name) {
4214 TString dll = (
char*)section_data +
4215 ((DWORD)(stuff_start->Name)) -
4216 section_header->VirtualAddress;
4220 char *winPath = getenv(
"windir");
4221 _splitpath(winPath,winDrive,winDir,winName,winExt);
4222 if(!strstr(dllPath, winDir)) {
4223 if (!linkedLibs.
IsNull())
4225 linkedLibs += dllPath;
4237 UnmapViewOfFile(basepointer);
4238 CloseHandle(hMapping);
4271 TRegexp separator(
"[^ \\t\\s]+");
4276 Ssiz_t start, index, end;
4277 start = index = end = 0;
4279 while ((start < libs.
Length()) && (index !=
kNPOS)) {
4280 index = libs.
Index(separator, &end, start);
4284 s = libs(index, end);
4285 if (
s.Index(user_dll) !=
kNPOS) {
4286 s.ReplaceAll(
".dll",
".lib");
4288 s.Replace( 0,
s.Last(
'/')+1, 0, 0);
4289 s.Replace( 0,
s.Last(
'\\')+1, 0, 0);
4291 }
else if (
s.Index(user_lib) !=
kNPOS) {
4293 s.Replace( 0,
s.Last(
'/')+1, 0, 0);
4294 s.Replace( 0,
s.Last(
'\\')+1, 0, 0);
4361 if (mode && t->
IsSync()) {
4365 }
else if (!mode && t->
IsAsync()) {
4383 FILETIME ftFileTime;
4387 ::GetSystemTimeAsFileTime(&ftRealTime.ftFileTime);
4396 OSVERSIONINFO OsVersionInfo;
4405 OsVersionInfo.dwOSVersionInfoSize =
sizeof(OSVERSIONINFO);
4406 GetVersionEx(&OsVersionInfo);
4407 if (OsVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) {
4413 FILETIME ftFileTime;
4418 FILETIME ftFileTime;
4422 HANDLE hThread = GetCurrentThread();
4423 ret = GetThreadTimes (hThread, &ftCreate, &ftExit,
4424 &ftKernel.ftFileTime,
4425 &ftUser.ftFileTime);
4427 ret = ::GetLastError();
4428 ::Error(
"GetCPUTime",
" Error on GetProcessTimes 0x%lx", (
int)ret);
4448 static time_t jan95 = 0;
4459 jan95 = mktime(&tp);
4460 if ((
int)jan95 == -1) {
4461 ::SysError(
"TWinNTSystem::Now",
"error converting 950001 0:00 to time_t");
4468 return TTime((now.time-(
Long_t)jan95)*1000 + now.millitm);
4494 if (
h->HasReadInterest())
4496 if (
h->HasWriteInterest())
4498 h->ResetReadyMask();
4500 rc = WinNTSelect(&rd, &wr, to);
4529 if (
h->HasReadInterest())
4531 if (
h->HasWriteInterest())
4533 h->ResetReadyMask();
4534 rc = WinNTSelect(&rd, &wr, to);
4556 if ((sp = ::getservbyname(servicename,
kProtocolName)) == 0) {
4557 Error(
"GetServiceByName",
"no service \"%s\" with protocol \"%s\"\n",
4561 return ::ntohs(sp->s_port);
4572 if ((sp = ::getservbyport(::htons(port),
kProtocolName)) == 0) {
4573 return Form(
"%d", port);
4583 struct hostent *host_ptr;
4588 if ((addr = ::inet_addr(hostname)) != INADDR_NONE) {
4590 if ((host_ptr = ::gethostbyaddr((
const char *)&addr,
4591 sizeof(addr), AF_INET))) {
4592 host = host_ptr->h_name;
4596 for (i = 1; host_ptr->h_addr_list[i]; i++) {
4597 memcpy(&addr2, host_ptr->h_addr_list[i], host_ptr->h_length);
4598 a.AddAddress(ntohl(addr2));
4600 for (i = 0; host_ptr->h_aliases[i]; i++)
4601 a.AddAlias(host_ptr->h_aliases[i]);
4604 host =
"UnNamedHost";
4606 }
else if ((host_ptr = ::gethostbyname(hostname))) {
4608 if (host_ptr->h_addrtype != AF_INET) {
4609 Error(
"GetHostByName",
"%s is not an internet host\n", hostname);
4612 memcpy(&addr, host_ptr->h_addr, host_ptr->h_length);
4613 host = host_ptr->h_name;
4614 type = host_ptr->h_addrtype;
4618 for (i = 1; host_ptr->h_addr_list[i]; i++) {
4619 memcpy(&addr2, host_ptr->h_addr_list[i], host_ptr->h_length);
4620 a.AddAddress(ntohl(addr2));
4622 for (i = 0; host_ptr->h_aliases[i]; i++)
4623 a.AddAlias(host_ptr->h_aliases[i]);
4626 if (
gDebug > 0)
Error(
"GetHostByName",
"unknown host %s", hostname);
4639 struct sockaddr_in addr;
4640 int len =
sizeof(addr);
4642 if (::getpeername(sock, (
struct sockaddr *)&addr, &len) == SOCKET_ERROR) {
4647 struct hostent *host_ptr;
4648 const char *hostname;
4652 if ((host_ptr = ::gethostbyaddr((
const char *)&addr.sin_addr,
4653 sizeof(addr.sin_addr), AF_INET))) {
4654 memcpy(&iaddr, host_ptr->h_addr, host_ptr->h_length);
4655 hostname = host_ptr->h_name;
4656 family = host_ptr->h_addrtype;
4658 memcpy(&iaddr, &addr.sin_addr,
sizeof(addr.sin_addr));
4663 return TInetAddress(hostname, ::ntohl(iaddr), family, ::ntohs(addr.sin_port));
4672 struct sockaddr_in addr;
4673 int len =
sizeof(addr);
4675 if (::getsockname(sock, (
struct sockaddr *)&addr, &len) == SOCKET_ERROR) {
4680 struct hostent *host_ptr;
4681 const char *hostname;
4685 if ((host_ptr = ::gethostbyaddr((
const char *)&addr.sin_addr,
4686 sizeof(addr.sin_addr), AF_INET))) {
4687 memcpy(&iaddr, host_ptr->h_addr, host_ptr->h_length);
4688 hostname = host_ptr->h_name;
4689 family = host_ptr->h_addrtype;
4691 memcpy(&iaddr, &addr.sin_addr,
sizeof(addr.sin_addr));
4696 return TInetAddress(hostname, ::ntohl(iaddr), family, ::ntohs(addr.sin_port));
4707 if ((sock = ::socket(AF_INET, SOCK_STREAM, 0)) ==
INVALID_SOCKET) {
4708 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"socket");
4712 struct sockaddr_in inserver;
4713 memset(&inserver, 0,
sizeof(inserver));
4714 inserver.sin_family = AF_INET;
4715 inserver.sin_addr.s_addr = ::htonl(INADDR_LOOPBACK);
4716 inserver.sin_port = port;
4720 if (::bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver)) == SOCKET_ERROR) {
4721 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"bind");
4726 if (::listen(sock, backlog)) {
4727 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"listen");
4739 if (!sockpath || strlen(sockpath) <= 0) {
4740 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"socket path undefined");
4744 struct sockaddr_in myaddr;
4746 int len =
sizeof myaddr;
4751 if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
4752 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"socket");
4756 memset(&myaddr, 0,
sizeof(myaddr));
4757 myaddr.sin_port = 0;
4758 myaddr.sin_family = AF_INET;
4759 myaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
4761 rc = bind(sock, (
struct sockaddr *)&myaddr, len);
4763 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"bind");
4766 rc = getsockname(sock, (
struct sockaddr *)&myaddr, &len);
4768 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"getsockname");
4771 TString socketpath = sockpath;
4773 fp = fopen(socketpath,
"wb");
4775 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"fopen");
4778 fprintf(fp,
"%d", myaddr.sin_port);
4782 if (listen(sock, backlog)) {
4783 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"listen");
4795 if (socket == -1)
return;
4799 ::shutdown(sock, 2);
4801 struct linger linger = {0, 0};
4802 ::setsockopt(sock, SOL_SOCKET, SO_LINGER, (
char *) &linger,
sizeof(linger));
4803 while (::
closesocket(sock) == SOCKET_ERROR && WSAGetLastError() == WSAEINTR) {
4817 if (WinNTRecv(sock, &header,
sizeof(header), 0) > 0) {
4818 int count = ::ntohl(header);
4820 if (count > length) {
4821 Error(
"RecvBuf",
"record header exceeds buffer size");
4823 }
else if (count > 0) {
4824 if (WinNTRecv(sock, buf, count, 0) < 0) {
4825 Error(
"RecvBuf",
"cannot receive buffer");
4840 Int_t header = ::htonl(length);
4842 if (WinNTSend(sock, &header,
sizeof(header), 0) < 0) {
4843 Error(
"SendBuf",
"cannot send header");
4847 if (WinNTSend(sock, buf, length, 0) < 0) {
4848 Error(
"SendBuf",
"cannot send buffer");
4888 if ((
n = WinNTRecv(sock, buf, length, flag)) <= 0) {
4890 Error(
"RecvRaw",
"cannot receive buffer");
4924 if ((
n = WinNTSend(sock, buf, length, flag)) <= 0) {
4926 Error(
"SendRaw",
"cannot send buffer");
4939 if (socket == -1)
return -1;
4944 if (::setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4945 ::SysError(
"SetSockOpt",
"setsockopt(SO_SNDBUF)");
4950 if (::setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4951 ::SysError(
"SetSockOpt",
"setsockopt(SO_RCVBUF)");
4956 if (::setsockopt(sock, SOL_SOCKET, SO_OOBINLINE, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4957 SysError(
"SetSockOpt",
"setsockopt(SO_OOBINLINE)");
4962 if (::setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4963 ::SysError(
"SetSockOpt",
"setsockopt(SO_KEEPALIVE)");
4968 if (::setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4969 ::SysError(
"SetSockOpt",
"setsockopt(SO_REUSEADDR)");
4974 if (::setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4975 ::SysError(
"SetSockOpt",
"setsockopt(TCP_NODELAY)");
4980 if (::ioctlsocket(sock, FIONBIO, &val) == SOCKET_ERROR) {
4987 if (::ioctl(sock, SIOCSPGRP, &val) == -1) {
4988 ::SysError(
"SetSockOpt",
"ioctl(SIOCSPGRP)");
4996 Error(
"SetSockOpt",
"illegal option (%d)", opt);
5008 if (socket == -1)
return -1;
5011 int optlen =
sizeof(*val);
5015 if (::getsockopt(sock, SOL_SOCKET, SO_SNDBUF, (
char*)val, &optlen) == SOCKET_ERROR) {
5016 ::SysError(
"GetSockOpt",
"getsockopt(SO_SNDBUF)");
5021 if (::getsockopt(sock, SOL_SOCKET, SO_RCVBUF, (
char*)val, &optlen) == SOCKET_ERROR) {
5022 ::SysError(
"GetSockOpt",
"getsockopt(SO_RCVBUF)");
5027 if (::getsockopt(sock, SOL_SOCKET, SO_OOBINLINE, (
char*)val, &optlen) == SOCKET_ERROR) {
5028 ::SysError(
"GetSockOpt",
"getsockopt(SO_OOBINLINE)");
5033 if (::getsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (
char*)val, &optlen) == SOCKET_ERROR) {
5034 ::SysError(
"GetSockOpt",
"getsockopt(SO_KEEPALIVE)");
5039 if (::getsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (
char*)val, &optlen) == SOCKET_ERROR) {
5040 ::SysError(
"GetSockOpt",
"getsockopt(SO_REUSEADDR)");
5045 if (::getsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (
char*)val, &optlen) == SOCKET_ERROR) {
5046 ::SysError(
"GetSockOpt",
"getsockopt(TCP_NODELAY)");
5062 if (::ioctlsocket(sock, SIOCGPGRP, (u_long*)val) == SOCKET_ERROR) {
5063 ::SysError(
"GetSockOpt",
"ioctl(SIOCGPGRP)");
5069 if (::ioctlsocket(sock, SIOCATMARK, (u_long*)val) == SOCKET_ERROR) {
5070 ::SysError(
"GetSockOpt",
"ioctl(SIOCATMARK)");
5075 if (::ioctlsocket(sock, FIONREAD, (u_long*)val) == SOCKET_ERROR) {
5081 Error(
"GetSockOpt",
"illegal option (%d)", opt);
5093 int tcpwindowsize,
const char *protocol)
5098 if (!strcmp(servername,
"unix")) {
5102 (servername[1] ==
':' && servername[2] ==
'/')) {
5106 if (!strcmp(protocol,
"udp")){
5113 sport = ::htons(port);
5117 if (!addr.
IsValid())
return -1;
5120 struct sockaddr_in server;
5121 memset(&server, 0,
sizeof(server));
5122 memcpy(&server.sin_addr, &adr,
sizeof(adr));
5124 server.sin_port = sport;
5128 if ((sock = ::socket(AF_INET, SOCK_STREAM, 0)) ==
INVALID_SOCKET) {
5129 ::SysError(
"TWinNTSystem::WinNTConnectTcp",
"socket");
5133 if (tcpwindowsize > 0) {
5138 if (::connect(sock, (
struct sockaddr*) &server,
sizeof(server)) ==
INVALID_SOCKET) {
5151 struct sockaddr_in myaddr;
5154 memset(&myaddr, 0,
sizeof(myaddr));
5155 myaddr.sin_family = AF_INET;
5156 myaddr.sin_port = port;
5157 myaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
5160 if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
5161 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"socket");
5165 while ((connect(sock, (
struct sockaddr *)&myaddr,
sizeof myaddr)) == -1) {
5169 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"connect");
5185 if (!sockpath || strlen(sockpath) <= 0) {
5186 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"socket path undefined");
5189 TString socketpath = sockpath;
5191 fp = fopen(socketpath.
Data(),
"rb");
5193 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"fopen");
5196 fscanf(fp,
"%d", &port);
5199 if (port < 0 || port > 65535) {
5200 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"invalid port");
5218 sport = htons(port);
5221 if (!addr.
IsValid())
return -1;
5224 struct sockaddr_in server;
5225 memset(&server, 0,
sizeof(server));
5226 memcpy(&server.sin_addr, &adr,
sizeof(adr));
5228 server.sin_port = sport;
5232 if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
5233 ::SysError(
"TWinNTSystem::WinNTUdpConnect",
"socket (%s:%d)",
5238 while (connect(sock, (
struct sockaddr*) &server,
sizeof(server)) == -1) {
5242 ::SysError(
"TWinNTSystem::WinNTUdpConnect",
"connect (%s:%d)",
5260 const char *protocol)
5281 const short kSOCKET_MINPORT = 5000, kSOCKET_MAXPORT = 15000;
5282 short tryport = kSOCKET_MINPORT;
5287 sport = ::htons(port);
5290 if (port == 0 && reuse) {
5291 ::Error(
"TWinNTSystem::WinNTTcpService",
"cannot do a port scan while reuse is true");
5298 sport = ::htons(port);
5303 if ((sock = ::socket(AF_INET, SOCK_STREAM, 0)) < 0) {
5304 ::SysError(
"TWinNTSystem::WinNTTcpService",
"socket");
5312 if (tcpwindowsize > 0) {
5317 struct sockaddr_in inserver;
5318 memset(&inserver, 0,
sizeof(inserver));
5319 inserver.sin_family = AF_INET;
5320 inserver.sin_addr.s_addr = ::htonl(INADDR_ANY);
5321 inserver.sin_port = sport;
5325 if (::bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver)) == SOCKET_ERROR) {
5326 ::SysError(
"TWinNTSystem::WinNTTcpService",
"bind");
5332 inserver.sin_port = ::htons(tryport);
5333 bret = ::bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver));
5335 }
while (bret == SOCKET_ERROR && WSAGetLastError() == WSAEADDRINUSE &&
5336 tryport < kSOCKET_MAXPORT);
5337 if (bret == SOCKET_ERROR) {
5338 ::SysError(
"TWinNTSystem::WinNTTcpService",
"bind (port scan)");
5344 if (::listen(sock, backlog) == SOCKET_ERROR) {
5345 ::SysError(
"TWinNTSystem::WinNTTcpService",
"listen");
5362 const short kSOCKET_MINPORT = 5000, kSOCKET_MAXPORT = 15000;
5363 short sport, tryport = kSOCKET_MINPORT;
5369 sport = htons(port);
5373 if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
5374 ::SysError(
"TUnixSystem::UnixUdpService",
"socket");
5378 struct sockaddr_in inserver;
5379 memset(&inserver, 0,
sizeof(inserver));
5380 inserver.sin_family = AF_INET;
5381 inserver.sin_addr.s_addr = htonl(INADDR_ANY);
5382 inserver.sin_port = sport;
5386 if (bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver))) {
5387 ::SysError(
"TWinNTSystem::AnnounceUdpService",
"bind");
5393 inserver.sin_port = htons(tryport);
5394 bret = bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver));
5396 }
while (bret == SOCKET_ERROR && WSAGetLastError() == WSAEADDRINUSE &&
5397 tryport < kSOCKET_MAXPORT);
5399 ::SysError(
"TWinNTSystem::AnnounceUdpService",
"bind (port scan)");
5405 if (listen(sock, backlog)) {
5406 ::SysError(
"TWinNTSystem::AnnounceUdpService",
"listen");
5424 (::WSAGetLastError() == WSAEINTR)) {
5429 if (::WSAGetLastError() == WSAEWOULDBLOCK) {
5443#define SystemBasicInformation 0
5444#define SystemPerformanceInformation 2
5449 ULONG uKeMaximumIncrement;
5451 ULONG uMmNumberOfPhysicalPages;
5452 ULONG uMmLowestPhysicalPage;
5453 ULONG UMmHighestPhysicalPage;
5454 ULONG uAllocationGranularity;
5455 PVOID pLowestUserAddress;
5456 PVOID pMmHighestUserAddress;
5457 ULONG uKeActiveProcessors;
5458 BYTE bKeNumberProcessors;
5461} SYSTEM_BASIC_INFORMATION;
5465 LARGE_INTEGER liIdleTime;
5467} SYSTEM_PERFORMANCE_INFORMATION;
5469typedef struct _PROCESS_MEMORY_COUNTERS {
5471 DWORD PageFaultCount;
5472 SIZE_T PeakWorkingSetSize;
5473 SIZE_T WorkingSetSize;
5474 SIZE_T QuotaPeakPagedPoolUsage;
5475 SIZE_T QuotaPagedPoolUsage;
5476 SIZE_T QuotaPeakNonPagedPoolUsage;
5477 SIZE_T QuotaNonPagedPoolUsage;
5478 SIZE_T PagefileUsage;
5479 SIZE_T PeakPagefileUsage;
5484#define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 + (double)((x).LowPart))
5492 LARGE_INTEGER ulFreq, ulTicks, ulValue, ulStartCounter;
5496 if (QueryPerformanceFrequency(&ulFreq)) {
5498 QueryPerformanceCounter(&ulTicks);
5501 ulValue.QuadPart = ulTicks.QuadPart + ulFreq.QuadPart/10;
5502 ulStartCounter.QuadPart =
__rdtsc();
5506 QueryPerformanceCounter(&ulTicks);
5507 }
while (ulTicks.QuadPart <= ulValue.QuadPart);
5509 return (DWORD)((
__rdtsc() - ulStartCounter.QuadPart)/100000);
5517#define SM_SERVERR2 89
5524 OSVERSIONINFOEX osvi;
5527 BOOL bOsVersionInfoEx;
5528 static char *strReturn = 0;
5532 strReturn =
new char[2048];
5536 ZeroMemory(&si,
sizeof(SYSTEM_INFO));
5537 ZeroMemory(&osvi,
sizeof(OSVERSIONINFOEX));
5542 osvi.dwOSVersionInfoSize =
sizeof(OSVERSIONINFOEX);
5544 if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
5546 osvi.dwOSVersionInfoSize =
sizeof (OSVERSIONINFO);
5547 if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
5552 pGNSI = (
PGNSI) GetProcAddress( GetModuleHandle(
"kernel32.dll"),
5553 "GetNativeSystemInfo");
5556 else GetSystemInfo(&si);
5558 switch (osvi.dwPlatformId)
5561 case VER_PLATFORM_WIN32_NT:
5564 if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 )
5566 if( osvi.wProductType == VER_NT_WORKSTATION )
5567 strlcpy(strReturn,
"Microsoft Windows Vista ",2048);
5568 else strlcpy(strReturn,
"Windows Server \"Longhorn\" " ,2048);
5570 if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
5573 strlcpy(strReturn,
"Microsoft Windows Server 2003 \"R2\" ",2048);
5574 else if( osvi.wProductType == VER_NT_WORKSTATION &&
5575 si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
5577 strlcpy(strReturn,
"Microsoft Windows XP Professional x64 Edition ",2048);
5579 else strlcpy(strReturn,
"Microsoft Windows Server 2003, ",2048);
5581 if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
5582 strlcpy(strReturn,
"Microsoft Windows XP ",2048);
5584 if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
5585 strlcpy(strReturn,
"Microsoft Windows 2000 ",2048);
5587 if ( osvi.dwMajorVersion <= 4 )
5588 strlcpy(strReturn,
"Microsoft Windows NT ",2048);
5591 if( bOsVersionInfoEx )
5594 if ( osvi.wProductType == VER_NT_WORKSTATION &&
5595 si.wProcessorArchitecture!=PROCESSOR_ARCHITECTURE_AMD64)
5597 if( osvi.dwMajorVersion == 4 )
5598 strlcat(strReturn,
"Workstation 4.0 ",2048 );
5599 else if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
5600 strlcat(strReturn,
"Home Edition " ,2048);
5601 else strlcat(strReturn,
"Professional " ,2048);
5604 else if ( osvi.wProductType == VER_NT_SERVER ||
5605 osvi.wProductType == VER_NT_DOMAIN_CONTROLLER )
5607 if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==2)
5609 if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_IA64 )
5611 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
5612 strlcat(strReturn,
"Datacenter Edition for Itanium-based Systems",2048 );
5613 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5614 strlcat(strReturn,
"Enterprise Edition for Itanium-based Systems" ,2048);
5616 else if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 )
5618 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
5619 strlcat(strReturn,
"Datacenter x64 Edition ",2048 );
5620 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5621 strlcat(strReturn,
"Enterprise x64 Edition ",2048 );
5622 else strlcat(strReturn,
"Standard x64 Edition ",2048 );
5626 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
5627 strlcat(strReturn,
"Datacenter Edition ",2048 );
5628 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5629 strlcat(strReturn,
"Enterprise Edition ",2048 );
5630 else if ( osvi.wSuiteMask == VER_SUITE_BLADE )
5631 strlcat(strReturn,
"Web Edition " ,2048);
5632 else strlcat(strReturn,
"Standard Edition ",2048 );
5635 else if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==0)
5637 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
5638 strlcat(strReturn,
"Datacenter Server ",2048 );
5639 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5640 strlcat(strReturn,
"Advanced Server ",2048 );
5641 else strlcat(strReturn,
"Server ",2048 );
5645 if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5646 strlcat(strReturn,
"Server 4.0, Enterprise Edition " ,2048);
5647 else strlcat(strReturn,
"Server 4.0 ",2048 );
5656 DWORD dwBufLen=
BUFSIZE*
sizeof(TCHAR);
5659 lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
5660 "SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
5661 0, KEY_QUERY_VALUE, &hKey );
5662 if( lRet != ERROR_SUCCESS )
5665 lRet = RegQueryValueEx( hKey,
"ProductType", NULL, NULL,
5666 (LPBYTE) szProductType, &dwBufLen);
5667 RegCloseKey( hKey );
5669 if( (lRet != ERROR_SUCCESS) || (dwBufLen >
BUFSIZE*
sizeof(TCHAR)) )
5672 if ( lstrcmpi(
"WINNT", szProductType) == 0 )
5673 strlcat(strReturn,
"Workstation " ,2048);
5674 if ( lstrcmpi(
"LANMANNT", szProductType) == 0 )
5675 strlcat(strReturn,
"Server " ,2048);
5676 if ( lstrcmpi(
"SERVERNT", szProductType) == 0 )
5677 strlcat(strReturn,
"Advanced Server " ,2048);
5678 snprintf(temp,512,
"%d.%d ", osvi.dwMajorVersion, osvi.dwMinorVersion);
5679 strlcat(strReturn, temp,2048);
5684 if( osvi.dwMajorVersion == 4 &&
5685 lstrcmpi( osvi.szCSDVersion,
"Service Pack 6" ) == 0 )
5691 lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
5692 "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009",
5693 0, KEY_QUERY_VALUE, &hKey );
5694 if( lRet == ERROR_SUCCESS ) {
5695 snprintf(temp, 512,
"Service Pack 6a (Build %d)", osvi.dwBuildNumber & 0xFFFF );
5696 strlcat(strReturn, temp,2048 );
5700 snprintf(temp,512,
"%s (Build %d)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF);
5701 strlcat(strReturn, temp,2048 );
5704 RegCloseKey( hKey );
5708 snprintf(temp, 512,
"%s (Build %d)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF);
5709 strlcat(strReturn, temp,2048 );
5715 case VER_PLATFORM_WIN32_WINDOWS:
5717 if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
5719 strlcpy(strReturn,
"Microsoft Windows 95 ",2048);
5720 if (osvi.szCSDVersion[1]==
'C' || osvi.szCSDVersion[1]==
'B')
5721 strlcat(strReturn,
"OSR2 " ,2048);
5724 if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
5726 strlcpy(strReturn,
"Microsoft Windows 98 ",2048);
5727 if ( osvi.szCSDVersion[1]==
'A' || osvi.szCSDVersion[1]==
'B')
5728 strlcat(strReturn,
"SE ",2048 );
5731 if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
5733 strlcpy(strReturn,
"Microsoft Windows Millennium Edition",2048);
5737 case VER_PLATFORM_WIN32s:
5738 strlcpy(strReturn,
"Microsoft Win32s",2048);
5749 unsigned nHighestFeatureEx;
5753 nHighestFeatureEx = (unsigned)nBuff[0];
5755 if (nHighestFeatureEx >= 0x80000006) {
5757 return (((
unsigned)nBuff[2])>>16);
5767 SYSTEM_PERFORMANCE_INFORMATION SysPerfInfo;
5768 SYSTEM_INFO sysInfo;
5769 MEMORYSTATUSEX statex;
5770 OSVERSIONINFO OsVersionInfo;
5772 char szKeyValueString[80];
5773 DWORD szKeyValueDword;
5778 NtQuerySystemInformation = (
PROCNTQSI)GetProcAddress(
5779 GetModuleHandle(
"ntdll"),
"NtQuerySystemInformation");
5781 if (!NtQuerySystemInformation) {
5783 "Error on GetProcAddress(NtQuerySystemInformation)");
5788 &SysPerfInfo,
sizeof(SysPerfInfo),
5790 OsVersionInfo.dwOSVersionInfoSize =
sizeof(OSVERSIONINFO);
5791 GetVersionEx(&OsVersionInfo);
5792 GetSystemInfo(&sysInfo);
5793 statex.dwLength =
sizeof(statex);
5794 if (!GlobalMemoryStatusEx(&statex)) {
5795 ::Error(
"GetWinNTSysInfo",
"Error on GlobalMemoryStatusEx()");
5798 sysinfo->
fCpus = sysInfo.dwNumberOfProcessors;
5807 status = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"HARDWARE\\DESCRIPTION\\System",
5808 0, KEY_QUERY_VALUE, &hKey);
5809 if (status == ERROR_SUCCESS) {
5810 dwBufLen =
sizeof(szKeyValueString);
5811 RegQueryValueEx(hKey,
"Identifier", NULL, NULL,(LPBYTE)szKeyValueString,
5813 sysinfo->
fModel = szKeyValueString;
5816 status = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
5817 "Hardware\\Description\\System\\CentralProcessor\\0",
5818 0, KEY_QUERY_VALUE, &hKey);
5819 if (status == ERROR_SUCCESS) {
5820 dwBufLen =
sizeof(szKeyValueString);
5821 status = RegQueryValueEx(hKey,
"ProcessorNameString", NULL, NULL,
5822 (LPBYTE)szKeyValueString, &dwBufLen);
5823 if (status == ERROR_SUCCESS)
5824 sysinfo->
fCpuType = szKeyValueString;
5825 dwBufLen =
sizeof(DWORD);
5826 status = RegQueryValueEx(hKey,
"~MHz",NULL,NULL,(LPBYTE)&szKeyValueDword,
5828 if ((status == ERROR_SUCCESS) && ((sysinfo->
fCpuSpeed <= 0) ||
5829 (sysinfo->
fCpuSpeed < (szKeyValueDword >> 1))))
5843 SYSTEM_INFO sysInfo;
5844 Float_t idle_ratio, kernel_ratio, user_ratio, total_ratio;
5845 FILETIME ft_sys_idle, ft_sys_kernel, ft_sys_user, ft_fun_time;
5846 SYSTEMTIME st_fun_time;
5848 ULARGE_INTEGER ul_sys_idle, ul_sys_kernel, ul_sys_user;
5849 static ULARGE_INTEGER ul_sys_idleold = {0, 0};
5850 static ULARGE_INTEGER ul_sys_kernelold = {0, 0};
5851 static ULARGE_INTEGER ul_sys_userold = {0, 0};
5852 ULARGE_INTEGER ul_sys_idle_diff, ul_sys_kernel_diff, ul_sys_user_diff;
5854 ULARGE_INTEGER ul_fun_time;
5855 ULARGE_INTEGER ul_fun_timeold = {0, 0};
5856 ULARGE_INTEGER ul_fun_time_diff;
5858 typedef BOOL (__stdcall *GetSystemTimesProc)( LPFILETIME lpIdleTime,
5859 LPFILETIME lpKernelTime, LPFILETIME lpUserTime );
5860 static GetSystemTimesProc pGetSystemTimes = 0;
5862 HMODULE hModImagehlp = LoadLibrary(
"Kernel32.dll" );
5863 if (!hModImagehlp) {
5864 ::Error(
"GetWinNTCpuInfo",
"Error on LoadLibrary(Kernel32.dll)");
5868 pGetSystemTimes = (GetSystemTimesProc) GetProcAddress( hModImagehlp,
5870 if (!pGetSystemTimes) {
5871 ::Error(
"GetWinNTCpuInfo",
"Error on GetProcAddress(GetSystemTimes)");
5874 GetSystemInfo(&sysInfo);
5877 pGetSystemTimes(&ft_sys_idle,&ft_sys_kernel,&ft_sys_user);
5878 GetSystemTime(&st_fun_time);
5879 SystemTimeToFileTime(&st_fun_time,&ft_fun_time);
5881 memcpy(&ul_sys_idle, &ft_sys_idle,
sizeof(FILETIME));
5882 memcpy(&ul_sys_kernel, &ft_sys_kernel,
sizeof(FILETIME));
5883 memcpy(&ul_sys_user, &ft_sys_user,
sizeof(FILETIME));
5884 memcpy(&ul_fun_time, &ft_fun_time,
sizeof(FILETIME));
5886 ul_sys_idle_diff.QuadPart = ul_sys_idle.QuadPart -
5887 ul_sys_idleold.QuadPart;
5888 ul_sys_kernel_diff.QuadPart = ul_sys_kernel.QuadPart -
5889 ul_sys_kernelold.QuadPart;
5890 ul_sys_user_diff.QuadPart = ul_sys_user.QuadPart -
5891 ul_sys_userold.QuadPart;
5893 ul_fun_time_diff.QuadPart = ul_fun_time.QuadPart -
5894 ul_fun_timeold.QuadPart;
5896 ul_sys_idleold.QuadPart = ul_sys_idle.QuadPart;
5897 ul_sys_kernelold.QuadPart = ul_sys_kernel.QuadPart;
5898 ul_sys_userold.QuadPart = ul_sys_user.QuadPart;
5900 if (ul_fun_timeold.QuadPart == 0) {
5902 ul_fun_timeold.QuadPart = ul_fun_time.QuadPart;
5905 ul_fun_timeold.QuadPart = ul_fun_time.QuadPart;
5913 idle_ratio /= (
Float_t)sysInfo.dwNumberOfProcessors;
5914 user_ratio /= (
Float_t)sysInfo.dwNumberOfProcessors;
5915 kernel_ratio /= (
Float_t)sysInfo.dwNumberOfProcessors;
5916 total_ratio = 100.0 - idle_ratio;
5921 cpuinfo->
fUser = user_ratio;
5922 cpuinfo->
fSys = kernel_ratio;
5923 cpuinfo->
fTotal = total_ratio;
5924 cpuinfo->
fIdle = idle_ratio;
5933 MEMORYSTATUSEX statex;
5934 statex.dwLength =
sizeof(statex);
5935 if (!GlobalMemoryStatusEx(&statex)) {
5936 ::Error(
"GetWinNTMemInfo",
"Error on GlobalMemoryStatusEx()");
5939 used = (
Long64_t)(statex.ullTotalPhys - statex.ullAvailPhys);
5947 swap_total = (
Long64_t)(statex.ullTotalPageFile - statex.ullTotalPhys);
5948 swap_avail = (
Long64_t)(statex.ullAvailPageFile - statex.ullAvailPhys);
5949 swap_used = swap_total - swap_avail;
5962 FILETIME starttime, exittime, kerneltime, usertime;
5963 timeval ru_stime, ru_utime;
5966 typedef BOOL (__stdcall *GetProcessMemoryInfoProc)( HANDLE Process,
5968 static GetProcessMemoryInfoProc pGetProcessMemoryInfo = 0;
5970 HMODULE hModImagehlp = LoadLibrary(
"Psapi.dll" );
5971 if (!hModImagehlp) {
5972 ::Error(
"GetWinNTProcInfo",
"Error on LoadLibrary(Psapi.dll)");
5976 pGetProcessMemoryInfo = (GetProcessMemoryInfoProc) GetProcAddress(
5977 hModImagehlp,
"GetProcessMemoryInfo" );
5978 if (!pGetProcessMemoryInfo) {
5980 "Error on GetProcAddress(GetProcessMemoryInfo)");
5984 if ( pGetProcessMemoryInfo( GetCurrentProcess(), &pmc,
sizeof(pmc)) ) {
5988 if ( GetProcessTimes(GetCurrentProcess(), &starttime, &exittime,
5989 &kerneltime, &usertime)) {
5992 memcpy(&li, &kerneltime,
sizeof(FILETIME));
5994 ru_stime.tv_sec = li.QuadPart / 1000000L;
5995 ru_stime.tv_usec = li.QuadPart % 1000000L;
5997 memcpy(&li, &usertime,
sizeof(FILETIME));
5999 ru_utime.tv_sec = li.QuadPart / 1000000L;
6000 ru_utime.tv_usec = li.QuadPart % 1000000L;
6003 ((
Float_t)(ru_utime.tv_usec) / 1000000.);
6005 ((
Float_t)(ru_stime.tv_usec) / 1000000.);
6016 if (!info)
return -1;
6028 if (!info)
return -1;
6039 if (!info)
return -1;
6050 if (!info)
return -1;
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,...)
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)
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.
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)
__inline BOOL DBL_BSLASH(LPCTSTR psz)
Inline function to check for a double-backslash at the beginning of a string.
static char * GetWindowsVersion()
static void GetWinNTSysInfo(SysInfo_t *sysinfo)
Get system info for Windows NT.
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...
void Copy(void *source, void *dest)
RooCmdArg Index(RooCategory &icat)
static constexpr double s
static constexpr double cm
static constexpr double L