7027 ! ! |
7043 ! ! |
7028 |
7044 |
7029 !Win32OperatingSystem class methodsFor:'mutex'! |
7045 !Win32OperatingSystem class methodsFor:'mutex'! |
7030 |
7046 |
7031 createMutexNamed: name |
7047 createMutexNamed: name |
7032 |
|
7033 "Returns an array with the handle and the lastErrorCode" |
7048 "Returns an array with the handle and the lastErrorCode" |
7034 |
7049 |
7035 |handle lastErrorCode| |
7050 |handle lastErrorCode| |
7036 |
7051 |
7037 "Without clear reasons, before creating the mutex we must call #printCR" |
7052 "/ "Without clear reasons, before creating the mutex we must call #printCR" |
7038 'Creating mutex' printCR. |
7053 "/ 'Creating mutex' printCR. |
7039 self primSetLastError: 0. |
7054 self primSetLastError: 0. |
7040 self primGetLastError. |
7055 self primGetLastError. |
7041 handle := self primCreateMutex:nil initialOwner: true name: name. |
7056 handle := self primCreateMutex:nil initialOwner: true name: name. |
7042 lastErrorCode := self primGetLastError. |
7057 lastErrorCode := self primGetLastError. |
7043 lastErrorCode printCR. |
7058 "/ lastErrorCode printCR. |
|
7059 |
7044 "/ self assert: lastErrorCode == 0. |
7060 "/ self assert: lastErrorCode == 0. |
7045 "/ lastErrorCode == 5 "ERROR_ACCESS_DENIED" ifTrue:[Transcript showCR: 'Mutex not accesible (GetLastError = ERROR_ACCESS_DENIED)'.]. |
7061 "/ lastErrorCode == 5 "ERROR_ACCESS_DENIED" ifTrue:[Transcript showCR: 'Mutex not accesible (GetLastError = ERROR_ACCESS_DENIED)'.]. |
7046 "/ lastErrorCode == 183 "ERROR_ALREADY_EXISTS" ifTrue:[Transcript showCR: 'Mutex already exists (GetLastError = ERROR_ALREADY_EXISTS)'.]. |
7062 "/ lastErrorCode == 183 "ERROR_ALREADY_EXISTS" ifTrue:[Transcript showCR: 'Mutex already exists (GetLastError = ERROR_ALREADY_EXISTS)'.]. |
7047 (handle isNil or:[handle address ~~ 0]) ifFalse:[ |
7063 (handle isNil or:[handle address ~~ 0]) ifFalse:[ |
7048 Transcript showCR: 'CreateMutexNamed: "', name printString, '" failed'. |
7064 Transcript showCR: 'CreateMutexNamed: "', name printString, '" failed'. |
7049 handle := nil. |
7065 handle := nil. |
7050 ]. |
7066 ]. |
7051 ^ Array with: handle with: lastErrorCode |
7067 ^ Array with: handle with: lastErrorCode |
7052 |
7068 |
7053 " |
7069 " |
7054 self createMutexNamed: '8906f5e0-54ed-11dd-9da4-001558137da0' |
7070 self createMutexNamed: '8906f5e0-54ed-11dd-9da4-001558137da0' |
7055 self releaseMutexNamed: '8906f5e0-54ed-11dd-9da4-001558137da0' |
7071 self releaseMutexNamed: '8906f5e0-54ed-11dd-9da4-001558137da0' |
7056 " |
7072 " |
|
7073 |
|
7074 "Modified: / 03-08-2010 / 16:57:36 / cg" |
7057 ! |
7075 ! |
7058 |
7076 |
7059 existsMutexNamed: name |
7077 existsMutexNamed: name |
7060 |
|
7061 |handle lastErrorCode handleAndLastErrorCode| |
7078 |handle lastErrorCode handleAndLastErrorCode| |
7062 |
7079 |
7063 handleAndLastErrorCode := self createMutexNamed: name. |
7080 handleAndLastErrorCode := self createMutexNamed: name. |
7064 handle := handleAndLastErrorCode first. |
7081 handle := handleAndLastErrorCode first. |
7065 lastErrorCode := handleAndLastErrorCode second. |
7082 lastErrorCode := handleAndLastErrorCode second. |
7066 "/ self assert: lastErrorCode == 0. |
7083 "/ self assert: lastErrorCode == 0. |
7067 ^ handle isNil |
7084 ^ handle isNil |
7068 or:[lastErrorCode == 183 "ERROR_ALREADY_EXISTS" |
7085 or:[lastErrorCode == 183 "ERROR_ALREADY_EXISTS" |
7069 or:[ lastErrorCode == 5 "ERROR_ACCESS_DENIED"]] |
7086 or:[ lastErrorCode == 5 "ERROR_ACCESS_DENIED"]] |
|
7087 |
|
7088 "Modified: / 03-08-2010 / 16:59:41 / cg" |
7070 ! |
7089 ! |
7071 |
7090 |
7072 openMutexNamed: name |
7091 openMutexNamed: name |
7073 |
7092 "If the function succeeds, the return value is a handle to the mutex object. |
7074 " |
7093 If the function fails, the return value is NULL. To get extended error information, call GetLastError. |
7075 If the function succeeds, the return value is a handle to the mutex object. |
7094 If a named mutex does not exist, the function fails and GetLastError returns ERROR_FILE_NOT_FOUND." |
7076 If the function fails, the return value is NULL. To get extended error information, call GetLastError. |
|
7077 If a named mutex does not exist, the function fails and GetLastError returns ERROR_FILE_NOT_FOUND. |
|
7078 " |
|
7079 |
7095 |
7080 |handle | |
7096 |handle | |
7081 |
7097 |
7082 handle := self primOpenMutex:nil initialOwner: true name: name. |
7098 handle := self primOpenMutex:nil initialOwner: true name: name. |
7083 "/ lastErrorCode := self primGetLastError. |
7099 "/ lastErrorCode := self primGetLastError. |
7084 "/ lastErrorCode = 2 ifTrue:[Transcript showCR: 'Mutex does not exist (GetLastError = ERROR_FILE_NOT_FOUND)'.]. |
7100 "/ lastErrorCode = 2 ifTrue:[Transcript showCR: 'Mutex does not exist (GetLastError = ERROR_FILE_NOT_FOUND)'.]. |
7085 "/ lastErrorCode = 5 ifTrue:[Transcript showCR: 'Mutex not accesible (GetLastError = ERROR_ACCESS_DENIED)'.]. |
7101 "/ lastErrorCode = 5 ifTrue:[Transcript showCR: 'Mutex not accesible (GetLastError = ERROR_ACCESS_DENIED)'.]. |
7086 (handle isNil or:[handle address ~~ 0]) ifFalse:[ |
7102 (handle isNil or:[handle address ~~ 0]) ifFalse:[ |
7087 Transcript showCR: 'OpenMutexNamed: "', name printString, '" failed'. |
7103 Transcript showCR: 'OpenMutexNamed: "', name printString, '" failed'. |
7088 ^ nil. |
7104 ^ nil. |
7089 ]. |
7105 ]. |
7090 |
7106 |
7091 ^ handle |
7107 ^ handle |
7092 |
7108 |
7093 |
7109 |
7094 " |
7110 " |
7095 self openMutexNamed: '8906f5e0-54ed-11dd-9da4-001558137da0' |
7111 self openMutexNamed: '8906f5e0-54ed-11dd-9da4-001558137da0' |
7096 " |
7112 " |
|
7113 |
|
7114 "Modified: / 03-08-2010 / 16:59:37 / cg" |
7097 ! |
7115 ! |
7098 |
7116 |
7099 primCreateMutex:lpSecurityDescriptor initialOwner: bInitialOwner name: lpName |
7117 primCreateMutex:lpSecurityDescriptor initialOwner: bInitialOwner name: lpName |
7100 |
7118 "If the function succeeds, the return value is a handle to the newly created mutex object. |
7101 " |
|
7102 If the function succeeds, the return value is a handle to the newly created mutex object. |
|
7103 If the function fails, the return value is NULL. |
7119 If the function fails, the return value is NULL. |
7104 If the mutex is a named mutex and the object existed before this function call, the return value is a handle to the existing object. |
7120 If the mutex is a named mutex and the object existed before this function call, the return value is a handle to the existing object." |
7105 " |
|
7106 |
7121 |
7107 <apicall: handle "CreateMutexA" (lpstr bool lpstr) module: "kernel32.dll" > |
7122 <apicall: handle "CreateMutexA" (lpstr bool lpstr) module: "kernel32.dll" > |
|
7123 |
|
7124 "Modified: / 03-08-2010 / 16:59:26 / cg" |
7108 ! |
7125 ! |
7109 |
7126 |
7110 primOpenMutex:lpSecurityDescriptor initialOwner: bInitialOwner name: lpName |
7127 primOpenMutex:lpSecurityDescriptor initialOwner: bInitialOwner name: lpName |
7111 |
7128 "If the function succeeds, the return value is a handle to the mutex object. |
7112 " |
7129 If the function fails, the return value is NULL. To get extended error information, call GetLastError. |
7113 If the function succeeds, the return value is a handle to the mutex object. |
7130 If a named mutex does not exist, the function fails and GetLastError returns ERROR_FILE_NOT_FOUND." |
7114 If the function fails, the return value is NULL. To get extended error information, call GetLastError. |
|
7115 If a named mutex does not exist, the function fails and GetLastError returns ERROR_FILE_NOT_FOUND. |
|
7116 " |
|
7117 |
7131 |
7118 <apicall: handle "OpenMutexA" (lpstr bool lpstr) module: "kernel32.dll" > |
7132 <apicall: handle "OpenMutexA" (lpstr bool lpstr) module: "kernel32.dll" > |
|
7133 |
|
7134 "Modified: / 03-08-2010 / 16:59:11 / cg" |
7119 ! |
7135 ! |
7120 |
7136 |
7121 primReleaseMutex: hMutex |
7137 primReleaseMutex: hMutex |
7122 |
7138 "If the function succeeds, the return value is nonzero. |
7123 " |
7139 If the function fails, the return value is zero." |
7124 If the function succeeds, the return value is nonzero. |
|
7125 If the function fails, the return value is zero. |
|
7126 " |
|
7127 |
7140 |
7128 <apicall: bool "ReleaseMutex" (handle) module: "kernel32.dll" > |
7141 <apicall: bool "ReleaseMutex" (handle) module: "kernel32.dll" > |
|
7142 |
|
7143 "Modified: / 03-08-2010 / 16:59:55 / cg" |
7129 ! |
7144 ! |
7130 |
7145 |
7131 primWaitForSingleObject: handle milliseconds: dwMilliseconds |
7146 primWaitForSingleObject: handle milliseconds: dwMilliseconds |
7132 |
7147 "If the function succeeds, the return value indicates the event that caused the function to return. |
7133 " |
7148 If the function fails, the return value is WAIT_FAILED ((DWORD)0xFFFFFFFF)." |
7134 If the function succeeds, the return value indicates the event that caused the function to return. |
|
7135 If the function fails, the return value is WAIT_FAILED ((DWORD)0xFFFFFFFF). |
|
7136 " |
|
7137 |
7149 |
7138 <apicall: dword "WaitForSingleObject" (handle dword) module: "kernel32.dll" > |
7150 <apicall: dword "WaitForSingleObject" (handle dword) module: "kernel32.dll" > |
|
7151 |
|
7152 "Modified: / 03-08-2010 / 17:00:02 / cg" |
7139 ! |
7153 ! |
7140 |
7154 |
7141 releaseMutex: hMutex |
7155 releaseMutex: hMutex |
7142 |
|
7143 "Returns true if the Mutex was released. Otherwise, returns false." |
7156 "Returns true if the Mutex was released. Otherwise, returns false." |
7144 |
7157 |
7145 | released| |
7158 | released| |
7146 |
7159 |
7147 hMutex isNil ifTrue:[ |
7160 hMutex isNil ifTrue:[ |
7148 Transcript showCR: 'hMutex is nil - cannot release'. |
7161 Transcript showCR: 'hMutex is nil - cannot release'. |
7149 ^ false |
7162 ^ false |
7150 ]. |
7163 ]. |
7151 released := self primReleaseMutex: hMutex. |
7164 released := self primReleaseMutex: hMutex. |
7152 released ifFalse:[Transcript showCR: 'Release Mutex failed'.]. |
7165 released ifFalse:[Transcript showCR: 'Release Mutex failed'.]. |
7153 ^ released |
7166 ^ released |
|
7167 |
|
7168 "Modified: / 03-08-2010 / 17:00:05 / cg" |
7154 ! |
7169 ! |
7155 |
7170 |
7156 releaseMutexNamed: name |
7171 releaseMutexNamed: name |
7157 |
|
7158 "Returns true if the Mutex was released. Otherwise, returns false." |
7172 "Returns true if the Mutex was released. Otherwise, returns false." |
7159 |
7173 |
7160 | hMutex | |
7174 | hMutex | |
|
7175 |
7161 hMutex := self openMutexNamed: name. |
7176 hMutex := self openMutexNamed: name. |
7162 hMutex isNil ifTrue:[ |
7177 hMutex isNil ifTrue:[ |
7163 Transcript showCR: 'Cannot release Mutex named: "', name printString,'"'. |
7178 Transcript showCR: 'Cannot release Mutex named: "', name printString,'"'. |
7164 ^ false |
7179 ^ false |
7165 ]. |
7180 ]. |
7166 ^ self releaseMutex: hMutex. |
7181 ^ self releaseMutex: hMutex. |
|
7182 |
|
7183 "Modified: / 03-08-2010 / 16:58:25 / cg" |
7167 ! |
7184 ! |
7168 |
7185 |
7169 waitForSingleObject: handle |
7186 waitForSingleObject: handle |
7170 |
|
7171 |result| |
7187 |result| |
7172 |
7188 |
7173 result := self primWaitForSingleObject: handle milliseconds: 500. |
7189 result := self primWaitForSingleObject: handle milliseconds: 500. |
7174 ^ result |
7190 ^ result |
|
7191 |
|
7192 "Modified: / 03-08-2010 / 17:00:10 / cg" |
7175 ! ! |
7193 ! ! |
7176 |
7194 |
7177 !Win32OperatingSystem class methodsFor:'os queries'! |
7195 !Win32OperatingSystem class methodsFor:'os queries'! |
7178 |
7196 |
7179 executableFileExtensions |
7197 executableFileExtensions |
7184 |
7202 |
7185 "Created: 2.5.1997 / 11:42:29 / cg" |
7203 "Created: 2.5.1997 / 11:42:29 / cg" |
7186 ! |
7204 ! |
7187 |
7205 |
7188 getDomainName |
7206 getDomainName |
7189 "return the domain this host is in. |
7207 "return the DNS domain this host is in. |
7190 Notice: |
7208 Notice: |
7191 not all systems support this; on some, 'unknown' is returned." |
7209 not all systems support this; on some, 'unknown' is returned." |
7192 |
7210 |
7193 |name idx hostName k| |
7211 |domainName idx hostName k| |
7194 |
7212 |
7195 DomainName notNil ifTrue:[ |
7213 DomainName notNil ifTrue:[ |
7196 ^ DomainName |
7214 ^ DomainName |
7197 ]. |
7215 ]. |
7198 |
7216 |
7199 name := self getEnvironment:'DOMAIN'. |
7217 "/ sometimes, we can extract the domainName from the hostName ... |
7200 name isNil ifTrue:[ |
7218 hostName := self getHostName. |
7201 name := self getEnvironment:'DOMAINNAME'. |
7219 hostName notEmptyOrNil ifTrue:[ |
|
7220 idx := hostName indexOf:$.. |
|
7221 idx ~~ 0 ifTrue:[ |
|
7222 domainName := hostName copyFrom:idx+1. |
|
7223 ] |
7202 ]. |
7224 ]. |
7203 |
7225 |
7204 name isNil ifTrue:[ |
7226 domainName isNil ifTrue:[ |
7205 "/ sometimes, we can extract the domainName from the hostName ... |
7227 domainName := self getEnvironment:'DOMAIN'. |
7206 hostName := self primGetHostName. |
7228 domainName isNil ifTrue:[ |
7207 hostName notNil ifTrue:[ |
7229 domainName := self getEnvironment:'DOMAINNAME'. |
7208 idx := hostName indexOf:$.. |
7230 ]. |
7209 idx ~~ 0 ifTrue:[ |
7231 |
7210 name := hostName copyFrom:idx+1. |
7232 domainName isNil ifTrue:[ |
7211 ] |
7233 "/ ok, search the registry ... |
7212 ]. |
7234 "/ under NT and later, it is found there ... |
7213 |
7235 k := RegistryEntry key:'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters'. |
7214 name isNil ifTrue:[ |
7236 k notNil ifTrue:[ |
7215 "/ ok, search the registry ... |
7237 domainName := k valueNamed:'Domain'. |
7216 "/ under NT and later, it is found there ... |
7238 k close. |
7217 k := RegistryEntry key:'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters'. |
7239 ]. |
7218 k notNil ifTrue:[ |
7240 ]. |
7219 name := k valueNamed:'Domain'. |
7241 |
7220 k close. |
7242 domainName isNil ifTrue:[ |
7221 ]. |
7243 "/ under Win95/Win98, it is found there ... |
7222 ]. |
7244 k := RegistryEntry key:'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\MSTCP'. |
7223 |
7245 k notNil ifTrue:[ |
7224 name isNil ifTrue:[ |
7246 domainName := k valueNamed:'Domain'. |
7225 "/ under Win95/Win98, it is found there ... |
7247 k close. |
7226 k := RegistryEntry key:'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\MSTCP'. |
7248 ] |
7227 k notNil ifTrue:[ |
7249 ]. |
7228 name := k valueNamed:'Domain'. |
7250 |
7229 k close. |
7251 domainName isNil ifTrue:[ |
7230 ] |
7252 'Win32OperatingSystem [warning]: cannot find out domainName' errorPrintCR. |
7231 ]. |
7253 domainName := 'unknown'. |
7232 |
7254 ]. |
7233 name isNil ifTrue:[ |
7255 DomainName := domainName. "cache only, if it is fixed" |
7234 'Win32OperatingSystem [warning]: cannot find out domainname' errorPrintCR. |
|
7235 name := 'unknown'. |
|
7236 ] |
|
7237 ]. |
7256 ]. |
7238 DomainName := name. |
7257 ^ domainName |
7239 ^ name |
|
7240 |
7258 |
7241 " |
7259 " |
7242 DomainName := nil. |
7260 DomainName := nil. |
7243 OperatingSystem getDomainName |
7261 OperatingSystem getDomainName |
7244 OperatingSystem getHostName |
7262 OperatingSystem getHostName |
7774 OS, for example, linux returns 'ix86', while WIN32 returns 'x86'. |
7784 OS, for example, linux returns 'ix86', while WIN32 returns 'x86'. |
7775 |
7785 |
7776 This method is mainly provided to augment error reports with some system |
7786 This method is mainly provided to augment error reports with some system |
7777 information. |
7787 information. |
7778 (in case of system/version specific OS errors, conditional workarounds and patches |
7788 (in case of system/version specific OS errors, conditional workarounds and patches |
7779 may be based upon this info). |
7789 may be based upon this info). |
7780 Your application should NOT depend upon this in any way. |
7790 Your application should NOT depend upon this in any way. |
7781 |
7791 |
7782 The returned info may (or may not) contain: |
7792 The returned info may (or may not) contain: |
7783 #system -> some operating system identification (irix, Linux, nt, win32s ...) |
7793 #system -> some operating system identification (irix, Linux, nt, win32s ...) |
7784 #version -> OS version (some os version identification) |
7794 #version -> OS version (some os version identification) |
7785 #release -> OS release (3.5, 1.2.1 ...) |
7795 #release -> OS release (3.5, 1.2.1 ...) |
7786 #node -> some host identification (hostname) |
7796 #node -> some host identification (hostname) |
7787 #domain -> domain name (hosts domain) |
7797 #domain -> domain name (hosts domain) |
7788 #machine -> type of machine (i586, mips ...) |
7798 #machine -> type of machine (i586, mips ...) |
7789 |
7799 |
7790 win32: |
7800 win32: |
7791 #physicalRam -> total amount of physical memory |
7801 #physicalRam -> total amount of physical memory |
7792 #freeRam -> amount of free memory |
7802 #freeRam -> amount of free memory |
7793 #swapSize -> size of swapSpace (page file) |
7803 #swapSize -> size of swapSpace (page file) |
7794 #freeSwap -> free bytes in swapSpace |
7804 #freeSwap -> free bytes in swapSpace |
7795 #virtualRam -> total amount of virtual memory |
7805 #virtualRam -> total amount of virtual memory |
7796 #freeVirtual -> amount of free virtual memory |
7806 #freeVirtual -> amount of free virtual memory |
7797 #memoryLoad -> percentage of memory usage (useless) |
7807 #memoryLoad -> percentage of memory usage (useless) |
7798 " |
7808 " |
7799 |
7809 |
7800 |sys node rel ver minorVer majorVer mach dom info arch |
7810 |sys node rel ver minorVer majorVer mach dom info arch |
7801 physicalRam freeRam swapSize freeSwap |
7811 physicalRam freeRam swapSize freeSwap |
7802 virtualRam freeVirtual memoryLoad numberOfCPUs| |
7812 virtualRam freeVirtual memoryLoad numberOfCPUs| |
7855 /* MSC, BorlandC4 ... */ |
7867 /* MSC, BorlandC4 ... */ |
7856 switch (sysInfo.wProcessorArchitecture) |
7868 switch (sysInfo.wProcessorArchitecture) |
7857 #endif |
7869 #endif |
7858 { |
7870 { |
7859 #ifdef PROCESSOR_ARCHITECTURE_INTEL |
7871 #ifdef PROCESSOR_ARCHITECTURE_INTEL |
7860 case PROCESSOR_ARCHITECTURE_INTEL: |
7872 case PROCESSOR_ARCHITECTURE_INTEL: |
7861 s = "intel"; |
7873 arch = @symbol(intel); |
7862 break; |
7874 break; |
7863 #endif |
7875 #endif |
7864 #ifdef PROCESSOR_ARCHITECTURE_MIPS |
7876 #ifdef PROCESSOR_ARCHITECTURE_MIPS |
7865 case PROCESSOR_ARCHITECTURE_MIPS: |
7877 case PROCESSOR_ARCHITECTURE_MIPS: |
7866 s = "mips"; |
7878 arch = @symbol(mips); |
7867 break; |
7879 break; |
7868 #endif |
7880 #endif |
7869 #ifdef PROCESSOR_ARCHITECTURE_ALPHA |
7881 #ifdef PROCESSOR_ARCHITECTURE_ALPHA |
7870 case PROCESSOR_ARCHITECTURE_ALPHA: |
7882 case PROCESSOR_ARCHITECTURE_ALPHA: |
7871 s = "alpha"; |
7883 arch = @symbol(alpha); |
7872 break; |
7884 break; |
7873 #endif |
7885 #endif |
7874 #ifdef PROCESSOR_ARCHITECTURE_ALPHA64 |
7886 #ifdef PROCESSOR_ARCHITECTURE_ALPHA64 |
7875 case PROCESSOR_ARCHITECTURE_ALPHA64: |
7887 case PROCESSOR_ARCHITECTURE_ALPHA64: |
7876 s = "alpha64"; |
7888 arch = @symbol(alpha64); |
7877 break; |
7889 break; |
7878 #endif |
7890 #endif |
7879 #ifdef PROCESSOR_ARCHITECTURE_PPC |
7891 #ifdef PROCESSOR_ARCHITECTURE_PPC |
7880 case PROCESSOR_ARCHITECTURE_PPC: |
7892 case PROCESSOR_ARCHITECTURE_PPC: |
7881 s = "ppc"; |
7893 arch = @symbol(ppc); |
7882 break; |
7894 break; |
7883 #endif |
7895 #endif |
7884 #ifdef PROCESSOR_ARCHITECTURE_ARM |
7896 #ifdef PROCESSOR_ARCHITECTURE_ARM |
7885 case PROCESSOR_ARCHITECTURE_ARM: |
7897 case PROCESSOR_ARCHITECTURE_ARM: |
7886 s = "arm"; |
7898 arch = @symbol(arm); |
7887 break; |
7899 break; |
7888 #endif |
7900 #endif |
7889 #ifdef PROCESSOR_ARCHITECTURE_SHX |
7901 #ifdef PROCESSOR_ARCHITECTURE_SHX |
7890 case PROCESSOR_ARCHITECTURE_SHX: |
7902 case PROCESSOR_ARCHITECTURE_SHX: |
7891 s = "shx"; |
7903 arch = @symbol(shx); |
7892 break; |
7904 break; |
7893 #endif |
7905 #endif |
7894 #ifdef PROCESSOR_ARCHITECTURE_IA64 |
7906 #ifdef PROCESSOR_ARCHITECTURE_IA64 |
7895 case PROCESSOR_ARCHITECTURE_IA64: |
7907 case PROCESSOR_ARCHITECTURE_IA64: |
7896 s = "ia64"; |
7908 arch = @symbol(ia64); |
7897 break; |
7909 break; |
7898 #endif |
7910 #endif |
7899 #ifdef PROCESSOR_ARCHITECTURE_MSIL |
7911 #ifdef PROCESSOR_ARCHITECTURE_MSIL |
7900 case PROCESSOR_ARCHITECTURE_MSIL: |
7912 case PROCESSOR_ARCHITECTURE_MSIL: |
7901 s = "msil"; |
7913 arch = @symbol(msil); |
7902 break; |
7914 break; |
7903 #endif |
7915 #endif |
7904 default: |
7916 default: |
7905 s = "unknown"; |
7917 arch = @symbol(unknown); |
7906 break; |
7918 break; |
7907 } |
7919 } |
7908 arch = __MKSTRING(s); |
|
7909 |
7920 |
7910 switch (sysInfo.dwProcessorType) { |
7921 switch (sysInfo.dwProcessorType) { |
7911 #ifdef PROCESSOR_INTEL_386 |
7922 #ifdef PROCESSOR_INTEL_386 |
7912 case PROCESSOR_INTEL_386: |
7923 case PROCESSOR_INTEL_386: |
7913 s = "i386"; |
7924 mach = @symbol(i386); |
7914 break; |
7925 break; |
7915 #endif |
7926 #endif |
7916 #ifdef PROCESSOR_INTEL_486 |
7927 #ifdef PROCESSOR_INTEL_486 |
7917 case PROCESSOR_INTEL_486: |
7928 case PROCESSOR_INTEL_486: |
7918 s = "i486"; |
7929 mach = @symbol(i486); |
7919 break; |
7930 break; |
7920 #endif |
7931 #endif |
7921 #ifdef PROCESSOR_INTEL_PENTIUM |
7932 #ifdef PROCESSOR_INTEL_PENTIUM |
7922 case PROCESSOR_INTEL_PENTIUM: |
7933 case PROCESSOR_INTEL_PENTIUM: |
7923 s = "i586"; |
7934 mach = @symbol(i586); |
7924 break; |
7935 break; |
7925 #endif |
7936 #endif |
7926 #ifdef PROCESSOR_INTEL_860 |
7937 #ifdef PROCESSOR_INTEL_860 |
7927 case PROCESSOR_INTEL_860: |
7938 case PROCESSOR_INTEL_860: |
7928 s = "i860"; |
7939 mach = @symbol(i860); |
7929 break; |
7940 break; |
7930 #endif |
7941 #endif |
7931 #ifdef PROCESSOR_INTEL_IA64 |
7942 #ifdef PROCESSOR_INTEL_IA64 |
7932 case PROCESSOR_INTEL_IA64: |
7943 case PROCESSOR_INTEL_IA64: |
7933 s = "ia64"; |
7944 mach = @symbol(ia64); |
7934 break; |
7945 break; |
7935 #endif |
7946 #endif |
7936 #ifdef PROCESSOR_MIPS_R2000 |
7947 #ifdef PROCESSOR_MIPS_R2000 |
7937 case PROCESSOR_MIPS_R2000: |
7948 case PROCESSOR_MIPS_R2000: |
7938 s = "r2000"; |
7949 mach = @symbol(r2000); |
7939 break; |
7950 break; |
7940 #endif |
7951 #endif |
7941 #ifdef PROCESSOR_MIPS_R3000 |
7952 #ifdef PROCESSOR_MIPS_R3000 |
7942 case PROCESSOR_MIPS_R3000: |
7953 case PROCESSOR_MIPS_R3000: |
7943 s = "r3000"; |
7954 mach = @symbol(r3000); |
7944 break; |
7955 break; |
7945 #endif |
7956 #endif |
7946 #ifdef PROCESSOR_MIPS_R4000 |
7957 #ifdef PROCESSOR_MIPS_R4000 |
7947 case PROCESSOR_MIPS_R4000: |
7958 case PROCESSOR_MIPS_R4000: |
7948 s = "r4000"; |
7959 mach = @symbol(r4000); |
7949 break; |
7960 break; |
7950 #endif |
7961 #endif |
7951 #ifdef PROCESSOR_ALPHA_21064 |
7962 #ifdef PROCESSOR_ALPHA_21064 |
7952 case PROCESSOR_ALPHA_21064: |
7963 case PROCESSOR_ALPHA_21064: |
7953 s = "alpha21064"; |
7964 mach = @symbol(alpha21064); |
7954 break; |
7965 break; |
7955 #endif |
7966 #endif |
7956 #ifdef PROCESSOR_ARM720 |
7967 #ifdef PROCESSOR_ARM720 |
7957 case PROCESSOR_ARM720: |
7968 case PROCESSOR_ARM720: |
7958 s = "arm720"; |
7969 mach = @symbol(arm720); |
7959 break; |
7970 break; |
7960 #endif |
7971 #endif |
7961 #ifdef PROCESSOR_ARM820 |
7972 #ifdef PROCESSOR_ARM820 |
7962 case PROCESSOR_ARM820: |
7973 case PROCESSOR_ARM820: |
7963 s = "arm820"; |
7974 mach = @symbol(arm820); |
7964 break; |
7975 break; |
7965 #endif |
7976 #endif |
7966 #ifdef PROCESSOR_ARM920 |
7977 #ifdef PROCESSOR_ARM920 |
7967 case PROCESSOR_ARM920: |
7978 case PROCESSOR_ARM920: |
7968 s = "arm920"; |
7979 mach = @symbol(arm920); |
7969 break; |
7980 break; |
7970 #endif |
7981 #endif |
7971 #ifdef PROCESSOR_ARM_7TDMI |
7982 #ifdef PROCESSOR_ARM_7TDMI |
7972 case PROCESSOR_ARM_7TDMI: |
7983 case PROCESSOR_ARM_7TDMI: |
7973 s = "arm70001"; |
7984 mach = @symbol(arm70001); |
7974 break; |
7985 break; |
7975 #endif |
7986 #endif |
7976 #ifdef PROCESSOR_PPC_601 |
7987 #ifdef PROCESSOR_PPC_601 |
7977 case PROCESSOR_PPC_601: |
7988 case PROCESSOR_PPC_601: |
7978 s = "ppc601"; |
7989 mach = @symbol(ppc601); |
7979 break; |
7990 break; |
7980 #endif |
7991 #endif |
7981 #ifdef PROCESSOR_PPC_603 |
7992 #ifdef PROCESSOR_PPC_603 |
7982 case PROCESSOR_PPC_603: |
7993 case PROCESSOR_PPC_603: |
7983 s = "ppc603"; |
7994 mach = @symbol(ppc603); |
7984 break; |
7995 break; |
7985 #endif |
7996 #endif |
7986 #ifdef PROCESSOR_PPC_604 |
7997 #ifdef PROCESSOR_PPC_604 |
7987 case PROCESSOR_PPC_604: |
7998 case PROCESSOR_PPC_604: |
7988 s = "ppc604"; |
7999 mach = @symbol(ppc604); |
7989 break; |
8000 break; |
7990 #endif |
8001 #endif |
7991 #ifdef PROCESSOR_PPC_620 |
8002 #ifdef PROCESSOR_PPC_620 |
7992 case PROCESSOR_PPC_620: |
8003 case PROCESSOR_PPC_620: |
7993 s = "ppc620"; |
8004 mach = @symbol(ppc620); |
7994 break; |
8005 break; |
7995 #endif |
8006 #endif |
7996 |
8007 |
7997 default: |
8008 default: |
7998 sprintf(vsnBuffer, "%d", sysInfo.dwProcessorType); |
8009 sprintf(vsnBuffer, "%d", sysInfo.dwProcessorType); |
7999 s = vsnBuffer; |
8010 mach = __MKSTRING(vsnBuffer); |
8000 break; |
8011 break; |
8001 } |
8012 } |
8002 mach = __MKSTRING(s); |
|
8003 |
8013 |
8004 numberOfCPUs = __MKUINT(sysInfo.dwNumberOfProcessors); |
8014 numberOfCPUs = __MKUINT(sysInfo.dwNumberOfProcessors); |
8005 %}. |
8015 %}. |
8006 sys isNil ifTrue:[ |
|
8007 sys := self getSystemType. |
|
8008 ]. |
|
8009 node isNil ifTrue:[ |
8016 node isNil ifTrue:[ |
8010 node := self getHostName. |
8017 node := self getHostName. |
8011 ]. |
8018 ]. |
8012 dom isNil ifTrue:[ |
8019 dom isNil ifTrue:[ |
8013 dom := self getDomainName. |
8020 dom := self getDomainName. |
8014 ]. |
|
8015 mach isNil ifTrue:[ |
|
8016 mach := self getCPUType. |
|
8017 ]. |
|
8018 arch isNil ifTrue:[ |
|
8019 arch := 'unknown'. |
|
8020 ]. |
8021 ]. |
8021 |
8022 |
8022 info := IdentityDictionary new. |
8023 info := IdentityDictionary new. |
8023 info at:#system put:sys. |
8024 info at:#system put:sys. |
8024 info at:#node put:node. |
8025 info at:#node put:node. |
8287 " |
8304 " |
8288 OperatingSystem platformName |
8305 OperatingSystem platformName |
8289 " |
8306 " |
8290 |
8307 |
8291 "Modified: 20.6.1997 / 17:37:26 / cg" |
8308 "Modified: 20.6.1997 / 17:37:26 / cg" |
8292 ! |
|
8293 |
|
8294 primGetDomainName |
|
8295 %{ |
|
8296 #if 0 /* not needed */ |
|
8297 HINSTANCE hNetApi32 = LoadLibrary("netapi32.dll"); |
|
8298 DWORD (__stdcall *pfnNetApiBufferFree)(LPVOID Buffer); |
|
8299 DWORD (__stdcall *pfnNetWkstaGetInfo)(LPWSTR servername, DWORD level, void *bufptr); |
|
8300 |
|
8301 if (hNetApi32) { |
|
8302 pfnNetApiBufferFree = (DWORD (__stdcall *)(void *)) GetProcAddress(hNetApi32, "NetApiBufferFree"); |
|
8303 pfnNetWkstaGetInfo = (DWORD (__stdcall *)(LPWSTR, DWORD, void *)) GetProcAddress(hNetApi32, "NetWkstaGetInfo"); |
|
8304 } |
|
8305 |
|
8306 if (hNetApi32 && pfnNetWkstaGetInfo && pfnNetApiBufferFree) { |
|
8307 /* this way is more reliable, in case user has a local account. */ |
|
8308 char dname[256]; |
|
8309 DWORD dnamelen = sizeof(dname); |
|
8310 struct { |
|
8311 DWORD wki100_platform_id; |
|
8312 LPWSTR wki100_computername; |
|
8313 LPWSTR wki100_langroup; |
|
8314 DWORD wki100_ver_major; |
|
8315 DWORD wki100_ver_minor; |
|
8316 } *pwi; |
|
8317 |
|
8318 /* NERR_Success *is* 0*/ |
|
8319 if (0 == pfnNetWkstaGetInfo(NULL, 100, &pwi)) { |
|
8320 if (pwi->wki100_langroup && *(pwi->wki100_langroup)) { |
|
8321 WideCharToMultiByte(CP_ACP, NULL, pwi->wki100_langroup, |
|
8322 -1, (LPSTR)dname, dnamelen, NULL, NULL); |
|
8323 } |
|
8324 else { |
|
8325 WideCharToMultiByte(CP_ACP, NULL, pwi->wki100_computername, |
|
8326 -1, (LPSTR)dname, dnamelen, NULL, NULL); |
|
8327 } |
|
8328 pfnNetApiBufferFree(pwi); |
|
8329 FreeLibrary(hNetApi32); |
|
8330 RETURN (__MKSTRING(dname)); |
|
8331 } |
|
8332 FreeLibrary(hNetApi32); |
|
8333 } else { |
|
8334 /* Win95 doesn't have NetWksta*(), so do it the old way */ |
|
8335 char name[256]; |
|
8336 DWORD size = sizeof(name); |
|
8337 if (hNetApi32) |
|
8338 FreeLibrary(hNetApi32); |
|
8339 if (GetUserName(name,&size)) { |
|
8340 char sid[1024]; |
|
8341 DWORD sidlen = sizeof(sid); |
|
8342 char dname[256]; |
|
8343 DWORD dnamelen = sizeof(dname); |
|
8344 SID_NAME_USE snu; |
|
8345 if (LookupAccountName(NULL, name, (PSID)&sid, &sidlen, |
|
8346 dname, &dnamelen, &snu)) { |
|
8347 RETURN (__MKSTRING(dname)); /* all that for this */ |
|
8348 } |
|
8349 } |
|
8350 } |
|
8351 #endif /* not needed */ |
|
8352 %}. |
|
8353 ^ nil |
|
8354 ! |
|
8355 |
|
8356 primGetHostName |
|
8357 "return the hostname we are running on - if there is |
|
8358 a HOST environment variable, we are much faster here ... |
|
8359 Notice: |
|
8360 not all systems support this; on some, 'unknown' is returned." |
|
8361 |
|
8362 |name| |
|
8363 |
|
8364 %{ /* STACK: 2048 */ |
|
8365 #if defined(HAS_GETHOSTNAME) |
|
8366 char buffer[256]; |
|
8367 |
|
8368 if (gethostname(buffer, sizeof(buffer)) == 0) { |
|
8369 name = __MKSTRING(buffer); |
|
8370 } |
|
8371 #else |
|
8372 char buffer[128]; |
|
8373 DWORD buffSize = sizeof(buffer); |
|
8374 |
|
8375 if (GetComputerName(buffer, &buffSize) == TRUE) { |
|
8376 name = __MKSTRING(buffer); |
|
8377 } |
|
8378 #endif |
|
8379 %}. |
|
8380 name isNil ifTrue:[ |
|
8381 name := self getEnvironment:'HOST'. |
|
8382 name isNil ifTrue:[ |
|
8383 name := self getEnvironment:'HOSTNAME'. |
|
8384 name isNil ifTrue:[ |
|
8385 name := self getEnvironment:'COMPUTERNAME'. |
|
8386 name isNil ifTrue:[ |
|
8387 'Win32OperatingSystem [warning]: cannot find out hostname' errorPrintCR. |
|
8388 name := 'unknown'. |
|
8389 ] |
|
8390 ] |
|
8391 ] |
|
8392 ]. |
|
8393 ^ name |
|
8394 |
|
8395 " |
|
8396 OperatingSystem primGetHostName |
|
8397 " |
|
8398 ! |
8309 ! |
8399 |
8310 |
8400 randomBytesInto:bufferOrInteger |
8311 randomBytesInto:bufferOrInteger |
8401 "If bufferOrInteger is a String or a ByteArray, |
8312 "If bufferOrInteger is a String or a ByteArray, |
8402 fill a given buffer with random bytes from the RtlGenRandom function |
8313 fill a given buffer with random bytes from the RtlGenRandom function |