Win32OperatingSystem.st
changeset 13742 cfb6a76de348
parent 13618 9af72c855037
child 13778 8e34483d10dd
equal deleted inserted replaced
13741:cc55df8d23dc 13742:cfb6a76de348
     1 "
     1 "
     2  COPYRIGHT (c) 1988 by Claus Gittinger
     2  COPYRIGHT (c) 1988 by Claus Gittinger
     3  COPYRIGHT (c) 1998-2004 by eXept Software AG
     3  COPYRIGHT (c) 1998-2004 by eXept Software AG
     4               All Rights Reserved
     4 	      All Rights Reserved
     5 
     5 
     6  This software is furnished under a license and may be used
     6  This software is furnished under a license and may be used
     7  only in accordance with the terms of that license and with the
     7  only in accordance with the terms of that license and with the
     8  inclusion of the above copyright notice.   This software may not
     8  inclusion of the above copyright notice.   This software may not
     9  be provided or otherwise made available to, or used by, any
     9  be provided or otherwise made available to, or used by, any
    11  hereby transferred.
    11  hereby transferred.
    12 "
    12 "
    13 "{ Package: 'stx:libbasic' }"
    13 "{ Package: 'stx:libbasic' }"
    14 
    14 
    15 AbstractOperatingSystem subclass:#Win32OperatingSystem
    15 AbstractOperatingSystem subclass:#Win32OperatingSystem
    16         instanceVariableNames:''
    16 	instanceVariableNames:''
    17         classVariableNames:'Initialized HostName DomainName CurrentDirectory'
    17 	classVariableNames:'Initialized HostName DomainName CurrentDirectory'
    18         poolDictionaries:'Win32Constants'
    18 	poolDictionaries:'Win32Constants'
    19         category:'OS-Windows'
    19 	category:'OS-Windows'
    20 !
    20 !
    21 
    21 
    22 ByteArray variableByteSubclass:#DevModeStructure
    22 ByteArray variableByteSubclass:#DevModeStructure
    23         instanceVariableNames:''
    23 	instanceVariableNames:''
    24         classVariableNames:''
    24 	classVariableNames:''
    25         poolDictionaries:''
    25 	poolDictionaries:''
    26         privateIn:Win32OperatingSystem
    26 	privateIn:Win32OperatingSystem
    27 !
    27 !
    28 
    28 
    29 ByteArray variableByteSubclass:#DocInfoStructure
    29 ByteArray variableByteSubclass:#DocInfoStructure
    30         instanceVariableNames:''
    30 	instanceVariableNames:''
    31         classVariableNames:''
    31 	classVariableNames:''
    32         poolDictionaries:''
    32 	poolDictionaries:''
    33         privateIn:Win32OperatingSystem
    33 	privateIn:Win32OperatingSystem
    34 !
    34 !
    35 
    35 
    36 Object subclass:#FileStatusInfo
    36 Object subclass:#FileStatusInfo
    37         instanceVariableNames:'type mode uid gid size id accessed modified created statusChanged
    37 	instanceVariableNames:'type mode uid gid size id accessed modified created statusChanged
    38                 sourcePath linkTargetPath fullPathName alternativePathName'
    38 		sourcePath linkTargetPath fullPathName alternativePathName'
    39         classVariableNames:''
    39 	classVariableNames:''
    40         poolDictionaries:''
    40 	poolDictionaries:''
    41         privateIn:Win32OperatingSystem
    41 	privateIn:Win32OperatingSystem
    42 !
    42 !
    43 
    43 
    44 Object subclass:#OSProcessStatus
    44 Object subclass:#OSProcessStatus
    45         instanceVariableNames:'pid status code core'
    45 	instanceVariableNames:'pid status code core'
    46         classVariableNames:''
    46 	classVariableNames:''
    47         poolDictionaries:''
    47 	poolDictionaries:''
    48         privateIn:Win32OperatingSystem
    48 	privateIn:Win32OperatingSystem
    49 !
    49 !
    50 
    50 
    51 Object subclass:#PerformanceData
    51 Object subclass:#PerformanceData
    52         instanceVariableNames:'objectArray perfTime perfFreq perfTime100nSec'
    52 	instanceVariableNames:'objectArray perfTime perfFreq perfTime100nSec'
    53         classVariableNames:'PerformanceText CounterIndexTextDictionary
    53 	classVariableNames:'PerformanceText CounterIndexTextDictionary
    54                 HelpIndexTextDictionary'
    54 		HelpIndexTextDictionary'
    55         poolDictionaries:''
    55 	poolDictionaries:''
    56         privateIn:Win32OperatingSystem
    56 	privateIn:Win32OperatingSystem
    57 !
    57 !
    58 
    58 
    59 Object subclass:#Abstract
    59 Object subclass:#Abstract
    60         instanceVariableNames:'lastData lastTimestamp cachedResults'
    60 	instanceVariableNames:'lastData lastTimestamp cachedResults'
    61         classVariableNames:''
    61 	classVariableNames:''
    62         poolDictionaries:''
    62 	poolDictionaries:''
    63         privateIn:Win32OperatingSystem::PerformanceData
    63 	privateIn:Win32OperatingSystem::PerformanceData
    64 !
    64 !
    65 
    65 
    66 Win32OperatingSystem::PerformanceData::Abstract subclass:#DiskIO
    66 Win32OperatingSystem::PerformanceData::Abstract subclass:#DiskIO
    67         instanceVariableNames:''
    67 	instanceVariableNames:''
    68         classVariableNames:'TheOneAndOnlyInstance'
    68 	classVariableNames:'TheOneAndOnlyInstance'
    69         poolDictionaries:''
    69 	poolDictionaries:''
    70         privateIn:Win32OperatingSystem::PerformanceData
    70 	privateIn:Win32OperatingSystem::PerformanceData
    71 !
    71 !
    72 
    72 
    73 Win32OperatingSystem::PerformanceData::Abstract subclass:#Global
    73 Win32OperatingSystem::PerformanceData::Abstract subclass:#Global
    74         instanceVariableNames:''
    74 	instanceVariableNames:''
    75         classVariableNames:'TheOneAndOnlyInstance'
    75 	classVariableNames:'TheOneAndOnlyInstance'
    76         poolDictionaries:''
    76 	poolDictionaries:''
    77         privateIn:Win32OperatingSystem::PerformanceData
    77 	privateIn:Win32OperatingSystem::PerformanceData
    78 !
    78 !
    79 
    79 
    80 Win32OperatingSystem::PerformanceData::Abstract subclass:#Memory
    80 Win32OperatingSystem::PerformanceData::Abstract subclass:#Memory
    81         instanceVariableNames:''
    81 	instanceVariableNames:''
    82         classVariableNames:'TheOneAndOnlyInstance'
    82 	classVariableNames:'TheOneAndOnlyInstance'
    83         poolDictionaries:''
    83 	poolDictionaries:''
    84         privateIn:Win32OperatingSystem::PerformanceData
    84 	privateIn:Win32OperatingSystem::PerformanceData
    85 !
    85 !
    86 
    86 
    87 Win32OperatingSystem::PerformanceData::Abstract subclass:#Network
    87 Win32OperatingSystem::PerformanceData::Abstract subclass:#Network
    88         instanceVariableNames:''
    88 	instanceVariableNames:''
    89         classVariableNames:'TheOneAndOnlyInstance'
    89 	classVariableNames:'TheOneAndOnlyInstance'
    90         poolDictionaries:''
    90 	poolDictionaries:''
    91         privateIn:Win32OperatingSystem::PerformanceData
    91 	privateIn:Win32OperatingSystem::PerformanceData
    92 !
    92 !
    93 
    93 
    94 Win32OperatingSystem::PerformanceData::Abstract subclass:#Process
    94 Win32OperatingSystem::PerformanceData::Abstract subclass:#Process
    95         instanceVariableNames:''
    95 	instanceVariableNames:''
    96         classVariableNames:'TheOneAndOnlyInstance'
    96 	classVariableNames:'TheOneAndOnlyInstance'
    97         poolDictionaries:''
    97 	poolDictionaries:''
    98         privateIn:Win32OperatingSystem::PerformanceData
    98 	privateIn:Win32OperatingSystem::PerformanceData
    99 !
    99 !
   100 
   100 
   101 Win32OperatingSystem::PerformanceData::Abstract subclass:#Processor
   101 Win32OperatingSystem::PerformanceData::Abstract subclass:#Processor
   102         instanceVariableNames:''
   102 	instanceVariableNames:''
   103         classVariableNames:'TheOneAndOnlyInstance'
   103 	classVariableNames:'TheOneAndOnlyInstance'
   104         poolDictionaries:''
   104 	poolDictionaries:''
   105         privateIn:Win32OperatingSystem::PerformanceData
   105 	privateIn:Win32OperatingSystem::PerformanceData
   106 !
   106 !
   107 
   107 
   108 ByteArray variableByteSubclass:#PrinterInfo2Structure
   108 ByteArray variableByteSubclass:#PrinterInfo2Structure
   109         instanceVariableNames:''
   109 	instanceVariableNames:''
   110         classVariableNames:''
   110 	classVariableNames:''
   111         poolDictionaries:''
   111 	poolDictionaries:''
   112         privateIn:Win32OperatingSystem
   112 	privateIn:Win32OperatingSystem
   113 !
   113 !
   114 
   114 
   115 Object subclass:#RegistryEntry
   115 Object subclass:#RegistryEntry
   116         instanceVariableNames:'path handle'
   116 	instanceVariableNames:'path handle'
   117         classVariableNames:'Lobby HKEY_CLASSES_ROOT HKEY_CURRENT_USER HKEY_LOCAL_MACHINE
   117 	classVariableNames:'Lobby HKEY_CLASSES_ROOT HKEY_CURRENT_USER HKEY_LOCAL_MACHINE
   118                 HKEY_USERS HKEY_PERFORMANCE_DATA HKEY_CURRENT_CONFIG
   118 		HKEY_USERS HKEY_PERFORMANCE_DATA HKEY_CURRENT_CONFIG
   119                 HKEY_DYN_DATA HKEY_PERFORMANCE_TEXT HKEY_PERFORMANCE_NLSTEXT'
   119 		HKEY_DYN_DATA HKEY_PERFORMANCE_TEXT HKEY_PERFORMANCE_NLSTEXT'
   120         poolDictionaries:''
   120 	poolDictionaries:''
   121         privateIn:Win32OperatingSystem
   121 	privateIn:Win32OperatingSystem
   122 !
   122 !
   123 
   123 
   124 ByteArray variableByteSubclass:#TextMetricsStructure
   124 ByteArray variableByteSubclass:#TextMetricsStructure
   125         instanceVariableNames:''
   125 	instanceVariableNames:''
   126         classVariableNames:''
   126 	classVariableNames:''
   127         poolDictionaries:''
   127 	poolDictionaries:''
   128         privateIn:Win32OperatingSystem
   128 	privateIn:Win32OperatingSystem
   129 !
   129 !
   130 
   130 
   131 OSHandle subclass:#Win32IOHandle
   131 OSHandle subclass:#Win32IOHandle
   132         instanceVariableNames:''
   132 	instanceVariableNames:''
   133         classVariableNames:'Lobby'
   133 	classVariableNames:'Lobby'
   134         poolDictionaries:''
   134 	poolDictionaries:''
   135         privateIn:Win32OperatingSystem
   135 	privateIn:Win32OperatingSystem
   136 !
   136 !
   137 
   137 
   138 Win32Handle subclass:#Win32PrinterHandle
   138 Win32Handle subclass:#Win32PrinterHandle
   139         instanceVariableNames:''
   139 	instanceVariableNames:''
   140         classVariableNames:''
   140 	classVariableNames:''
   141         poolDictionaries:''
   141 	poolDictionaries:''
   142         privateIn:Win32OperatingSystem
   142 	privateIn:Win32OperatingSystem
   143 !
   143 !
   144 
   144 
   145 Win32Handle subclass:#Win32ProcessHandle
   145 Win32Handle subclass:#Win32ProcessHandle
   146         instanceVariableNames:'pid'
   146 	instanceVariableNames:'pid'
   147         classVariableNames:''
   147 	classVariableNames:''
   148         poolDictionaries:''
   148 	poolDictionaries:''
   149         privateIn:Win32OperatingSystem
   149 	privateIn:Win32OperatingSystem
   150 !
   150 !
   151 
   151 
   152 Win32OperatingSystem::Win32IOHandle subclass:#Win32SerialPortHandle
   152 Win32OperatingSystem::Win32IOHandle subclass:#Win32SerialPortHandle
   153         instanceVariableNames:''
   153 	instanceVariableNames:''
   154         classVariableNames:''
   154 	classVariableNames:''
   155         poolDictionaries:''
   155 	poolDictionaries:''
   156         privateIn:Win32OperatingSystem
   156 	privateIn:Win32OperatingSystem
   157 !
   157 !
   158 
   158 
   159 Win32OperatingSystem::Win32IOHandle subclass:#Win32SocketHandle
   159 Win32OperatingSystem::Win32IOHandle subclass:#Win32SocketHandle
   160         instanceVariableNames:''
   160 	instanceVariableNames:''
   161         classVariableNames:''
   161 	classVariableNames:''
   162         poolDictionaries:''
   162 	poolDictionaries:''
   163         privateIn:Win32OperatingSystem
   163 	privateIn:Win32OperatingSystem
   164 !
   164 !
   165 
   165 
   166 ByteArray variableByteSubclass:#WinPointStructure
   166 ByteArray variableByteSubclass:#WinPointStructure
   167         instanceVariableNames:''
   167 	instanceVariableNames:''
   168         classVariableNames:''
   168 	classVariableNames:''
   169         poolDictionaries:''
   169 	poolDictionaries:''
   170         privateIn:Win32OperatingSystem
   170 	privateIn:Win32OperatingSystem
   171 !
   171 !
   172 
   172 
   173 !Win32OperatingSystem primitiveDefinitions!
   173 !Win32OperatingSystem primitiveDefinitions!
   174 %{
   174 %{
   175 
   175 
   483 
   483 
   484     tv.tv_sec  = 0;
   484     tv.tv_sec  = 0;
   485     tv.tv_usec = 0;
   485     tv.tv_usec = 0;
   486 
   486 
   487     if (readMode) {
   487     if (readMode) {
   488         n = select (sock + 1, & fds, NULL, NULL, & tv);
   488 	n = select (sock + 1, & fds, NULL, NULL, & tv);
   489     } else {
   489     } else {
   490         n = select (sock + 1, NULL, & fds, NULL, & tv);
   490 	n = select (sock + 1, NULL, & fds, NULL, & tv);
   491     }
   491     }
   492 
   492 
   493     if (n == 0) {
   493     if (n == 0) {
   494         return (0);
   494 	return (0);
   495     }
   495     }
   496 
   496 
   497     if (n > 0) {
   497     if (n > 0) {
   498         return ((FD_ISSET (sock, & fds)) ? 1 : 0);
   498 	return ((FD_ISSET (sock, & fds)) ? 1 : 0);
   499     }
   499     }
   500 
   500 
   501     winErrNo = WSAGetLastError();
   501     winErrNo = WSAGetLastError();
   502     switch (winErrNo) {
   502     switch (winErrNo) {
   503         case WSAENOTSOCK:
   503 	case WSAENOTSOCK:
   504             if (readMode) {
   504 	    if (readMode) {
   505 
   505 
   506                 DWORD  w = 0;
   506 		DWORD  w = 0;
   507                 HANDLE h = (HANDLE) _get_osfhandle (aFD);
   507 		HANDLE h = (HANDLE) _get_osfhandle (aFD);
   508 
   508 
   509                 if (PeekNamedPipe (h, 0, 0, 0, & w, 0)) {
   509 		if (PeekNamedPipe (h, 0, 0, 0, & w, 0)) {
   510                     if( !__isWinNT || w > 0 )
   510 		    if( !__isWinNT || w > 0 )
   511                         return (1);
   511 			return (1);
   512 
   512 
   513                     return (0);
   513 		    return (0);
   514                 }
   514 		}
   515 #if 0
   515 #if 0
   516                 console_fprintf(stderr, "_canAccessIOWithoutBlocking non Socket\n");
   516 		console_fprintf(stderr, "_canAccessIOWithoutBlocking non Socket\n");
   517 #endif
   517 #endif
   518                 return (-1);
   518 		return (-1);
   519             }
   519 	    }
   520             /* in writeMode we return allways true for none-sockets */
   520 	    /* in writeMode we return allways true for none-sockets */
   521             return (1);
   521 	    return (1);
   522 
   522 
   523         case WSAEINPROGRESS:
   523 	case WSAEINPROGRESS:
   524         case WSAEWOULDBLOCK:
   524 	case WSAEWOULDBLOCK:
   525             return (0);
   525 	    return (0);
   526 
   526 
   527         default:
   527 	default:
   528             console_fprintf(stderr, "_canAccessIOWithoutBlocking -> %d (0x%x)\n", winErrNo, winErrNo);
   528 	    console_fprintf(stderr, "_canAccessIOWithoutBlocking -> %d (0x%x)\n", winErrNo, winErrNo);
   529             return (-1);
   529 	    return (-1);
   530     }
   530     }
   531 
   531 
   532     /* not reached */
   532     /* not reached */
   533     return (0);
   533     return (0);
   534 }
   534 }
   546 __get_functionAddress(HINSTANCE *pLibHandle, char *libraryName, char *functionName)
   546 __get_functionAddress(HINSTANCE *pLibHandle, char *libraryName, char *functionName)
   547 {
   547 {
   548     FARPROC entry;
   548     FARPROC entry;
   549 
   549 
   550     if (*pLibHandle == NULL) {
   550     if (*pLibHandle == NULL) {
   551         *pLibHandle = LoadLibrary(libraryName);
   551 	*pLibHandle = LoadLibrary(libraryName);
   552     }
   552     }
   553     entry = GetProcAddress(*pLibHandle, functionName);
   553     entry = GetProcAddress(*pLibHandle, functionName);
   554     return entry;
   554     return entry;
   555 }
   555 }
   556 
   556 
   609 
   609 
   610 copyright
   610 copyright
   611 "
   611 "
   612  COPYRIGHT (c) 1988 by Claus Gittinger
   612  COPYRIGHT (c) 1988 by Claus Gittinger
   613  COPYRIGHT (c) 1998-2004 by eXept Software AG
   613  COPYRIGHT (c) 1998-2004 by eXept Software AG
   614               All Rights Reserved
   614 	      All Rights Reserved
   615 
   615 
   616  This software is furnished under a license and may be used
   616  This software is furnished under a license and may be used
   617  only in accordance with the terms of that license and with the
   617  only in accordance with the terms of that license and with the
   618  inclusion of the above copyright notice.   This software may not
   618  inclusion of the above copyright notice.   This software may not
   619  be provided or otherwise made available to, or used by, any
   619  be provided or otherwise made available to, or used by, any
   639      able to get down to a select or fork system call easily (at least on Unix systems).
   639      able to get down to a select or fork system call easily (at least on Unix systems).
   640      You decide - portability vs. functionality)
   640      You decide - portability vs. functionality)
   641 
   641 
   642     [Class variables:]
   642     [Class variables:]
   643 
   643 
   644         HostName        <String>        remembered hostname
   644 	HostName        <String>        remembered hostname
   645 
   645 
   646         DomainName      <String>        remembered domainname
   646 	DomainName      <String>        remembered domainname
   647 
   647 
   648         CurrentDirectory <String>       remembered currentDirectories path
   648 	CurrentDirectory <String>       remembered currentDirectories path
   649 
   649 
   650     [author:]
   650     [author:]
   651         Claus Gittinger (initial version & cleanup)
   651 	Claus Gittinger (initial version & cleanup)
   652         Manfred Dierolf (many features)
   652 	Manfred Dierolf (many features)
   653 
   653 
   654     [see also:]
   654     [see also:]
   655         OSProcessStatus
   655 	OSProcessStatus
   656         Filename Date Time
   656 	Filename Date Time
   657         ExternalStream FileStream PipeStream Socket
   657 	ExternalStream FileStream PipeStream Socket
   658 "
   658 "
   659 !
   659 !
   660 
   660 
   661 examples
   661 examples
   662 "
   662 "
   663   various queries
   663   various queries
   664                                                                 [exBegin]
   664 								[exBegin]
   665     Transcript
   665     Transcript
   666         showCR:'hello ' , (OperatingSystem getLoginName)
   666 	showCR:'hello ' , (OperatingSystem getLoginName)
   667                                                                 [exEnd]
   667 								[exEnd]
   668 
   668 
   669                                                                 [exBegin]
   669 								[exBegin]
   670     OperatingSystem isUNIXlike ifTrue:[
   670     OperatingSystem isUNIXlike ifTrue:[
   671         Transcript showCR:'this is some UNIX-like OS'
   671 	Transcript showCR:'this is some UNIX-like OS'
   672     ] ifFalse:[
   672     ] ifFalse:[
   673         Transcript showCR:'this OS is not UNIX-like'
   673 	Transcript showCR:'this OS is not UNIX-like'
   674     ]
   674     ]
   675                                                                 [exEnd]
   675 								[exEnd]
   676 
   676 
   677                                                                 [exBegin]
   677 								[exBegin]
   678     Transcript
   678     Transcript
   679         showCR:'this machine is called ' , OperatingSystem getHostName
   679 	showCR:'this machine is called ' , OperatingSystem getHostName
   680                                                                 [exEnd]
   680 								[exEnd]
   681 
   681 
   682                                                                 [exBegin]
   682 								[exBegin]
   683     Transcript
   683     Transcript
   684         showCR:('this machine is in the '
   684 	showCR:('this machine is in the '
   685                , OperatingSystem getDomainName
   685 	       , OperatingSystem getDomainName
   686                , ' domain')
   686 	       , ' domain')
   687                                                                 [exEnd]
   687 								[exEnd]
   688 
   688 
   689                                                                 [exBegin]
   689 								[exBegin]
   690     Transcript
   690     Transcript
   691         showCR:('this machine''s CPU is a '
   691 	showCR:('this machine''s CPU is a '
   692                , OperatingSystem getCPUType
   692 	       , OperatingSystem getCPUType
   693                )
   693 	       )
   694                                                                 [exEnd]
   694 								[exEnd]
   695 
   695 
   696                                                                 [exBegin]
   696 								[exBegin]
   697     Transcript showCR:'executing ls command ...'.
   697     Transcript showCR:'executing ls command ...'.
   698     OperatingSystem executeCommand:'ls'.
   698     OperatingSystem executeCommand:'ls'.
   699     Transcript showCR:'... done.'.
   699     Transcript showCR:'... done.'.
   700                                                                 [exEnd]
   700 								[exEnd]
   701 
   701 
   702   locking a file
   702   locking a file
   703   (should be executed on two running smalltalks - not in two threads):
   703   (should be executed on two running smalltalks - not in two threads):
   704                                                                 [exBegin]
   704 								[exBegin]
   705     |f|
   705     |f|
   706 
   706 
   707     f := 'testFile' asFilename readWriteStream.
   707     f := 'testFile' asFilename readWriteStream.
   708 
   708 
   709     10 timesRepeat:[
   709     10 timesRepeat:[
   710         'about to lock ...' printCR.
   710 	'about to lock ...' printCR.
   711         [
   711 	[
   712           OperatingSystem
   712 	  OperatingSystem
   713             lockFD:(f fileDescriptor)
   713 	    lockFD:(f fileDescriptor)
   714             shared:false
   714 	    shared:false
   715             blocking:false
   715 	    blocking:false
   716         ] whileFalse:[
   716 	] whileFalse:[
   717             'process ' print. OperatingSystem getProcessId print. ' is waiting' printCR.
   717 	    'process ' print. OperatingSystem getProcessId print. ' is waiting' printCR.
   718             Delay waitForSeconds:1
   718 	    Delay waitForSeconds:1
   719         ].
   719 	].
   720         'LOCKED ...' printCR.
   720 	'LOCKED ...' printCR.
   721         Delay waitForSeconds:10.
   721 	Delay waitForSeconds:10.
   722         'unlock ...' printCR.
   722 	'unlock ...' printCR.
   723         (OperatingSystem
   723 	(OperatingSystem
   724             unlockFD:(f fileDescriptor)) printCR.
   724 	    unlockFD:(f fileDescriptor)) printCR.
   725         Delay waitForSeconds:3.
   725 	Delay waitForSeconds:3.
   726     ]
   726     ]
   727                                                                 [exBegin]
   727 								[exBegin]
   728 "
   728 "
   729 ! !
   729 ! !
   730 
   730 
   731 !Win32OperatingSystem class methodsFor:'initialization'!
   731 !Win32OperatingSystem class methodsFor:'initialization'!
   732 
   732 
   734 %{
   734 %{
   735     HRESULT hres;
   735     HRESULT hres;
   736 
   736 
   737     if( ! coInitialized ) {
   737     if( ! coInitialized ) {
   738 #ifdef NO_NT4_0_COMPATIBILITY
   738 #ifdef NO_NT4_0_COMPATIBILITY
   739         FARPROC CoInitializeEx_entry = (FARPROC) CoInitializeEx;
   739 	FARPROC CoInitializeEx_entry = (FARPROC) CoInitializeEx;
   740 #else
   740 #else
   741         FARPROC CoInitializeEx_entry = __get_ole32_functionAddress("CoInitializeEx");
   741 	FARPROC CoInitializeEx_entry = __get_ole32_functionAddress("CoInitializeEx");
   742 #endif /* NO_NT4_0_COMPATIBILITY */
   742 #endif /* NO_NT4_0_COMPATIBILITY */
   743         hres = (*CoInitializeEx_entry)(NULL, COINIT_MULTITHREADED);
   743 	hres = (*CoInitializeEx_entry)(NULL, COINIT_MULTITHREADED);
   744         if (! SUCCEEDED(hres)) {
   744 	if (! SUCCEEDED(hres)) {
   745             console_fprintf(stderr, "OperatingSystem [info]: Could not open the COM library hres = %08x\n", hres );
   745 	    console_fprintf(stderr, "OperatingSystem [info]: Could not open the COM library hres = %08x\n", hres );
   746             goto error;
   746 	    goto error;
   747         }
   747 	}
   748         coInitialized = 1;
   748 	coInitialized = 1;
   749 #ifdef COM_DEBUG
   749 #ifdef COM_DEBUG
   750         console_fprintf(stderr, "OperatingSystem [info]: COM initialized\n" );
   750 	console_fprintf(stderr, "OperatingSystem [info]: COM initialized\n" );
   751 #endif
   751 #endif
   752     }
   752     }
   753     RETURN (self );
   753     RETURN (self );
   754 
   754 
   755 error: ;
   755 error: ;
   767     memset(&osvi, 0, sizeof(OSVERSIONINFO));
   767     memset(&osvi, 0, sizeof(OSVERSIONINFO));
   768     osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
   768     osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
   769     GetVersionEx (&osvi);
   769     GetVersionEx (&osvi);
   770 
   770 
   771     if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
   771     if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
   772         __isWinNT = 1;
   772 	__isWinNT = 1;
   773     } else {
   773     } else {
   774         __isWinNT = 0;
   774 	__isWinNT = 0;
   775     }
   775     }
   776 %}.
   776 %}.
   777 !
   777 !
   778 
   778 
   779 initialize
   779 initialize
   780     "initialize the class"
   780     "initialize the class"
   781 
   781 
   782     "/ attention: must be ok to be called twice during startup.
   782     "/ attention: must be ok to be called twice during startup.
   783     Initialized == nil ifTrue:[
   783     Initialized == nil ifTrue:[
   784         Initialized := true.
   784 	Initialized := true.
   785         ObjectMemory addDependent:self.
   785 	ObjectMemory addDependent:self.
   786         HostName := nil.
   786 	HostName := nil.
   787         DomainName := nil.
   787 	DomainName := nil.
   788         LastErrorNumber := nil.
   788 	LastErrorNumber := nil.
   789         PipeFailed := false.
   789 	PipeFailed := false.
   790         self initOSType.
   790 	self initOSType.
   791         self coInitialize.
   791 	self coInitialize.
   792     ].
   792     ].
   793 
   793 
   794     "Modified: 13.9.1997 / 10:47:32 / cg"
   794     "Modified: 13.9.1997 / 10:47:32 / cg"
   795 !
   795 !
   796 
   796 
   797 update:something with:aParameter from:changedObject
   797 update:something with:aParameter from:changedObject
   798     "catch image restart and flush some cached data"
   798     "catch image restart and flush some cached data"
   799 
   799 
   800     something == #earlyRestart ifTrue:[
   800     something == #earlyRestart ifTrue:[
   801         "
   801 	"
   802          flush cached data
   802 	 flush cached data
   803         "
   803 	"
   804         HostName := nil.
   804 	HostName := nil.
   805         DomainName := nil.
   805 	DomainName := nil.
   806         LastErrorNumber := nil.
   806 	LastErrorNumber := nil.
   807         PipeFailed := false.
   807 	PipeFailed := false.
   808         self initOSType.
   808 	self initOSType.
   809         self coInitialize.
   809 	self coInitialize.
   810     ]
   810     ]
   811 
   811 
   812     "Modified: 22.4.1996 / 13:10:43 / cg"
   812     "Modified: 22.4.1996 / 13:10:43 / cg"
   813     "Created: 15.6.1996 / 15:22:37 / cg"
   813     "Created: 15.6.1996 / 15:22:37 / cg"
   814     "Modified: 7.1.1997 / 19:36:11 / stefan"
   814     "Modified: 7.1.1997 / 19:36:11 / stefan"
  1398     extern char *__win32_getLogFilename();
  1398     extern char *__win32_getLogFilename();
  1399     char *lp;
  1399     char *lp;
  1400 
  1400 
  1401     lp = __win32_getLogFilename();
  1401     lp = __win32_getLogFilename();
  1402     if (lp) {
  1402     if (lp) {
  1403         ret = __MKSTRING(lp);
  1403 	ret = __MKSTRING(lp);
  1404     }
  1404     }
  1405 %}.
  1405 %}.
  1406     ^ ret
  1406     ^ ret
  1407 
  1407 
  1408     "
  1408     "
  1416      which write their log info into a file named xxx_log_xxx.log"
  1416      which write their log info into a file named xxx_log_xxx.log"
  1417 
  1417 
  1418     |logFilePath|
  1418     |logFilePath|
  1419 
  1419 
  1420     aFilenameOrNil notNil ifTrue:[
  1420     aFilenameOrNil notNil ifTrue:[
  1421         logFilePath := aFilenameOrNil asFilename pathName
  1421 	logFilePath := aFilenameOrNil asFilename pathName
  1422     ].
  1422     ].
  1423 
  1423 
  1424 %{
  1424 %{
  1425     extern void __win32_setLogFile();
  1425     extern void __win32_setLogFile();
  1426 
  1426 
  1427     if (__isStringLike(logFilePath)) {
  1427     if (__isStringLike(logFilePath)) {
  1428         __win32_setLogFile(__stringVal(logFilePath));
  1428 	__win32_setLogFile(__stringVal(logFilePath));
  1429     } else {
  1429     } else {
  1430         __win32_setLogFile( NULL );
  1430 	__win32_setLogFile( NULL );
  1431     }
  1431     }
  1432 %}
  1432 %}
  1433 
  1433 
  1434     "
  1434     "
  1435      Win32OperatingSystem win32LogFile:'myLog.log'
  1435      Win32OperatingSystem win32LogFile:'myLog.log'
  1444 ! !
  1444 ! !
  1445 
  1445 
  1446 !Win32OperatingSystem class methodsFor:'clipboard'!
  1446 !Win32OperatingSystem class methodsFor:'clipboard'!
  1447 
  1447 
  1448 clipboardContainsBitmap
  1448 clipboardContainsBitmap
  1449         "Answer whether the clipboard contains a bitmap."
  1449 	"Answer whether the clipboard contains a bitmap."
  1450 
  1450 
  1451     ^self clipboardContainsFormat: 2 "CfBitmap"
  1451     ^self clipboardContainsFormat: 2 "CfBitmap"
  1452 !
  1452 !
  1453 
  1453 
  1454 clipboardContainsFormat: aCfConstant
  1454 clipboardContainsFormat: aCfConstant
  1455         "Answer true if the clipboard contains data in
  1455 	"Answer true if the clipboard contains data in
  1456          the format described by aCfConstant.  "
  1456 	 the format described by aCfConstant.  "
  1457 
  1457 
  1458     ^self primIsClipboardFormatAvailable: aCfConstant
  1458     ^self primIsClipboardFormatAvailable: aCfConstant
  1459 !
  1459 !
  1460 
  1460 
  1461 closeClipboard
  1461 closeClipboard
  1464     result ifFalse: [ ^self error].
  1464     result ifFalse: [ ^self error].
  1465     ^result
  1465     ^result
  1466 !
  1466 !
  1467 
  1467 
  1468 emptyClipboard
  1468 emptyClipboard
  1469         "Private - empty the clipboard. Note: it must be opened first."
  1469 	"Private - empty the clipboard. Note: it must be opened first."
  1470     | result |
  1470     | result |
  1471     result := self primEmptyClipboard.
  1471     result := self primEmptyClipboard.
  1472     result ifFalse: [ ^self error].
  1472     result ifFalse: [ ^self error].
  1473     ^result
  1473     ^result
  1474 !
  1474 !
  1525     <apicall: ulongReturn "SetClipboardData" (ulong ulong) module: "user32.dll" >
  1525     <apicall: ulongReturn "SetClipboardData" (ulong ulong) module: "user32.dll" >
  1526     ^self primitiveFailed
  1526     ^self primitiveFailed
  1527 !
  1527 !
  1528 
  1528 
  1529 setBitmapToClipboard: aBitmap
  1529 setBitmapToClipboard: aBitmap
  1530         "Copy aBitmap to the clipboard."
  1530 	"Copy aBitmap to the clipboard."
  1531     | handle |
  1531     | handle |
  1532     aBitmap isNil ifTrue:[ ^nil ].
  1532     aBitmap isNil ifTrue:[ ^nil ].
  1533     aBitmap id isNil ifTrue:[aBitmap onDevice: Screen current].
  1533     aBitmap id isNil ifTrue:[aBitmap onDevice: Screen current].
  1534     handle := aBitmap id.
  1534     handle := aBitmap id.
  1535     handle isNil ifTrue: [ ^nil ].
  1535     handle isNil ifTrue: [ ^nil ].
  1537     self emptyClipboard.
  1537     self emptyClipboard.
  1538     self setClipboardData: 2 "CfBitmap" hMem: handle.
  1538     self setClipboardData: 2 "CfBitmap" hMem: handle.
  1539     self closeClipboard
  1539     self closeClipboard
  1540 
  1540 
  1541     "
  1541     "
  1542         self setBitmapToClipboard: Image fromUser
  1542 	self setBitmapToClipboard: Image fromUser
  1543     "
  1543     "
  1544 !
  1544 !
  1545 
  1545 
  1546 setClipboardData: aCfConstant hMem: aMemHandle
  1546 setClipboardData: aCfConstant hMem: aMemHandle
  1547     |result|
  1547     |result|
  1584 
  1584 
  1585     if (__isSmallInteger(errNr) || (__unsignedLongIntVal(errNr) > 0)) {
  1585     if (__isSmallInteger(errNr) || (__unsignedLongIntVal(errNr) > 0)) {
  1586       int __eno = __unsignedLongIntVal(errNr);
  1586       int __eno = __unsignedLongIntVal(errNr);
  1587 
  1587 
  1588       if (__isWIN32Error(__eno)) {
  1588       if (__isWIN32Error(__eno)) {
  1589         switch (__eno & 0xFFFF) {
  1589 	switch (__eno & 0xFFFF) {
  1590             /*
  1590 	    /*
  1591              * WIN32 GetLastError returns
  1591 	     * WIN32 GetLastError returns
  1592              */
  1592 	     */
  1593             case ERROR_INVALID_FUNCTION:
  1593 	    case ERROR_INVALID_FUNCTION:
  1594                 sym = @symbol(ERROR_INVALID_FUNCTION);
  1594 		sym = @symbol(ERROR_INVALID_FUNCTION);
  1595                 typ = @symbol(illegalOperationSignal);
  1595 		typ = @symbol(illegalOperationSignal);
  1596                 break;
  1596 		break;
  1597 
  1597 
  1598             case ERROR_BAD_FORMAT:
  1598 	    case ERROR_BAD_FORMAT:
  1599                 sym = @symbol(ERROR_BAD_FORMAT);
  1599 		sym = @symbol(ERROR_BAD_FORMAT);
  1600                 typ = @symbol(invalidArgumentsSignal);
  1600 		typ = @symbol(invalidArgumentsSignal);
  1601                 break;
  1601 		break;
  1602 
  1602 
  1603             case ERROR_FILE_NOT_FOUND:
  1603 	    case ERROR_FILE_NOT_FOUND:
  1604                 sym = @symbol(ERROR_FILE_NOT_FOUND);
  1604 		sym = @symbol(ERROR_FILE_NOT_FOUND);
  1605                 typ = @symbol(nonexistentSignal);
  1605 		typ = @symbol(nonexistentSignal);
  1606                 break;
  1606 		break;
  1607 
  1607 
  1608             case ERROR_PATH_NOT_FOUND:
  1608 	    case ERROR_PATH_NOT_FOUND:
  1609                 sym = @symbol(ERROR_PATH_NOT_FOUND);
  1609 		sym = @symbol(ERROR_PATH_NOT_FOUND);
  1610                 typ = @symbol(nonexistentSignal);
  1610 		typ = @symbol(nonexistentSignal);
  1611                 break;
  1611 		break;
  1612 
  1612 
  1613             case ERROR_TOO_MANY_OPEN_FILES:
  1613 	    case ERROR_TOO_MANY_OPEN_FILES:
  1614                 sym = @symbol(ERROR_TOO_MANY_OPEN_FILES);
  1614 		sym = @symbol(ERROR_TOO_MANY_OPEN_FILES);
  1615                 typ = @symbol(noResourcesSignal);
  1615 		typ = @symbol(noResourcesSignal);
  1616                 break;
  1616 		break;
  1617 
  1617 
  1618             /*
  1618 	    /*
  1619              * what a nice errorCode - thats the most "useful" one I ever
  1619 	     * what a nice errorCode - thats the most "useful" one I ever
  1620              * encountered ... (... those stupid micro-softies ...)
  1620 	     * encountered ... (... those stupid micro-softies ...)
  1621              */
  1621 	     */
  1622             case ERROR_OPEN_FAILED:
  1622 	    case ERROR_OPEN_FAILED:
  1623                 sym = @symbol(ERROR_OPEN_FAILED);
  1623 		sym = @symbol(ERROR_OPEN_FAILED);
  1624                 typ = @symbol(noResourcesSignal);
  1624 		typ = @symbol(noResourcesSignal);
  1625                 break;
  1625 		break;
  1626 
  1626 
  1627             case ERROR_ACCESS_DENIED:
  1627 	    case ERROR_ACCESS_DENIED:
  1628                 sym = @symbol(ERROR_ACCESS_DENIED);
  1628 		sym = @symbol(ERROR_ACCESS_DENIED);
  1629                 typ = @symbol(noPermissionsSignal);
  1629 		typ = @symbol(noPermissionsSignal);
  1630                 break;
  1630 		break;
  1631 
  1631 
  1632             case ERROR_INVALID_HANDLE:
  1632 	    case ERROR_INVALID_HANDLE:
  1633                 sym = @symbol(ERROR_INVALID_HANDLE);
  1633 		sym = @symbol(ERROR_INVALID_HANDLE);
  1634                 typ = @symbol(invalidArgumentsSignal);
  1634 		typ = @symbol(invalidArgumentsSignal);
  1635                 break;
  1635 		break;
  1636 
  1636 
  1637             case ERROR_NOT_ENOUGH_MEMORY:
  1637 	    case ERROR_NOT_ENOUGH_MEMORY:
  1638                 sym = @symbol(ERROR_NOT_ENOUGH_MEMORY);
  1638 		sym = @symbol(ERROR_NOT_ENOUGH_MEMORY);
  1639                 typ = @symbol(noResourcesSignal);
  1639 		typ = @symbol(noResourcesSignal);
  1640                 break;
  1640 		break;
  1641 
  1641 
  1642             case ERROR_INVALID_ACCESS:
  1642 	    case ERROR_NO_SYSTEM_RESOURCES:
  1643                 sym = @symbol(ERROR_INVALID_ACCESS);
  1643 		sym = @symbol(ERROR_NO_SYSTEM_RESOURCES);
  1644                 typ = @symbol(inappropriateOperationSignal);
  1644 		typ = @symbol(noResourcesSignal);
  1645                 break;
  1645 		break;
  1646 
  1646 
  1647             case ERROR_INVALID_DATA:
  1647 	    case ERROR_NONPAGED_SYSTEM_RESOURCES:
  1648                 sym = @symbol(ERROR_INVALID_DATA);
  1648 		sym = @symbol(ERROR_NONPAGED_SYSTEM_RESOURCES);
  1649                 typ = @symbol(invalidArgumentsSignal);
  1649 		typ = @symbol(noResourcesSignal);
  1650                 break;
  1650 		break;
  1651 
  1651 
  1652             case ERROR_INVALID_NAME:
  1652 	    case ERROR_PAGED_SYSTEM_RESOURCES:
  1653                 sym = @symbol(ERROR_INVALID_NAME);
  1653 		sym = @symbol(ERROR_PAGED_SYSTEM_RESOURCES);
  1654                 typ = @symbol(invalidArgumentsSignal);
  1654 		typ = @symbol(noResourcesSignal);
  1655                 break;
  1655 		break;
  1656 
  1656 
  1657             case ERROR_ARENA_TRASHED:
  1657 	    case ERROR_INVALID_ACCESS:
  1658                 sym = @symbol(ERROR_ARENA_TRASHED);
  1658 		sym = @symbol(ERROR_INVALID_ACCESS);
  1659                 typ = @symbol(noResourcesSignal);
  1659 		typ = @symbol(inappropriateOperationSignal);
  1660                 break;
  1660 		break;
  1661 
  1661 
  1662             case ERROR_OUTOFMEMORY:
  1662 	    case ERROR_INVALID_DATA:
  1663                 sym = @symbol(ERROR_OUTOFMEMORY);
  1663 		sym = @symbol(ERROR_INVALID_DATA);
  1664                 typ = @symbol(noResourcesSignal);
  1664 		typ = @symbol(invalidArgumentsSignal);
  1665                 break;
  1665 		break;
  1666 
  1666 
  1667             case ERROR_BROKEN_PIPE:
  1667 	    case ERROR_INVALID_NAME:
  1668                 sym = @symbol(ERROR_BROKEN_PIPE);
  1668 		sym = @symbol(ERROR_INVALID_NAME);
  1669                 typ = @symbol(peerFaultSignal);
  1669 		typ = @symbol(invalidArgumentsSignal);
  1670                 break;
  1670 		break;
  1671 
  1671 
  1672             case ERROR_GEN_FAILURE:
  1672 	    case ERROR_ARENA_TRASHED:
  1673                 sym = @symbol(ERROR_GEN_FAILURE);
  1673 		sym = @symbol(ERROR_ARENA_TRASHED);
  1674                 break;
  1674 		typ = @symbol(noResourcesSignal);
  1675 
  1675 		break;
  1676             case ERROR_WRITE_PROTECT:
  1676 
  1677                 sym = @symbol(ERROR_WRITE_PROTECT);
  1677 	    case ERROR_OUTOFMEMORY:
  1678                 typ = @symbol(inappropriateOperationSignal);
  1678 		sym = @symbol(ERROR_OUTOFMEMORY);
  1679                 break;
  1679 		typ = @symbol(noResourcesSignal);
  1680 
  1680 		break;
  1681             case ERROR_WRITE_FAULT:
  1681 
  1682                 sym = @symbol(ERROR_WRITE_FAULT);
  1682 	    case ERROR_BROKEN_PIPE:
  1683                 typ = @symbol(transferFaultSignal);
  1683 		sym = @symbol(ERROR_BROKEN_PIPE);
  1684                 break;
  1684 		typ = @symbol(peerFaultSignal);
  1685 
  1685 		break;
  1686             case ERROR_READ_FAULT:
  1686 
  1687                 sym = @symbol(ERROR_READ_FAULT);
  1687 	    case ERROR_GEN_FAILURE:
  1688                 typ = @symbol(transferFaultSignal);
  1688 		sym = @symbol(ERROR_GEN_FAILURE);
  1689                 break;
  1689 		break;
  1690 
  1690 
  1691             case ERROR_HANDLE_DISK_FULL:
  1691 	    case ERROR_WRITE_PROTECT:
  1692                 sym = @symbol(ERROR_HANDLE_DISK_FULL);
  1692 		sym = @symbol(ERROR_WRITE_PROTECT);
  1693                 typ = @symbol(volumeFullSignal);
  1693 		typ = @symbol(inappropriateOperationSignal);
  1694                 break;
  1694 		break;
  1695 
  1695 
  1696             case ERROR_DISK_FULL:
  1696 	    case ERROR_WRITE_FAULT:
  1697                 sym = @symbol(ERROR_DISK_FULL);
  1697 		sym = @symbol(ERROR_WRITE_FAULT);
  1698                 typ = @symbol(volumeFullSignal);
  1698 		typ = @symbol(transferFaultSignal);
  1699                 break;
  1699 		break;
  1700 
  1700 
  1701             case ERROR_SHARING_VIOLATION:
  1701 	    case ERROR_READ_FAULT:
  1702                 sym = @symbol(ERROR_SHARING_VIOLATION);
  1702 		sym = @symbol(ERROR_READ_FAULT);
  1703                 typ = @symbol(noPermissionsSignal);
  1703 		typ = @symbol(transferFaultSignal);
  1704                 break;
  1704 		break;
  1705 
  1705 
  1706             case ERROR_LOCK_VIOLATION:
  1706 	    case ERROR_HANDLE_DISK_FULL:
  1707                 sym = @symbol(ERROR_LOCK_VIOLATION);
  1707 		sym = @symbol(ERROR_HANDLE_DISK_FULL);
  1708                 typ = @symbol(noPermissionsSignal);
  1708 		typ = @symbol(volumeFullSignal);
  1709                 break;
  1709 		break;
  1710 
  1710 
  1711             case ERROR_INVALID_PARAMETER:
  1711 	    case ERROR_DISK_FULL:
  1712                 sym = @symbol(ERROR_INVALID_PARAMETER);
  1712 		sym = @symbol(ERROR_DISK_FULL);
  1713                 typ = @symbol(invalidArgumentsSignal);
  1713 		typ = @symbol(volumeFullSignal);
  1714                 break;
  1714 		break;
  1715 
  1715 
  1716             case ERROR_NET_WRITE_FAULT:
  1716 	    case ERROR_SHARING_VIOLATION:
  1717                 sym = @symbol(ERROR_NET_WRITE_FAULT);
  1717 		sym = @symbol(ERROR_SHARING_VIOLATION);
  1718                 typ = @symbol(transferFaultSignal);
  1718 		typ = @symbol(noPermissionsSignal);
  1719                 break;
  1719 		break;
  1720 
  1720 
  1721             case ERROR_NOT_SUPPORTED:
  1721 	    case ERROR_LOCK_VIOLATION:
  1722                 sym = @symbol(ERROR_NOT_SUPPORTED);
  1722 		sym = @symbol(ERROR_LOCK_VIOLATION);
  1723                 typ = @symbol(inappropriateOperationSignal);
  1723 		typ = @symbol(noPermissionsSignal);
  1724                 break;
  1724 		break;
  1725 
  1725 
  1726             case ERROR_REM_NOT_LIST:
  1726 	    case ERROR_INVALID_PARAMETER:
  1727                 sym = @symbol(ERROR_REM_NOT_LIST);
  1727 		sym = @symbol(ERROR_INVALID_PARAMETER);
  1728                 typ = @symbol(noResourcesSignal);
  1728 		typ = @symbol(invalidArgumentsSignal);
  1729                 break;
  1729 		break;
  1730 
  1730 
  1731             case ERROR_NETWORK_ACCESS_DENIED:
  1731 	    case ERROR_NET_WRITE_FAULT:
  1732                 sym = @symbol(ERROR_NETWORK_ACCESS_DENIED);
  1732 		sym = @symbol(ERROR_NET_WRITE_FAULT);
  1733                 typ = @symbol(noPermissionsSignal);
  1733 		typ = @symbol(transferFaultSignal);
  1734                 break;
  1734 		break;
  1735 
  1735 
  1736             case ERROR_DUP_NAME:
  1736 	    case ERROR_NOT_SUPPORTED:
  1737                 sym = @symbol(ERROR_DUP_NAME);
  1737 		sym = @symbol(ERROR_NOT_SUPPORTED);
  1738                 typ = @symbol(noResourcesSignal);
  1738 		typ = @symbol(inappropriateOperationSignal);
  1739                 break;
  1739 		break;
  1740 
  1740 
  1741             case ERROR_BAD_NETPATH:
  1741 	    case ERROR_REM_NOT_LIST:
  1742                 sym = @symbol(ERROR_BAD_NETPATH);
  1742 		sym = @symbol(ERROR_REM_NOT_LIST);
  1743                 typ = @symbol(noResourcesSignal);
  1743 		typ = @symbol(noResourcesSignal);
  1744                 break;
  1744 		break;
  1745 
  1745 
  1746             case ERROR_NETWORK_BUSY:
  1746 	    case ERROR_NETWORK_ACCESS_DENIED:
  1747                 sym = @symbol(ERROR_NETWORK_BUSY);
  1747 		sym = @symbol(ERROR_NETWORK_ACCESS_DENIED);
  1748                 typ = @symbol(noResourcesSignal);
  1748 		typ = @symbol(noPermissionsSignal);
  1749                 break;
  1749 		break;
  1750 
  1750 
  1751             case ERROR_DRIVE_LOCKED:
  1751 	    case ERROR_DUP_NAME:
  1752                 sym = @symbol(ERROR_DRIVE_LOCKED);
  1752 		sym = @symbol(ERROR_DUP_NAME);
  1753                 typ = @symbol(inappropriateOperationSignal);
  1753 		typ = @symbol(noResourcesSignal);
  1754                 break;
  1754 		break;
  1755 
  1755 
  1756             case ERROR_INVALID_DRIVE:
  1756 	    case ERROR_BAD_NETPATH:
  1757                 sym = @symbol(ERROR_INVALID_DRIVE);
  1757 		sym = @symbol(ERROR_BAD_NETPATH);
  1758                 typ = @symbol(invalidArgumentsSignal);
  1758 		typ = @symbol(noResourcesSignal);
  1759                 break;
  1759 		break;
  1760 
  1760 
  1761             case ERROR_WRONG_DISK:
  1761 	    case ERROR_NETWORK_BUSY:
  1762                 sym = @symbol(ERROR_WRONG_DISK);
  1762 		sym = @symbol(ERROR_NETWORK_BUSY);
  1763                 typ = @symbol(noResourcesSignal);
  1763 		typ = @symbol(noResourcesSignal);
  1764                 break;
  1764 		break;
  1765 
  1765 
  1766             case ERROR_CURRENT_DIRECTORY:
  1766 	    case ERROR_DRIVE_LOCKED:
  1767                 sym = @symbol(ERROR_CURRENT_DIRECTORY);
  1767 		sym = @symbol(ERROR_DRIVE_LOCKED);
  1768                 typ = @symbol(invalidArgumentsSignal);
  1768 		typ = @symbol(inappropriateOperationSignal);
  1769                 break;
  1769 		break;
  1770 
  1770 
  1771             /*
  1771 	    case ERROR_INVALID_DRIVE:
  1772              * what a nice errorCode - thats the most "useful" one I ever
  1772 		sym = @symbol(ERROR_INVALID_DRIVE);
  1773              * encountered ... (... those stupid micro-softies ...)
  1773 		typ = @symbol(invalidArgumentsSignal);
  1774              */
  1774 		break;
  1775             case ERROR_CANNOT_MAKE:
  1775 
  1776                 sym = @symbol(ERROR_CANNOT_MAKE);
  1776 	    case ERROR_WRONG_DISK:
  1777                 typ = @symbol(inappropriateOperationSignal);
  1777 		sym = @symbol(ERROR_WRONG_DISK);
  1778                 break;
  1778 		typ = @symbol(noResourcesSignal);
  1779 
  1779 		break;
  1780             case ERROR_NO_MORE_FILES:
  1780 
  1781                 sym = @symbol(ERROR_NO_MORE_FILES);
  1781 	    case ERROR_CURRENT_DIRECTORY:
  1782                 typ = @symbol(noResourcesSignal);
  1782 		sym = @symbol(ERROR_CURRENT_DIRECTORY);
  1783                 break;
  1783 		typ = @symbol(invalidArgumentsSignal);
  1784 
  1784 		break;
  1785             case ERROR_NOT_READY:
  1785 
  1786                 sym = @symbol(ERROR_NOT_READY);
  1786 	    /*
  1787                 typ = @symbol(noResourcesSignal);
  1787 	     * what a nice errorCode - thats the most "useful" one I ever
  1788                 break;
  1788 	     * encountered ... (... those stupid micro-softies ...)
  1789 
  1789 	     */
  1790             case ERROR_NOT_DOS_DISK:
  1790 	    case ERROR_CANNOT_MAKE:
  1791                 sym = @symbol(ERROR_NOT_DOS_DISK);
  1791 		sym = @symbol(ERROR_CANNOT_MAKE);
  1792                 typ = @symbol(invalidArgumentsSignal);
  1792 		typ = @symbol(inappropriateOperationSignal);
  1793                 break;
  1793 		break;
  1794 
  1794 
  1795             case ERROR_OUT_OF_PAPER:
  1795 	    case ERROR_NO_MORE_FILES:
  1796                 sym = @symbol(ERROR_OUT_OF_PAPER);
  1796 		sym = @symbol(ERROR_NO_MORE_FILES);
  1797                 typ = @symbol(noResourcesSignal);
  1797 		typ = @symbol(noResourcesSignal);
  1798                 break;
  1798 		break;
  1799 
  1799 
  1800             case ERROR_PRINTQ_FULL:
  1800 	    case ERROR_NOT_READY:
  1801                 sym = @symbol(ERROR_PRINTQ_FULL);
  1801 		sym = @symbol(ERROR_NOT_READY);
  1802                 typ = @symbol(noResourcesSignal);
  1802 		typ = @symbol(noResourcesSignal);
  1803                 break;
  1803 		break;
  1804 
  1804 
  1805             default:
  1805 	    case ERROR_NOT_DOS_DISK:
  1806                 sym = nil;
  1806 		sym = @symbol(ERROR_NOT_DOS_DISK);
  1807                 break;
  1807 		typ = @symbol(invalidArgumentsSignal);
  1808         }
  1808 		break;
       
  1809 
       
  1810 	    case ERROR_OUT_OF_PAPER:
       
  1811 		sym = @symbol(ERROR_OUT_OF_PAPER);
       
  1812 		typ = @symbol(noResourcesSignal);
       
  1813 		break;
       
  1814 
       
  1815 	    case ERROR_PRINTQ_FULL:
       
  1816 		sym = @symbol(ERROR_PRINTQ_FULL);
       
  1817 		typ = @symbol(noResourcesSignal);
       
  1818 		break;
       
  1819 
       
  1820 	    default:
       
  1821 		sym = nil;
       
  1822 		break;
       
  1823 	}
  1809       } else {
  1824       } else {
  1810         switch (__eno) {
  1825 	switch (__eno) {
  1811             /*
  1826 	    /*
  1812              * POSIX errnos - these should be defined
  1827 	     * POSIX errnos - these should be defined
  1813              */
  1828 	     */
  1814 #ifdef EPERM
  1829 #ifdef EPERM
  1815             case EPERM:
  1830 	    case EPERM:
  1816                 sym = @symbol(EPERM);
  1831 		sym = @symbol(EPERM);
  1817                 typ = @symbol(noPermissionsSignal);
  1832 		typ = @symbol(noPermissionsSignal);
  1818                 break;
  1833 		break;
  1819 #endif
  1834 #endif
  1820 #ifdef ENOENT
  1835 #ifdef ENOENT
  1821             case ENOENT:
  1836 	    case ENOENT:
  1822                 sym = @symbol(ENOENT);
  1837 		sym = @symbol(ENOENT);
  1823                 typ = @symbol(nonexistentSignal);
  1838 		typ = @symbol(nonexistentSignal);
  1824                 break;
  1839 		break;
  1825 #endif
  1840 #endif
  1826 #ifdef ESRCH
  1841 #ifdef ESRCH
  1827             case ESRCH:
  1842 	    case ESRCH:
  1828                 sym = @symbol(ESRCH);
  1843 		sym = @symbol(ESRCH);
  1829                 typ = @symbol(unavailableReferentSignal);
  1844 		typ = @symbol(unavailableReferentSignal);
  1830                 break;
  1845 		break;
  1831 #endif
  1846 #endif
  1832 #ifdef EINTR
  1847 #ifdef EINTR
  1833             case EINTR:
  1848 	    case EINTR:
  1834                 sym = @symbol(EINTR);
  1849 		sym = @symbol(EINTR);
  1835                 typ = @symbol(transientErrorSignal);
  1850 		typ = @symbol(transientErrorSignal);
  1836                 break;
  1851 		break;
  1837 #endif
  1852 #endif
  1838 #ifdef EIO
  1853 #ifdef EIO
  1839             case EIO:
  1854 	    case EIO:
  1840                 sym = @symbol(EIO);
  1855 		sym = @symbol(EIO);
  1841                 typ = @symbol(transferFaultSignal);
  1856 		typ = @symbol(transferFaultSignal);
  1842                 break;
  1857 		break;
  1843 #endif
  1858 #endif
  1844 #ifdef ENXIO
  1859 #ifdef ENXIO
  1845             case ENXIO:
  1860 	    case ENXIO:
  1846                 sym = @symbol(ENXIO);
  1861 		sym = @symbol(ENXIO);
  1847                 typ = @symbol(unavailableReferentSignal);
  1862 		typ = @symbol(unavailableReferentSignal);
  1848                 break;
  1863 		break;
  1849 #endif
  1864 #endif
  1850 #ifdef E2BIG
  1865 #ifdef E2BIG
  1851             case E2BIG:
  1866 	    case E2BIG:
  1852                 sym = @symbol(E2BIG);
  1867 		sym = @symbol(E2BIG);
  1853                 typ = @symbol(invalidArgumentsSignal);
  1868 		typ = @symbol(invalidArgumentsSignal);
  1854                 break;
  1869 		break;
  1855 #endif
  1870 #endif
  1856 #ifdef ENOEXEC
  1871 #ifdef ENOEXEC
  1857             case ENOEXEC:
  1872 	    case ENOEXEC:
  1858                 sym = @symbol(ENOEXEC);
  1873 		sym = @symbol(ENOEXEC);
  1859                 typ = @symbol(inappropriateOperationSignal);
  1874 		typ = @symbol(inappropriateOperationSignal);
  1860                 break;
  1875 		break;
  1861 #endif
  1876 #endif
  1862 #ifdef EBADF
  1877 #ifdef EBADF
  1863             case EBADF:
  1878 	    case EBADF:
  1864                 sym = @symbol(EBADF);
  1879 		sym = @symbol(EBADF);
  1865                 typ = @symbol(badAccessorSignal);
  1880 		typ = @symbol(badAccessorSignal);
  1866                 break;
  1881 		break;
  1867 #endif
  1882 #endif
  1868 #ifdef ECHILD
  1883 #ifdef ECHILD
  1869             case ECHILD:
  1884 	    case ECHILD:
  1870                 sym = @symbol(ECHILD);
  1885 		sym = @symbol(ECHILD);
  1871                 typ = @symbol(informationSignal);
  1886 		typ = @symbol(informationSignal);
  1872                 break;
  1887 		break;
  1873 #endif
  1888 #endif
  1874 #if !defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN)
  1889 #if !defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN)
  1875             case EAGAIN:
  1890 	    case EAGAIN:
  1876                 sym = @symbol(EAGAIN);
  1891 		sym = @symbol(EAGAIN);
  1877                 typ = @symbol(notReadySignal);
  1892 		typ = @symbol(notReadySignal);
  1878                 break;
  1893 		break;
  1879 #endif
  1894 #endif
  1880 #ifdef ENOMEM
  1895 #ifdef ENOMEM
  1881             case ENOMEM:
  1896 	    case ENOMEM:
  1882                 sym = @symbol(ENOMEM);
  1897 		sym = @symbol(ENOMEM);
  1883                 typ = @symbol(noMemorySignal);
  1898 		typ = @symbol(noMemorySignal);
  1884                 break;
  1899 		break;
  1885 #endif
  1900 #endif
  1886 #ifdef EACCES
  1901 #ifdef EACCES
  1887             case EACCES:
  1902 	    case EACCES:
  1888                 sym = @symbol(EACCES);
  1903 		sym = @symbol(EACCES);
  1889                 typ = @symbol(noPermissionsSignal);
  1904 		typ = @symbol(noPermissionsSignal);
  1890                 break;
  1905 		break;
  1891 #endif
  1906 #endif
  1892 #ifdef EFAULT
  1907 #ifdef EFAULT
  1893             case EFAULT:
  1908 	    case EFAULT:
  1894                 sym = @symbol(EFAULT);
  1909 		sym = @symbol(EFAULT);
  1895                 typ = @symbol(invalidArgumentsSignal);
  1910 		typ = @symbol(invalidArgumentsSignal);
  1896                 break;
  1911 		break;
  1897 #endif
  1912 #endif
  1898 #ifdef EBUSY
  1913 #ifdef EBUSY
  1899             case EBUSY:
  1914 	    case EBUSY:
  1900                 sym = @symbol(EBUSY);
  1915 		sym = @symbol(EBUSY);
  1901                 typ = @symbol(unavailableReferentSignal);
  1916 		typ = @symbol(unavailableReferentSignal);
  1902                 break;
  1917 		break;
  1903 #endif
  1918 #endif
  1904 #ifdef EEXIST
  1919 #ifdef EEXIST
  1905             case EEXIST:
  1920 	    case EEXIST:
  1906                 sym = @symbol(EEXIST);
  1921 		sym = @symbol(EEXIST);
  1907                 typ = @symbol(existingReferentSignal);
  1922 		typ = @symbol(existingReferentSignal);
  1908                 break;
  1923 		break;
  1909 #endif
  1924 #endif
  1910 #ifdef EXDEV
  1925 #ifdef EXDEV
  1911             case EXDEV:
  1926 	    case EXDEV:
  1912                 sym = @symbol(EXDEV);
  1927 		sym = @symbol(EXDEV);
  1913                 typ = @symbol(inappropriateReferentSignal);
  1928 		typ = @symbol(inappropriateReferentSignal);
  1914                 break;
  1929 		break;
  1915 #endif
  1930 #endif
  1916 #ifdef ENODEV
  1931 #ifdef ENODEV
  1917             case ENODEV:
  1932 	    case ENODEV:
  1918                 sym = @symbol(ENODEV);
  1933 		sym = @symbol(ENODEV);
  1919                 typ = @symbol(inaccessibleSignal);
  1934 		typ = @symbol(inaccessibleSignal);
  1920                 break;
  1935 		break;
  1921 #endif
  1936 #endif
  1922 #ifdef ENOTDIR
  1937 #ifdef ENOTDIR
  1923             case ENOTDIR:
  1938 	    case ENOTDIR:
  1924                 sym = @symbol(ENOTDIR);
  1939 		sym = @symbol(ENOTDIR);
  1925                 typ = @symbol(inappropriateOperationSignal);
  1940 		typ = @symbol(inappropriateOperationSignal);
  1926                 break;
  1941 		break;
  1927 #endif
  1942 #endif
  1928 #ifdef EISDIR
  1943 #ifdef EISDIR
  1929             case EISDIR:
  1944 	    case EISDIR:
  1930                 sym = @symbol(EISDIR);
  1945 		sym = @symbol(EISDIR);
  1931                 typ = @symbol(inappropriateOperationSignal);
  1946 		typ = @symbol(inappropriateOperationSignal);
  1932                 break;
  1947 		break;
  1933 #endif
  1948 #endif
  1934 #ifdef EINVAL
  1949 #ifdef EINVAL
  1935             case EINVAL:
  1950 	    case EINVAL:
  1936                 sym = @symbol(EINVAL);
  1951 		sym = @symbol(EINVAL);
  1937                 typ = @symbol(invalidArgumentsSignal);
  1952 		typ = @symbol(invalidArgumentsSignal);
  1938                 break;
  1953 		break;
  1939 #endif
  1954 #endif
  1940 #ifdef ENFILE
  1955 #ifdef ENFILE
  1941             case ENFILE:
  1956 	    case ENFILE:
  1942                 sym = @symbol(ENFILE);
  1957 		sym = @symbol(ENFILE);
  1943                 typ = @symbol(noResourcesSignal);
  1958 		typ = @symbol(noResourcesSignal);
  1944                 break;
  1959 		break;
  1945 #endif
  1960 #endif
  1946 #ifdef EMFILE
  1961 #ifdef EMFILE
  1947             case EMFILE:
  1962 	    case EMFILE:
  1948                 sym = @symbol(EMFILE);
  1963 		sym = @symbol(EMFILE);
  1949                 typ = @symbol(noResourcesSignal);
  1964 		typ = @symbol(noResourcesSignal);
  1950                 break;
  1965 		break;
  1951 #endif
  1966 #endif
  1952 #ifdef ENOTTY
  1967 #ifdef ENOTTY
  1953             case ENOTTY:
  1968 	    case ENOTTY:
  1954                 sym = @symbol(ENOTTY);
  1969 		sym = @symbol(ENOTTY);
  1955                 typ = @symbol(inappropriateOperationSignal);
  1970 		typ = @symbol(inappropriateOperationSignal);
  1956                 break;
  1971 		break;
  1957 #endif
  1972 #endif
  1958 #ifdef EFBIG
  1973 #ifdef EFBIG
  1959             case EFBIG:
  1974 	    case EFBIG:
  1960                 sym = @symbol(EFBIG);
  1975 		sym = @symbol(EFBIG);
  1961                 typ = @symbol(noResourcesSignal);
  1976 		typ = @symbol(noResourcesSignal);
  1962                 break;
  1977 		break;
  1963 #endif
  1978 #endif
  1964 #ifdef ENOSPC
  1979 #ifdef ENOSPC
  1965             case ENOSPC:
  1980 	    case ENOSPC:
  1966                 sym = @symbol(ENOSPC);
  1981 		sym = @symbol(ENOSPC);
  1967                 typ = @symbol(noResourcesSignal);
  1982 		typ = @symbol(noResourcesSignal);
  1968                 break;
  1983 		break;
  1969 #endif
  1984 #endif
  1970 #ifdef ESPIPE
  1985 #ifdef ESPIPE
  1971             case ESPIPE:
  1986 	    case ESPIPE:
  1972                 sym = @symbol(ESPIPE);
  1987 		sym = @symbol(ESPIPE);
  1973                 typ = @symbol(inappropriateOperationSignal);
  1988 		typ = @symbol(inappropriateOperationSignal);
  1974                 break;
  1989 		break;
  1975 #endif
  1990 #endif
  1976 #ifdef EROFS
  1991 #ifdef EROFS
  1977             case EROFS:
  1992 	    case EROFS:
  1978                 sym = @symbol(EROFS);
  1993 		sym = @symbol(EROFS);
  1979                 typ = @symbol(inappropriateOperationSignal);
  1994 		typ = @symbol(inappropriateOperationSignal);
  1980                 break;
  1995 		break;
  1981 #endif
  1996 #endif
  1982 #ifdef EMLINK
  1997 #ifdef EMLINK
  1983             case EMLINK:
  1998 	    case EMLINK:
  1984                 sym = @symbol(EMLINK);
  1999 		sym = @symbol(EMLINK);
  1985                 typ = @symbol(rangeErrorSignal);
  2000 		typ = @symbol(rangeErrorSignal);
  1986                 break;
  2001 		break;
  1987 #endif
  2002 #endif
  1988 #ifdef EPIPE
  2003 #ifdef EPIPE
  1989             case EPIPE:
  2004 	    case EPIPE:
  1990                 sym = @symbol(EPIPE);
  2005 		sym = @symbol(EPIPE);
  1991                 typ = @symbol(peerFaultSignal);
  2006 		typ = @symbol(peerFaultSignal);
  1992                 break;
  2007 		break;
  1993 #endif
  2008 #endif
  1994 #ifdef EDOM
  2009 #ifdef EDOM
  1995             case EDOM:
  2010 	    case EDOM:
  1996                 sym = @symbol(EDOM);
  2011 		sym = @symbol(EDOM);
  1997                 typ = @symbol(rangeErrorSignal);
  2012 		typ = @symbol(rangeErrorSignal);
  1998                 break;
  2013 		break;
  1999 #endif
  2014 #endif
  2000 #ifdef ERANGE
  2015 #ifdef ERANGE
  2001             case ERANGE:
  2016 	    case ERANGE:
  2002                 sym = @symbol(ERANGE);
  2017 		sym = @symbol(ERANGE);
  2003                 typ = @symbol(rangeErrorSignal);
  2018 		typ = @symbol(rangeErrorSignal);
  2004                 break;
  2019 		break;
  2005 #endif
  2020 #endif
  2006 #ifdef EDEADLK
  2021 #ifdef EDEADLK
  2007 # if EDEADLK != EWOULDBLOCK
  2022 # if EDEADLK != EWOULDBLOCK
  2008             case EDEADLK:
  2023 	    case EDEADLK:
  2009                 sym = @symbol(EDEADLK);
  2024 		sym = @symbol(EDEADLK);
  2010                 typ = @symbol(noResourcesSignal);
  2025 		typ = @symbol(noResourcesSignal);
  2011                 break;
  2026 		break;
  2012 # endif
  2027 # endif
  2013 #endif
  2028 #endif
  2014 #ifdef ENAMETOOLONG
  2029 #ifdef ENAMETOOLONG
  2015             case ENAMETOOLONG:
  2030 	    case ENAMETOOLONG:
  2016                 sym = @symbol(ENAMETOOLONG);
  2031 		sym = @symbol(ENAMETOOLONG);
  2017                 typ = @symbol(rangeErrorSignal);
  2032 		typ = @symbol(rangeErrorSignal);
  2018                 break;
  2033 		break;
  2019 #endif
  2034 #endif
  2020 #ifdef ENOLCK
  2035 #ifdef ENOLCK
  2021             case ENOLCK:
  2036 	    case ENOLCK:
  2022                 sym = @symbol(ENOLCK);
  2037 		sym = @symbol(ENOLCK);
  2023                 typ = @symbol(inappropriateOperationSignal);
  2038 		typ = @symbol(inappropriateOperationSignal);
  2024                 break;
  2039 		break;
  2025 #endif
  2040 #endif
  2026 #ifdef ENOSYS
  2041 #ifdef ENOSYS
  2027             case ENOSYS:
  2042 	    case ENOSYS:
  2028                 sym = @symbol(ENOSYS);
  2043 		sym = @symbol(ENOSYS);
  2029                 typ = @symbol(inappropriateOperationSignal);
  2044 		typ = @symbol(inappropriateOperationSignal);
  2030                 break;
  2045 		break;
  2031 #endif
  2046 #endif
  2032 #if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST)
  2047 #if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST)
  2033             case ENOTEMPTY:
  2048 	    case ENOTEMPTY:
  2034                 sym = @symbol(ENOTEMPTY);
  2049 		sym = @symbol(ENOTEMPTY);
  2035                 typ = @symbol(inappropriateReferentSignal);
  2050 		typ = @symbol(inappropriateReferentSignal);
  2036                 break;
  2051 		break;
  2037 #endif
  2052 #endif
  2038 #ifdef EILSEQ
  2053 #ifdef EILSEQ
  2039             case EILSEQ:
  2054 	    case EILSEQ:
  2040                 sym = @symbol(EILSEQ);
  2055 		sym = @symbol(EILSEQ);
  2041                 typ = @symbol(transferFaultSignal);
  2056 		typ = @symbol(transferFaultSignal);
  2042                 break;
  2057 		break;
  2043 #endif
  2058 #endif
  2044             /*
  2059 	    /*
  2045              * XPG3 errnos - defined on most systems
  2060 	     * XPG3 errnos - defined on most systems
  2046              */
  2061 	     */
  2047 #ifdef ENOTBLK
  2062 #ifdef ENOTBLK
  2048             case ENOTBLK:
  2063 	    case ENOTBLK:
  2049                 sym = @symbol(ENOTBLK);
  2064 		sym = @symbol(ENOTBLK);
  2050                 typ = @symbol(inappropriateReferentSignal);
  2065 		typ = @symbol(inappropriateReferentSignal);
  2051                 break;
  2066 		break;
  2052 #endif
  2067 #endif
  2053 #ifdef ETXTBSY
  2068 #ifdef ETXTBSY
  2054             case ETXTBSY:
  2069 	    case ETXTBSY:
  2055                 sym = @symbol(ETXTBSY);
  2070 		sym = @symbol(ETXTBSY);
  2056                 typ = @symbol(inaccessibleSignal);
  2071 		typ = @symbol(inaccessibleSignal);
  2057                 break;
  2072 		break;
  2058 #endif
  2073 #endif
  2059             /*
  2074 	    /*
  2060              * some others
  2075 	     * some others
  2061              */
  2076 	     */
  2062 #ifdef EWOULDBLOCK
  2077 #ifdef EWOULDBLOCK
  2063             case EWOULDBLOCK:
  2078 	    case EWOULDBLOCK:
  2064                 sym = @symbol(EWOULDBLOCK);
  2079 		sym = @symbol(EWOULDBLOCK);
  2065                 typ = @symbol(notReadySignal);
  2080 		typ = @symbol(notReadySignal);
  2066                 break;
  2081 		break;
  2067 #endif
  2082 #endif
  2068 #ifdef ENOMSG
  2083 #ifdef ENOMSG
  2069             case ENOMSG:
  2084 	    case ENOMSG:
  2070                 sym = @symbol(ENOMSG);
  2085 		sym = @symbol(ENOMSG);
  2071                 typ = @symbol(noDataSignal);
  2086 		typ = @symbol(noDataSignal);
  2072                 break;
  2087 		break;
  2073 #endif
  2088 #endif
  2074 #ifdef ELOOP
  2089 #ifdef ELOOP
  2075             case ELOOP:
  2090 	    case ELOOP:
  2076                 sym = @symbol(ELOOP);
  2091 		sym = @symbol(ELOOP);
  2077                 typ = @symbol(rangeErrorSignal);
  2092 		typ = @symbol(rangeErrorSignal);
  2078                 break;
  2093 		break;
  2079 #endif
  2094 #endif
  2080 
  2095 
  2081             /*
  2096 	    /*
  2082              * some stream errors
  2097 	     * some stream errors
  2083              */
  2098 	     */
  2084 #ifdef ETIME
  2099 #ifdef ETIME
  2085             case ETIME:
  2100 	    case ETIME:
  2086                 sym = @symbol(ETIME);
  2101 		sym = @symbol(ETIME);
  2087                 typ = @symbol(peerFaultSignal);
  2102 		typ = @symbol(peerFaultSignal);
  2088                 break;
  2103 		break;
  2089 #endif
  2104 #endif
  2090 #ifdef ENOSR
  2105 #ifdef ENOSR
  2091             case ENOSR:
  2106 	    case ENOSR:
  2092                 sym = @symbol(ENOSR);
  2107 		sym = @symbol(ENOSR);
  2093                 typ = @symbol(noResourcesSignal);
  2108 		typ = @symbol(noResourcesSignal);
  2094                 break;
  2109 		break;
  2095 #endif
  2110 #endif
  2096 #ifdef ENOSTR
  2111 #ifdef ENOSTR
  2097             case ENOSTR:
  2112 	    case ENOSTR:
  2098                 sym = @symbol(ENOSTR);
  2113 		sym = @symbol(ENOSTR);
  2099                 typ = @symbol(inappropriateReferentSignal);
  2114 		typ = @symbol(inappropriateReferentSignal);
  2100                 break;
  2115 		break;
  2101 #endif
  2116 #endif
  2102 #ifdef ECOMM
  2117 #ifdef ECOMM
  2103             case ECOMM:
  2118 	    case ECOMM:
  2104                 sym = @symbol(ECOMM);
  2119 		sym = @symbol(ECOMM);
  2105                 typ = @symbol(transferFaultSignal);
  2120 		typ = @symbol(transferFaultSignal);
  2106                 break;
  2121 		break;
  2107 #endif
  2122 #endif
  2108 #ifdef EPROTO
  2123 #ifdef EPROTO
  2109             case EPROTO:
  2124 	    case EPROTO:
  2110                 sym = @symbol(EPROTO);
  2125 		sym = @symbol(EPROTO);
  2111                 typ = @symbol(inappropriateOperationSignal);
  2126 		typ = @symbol(inappropriateOperationSignal);
  2112                 break;
  2127 		break;
  2113 #endif
  2128 #endif
  2114             /*
  2129 	    /*
  2115              * nfs errors
  2130 	     * nfs errors
  2116              */
  2131 	     */
  2117 #ifdef ESTALE
  2132 #ifdef ESTALE
  2118             case ESTALE:
  2133 	    case ESTALE:
  2119                 sym = @symbol(ESTALE);
  2134 		sym = @symbol(ESTALE);
  2120                 typ = @symbol(unavailableReferentSignal);
  2135 		typ = @symbol(unavailableReferentSignal);
  2121                 break;
  2136 		break;
  2122 #endif
  2137 #endif
  2123 #ifdef EREMOTE
  2138 #ifdef EREMOTE
  2124             case EREMOTE:
  2139 	    case EREMOTE:
  2125                 sym = @symbol(EREMOTE);
  2140 		sym = @symbol(EREMOTE);
  2126                 typ = @symbol(rangeErrorSignal);
  2141 		typ = @symbol(rangeErrorSignal);
  2127                 break;
  2142 		break;
  2128 #endif
  2143 #endif
  2129             /*
  2144 	    /*
  2130              * some networking errors
  2145 	     * some networking errors
  2131              */
  2146 	     */
  2132 #ifdef EINPROGRESS
  2147 #ifdef EINPROGRESS
  2133             case EINPROGRESS:
  2148 	    case EINPROGRESS:
  2134                 sym = @symbol(EINPROGRESS);
  2149 		sym = @symbol(EINPROGRESS);
  2135                 typ = @symbol(operationStartedSignal);
  2150 		typ = @symbol(operationStartedSignal);
  2136                 break;
  2151 		break;
  2137 #endif
  2152 #endif
  2138 #ifdef EALREADY
  2153 #ifdef EALREADY
  2139             case EALREADY:
  2154 	    case EALREADY:
  2140                 sym = @symbol(EALREADY);
  2155 		sym = @symbol(EALREADY);
  2141                 typ = @symbol(operationStartedSignal);
  2156 		typ = @symbol(operationStartedSignal);
  2142                 break;
  2157 		break;
  2143 #endif
  2158 #endif
  2144 #ifdef ENOTSOCK
  2159 #ifdef ENOTSOCK
  2145             case ENOTSOCK:
  2160 	    case ENOTSOCK:
  2146                 sym = @symbol(ENOTSOCK);
  2161 		sym = @symbol(ENOTSOCK);
  2147                 typ = @symbol(inappropriateOperationSignal);
  2162 		typ = @symbol(inappropriateOperationSignal);
  2148                 break;
  2163 		break;
  2149 #endif
  2164 #endif
  2150 #ifdef EDESTADDRREQ
  2165 #ifdef EDESTADDRREQ
  2151             case EDESTADDRREQ:
  2166 	    case EDESTADDRREQ:
  2152                 sym = @symbol(EDESTADDRREQ);
  2167 		sym = @symbol(EDESTADDRREQ);
  2153                 typ = @symbol(underspecifiedSignal);
  2168 		typ = @symbol(underspecifiedSignal);
  2154                 break;
  2169 		break;
  2155 #endif
  2170 #endif
  2156 #ifdef EMSGSIZE
  2171 #ifdef EMSGSIZE
  2157             case EMSGSIZE:
  2172 	    case EMSGSIZE:
  2158                 sym = @symbol(EMSGSIZE);
  2173 		sym = @symbol(EMSGSIZE);
  2159                 typ = @symbol(rangeErrorSignal);
  2174 		typ = @symbol(rangeErrorSignal);
  2160                 break;
  2175 		break;
  2161 #endif
  2176 #endif
  2162 #ifdef EPROTOTYPE
  2177 #ifdef EPROTOTYPE
  2163             case EPROTOTYPE:
  2178 	    case EPROTOTYPE:
  2164                 sym = @symbol(EPROTOTYPE);
  2179 		sym = @symbol(EPROTOTYPE);
  2165                 typ = @symbol(wrongSubtypeForOperationSignal);
  2180 		typ = @symbol(wrongSubtypeForOperationSignal);
  2166                 break;
  2181 		break;
  2167 #endif
  2182 #endif
  2168 #ifdef ENOPROTOOPT
  2183 #ifdef ENOPROTOOPT
  2169             case ENOPROTOOPT:
  2184 	    case ENOPROTOOPT:
  2170                 sym = @symbol(ENOPROTOOPT);
  2185 		sym = @symbol(ENOPROTOOPT);
  2171                 typ = @symbol(unsupportedOperationSignal);
  2186 		typ = @symbol(unsupportedOperationSignal);
  2172                 break;
  2187 		break;
  2173 #endif
  2188 #endif
  2174 #ifdef EPROTONOSUPPORT
  2189 #ifdef EPROTONOSUPPORT
  2175             case EPROTONOSUPPORT:
  2190 	    case EPROTONOSUPPORT:
  2176                 sym = @symbol(EPROTONOSUPPORT);
  2191 		sym = @symbol(EPROTONOSUPPORT);
  2177                 typ = @symbol(unsupportedOperationSignal);
  2192 		typ = @symbol(unsupportedOperationSignal);
  2178                 break;
  2193 		break;
  2179 #endif
  2194 #endif
  2180 #ifdef ESOCKTNOSUPPORT
  2195 #ifdef ESOCKTNOSUPPORT
  2181             case ESOCKTNOSUPPORT:
  2196 	    case ESOCKTNOSUPPORT:
  2182                 sym = @symbol(ESOCKTNOSUPPORT);
  2197 		sym = @symbol(ESOCKTNOSUPPORT);
  2183                 typ = @symbol(unsupportedOperationSignal);
  2198 		typ = @symbol(unsupportedOperationSignal);
  2184                 break;
  2199 		break;
  2185 #endif
  2200 #endif
  2186 #ifdef EOPNOTSUPP
  2201 #ifdef EOPNOTSUPP
  2187             case EOPNOTSUPP:
  2202 	    case EOPNOTSUPP:
  2188                 sym = @symbol(EOPNOTSUPP);
  2203 		sym = @symbol(EOPNOTSUPP);
  2189                 typ = @symbol(inappropriateOperationSignal);
  2204 		typ = @symbol(inappropriateOperationSignal);
  2190                 break;
  2205 		break;
  2191 #endif
  2206 #endif
  2192 #ifdef EPFNOSUPPORT
  2207 #ifdef EPFNOSUPPORT
  2193             case EPFNOSUPPORT:
  2208 	    case EPFNOSUPPORT:
  2194                 sym = @symbol(EPFNOSUPPORT);
  2209 		sym = @symbol(EPFNOSUPPORT);
  2195                 typ = @symbol(unsupportedOperationSignal);
  2210 		typ = @symbol(unsupportedOperationSignal);
  2196                 break;
  2211 		break;
  2197 #endif
  2212 #endif
  2198 #ifdef EAFNOSUPPORT
  2213 #ifdef EAFNOSUPPORT
  2199             case EAFNOSUPPORT:
  2214 	    case EAFNOSUPPORT:
  2200                 sym = @symbol(EAFNOSUPPORT);
  2215 		sym = @symbol(EAFNOSUPPORT);
  2201                 typ = @symbol(unsupportedOperationSignal);
  2216 		typ = @symbol(unsupportedOperationSignal);
  2202                 break;
  2217 		break;
  2203 #endif
  2218 #endif
  2204 #ifdef EADDRINUSE
  2219 #ifdef EADDRINUSE
  2205             case EADDRINUSE:
  2220 	    case EADDRINUSE:
  2206                 sym = @symbol(EADDRINUSE);
  2221 		sym = @symbol(EADDRINUSE);
  2207                 typ = @symbol(existingReferentSignal);
  2222 		typ = @symbol(existingReferentSignal);
  2208                 break;
  2223 		break;
  2209 #endif
  2224 #endif
  2210 #ifdef EADDRNOTAVAIL
  2225 #ifdef EADDRNOTAVAIL
  2211             case EADDRNOTAVAIL:
  2226 	    case EADDRNOTAVAIL:
  2212                 sym = @symbol(EADDRNOTAVAIL);
  2227 		sym = @symbol(EADDRNOTAVAIL);
  2213                 typ = @symbol(noPermissionsSignal);
  2228 		typ = @symbol(noPermissionsSignal);
  2214                 break;
  2229 		break;
  2215 #endif
  2230 #endif
  2216 #ifdef ETIMEDOUT
  2231 #ifdef ETIMEDOUT
  2217             case ETIMEDOUT:
  2232 	    case ETIMEDOUT:
  2218                 sym = @symbol(ETIMEDOUT);
  2233 		sym = @symbol(ETIMEDOUT);
  2219                 typ = @symbol(peerFaultSignal);
  2234 		typ = @symbol(peerFaultSignal);
  2220                 break;
  2235 		break;
  2221 #endif
  2236 #endif
  2222 #ifdef ECONNREFUSED
  2237 #ifdef ECONNREFUSED
  2223             case ECONNREFUSED:
  2238 	    case ECONNREFUSED:
  2224                 sym = @symbol(ECONNREFUSED);
  2239 		sym = @symbol(ECONNREFUSED);
  2225                 typ = @symbol(peerFaultSignal);
  2240 		typ = @symbol(peerFaultSignal);
  2226                 break;
  2241 		break;
  2227 #endif
  2242 #endif
  2228 #ifdef ENETDOWN
  2243 #ifdef ENETDOWN
  2229             case ENETDOWN:
  2244 	    case ENETDOWN:
  2230                 sym = @symbol(ENETDOWN);
  2245 		sym = @symbol(ENETDOWN);
  2231                 typ = @symbol(peerFaultSignal);
  2246 		typ = @symbol(peerFaultSignal);
  2232                 break;
  2247 		break;
  2233 #endif
  2248 #endif
  2234 #ifdef ENETUNREACH
  2249 #ifdef ENETUNREACH
  2235             case ENETUNREACH:
  2250 	    case ENETUNREACH:
  2236                 sym = @symbol(ENETUNREACH);
  2251 		sym = @symbol(ENETUNREACH);
  2237                 typ = @symbol(peerFaultSignal);
  2252 		typ = @symbol(peerFaultSignal);
  2238                 break;
  2253 		break;
  2239 #endif
  2254 #endif
  2240 #ifdef ENETRESET
  2255 #ifdef ENETRESET
  2241             case ENETRESET:
  2256 	    case ENETRESET:
  2242                 sym = @symbol(ENETRESET);
  2257 		sym = @symbol(ENETRESET);
  2243                 typ = @symbol(peerFaultSignal);
  2258 		typ = @symbol(peerFaultSignal);
  2244                 break;
  2259 		break;
  2245 #endif
  2260 #endif
  2246 #ifdef ECONNABORTED
  2261 #ifdef ECONNABORTED
  2247             case ECONNABORTED:
  2262 	    case ECONNABORTED:
  2248                 sym = @symbol(ECONNABORTED);
  2263 		sym = @symbol(ECONNABORTED);
  2249                 typ = @symbol(peerFaultSignal);
  2264 		typ = @symbol(peerFaultSignal);
  2250                 break;
  2265 		break;
  2251 #endif
  2266 #endif
  2252 #ifdef ECONNRESET
  2267 #ifdef ECONNRESET
  2253             case ECONNRESET:
  2268 	    case ECONNRESET:
  2254                 sym = @symbol(ECONNRESET);
  2269 		sym = @symbol(ECONNRESET);
  2255                 typ = @symbol(peerFaultSignal);
  2270 		typ = @symbol(peerFaultSignal);
  2256                 break;
  2271 		break;
  2257 #endif
  2272 #endif
  2258 #ifdef EISCONN
  2273 #ifdef EISCONN
  2259             case EISCONN:
  2274 	    case EISCONN:
  2260                 sym = @symbol(EISCONN);
  2275 		sym = @symbol(EISCONN);
  2261                 typ = @symbol(unpreparedOperationSignal);
  2276 		typ = @symbol(unpreparedOperationSignal);
  2262                 break;
  2277 		break;
  2263 #endif
  2278 #endif
  2264 #ifdef ENOTCONN
  2279 #ifdef ENOTCONN
  2265             case ENOTCONN:
  2280 	    case ENOTCONN:
  2266                 sym = @symbol(ENOTCONN);
  2281 		sym = @symbol(ENOTCONN);
  2267                 typ = @symbol(unpreparedOperationSignal);
  2282 		typ = @symbol(unpreparedOperationSignal);
  2268                 break;
  2283 		break;
  2269 #endif
  2284 #endif
  2270 #ifdef ESHUTDOWN
  2285 #ifdef ESHUTDOWN
  2271             case ESHUTDOWN:
  2286 	    case ESHUTDOWN:
  2272                 sym = @symbol(ESHUTDOWN);
  2287 		sym = @symbol(ESHUTDOWN);
  2273                 typ = @symbol(unpreparedOperationSignal);
  2288 		typ = @symbol(unpreparedOperationSignal);
  2274                 break;
  2289 		break;
  2275 #endif
  2290 #endif
  2276 #ifdef EHOSTDOWN
  2291 #ifdef EHOSTDOWN
  2277             case EHOSTDOWN:
  2292 	    case EHOSTDOWN:
  2278                 sym = @symbol(EHOSTDOWN);
  2293 		sym = @symbol(EHOSTDOWN);
  2279                 typ = @symbol(peerFaultSignal);
  2294 		typ = @symbol(peerFaultSignal);
  2280                 break;
  2295 		break;
  2281 #endif
  2296 #endif
  2282 #ifdef EHOSTUNREACH
  2297 #ifdef EHOSTUNREACH
  2283             case EHOSTUNREACH:
  2298 	    case EHOSTUNREACH:
  2284                 sym = @symbol(EHOSTUNREACH);
  2299 		sym = @symbol(EHOSTUNREACH);
  2285                 typ = @symbol(peerFaultSignal);
  2300 		typ = @symbol(peerFaultSignal);
  2286                 break;
  2301 		break;
  2287 #endif
  2302 #endif
  2288 
  2303 
  2289 #ifdef WSAEFAULT
  2304 #ifdef WSAEFAULT
  2290             case WSAEFAULT:
  2305 	    case WSAEFAULT:
  2291                 sym = @symbol(WSAEFAULT);
  2306 		sym = @symbol(WSAEFAULT);
  2292                 typ = @symbol(invalidArgumentsSignal);
  2307 		typ = @symbol(invalidArgumentsSignal);
  2293                 break;
  2308 		break;
  2294 #endif
  2309 #endif
  2295 #ifdef WSAEINTR
  2310 #ifdef WSAEINTR
  2296             case WSAEINTR:
  2311 	    case WSAEINTR:
  2297                 sym = @symbol(WSAEINTR);
  2312 		sym = @symbol(WSAEINTR);
  2298                 typ = @symbol(transientErrorSignal);
  2313 		typ = @symbol(transientErrorSignal);
  2299                 break;
  2314 		break;
  2300 #endif
  2315 #endif
  2301 #ifdef WSAEBADF
  2316 #ifdef WSAEBADF
  2302             case WSAEBADF:
  2317 	    case WSAEBADF:
  2303                 sym = @symbol(WSAEBADF);
  2318 		sym = @symbol(WSAEBADF);
  2304                 typ = @symbol(badAccessorSignal);
  2319 		typ = @symbol(badAccessorSignal);
  2305                 break;
  2320 		break;
  2306 #endif
  2321 #endif
  2307 #ifdef WSAEACCESS
  2322 #ifdef WSAEACCESS
  2308             case WSAEACCESS:
  2323 	    case WSAEACCESS:
  2309                 sym = @symbol(WSAEACCESS);
  2324 		sym = @symbol(WSAEACCESS);
  2310                 typ = @symbol(badAccessorSignal);
  2325 		typ = @symbol(badAccessorSignal);
  2311                 break;
  2326 		break;
  2312 #endif
  2327 #endif
  2313 #ifdef WSAEINVAL
  2328 #ifdef WSAEINVAL
  2314             case WSAEINVAL:
  2329 	    case WSAEINVAL:
  2315                 sym = @symbol(WSAEINVAL);
  2330 		sym = @symbol(WSAEINVAL);
  2316                 typ = @symbol(invalidArgumentsSignal);
  2331 		typ = @symbol(invalidArgumentsSignal);
  2317                 break;
  2332 		break;
  2318 #endif
  2333 #endif
  2319 #ifdef WSAEMFILE
  2334 #ifdef WSAEMFILE
  2320             case WSAEMFILE:
  2335 	    case WSAEMFILE:
  2321                 sym = @symbol(WSAEMFILE);
  2336 		sym = @symbol(WSAEMFILE);
  2322                 typ = @symbol(noResourcesSignal);
  2337 		typ = @symbol(noResourcesSignal);
  2323                 break;
  2338 		break;
  2324 #endif
  2339 #endif
  2325 #ifdef WSAEWOULDBLOCK
  2340 #ifdef WSAEWOULDBLOCK
  2326             case WSAEWOULDBLOCK:
  2341 	    case WSAEWOULDBLOCK:
  2327                 sym = @symbol(WSAEWOULDBLOCK);
  2342 		sym = @symbol(WSAEWOULDBLOCK);
  2328                 typ = @symbol(notReadySignal);
  2343 		typ = @symbol(notReadySignal);
  2329                 break;
  2344 		break;
  2330 #endif
  2345 #endif
  2331 #ifdef WSAEINPROGRESS
  2346 #ifdef WSAEINPROGRESS
  2332             case WSAEINPROGRESS:
  2347 	    case WSAEINPROGRESS:
  2333                 sym = @symbol(WSAEINPROGRESS);
  2348 		sym = @symbol(WSAEINPROGRESS);
  2334                 typ = @symbol(operationStartedSignal);
  2349 		typ = @symbol(operationStartedSignal);
  2335                 break;
  2350 		break;
  2336 #endif
  2351 #endif
  2337 #ifdef WSAEALREADY
  2352 #ifdef WSAEALREADY
  2338             case WSAEALREADY:
  2353 	    case WSAEALREADY:
  2339                 sym = @symbol(WSAEALREADY);
  2354 		sym = @symbol(WSAEALREADY);
  2340                 typ = @symbol(operationStartedSignal);
  2355 		typ = @symbol(operationStartedSignal);
  2341                 break;
  2356 		break;
  2342 #endif
  2357 #endif
  2343 #ifdef WSAENOTSOCK
  2358 #ifdef WSAENOTSOCK
  2344             case WSAENOTSOCK:
  2359 	    case WSAENOTSOCK:
  2345                 sym = @symbol(WSAENOTSOCK);
  2360 		sym = @symbol(WSAENOTSOCK);
  2346                 typ = @symbol(inappropriateOperationSignal);
  2361 		typ = @symbol(inappropriateOperationSignal);
  2347                 break;
  2362 		break;
  2348 #endif
  2363 #endif
  2349 #ifdef WSAEPROTONOSUPPORT
  2364 #ifdef WSAEPROTONOSUPPORT
  2350             case WSAEPROTONOSUPPORT:
  2365 	    case WSAEPROTONOSUPPORT:
  2351                 sym = @symbol(WSAEPROTONOSUPPORT);
  2366 		sym = @symbol(WSAEPROTONOSUPPORT);
  2352                 typ = @symbol(unsupportedOperationSignal);
  2367 		typ = @symbol(unsupportedOperationSignal);
  2353                 break;
  2368 		break;
  2354 #endif
  2369 #endif
  2355 #ifdef WSAESOCKTNOSUPPORT
  2370 #ifdef WSAESOCKTNOSUPPORT
  2356             case WSAESOCKTNOSUPPORT:
  2371 	    case WSAESOCKTNOSUPPORT:
  2357                 sym = @symbol(WSAESOCKTNOSUPPORT);
  2372 		sym = @symbol(WSAESOCKTNOSUPPORT);
  2358                 typ = @symbol(unsupportedOperationSignal);
  2373 		typ = @symbol(unsupportedOperationSignal);
  2359                 break;
  2374 		break;
  2360 #endif
  2375 #endif
  2361 #ifdef E_NOINTERFACE
  2376 #ifdef E_NOINTERFACE
  2362             case E_NOINTERFACE:
  2377 	    case E_NOINTERFACE:
  2363                 sym = @symbol(E_NOINTERFACE);
  2378 		sym = @symbol(E_NOINTERFACE);
  2364                 typ = @symbol(noInterfaceSignal);
  2379 		typ = @symbol(noInterfaceSignal);
  2365                 break;
  2380 		break;
  2366 #endif
  2381 #endif
  2367 #ifdef CO_E_NOTINITIALIZED
  2382 #ifdef CO_E_NOTINITIALIZED
  2368             case CO_E_NOTINITIALIZED:
  2383 	    case CO_E_NOTINITIALIZED:
  2369                 sym = @symbol(CO_E_NOTINITIALIZED);
  2384 		sym = @symbol(CO_E_NOTINITIALIZED);
  2370                 typ = @symbol(coNotInitializedSignal);
  2385 		typ = @symbol(coNotInitializedSignal);
  2371                 break;
  2386 		break;
  2372 #endif
  2387 #endif
  2373 #ifdef REGDB_E_CLASSNOTREG
  2388 #ifdef REGDB_E_CLASSNOTREG
  2374             case REGDB_E_CLASSNOTREG:
  2389 	    case REGDB_E_CLASSNOTREG:
  2375                 sym = @symbol(REGDB_E_CLASSNOTREG);
  2390 		sym = @symbol(REGDB_E_CLASSNOTREG);
  2376                 typ = @symbol(classNotRegisteredSignal);
  2391 		typ = @symbol(classNotRegisteredSignal);
  2377                 break;
  2392 		break;
  2378 #endif
  2393 #endif
  2379 #ifdef CLASS_E_NOAGGREGATION
  2394 #ifdef CLASS_E_NOAGGREGATION
  2380             case CLASS_E_NOAGGREGATION:
  2395 	    case CLASS_E_NOAGGREGATION:
  2381                 sym = @symbol(CLASS_E_NOAGGREGATION);
  2396 		sym = @symbol(CLASS_E_NOAGGREGATION);
  2382                 typ = @symbol(noAggregationSignal);
  2397 		typ = @symbol(noAggregationSignal);
  2383                 break;
  2398 		break;
  2384 #endif
  2399 #endif
  2385 #ifdef DISP_E_UNKNOWNNAME
  2400 #ifdef DISP_E_UNKNOWNNAME
  2386             case DISP_E_UNKNOWNNAME:
  2401 	    case DISP_E_UNKNOWNNAME:
  2387                 sym = @symbol(DISP_E_UNKNOWNNAME);
  2402 		sym = @symbol(DISP_E_UNKNOWNNAME);
  2388                 typ = @symbol(unknownNameSignal);
  2403 		typ = @symbol(unknownNameSignal);
  2389                 break;
  2404 		break;
  2390 #endif
  2405 #endif
  2391 #ifdef OLEOBJ_E_NOVERBS
  2406 #ifdef OLEOBJ_E_NOVERBS
  2392             case OLEOBJ_E_NOVERBS:
  2407 	    case OLEOBJ_E_NOVERBS:
  2393                 sym = @symbol(OLEOBJ_E_NOVERBS);
  2408 		sym = @symbol(OLEOBJ_E_NOVERBS);
  2394                 typ = @symbol(noVerbsSignal);
  2409 		typ = @symbol(noVerbsSignal);
  2395                 break;
  2410 		break;
  2396 #endif
  2411 #endif
  2397 
  2412 
  2398             default:
  2413 	    default:
  2399                 break;
  2414 		break;
  2400         }
  2415 	}
  2401       }
  2416       }
  2402     }
  2417     }
  2403 %}.
  2418 %}.
  2404     holder := OSErrorHolder new.
  2419     holder := OSErrorHolder new.
  2405     holder errorSymbol:sym errorCategory:typ.
  2420     holder errorSymbol:sym errorCategory:typ.
  2425     /*
  2440     /*
  2426      * WIN32 GetLastError returns
  2441      * WIN32 GetLastError returns
  2427      */
  2442      */
  2428 #ifdef ERROR_INVALID_FUNCTION
  2443 #ifdef ERROR_INVALID_FUNCTION
  2429     if (sym == @symbol(ERROR_INVALID_FUNCTION)) {
  2444     if (sym == @symbol(ERROR_INVALID_FUNCTION)) {
  2430         RETURN ( __mkSmallInteger(ERROR_INVALID_FUNCTION) );
  2445 	RETURN ( __mkSmallInteger(ERROR_INVALID_FUNCTION) );
  2431     }
  2446     }
  2432 #endif
  2447 #endif
  2433 #ifdef ERROR_BAD_FORMAT
  2448 #ifdef ERROR_BAD_FORMAT
  2434     if (sym == @symbol(ERROR_BAD_FORMAT)) {
  2449     if (sym == @symbol(ERROR_BAD_FORMAT)) {
  2435         RETURN ( __mkSmallInteger(ERROR_BAD_FORMAT) );
  2450 	RETURN ( __mkSmallInteger(ERROR_BAD_FORMAT) );
  2436     }
  2451     }
  2437 #endif
  2452 #endif
  2438 #ifdef ERROR_FILE_NOT_FOUND
  2453 #ifdef ERROR_FILE_NOT_FOUND
  2439     if (sym == @symbol(ERROR_FILE_NOT_FOUND)) {
  2454     if (sym == @symbol(ERROR_FILE_NOT_FOUND)) {
  2440         RETURN ( __mkSmallInteger(ERROR_FILE_NOT_FOUND) );
  2455 	RETURN ( __mkSmallInteger(ERROR_FILE_NOT_FOUND) );
  2441     }
  2456     }
  2442 #endif
  2457 #endif
  2443 #ifdef ERROR_PATH_NOT_FOUND
  2458 #ifdef ERROR_PATH_NOT_FOUND
  2444     if (sym == @symbol(ERROR_PATH_NOT_FOUND)) {
  2459     if (sym == @symbol(ERROR_PATH_NOT_FOUND)) {
  2445         RETURN ( __mkSmallInteger(ERROR_PATH_NOT_FOUND) );
  2460 	RETURN ( __mkSmallInteger(ERROR_PATH_NOT_FOUND) );
  2446     }
  2461     }
  2447 #endif
  2462 #endif
  2448 #ifdef ERROR_TOO_MANY_OPEN_FILES
  2463 #ifdef ERROR_TOO_MANY_OPEN_FILES
  2449     if (sym == @symbol(ERROR_TOO_MANY_OPEN_FILES)) {
  2464     if (sym == @symbol(ERROR_TOO_MANY_OPEN_FILES)) {
  2450         RETURN ( __mkSmallInteger(ERROR_TOO_MANY_OPEN_FILES) );
  2465 	RETURN ( __mkSmallInteger(ERROR_TOO_MANY_OPEN_FILES) );
  2451     }
  2466     }
  2452 #endif
  2467 #endif
  2453 #ifdef ERROR_OPEN_FAILED
  2468 #ifdef ERROR_OPEN_FAILED
  2454     if (sym == @symbol(ERROR_OPEN_FAILED)) {
  2469     if (sym == @symbol(ERROR_OPEN_FAILED)) {
  2455         RETURN ( __mkSmallInteger(ERROR_OPEN_FAILED) );
  2470 	RETURN ( __mkSmallInteger(ERROR_OPEN_FAILED) );
  2456     }
  2471     }
  2457 #endif
  2472 #endif
  2458 #ifdef ERROR_ACCESS_DENIED
  2473 #ifdef ERROR_ACCESS_DENIED
  2459     if (sym == @symbol(ERROR_ACCESS_DENIED)) {
  2474     if (sym == @symbol(ERROR_ACCESS_DENIED)) {
  2460         RETURN ( __mkSmallInteger(ERROR_ACCESS_DENIED) );
  2475 	RETURN ( __mkSmallInteger(ERROR_ACCESS_DENIED) );
  2461     }
  2476     }
  2462 #endif
  2477 #endif
  2463 #ifdef ERROR_INVALID_HANDLE
  2478 #ifdef ERROR_INVALID_HANDLE
  2464     if (sym == @symbol(ERROR_INVALID_HANDLE)) {
  2479     if (sym == @symbol(ERROR_INVALID_HANDLE)) {
  2465         RETURN ( __mkSmallInteger(ERROR_INVALID_HANDLE) );
  2480 	RETURN ( __mkSmallInteger(ERROR_INVALID_HANDLE) );
  2466     }
  2481     }
  2467 #endif
  2482 #endif
  2468 #ifdef ERROR_NOT_ENOUGH_MEMORY
  2483 #ifdef ERROR_NOT_ENOUGH_MEMORY
  2469     if (sym == @symbol(ERROR_NOT_ENOUGH_MEMORY)) {
  2484     if (sym == @symbol(ERROR_NOT_ENOUGH_MEMORY)) {
  2470         RETURN ( __mkSmallInteger(ERROR_NOT_ENOUGH_MEMORY) );
  2485 	RETURN ( __mkSmallInteger(ERROR_NOT_ENOUGH_MEMORY) );
       
  2486     }
       
  2487 #endif
       
  2488 #ifdef ERROR_NO_SYSTEM_RESOURCES
       
  2489     if (sym == @symbol(ERROR_NO_SYSTEM_RESOURCES)) {
       
  2490 	RETURN ( __mkSmallInteger(ERROR_NO_SYSTEM_RESOURCES) );
  2471     }
  2491     }
  2472 #endif
  2492 #endif
  2473 #ifdef ERROR_INVALID_ACCESS
  2493 #ifdef ERROR_INVALID_ACCESS
  2474     if (sym == @symbol(ERROR_INVALID_ACCESS)) {
  2494     if (sym == @symbol(ERROR_INVALID_ACCESS)) {
  2475         RETURN ( __mkSmallInteger(ERROR_INVALID_ACCESS) );
  2495 	RETURN ( __mkSmallInteger(ERROR_INVALID_ACCESS) );
  2476     }
  2496     }
  2477 #endif
  2497 #endif
  2478 #ifdef ERROR_INVALID_DATA
  2498 #ifdef ERROR_INVALID_DATA
  2479     if (sym == @symbol(ERROR_INVALID_DATA)) {
  2499     if (sym == @symbol(ERROR_INVALID_DATA)) {
  2480         RETURN ( __mkSmallInteger(ERROR_INVALID_DATA) );
  2500 	RETURN ( __mkSmallInteger(ERROR_INVALID_DATA) );
  2481     }
  2501     }
  2482 #endif
  2502 #endif
  2483 #ifdef ERROR_INVALID_NAME
  2503 #ifdef ERROR_INVALID_NAME
  2484     if (sym == @symbol(ERROR_INVALID_NAME)) {
  2504     if (sym == @symbol(ERROR_INVALID_NAME)) {
  2485         RETURN ( __mkSmallInteger(ERROR_INVALID_NAME) );
  2505 	RETURN ( __mkSmallInteger(ERROR_INVALID_NAME) );
  2486     }
  2506     }
  2487 #endif
  2507 #endif
  2488 #ifdef ERROR_ARENA_TRASHED
  2508 #ifdef ERROR_ARENA_TRASHED
  2489     if (sym == @symbol(ERROR_ARENA_TRASHED)) {
  2509     if (sym == @symbol(ERROR_ARENA_TRASHED)) {
  2490         RETURN ( __mkSmallInteger(ERROR_ARENA_TRASHED) );
  2510 	RETURN ( __mkSmallInteger(ERROR_ARENA_TRASHED) );
  2491     }
  2511     }
  2492 #endif
  2512 #endif
  2493 #ifdef ERROR_OUTOFMEMORY
  2513 #ifdef ERROR_OUTOFMEMORY
  2494     if (sym == @symbol(ERROR_OUTOFMEMORY)) {
  2514     if (sym == @symbol(ERROR_OUTOFMEMORY)) {
  2495         RETURN ( __mkSmallInteger(ERROR_OUTOFMEMORY) );
  2515 	RETURN ( __mkSmallInteger(ERROR_OUTOFMEMORY) );
  2496     }
  2516     }
  2497 #endif
  2517 #endif
  2498 #ifdef ERROR_BROKEN_PIPE
  2518 #ifdef ERROR_BROKEN_PIPE
  2499     if (sym == @symbol(ERROR_BROKEN_PIPE)) {
  2519     if (sym == @symbol(ERROR_BROKEN_PIPE)) {
  2500         RETURN ( __mkSmallInteger(ERROR_BROKEN_PIPE) );
  2520 	RETURN ( __mkSmallInteger(ERROR_BROKEN_PIPE) );
  2501     }
  2521     }
  2502 #endif
  2522 #endif
  2503 #ifdef ERROR_GEN_FAILURE
  2523 #ifdef ERROR_GEN_FAILURE
  2504     if (sym == @symbol(ERROR_GEN_FAILURE)) {
  2524     if (sym == @symbol(ERROR_GEN_FAILURE)) {
  2505         RETURN ( __mkSmallInteger(ERROR_GEN_FAILURE) );
  2525 	RETURN ( __mkSmallInteger(ERROR_GEN_FAILURE) );
  2506     }
  2526     }
  2507 #endif
  2527 #endif
  2508 #ifdef ERROR_WRITE_PROTECT
  2528 #ifdef ERROR_WRITE_PROTECT
  2509     if (sym == @symbol(ERROR_WRITE_PROTECT)) {
  2529     if (sym == @symbol(ERROR_WRITE_PROTECT)) {
  2510         RETURN ( __mkSmallInteger(ERROR_WRITE_PROTECT) );
  2530 	RETURN ( __mkSmallInteger(ERROR_WRITE_PROTECT) );
  2511     }
  2531     }
  2512 #endif
  2532 #endif
  2513 #ifdef ERROR_WRITE_FAULT
  2533 #ifdef ERROR_WRITE_FAULT
  2514     if (sym == @symbol(ERROR_WRITE_FAULT)) {
  2534     if (sym == @symbol(ERROR_WRITE_FAULT)) {
  2515         RETURN ( __mkSmallInteger(ERROR_WRITE_FAULT) );
  2535 	RETURN ( __mkSmallInteger(ERROR_WRITE_FAULT) );
  2516     }
  2536     }
  2517 #endif
  2537 #endif
  2518 #ifdef ERROR_READ_FAULT
  2538 #ifdef ERROR_READ_FAULT
  2519     if (sym == @symbol(ERROR_READ_FAULT)) {
  2539     if (sym == @symbol(ERROR_READ_FAULT)) {
  2520         RETURN ( __mkSmallInteger(ERROR_READ_FAULT) );
  2540 	RETURN ( __mkSmallInteger(ERROR_READ_FAULT) );
  2521     }
  2541     }
  2522 #endif
  2542 #endif
  2523 #ifdef ERROR_HANDLE_DISK_FULL
  2543 #ifdef ERROR_HANDLE_DISK_FULL
  2524     if (sym == @symbol(ERROR_HANDLE_DISK_FULL)) {
  2544     if (sym == @symbol(ERROR_HANDLE_DISK_FULL)) {
  2525         RETURN ( __mkSmallInteger(ERROR_HANDLE_DISK_FULL) );
  2545 	RETURN ( __mkSmallInteger(ERROR_HANDLE_DISK_FULL) );
  2526     }
  2546     }
  2527 #endif
  2547 #endif
  2528 #ifdef ERROR_DISK_FULL
  2548 #ifdef ERROR_DISK_FULL
  2529     if (sym == @symbol(ERROR_DISK_FULL)) {
  2549     if (sym == @symbol(ERROR_DISK_FULL)) {
  2530         RETURN ( __mkSmallInteger(ERROR_DISK_FULL) );
  2550 	RETURN ( __mkSmallInteger(ERROR_DISK_FULL) );
  2531     }
  2551     }
  2532 #endif
  2552 #endif
  2533 #ifdef ERROR_ERROR_SHARING_VIOLATION
  2553 #ifdef ERROR_ERROR_SHARING_VIOLATION
  2534     if (sym == @symbol(ERROR_ERROR_SHARING_VIOLATION)) {
  2554     if (sym == @symbol(ERROR_ERROR_SHARING_VIOLATION)) {
  2535         RETURN ( __mkSmallInteger(ERROR_ERROR_SHARING_VIOLATION) );
  2555 	RETURN ( __mkSmallInteger(ERROR_ERROR_SHARING_VIOLATION) );
  2536     }
  2556     }
  2537 #endif
  2557 #endif
  2538 #ifdef ERROR_LOCK_VIOLATION
  2558 #ifdef ERROR_LOCK_VIOLATION
  2539     if (sym == @symbol(ERROR_LOCK_VIOLATION)) {
  2559     if (sym == @symbol(ERROR_LOCK_VIOLATION)) {
  2540         RETURN ( __mkSmallInteger(ERROR_LOCK_VIOLATION) );
  2560 	RETURN ( __mkSmallInteger(ERROR_LOCK_VIOLATION) );
  2541     }
  2561     }
  2542 #endif
  2562 #endif
  2543 #ifdef ERROR_INVALID_PARAMETER
  2563 #ifdef ERROR_INVALID_PARAMETER
  2544     if (sym == @symbol(ERROR_INVALID_PARAMETER)) {
  2564     if (sym == @symbol(ERROR_INVALID_PARAMETER)) {
  2545         RETURN ( __mkSmallInteger(ERROR_INVALID_PARAMETER) );
  2565 	RETURN ( __mkSmallInteger(ERROR_INVALID_PARAMETER) );
  2546     }
  2566     }
  2547 #endif
  2567 #endif
  2548 #ifdef ERROR_NET_WRITE_FAULT
  2568 #ifdef ERROR_NET_WRITE_FAULT
  2549     if (sym == @symbol(ERROR_NET_WRITE_FAULT)) {
  2569     if (sym == @symbol(ERROR_NET_WRITE_FAULT)) {
  2550         RETURN ( __mkSmallInteger(ERROR_NET_WRITE_FAULT) );
  2570 	RETURN ( __mkSmallInteger(ERROR_NET_WRITE_FAULT) );
  2551     }
  2571     }
  2552 #endif
  2572 #endif
  2553 #ifdef ERROR_NOT_SUPPORTED
  2573 #ifdef ERROR_NOT_SUPPORTED
  2554     if (sym == @symbol(ERROR_NOT_SUPPORTED)) {
  2574     if (sym == @symbol(ERROR_NOT_SUPPORTED)) {
  2555         RETURN ( __mkSmallInteger(ERROR_NOT_SUPPORTED) );
  2575 	RETURN ( __mkSmallInteger(ERROR_NOT_SUPPORTED) );
  2556     }
  2576     }
  2557 #endif
  2577 #endif
  2558 #ifdef ERROR_REM_NOT_LIST
  2578 #ifdef ERROR_REM_NOT_LIST
  2559     if (sym == @symbol(ERROR_REM_NOT_LIST)) {
  2579     if (sym == @symbol(ERROR_REM_NOT_LIST)) {
  2560         RETURN ( __mkSmallInteger(ERROR_REM_NOT_LIST) );
  2580 	RETURN ( __mkSmallInteger(ERROR_REM_NOT_LIST) );
  2561     }
  2581     }
  2562 #endif
  2582 #endif
  2563 #ifdef ERROR_NETWORK_ACCESS_DENIED
  2583 #ifdef ERROR_NETWORK_ACCESS_DENIED
  2564     if (sym == @symbol(ERROR_NETWORK_ACCESS_DENIED)) {
  2584     if (sym == @symbol(ERROR_NETWORK_ACCESS_DENIED)) {
  2565         RETURN ( __mkSmallInteger(ERROR_NETWORK_ACCESS_DENIED) );
  2585 	RETURN ( __mkSmallInteger(ERROR_NETWORK_ACCESS_DENIED) );
  2566     }
  2586     }
  2567 #endif
  2587 #endif
  2568 #ifdef ERROR_DUP_NAME
  2588 #ifdef ERROR_DUP_NAME
  2569     if (sym == @symbol(ERROR_DUP_NAME)) {
  2589     if (sym == @symbol(ERROR_DUP_NAME)) {
  2570         RETURN ( __mkSmallInteger(ERROR_DUP_NAME) );
  2590 	RETURN ( __mkSmallInteger(ERROR_DUP_NAME) );
  2571     }
  2591     }
  2572 #endif
  2592 #endif
  2573 #ifdef ERROR_BAD_NETPATH
  2593 #ifdef ERROR_BAD_NETPATH
  2574     if (sym == @symbol(ERROR_BAD_NETPATH)) {
  2594     if (sym == @symbol(ERROR_BAD_NETPATH)) {
  2575         RETURN ( __mkSmallInteger(ERROR_BAD_NETPATH) );
  2595 	RETURN ( __mkSmallInteger(ERROR_BAD_NETPATH) );
  2576     }
  2596     }
  2577 #endif
  2597 #endif
  2578 #ifdef ERROR_NETWORK_BUSY
  2598 #ifdef ERROR_NETWORK_BUSY
  2579     if (sym == @symbol(ERROR_NETWORK_BUSY)) {
  2599     if (sym == @symbol(ERROR_NETWORK_BUSY)) {
  2580         RETURN ( __mkSmallInteger(ERROR_NETWORK_BUSY) );
  2600 	RETURN ( __mkSmallInteger(ERROR_NETWORK_BUSY) );
  2581     }
  2601     }
  2582 #endif
  2602 #endif
  2583 #ifdef ERROR_DRIVE_LOCKED
  2603 #ifdef ERROR_DRIVE_LOCKED
  2584     if (sym == @symbol(ERROR_DRIVE_LOCKED)) {
  2604     if (sym == @symbol(ERROR_DRIVE_LOCKED)) {
  2585         RETURN ( __mkSmallInteger(ERROR_DRIVE_LOCKED) );
  2605 	RETURN ( __mkSmallInteger(ERROR_DRIVE_LOCKED) );
  2586     }
  2606     }
  2587 #endif
  2607 #endif
  2588 #ifdef ERROR_INVALID_DRIVE
  2608 #ifdef ERROR_INVALID_DRIVE
  2589     if (sym == @symbol(ERROR_INVALID_DRIVE)) {
  2609     if (sym == @symbol(ERROR_INVALID_DRIVE)) {
  2590         RETURN ( __mkSmallInteger(ERROR_INVALID_DRIVE) );
  2610 	RETURN ( __mkSmallInteger(ERROR_INVALID_DRIVE) );
  2591     }
  2611     }
  2592 #endif
  2612 #endif
  2593 #ifdef ERROR_WRONG_DISK
  2613 #ifdef ERROR_WRONG_DISK
  2594     if (sym == @symbol(ERROR_WRONG_DISK)) {
  2614     if (sym == @symbol(ERROR_WRONG_DISK)) {
  2595         RETURN ( __mkSmallInteger(ERROR_WRONG_DISK) );
  2615 	RETURN ( __mkSmallInteger(ERROR_WRONG_DISK) );
  2596     }
  2616     }
  2597 #endif
  2617 #endif
  2598 #ifdef ERROR_CURRENT_DIRECTORY
  2618 #ifdef ERROR_CURRENT_DIRECTORY
  2599     if (sym == @symbol(ERROR_CURRENT_DIRECTORY)) {
  2619     if (sym == @symbol(ERROR_CURRENT_DIRECTORY)) {
  2600         RETURN ( __mkSmallInteger(ERROR_CURRENT_DIRECTORY) );
  2620 	RETURN ( __mkSmallInteger(ERROR_CURRENT_DIRECTORY) );
  2601     }
  2621     }
  2602 #endif
  2622 #endif
  2603 #ifdef ERROR_CANNOT_MAKE
  2623 #ifdef ERROR_CANNOT_MAKE
  2604     if (sym == @symbol(ERROR_CANNOT_MAKE)) {
  2624     if (sym == @symbol(ERROR_CANNOT_MAKE)) {
  2605         RETURN ( __mkSmallInteger(ERROR_CANNOT_MAKE) );
  2625 	RETURN ( __mkSmallInteger(ERROR_CANNOT_MAKE) );
  2606     }
  2626     }
  2607 #endif
  2627 #endif
  2608 #ifdef ERROR_NO_MORE_FILES
  2628 #ifdef ERROR_NO_MORE_FILES
  2609     if (sym == @symbol(ERROR_NO_MORE_FILES)) {
  2629     if (sym == @symbol(ERROR_NO_MORE_FILES)) {
  2610         RETURN ( __mkSmallInteger(ERROR_NO_MORE_FILES) );
  2630 	RETURN ( __mkSmallInteger(ERROR_NO_MORE_FILES) );
  2611     }
  2631     }
  2612 #endif
  2632 #endif
  2613 #ifdef ERROR_NOT_READY
  2633 #ifdef ERROR_NOT_READY
  2614     if (sym == @symbol(ERROR_NOT_READY)) {
  2634     if (sym == @symbol(ERROR_NOT_READY)) {
  2615         RETURN ( __mkSmallInteger(ERROR_NOT_READY) );
  2635 	RETURN ( __mkSmallInteger(ERROR_NOT_READY) );
  2616     }
  2636     }
  2617 #endif
  2637 #endif
  2618 #ifdef ERROR_NOT_DOS_DISK
  2638 #ifdef ERROR_NOT_DOS_DISK
  2619     if (sym == @symbol(ERROR_NOT_DOS_DISK)) {
  2639     if (sym == @symbol(ERROR_NOT_DOS_DISK)) {
  2620         RETURN ( __mkSmallInteger(ERROR_NOT_DOS_DISK) );
  2640 	RETURN ( __mkSmallInteger(ERROR_NOT_DOS_DISK) );
  2621     }
  2641     }
  2622 #endif
  2642 #endif
  2623 #ifdef ERROR_OUT_OF_PAPER
  2643 #ifdef ERROR_OUT_OF_PAPER
  2624     if (sym == @symbol(ERROR_OUT_OF_PAPER)) {
  2644     if (sym == @symbol(ERROR_OUT_OF_PAPER)) {
  2625         RETURN ( __mkSmallInteger(ERROR_OUT_OF_PAPER) );
  2645 	RETURN ( __mkSmallInteger(ERROR_OUT_OF_PAPER) );
  2626     }
  2646     }
  2627 #endif
  2647 #endif
  2628 #ifdef ERROR_PRINTQ_FULL
  2648 #ifdef ERROR_PRINTQ_FULL
  2629     if (sym == @symbol(ERROR_PRINTQ_FULL)) {
  2649     if (sym == @symbol(ERROR_PRINTQ_FULL)) {
  2630         RETURN ( __mkSmallInteger(ERROR_PRINTQ_FULL) );
  2650 	RETURN ( __mkSmallInteger(ERROR_PRINTQ_FULL) );
  2631     }
  2651     }
  2632 #endif
  2652 #endif
  2633 
  2653 
  2634     /*
  2654     /*
  2635      * POSIX errnos - these should be defined
  2655      * POSIX errnos - these should be defined
  2636      */
  2656      */
  2637 #ifdef EPERM
  2657 #ifdef EPERM
  2638     if (sym == @symbol(EPERM)) {
  2658     if (sym == @symbol(EPERM)) {
  2639         RETURN ( __mkSmallInteger(EPERM) );
  2659 	RETURN ( __mkSmallInteger(EPERM) );
  2640     }
  2660     }
  2641 #endif
  2661 #endif
  2642 
  2662 
  2643 #ifdef ENOENT
  2663 #ifdef ENOENT
  2644     if (sym == @symbol(ENOENT)) {
  2664     if (sym == @symbol(ENOENT)) {
  2645         RETURN ( __mkSmallInteger(ENOENT) );
  2665 	RETURN ( __mkSmallInteger(ENOENT) );
  2646     }
  2666     }
  2647 #endif
  2667 #endif
  2648 
  2668 
  2649 #ifdef ESRCH
  2669 #ifdef ESRCH
  2650     if (sym == @symbol(ESRCH)) {
  2670     if (sym == @symbol(ESRCH)) {
  2651         RETURN ( __mkSmallInteger(ESRCH) );
  2671 	RETURN ( __mkSmallInteger(ESRCH) );
  2652     }
  2672     }
  2653 #endif
  2673 #endif
  2654 
  2674 
  2655 #ifdef EINTR
  2675 #ifdef EINTR
  2656     if (sym == @symbol(EINTR)) {
  2676     if (sym == @symbol(EINTR)) {
  2657         RETURN ( __mkSmallInteger(EINTR) );
  2677 	RETURN ( __mkSmallInteger(EINTR) );
  2658     }
  2678     }
  2659 #endif
  2679 #endif
  2660 
  2680 
  2661 #ifdef EIO
  2681 #ifdef EIO
  2662     if (sym == @symbol(EIO)) {
  2682     if (sym == @symbol(EIO)) {
  2663         RETURN ( __mkSmallInteger(EIO) );
  2683 	RETURN ( __mkSmallInteger(EIO) );
  2664     }
  2684     }
  2665 #endif
  2685 #endif
  2666 
  2686 
  2667 #ifdef ENXIO
  2687 #ifdef ENXIO
  2668     if (sym == @symbol(ENXIO)) {
  2688     if (sym == @symbol(ENXIO)) {
  2669         RETURN ( __mkSmallInteger(ENXIO) );
  2689 	RETURN ( __mkSmallInteger(ENXIO) );
  2670     }
  2690     }
  2671 #endif
  2691 #endif
  2672 
  2692 
  2673 #ifdef E2BIG
  2693 #ifdef E2BIG
  2674     if (sym == @symbol(E2BIG)) {
  2694     if (sym == @symbol(E2BIG)) {
  2675         RETURN ( __mkSmallInteger(E2BIG) );
  2695 	RETURN ( __mkSmallInteger(E2BIG) );
  2676     }
  2696     }
  2677 #endif
  2697 #endif
  2678 
  2698 
  2679 #ifdef ENOEXEC
  2699 #ifdef ENOEXEC
  2680     if (sym == @symbol(ENOEXEC)) {
  2700     if (sym == @symbol(ENOEXEC)) {
  2681         RETURN ( __mkSmallInteger(ENOEXEC) );
  2701 	RETURN ( __mkSmallInteger(ENOEXEC) );
  2682     }
  2702     }
  2683 #endif
  2703 #endif
  2684 
  2704 
  2685 #ifdef EBADF
  2705 #ifdef EBADF
  2686     if (sym == @symbol(EBADF)) {
  2706     if (sym == @symbol(EBADF)) {
  2687         RETURN ( __mkSmallInteger(EBADF) );
  2707 	RETURN ( __mkSmallInteger(EBADF) );
  2688     }
  2708     }
  2689 #endif
  2709 #endif
  2690 
  2710 
  2691 #ifdef ECHILD
  2711 #ifdef ECHILD
  2692     if (sym == @symbol(ECHILD)) {
  2712     if (sym == @symbol(ECHILD)) {
  2693         RETURN ( __mkSmallInteger(ECHILD) );
  2713 	RETURN ( __mkSmallInteger(ECHILD) );
  2694     }
  2714     }
  2695 #endif
  2715 #endif
  2696 
  2716 
  2697 #if defined(EAGAIN)
  2717 #if defined(EAGAIN)
  2698     if (sym == @symbol(EAGAIN)) {
  2718     if (sym == @symbol(EAGAIN)) {
  2699         RETURN ( __mkSmallInteger(EAGAIN) );
  2719 	RETURN ( __mkSmallInteger(EAGAIN) );
  2700     }
  2720     }
  2701 #endif
  2721 #endif
  2702 
  2722 
  2703 #ifdef ENOMEM
  2723 #ifdef ENOMEM
  2704     if (sym == @symbol(ENOMEM)) {
  2724     if (sym == @symbol(ENOMEM)) {
  2705         RETURN ( __mkSmallInteger(ENOMEM) );
  2725 	RETURN ( __mkSmallInteger(ENOMEM) );
  2706     }
  2726     }
  2707 #endif
  2727 #endif
  2708 
  2728 
  2709 #ifdef EACCES
  2729 #ifdef EACCES
  2710     if (sym == @symbol(EACCES)) {
  2730     if (sym == @symbol(EACCES)) {
  2711         RETURN ( __mkSmallInteger(EACCES) );
  2731 	RETURN ( __mkSmallInteger(EACCES) );
  2712     }
  2732     }
  2713 #endif
  2733 #endif
  2714 
  2734 
  2715 #ifdef EFAULT
  2735 #ifdef EFAULT
  2716     if (sym == @symbol(EFAULT)) {
  2736     if (sym == @symbol(EFAULT)) {
  2717         RETURN ( __mkSmallInteger(EFAULT) );
  2737 	RETURN ( __mkSmallInteger(EFAULT) );
  2718     }
  2738     }
  2719 #endif
  2739 #endif
  2720 
  2740 
  2721 #ifdef EBUSY
  2741 #ifdef EBUSY
  2722     if (sym == @symbol(EBUSY)) {
  2742     if (sym == @symbol(EBUSY)) {
  2723         RETURN ( __mkSmallInteger(EBUSY) );
  2743 	RETURN ( __mkSmallInteger(EBUSY) );
  2724     }
  2744     }
  2725 #endif
  2745 #endif
  2726 
  2746 
  2727 #ifdef EXDEV
  2747 #ifdef EXDEV
  2728     if (sym == @symbol(EXDEV)) {
  2748     if (sym == @symbol(EXDEV)) {
  2729         RETURN ( __mkSmallInteger(EXDEV) );
  2749 	RETURN ( __mkSmallInteger(EXDEV) );
  2730     }
  2750     }
  2731 #endif
  2751 #endif
  2732 
  2752 
  2733 #ifdef ENODEV
  2753 #ifdef ENODEV
  2734     if (sym == @symbol(ENODEV)) {
  2754     if (sym == @symbol(ENODEV)) {
  2735         RETURN ( __mkSmallInteger(ENODEV) );
  2755 	RETURN ( __mkSmallInteger(ENODEV) );
  2736     }
  2756     }
  2737 #endif
  2757 #endif
  2738 
  2758 
  2739 #ifdef ENOTDIR
  2759 #ifdef ENOTDIR
  2740     if (sym == @symbol(ENOTDIR)) {
  2760     if (sym == @symbol(ENOTDIR)) {
  2741         RETURN ( __mkSmallInteger(ENOTDIR) );
  2761 	RETURN ( __mkSmallInteger(ENOTDIR) );
  2742     }
  2762     }
  2743 #endif
  2763 #endif
  2744 
  2764 
  2745 #ifdef EISDIR
  2765 #ifdef EISDIR
  2746     if (sym == @symbol(EISDIR)) {
  2766     if (sym == @symbol(EISDIR)) {
  2747         RETURN ( __mkSmallInteger(EISDIR) );
  2767 	RETURN ( __mkSmallInteger(EISDIR) );
  2748     }
  2768     }
  2749 #endif
  2769 #endif
  2750 
  2770 
  2751 #ifdef EINVAL
  2771 #ifdef EINVAL
  2752     if (sym == @symbol(EINVAL)) {
  2772     if (sym == @symbol(EINVAL)) {
  2753         RETURN ( __mkSmallInteger(EINVAL) );
  2773 	RETURN ( __mkSmallInteger(EINVAL) );
  2754     }
  2774     }
  2755 #endif
  2775 #endif
  2756 
  2776 
  2757 #ifdef ENFILE
  2777 #ifdef ENFILE
  2758     if (sym == @symbol(ENFILE)) {
  2778     if (sym == @symbol(ENFILE)) {
  2759         RETURN ( __mkSmallInteger(ENFILE) );
  2779 	RETURN ( __mkSmallInteger(ENFILE) );
  2760     }
  2780     }
  2761 #endif
  2781 #endif
  2762 
  2782 
  2763 #ifdef EMFILE
  2783 #ifdef EMFILE
  2764     if (sym == @symbol(EMFILE)) {
  2784     if (sym == @symbol(EMFILE)) {
  2765         RETURN ( __mkSmallInteger(EMFILE) );
  2785 	RETURN ( __mkSmallInteger(EMFILE) );
  2766     }
  2786     }
  2767 #endif
  2787 #endif
  2768 
  2788 
  2769 #ifdef ENOTTY
  2789 #ifdef ENOTTY
  2770     if (sym == @symbol(ENOTTY)) {
  2790     if (sym == @symbol(ENOTTY)) {
  2771         RETURN ( __mkSmallInteger(ENOTTY) );
  2791 	RETURN ( __mkSmallInteger(ENOTTY) );
  2772     }
  2792     }
  2773 #endif
  2793 #endif
  2774 
  2794 
  2775 #ifdef EFBIG
  2795 #ifdef EFBIG
  2776     if (sym == @symbol(EFBIG)) {
  2796     if (sym == @symbol(EFBIG)) {
  2777         RETURN ( __mkSmallInteger(EFBIG) );
  2797 	RETURN ( __mkSmallInteger(EFBIG) );
  2778     }
  2798     }
  2779 #endif
  2799 #endif
  2780 
  2800 
  2781 #ifdef ENOSPC
  2801 #ifdef ENOSPC
  2782     if (sym == @symbol(ENOSPC)) {
  2802     if (sym == @symbol(ENOSPC)) {
  2783         RETURN ( __mkSmallInteger(ENOSPC) );
  2803 	RETURN ( __mkSmallInteger(ENOSPC) );
  2784     }
  2804     }
  2785 #endif
  2805 #endif
  2786 
  2806 
  2787 #ifdef ESPIPE
  2807 #ifdef ESPIPE
  2788     if (sym == @symbol(ESPIPE)) {
  2808     if (sym == @symbol(ESPIPE)) {
  2789         RETURN ( __mkSmallInteger(ESPIPE) );
  2809 	RETURN ( __mkSmallInteger(ESPIPE) );
  2790     }
  2810     }
  2791 #endif
  2811 #endif
  2792 
  2812 
  2793 #ifdef EROFS
  2813 #ifdef EROFS
  2794     if (sym == @symbol(EROFS)) {
  2814     if (sym == @symbol(EROFS)) {
  2795         RETURN ( __mkSmallInteger(EROFS) );
  2815 	RETURN ( __mkSmallInteger(EROFS) );
  2796     }
  2816     }
  2797 #endif
  2817 #endif
  2798 
  2818 
  2799 #ifdef EMLINK
  2819 #ifdef EMLINK
  2800     if (sym == @symbol(EMLINK)) {
  2820     if (sym == @symbol(EMLINK)) {
  2801         RETURN ( __mkSmallInteger(EMLINK) );
  2821 	RETURN ( __mkSmallInteger(EMLINK) );
  2802     }
  2822     }
  2803 #endif
  2823 #endif
  2804 
  2824 
  2805 #ifdef EPIPE
  2825 #ifdef EPIPE
  2806     if (sym == @symbol(EPIPE)) {
  2826     if (sym == @symbol(EPIPE)) {
  2807         RETURN ( __mkSmallInteger(EPIPE) );
  2827 	RETURN ( __mkSmallInteger(EPIPE) );
  2808     }
  2828     }
  2809 #endif
  2829 #endif
  2810 
  2830 
  2811 #ifdef EDOM
  2831 #ifdef EDOM
  2812     if (sym == @symbol(EDOM)) {
  2832     if (sym == @symbol(EDOM)) {
  2813         RETURN ( __mkSmallInteger(EDOM) );
  2833 	RETURN ( __mkSmallInteger(EDOM) );
  2814     }
  2834     }
  2815 #endif
  2835 #endif
  2816 
  2836 
  2817 #ifdef ERANGE
  2837 #ifdef ERANGE
  2818     if (sym == @symbol(ERANGE)) {
  2838     if (sym == @symbol(ERANGE)) {
  2819         RETURN ( __mkSmallInteger(ERANGE) );
  2839 	RETURN ( __mkSmallInteger(ERANGE) );
  2820     }
  2840     }
  2821 #endif
  2841 #endif
  2822 
  2842 
  2823 #ifdef EDEADLK
  2843 #ifdef EDEADLK
  2824     if (sym == @symbol(EDEADLK)) {
  2844     if (sym == @symbol(EDEADLK)) {
  2825         RETURN ( __mkSmallInteger(EDEADLK) );
  2845 	RETURN ( __mkSmallInteger(EDEADLK) );
  2826     }
  2846     }
  2827 #endif
  2847 #endif
  2828 
  2848 
  2829 #ifdef ENAMETOOLONG
  2849 #ifdef ENAMETOOLONG
  2830     if (sym == @symbol(ENAMETOOLONG)) {
  2850     if (sym == @symbol(ENAMETOOLONG)) {
  2831         RETURN ( __mkSmallInteger(ENAMETOOLONG) );
  2851 	RETURN ( __mkSmallInteger(ENAMETOOLONG) );
  2832     }
  2852     }
  2833 #endif
  2853 #endif
  2834 
  2854 
  2835 #ifdef ENOLCK
  2855 #ifdef ENOLCK
  2836     if (sym == @symbol(ENOLCK)) {
  2856     if (sym == @symbol(ENOLCK)) {
  2837         RETURN ( __mkSmallInteger(ENOLCK) );
  2857 	RETURN ( __mkSmallInteger(ENOLCK) );
  2838     }
  2858     }
  2839 #endif
  2859 #endif
  2840 
  2860 
  2841 #ifdef ENOSYS
  2861 #ifdef ENOSYS
  2842     if (sym == @symbol(ENOSYS)) {
  2862     if (sym == @symbol(ENOSYS)) {
  2843         RETURN ( __mkSmallInteger(ENOSYS) );
  2863 	RETURN ( __mkSmallInteger(ENOSYS) );
  2844     }
  2864     }
  2845 #endif
  2865 #endif
  2846 
  2866 
  2847 #ifdef ENOTEMPTY
  2867 #ifdef ENOTEMPTY
  2848     if (sym == @symbol(ENOTEMPTY)) {
  2868     if (sym == @symbol(ENOTEMPTY)) {
  2849         RETURN ( __mkSmallInteger(ENOTEMPTY) );
  2869 	RETURN ( __mkSmallInteger(ENOTEMPTY) );
  2850     }
  2870     }
  2851 #endif
  2871 #endif
  2852 
  2872 
  2853 #ifdef EEXIST
  2873 #ifdef EEXIST
  2854     if (sym == @symbol(EEXIST)) {
  2874     if (sym == @symbol(EEXIST)) {
  2855         RETURN ( __mkSmallInteger(EEXIST) );
  2875 	RETURN ( __mkSmallInteger(EEXIST) );
  2856     }
  2876     }
  2857 #endif
  2877 #endif
  2858 
  2878 
  2859 #ifdef EILSEQ
  2879 #ifdef EILSEQ
  2860     if (sym == @symbol(EILSEQ)) {
  2880     if (sym == @symbol(EILSEQ)) {
  2861         RETURN ( __mkSmallInteger(EILSEQ) );
  2881 	RETURN ( __mkSmallInteger(EILSEQ) );
  2862     }
  2882     }
  2863 #endif
  2883 #endif
  2864 
  2884 
  2865     /*
  2885     /*
  2866      * XPG3 errnos - defined on most systems
  2886      * XPG3 errnos - defined on most systems
  2867      */
  2887      */
  2868 #ifdef ENOTBLK
  2888 #ifdef ENOTBLK
  2869     if (sym == @symbol(ENOTBLK)) {
  2889     if (sym == @symbol(ENOTBLK)) {
  2870         RETURN ( __mkSmallInteger(ENOTBLK) );
  2890 	RETURN ( __mkSmallInteger(ENOTBLK) );
  2871     }
  2891     }
  2872 #endif
  2892 #endif
  2873 
  2893 
  2874 #ifdef ETXTBSY
  2894 #ifdef ETXTBSY
  2875     if (sym == @symbol(ETXTBSY)) {
  2895     if (sym == @symbol(ETXTBSY)) {
  2876         RETURN ( __mkSmallInteger(ETXTBSY) );
  2896 	RETURN ( __mkSmallInteger(ETXTBSY) );
  2877     }
  2897     }
  2878 #endif
  2898 #endif
  2879 
  2899 
  2880     /*
  2900     /*
  2881      * some others
  2901      * some others
  2882      */
  2902      */
  2883 #ifdef EWOULDBLOCK
  2903 #ifdef EWOULDBLOCK
  2884     if (sym == @symbol(EWOULDBLOCK)) {
  2904     if (sym == @symbol(EWOULDBLOCK)) {
  2885         RETURN ( __mkSmallInteger(EWOULDBLOCK) );
  2905 	RETURN ( __mkSmallInteger(EWOULDBLOCK) );
  2886     }
  2906     }
  2887 #endif
  2907 #endif
  2888 
  2908 
  2889 #ifdef ENOMSG
  2909 #ifdef ENOMSG
  2890     if (sym == @symbol(ENOMSG)) {
  2910     if (sym == @symbol(ENOMSG)) {
  2891         RETURN ( __mkSmallInteger(ENOMSG) );
  2911 	RETURN ( __mkSmallInteger(ENOMSG) );
  2892     }
  2912     }
  2893 #endif
  2913 #endif
  2894 
  2914 
  2895 #ifdef ELOOP
  2915 #ifdef ELOOP
  2896     if (sym == @symbol(ELOOP)) {
  2916     if (sym == @symbol(ELOOP)) {
  2897         RETURN ( __mkSmallInteger(ELOOP) );
  2917 	RETURN ( __mkSmallInteger(ELOOP) );
  2898     }
  2918     }
  2899 #endif
  2919 #endif
  2900 
  2920 
  2901     /*
  2921     /*
  2902      * some stream errors
  2922      * some stream errors
  2903      */
  2923      */
  2904 #ifdef ETIME
  2924 #ifdef ETIME
  2905     if (sym == @symbol(ETIME)) {
  2925     if (sym == @symbol(ETIME)) {
  2906         RETURN ( __mkSmallInteger(ETIME) );
  2926 	RETURN ( __mkSmallInteger(ETIME) );
  2907     }
  2927     }
  2908 #endif
  2928 #endif
  2909 
  2929 
  2910 #ifdef ENOSR
  2930 #ifdef ENOSR
  2911     if (sym == @symbol(ENOSR)) {
  2931     if (sym == @symbol(ENOSR)) {
  2912         RETURN ( __mkSmallInteger(ENOSR) );
  2932 	RETURN ( __mkSmallInteger(ENOSR) );
  2913     }
  2933     }
  2914 #endif
  2934 #endif
  2915 
  2935 
  2916 #ifdef ENOSTR
  2936 #ifdef ENOSTR
  2917     if (sym == @symbol(ENOSTR)) {
  2937     if (sym == @symbol(ENOSTR)) {
  2918         RETURN ( __mkSmallInteger(ENOSTR) );
  2938 	RETURN ( __mkSmallInteger(ENOSTR) );
  2919     }
  2939     }
  2920 #endif
  2940 #endif
  2921 
  2941 
  2922 #ifdef ECOMM
  2942 #ifdef ECOMM
  2923     if (sym == @symbol(ECOMM)) {
  2943     if (sym == @symbol(ECOMM)) {
  2924         RETURN ( __mkSmallInteger(ECOMM) );
  2944 	RETURN ( __mkSmallInteger(ECOMM) );
  2925     }
  2945     }
  2926 #endif
  2946 #endif
  2927 
  2947 
  2928 #ifdef EPROTO
  2948 #ifdef EPROTO
  2929     if (sym == @symbol(EPROTO)) {
  2949     if (sym == @symbol(EPROTO)) {
  2930         RETURN ( __mkSmallInteger(EPROTO) );
  2950 	RETURN ( __mkSmallInteger(EPROTO) );
  2931     }
  2951     }
  2932 #endif
  2952 #endif
  2933 
  2953 
  2934     /*
  2954     /*
  2935      * nfs errors
  2955      * nfs errors
  2936      */
  2956      */
  2937 #ifdef ESTALE
  2957 #ifdef ESTALE
  2938     if (sym == @symbol(ESTALE)) {
  2958     if (sym == @symbol(ESTALE)) {
  2939         RETURN ( __mkSmallInteger(ESTALE) );
  2959 	RETURN ( __mkSmallInteger(ESTALE) );
  2940     }
  2960     }
  2941 #endif
  2961 #endif
  2942 
  2962 
  2943 #ifdef EREMOTE
  2963 #ifdef EREMOTE
  2944     if (sym == @symbol(EREMOTE)) {
  2964     if (sym == @symbol(EREMOTE)) {
  2945         RETURN ( __mkSmallInteger(EREMOTE) );
  2965 	RETURN ( __mkSmallInteger(EREMOTE) );
  2946     }
  2966     }
  2947 #endif
  2967 #endif
  2948 
  2968 
  2949     /*
  2969     /*
  2950      * some networking errors
  2970      * some networking errors
  2951      */
  2971      */
  2952 #ifdef EINPROGRESS
  2972 #ifdef EINPROGRESS
  2953     if (sym == @symbol(EINPROGRESS)) {
  2973     if (sym == @symbol(EINPROGRESS)) {
  2954         RETURN ( __mkSmallInteger(EINPROGRESS) );
  2974 	RETURN ( __mkSmallInteger(EINPROGRESS) );
  2955     }
  2975     }
  2956 #endif
  2976 #endif
  2957 
  2977 
  2958 #ifdef EALREADY
  2978 #ifdef EALREADY
  2959     if (sym == @symbol(EALREADY)) {
  2979     if (sym == @symbol(EALREADY)) {
  2960         RETURN ( __mkSmallInteger(EALREADY) );
  2980 	RETURN ( __mkSmallInteger(EALREADY) );
  2961     }
  2981     }
  2962 #endif
  2982 #endif
  2963 
  2983 
  2964 #ifdef ENOTSOCK
  2984 #ifdef ENOTSOCK
  2965     if (sym == @symbol(ENOTSOCK)) {
  2985     if (sym == @symbol(ENOTSOCK)) {
  2966         RETURN ( __mkSmallInteger(ENOTSOCK) );
  2986 	RETURN ( __mkSmallInteger(ENOTSOCK) );
  2967     }
  2987     }
  2968 #endif
  2988 #endif
  2969 
  2989 
  2970 #ifdef EDESTADDRREQ
  2990 #ifdef EDESTADDRREQ
  2971     if (sym == @symbol(EDESTADDRREQ)) {
  2991     if (sym == @symbol(EDESTADDRREQ)) {
  2972         RETURN ( __mkSmallInteger(EDESTADDRREQ) );
  2992 	RETURN ( __mkSmallInteger(EDESTADDRREQ) );
  2973     }
  2993     }
  2974 #endif
  2994 #endif
  2975 
  2995 
  2976 #ifdef EMSGSIZE
  2996 #ifdef EMSGSIZE
  2977     if (sym == @symbol(EMSGSIZE)) {
  2997     if (sym == @symbol(EMSGSIZE)) {
  2978         RETURN ( __mkSmallInteger(EMSGSIZE) );
  2998 	RETURN ( __mkSmallInteger(EMSGSIZE) );
  2979     }
  2999     }
  2980 #endif
  3000 #endif
  2981 
  3001 
  2982 #ifdef EPROTOTYPE
  3002 #ifdef EPROTOTYPE
  2983     if (sym == @symbol(EPROTOTYPE)) {
  3003     if (sym == @symbol(EPROTOTYPE)) {
  2984         RETURN ( __mkSmallInteger(EPROTOTYPE) );
  3004 	RETURN ( __mkSmallInteger(EPROTOTYPE) );
  2985     }
  3005     }
  2986 #endif
  3006 #endif
  2987 
  3007 
  2988 #ifdef ENOPROTOOPT
  3008 #ifdef ENOPROTOOPT
  2989     if (sym == @symbol(ENOPROTOOPT)) {
  3009     if (sym == @symbol(ENOPROTOOPT)) {
  2990         RETURN ( __mkSmallInteger(ENOPROTOOPT) );
  3010 	RETURN ( __mkSmallInteger(ENOPROTOOPT) );
  2991     }
  3011     }
  2992 #endif
  3012 #endif
  2993 
  3013 
  2994 #ifdef EPROTONOSUPPORT
  3014 #ifdef EPROTONOSUPPORT
  2995     if (sym == @symbol(EPROTONOSUPPORT)) {
  3015     if (sym == @symbol(EPROTONOSUPPORT)) {
  2996         RETURN ( __mkSmallInteger(EPROTONOSUPPORT) );
  3016 	RETURN ( __mkSmallInteger(EPROTONOSUPPORT) );
  2997     }
  3017     }
  2998 #endif
  3018 #endif
  2999 
  3019 
  3000 #ifdef ESOCKTNOSUPPORT
  3020 #ifdef ESOCKTNOSUPPORT
  3001     if (sym == @symbol(ESOCKTNOSUPPORT)) {
  3021     if (sym == @symbol(ESOCKTNOSUPPORT)) {
  3002         RETURN ( __mkSmallInteger(ESOCKTNOSUPPORT) );
  3022 	RETURN ( __mkSmallInteger(ESOCKTNOSUPPORT) );
  3003     }
  3023     }
  3004 #endif
  3024 #endif
  3005 
  3025 
  3006 #ifdef EOPNOTSUPP
  3026 #ifdef EOPNOTSUPP
  3007     if (sym == @symbol(EOPNOTSUPP)) {
  3027     if (sym == @symbol(EOPNOTSUPP)) {
  3008         RETURN ( __mkSmallInteger(EOPNOTSUPP) );
  3028 	RETURN ( __mkSmallInteger(EOPNOTSUPP) );
  3009     }
  3029     }
  3010 #endif
  3030 #endif
  3011 
  3031 
  3012 #ifdef EPFNOSUPPORT
  3032 #ifdef EPFNOSUPPORT
  3013     if (sym == @symbol(EPFNOSUPPORT)) {
  3033     if (sym == @symbol(EPFNOSUPPORT)) {
  3014         RETURN ( __mkSmallInteger(EPFNOSUPPORT) );
  3034 	RETURN ( __mkSmallInteger(EPFNOSUPPORT) );
  3015     }
  3035     }
  3016 #endif
  3036 #endif
  3017 
  3037 
  3018 #ifdef EAFNOSUPPORT
  3038 #ifdef EAFNOSUPPORT
  3019     if (sym == @symbol(EAFNOSUPPORT)) {
  3039     if (sym == @symbol(EAFNOSUPPORT)) {
  3020         RETURN ( __mkSmallInteger(EAFNOSUPPORT) );
  3040 	RETURN ( __mkSmallInteger(EAFNOSUPPORT) );
  3021     }
  3041     }
  3022 #endif
  3042 #endif
  3023 
  3043 
  3024 #ifdef EADDRINUSE
  3044 #ifdef EADDRINUSE
  3025     if (sym == @symbol(EADDRINUSE)) {
  3045     if (sym == @symbol(EADDRINUSE)) {
  3026         RETURN ( __mkSmallInteger(EADDRINUSE) );
  3046 	RETURN ( __mkSmallInteger(EADDRINUSE) );
  3027     }
  3047     }
  3028 #endif
  3048 #endif
  3029 
  3049 
  3030 #ifdef EADDRNOTAVAIL
  3050 #ifdef EADDRNOTAVAIL
  3031     if (sym == @symbol(EADDRNOTAVAIL)) {
  3051     if (sym == @symbol(EADDRNOTAVAIL)) {
  3032         RETURN ( __mkSmallInteger(EADDRNOTAVAIL) );
  3052 	RETURN ( __mkSmallInteger(EADDRNOTAVAIL) );
  3033     }
  3053     }
  3034 #endif
  3054 #endif
  3035 
  3055 
  3036 #ifdef ETIMEDOUT
  3056 #ifdef ETIMEDOUT
  3037     if (sym == @symbol(ETIMEDOUT)) {
  3057     if (sym == @symbol(ETIMEDOUT)) {
  3038         RETURN ( __mkSmallInteger(ETIMEDOUT) );
  3058 	RETURN ( __mkSmallInteger(ETIMEDOUT) );
  3039     }
  3059     }
  3040 #endif
  3060 #endif
  3041 
  3061 
  3042 #ifdef ECONNREFUSED
  3062 #ifdef ECONNREFUSED
  3043     if (sym == @symbol(ECONNREFUSED)) {
  3063     if (sym == @symbol(ECONNREFUSED)) {
  3044         RETURN ( __mkSmallInteger(ECONNREFUSED) );
  3064 	RETURN ( __mkSmallInteger(ECONNREFUSED) );
  3045     }
  3065     }
  3046 #endif
  3066 #endif
  3047 
  3067 
  3048 #ifdef ENETDOWN
  3068 #ifdef ENETDOWN
  3049     if (sym == @symbol(ENETDOWN)) {
  3069     if (sym == @symbol(ENETDOWN)) {
  3050         RETURN ( __mkSmallInteger(ENETDOWN) );
  3070 	RETURN ( __mkSmallInteger(ENETDOWN) );
  3051     }
  3071     }
  3052 #endif
  3072 #endif
  3053 
  3073 
  3054 #ifdef ENETUNREACH
  3074 #ifdef ENETUNREACH
  3055     if (sym == @symbol(ENETUNREACH)) {
  3075     if (sym == @symbol(ENETUNREACH)) {
  3056         RETURN ( __mkSmallInteger(ENETUNREACH) );
  3076 	RETURN ( __mkSmallInteger(ENETUNREACH) );
  3057     }
  3077     }
  3058 #endif
  3078 #endif
  3059 
  3079 
  3060 #ifdef ENETRESET
  3080 #ifdef ENETRESET
  3061     if (sym == @symbol(ENETRESET)) {
  3081     if (sym == @symbol(ENETRESET)) {
  3062         RETURN ( __mkSmallInteger(ENETRESET) );
  3082 	RETURN ( __mkSmallInteger(ENETRESET) );
  3063     }
  3083     }
  3064 #endif
  3084 #endif
  3065 
  3085 
  3066 #ifdef ECONNABORTED
  3086 #ifdef ECONNABORTED
  3067     if (sym == @symbol(ECONNABORTED)) {
  3087     if (sym == @symbol(ECONNABORTED)) {
  3068         RETURN ( __mkSmallInteger(ECONNABORTED) );
  3088 	RETURN ( __mkSmallInteger(ECONNABORTED) );
  3069     }
  3089     }
  3070 #endif
  3090 #endif
  3071 
  3091 
  3072 #ifdef ECONNRESET
  3092 #ifdef ECONNRESET
  3073     if (sym == @symbol(ECONNRESET)) {
  3093     if (sym == @symbol(ECONNRESET)) {
  3074         RETURN ( __mkSmallInteger(ECONNRESET) );
  3094 	RETURN ( __mkSmallInteger(ECONNRESET) );
  3075     }
  3095     }
  3076 #endif
  3096 #endif
  3077 
  3097 
  3078 #ifdef EISCONN
  3098 #ifdef EISCONN
  3079     if (sym == @symbol(EISCONN)) {
  3099     if (sym == @symbol(EISCONN)) {
  3080         RETURN ( __mkSmallInteger(EISCONN) );
  3100 	RETURN ( __mkSmallInteger(EISCONN) );
  3081     }
  3101     }
  3082 #endif
  3102 #endif
  3083 
  3103 
  3084 #ifdef ENOTCONN
  3104 #ifdef ENOTCONN
  3085     if (sym == @symbol(ENOTCONN)) {
  3105     if (sym == @symbol(ENOTCONN)) {
  3086         RETURN ( __mkSmallInteger(ENOTCONN) );
  3106 	RETURN ( __mkSmallInteger(ENOTCONN) );
  3087     }
  3107     }
  3088 #endif
  3108 #endif
  3089 
  3109 
  3090 #ifdef ESHUTDOWN
  3110 #ifdef ESHUTDOWN
  3091     if (sym == @symbol(ESHUTDOWN)) {
  3111     if (sym == @symbol(ESHUTDOWN)) {
  3092         RETURN ( __mkSmallInteger(ESHUTDOWN) );
  3112 	RETURN ( __mkSmallInteger(ESHUTDOWN) );
  3093     }
  3113     }
  3094 #endif
  3114 #endif
  3095 
  3115 
  3096 #ifdef EHOSTDOWN
  3116 #ifdef EHOSTDOWN
  3097     if (sym == @symbol(EHOSTDOWN)) {
  3117     if (sym == @symbol(EHOSTDOWN)) {
  3098         RETURN ( __mkSmallInteger(EHOSTDOWN) );
  3118 	RETURN ( __mkSmallInteger(EHOSTDOWN) );
  3099     }
  3119     }
  3100 #endif
  3120 #endif
  3101 
  3121 
  3102 #ifdef EHOSTUNREACH
  3122 #ifdef EHOSTUNREACH
  3103     if (sym == @symbol(EHOSTUNREACH)) {
  3123     if (sym == @symbol(EHOSTUNREACH)) {
  3104         RETURN ( __mkSmallInteger(EHOSTUNREACH) );
  3124 	RETURN ( __mkSmallInteger(EHOSTUNREACH) );
  3105     }
  3125     }
  3106 #endif
  3126 #endif
  3107     /*
  3127     /*
  3108      * windows socket errors
  3128      * windows socket errors
  3109      */
  3129      */
  3110 #ifdef WSAEINTR
  3130 #ifdef WSAEINTR
  3111     if (sym == @symbol(WSAEINTR)) {
  3131     if (sym == @symbol(WSAEINTR)) {
  3112         RETURN ( __mkSmallInteger(WSAEINTR) );
  3132 	RETURN ( __mkSmallInteger(WSAEINTR) );
  3113     }
  3133     }
  3114 #endif
  3134 #endif
  3115 #ifdef WSAEBADF
  3135 #ifdef WSAEBADF
  3116     if (sym == @symbol(WSAEBADF)) {
  3136     if (sym == @symbol(WSAEBADF)) {
  3117         RETURN ( __mkSmallInteger(WSAEBADF) );
  3137 	RETURN ( __mkSmallInteger(WSAEBADF) );
  3118     }
  3138     }
  3119 #endif
  3139 #endif
  3120 #ifdef WSAEACCESS
  3140 #ifdef WSAEACCESS
  3121     if (sym == @symbol(WSAEACCESS)) {
  3141     if (sym == @symbol(WSAEACCESS)) {
  3122         RETURN ( __mkSmallInteger(WSAEACCESS) );
  3142 	RETURN ( __mkSmallInteger(WSAEACCESS) );
  3123     }
  3143     }
  3124 #endif
  3144 #endif
  3125 #ifdef WSAEFAULT
  3145 #ifdef WSAEFAULT
  3126     if (sym == @symbol(WSAEFAULT)) {
  3146     if (sym == @symbol(WSAEFAULT)) {
  3127         RETURN ( __mkSmallInteger(WSAEFAULT) );
  3147 	RETURN ( __mkSmallInteger(WSAEFAULT) );
  3128     }
  3148     }
  3129 #endif
  3149 #endif
  3130 #ifdef WSAEINVAL
  3150 #ifdef WSAEINVAL
  3131     if (sym == @symbol(WSAEINVAL)) {
  3151     if (sym == @symbol(WSAEINVAL)) {
  3132         RETURN ( __mkSmallInteger(WSAEINVAL) );
  3152 	RETURN ( __mkSmallInteger(WSAEINVAL) );
  3133     }
  3153     }
  3134 #endif
  3154 #endif
  3135 #ifdef WSAEMFILE
  3155 #ifdef WSAEMFILE
  3136     if (sym == @symbol(WSAEMFILE)) {
  3156     if (sym == @symbol(WSAEMFILE)) {
  3137         RETURN ( __mkSmallInteger(WSAEMFILE) );
  3157 	RETURN ( __mkSmallInteger(WSAEMFILE) );
  3138     }
  3158     }
  3139 #endif
  3159 #endif
  3140 #ifdef WSAEWOULDBLOCK
  3160 #ifdef WSAEWOULDBLOCK
  3141     if (sym == @symbol(WSAEWOULDBLOCK)) {
  3161     if (sym == @symbol(WSAEWOULDBLOCK)) {
  3142         RETURN ( __mkSmallInteger(WSAEWOULDBLOCK) );
  3162 	RETURN ( __mkSmallInteger(WSAEWOULDBLOCK) );
  3143     }
  3163     }
  3144 #endif
  3164 #endif
  3145 #ifdef WSAEINPROGRESS
  3165 #ifdef WSAEINPROGRESS
  3146     if (sym == @symbol(WSAEINPROGRESS)) {
  3166     if (sym == @symbol(WSAEINPROGRESS)) {
  3147         RETURN ( __mkSmallInteger(WSAEINPROGRESS) );
  3167 	RETURN ( __mkSmallInteger(WSAEINPROGRESS) );
  3148     }
  3168     }
  3149 #endif
  3169 #endif
  3150 #ifdef WSAEALREADY
  3170 #ifdef WSAEALREADY
  3151     if (sym == @symbol(WSAEALREADY)) {
  3171     if (sym == @symbol(WSAEALREADY)) {
  3152         RETURN ( __mkSmallInteger(WSAEALREADY) );
  3172 	RETURN ( __mkSmallInteger(WSAEALREADY) );
  3153     }
  3173     }
  3154 #endif
  3174 #endif
  3155 #ifdef WSAENOTSOCK
  3175 #ifdef WSAENOTSOCK
  3156     if (sym == @symbol(WSAENOTSOCK)) {
  3176     if (sym == @symbol(WSAENOTSOCK)) {
  3157         RETURN ( __mkSmallInteger(WSAENOTSOCK) );
  3177 	RETURN ( __mkSmallInteger(WSAENOTSOCK) );
  3158     }
  3178     }
  3159 #endif
  3179 #endif
  3160 #ifdef WSAEPROTONOSUPPORT
  3180 #ifdef WSAEPROTONOSUPPORT
  3161     if (sym == @symbol(WSAEPROTONOSUPPORT)) {
  3181     if (sym == @symbol(WSAEPROTONOSUPPORT)) {
  3162         RETURN ( __mkSmallInteger(WSAEPROTONOSUPPORT) );
  3182 	RETURN ( __mkSmallInteger(WSAEPROTONOSUPPORT) );
  3163     }
  3183     }
  3164 #endif
  3184 #endif
  3165 #ifdef WSAESOCKTNOSUPPORT
  3185 #ifdef WSAESOCKTNOSUPPORT
  3166     if (sym == @symbol(WSAESOCKTNOSUPPORT)) {
  3186     if (sym == @symbol(WSAESOCKTNOSUPPORT)) {
  3167         RETURN ( __mkSmallInteger(WSAESOCKTNOSUPPORT) );
  3187 	RETURN ( __mkSmallInteger(WSAESOCKTNOSUPPORT) );
  3168     }
  3188     }
  3169 #endif
  3189 #endif
  3170 #ifdef E_NOINTERFACE
  3190 #ifdef E_NOINTERFACE
  3171     if (sym == @symbol(E_NOINTERFACE)) {
  3191     if (sym == @symbol(E_NOINTERFACE)) {
  3172         RETURN ( __MKUINT(E_NOINTERFACE) );
  3192 	RETURN ( __MKUINT(E_NOINTERFACE) );
  3173     }
  3193     }
  3174 #endif
  3194 #endif
  3175 #ifdef CO_E_NOTINITIALIZED
  3195 #ifdef CO_E_NOTINITIALIZED
  3176     if (sym == @symbol(CO_E_NOTINITIALIZED)) {
  3196     if (sym == @symbol(CO_E_NOTINITIALIZED)) {
  3177         RETURN ( __MKUINT(CO_E_NOTINITIALIZED) );
  3197 	RETURN ( __MKUINT(CO_E_NOTINITIALIZED) );
  3178     }
  3198     }
  3179 #endif
  3199 #endif
  3180 #ifdef REGDB_E_CLASSNOTREG
  3200 #ifdef REGDB_E_CLASSNOTREG
  3181     if (sym == @symbol(REGDB_E_CLASSNOTREG)) {
  3201     if (sym == @symbol(REGDB_E_CLASSNOTREG)) {
  3182         RETURN ( __MKUINT(REGDB_E_CLASSNOTREG) );
  3202 	RETURN ( __MKUINT(REGDB_E_CLASSNOTREG) );
  3183     }
  3203     }
  3184 #endif
  3204 #endif
  3185 #ifdef CLASS_E_NOAGGREGATION
  3205 #ifdef CLASS_E_NOAGGREGATION
  3186     if (sym == @symbol(CLASS_E_NOAGGREGATION)) {
  3206     if (sym == @symbol(CLASS_E_NOAGGREGATION)) {
  3187         RETURN ( __MKUINT(CLASS_E_NOAGGREGATION) );
  3207 	RETURN ( __MKUINT(CLASS_E_NOAGGREGATION) );
  3188     }
  3208     }
  3189 #endif
  3209 #endif
  3190 #ifdef DISP_E_UNKNOWNNAME
  3210 #ifdef DISP_E_UNKNOWNNAME
  3191     if (sym == @symbol(DISP_E_UNKNOWNNAME)) {
  3211     if (sym == @symbol(DISP_E_UNKNOWNNAME)) {
  3192         RETURN ( __MKUINT(DISP_E_UNKNOWNNAME) );
  3212 	RETURN ( __MKUINT(DISP_E_UNKNOWNNAME) );
  3193     }
  3213     }
  3194 #endif
  3214 #endif
  3195 #ifdef OLEOBJ_E_NOVERBS
  3215 #ifdef OLEOBJ_E_NOVERBS
  3196     if (sym == @symbol(OLEOBJ_E_NOVERBS)) {
  3216     if (sym == @symbol(OLEOBJ_E_NOVERBS)) {
  3197         RETURN ( __MKUINT(OLEOBJ_E_NOVERBS) );
  3217 	RETURN ( __MKUINT(OLEOBJ_E_NOVERBS) );
  3198     }
  3218     }
  3199 #endif
  3219 #endif
  3200 
  3220 
  3201 %}.
  3221 %}.
  3202     ^ -1
  3222     ^ -1
  3254     "/ command.com command-line parsing here (sigh).
  3274     "/ command.com command-line parsing here (sigh).
  3255 
  3275 
  3256     hasRedirection := (aCommandString isNil or:[aCommandString includesAny:'<>|']).
  3276     hasRedirection := (aCommandString isNil or:[aCommandString includesAny:'<>|']).
  3257 
  3277 
  3258     hasRedirection ifFalse:[
  3278     hasRedirection ifFalse:[
  3259         "/ test whether the commandString is an executable;
  3279 	"/ test whether the commandString is an executable;
  3260         "/ then, no shell is required
  3280 	"/ then, no shell is required
  3261         cmdName := aCommandString withoutSeparators.
  3281 	cmdName := aCommandString withoutSeparators.
  3262         (cmdName notEmpty and:[(cmdName startsWith:$") not]) ifTrue:[
  3282 	(cmdName notEmpty and:[(cmdName startsWith:$") not]) ifTrue:[
  3263             |index file suffix|
  3283 	    |index file suffix|
  3264 
  3284 
  3265             index := cmdName indexOfSeparatorStartingAt:1.
  3285 	    index := cmdName indexOfSeparatorStartingAt:1.
  3266             index ~~ 0 ifTrue:[
  3286 	    index ~~ 0 ifTrue:[
  3267                 args := cmdName copyFrom:(index+1).
  3287 		args := cmdName copyFrom:(index+1).
  3268                 cmdName := cmdName copyFrom:1 to:(index-1).
  3288 		cmdName := cmdName copyFrom:1 to:(index-1).
  3269             ] ifFalse:[
  3289 	    ] ifFalse:[
  3270                 args := ''.
  3290 		args := ''.
  3271             ].
  3291 	    ].
  3272 
  3292 
  3273             file   := cmdName asFilename.
  3293 	    file   := cmdName asFilename.
  3274             suffix := file suffix.
  3294 	    suffix := file suffix.
  3275 
  3295 
  3276             suffix isEmptyOrNil ifTrue:[
  3296 	    suffix isEmptyOrNil ifTrue:[
  3277                 suffix := 'exe'.
  3297 		suffix := 'exe'.
  3278                 file := file withSuffix:suffix.
  3298 		file := file withSuffix:suffix.
  3279             ].
  3299 	    ].
  3280 
  3300 
  3281             (file exists and:[suffix = 'exe' or:[suffix = 'com']]) ifTrue:[
  3301 	    (file exists and:[suffix = 'exe' or:[suffix = 'com']]) ifTrue:[
  3282                 "/ is an executable, no shell required
  3302 		"/ is an executable, no shell required
  3283                 path := file fullAlternativePathName.
  3303 		path := file fullAlternativePathName.
  3284                 ^ Array with:path with:aCommandString.
  3304 		^ Array with:path with:aCommandString.
  3285 "/                ^ Array with:path with:(path, ' ', args).
  3305 "/                ^ Array with:path with:(path, ' ', args).
  3286             ].
  3306 	    ].
  3287             path := self pathOfCommand:cmdName.
  3307 	    path := self pathOfCommand:cmdName.
  3288             path notNil ifTrue:[
  3308 	    path notNil ifTrue:[
  3289                 "/ is an executable, no shell required
  3309 		"/ is an executable, no shell required
  3290                 ^ Array with:path with:aCommandString.
  3310 		^ Array with:path with:aCommandString.
  3291 "/                ^ Array with:path with:(path, ' ', args).
  3311 "/                ^ Array with:path with:(path, ' ', args).
  3292             ].
  3312 	    ].
  3293         ].
  3313 	].
  3294     ].
  3314     ].
  3295 
  3315 
  3296     shell := self getEnvironment:'COMSPEC'.
  3316     shell := self getEnvironment:'COMSPEC'.
  3297     shell isNil ifTrue:[
  3317     shell isNil ifTrue:[
  3298         wDir := self getWindowsSystemDirectory asFilename.
  3318 	wDir := self getWindowsSystemDirectory asFilename.
  3299         shell := #('cmd.exe' 'command.com') detect:[:eachCommand|
  3319 	shell := #('cmd.exe' 'command.com') detect:[:eachCommand|
  3300                         (wDir / eachCommand) isExecutable
  3320 			(wDir / eachCommand) isExecutable
  3301                     ] ifNone:[
  3321 		    ] ifNone:[
  3302                         self error:'no cmd.exe available'.
  3322 			self error:'no cmd.exe available'.
  3303                     ].
  3323 		    ].
  3304         shell := (wDir / shell) pathName.
  3324 	shell := (wDir / shell) pathName.
  3305     ].
  3325     ].
  3306 
  3326 
  3307     aCommandString isEmptyOrNil ifTrue:[
  3327     aCommandString isEmptyOrNil ifTrue:[
  3308         ^ Array with:shell with:nil
  3328 	^ Array with:shell with:nil
  3309     ].
  3329     ].
  3310 
  3330 
  3311     ^ Array with:shell with:(' /c "' , aCommandString, '"')
  3331     ^ Array with:shell with:(' /c "' , aCommandString, '"')
  3312 
  3332 
  3313    "
  3333    "
  3322 
  3342 
  3323 exec:aCommandPath withArguments:argString environment:environment fileDescriptors:fdArray fork:doFork newPgrp:newPgrp inDirectory:aDirectory
  3343 exec:aCommandPath withArguments:argString environment:environment fileDescriptors:fdArray fork:doFork newPgrp:newPgrp inDirectory:aDirectory
  3324     "Internal lowLevel entry for combined fork & exec for WIN32
  3344     "Internal lowLevel entry for combined fork & exec for WIN32
  3325 
  3345 
  3326      If fork is false (chain a command):
  3346      If fork is false (chain a command):
  3327          execute the OS command specified by the argument, aCommandPath, with
  3347 	 execute the OS command specified by the argument, aCommandPath, with
  3328          arguments in argArray (no arguments, if nil).
  3348 	 arguments in argArray (no arguments, if nil).
  3329          If successful, this method does not return and smalltalk is gone.
  3349 	 If successful, this method does not return and smalltalk is gone.
  3330          If not successful, it does return.
  3350 	 If not successful, it does return.
  3331          Normal use is with forkForCommand.
  3351 	 Normal use is with forkForCommand.
  3332 
  3352 
  3333      If fork is true (subprocess command execution):
  3353      If fork is true (subprocess command execution):
  3334         fork a child to do the above.
  3354 	fork a child to do the above.
  3335         The Win32ProcessHandle of the child process is returned; nil if the fork failed.
  3355 	The Win32ProcessHandle of the child process is returned; nil if the fork failed.
  3336 
  3356 
  3337      fdArray contains the filedescriptors, to be used for the child (if fork is true).
  3357      fdArray contains the filedescriptors, to be used for the child (if fork is true).
  3338         fdArray[1] = 15 -> use fd 15 as stdin.
  3358 	fdArray[1] = 15 -> use fd 15 as stdin.
  3339         If an element of the array is set to nil, the corresponding filedescriptor
  3359 	If an element of the array is set to nil, the corresponding filedescriptor
  3340         will be closed for the child.
  3360 	will be closed for the child.
  3341         fdArray[0] == StdIn for child
  3361 	fdArray[0] == StdIn for child
  3342         fdArray[1] == StdOut for child
  3362 	fdArray[1] == StdOut for child
  3343         fdArray[2] == StdErr for child
  3363 	fdArray[2] == StdErr for child
  3344         on VMS, these must be channels as returned by createMailBox.
  3364 	on VMS, these must be channels as returned by createMailBox.
  3345 
  3365 
  3346      NOTE that in WIN32 the fds are HANDLES.
  3366      NOTE that in WIN32 the fds are HANDLES.
  3347 
  3367 
  3348      If newPgrp is true, the subprocess will be established in a new process group.
  3368      If newPgrp is true, the subprocess will be established in a new process group.
  3349         The processgroup will be equal to id.
  3369 	The processgroup will be equal to id.
  3350         newPgrp is not used on WIN32 and VMS systems."
  3370 	newPgrp is not used on WIN32 and VMS systems."
  3351 
  3371 
  3352     |dirPath rslt|
  3372     |dirPath rslt|
  3353 
  3373 
  3354     aDirectory notNil ifTrue:[
  3374     aDirectory notNil ifTrue:[
  3355         dirPath := aDirectory asFilename asAbsoluteFilename osNameForDirectory.
  3375 	dirPath := aDirectory asFilename asAbsoluteFilename osNameForDirectory.
  3356         (dirPath endsWith:':') ifTrue:[
  3376 	(dirPath endsWith:':') ifTrue:[
  3357             dirPath := dirPath , '\'.
  3377 	    dirPath := dirPath , '\'.
  3358         ].
  3378 	].
  3359     ].
  3379     ].
  3360 
  3380 
  3361     rslt := self
  3381     rslt := self
  3362         primExec:aCommandPath
  3382 	primExec:aCommandPath
  3363         commandLine:argString
  3383 	commandLine:argString
  3364         fileDescriptors:fdArray
  3384 	fileDescriptors:fdArray
  3365         fork:doFork
  3385 	fork:doFork
  3366         newPgrp:newPgrp
  3386 	newPgrp:newPgrp
  3367         inPath:dirPath
  3387 	inPath:dirPath
  3368         createFlags:nil.
  3388 	createFlags:nil.
  3369 
  3389 
  3370 "/ 'created ' print. cmdLine print. ' -> ' print. rslt printCR.
  3390 "/ 'created ' print. cmdLine print. ' -> ' print. rslt printCR.
  3371     ^ rslt
  3391     ^ rslt
  3372 
  3392 
  3373     "Modified: / 31.1.1998 / 10:54:24 / md"
  3393     "Modified: / 31.1.1998 / 10:54:24 / md"
  3392      or #killProcess: to stop it."
  3412      or #killProcess: to stop it."
  3393 
  3413 
  3394     |nullStream in out err rslt auxFd|
  3414     |nullStream in out err rslt auxFd|
  3395 
  3415 
  3396     (in := anExternalInStream) isNil ifTrue:[
  3416     (in := anExternalInStream) isNil ifTrue:[
  3397         nullStream := Filename nullDevice readWriteStream.
  3417 	nullStream := Filename nullDevice readWriteStream.
  3398         in := nullStream.
  3418 	in := nullStream.
  3399     ].
  3419     ].
  3400     (out := anExternalOutStream) isNil ifTrue:[
  3420     (out := anExternalOutStream) isNil ifTrue:[
  3401         nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream].
  3421 	nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream].
  3402         out := nullStream.
  3422 	out := nullStream.
  3403     ].
  3423     ].
  3404     (err := anExternalErrStream) isNil ifTrue:[
  3424     (err := anExternalErrStream) isNil ifTrue:[
  3405         err := out
  3425 	err := out
  3406     ].
  3426     ].
  3407     anAuxiliaryStream notNil ifTrue:[
  3427     anAuxiliaryStream notNil ifTrue:[
  3408         auxFd := anAuxiliaryStream fileDescriptor
  3428 	auxFd := anAuxiliaryStream fileDescriptor
  3409     ].
  3429     ].
  3410 
  3430 
  3411     rslt := self
  3431     rslt := self
  3412         exec:commandString
  3432 	exec:commandString
  3413         withArguments:argString
  3433 	withArguments:argString
  3414         environment:anEvironmentDictionary
  3434 	environment:anEvironmentDictionary
  3415         fileDescriptors:(Array with:in fileDescriptor
  3435 	fileDescriptors:(Array with:in fileDescriptor
  3416                                with:out fileDescriptor
  3436 			       with:out fileDescriptor
  3417                                with:err fileDescriptor
  3437 			       with:err fileDescriptor
  3418                                with:auxFd)
  3438 			       with:auxFd)
  3419         fork:true
  3439 	fork:true
  3420         newPgrp:true "/ false
  3440 	newPgrp:true "/ false
  3421         inDirectory:dir.
  3441 	inDirectory:dir.
  3422 
  3442 
  3423     nullStream notNil ifTrue:[
  3443     nullStream notNil ifTrue:[
  3424         nullStream close.
  3444 	nullStream close.
  3425     ].
  3445     ].
  3426     ^ rslt
  3446     ^ rslt
  3427 
  3447 
  3428     "blocking at current prio (i.e. only higher prio threads execute):
  3448     "blocking at current prio (i.e. only higher prio threads execute):
  3429 
  3449 
  3442      pid := OperatingSystem startProcess:'sleep 10; grep drw' inputFrom:in outputTo:out errorTo:err.
  3462      pid := OperatingSystem startProcess:'sleep 10; grep drw' inputFrom:in outputTo:out errorTo:err.
  3443 
  3463 
  3444      The following will no longer work. monitorPid has disappeared
  3464      The following will no longer work. monitorPid has disappeared
  3445 
  3465 
  3446      pid notNil ifTrue:[
  3466      pid notNil ifTrue:[
  3447          Processor monitorPid:pid action:[:OSstatus | sema signal ].
  3467 	 Processor monitorPid:pid action:[:OSstatus | sema signal ].
  3448      ].
  3468      ].
  3449      in close.
  3469      in close.
  3450      out close.
  3470      out close.
  3451      err close.
  3471      err close.
  3452      sema wait.
  3472      sema wait.
  3466 %{
  3486 %{
  3467     DWORD endStatus;
  3487     DWORD endStatus;
  3468     int status = -1;
  3488     int status = -1;
  3469 
  3489 
  3470     if (__isExternalAddressLike(aProcessId)) {
  3490     if (__isExternalAddressLike(aProcessId)) {
  3471         HANDLE handle = _HANDLEVal(aProcessId);
  3491 	HANDLE handle = _HANDLEVal(aProcessId);
  3472         if (handle) {
  3492 	if (handle) {
  3473 #ifdef DO_WRAP_CALLS
  3493 #ifdef DO_WRAP_CALLS
  3474             do {
  3494 	    do {
  3475                 __threadErrno = 0;
  3495 		__threadErrno = 0;
  3476                 endStatus = STX_API_CALL2( "WaitForSingleObject", WaitForSingleObject, handle, INFINITE);
  3496 		endStatus = STX_API_CALL2( "WaitForSingleObject", WaitForSingleObject, handle, INFINITE);
  3477             } while ((endStatus < 0) && (__threadErrno == EINTR));
  3497 	    } while ((endStatus < 0) && (__threadErrno == EINTR));
  3478 #else
  3498 #else
  3479             endStatus = WaitForSingleObject(handle , INFINITE);
  3499 	    endStatus = WaitForSingleObject(handle , INFINITE);
  3480 #endif
  3500 #endif
  3481             if (endStatus != WAIT_FAILED) {
  3501 	    if (endStatus != WAIT_FAILED) {
  3482                 if (GetExitCodeProcess(handle,&endStatus)) {
  3502 		if (GetExitCodeProcess(handle,&endStatus)) {
  3483                     status = endStatus;
  3503 		    status = endStatus;
  3484 #ifdef PROCESSDEBUGWIN32
  3504 #ifdef PROCESSDEBUGWIN32
  3485                     console_fprintf(stderr, "getexitcode status = %d\n",status);
  3505 		    console_fprintf(stderr, "getexitcode status = %d\n",status);
  3486                 } else {
  3506 		} else {
  3487                     console_fprintf(stderr, "getexitcode failed.\n");
  3507 		    console_fprintf(stderr, "getexitcode failed.\n");
  3488 #endif
  3508 #endif
  3489                 }
  3509 		}
  3490             }
  3510 	    }
  3491         }
  3511 	}
  3492         RETURN ( __mkSmallInteger(status));
  3512 	RETURN ( __mkSmallInteger(status));
  3493     }
  3513     }
  3494 %}.
  3514 %}.
  3495     self primitiveFailed
  3515     self primitiveFailed
  3496 !
  3516 !
  3497 
  3517 
  3501      return nil."
  3521      return nil."
  3502 
  3522 
  3503     |path rentry rpath f fExt|
  3523     |path rentry rpath f fExt|
  3504 
  3524 
  3505     aCommand asFilename isAbsolute ifTrue:[
  3525     aCommand asFilename isAbsolute ifTrue:[
  3506         aCommand asFilename exists ifTrue:[
  3526 	aCommand asFilename exists ifTrue:[
  3507             ^ aCommand
  3527 	    ^ aCommand
  3508         ].
  3528 	].
  3509         ^ nil
  3529 	^ nil
  3510     ].
  3530     ].
  3511 
  3531 
  3512     (aCommand includes:Filename separator) ifTrue:[
  3532     (aCommand includes:Filename separator) ifTrue:[
  3513         path := Filename currentDirectory construct:aCommand.
  3533 	path := Filename currentDirectory construct:aCommand.
  3514         (path exists
  3534 	(path exists
  3515         or:[(path withSuffix:'exe') exists]) ifTrue:[
  3535 	or:[(path withSuffix:'exe') exists]) ifTrue:[
  3516             ^ path pathName
  3536 	    ^ path pathName
  3517         ].
  3537 	].
  3518     ].
  3538     ].
  3519 
  3539 
  3520     path := self getEnvironment:'PATH'.
  3540     path := self getEnvironment:'PATH'.
  3521     (rentry := self registryEntry key: 'HKEY_CURRENT_USER\Environment') notNil ifTrue:[
  3541     (rentry := self registryEntry key: 'HKEY_CURRENT_USER\Environment') notNil ifTrue:[
  3522         rpath := rentry valueNamed: 'PATH'.
  3542 	rpath := rentry valueNamed: 'PATH'.
  3523         rpath notNil ifTrue:[
  3543 	rpath notNil ifTrue:[
  3524             path := path , ';' , rpath
  3544 	    path := path , ';' , rpath
  3525         ].
  3545 	].
  3526     ].
  3546     ].
  3527 
  3547 
  3528     path notNil ifTrue:[
  3548     path notNil ifTrue:[
  3529         (path asCollectionOfSubstringsSeparatedBy:(self pathSeparator)) do:[:path |
  3549 	(path asCollectionOfSubstringsSeparatedBy:(self pathSeparator)) do:[:path |
  3530             path isEmpty ifTrue:[
  3550 	    path isEmpty ifTrue:[
  3531                 f := aCommand asFilename
  3551 		f := aCommand asFilename
  3532             ] ifFalse:[
  3552 	    ] ifFalse:[
  3533                 f := path asFilename construct:aCommand.
  3553 		f := path asFilename construct:aCommand.
  3534             ].
  3554 	    ].
  3535             f suffix isEmpty ifTrue:[
  3555 	    f suffix isEmpty ifTrue:[
  3536                 self executableFileExtensions do:[:ext |
  3556 		self executableFileExtensions do:[:ext |
  3537                     ext notEmpty ifTrue:[
  3557 		    ext notEmpty ifTrue:[
  3538                         fExt := (f pathName , '.' , ext) asFilename.
  3558 			fExt := (f pathName , '.' , ext) asFilename.
  3539                     ] ifFalse:[
  3559 		    ] ifFalse:[
  3540                         fExt := f.
  3560 			fExt := f.
  3541                     ].
  3561 		    ].
  3542                     fExt isExecutable ifTrue:[
  3562 		    fExt isExecutable ifTrue:[
  3543                         ^ fExt pathName
  3563 			^ fExt pathName
  3544                     ].
  3564 		    ].
  3545                 ].
  3565 		].
  3546             ] ifFalse:[
  3566 	    ] ifFalse:[
  3547                 f isExecutable ifTrue:[
  3567 		f isExecutable ifTrue:[
  3548                     ^ f pathName
  3568 		    ^ f pathName
  3549                 ].
  3569 		].
  3550             ].
  3570 	    ].
  3551         ].
  3571 	].
  3552     ].
  3572     ].
  3553     ^ nil
  3573     ^ nil
  3554 
  3574 
  3555     "windows:
  3575     "windows:
  3556 
  3576 
  3585     PROCESS_INFORMATION lppiProcInfo;
  3605     PROCESS_INFORMATION lppiProcInfo;
  3586     SECURITY_ATTRIBUTES securityAttributes;
  3606     SECURITY_ATTRIBUTES securityAttributes;
  3587     SECURITY_DESCRIPTOR securityDescriptor;
  3607     SECURITY_DESCRIPTOR securityDescriptor;
  3588 
  3608 
  3589     if ((__isStringLike(commandPath) || (commandPath == nil)) && __isStringLike(commandLine)) {
  3609     if ((__isStringLike(commandPath) || (commandPath == nil)) && __isStringLike(commandLine)) {
  3590         if (commandPath != nil) {
  3610 	if (commandPath != nil) {
  3591             cmdPath = __stringVal(commandPath);
  3611 	    cmdPath = __stringVal(commandPath);
  3592         }
  3612 	}
  3593         cmdLine = __stringVal(commandLine);
  3613 	cmdLine = __stringVal(commandLine);
  3594 
  3614 
  3595         if (__isStringLike(dirName)) {
  3615 	if (__isStringLike(dirName)) {
  3596             dir = __stringVal(dirName);
  3616 	    dir = __stringVal(dirName);
  3597         }
  3617 	}
  3598 
  3618 
  3599         /*
  3619 	/*
  3600          * create descriptors as req'd
  3620 	 * create descriptors as req'd
  3601          */
  3621 	 */
  3602         memset(&securityAttributes, 0, sizeof(securityAttributes));
  3622 	memset(&securityAttributes, 0, sizeof(securityAttributes));
  3603         securityAttributes.nLength = sizeof(securityAttributes);
  3623 	securityAttributes.nLength = sizeof(securityAttributes);
  3604         securityAttributes.bInheritHandle = TRUE;
  3624 	securityAttributes.bInheritHandle = TRUE;
  3605 
  3625 
  3606         InitializeSecurityDescriptor(&securityDescriptor, SECURITY_DESCRIPTOR_REVISION);
  3626 	InitializeSecurityDescriptor(&securityDescriptor, SECURITY_DESCRIPTOR_REVISION);
  3607         SetSecurityDescriptorDacl(&securityDescriptor, -1, 0, 0);
  3627 	SetSecurityDescriptorDacl(&securityDescriptor, -1, 0, 0);
  3608 
  3628 
  3609         securityAttributes.lpSecurityDescriptor = &securityDescriptor;
  3629 	securityAttributes.lpSecurityDescriptor = &securityDescriptor;
  3610         memset(&lppiProcInfo, 0, sizeof (lppiProcInfo));
  3630 	memset(&lppiProcInfo, 0, sizeof (lppiProcInfo));
  3611 
  3631 
  3612         memset(&lpsiStartInfo, 0, sizeof(lpsiStartInfo));
  3632 	memset(&lpsiStartInfo, 0, sizeof(lpsiStartInfo));
  3613         lpsiStartInfo.cb                = sizeof(lpsiStartInfo);
  3633 	lpsiStartInfo.cb                = sizeof(lpsiStartInfo);
  3614         lpsiStartInfo.lpReserved        = NULL;
  3634 	lpsiStartInfo.lpReserved        = NULL;
  3615         lpsiStartInfo.lpDesktop         = NULL;
  3635 	lpsiStartInfo.lpDesktop         = NULL;
  3616         lpsiStartInfo.lpTitle           = NULL;
  3636 	lpsiStartInfo.lpTitle           = NULL;
  3617         lpsiStartInfo.dwX               = 0;
  3637 	lpsiStartInfo.dwX               = 0;
  3618         lpsiStartInfo.dwY               = 0;
  3638 	lpsiStartInfo.dwY               = 0;
  3619         lpsiStartInfo.dwXSize           = 100;
  3639 	lpsiStartInfo.dwXSize           = 100;
  3620         lpsiStartInfo.dwYSize           = 100;
  3640 	lpsiStartInfo.dwYSize           = 100;
  3621         lpsiStartInfo.dwXCountChars     = 0;
  3641 	lpsiStartInfo.dwXCountChars     = 0;
  3622         lpsiStartInfo.dwYCountChars     = 0;
  3642 	lpsiStartInfo.dwYCountChars     = 0;
  3623         lpsiStartInfo.dwFillAttribute   = 0;
  3643 	lpsiStartInfo.dwFillAttribute   = 0;
  3624         if (0 /*__isWinNT*/) {
  3644 	if (0 /*__isWinNT*/) {
  3625             lpsiStartInfo.dwFlags           = STARTF_USESTDHANDLES;
  3645 	    lpsiStartInfo.dwFlags           = STARTF_USESTDHANDLES;
  3626             lpsiStartInfo.wShowWindow       = SW_SHOWDEFAULT;
  3646 	    lpsiStartInfo.wShowWindow       = SW_SHOWDEFAULT;
  3627         } else {
  3647 	} else {
  3628             lpsiStartInfo.dwFlags           = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES /*| STARTF_USEPOSITION*/;
  3648 	    lpsiStartInfo.dwFlags           = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES /*| STARTF_USEPOSITION*/;
  3629             lpsiStartInfo.wShowWindow       = SW_HIDE /*SW_SHOWDEFAULT*/;
  3649 	    lpsiStartInfo.wShowWindow       = SW_HIDE /*SW_SHOWDEFAULT*/;
  3630         }
  3650 	}
  3631         lpsiStartInfo.cbReserved2       = 0;
  3651 	lpsiStartInfo.cbReserved2       = 0;
  3632         lpsiStartInfo.lpReserved2       = NULL;
  3652 	lpsiStartInfo.lpReserved2       = NULL;
  3633         lpsiStartInfo.hStdInput         = NULL;
  3653 	lpsiStartInfo.hStdInput         = NULL;
  3634         lpsiStartInfo.hStdOutput        = NULL;
  3654 	lpsiStartInfo.hStdOutput        = NULL;
  3635         lpsiStartInfo.hStdError         = NULL;
  3655 	lpsiStartInfo.hStdError         = NULL;
  3636 
  3656 
  3637         /*
  3657 	/*
  3638          * set create process flags
  3658 	 * set create process flags
  3639          * if the flags arg is nil, use common defaults;
  3659 	 * if the flags arg is nil, use common defaults;
  3640          * if non-nil, it must be a positive integer containing the fdwCreate bits.
  3660 	 * if non-nil, it must be a positive integer containing the fdwCreate bits.
  3641          */
  3661 	 */
  3642         if (flagsOrNil != nil) {
  3662 	if (flagsOrNil != nil) {
  3643             fdwCreate = __longIntVal(flagsOrNil);
  3663 	    fdwCreate = __longIntVal(flagsOrNil);
  3644         } else {
  3664 	} else {
  3645             if (0 /* __isWinNT */)
  3665 	    if (0 /* __isWinNT */)
  3646                 fdwCreate = 0; //IDLE_PRIORITY_CLASS;
  3666 		fdwCreate = 0; //IDLE_PRIORITY_CLASS;
  3647             else
  3667 	    else
  3648                 fdwCreate = CREATE_NEW_CONSOLE; //|IDLE_PRIORITY_CLASS; // DETACHED_PROCESS; // NORMAL_PRIORITY_CLASS ;
  3668 		fdwCreate = CREATE_NEW_CONSOLE; //|IDLE_PRIORITY_CLASS; // DETACHED_PROCESS; // NORMAL_PRIORITY_CLASS ;
  3649 
  3669 
  3650             if (newPgrp == true) {
  3670 	    if (newPgrp == true) {
  3651                 fdwCreate |= CREATE_NEW_PROCESS_GROUP;
  3671 		fdwCreate |= CREATE_NEW_PROCESS_GROUP;
  3652             }
  3672 	    }
  3653             fdwCreate |= CREATE_DEFAULT_ERROR_MODE;
  3673 	    fdwCreate |= CREATE_DEFAULT_ERROR_MODE;
  3654         }
  3674 	}
  3655 
  3675 
  3656         if (fdArray == nil) {
  3676 	if (fdArray == nil) {
  3657             lpsiStartInfo.hStdInput  = (HANDLE) _get_osfhandle (0);
  3677 	    lpsiStartInfo.hStdInput  = (HANDLE) _get_osfhandle (0);
  3658             lpsiStartInfo.hStdOutput = (HANDLE) _get_osfhandle (1);
  3678 	    lpsiStartInfo.hStdOutput = (HANDLE) _get_osfhandle (1);
  3659             lpsiStartInfo.hStdError  = (HANDLE) _get_osfhandle (2);
  3679 	    lpsiStartInfo.hStdError  = (HANDLE) _get_osfhandle (2);
  3660         } else if (__isArrayLike(fdArray) && (__arraySize(fdArray) >= 3)) {
  3680 	} else if (__isArrayLike(fdArray) && (__arraySize(fdArray) >= 3)) {
  3661             if (__ArrayInstPtr(fdArray)->a_element[0] != nil) {
  3681 	    if (__ArrayInstPtr(fdArray)->a_element[0] != nil) {
  3662                 if (__isExternalAddressLike(__ArrayInstPtr(fdArray)->a_element[0])) {
  3682 		if (__isExternalAddressLike(__ArrayInstPtr(fdArray)->a_element[0])) {
  3663                     lpsiStartInfo.hStdInput = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[0]);
  3683 		    lpsiStartInfo.hStdInput = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[0]);
  3664                 } else {
  3684 		} else {
  3665                     lpsiStartInfo.hStdInput = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[0]));
  3685 		    lpsiStartInfo.hStdInput = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[0]));
  3666                 }
  3686 		}
  3667             }
  3687 	    }
  3668             if (__ArrayInstPtr(fdArray)->a_element[1] != nil) {
  3688 	    if (__ArrayInstPtr(fdArray)->a_element[1] != nil) {
  3669                 if (__isExternalAddressLike(__ArrayInstPtr(fdArray)->a_element[1])) {
  3689 		if (__isExternalAddressLike(__ArrayInstPtr(fdArray)->a_element[1])) {
  3670                     lpsiStartInfo.hStdOutput = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[1]);
  3690 		    lpsiStartInfo.hStdOutput = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[1]);
  3671                 } else {
  3691 		} else {
  3672                     lpsiStartInfo.hStdOutput = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[1]));
  3692 		    lpsiStartInfo.hStdOutput = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[1]));
  3673                 }
  3693 		}
  3674             }
  3694 	    }
  3675             if (__ArrayInstPtr(fdArray)->a_element[2] != nil) {
  3695 	    if (__ArrayInstPtr(fdArray)->a_element[2] != nil) {
  3676                 if (__isExternalAddressLike(__ArrayInstPtr(fdArray)->a_element[2])) {
  3696 		if (__isExternalAddressLike(__ArrayInstPtr(fdArray)->a_element[2])) {
  3677                     lpsiStartInfo.hStdError  = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[2]);
  3697 		    lpsiStartInfo.hStdError  = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[2]);
  3678                 } else {
  3698 		} else {
  3679                     lpsiStartInfo.hStdError = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[2]));
  3699 		    lpsiStartInfo.hStdError = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[2]));
  3680                 }
  3700 		}
  3681             }
  3701 	    }
  3682 #if defined(PROCESSDEBUGWIN32)
  3702 #if defined(PROCESSDEBUGWIN32)
  3683             console_fprintf(stderr, "stdin %x\n", lpsiStartInfo.hStdInput);
  3703 	    console_fprintf(stderr, "stdin %x\n", lpsiStartInfo.hStdInput);
  3684             console_fprintf(stderr, "stdout %x\n",lpsiStartInfo.hStdOutput);
  3704 	    console_fprintf(stderr, "stdout %x\n",lpsiStartInfo.hStdOutput);
  3685             console_fprintf(stderr, "stderr %x\n",lpsiStartInfo.hStdError);
  3705 	    console_fprintf(stderr, "stderr %x\n",lpsiStartInfo.hStdError);
  3686 #endif
  3706 #endif
  3687         } else {
  3707 	} else {
  3688             console_fprintf(stderr, "Win32OS [warning]: bad fd arg in createProcess\n");
  3708 	    console_fprintf(stderr, "Win32OS [warning]: bad fd arg in createProcess\n");
  3689         }
  3709 	}
  3690 
  3710 
  3691         if (doFork == true) {
  3711 	if (doFork == true) {
  3692 #ifdef PROCESSDEBUGWIN32
  3712 #ifdef PROCESSDEBUGWIN32
  3693             console_fprintf(stderr, "create process cmdPath:<%s> cmdLine:<%s> in <%s>\n", cmdPath, cmdLine, dir);
  3713 	    console_fprintf(stderr, "create process cmdPath:<%s> cmdLine:<%s> in <%s>\n", cmdPath, cmdLine, dir);
  3694 #endif
  3714 #endif
  3695             if (CreateProcess(  cmdPath,
  3715 	    if (CreateProcess(  cmdPath,
  3696                                 cmdLine,
  3716 				cmdLine,
  3697                                 &securityAttributes, NULL /* &securityAttributes */,
  3717 				&securityAttributes, NULL /* &securityAttributes */,
  3698                                 securityAttributes.bInheritHandle,      /* inherit handles */
  3718 				securityAttributes.bInheritHandle,      /* inherit handles */
  3699                                 fdwCreate | CREATE_SUSPENDED,           /* resume after setting affinity */
  3719 				fdwCreate | CREATE_SUSPENDED,           /* resume after setting affinity */
  3700                                 NULL,                                   /* env */
  3720 				NULL,                                   /* env */
  3701                                 dir,
  3721 				dir,
  3702                                 &lpsiStartInfo,
  3722 				&lpsiStartInfo,
  3703                                 &lppiProcInfo ))
  3723 				&lppiProcInfo ))
  3704             {
  3724 	    {
  3705                 DWORD processAffinityMask, systemAffinityMask;
  3725 		DWORD processAffinityMask, systemAffinityMask;
  3706 
  3726 
  3707                 /*
  3727 		/*
  3708                  * Process was created suspended, now set the affinity mask
  3728 		 * Process was created suspended, now set the affinity mask
  3709                  * to any processor, and resume the processes main thread.
  3729 		 * to any processor, and resume the processes main thread.
  3710                  * (librun/process.s limited the affinity to a single processor).
  3730 		 * (librun/process.s limited the affinity to a single processor).
  3711                  */
  3731 		 */
  3712                 GetProcessAffinityMask(lppiProcInfo.hProcess, &processAffinityMask, &systemAffinityMask);
  3732 		GetProcessAffinityMask(lppiProcInfo.hProcess, &processAffinityMask, &systemAffinityMask);
  3713                 SetProcessAffinityMask(lppiProcInfo.hProcess, systemAffinityMask);
  3733 		SetProcessAffinityMask(lppiProcInfo.hProcess, systemAffinityMask);
  3714                 if ((fdwCreate & CREATE_SUSPENDED) == 0) {
  3734 		if ((fdwCreate & CREATE_SUSPENDED) == 0) {
  3715                     ResumeThread(lppiProcInfo.hThread);
  3735 		    ResumeThread(lppiProcInfo.hThread);
  3716                 }
  3736 		}
  3717                 CloseHandle(lppiProcInfo.hThread);
  3737 		CloseHandle(lppiProcInfo.hThread);
  3718 #ifdef PROCESSDEBUGWIN32
  3738 #ifdef PROCESSDEBUGWIN32
  3719                 console_fprintf(stderr, "created process hProcess=%x\n", lppiProcInfo.hProcess);
  3739 		console_fprintf(stderr, "created process hProcess=%x\n", lppiProcInfo.hProcess);
  3720 #endif
  3740 #endif
  3721 
  3741 
  3722                 __externalAddressVal(handle) = lppiProcInfo.hProcess;
  3742 		__externalAddressVal(handle) = lppiProcInfo.hProcess;
  3723                 ((struct __Win32OperatingSystem__Win32ProcessHandle_struct *)(handle))->pid = __mkSmallInteger(lppiProcInfo.dwProcessId);
  3743 		((struct __Win32OperatingSystem__Win32ProcessHandle_struct *)(handle))->pid = __mkSmallInteger(lppiProcInfo.dwProcessId);
  3724                 RETURN (handle);
  3744 		RETURN (handle);
  3725             }
  3745 	    }
  3726 #ifdef PROCESSDEBUGWIN32
  3746 #ifdef PROCESSDEBUGWIN32
  3727             console_fprintf(stderr, "created process error %d\n", GetLastError());
  3747 	    console_fprintf(stderr, "created process error %d\n", GetLastError());
  3728 #endif
  3748 #endif
  3729             RETURN (nil);
  3749 	    RETURN (nil);
  3730         } else {
  3750 	} else {
  3731             ; /* should never be called that way */
  3751 	    ; /* should never be called that way */
  3732         }
  3752 	}
  3733     }
  3753     }
  3734 %}.
  3754 %}.
  3735     "
  3755     "
  3736      path-argument not string
  3756      path-argument not string
  3737      or argArray not an array/nil
  3757      or argArray not an array/nil
  3753 %{
  3773 %{
  3754     SHELLEXECUTEINFO shExecInfo = {0};
  3774     SHELLEXECUTEINFO shExecInfo = {0};
  3755     shExecInfo.cbSize = sizeof(shExecInfo);
  3775     shExecInfo.cbSize = sizeof(shExecInfo);
  3756 
  3776 
  3757     if (__isSmallInteger(nShowCmd)) {
  3777     if (__isSmallInteger(nShowCmd)) {
  3758         shExecInfo.nShow = __intVal(nShowCmd);
  3778 	shExecInfo.nShow = __intVal(nShowCmd);
  3759     } else {
  3779     } else {
  3760         if (nShowCmd == @symbol(SW_SHOW)) {
  3780 	if (nShowCmd == @symbol(SW_SHOW)) {
  3761             shExecInfo.nShow = SW_SHOW;
  3781 	    shExecInfo.nShow = SW_SHOW;
  3762         } else if (nShowCmd == @symbol(SW_SHOWNORMAL)) {
  3782 	} else if (nShowCmd == @symbol(SW_SHOWNORMAL)) {
  3763             shExecInfo.nShow = SW_SHOWNORMAL;
  3783 	    shExecInfo.nShow = SW_SHOWNORMAL;
  3764         } else if (nShowCmd == @symbol(SW_SHOWDEFAULT)) {
  3784 	} else if (nShowCmd == @symbol(SW_SHOWDEFAULT)) {
  3765             shExecInfo.nShow = SW_SHOWDEFAULT;
  3785 	    shExecInfo.nShow = SW_SHOWDEFAULT;
  3766         } else if (nShowCmd == @symbol(SW_SHOWMAXIMIZED)) {
  3786 	} else if (nShowCmd == @symbol(SW_SHOWMAXIMIZED)) {
  3767             shExecInfo.nShow = SW_SHOWMAXIMIZED;
  3787 	    shExecInfo.nShow = SW_SHOWMAXIMIZED;
  3768         } else if (nShowCmd == @symbol(SW_SHOWMINIMIZED)) {
  3788 	} else if (nShowCmd == @symbol(SW_SHOWMINIMIZED)) {
  3769             shExecInfo.nShow = SW_SHOWMINIMIZED;
  3789 	    shExecInfo.nShow = SW_SHOWMINIMIZED;
  3770         } else if (nShowCmd == @symbol(SW_SHOWMINNOACTIVE)) {
  3790 	} else if (nShowCmd == @symbol(SW_SHOWMINNOACTIVE)) {
  3771             shExecInfo.nShow = SW_SHOWMINNOACTIVE;
  3791 	    shExecInfo.nShow = SW_SHOWMINNOACTIVE;
  3772         } else if (nShowCmd == @symbol(SW_SHOWNA)) {
  3792 	} else if (nShowCmd == @symbol(SW_SHOWNA)) {
  3773             shExecInfo.nShow = SW_SHOWNA;
  3793 	    shExecInfo.nShow = SW_SHOWNA;
  3774         } else if (nShowCmd == @symbol(SW_SHOWNOACTIVATE)) {
  3794 	} else if (nShowCmd == @symbol(SW_SHOWNOACTIVATE)) {
  3775             shExecInfo.nShow = SW_SHOWNOACTIVATE;
  3795 	    shExecInfo.nShow = SW_SHOWNOACTIVATE;
  3776         } else if (nShowCmd == @symbol(SW_MAXIMIZE)) {
  3796 	} else if (nShowCmd == @symbol(SW_MAXIMIZE)) {
  3777             shExecInfo.nShow = SW_MAXIMIZE;
  3797 	    shExecInfo.nShow = SW_MAXIMIZE;
  3778         } else if (nShowCmd == @symbol(SW_RESTORE)) {
  3798 	} else if (nShowCmd == @symbol(SW_RESTORE)) {
  3779             shExecInfo.nShow = SW_RESTORE;
  3799 	    shExecInfo.nShow = SW_RESTORE;
  3780         } else {
  3800 	} else {
  3781             goto badArgument;
  3801 	    goto badArgument;
  3782         }
  3802 	}
  3783     }
  3803     }
  3784     if (((lpOperation == nil) || __isStringLike(lpOperation))
  3804     if (((lpOperation == nil) || __isStringLike(lpOperation))
  3785      && ((lpFile == nil) || __isStringLike(lpFile))
  3805      && ((lpFile == nil) || __isStringLike(lpFile))
  3786      && ((lpParameters == nil) || __isStringLike(lpParameters))
  3806      && ((lpParameters == nil) || __isStringLike(lpParameters))
  3787      && ((lpDirectory == nil) || __isStringLike(lpDirectory))
  3807      && ((lpDirectory == nil) || __isStringLike(lpDirectory))
  3788     ) {
  3808     ) {
  3789         // hProcess member receives the process handle
  3809 	// hProcess member receives the process handle
  3790         shExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
  3810 	shExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
  3791 
  3811 
  3792         shExecInfo.hwnd = 0;
  3812 	shExecInfo.hwnd = 0;
  3793         shExecInfo.lpVerb        = (lpOperation != nil) ? __stringVal(lpOperation) : NULL;
  3813 	shExecInfo.lpVerb        = (lpOperation != nil) ? __stringVal(lpOperation) : NULL;
  3794         shExecInfo.lpFile        = (lpFile != nil) ? __stringVal(lpFile) : NULL;
  3814 	shExecInfo.lpFile        = (lpFile != nil) ? __stringVal(lpFile) : NULL;
  3795         shExecInfo.lpParameters  = (lpParameters != nil) ? __stringVal(lpParameters) : NULL;
  3815 	shExecInfo.lpParameters  = (lpParameters != nil) ? __stringVal(lpParameters) : NULL;
  3796         shExecInfo.lpDirectory   = (lpDirectory != nil) ? __stringVal(lpDirectory) : NULL;
  3816 	shExecInfo.lpDirectory   = (lpDirectory != nil) ? __stringVal(lpDirectory) : NULL;
  3797         if (hwnd != nil) {
  3817 	if (hwnd != nil) {
  3798             if (__isExternalAddressLike(hwnd)) {
  3818 	    if (__isExternalAddressLike(hwnd)) {
  3799                 shExecInfo.hwnd = (HANDLE)(__externalAddressVal(hwnd));
  3819 		shExecInfo.hwnd = (HANDLE)(__externalAddressVal(hwnd));
  3800             } else
  3820 	    } else
  3801                 goto badArgument;
  3821 		goto badArgument;
  3802         }
  3822 	}
  3803         if (ShellExecuteEx(&shExecInfo)) {
  3823 	if (ShellExecuteEx(&shExecInfo)) {
  3804             if (shExecInfo.hProcess) {
  3824 	    if (shExecInfo.hProcess) {
  3805                 DWORD processAffinityMask, systemAffinityMask;
  3825 		DWORD processAffinityMask, systemAffinityMask;
  3806                 /*
  3826 		/*
  3807                  * Set the affinity mask
  3827 		 * Set the affinity mask
  3808                  * to any processor, and resume the processes main thread.
  3828 		 * to any processor, and resume the processes main thread.
  3809                  * (librun/process.s limited the affinity to a single processor).
  3829 		 * (librun/process.s limited the affinity to a single processor).
  3810                  */
  3830 		 */
  3811                 GetProcessAffinityMask(shExecInfo.hProcess, &processAffinityMask, &systemAffinityMask);
  3831 		GetProcessAffinityMask(shExecInfo.hProcess, &processAffinityMask, &systemAffinityMask);
  3812                 SetProcessAffinityMask(shExecInfo.hProcess, systemAffinityMask);
  3832 		SetProcessAffinityMask(shExecInfo.hProcess, systemAffinityMask);
  3813 
  3833 
  3814                 // new (does not work, yet):
  3834 		// new (does not work, yet):
  3815                 // __externalAddressVal(handle) = shExecInfo.hProcess;
  3835 		// __externalAddressVal(handle) = shExecInfo.hProcess;
  3816                 // RETURN (handle);
  3836 		// RETURN (handle);
  3817 
  3837 
  3818                 // old:
  3838 		// old:
  3819                 CloseHandle(shExecInfo.hProcess);
  3839 		CloseHandle(shExecInfo.hProcess);
  3820                 RETURN (self); /* OK */
  3840 		RETURN (self); /* OK */
  3821             } else {
  3841 	    } else {
  3822                 RETURN (self); /* OK */
  3842 		RETURN (self); /* OK */
  3823             }
  3843 	    }
  3824         } else {
  3844 	} else {
  3825             /* error */
  3845 	    /* error */
  3826             errorNumber = __mkSmallInteger(__WIN32_ERR(GetLastError()));
  3846 	    errorNumber = __mkSmallInteger(__WIN32_ERR(GetLastError()));
  3827         }
  3847 	}
  3828     }
  3848     }
  3829 badArgument: ;
  3849 badArgument: ;
  3830 %}.
  3850 %}.
  3831     errorNumber isNil ifTrue:[
  3851     errorNumber isNil ifTrue:[
  3832         self primitiveFailed:'invalid argument(s)'.
  3852 	self primitiveFailed:'invalid argument(s)'.
  3833     ] ifFalse:[
  3853     ] ifFalse:[
  3834         (OperatingSystem errorHolderForNumber:errorNumber)
  3854 	(OperatingSystem errorHolderForNumber:errorNumber)
  3835             parameter:lpFile;
  3855 	    parameter:lpFile;
  3836             reportError
  3856 	    reportError
  3837     ].
  3857     ].
  3838 
  3858 
  3839     "
  3859     "
  3840      self
  3860      self
  3841         shellExecute:nil
  3861 	shellExecute:nil
  3842         lpOperation:'open'
  3862 	lpOperation:'open'
  3843         lpFile:(Filename currentDirectory pathName)
  3863 	lpFile:(Filename currentDirectory pathName)
  3844         lpParameters:nil
  3864 	lpParameters:nil
  3845         lpDirectory:(Filename currentDirectory pathName)
  3865 	lpDirectory:(Filename currentDirectory pathName)
  3846         nShowCmd:#SW_SHOWNORMAL
  3866 	nShowCmd:#SW_SHOWNORMAL
  3847     self
  3867     self
  3848         shellExecute:nil
  3868 	shellExecute:nil
  3849         lpOperation:'explore'
  3869 	lpOperation:'explore'
  3850         lpFile:(Filename currentDirectory pathName)
  3870 	lpFile:(Filename currentDirectory pathName)
  3851         lpParameters:nil
  3871 	lpParameters:nil
  3852         lpDirectory:(Filename currentDirectory pathName)
  3872 	lpDirectory:(Filename currentDirectory pathName)
  3853         nShowCmd:#SW_SHOWNORMAL
  3873 	nShowCmd:#SW_SHOWNORMAL
  3854     "
  3874     "
  3855 !
  3875 !
  3856 
  3876 
  3857 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream
  3877 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream
  3858     errorTo:anExternalErrStream auxFrom:anAuxiliaryStream
  3878     errorTo:anExternalErrStream auxFrom:anAuxiliaryStream
  3875     aCommandString isNil ifTrue:[^ nil].
  3895     aCommandString isNil ifTrue:[^ nil].
  3876 
  3896 
  3877     shellAndArgs := self commandAndArgsForOSCommand:aCommandString.
  3897     shellAndArgs := self commandAndArgsForOSCommand:aCommandString.
  3878 
  3898 
  3879     ^ self
  3899     ^ self
  3880         exec:(shellAndArgs at:1) withArguments:(shellAndArgs at:2)
  3900 	exec:(shellAndArgs at:1) withArguments:(shellAndArgs at:2)
  3881         inputFrom:anExternalInStream outputTo:anExternalOutStream
  3901 	inputFrom:anExternalInStream outputTo:anExternalOutStream
  3882         errorTo:anExternalErrStream auxFrom:anAuxiliaryStream
  3902 	errorTo:anExternalErrStream auxFrom:anAuxiliaryStream
  3883         environment:anEvironmentDictionary inDirectory:dir
  3903 	environment:anEvironmentDictionary inDirectory:dir
  3884 
  3904 
  3885     "blocking at current prio (i.e. only higher prio threads execute):
  3905     "blocking at current prio (i.e. only higher prio threads execute):
  3886 
  3906 
  3887      OperatingSystem executeCommand:'ls -l > out'.
  3907      OperatingSystem executeCommand:'ls -l > out'.
  3888     "
  3908     "
  3899      pid := OperatingSystem startProcess:'sleep 10; grep drw' inputFrom:in outputTo:out errorTo:err.
  3919      pid := OperatingSystem startProcess:'sleep 10; grep drw' inputFrom:in outputTo:out errorTo:err.
  3900 
  3920 
  3901      The following will no longer work. monitorPid has disappeared
  3921      The following will no longer work. monitorPid has disappeared
  3902 
  3922 
  3903      pid notNil ifTrue:[
  3923      pid notNil ifTrue:[
  3904          Processor monitorPid:pid action:[:OSstatus | sema signal ].
  3924 	 Processor monitorPid:pid action:[:OSstatus | sema signal ].
  3905      ].
  3925      ].
  3906      in close.
  3926      in close.
  3907      out close.
  3927      out close.
  3908      err close.
  3928      err close.
  3909      sema wait.
  3929      sema wait.
  3921 closeFd:anIntegerOrHandle
  3941 closeFd:anIntegerOrHandle
  3922     "low level close of a filedescriptor"
  3942     "low level close of a filedescriptor"
  3923 
  3943 
  3924 %{
  3944 %{
  3925     if (__isSmallInteger(anIntegerOrHandle)) {
  3945     if (__isSmallInteger(anIntegerOrHandle)) {
  3926         close(__intVal(anIntegerOrHandle));
  3946 	close(__intVal(anIntegerOrHandle));
  3927         RETURN(self);
  3947 	RETURN(self);
  3928     }
  3948     }
  3929     if (__isExternalAddressLike(anIntegerOrHandle)) {
  3949     if (__isExternalAddressLike(anIntegerOrHandle)) {
  3930        if (!CloseHandle( __externalAddressVal(anIntegerOrHandle))) {
  3950        if (!CloseHandle( __externalAddressVal(anIntegerOrHandle))) {
  3931            console_fprintf( stderr, "Win32OS [warning]: Could not close handle : %x\n", __externalAddressVal(anIntegerOrHandle));
  3951 	   console_fprintf( stderr, "Win32OS [warning]: Could not close handle : %x\n", __externalAddressVal(anIntegerOrHandle));
  3932        }
  3952        }
  3933        RETURN(self);
  3953        RETURN(self);
  3934     }
  3954     }
  3935 %}.
  3955 %}.
  3936     ^ self primitiveFailed.
  3956     ^ self primitiveFailed.
  3954 
  3974 
  3955     (self isDirectory:aPathName) ifTrue:[^ true].
  3975     (self isDirectory:aPathName) ifTrue:[^ true].
  3956 
  3976 
  3957 %{
  3977 %{
  3958     if (__isStringLike(aPathName)) {
  3978     if (__isStringLike(aPathName)) {
  3959         int ret;
  3979 	int ret;
  3960         SECURITY_ATTRIBUTES sa;
  3980 	SECURITY_ATTRIBUTES sa;
  3961 
  3981 
  3962         sa.nLength = sizeof( sa );
  3982 	sa.nLength = sizeof( sa );
  3963         sa.lpSecurityDescriptor = NULL;
  3983 	sa.lpSecurityDescriptor = NULL;
  3964         sa.bInheritHandle = TRUE;
  3984 	sa.bInheritHandle = TRUE;
  3965 
  3985 
  3966         ret = CreateDirectoryA(__stringVal(aPathName), &sa);
  3986 	ret = CreateDirectoryA(__stringVal(aPathName), &sa);
  3967         if (ret != TRUE) {
  3987 	if (ret != TRUE) {
  3968             __threadErrno = __WIN32_ERR(GetLastError());
  3988 	    __threadErrno = __WIN32_ERR(GetLastError());
  3969             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  3989 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  3970             RETURN (false);
  3990 	    RETURN (false);
  3971         }
  3991 	}
  3972         RETURN (true);
  3992 	RETURN (true);
  3973     }
  3993     }
  3974     if (__isUnicode16String(aPathName)) {
  3994     if (__isUnicode16String(aPathName)) {
  3975         int ret;
  3995 	int ret;
  3976         SECURITY_ATTRIBUTES sa;
  3996 	SECURITY_ATTRIBUTES sa;
  3977         wchar_t _wPathName[MAXPATHLEN+1];
  3997 	wchar_t _wPathName[MAXPATHLEN+1];
  3978         int i, l;
  3998 	int i, l;
  3979 
  3999 
  3980         l = __unicode16StringSize(aPathName);
  4000 	l = __unicode16StringSize(aPathName);
  3981         if (l > MAXPATHLEN) l = MAXPATHLEN;
  4001 	if (l > MAXPATHLEN) l = MAXPATHLEN;
  3982         for (i=0; i<l; i++) {
  4002 	for (i=0; i<l; i++) {
  3983             _wPathName[i] = __unicode16StringVal(aPathName)[i];
  4003 	    _wPathName[i] = __unicode16StringVal(aPathName)[i];
  3984         }
  4004 	}
  3985         _wPathName[i] = 0;
  4005 	_wPathName[i] = 0;
  3986 
  4006 
  3987         sa.nLength = sizeof( sa );
  4007 	sa.nLength = sizeof( sa );
  3988         sa.lpSecurityDescriptor = NULL;
  4008 	sa.lpSecurityDescriptor = NULL;
  3989         sa.bInheritHandle = TRUE;
  4009 	sa.bInheritHandle = TRUE;
  3990 
  4010 
  3991         ret = CreateDirectoryW(_wPathName, &sa);
  4011 	ret = CreateDirectoryW(_wPathName, &sa);
  3992         if (ret != TRUE) {
  4012 	if (ret != TRUE) {
  3993             __threadErrno = __WIN32_ERR(GetLastError());
  4013 	    __threadErrno = __WIN32_ERR(GetLastError());
  3994             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4014 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  3995             RETURN (false);
  4015 	    RETURN (false);
  3996         }
  4016 	}
  3997         RETURN (true);
  4017 	RETURN (true);
  3998     }
  4018     }
  3999 %}.
  4019 %}.
  4000     ^ self primitiveFailed
  4020     ^ self primitiveFailed
  4001 
  4021 
  4002     "
  4022     "
  4057     WIN32_FIND_DATA wfd;
  4077     WIN32_FIND_DATA wfd;
  4058     WORD wsz[MAX_PATH];
  4078     WORD wsz[MAX_PATH];
  4059     char szGotPath[MAX_PATH];
  4079     char szGotPath[MAX_PATH];
  4060 
  4080 
  4061     if (! __isStringLike(aPathName)) {
  4081     if (! __isStringLike(aPathName)) {
  4062         console_fprintf(stderr, "OperatingSystem [info]: invalid argument\n");
  4082 	console_fprintf(stderr, "OperatingSystem [info]: invalid argument\n");
  4063         goto error;
  4083 	goto error;
  4064     }
  4084     }
  4065 
  4085 
  4066     if( ! coInitialized ) {
  4086     if( ! coInitialized ) {
  4067         console_fprintf(stderr, "OperatingSystem [info]: com not initialized\n");
  4087 	console_fprintf(stderr, "OperatingSystem [info]: com not initialized\n");
  4068         goto error;
  4088 	goto error;
  4069     }
  4089     }
  4070 
  4090 
  4071     if ( ipShellLink == NULL ) {
  4091     if ( ipShellLink == NULL ) {
  4072         hres = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
  4092 	hres = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
  4073                                 &IID_IShellLink, (LPVOID *)&ipShellLink);
  4093 				&IID_IShellLink, (LPVOID *)&ipShellLink);
  4074         if (! SUCCEEDED(hres)) {
  4094 	if (! SUCCEEDED(hres)) {
  4075             console_fprintf(stderr, "OperatingSystem [info]: CoCreateInstance Error - hres = %08x\n", hres);
  4095 	    console_fprintf(stderr, "OperatingSystem [info]: CoCreateInstance Error - hres = %08x\n", hres);
  4076             ipShellLink = NULL;
  4096 	    ipShellLink = NULL;
  4077             goto error;
  4097 	    goto error;
  4078         }
  4098 	}
  4079 
  4099 
  4080         hres = ipShellLink->lpVtbl->QueryInterface( ipShellLink, &IID_IPersistFile, & ipPersistFile );
  4100 	hres = ipShellLink->lpVtbl->QueryInterface( ipShellLink, &IID_IPersistFile, & ipPersistFile );
  4081         if (! SUCCEEDED(hres)) {
  4101 	if (! SUCCEEDED(hres)) {
  4082             console_fprintf(stderr, "OperatingSystem [info]: QueryInterface Error - hres = %08x\n", hres);
  4102 	    console_fprintf(stderr, "OperatingSystem [info]: QueryInterface Error - hres = %08x\n", hres);
  4083             ipShellLink->lpVtbl->Release(ipShellLink);
  4103 	    ipShellLink->lpVtbl->Release(ipShellLink);
  4084             ipShellLink   = NULL;
  4104 	    ipShellLink   = NULL;
  4085             ipPersistFile = NULL;
  4105 	    ipPersistFile = NULL;
  4086             goto error;
  4106 	    goto error;
  4087         }
  4107 	}
  4088     }
  4108     }
  4089 
  4109 
  4090     MultiByteToWideChar(CP_ACP, 0, __stringVal(aPathName), -1, wsz, MAX_PATH);
  4110     MultiByteToWideChar(CP_ACP, 0, __stringVal(aPathName), -1, wsz, MAX_PATH);
  4091 
  4111 
  4092     hres = ipPersistFile->lpVtbl->Load(ipPersistFile, wsz, STGM_READ);
  4112     hres = ipPersistFile->lpVtbl->Load(ipPersistFile, wsz, STGM_READ);
  4093 
  4113 
  4094     if (SUCCEEDED(hres)) {
  4114     if (SUCCEEDED(hres)) {
  4095         hres = ipShellLink->lpVtbl->GetPath(ipShellLink, szGotPath, MAX_PATH,
  4115 	hres = ipShellLink->lpVtbl->GetPath(ipShellLink, szGotPath, MAX_PATH,
  4096                     (WIN32_FIND_DATA *)&wfd, 0 /* SLGP_SHORTPATH */ );
  4116 		    (WIN32_FIND_DATA *)&wfd, 0 /* SLGP_SHORTPATH */ );
  4097         if (SUCCEEDED(hres)) {
  4117 	if (SUCCEEDED(hres)) {
  4098             resolvedPath = __MKSTRING(szGotPath);
  4118 	    resolvedPath = __MKSTRING(szGotPath);
  4099         } else {
  4119 	} else {
  4100 #ifdef COM_DEBUG
  4120 #ifdef COM_DEBUG
  4101             console_fprintf(stderr, "OperatingSystem [info]: GetPath failed - hres = %08x\n", hres );
  4121 	    console_fprintf(stderr, "OperatingSystem [info]: GetPath failed - hres = %08x\n", hres );
  4102 #endif
  4122 #endif
  4103         }
  4123 	}
  4104     } else {
  4124     } else {
  4105 #ifdef COM_DEBUG
  4125 #ifdef COM_DEBUG
  4106         console_fprintf(stderr, "OperatingSystem [info]: Load failed - hres = %08x\n", hres );
  4126 	console_fprintf(stderr, "OperatingSystem [info]: Load failed - hres = %08x\n", hres );
  4107 #endif
  4127 #endif
  4108     }
  4128     }
  4109     /* ipPersistFile->lpVtbl->Release(ipPersistFile);  */
  4129     /* ipPersistFile->lpVtbl->Release(ipPersistFile);  */
  4110 
  4130 
  4111 error: ;
  4131 error: ;
  4127 linkFile:oldPath to:newPath
  4147 linkFile:oldPath to:newPath
  4128     "link the file 'oldPath' to 'newPath'. The link will be a hard link.
  4148     "link the file 'oldPath' to 'newPath'. The link will be a hard link.
  4129      Return true if successful, false if not."
  4149      Return true if successful, false if not."
  4130 
  4150 
  4131     (oldPath isString not or:[newPath isString not]) ifTrue:[
  4151     (oldPath isString not or:[newPath isString not]) ifTrue:[
  4132         "/
  4152 	"/
  4133         "/ bad argument(s) given
  4153 	"/ bad argument(s) given
  4134         "/
  4154 	"/
  4135         ^ self primitiveFailed
  4155 	^ self primitiveFailed
  4136     ].
  4156     ].
  4137 
  4157 
  4138     ^ self createHardLinkFrom:oldPath to:newPath
  4158     ^ self createHardLinkFrom:oldPath to:newPath
  4139 
  4159 
  4140     "
  4160     "
  4162     int numAttrib;
  4182     int numAttrib;
  4163     int i, l;
  4183     int i, l;
  4164     DWORD access, share, create, attr;
  4184     DWORD access, share, create, attr;
  4165 
  4185 
  4166     if (__isStringLike(pathName)) {
  4186     if (__isStringLike(pathName)) {
  4167         name = __stringVal(pathName);
  4187 	name = __stringVal(pathName);
  4168     } else if (__isUnicode16String(pathName)) {
  4188     } else if (__isUnicode16String(pathName)) {
  4169         l = __unicode16StringSize(pathName);
  4189 	l = __unicode16StringSize(pathName);
  4170         if (l > MAXPATHLEN) l = MAXPATHLEN;
  4190 	if (l > MAXPATHLEN) l = MAXPATHLEN;
  4171         for (i=0; i<l; i++) {
  4191 	for (i=0; i<l; i++) {
  4172             _wPathName[i] = __unicode16StringVal(pathName)[i];
  4192 	    _wPathName[i] = __unicode16StringVal(pathName)[i];
  4173         }
  4193 	}
  4174         _wPathName[i] = 0;
  4194 	_wPathName[i] = 0;
  4175     } else {
  4195     } else {
  4176         fileHandle = nil;
  4196 	fileHandle = nil;
  4177         argumentError = @symbol(badPathName);
  4197 	argumentError = @symbol(badPathName);
  4178         goto badArgument;
  4198 	goto badArgument;
  4179     }
  4199     }
  4180 
  4200 
  4181     if (! __isArrayLike(attributeSpec)) {
  4201     if (! __isArrayLike(attributeSpec)) {
  4182         fileHandle = nil;
  4202 	fileHandle = nil;
  4183         argumentError = @symbol(badAttributeSpec);
  4203 	argumentError = @symbol(badAttributeSpec);
  4184         goto badArgument;
  4204 	goto badArgument;
  4185     }
  4205     }
  4186     ap = __ArrayInstPtr(attributeSpec)->a_element;
  4206     ap = __ArrayInstPtr(attributeSpec)->a_element;
  4187     numAttrib = __arraySize(attributeSpec);
  4207     numAttrib = __arraySize(attributeSpec);
  4188 
  4208 
  4189     share = 0;
  4209     share = 0;
  4190     access = 0;
  4210     access = 0;
  4191     create = 0;
  4211     create = 0;
  4192     attr = 0;
  4212     attr = 0;
  4193 
  4213 
  4194     for (i=0; i<numAttrib;i++) {
  4214     for (i=0; i<numAttrib;i++) {
  4195         OBJ attrSym = ap[i];
  4215 	OBJ attrSym = ap[i];
  4196 
  4216 
  4197         if (attrSym == @symbol(FILE_SHARE_READ)) {
  4217 	if (attrSym == @symbol(FILE_SHARE_READ)) {
  4198             share |= FILE_SHARE_READ;
  4218 	    share |= FILE_SHARE_READ;
  4199         } else if (attrSym == @symbol(FILE_SHARE_WRITE)) {
  4219 	} else if (attrSym == @symbol(FILE_SHARE_WRITE)) {
  4200             share |= FILE_SHARE_WRITE;
  4220 	    share |= FILE_SHARE_WRITE;
  4201 
  4221 
  4202         } else if (attrSym == @symbol(GENERIC_READ)) {
  4222 	} else if (attrSym == @symbol(GENERIC_READ)) {
  4203             access |= GENERIC_READ;
  4223 	    access |= GENERIC_READ;
  4204         } else if (attrSym == @symbol(GENERIC_WRITE)) {
  4224 	} else if (attrSym == @symbol(GENERIC_WRITE)) {
  4205             access |= GENERIC_WRITE;
  4225 	    access |= GENERIC_WRITE;
  4206 
  4226 
  4207         } else if (attrSym == @symbol(CREATE_NEW)) {
  4227 	} else if (attrSym == @symbol(CREATE_NEW)) {
  4208             create |= CREATE_NEW;
  4228 	    create |= CREATE_NEW;
  4209         } else if (attrSym == @symbol(CREATE_ALWAYS)) {
  4229 	} else if (attrSym == @symbol(CREATE_ALWAYS)) {
  4210             create |= CREATE_ALWAYS;
  4230 	    create |= CREATE_ALWAYS;
  4211         } else if (attrSym == @symbol(OPEN_EXISTING)) {
  4231 	} else if (attrSym == @symbol(OPEN_EXISTING)) {
  4212             create |= OPEN_EXISTING;
  4232 	    create |= OPEN_EXISTING;
  4213         } else if (attrSym == @symbol(OPEN_ALWAYS)) {
  4233 	} else if (attrSym == @symbol(OPEN_ALWAYS)) {
  4214             create |= OPEN_ALWAYS;
  4234 	    create |= OPEN_ALWAYS;
  4215         } else if (attrSym == @symbol(TRUNCATE_EXISTING)) {
  4235 	} else if (attrSym == @symbol(TRUNCATE_EXISTING)) {
  4216             create |= TRUNCATE_EXISTING;
  4236 	    create |= TRUNCATE_EXISTING;
  4217 
  4237 
  4218         } else if (attrSym == @symbol(FILE_ATTRIBUTE_HIDDEN)) {
  4238 	} else if (attrSym == @symbol(FILE_ATTRIBUTE_HIDDEN)) {
  4219             attr |= FILE_ATTRIBUTE_HIDDEN;
  4239 	    attr |= FILE_ATTRIBUTE_HIDDEN;
  4220         } else if (attrSym == @symbol(FILE_ATTRIBUTE_READONLY)) {
  4240 	} else if (attrSym == @symbol(FILE_ATTRIBUTE_READONLY)) {
  4221             attr |= FILE_ATTRIBUTE_READONLY;
  4241 	    attr |= FILE_ATTRIBUTE_READONLY;
  4222         } else if (attrSym == @symbol(FILE_ATTRIBUTE_READONLY)) {
  4242 	} else if (attrSym == @symbol(FILE_ATTRIBUTE_READONLY)) {
  4223             attr |= FILE_ATTRIBUTE_READONLY;
  4243 	    attr |= FILE_ATTRIBUTE_READONLY;
  4224         } else if (attrSym == @symbol(FILE_FLAG_WRITE_THROUGH)) {
  4244 	} else if (attrSym == @symbol(FILE_FLAG_WRITE_THROUGH)) {
  4225             attr |= FILE_FLAG_WRITE_THROUGH;
  4245 	    attr |= FILE_FLAG_WRITE_THROUGH;
  4226         } else if (attrSym == @symbol(FILE_FLAG_SEQUENTIAL_SCAN)) {
  4246 	} else if (attrSym == @symbol(FILE_FLAG_SEQUENTIAL_SCAN)) {
  4227             attr |= FILE_FLAG_SEQUENTIAL_SCAN;
  4247 	    attr |= FILE_FLAG_SEQUENTIAL_SCAN;
  4228         } else if (attrSym == @symbol(FILE_FLAG_DELETE_ON_CLOSE)) {
  4248 	} else if (attrSym == @symbol(FILE_FLAG_DELETE_ON_CLOSE)) {
  4229             attr |= FILE_FLAG_DELETE_ON_CLOSE;
  4249 	    attr |= FILE_FLAG_DELETE_ON_CLOSE;
  4230         } else {
  4250 	} else {
  4231             console_fprintf(stderr, "Win32OS [warning]: unsupported open mode\n");
  4251 	    console_fprintf(stderr, "Win32OS [warning]: unsupported open mode\n");
  4232         }
  4252 	}
  4233     }
  4253     }
  4234     if (create == 0) {
  4254     if (create == 0) {
  4235         fileHandle = nil;
  4255 	fileHandle = nil;
  4236         argumentError = @symbol(missingCreateMode);
  4256 	argumentError = @symbol(missingCreateMode);
  4237         goto badArgument;
  4257 	goto badArgument;
  4238     }
  4258     }
  4239 #ifdef PROCESSDEBUGWIN32
  4259 #ifdef PROCESSDEBUGWIN32
  4240     console_fprintf(stderr, "name:<%s> access:%x share:%x create:%x attr:%x\n",
  4260     console_fprintf(stderr, "name:<%s> access:%x share:%x create:%x attr:%x\n",
  4241                 name, access, share, create, attr);
  4261 		name, access, share, create, attr);
  4242 #endif
  4262 #endif
  4243     if (__isStringLike(pathName)) {
  4263     if (__isStringLike(pathName)) {
  4244         h = CreateFileA(name, access, share, 0 /* sa */, create, attr, 0 /* hTempl */);
  4264 	h = CreateFileA(name, access, share, 0 /* sa */, create, attr, 0 /* hTempl */);
  4245     } else {
  4265     } else {
  4246         h = CreateFileW(_wPathName, access, share, 0 /* sa */, create, attr, 0 /* hTempl */);
  4266 	h = CreateFileW(_wPathName, access, share, 0 /* sa */, create, attr, 0 /* hTempl */);
  4247     }
  4267     }
  4248 
  4268 
  4249     if (h != INVALID_HANDLE_VALUE) {
  4269     if (h != INVALID_HANDLE_VALUE) {
  4250         __externalAddressVal(fileHandle) = (void *)h;
  4270 	__externalAddressVal(fileHandle) = (void *)h;
  4251     } else {
  4271     } else {
  4252         fileHandle = nil;
  4272 	fileHandle = nil;
  4253         errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
  4273 	errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
  4254     }
  4274     }
  4255 
  4275 
  4256 badArgument: ;
  4276 badArgument: ;
  4257 %}.
  4277 %}.
  4258     fileHandle notNil ifTrue:[
  4278     fileHandle notNil ifTrue:[
  4259         fileHandle registerForFinalization.
  4279 	fileHandle registerForFinalization.
  4260         ^ fileHandle.
  4280 	^ fileHandle.
  4261     ].
  4281     ].
  4262     errorNumber isNil ifTrue:[
  4282     errorNumber isNil ifTrue:[
  4263         self error:'invalid argument(s): ', argumentError.
  4283 	self error:'invalid argument(s): ', argumentError.
  4264     ] ifFalse:[
  4284     ] ifFalse:[
  4265         (self errorHolderForNumber:errorNumber) reportError
  4285 	(self errorHolderForNumber:errorNumber) reportError
  4266     ].
  4286     ].
  4267 !
  4287 !
  4268 
  4288 
  4269 openFileForAppend:pathName
  4289 openFileForAppend:pathName
  4270     "noone sends this message yet"
  4290     "noone sends this message yet"
  4308 %{
  4328 %{
  4309     int ret;
  4329     int ret;
  4310 
  4330 
  4311     if (__isStringLike(fullPathName)) {
  4331     if (__isStringLike(fullPathName)) {
  4312 #ifdef DO_WRAP_CALLS
  4332 #ifdef DO_WRAP_CALLS
  4313         {
  4333 	{
  4314             char _aPathName[MAXPATHLEN];
  4334 	    char _aPathName[MAXPATHLEN];
  4315 
  4335 
  4316             strncpy(_aPathName, __stringVal(fullPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4336 	    strncpy(_aPathName, __stringVal(fullPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4317             do {
  4337 	    do {
  4318                 __threadErrno = 0;
  4338 		__threadErrno = 0;
  4319                 ret = STX_API_NOINT_CALL1( "RemoveDirectoryA", RemoveDirectoryA, _aPathName);
  4339 		ret = STX_API_NOINT_CALL1( "RemoveDirectoryA", RemoveDirectoryA, _aPathName);
  4320             } while ((ret < 0) && (__threadErrno == EINTR));
  4340 	    } while ((ret < 0) && (__threadErrno == EINTR));
  4321         }
  4341 	}
  4322 #else
  4342 #else
  4323         ret = RemoveDirectoryA((char *)__stringVal(fullPathName));
  4343 	ret = RemoveDirectoryA((char *)__stringVal(fullPathName));
  4324         __threadErrno = __WIN32_ERR(GetLastError());
  4344 	__threadErrno = __WIN32_ERR(GetLastError());
  4325 #endif
  4345 #endif
  4326         if (ret != TRUE) {
  4346 	if (ret != TRUE) {
  4327             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4347 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4328             RETURN (false);
  4348 	    RETURN (false);
  4329         }
  4349 	}
  4330         RETURN (true);
  4350 	RETURN (true);
  4331     }
  4351     }
  4332     if (__isUnicode16String(fullPathName)) {
  4352     if (__isUnicode16String(fullPathName)) {
  4333 #ifdef DO_WRAP_CALLS
  4353 #ifdef DO_WRAP_CALLS
  4334         {
  4354 	{
  4335             wchar_t _wPathName[MAXPATHLEN+1];
  4355 	    wchar_t _wPathName[MAXPATHLEN+1];
  4336             int i, l;
  4356 	    int i, l;
  4337 
  4357 
  4338             l = __unicode16StringSize(fullPathName);
  4358 	    l = __unicode16StringSize(fullPathName);
  4339             if (l > MAXPATHLEN) l = MAXPATHLEN;
  4359 	    if (l > MAXPATHLEN) l = MAXPATHLEN;
  4340             for (i=0; i<l; i++) {
  4360 	    for (i=0; i<l; i++) {
  4341                 _wPathName[i] = __unicode16StringVal(fullPathName)[i];
  4361 		_wPathName[i] = __unicode16StringVal(fullPathName)[i];
  4342             }
  4362 	    }
  4343             _wPathName[i] = 0;
  4363 	    _wPathName[i] = 0;
  4344             do {
  4364 	    do {
  4345                 __threadErrno = 0;
  4365 		__threadErrno = 0;
  4346                 ret = STX_API_NOINT_CALL1( "RemoveDirectoryW", RemoveDirectoryW, _wPathName);
  4366 		ret = STX_API_NOINT_CALL1( "RemoveDirectoryW", RemoveDirectoryW, _wPathName);
  4347             } while ((ret < 0) && (__threadErrno == EINTR));
  4367 	    } while ((ret < 0) && (__threadErrno == EINTR));
  4348         }
  4368 	}
  4349 #else
  4369 #else
  4350         ret = RemoveDirectoryW((char *)__stringVal(fullPathName));
  4370 	ret = RemoveDirectoryW((char *)__stringVal(fullPathName));
  4351         __threadErrno = __WIN32_ERR(GetLastError());
  4371 	__threadErrno = __WIN32_ERR(GetLastError());
  4352 #endif
  4372 #endif
  4353         if (ret != TRUE) {
  4373 	if (ret != TRUE) {
  4354             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4374 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4355             RETURN (false);
  4375 	    RETURN (false);
  4356         }
  4376 	}
  4357         RETURN (true);
  4377 	RETURN (true);
  4358     }
  4378     }
  4359 %}.
  4379 %}.
  4360     "/
  4380     "/
  4361     "/ either not a string argument,
  4381     "/ either not a string argument,
  4362     "/ or not supported by OS
  4382     "/ or not supported by OS
  4376 %{
  4396 %{
  4377     int ret;
  4397     int ret;
  4378 
  4398 
  4379     if (__isStringLike(fullPathName)) {
  4399     if (__isStringLike(fullPathName)) {
  4380 #ifdef DO_WRAP_CALLS
  4400 #ifdef DO_WRAP_CALLS
  4381         {
  4401 	{
  4382             char _aPathName[MAXPATHLEN];
  4402 	    char _aPathName[MAXPATHLEN];
  4383 
  4403 
  4384             strncpy(_aPathName, __stringVal(fullPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4404 	    strncpy(_aPathName, __stringVal(fullPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4385             do {
  4405 	    do {
  4386                 __threadErrno = 0;
  4406 		__threadErrno = 0;
  4387                 ret = STX_API_NOINT_CALL1( "DeleteFileA", DeleteFileA, _aPathName);
  4407 		ret = STX_API_NOINT_CALL1( "DeleteFileA", DeleteFileA, _aPathName);
  4388             } while ((ret < 0) && (__threadErrno == EINTR));
  4408 	    } while ((ret < 0) && (__threadErrno == EINTR));
  4389         }
  4409 	}
  4390 #else
  4410 #else
  4391         ret = DeleteFileA((char *)__stringVal(fullPathName));
  4411 	ret = DeleteFileA((char *)__stringVal(fullPathName));
  4392         __threadErrno = __WIN32_ERR(GetLastError());
  4412 	__threadErrno = __WIN32_ERR(GetLastError());
  4393 #endif
  4413 #endif
  4394         if (ret != TRUE) {
  4414 	if (ret != TRUE) {
  4395             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4415 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4396             RETURN (false);
  4416 	    RETURN (false);
  4397         }
  4417 	}
  4398         RETURN (true);
  4418 	RETURN (true);
  4399     }
  4419     }
  4400     if (__isUnicode16String(fullPathName)) {
  4420     if (__isUnicode16String(fullPathName)) {
  4401 #ifdef DO_WRAP_CALLS
  4421 #ifdef DO_WRAP_CALLS
  4402         {
  4422 	{
  4403             wchar_t _wPathName[MAXPATHLEN+1];
  4423 	    wchar_t _wPathName[MAXPATHLEN+1];
  4404             int i, l;
  4424 	    int i, l;
  4405 
  4425 
  4406             l = __unicode16StringSize(fullPathName);
  4426 	    l = __unicode16StringSize(fullPathName);
  4407             if (l > MAXPATHLEN) l = MAXPATHLEN;
  4427 	    if (l > MAXPATHLEN) l = MAXPATHLEN;
  4408             for (i=0; i<l; i++) {
  4428 	    for (i=0; i<l; i++) {
  4409                 _wPathName[i] = __unicode16StringVal(fullPathName)[i];
  4429 		_wPathName[i] = __unicode16StringVal(fullPathName)[i];
  4410             }
  4430 	    }
  4411             _wPathName[i] = 0;
  4431 	    _wPathName[i] = 0;
  4412             do {
  4432 	    do {
  4413                 __threadErrno = 0;
  4433 		__threadErrno = 0;
  4414                 ret = STX_API_NOINT_CALL1( "DeleteFileW", DeleteFileW, _wPathName);
  4434 		ret = STX_API_NOINT_CALL1( "DeleteFileW", DeleteFileW, _wPathName);
  4415             } while ((ret < 0) && (__threadErrno == EINTR));
  4435 	    } while ((ret < 0) && (__threadErrno == EINTR));
  4416         }
  4436 	}
  4417 #else
  4437 #else
  4418         ret = DeleteFileW((char *)__stringVal(fullPathName));
  4438 	ret = DeleteFileW((char *)__stringVal(fullPathName));
  4419         __threadErrno = __WIN32_ERR(GetLastError());
  4439 	__threadErrno = __WIN32_ERR(GetLastError());
  4420 #endif
  4440 #endif
  4421         if (ret != TRUE) {
  4441 	if (ret != TRUE) {
  4422             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4442 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4423             RETURN (false);
  4443 	    RETURN (false);
  4424         }
  4444 	}
  4425         RETURN (true);
  4445 	RETURN (true);
  4426     }
  4446     }
  4427 
  4447 
  4428 %}.
  4448 %}.
  4429     ^ self primitiveFailed
  4449     ^ self primitiveFailed
  4430 !
  4450 !
  4440 %{
  4460 %{
  4441     int ret, eno;
  4461     int ret, eno;
  4442 
  4462 
  4443     if (__isStringLike(oldPath) && __isStringLike(newPath)) {
  4463     if (__isStringLike(oldPath) && __isStringLike(newPath)) {
  4444 #ifdef DO_WRAP_CALLS
  4464 #ifdef DO_WRAP_CALLS
  4445         char _oldPath[MAXPATHLEN], _newPath[MAXPATHLEN];
  4465 	char _oldPath[MAXPATHLEN], _newPath[MAXPATHLEN];
  4446 
  4466 
  4447         strncpy(_oldPath, __stringVal(oldPath), MAXPATHLEN-1); _oldPath[MAXPATHLEN-1] = '\0';
  4467 	strncpy(_oldPath, __stringVal(oldPath), MAXPATHLEN-1); _oldPath[MAXPATHLEN-1] = '\0';
  4448         strncpy(_newPath, __stringVal(newPath), MAXPATHLEN-1); _newPath[MAXPATHLEN-1] = '\0';
  4468 	strncpy(_newPath, __stringVal(newPath), MAXPATHLEN-1); _newPath[MAXPATHLEN-1] = '\0';
  4449 
  4469 
  4450         do {
  4470 	do {
  4451             __threadErrno = 0;
  4471 	    __threadErrno = 0;
  4452             ret = STX_C_NOINT_CALL2( "rename", rename, _oldPath, _newPath);
  4472 	    ret = STX_C_NOINT_CALL2( "rename", rename, _oldPath, _newPath);
  4453         } while ((ret < 0) && (__threadErrno == EINTR));
  4473 	} while ((ret < 0) && (__threadErrno == EINTR));
  4454 #else
  4474 #else
  4455         __BEGIN_INTERRUPTABLE__
  4475 	__BEGIN_INTERRUPTABLE__
  4456         do {
  4476 	do {
  4457             __threadErrno = 0;
  4477 	    __threadErrno = 0;
  4458             ret = rename((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
  4478 	    ret = rename((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
  4459         } while ((ret < 0) && (__threadErrno == EINTR));
  4479 	} while ((ret < 0) && (__threadErrno == EINTR));
  4460         __END_INTERRUPTABLE__
  4480 	__END_INTERRUPTABLE__
  4461 
  4481 
  4462         if (ret < 0) {
  4482 	if (ret < 0) {
  4463             __threadErrno = __WIN32_ERR(GetLastError());
  4483 	    __threadErrno = __WIN32_ERR(GetLastError());
  4464         }
  4484 	}
  4465 #endif
  4485 #endif
  4466         if (ret < 0) {
  4486 	if (ret < 0) {
  4467             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4487 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4468             RETURN (false);
  4488 	    RETURN (false);
  4469         }
  4489 	}
  4470         RETURN (true);
  4490 	RETURN (true);
  4471     }
  4491     }
  4472 %}.
  4492 %}.
  4473     ^ self primitiveFailed
  4493     ^ self primitiveFailed
  4474 
  4494 
  4475     "
  4495     "
  4524 #   ifndef S_IXOTH
  4544 #   ifndef S_IXOTH
  4525 #    define S_IXOTH 0001
  4545 #    define S_IXOTH 0001
  4526 #   endif
  4546 #   endif
  4527 
  4547 
  4528     if (aSymbol == @symbol(readUser)) {
  4548     if (aSymbol == @symbol(readUser)) {
  4529         RETURN ( __mkSmallInteger(S_IRUSR) );
  4549 	RETURN ( __mkSmallInteger(S_IRUSR) );
  4530     }
  4550     }
  4531     if (aSymbol == @symbol(writeUser)) {
  4551     if (aSymbol == @symbol(writeUser)) {
  4532         RETURN ( __mkSmallInteger(S_IWUSR) );
  4552 	RETURN ( __mkSmallInteger(S_IWUSR) );
  4533     }
  4553     }
  4534     if (aSymbol == @symbol(executeUser)) {
  4554     if (aSymbol == @symbol(executeUser)) {
  4535         RETURN ( __mkSmallInteger(S_IXUSR) );
  4555 	RETURN ( __mkSmallInteger(S_IXUSR) );
  4536     }
  4556     }
  4537     if (aSymbol == @symbol(readGroup)) {
  4557     if (aSymbol == @symbol(readGroup)) {
  4538         RETURN ( __mkSmallInteger(S_IRGRP) );
  4558 	RETURN ( __mkSmallInteger(S_IRGRP) );
  4539     }
  4559     }
  4540     if (aSymbol == @symbol(writeGroup)) {
  4560     if (aSymbol == @symbol(writeGroup)) {
  4541         RETURN ( __mkSmallInteger(S_IWGRP) );
  4561 	RETURN ( __mkSmallInteger(S_IWGRP) );
  4542     }
  4562     }
  4543     if (aSymbol == @symbol(executeGroup)) {
  4563     if (aSymbol == @symbol(executeGroup)) {
  4544         RETURN ( __mkSmallInteger(S_IXGRP) );
  4564 	RETURN ( __mkSmallInteger(S_IXGRP) );
  4545     }
  4565     }
  4546     if (aSymbol == @symbol(readOthers)) {
  4566     if (aSymbol == @symbol(readOthers)) {
  4547         RETURN ( __mkSmallInteger(S_IROTH) );
  4567 	RETURN ( __mkSmallInteger(S_IROTH) );
  4548     }
  4568     }
  4549     if (aSymbol == @symbol(writeOthers)) {
  4569     if (aSymbol == @symbol(writeOthers)) {
  4550         RETURN ( __mkSmallInteger(S_IWOTH) );
  4570 	RETURN ( __mkSmallInteger(S_IWOTH) );
  4551     }
  4571     }
  4552     if (aSymbol == @symbol(executeOthers)) {
  4572     if (aSymbol == @symbol(executeOthers)) {
  4553         RETURN ( __mkSmallInteger(S_IXOTH) );
  4573 	RETURN ( __mkSmallInteger(S_IXOTH) );
  4554     }
  4574     }
  4555 
  4575 
  4556     // These are not defined for Win32 - simply ignore them
  4576     // These are not defined for Win32 - simply ignore them
  4557     // (but handle them for UNIX compatibility
  4577     // (but handle them for UNIX compatibility
  4558     if (aSymbol == @symbol(setUid)) {
  4578     if (aSymbol == @symbol(setUid)) {
  4559         RETURN ( __mkSmallInteger(0) );
  4579 	RETURN ( __mkSmallInteger(0) );
  4560     }
  4580     }
  4561     if (aSymbol == @symbol(setGid)) {
  4581     if (aSymbol == @symbol(setGid)) {
  4562         RETURN ( __mkSmallInteger(0) );
  4582 	RETURN ( __mkSmallInteger(0) );
  4563     }
  4583     }
  4564     if (aSymbol == @symbol(removeOnlyByOwner)) {
  4584     if (aSymbol == @symbol(removeOnlyByOwner)) {
  4565         RETURN ( __mkSmallInteger(0) );
  4585 	RETURN ( __mkSmallInteger(0) );
  4566     }
  4586     }
  4567 
  4587 
  4568 %}.
  4588 %}.
  4569     ^ self primitiveFailed
  4589     ^ self primitiveFailed
  4570 
  4590 
  4579      Notice that the returned number is OS dependent - use the
  4599      Notice that the returned number is OS dependent - use the
  4580      modeMasks as returned by OperatingSystem>>accessMaskFor:"
  4600      modeMasks as returned by OperatingSystem>>accessMaskFor:"
  4581 
  4601 
  4582     "
  4602     "
  4583      this could have been implemented as:
  4603      this could have been implemented as:
  4584         (self infoOf:aPathName) at:#mode
  4604 	(self infoOf:aPathName) at:#mode
  4585      but for huge directory searches the code below is faster
  4605      but for huge directory searches the code below is faster
  4586     "
  4606     "
  4587 
  4607 
  4588 %{
  4608 %{
  4589     struct stat buf;
  4609     struct stat buf;
  4590     int ret;
  4610     int ret;
  4591 
  4611 
  4592     if (__isStringLike(aPathName)) {
  4612     if (__isStringLike(aPathName)) {
  4593 #ifdef DO_WRAP_CALLS
  4613 #ifdef DO_WRAP_CALLS
  4594         char _aPathName[MAXPATHLEN];
  4614 	char _aPathName[MAXPATHLEN];
  4595 
  4615 
  4596         strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4616 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4597 
  4617 
  4598         do {
  4618 	do {
  4599             __threadErrno = 0;
  4619 	    __threadErrno = 0;
  4600             ret = STX_C_NOINT_CALL2( "stat", stat, _aPathName, &buf);
  4620 	    ret = STX_C_NOINT_CALL2( "stat", stat, _aPathName, &buf);
  4601         } while ((ret < 0) && (__threadErrno == EINTR));
  4621 	} while ((ret < 0) && (__threadErrno == EINTR));
  4602 #else
  4622 #else
  4603         __BEGIN_INTERRUPTABLE__
  4623 	__BEGIN_INTERRUPTABLE__
  4604         do {
  4624 	do {
  4605             __threadErrno = 0;
  4625 	    __threadErrno = 0;
  4606             ret = stat( (char *)__stringVal(aPathName), &buf);
  4626 	    ret = stat( (char *)__stringVal(aPathName), &buf);
  4607         } while ((ret < 0) && (__threadErrno == EINTR));
  4627 	} while ((ret < 0) && (__threadErrno == EINTR));
  4608         __END_INTERRUPTABLE__
  4628 	__END_INTERRUPTABLE__
  4609         if (ret < 0) {
  4629 	if (ret < 0) {
  4610             __threadErrno = __WIN32_ERR(GetLastError());
  4630 	    __threadErrno = __WIN32_ERR(GetLastError());
  4611         }
  4631 	}
  4612 #endif
  4632 #endif
  4613 
  4633 
  4614         if (ret < 0) {
  4634 	if (ret < 0) {
  4615             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4635 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4616             RETURN ( nil );
  4636 	    RETURN ( nil );
  4617         }
  4637 	}
  4618         RETURN ( __mkSmallInteger(buf.st_mode & 0777) );
  4638 	RETURN ( __mkSmallInteger(buf.st_mode & 0777) );
  4619     }
  4639     }
  4620 %}.
  4640 %}.
  4621    ^ self primitiveFailed
  4641    ^ self primitiveFailed
  4622 
  4642 
  4623    "
  4643    "
  4636 %{
  4656 %{
  4637     int ret;
  4657     int ret;
  4638 
  4658 
  4639     if (__isStringLike(aPathName) && __isSmallInteger(modeBits)) {
  4659     if (__isStringLike(aPathName) && __isSmallInteger(modeBits)) {
  4640 #ifdef DO_WRAP_CALLS
  4660 #ifdef DO_WRAP_CALLS
  4641         int chmod();
  4661 	int chmod();
  4642         char _aPathName[MAXPATHLEN];
  4662 	char _aPathName[MAXPATHLEN];
  4643 
  4663 
  4644         strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4664 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4645         do {
  4665 	do {
  4646             __threadErrno = 0;
  4666 	    __threadErrno = 0;
  4647             ret = STX_C_NOINT_CALL2( "chmod", chmod, _aPathName, __intVal(modeBits));
  4667 	    ret = STX_C_NOINT_CALL2( "chmod", chmod, _aPathName, __intVal(modeBits));
  4648         } while ((ret < 0) && (__threadErrno == EINTR));
  4668 	} while ((ret < 0) && (__threadErrno == EINTR));
  4649 #else
  4669 #else
  4650         __BEGIN_INTERRUPTABLE__
  4670 	__BEGIN_INTERRUPTABLE__
  4651         do {
  4671 	do {
  4652             __threadErrno = 0;
  4672 	    __threadErrno = 0;
  4653             ret = chmod((char *)__stringVal(aPathName), __intVal(modeBits));
  4673 	    ret = chmod((char *)__stringVal(aPathName), __intVal(modeBits));
  4654         } while ((ret < 0) && (__threadErrno == EINTR));
  4674 	} while ((ret < 0) && (__threadErrno == EINTR));
  4655         __END_INTERRUPTABLE__
  4675 	__END_INTERRUPTABLE__
  4656         if (ret < 0) {
  4676 	if (ret < 0) {
  4657             __threadErrno = __WIN32_ERR(GetLastError());
  4677 	    __threadErrno = __WIN32_ERR(GetLastError());
  4658         }
  4678 	}
  4659 #endif
  4679 #endif
  4660         if (ret < 0) {
  4680 	if (ret < 0) {
  4661             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4681 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4662             RETURN ( false );
  4682 	    RETURN ( false );
  4663         }
  4683 	}
  4664         RETURN ( true );
  4684 	RETURN ( true );
  4665     }
  4685     }
  4666 %}.
  4686 %}.
  4667     ^ self primitiveFailed
  4687     ^ self primitiveFailed
  4668 
  4688 
  4669    "
  4689    "
  4693 
  4713 
  4694     __address = __intVal(openFilenameStructureExternalAddress);
  4714     __address = __intVal(openFilenameStructureExternalAddress);
  4695     __rslt = __STX_API_CALL1( "GetOpenFileName", (void *)GetOpenFileName, (void *)(__address));
  4715     __rslt = __STX_API_CALL1( "GetOpenFileName", (void *)GetOpenFileName, (void *)(__address));
  4696 
  4716 
  4697     if (__rslt == TRUE) {
  4717     if (__rslt == TRUE) {
  4698         rslt = true;
  4718 	rslt = true;
  4699     } else {
  4719     } else {
  4700         rslt = false;
  4720 	rslt = false;
  4701     }
  4721     }
  4702 %}.
  4722 %}.
  4703     ^ rslt
  4723     ^ rslt
  4704 !
  4724 !
  4705 
  4725 
  4717 
  4737 
  4718     __address = __intVal(openFilenameStructureExternalAddress);
  4738     __address = __intVal(openFilenameStructureExternalAddress);
  4719     __rslt = __STX_API_CALL1( "GetSaveFileName", (void *)GetSaveFileName, (void *)(__address));
  4739     __rslt = __STX_API_CALL1( "GetSaveFileName", (void *)GetSaveFileName, (void *)(__address));
  4720 
  4740 
  4721     if (__rslt == TRUE) {
  4741     if (__rslt == TRUE) {
  4722         rslt = true;
  4742 	rslt = true;
  4723     } else {
  4743     } else {
  4724         rslt = false;
  4744 	rslt = false;
  4725     }
  4745     }
  4726 %}.
  4746 %}.
  4727     ^ rslt
  4747     ^ rslt
  4728 ! !
  4748 ! !
  4729 
  4749 
  4742 
  4762 
  4743     |attr|
  4763     |attr|
  4744 
  4764 
  4745     attr := self primGetFileAttributes:aPathName.
  4765     attr := self primGetFileAttributes:aPathName.
  4746     (attr bitTest:FILE_ATTRIBUTE_HIDDEN ) ifTrue:[
  4766     (attr bitTest:FILE_ATTRIBUTE_HIDDEN ) ifTrue:[
  4747         ^ self primSetFileAttributes:aPathName to:(attr bitClear:2).
  4767 	^ self primSetFileAttributes:aPathName to:(attr bitClear:2).
  4748     ].
  4768     ].
  4749     ^ true
  4769     ^ true
  4750 
  4770 
  4751     "Created: / 29-07-2010 / 11:31:55 / sr"
  4771     "Created: / 29-07-2010 / 11:31:55 / sr"
  4752 !
  4772 !
  4758      if realPath and popen failed."
  4778      if realPath and popen failed."
  4759 
  4779 
  4760     |names n "{ Class: SmallInteger }" |
  4780     |names n "{ Class: SmallInteger }" |
  4761 
  4781 
  4762     names := pathName
  4782     names := pathName
  4763                 asCollectionOfSubstringsSeparatedBy:self fileSeparator.
  4783 		asCollectionOfSubstringsSeparatedBy:self fileSeparator.
  4764     names := names asOrderedCollection.
  4784     names := names asOrderedCollection.
  4765     "
  4785     "
  4766      cut off initial double-slashes
  4786      cut off initial double-slashes
  4767     "
  4787     "
  4768     [names startsWith:#('' '')] whileTrue:[
  4788     [names startsWith:#('' '')] whileTrue:[
  4769         names removeFirst.
  4789 	names removeFirst.
  4770     ].
  4790     ].
  4771     "
  4791     "
  4772      cut off double-slashes at end
  4792      cut off double-slashes at end
  4773     "
  4793     "
  4774     [names endsWith:#('')] whileTrue:[
  4794     [names endsWith:#('')] whileTrue:[
  4775         names removeLast.
  4795 	names removeLast.
  4776     ].
  4796     ].
  4777     "
  4797     "
  4778      cut off current-dir at beginning
  4798      cut off current-dir at beginning
  4779     "
  4799     "
  4780     n := names size.
  4800     n := names size.
  4781     [(n >= 2) and:[names startsWith:#('.')]] whileTrue:[
  4801     [(n >= 2) and:[names startsWith:#('.')]] whileTrue:[
  4782         names removeFirst.
  4802 	names removeFirst.
  4783         n := n - 1.
  4803 	n := n - 1.
  4784     ].
  4804     ].
  4785 
  4805 
  4786     "
  4806     "
  4787      cut off parent-dirs at end
  4807      cut off parent-dirs at end
  4788     "
  4808     "
  4789     [(n > 2)
  4809     [(n > 2)
  4790      and:[(names endsWith:#('..'))
  4810      and:[(names endsWith:#('..'))
  4791      and:[((names at:(n - 1)) startsWith:'.') not ]]] whileTrue:[
  4811      and:[((names at:(n - 1)) startsWith:'.') not ]]] whileTrue:[
  4792         names removeLast; removeLast.
  4812 	names removeLast; removeLast.
  4793         n := n - 2.
  4813 	n := n - 2.
  4794     ].
  4814     ].
  4795 
  4815 
  4796     ^ names asStringWith:self fileSeparator
  4816     ^ names asStringWith:self fileSeparator
  4797                     from:1
  4817 		    from:1
  4798                     to:n
  4818 		    to:n
  4799                     compressTabs:false final:nil
  4819 		    compressTabs:false final:nil
  4800 
  4820 
  4801     "
  4821     "
  4802      OperatingSystem compressPath:'.\..'
  4822      OperatingSystem compressPath:'.\..'
  4803      OperatingSystem compressPath:'\foo\bar\baz\..'
  4823      OperatingSystem compressPath:'\foo\bar\baz\..'
  4804      OperatingSystem compressPath:'foo\bar\baz\..'
  4824      OperatingSystem compressPath:'foo\bar\baz\..'
  4832     "
  4852     "
  4833 !
  4853 !
  4834 
  4854 
  4835 getDiskInfoOf:volumeNameArg
  4855 getDiskInfoOf:volumeNameArg
  4836     "returns a dictionary filled with any of:
  4856     "returns a dictionary filled with any of:
  4837         freeBytes
  4857 	freeBytes
  4838         totalBytes
  4858 	totalBytes
  4839      and possibly additional (OS-specific) information"
  4859      and possibly additional (OS-specific) information"
  4840 
  4860 
  4841     |volumeName info ok sectorsPerCluster bytesPerSector freeClusters totalClusters
  4861     |volumeName info ok sectorsPerCluster bytesPerSector freeClusters totalClusters
  4842      type freeBytesForUsersQuota freeBytes totalBytes |
  4862      type freeBytesForUsersQuota freeBytes totalBytes |
  4843 
  4863 
  4844     volumeName := volumeNameArg.
  4864     volumeName := volumeNameArg.
  4845     (volumeName endsWith:$\) ifFalse:[
  4865     (volumeName endsWith:$\) ifFalse:[
  4846         volumeName := volumeName , '\'
  4866 	volumeName := volumeName , '\'
  4847     ].
  4867     ].
  4848 %{
  4868 %{
  4849     typedef BOOL (WINAPI *P_GDFSE)(LPCTSTR, PULARGE_INTEGER,
  4869     typedef BOOL (WINAPI *P_GDFSE)(LPCTSTR, PULARGE_INTEGER,
  4850                                    PULARGE_INTEGER, PULARGE_INTEGER);
  4870 				   PULARGE_INTEGER, PULARGE_INTEGER);
  4851     P_GDFSE pGetDiskFreeSpaceEx = NULL;
  4871     P_GDFSE pGetDiskFreeSpaceEx = NULL;
  4852 
  4872 
  4853     DWORD __sectorsPerCluster, __bytesPerSector, __freeClusters, __totalClusters;
  4873     DWORD __sectorsPerCluster, __bytesPerSector, __freeClusters, __totalClusters;
  4854     BOOL  fResult = 0;
  4874     BOOL  fResult = 0;
  4855     unsigned __int64 i64FreeBytesForUsersQuota, i64TotalBytes, i64FreeBytes;
  4875     unsigned __int64 i64FreeBytesForUsersQuota, i64TotalBytes, i64FreeBytes;
  4856 
  4876 
  4857     if (__isStringLike(volumeName) || __isSymbol(volumeName)) {
  4877     if (__isStringLike(volumeName) || __isSymbol(volumeName)) {
  4858          /*
  4878 	 /*
  4859           *  Use GetDiskFreeSpaceEx if available; otherwise, use GetDiskFreeSpace.
  4879 	  *  Use GetDiskFreeSpaceEx if available; otherwise, use GetDiskFreeSpace.
  4860           *  Notice that GetDiskFreeSpace does not work correctly under win2k,
  4880 	  *  Notice that GetDiskFreeSpace does not work correctly under win2k,
  4861           *  and GetDiskFreeSpaceEx is not avail. for all win versions (can microsoft ever do something right ?).
  4881 	  *  and GetDiskFreeSpaceEx is not avail. for all win versions (can microsoft ever do something right ?).
  4862           */
  4882 	  */
  4863         pGetDiskFreeSpaceEx = (P_GDFSE)GetProcAddress (
  4883 	pGetDiskFreeSpaceEx = (P_GDFSE)GetProcAddress (
  4864                                             GetModuleHandle ("kernel32.dll"),
  4884 					    GetModuleHandle ("kernel32.dll"),
  4865                                                              "GetDiskFreeSpaceExA");
  4885 							     "GetDiskFreeSpaceExA");
  4866         if (pGetDiskFreeSpaceEx) {
  4886 	if (pGetDiskFreeSpaceEx) {
  4867             fResult = pGetDiskFreeSpaceEx (__stringVal(volumeName),
  4887 	    fResult = pGetDiskFreeSpaceEx (__stringVal(volumeName),
  4868                                  (PULARGE_INTEGER)&i64FreeBytesForUsersQuota,
  4888 				 (PULARGE_INTEGER)&i64FreeBytesForUsersQuota,
  4869                                  (PULARGE_INTEGER)&i64TotalBytes,
  4889 				 (PULARGE_INTEGER)&i64TotalBytes,
  4870                                  (PULARGE_INTEGER)&i64FreeBytes);
  4890 				 (PULARGE_INTEGER)&i64FreeBytes);
  4871             if (fResult) {
  4891 	    if (fResult) {
  4872                 freeBytesForUsersQuota = __MKUINT64(&i64FreeBytesForUsersQuota);
  4892 		freeBytesForUsersQuota = __MKUINT64(&i64FreeBytesForUsersQuota);
  4873                 totalBytes = __MKUINT64(&i64TotalBytes);
  4893 		totalBytes = __MKUINT64(&i64TotalBytes);
  4874                 freeBytes = __MKUINT64(&i64FreeBytes);
  4894 		freeBytes = __MKUINT64(&i64FreeBytes);
  4875             }
  4895 	    }
  4876         }
  4896 	}
  4877         fResult = GetDiskFreeSpace(__stringVal(volumeName),
  4897 	fResult = GetDiskFreeSpace(__stringVal(volumeName),
  4878                              &__sectorsPerCluster,
  4898 			     &__sectorsPerCluster,
  4879                              &__bytesPerSector,
  4899 			     &__bytesPerSector,
  4880                              &__freeClusters,
  4900 			     &__freeClusters,
  4881                              &__totalClusters);
  4901 			     &__totalClusters);
  4882         if (fResult) {
  4902 	if (fResult) {
  4883             sectorsPerCluster = __MKUINT(__sectorsPerCluster);
  4903 	    sectorsPerCluster = __MKUINT(__sectorsPerCluster);
  4884             bytesPerSector = __MKUINT(__bytesPerSector);
  4904 	    bytesPerSector = __MKUINT(__bytesPerSector);
  4885             freeClusters = __MKUINT(__freeClusters);
  4905 	    freeClusters = __MKUINT(__freeClusters);
  4886             totalClusters = __MKUINT(__totalClusters);
  4906 	    totalClusters = __MKUINT(__totalClusters);
  4887         }
  4907 	}
  4888         switch (GetDriveType(__stringVal(volumeName))) {
  4908 	switch (GetDriveType(__stringVal(volumeName))) {
  4889             case DRIVE_REMOVABLE:
  4909 	    case DRIVE_REMOVABLE:
  4890                 type = @symbol(removable); break;
  4910 		type = @symbol(removable); break;
  4891             case DRIVE_FIXED:
  4911 	    case DRIVE_FIXED:
  4892                 type = @symbol(fixed); break;
  4912 		type = @symbol(fixed); break;
  4893             case DRIVE_REMOTE:
  4913 	    case DRIVE_REMOTE:
  4894                 type = @symbol(network); break;
  4914 		type = @symbol(network); break;
  4895             case DRIVE_CDROM:
  4915 	    case DRIVE_CDROM:
  4896                 type = @symbol(cdrom); break;
  4916 		type = @symbol(cdrom); break;
  4897             case DRIVE_RAMDISK:
  4917 	    case DRIVE_RAMDISK:
  4898                 type = @symbol(ramdisk); break;
  4918 		type = @symbol(ramdisk); break;
  4899             case DRIVE_UNKNOWN:
  4919 	    case DRIVE_UNKNOWN:
  4900             default:
  4920 	    default:
  4901                 break;
  4921 		break;
  4902         }
  4922 	}
  4903         if (fResult) {
  4923 	if (fResult) {
  4904             ok = true;
  4924 	    ok = true;
  4905         } else {
  4925 	} else {
  4906             __threadErrno = __WIN32_ERR(GetLastError());
  4926 	    __threadErrno = __WIN32_ERR(GetLastError());
  4907             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4927 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4908         }
  4928 	}
  4909     }
  4929     }
  4910 %}.
  4930 %}.
  4911     ok == true ifFalse:[
  4931     ok == true ifFalse:[
  4912         self primitiveFailed.
  4932 	self primitiveFailed.
  4913         ^ self
  4933 	^ self
  4914     ].
  4934     ].
  4915 
  4935 
  4916     info := IdentityDictionary new.
  4936     info := IdentityDictionary new.
  4917     info at:#sectorsPerCluster put:sectorsPerCluster.
  4937     info at:#sectorsPerCluster put:sectorsPerCluster.
  4918     info at:#bytesPerSector put:bytesPerSector.
  4938     info at:#bytesPerSector put:bytesPerSector.
  4919     info at:#freeClusters put:freeClusters.
  4939     info at:#freeClusters put:freeClusters.
  4920     info at:#totalClusters put:totalClusters.
  4940     info at:#totalClusters put:totalClusters.
  4921 
  4941 
  4922     info at:#freeBytes put:(freeBytes notNil
  4942     info at:#freeBytes put:(freeBytes notNil
  4923                                 ifTrue:[freeBytes]
  4943 				ifTrue:[freeBytes]
  4924                                 ifFalse:[freeClusters * sectorsPerCluster * bytesPerSector]).
  4944 				ifFalse:[freeClusters * sectorsPerCluster * bytesPerSector]).
  4925     info at:#totalBytes put:(totalBytes notNil
  4945     info at:#totalBytes put:(totalBytes notNil
  4926                                 ifTrue:[totalBytes]
  4946 				ifTrue:[totalBytes]
  4927                                 ifFalse:[totalClusters * sectorsPerCluster * bytesPerSector]).
  4947 				ifFalse:[totalClusters * sectorsPerCluster * bytesPerSector]).
  4928     info at:#freeBytesForUsersQuota put:freeBytesForUsersQuota.
  4948     info at:#freeBytesForUsersQuota put:freeBytesForUsersQuota.
  4929     type notNil ifTrue:[
  4949     type notNil ifTrue:[
  4930         info at:#type put:type
  4950 	info at:#type put:type
  4931     ].
  4951     ].
  4932     ^ info
  4952     ^ info
  4933 
  4953 
  4934     "
  4954     "
  4935      self getDiskInfoOf:'c:\'
  4955      self getDiskInfoOf:'c:\'
  4967     ^ list
  4987     ^ list
  4968 !
  4988 !
  4969 
  4989 
  4970 getDriveType:aPathName
  4990 getDriveType:aPathName
  4971     "returns:
  4991     "returns:
  4972         0 -> Unknown
  4992 	0 -> Unknown
  4973         1 -> Invalid
  4993 	1 -> Invalid
  4974         2 -> removable
  4994 	2 -> removable
  4975         3 -> fixed
  4995 	3 -> fixed
  4976         4 -> remote
  4996 	4 -> remote
  4977         5 -> cdrom
  4997 	5 -> cdrom
  4978         6 -> ramdisk.
  4998 	6 -> ramdisk.
  4979     This is a stupid interface - do not use."
  4999     This is a stupid interface - do not use."
  4980 
  5000 
  4981 %{
  5001 %{
  4982     int ret;
  5002     int ret;
  4983 
  5003 
  4984     if (__isStringLike(aPathName)) {
  5004     if (__isStringLike(aPathName)) {
  4985 #ifdef DO_WRAP_CALLS
  5005 #ifdef DO_WRAP_CALLS
  4986         char _aPathName[MAXPATHLEN];
  5006 	char _aPathName[MAXPATHLEN];
  4987 
  5007 
  4988         strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  5008 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4989         do {
  5009 	do {
  4990             __threadErrno = 0;
  5010 	    __threadErrno = 0;
  4991             ret = STX_API_NOINT_CALL1( "GetDriveType", GetDriveType, _aPathName);
  5011 	    ret = STX_API_NOINT_CALL1( "GetDriveType", GetDriveType, _aPathName);
  4992         } while ((ret < 0) && (__threadErrno == EINTR));
  5012 	} while ((ret < 0) && (__threadErrno == EINTR));
  4993 #else
  5013 #else
  4994         ret = GetDriveType((char *) __stringVal(aPathName));
  5014 	ret = GetDriveType((char *) __stringVal(aPathName));
  4995         if (ret < 0) {
  5015 	if (ret < 0) {
  4996             __threadErrno = __WIN32_ERR(GetLastError());
  5016 	    __threadErrno = __WIN32_ERR(GetLastError());
  4997         }
  5017 	}
  4998 #endif
  5018 #endif
  4999         RETURN (__MKSMALLINT(ret));
  5019 	RETURN (__MKSMALLINT(ret));
  5000     }
  5020     }
  5001 %}.
  5021 %}.
  5002     ^ self primitiveFailed
  5022     ^ self primitiveFailed
  5003 
  5023 
  5004     "
  5024     "
  5017 %{
  5037 %{
  5018     int sz;
  5038     int sz;
  5019     DWORD dummy;
  5039     DWORD dummy;
  5020 
  5040 
  5021     if (__isStringLike(aPathName)) {
  5041     if (__isStringLike(aPathName)) {
  5022         sz = GetFileVersionInfoSizeA(__stringVal(aPathName), &dummy);
  5042 	sz = GetFileVersionInfoSizeA(__stringVal(aPathName), &dummy);
  5023     } else if (__isUnicode16String(aPathName)) {
  5043     } else if (__isUnicode16String(aPathName)) {
  5024         sz = GetFileVersionInfoSizeW(__unicode16StringVal(aPathName), &dummy);
  5044 	sz = GetFileVersionInfoSizeW(__unicode16StringVal(aPathName), &dummy);
  5025     } else {
  5045     } else {
  5026         goto badArgument;
  5046 	goto badArgument;
  5027     }
  5047     }
  5028 
  5048 
  5029     if (sz > 0) {
  5049     if (sz > 0) {
  5030         OBJ versionData;
  5050 	OBJ versionData;
  5031 
  5051 
  5032         versionData = __BYTEARRAY_UNINITIALIZED_NEW_INT(sz);
  5052 	versionData = __BYTEARRAY_UNINITIALIZED_NEW_INT(sz);
  5033         if (versionData == nil) {
  5053 	if (versionData == nil) {
  5034             RETURN (nil);
  5054 	    RETURN (nil);
  5035         }
  5055 	}
  5036         if (GetFileVersionInfo(__stringVal(aPathName), 0, sz, __ByteArrayInstPtr(versionData)->ba_element) == FALSE) {
  5056 	if (GetFileVersionInfo(__stringVal(aPathName), 0, sz, __ByteArrayInstPtr(versionData)->ba_element) == FALSE) {
  5037             RETURN (nil);
  5057 	    RETURN (nil);
  5038         }
  5058 	}
  5039         RETURN (versionData);
  5059 	RETURN (versionData);
  5040     }
  5060     }
  5041     RETURN (nil);
  5061     RETURN (nil);
  5042 badArgument: ;
  5062 badArgument: ;
  5043 %}.
  5063 %}.
  5044     self primitiveFailed
  5064     self primitiveFailed
  5052 %{
  5072 %{
  5053     int ret;
  5073     int ret;
  5054     wchar_t _aPathName[MAX_PATH+1];
  5074     wchar_t _aPathName[MAX_PATH+1];
  5055 
  5075 
  5056     if (__isStringLike(aPathName)) {
  5076     if (__isStringLike(aPathName)) {
  5057         int i;
  5077 	int i;
  5058         int l = __stringSize(aPathName);
  5078 	int l = __stringSize(aPathName);
  5059         if (l > MAX_PATH) l = MAX_PATH;
  5079 	if (l > MAX_PATH) l = MAX_PATH;
  5060 
  5080 
  5061         for (i=0; i<l; i++) {
  5081 	for (i=0; i<l; i++) {
  5062             _aPathName[i] = __stringVal(aPathName)[i];
  5082 	    _aPathName[i] = __stringVal(aPathName)[i];
  5063         }
  5083 	}
  5064         _aPathName[i] = 0;
  5084 	_aPathName[i] = 0;
  5065     } else if (__isUnicode16String(aPathName)) {
  5085     } else if (__isUnicode16String(aPathName)) {
  5066         int i;
  5086 	int i;
  5067         int l = __unicode16StringSize(aPathName);
  5087 	int l = __unicode16StringSize(aPathName);
  5068         if (l > MAX_PATH) l = MAX_PATH;
  5088 	if (l > MAX_PATH) l = MAX_PATH;
  5069 
  5089 
  5070         for (i=0; i<l; i++) {
  5090 	for (i=0; i<l; i++) {
  5071             _aPathName[i] = __unicode16StringVal(aPathName)[i];
  5091 	    _aPathName[i] = __unicode16StringVal(aPathName)[i];
  5072         }
  5092 	}
  5073         _aPathName[i] = 0;
  5093 	_aPathName[i] = 0;
  5074     } else
  5094     } else
  5075         goto badArgument;
  5095 	goto badArgument;
  5076 
  5096 
  5077 #ifdef DO_WRAP_CALLS
  5097 #ifdef DO_WRAP_CALLS
  5078      do {
  5098      do {
  5079          __threadErrno = 0;
  5099 	 __threadErrno = 0;
  5080          ret = STX_API_NOINT_CALL3( "GetLongPathNameW", GetLongPathNameW, _aPathName, _aPathName, MAX_PATH+1);
  5100 	 ret = STX_API_NOINT_CALL3( "GetLongPathNameW", GetLongPathNameW, _aPathName, _aPathName, MAX_PATH+1);
  5081      } while ((ret == 0) && (__threadErrno == EINTR));
  5101      } while ((ret == 0) && (__threadErrno == EINTR));
  5082 #else
  5102 #else
  5083      ret = GetLongPathNameW(_aPathName, _aPathName, MAX_PATH+1);
  5103      ret = GetLongPathNameW(_aPathName, _aPathName, MAX_PATH+1);
  5084      if (ret == 0) {
  5104      if (ret == 0) {
  5085          __threadErrno = __WIN32_ERR(GetLastError());
  5105 	 __threadErrno = __WIN32_ERR(GetLastError());
  5086      }
  5106      }
  5087 #endif
  5107 #endif
  5088      RETURN ( __MKU16STRING(_aPathName));
  5108      RETURN ( __MKU16STRING(_aPathName));
  5089 
  5109 
  5090 badArgument:;
  5110 badArgument:;
  5110 %{
  5130 %{
  5111     int ret;
  5131     int ret;
  5112     wchar_t _aPathName[MAX_PATH+1];
  5132     wchar_t _aPathName[MAX_PATH+1];
  5113 
  5133 
  5114     if (__isStringLike(aPathName)) {
  5134     if (__isStringLike(aPathName)) {
  5115         int i;
  5135 	int i;
  5116         int l = __stringSize(aPathName);
  5136 	int l = __stringSize(aPathName);
  5117         if (l > MAX_PATH) l = MAX_PATH;
  5137 	if (l > MAX_PATH) l = MAX_PATH;
  5118 
  5138 
  5119         for (i=0; i<l; i++) {
  5139 	for (i=0; i<l; i++) {
  5120             _aPathName[i] = __stringVal(aPathName)[i];
  5140 	    _aPathName[i] = __stringVal(aPathName)[i];
  5121         }
  5141 	}
  5122         _aPathName[i] = 0;
  5142 	_aPathName[i] = 0;
  5123     } else if (__isUnicode16String(aPathName)) {
  5143     } else if (__isUnicode16String(aPathName)) {
  5124         int i;
  5144 	int i;
  5125         int l = __unicode16StringSize(aPathName);
  5145 	int l = __unicode16StringSize(aPathName);
  5126         if (l > MAX_PATH) l = MAX_PATH;
  5146 	if (l > MAX_PATH) l = MAX_PATH;
  5127 
  5147 
  5128         for (i=0; i<l; i++) {
  5148 	for (i=0; i<l; i++) {
  5129             _aPathName[i] = __unicode16StringVal(aPathName)[i];
  5149 	    _aPathName[i] = __unicode16StringVal(aPathName)[i];
  5130         }
  5150 	}
  5131         _aPathName[i] = 0;
  5151 	_aPathName[i] = 0;
  5132     } else
  5152     } else
  5133         goto badArgument;
  5153 	goto badArgument;
  5134 
  5154 
  5135 #ifdef DO_WRAP_CALLS
  5155 #ifdef DO_WRAP_CALLS
  5136      do {
  5156      do {
  5137          __threadErrno = 0;
  5157 	 __threadErrno = 0;
  5138          ret = STX_API_NOINT_CALL3( "GetShortPathNameW", GetShortPathNameW, _aPathName, _aPathName, MAX_PATH+1);
  5158 	 ret = STX_API_NOINT_CALL3( "GetShortPathNameW", GetShortPathNameW, _aPathName, _aPathName, MAX_PATH+1);
  5139      } while ((ret == 0) && (__threadErrno == EINTR));
  5159      } while ((ret == 0) && (__threadErrno == EINTR));
  5140 #else
  5160 #else
  5141      ret = GetShortPathNameW(_aPathName, _aPathName, MAX_PATH+1);
  5161      ret = GetShortPathNameW(_aPathName, _aPathName, MAX_PATH+1);
  5142      if (ret == 0) {
  5162      if (ret == 0) {
  5143          __threadErrno = __WIN32_ERR(GetLastError());
  5163 	 __threadErrno = __WIN32_ERR(GetLastError());
  5144      }
  5164      }
  5145 #endif
  5165 #endif
  5146      RETURN ( __MKU16STRING(_aPathName));
  5166      RETURN ( __MKU16STRING(_aPathName));
  5147 
  5167 
  5148 badArgument:;
  5168 badArgument:;
  5171 
  5191 
  5172 infoOf:aPathName
  5192 infoOf:aPathName
  5173     "return some object filled with info for the file 'aPathName';
  5193     "return some object filled with info for the file 'aPathName';
  5174      the info (for which corresponding access methods are understood by
  5194      the info (for which corresponding access methods are understood by
  5175      the returned object) is:
  5195      the returned object) is:
  5176          type            - a symbol giving the files type
  5196 	 type            - a symbol giving the files type
  5177          mode            - numeric access mode
  5197 	 mode            - numeric access mode
  5178          uid             - owners user id
  5198 	 uid             - owners user id
  5179          gid             - owners group id
  5199 	 gid             - owners group id
  5180          size            - files size
  5200 	 size            - files size
  5181          id              - files number (i.e. inode number)
  5201 	 id              - files number (i.e. inode number)
  5182          accessed        - last access time (as Timestamp)
  5202 	 accessed        - last access time (as Timestamp)
  5183          modified        - last modification time (as Timestamp)
  5203 	 modified        - last modification time (as Timestamp)
  5184          statusChanged   - last status change time (as Timestamp)
  5204 	 statusChanged   - last status change time (as Timestamp)
  5185          alternativeName - (windows only:) the MSDOS name of the file
  5205 	 alternativeName - (windows only:) the MSDOS name of the file
  5186 
  5206 
  5187      Some of the fields may be returned as nil on systems which do not provide
  5207      Some of the fields may be returned as nil on systems which do not provide
  5188      all of the information.
  5208      all of the information.
  5189      Return nil if such a file does not exist.
  5209      Return nil if such a file does not exist.
  5190      For symbolic links (if supported by the OS),
  5210      For symbolic links (if supported by the OS),
  5194 
  5214 
  5195     |info target|
  5215     |info target|
  5196 
  5216 
  5197     info := self linkInfoOf:aPathName.
  5217     info := self linkInfoOf:aPathName.
  5198     (info notNil and:[info isSymbolicLink]) ifTrue:[
  5218     (info notNil and:[info isSymbolicLink]) ifTrue:[
  5199         target := info path.
  5219 	target := info path.
  5200         target notNil ifTrue:[
  5220 	target notNil ifTrue:[
  5201             ^ self linkInfoOf:target.
  5221 	    ^ self linkInfoOf:target.
  5202         ]
  5222 	]
  5203     ].
  5223     ].
  5204     ^ info
  5224     ^ info
  5205 
  5225 
  5206    "
  5226    "
  5207     OperatingSystem infoOf:'c:\windows'
  5227     OperatingSystem infoOf:'c:\windows'
  5222 %{
  5242 %{
  5223     int ret;
  5243     int ret;
  5224 
  5244 
  5225     if (__isStringLike(aPathName)) {
  5245     if (__isStringLike(aPathName)) {
  5226 #ifdef DO_WRAP_CALLS
  5246 #ifdef DO_WRAP_CALLS
  5227         char _aPathName[MAXPATHLEN];
  5247 	char _aPathName[MAXPATHLEN];
  5228 
  5248 
  5229         strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  5249 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  5230         do {
  5250 	do {
  5231             __threadErrno = 0;
  5251 	    __threadErrno = 0;
  5232             ret = STX_API_NOINT_CALL1( "GetFileAttributesA", GetFileAttributesA, _aPathName);
  5252 	    ret = STX_API_NOINT_CALL1( "GetFileAttributesA", GetFileAttributesA, _aPathName);
  5233         } while ((ret == -1) && (__threadErrno == EINTR));
  5253 	} while ((ret == -1) && (__threadErrno == EINTR));
  5234 #else
  5254 #else
  5235         ret = GetFileAttributesA((char *) __stringVal(aPathName));
  5255 	ret = GetFileAttributesA((char *) __stringVal(aPathName));
  5236         if (ret == -1) {
  5256 	if (ret == -1) {
  5237             __threadErrno = __WIN32_ERR(GetLastError());
  5257 	    __threadErrno = __WIN32_ERR(GetLastError());
  5238         }
  5258 	}
  5239 #endif
  5259 #endif
  5240     } else if (__isUnicode16String(aPathName)) {
  5260     } else if (__isUnicode16String(aPathName)) {
  5241         wchar_t _wPathName[MAXPATHLEN+1];
  5261 	wchar_t _wPathName[MAXPATHLEN+1];
  5242         int i, l;
  5262 	int i, l;
  5243 
  5263 
  5244         l = __unicode16StringSize(aPathName);
  5264 	l = __unicode16StringSize(aPathName);
  5245         if (l > MAXPATHLEN) l = MAXPATHLEN;
  5265 	if (l > MAXPATHLEN) l = MAXPATHLEN;
  5246         for (i=0; i<l; i++) {
  5266 	for (i=0; i<l; i++) {
  5247             _wPathName[i] = __unicode16StringVal(aPathName)[i];
  5267 	    _wPathName[i] = __unicode16StringVal(aPathName)[i];
  5248         }
  5268 	}
  5249         _wPathName[i] = 0;
  5269 	_wPathName[i] = 0;
  5250 #ifdef DO_WRAP_CALLS
  5270 #ifdef DO_WRAP_CALLS
  5251         do {
  5271 	do {
  5252             __threadErrno = 0;
  5272 	    __threadErrno = 0;
  5253             ret = STX_API_NOINT_CALL1( "GetFileAttributesW", GetFileAttributesW, _wPathName);
  5273 	    ret = STX_API_NOINT_CALL1( "GetFileAttributesW", GetFileAttributesW, _wPathName);
  5254         } while ((ret == -1) && (__threadErrno == EINTR));
  5274 	} while ((ret == -1) && (__threadErrno == EINTR));
  5255 #else
  5275 #else
  5256         ret = GetFileAttributesW(_wPathName);
  5276 	ret = GetFileAttributesW(_wPathName);
  5257         if (ret == -1) {
  5277 	if (ret == -1) {
  5258             __threadErrno = __WIN32_ERR(GetLastError());
  5278 	    __threadErrno = __WIN32_ERR(GetLastError());
  5259         }
  5279 	}
  5260 #endif
  5280 #endif
  5261     } else
  5281     } else
  5262         goto err;
  5282 	goto err;
  5263 
  5283 
  5264     if (ret < 0) {
  5284     if (ret < 0) {
  5265         @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  5285 	@global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  5266         RETURN ( false );
  5286 	RETURN ( false );
  5267     }
  5287     }
  5268     RETURN ( (ret & FILE_ATTRIBUTE_DIRECTORY) ? true : false);
  5288     RETURN ( (ret & FILE_ATTRIBUTE_DIRECTORY) ? true : false);
  5269 err:;
  5289 err:;
  5270 %}.
  5290 %}.
  5271     ^ self primitiveFailed
  5291     ^ self primitiveFailed
  5272 
  5292 
  5273     "an alternative implementation would be:
  5293     "an alternative implementation would be:
  5274         ^ (self infoOf:aPathName) type == #directory
  5294 	^ (self infoOf:aPathName) type == #directory
  5275     "
  5295     "
  5276     "
  5296     "
  5277      self isDirectory:'.'
  5297      self isDirectory:'.'
  5278      self isDirectory:'.' asUnicode16String
  5298      self isDirectory:'.' asUnicode16String
  5279     "
  5299     "
  5313     "return true, if the file/dir 'aPathName' is readable.
  5333     "return true, if the file/dir 'aPathName' is readable.
  5314      For symbolic links, the pointed-to-file is checked."
  5334      For symbolic links, the pointed-to-file is checked."
  5315 
  5335 
  5316 %{
  5336 %{
  5317     if (__isStringLike(aPathName)) {
  5337     if (__isStringLike(aPathName)) {
  5318         int ret;
  5338 	int ret;
  5319 
  5339 
  5320         /*
  5340 	/*
  5321          * under windows, all files are readable ...
  5341 	 * under windows, all files are readable ...
  5322          * so, only check for the files existence here.
  5342 	 * so, only check for the files existence here.
  5323          */
  5343 	 */
  5324 #ifdef DO_WRAP_CALLS
  5344 #ifdef DO_WRAP_CALLS
  5325         char _aPathName[MAXPATHLEN];
  5345 	char _aPathName[MAXPATHLEN];
  5326 
  5346 
  5327         strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  5347 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  5328         do {
  5348 	do {
  5329             __threadErrno = 0;
  5349 	    __threadErrno = 0;
  5330             ret = STX_API_NOINT_CALL1( "GetFileAttributesA", GetFileAttributesA, _aPathName);
  5350 	    ret = STX_API_NOINT_CALL1( "GetFileAttributesA", GetFileAttributesA, _aPathName);
  5331         } while ((ret < 0) && (__threadErrno == EINTR));
  5351 	} while ((ret < 0) && (__threadErrno == EINTR));
  5332 #else
  5352 #else
  5333         ret = GetFileAttributesA((char *) __stringVal(aPathName));
  5353 	ret = GetFileAttributesA((char *) __stringVal(aPathName));
  5334         if (ret < 0) {
  5354 	if (ret < 0) {
  5335             __threadErrno = __WIN32_ERR(GetLastError());
  5355 	    __threadErrno = __WIN32_ERR(GetLastError());
  5336         }
  5356 	}
  5337 #endif
  5357 #endif
  5338         if (ret < 0) {
  5358 	if (ret < 0) {
  5339             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  5359 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  5340             RETURN (false);
  5360 	    RETURN (false);
  5341         }
  5361 	}
  5342         RETURN (true);
  5362 	RETURN (true);
  5343     }
  5363     }
  5344 
  5364 
  5345     if (__isUnicode16String(aPathName)) {
  5365     if (__isUnicode16String(aPathName)) {
  5346         int ret;
  5366 	int ret;
  5347 
  5367 
  5348         /*
  5368 	/*
  5349          * under windows, all files are readable ...
  5369 	 * under windows, all files are readable ...
  5350          * so, only check for the files existence here.
  5370 	 * so, only check for the files existence here.
  5351          */
  5371 	 */
  5352         wchar_t _wPathName[MAXPATHLEN+1];
  5372 	wchar_t _wPathName[MAXPATHLEN+1];
  5353         int i, l;
  5373 	int i, l;
  5354 
  5374 
  5355         l = __unicode16StringSize(aPathName);
  5375 	l = __unicode16StringSize(aPathName);
  5356         if (l > MAXPATHLEN) l = MAXPATHLEN;
  5376 	if (l > MAXPATHLEN) l = MAXPATHLEN;
  5357         for (i=0; i<l; i++) {
  5377 	for (i=0; i<l; i++) {
  5358             _wPathName[i] = __unicode16StringVal(aPathName)[i];
  5378 	    _wPathName[i] = __unicode16StringVal(aPathName)[i];
  5359         }
  5379 	}
  5360         _wPathName[i] = 0;
  5380 	_wPathName[i] = 0;
  5361 #ifdef DO_WRAP_CALLS
  5381 #ifdef DO_WRAP_CALLS
  5362         do {
  5382 	do {
  5363             __threadErrno = 0;
  5383 	    __threadErrno = 0;
  5364             ret = STX_API_NOINT_CALL1( "GetFileAttributesW", GetFileAttributesW, _wPathName);
  5384 	    ret = STX_API_NOINT_CALL1( "GetFileAttributesW", GetFileAttributesW, _wPathName);
  5365         } while ((ret < 0) && (__threadErrno == EINTR));
  5385 	} while ((ret < 0) && (__threadErrno == EINTR));
  5366 #else
  5386 #else
  5367         ret = GetFileAttributesW(_wPathName);
  5387 	ret = GetFileAttributesW(_wPathName);
  5368         if (ret < 0) {
  5388 	if (ret < 0) {
  5369             __threadErrno = __WIN32_ERR(GetLastError());
  5389 	    __threadErrno = __WIN32_ERR(GetLastError());
  5370         }
  5390 	}
  5371 #endif
  5391 #endif
  5372         if (ret < 0) {
  5392 	if (ret < 0) {
  5373             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  5393 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  5374             RETURN (false);
  5394 	    RETURN (false);
  5375         }
  5395 	}
  5376         RETURN (true);
  5396 	RETURN (true);
  5377     }
  5397     }
  5378 %}.
  5398 %}.
  5379     ^ self primitiveFailed
  5399     ^ self primitiveFailed
  5380 
  5400 
  5381     "
  5401     "
  5406 %{
  5426 %{
  5407     int ret;
  5427     int ret;
  5408 
  5428 
  5409     if (__isStringLike(aPathName)) {
  5429     if (__isStringLike(aPathName)) {
  5410 #ifdef DO_WRAP_CALLS
  5430 #ifdef DO_WRAP_CALLS
  5411         char _aPathName[MAXPATHLEN];
  5431 	char _aPathName[MAXPATHLEN];
  5412 
  5432 
  5413         strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  5433 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  5414         do {
  5434 	do {
  5415             __threadErrno = 0;
  5435 	    __threadErrno = 0;
  5416             ret = STX_API_NOINT_CALL1( "GetFileAttributesA", GetFileAttributesA, _aPathName);
  5436 	    ret = STX_API_NOINT_CALL1( "GetFileAttributesA", GetFileAttributesA, _aPathName);
  5417         } while ((ret == -1) && (__threadErrno == EINTR));
  5437 	} while ((ret == -1) && (__threadErrno == EINTR));
  5418 #else
  5438 #else
  5419         ret = GetFileAttributesA((char *) __stringVal(aPathName));
  5439 	ret = GetFileAttributesA((char *) __stringVal(aPathName));
  5420         if (ret == -1) {
  5440 	if (ret == -1) {
  5421             __threadErrno = __WIN32_ERR(GetLastError());
  5441 	    __threadErrno = __WIN32_ERR(GetLastError());
  5422         }
  5442 	}
  5423 #endif
  5443 #endif
  5424     } else  if (__isUnicode16String(aPathName)) {
  5444     } else  if (__isUnicode16String(aPathName)) {
  5425         wchar_t _wPathName[MAXPATHLEN+1];
  5445 	wchar_t _wPathName[MAXPATHLEN+1];
  5426         int i, l;
  5446 	int i, l;
  5427 
  5447 
  5428         l = __unicode16StringSize(aPathName);
  5448 	l = __unicode16StringSize(aPathName);
  5429         if (l > MAXPATHLEN) l = MAXPATHLEN;
  5449 	if (l > MAXPATHLEN) l = MAXPATHLEN;
  5430         for (i=0; i<l; i++) {
  5450 	for (i=0; i<l; i++) {
  5431             _wPathName[i] = __unicode16StringVal(aPathName)[i];
  5451 	    _wPathName[i] = __unicode16StringVal(aPathName)[i];
  5432         }
  5452 	}
  5433         _wPathName[i] = 0;
  5453 	_wPathName[i] = 0;
  5434 #ifdef DO_WRAP_CALLS
  5454 #ifdef DO_WRAP_CALLS
  5435         do {
  5455 	do {
  5436             __threadErrno = 0;
  5456 	    __threadErrno = 0;
  5437             ret = STX_API_NOINT_CALL1( "GetFileAttributesW", GetFileAttributesW, _wPathName);
  5457 	    ret = STX_API_NOINT_CALL1( "GetFileAttributesW", GetFileAttributesW, _wPathName);
  5438         } while ((ret == -1) && (__threadErrno == EINTR));
  5458 	} while ((ret == -1) && (__threadErrno == EINTR));
  5439 #else
  5459 #else
  5440         ret = GetFileAttributesW(_wPathName);
  5460 	ret = GetFileAttributesW(_wPathName);
  5441         if (ret == -1) {
  5461 	if (ret == -1) {
  5442             __threadErrno = __WIN32_ERR(GetLastError());
  5462 	    __threadErrno = __WIN32_ERR(GetLastError());
  5443         }
  5463 	}
  5444 #endif
  5464 #endif
  5445     } else
  5465     } else
  5446         goto err;
  5466 	goto err;
  5447 
  5467 
  5448     if (ret == -1) {
  5468     if (ret == -1) {
  5449         @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  5469 	@global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  5450         RETURN ( false );
  5470 	RETURN ( false );
  5451     }
  5471     }
  5452     RETURN (true);
  5472     RETURN (true);
  5453 
  5473 
  5454 err:;
  5474 err:;
  5455 %}.
  5475 %}.
  5468 
  5488 
  5469     |attr|
  5489     |attr|
  5470 
  5490 
  5471     attr := self primGetFileAttributes:aPathName.
  5491     attr := self primGetFileAttributes:aPathName.
  5472     attr notNil ifTrue:[
  5492     attr notNil ifTrue:[
  5473         ^ (attr bitAnd: (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_READONLY ))
  5493 	^ (attr bitAnd: (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_READONLY ))
  5474             ~~ FILE_ATTRIBUTE_READONLY
  5494 	    ~~ FILE_ATTRIBUTE_READONLY
  5475     ].
  5495     ].
  5476     ^ false
  5496     ^ false
  5477 
  5497 
  5478     "
  5498     "
  5479      self isWritable:'.'
  5499      self isWritable:'.'
  5484 
  5504 
  5485 linkInfoOf:aPathName
  5505 linkInfoOf:aPathName
  5486     "return some object filled with info for the file 'aPathName';
  5506     "return some object filled with info for the file 'aPathName';
  5487      the info (for which corresponding access methods are understood by
  5507      the info (for which corresponding access methods are understood by
  5488      the returned object) is:
  5508      the returned object) is:
  5489          type            - a symbol giving the files type
  5509 	 type            - a symbol giving the files type
  5490          mode            - numeric access mode
  5510 	 mode            - numeric access mode
  5491          uid             - owners user id
  5511 	 uid             - owners user id
  5492          gid             - owners group id
  5512 	 gid             - owners group id
  5493          size            - files size
  5513 	 size            - files size
  5494          id              - files number (i.e. inode number)
  5514 	 id              - files number (i.e. inode number)
  5495          accessed        - last access time (as Timestamp)
  5515 	 accessed        - last access time (as Timestamp)
  5496          modified        - last modification time (as Timestamp)
  5516 	 modified        - last modification time (as Timestamp)
  5497          statusChanged   - last status change time (as Timestamp)
  5517 	 statusChanged   - last status change time (as Timestamp)
  5498          alternativeName - (windows only:) the MSDOS name of the file
  5518 	 alternativeName - (windows only:) the MSDOS name of the file
  5499 
  5519 
  5500      Some of the fields may be returned as nil on systems which do not provide
  5520      Some of the fields may be returned as nil on systems which do not provide
  5501      all of the information.
  5521      all of the information.
  5502      Return nil if such a file does not exist.
  5522      Return nil if such a file does not exist.
  5503      For symbolic links (if supported by the OS),
  5523      For symbolic links (if supported by the OS),
  5519     WIN32_FILE_ATTRIBUTE_DATA fileAttributeData;
  5539     WIN32_FILE_ATTRIBUTE_DATA fileAttributeData;
  5520     unsigned INT ino;
  5540     unsigned INT ino;
  5521     wchar_t _aPathName[MAX_PATH+1];
  5541     wchar_t _aPathName[MAX_PATH+1];
  5522 
  5542 
  5523     if (__isStringLike(aPathName)) {
  5543     if (__isStringLike(aPathName)) {
  5524         int i;
  5544 	int i;
  5525         int l = __stringSize(aPathName);
  5545 	int l = __stringSize(aPathName);
  5526         if (l > MAX_PATH) l = MAX_PATH;
  5546 	if (l > MAX_PATH) l = MAX_PATH;
  5527 
  5547 
  5528         for (i=0; i<l; i++) {
  5548 	for (i=0; i<l; i++) {
  5529             _aPathName[i] = __stringVal(aPathName)[i];
  5549 	    _aPathName[i] = __stringVal(aPathName)[i];
  5530         }
  5550 	}
  5531         _aPathName[i] = 0;
  5551 	_aPathName[i] = 0;
  5532     } else if (__isUnicode16String(aPathName)) {
  5552     } else if (__isUnicode16String(aPathName)) {
  5533         int i;
  5553 	int i;
  5534         int l = __unicode16StringSize(aPathName);
  5554 	int l = __unicode16StringSize(aPathName);
  5535         if (l > MAX_PATH) l = MAX_PATH;
  5555 	if (l > MAX_PATH) l = MAX_PATH;
  5536 
  5556 
  5537         for (i=0; i<l; i++) {
  5557 	for (i=0; i<l; i++) {
  5538             _aPathName[i] = __unicode16StringVal(aPathName)[i];
  5558 	    _aPathName[i] = __unicode16StringVal(aPathName)[i];
  5539         }
  5559 	}
  5540         _aPathName[i] = 0;
  5560 	_aPathName[i] = 0;
  5541     } else
  5561     } else
  5542         goto badArgument;
  5562 	goto badArgument;
  5543 
  5563 
  5544 #ifdef DO_WRAP_CALLS
  5564 #ifdef DO_WRAP_CALLS
  5545     {
  5565     {
  5546         do {
  5566 	do {
  5547             __threadErrno = 0;
  5567 	    __threadErrno = 0;
  5548             result = STX_API_NOINT_CALL3( "GetFileAttributesExW", GetFileAttributesExW, _aPathName, GetFileExInfoStandard, &fileAttributeData);
  5568 	    result = STX_API_NOINT_CALL3( "GetFileAttributesExW", GetFileAttributesExW, _aPathName, GetFileExInfoStandard, &fileAttributeData);
  5549         } while (!result && (__threadErrno == EINTR));
  5569 	} while (!result && (__threadErrno == EINTR));
  5550     }
  5570     }
  5551 #else
  5571 #else
  5552     result = GetFileAttributesExW(_aPathName, GetFileExInfoStandard, &fileAttributeData);
  5572     result = GetFileAttributesExW(_aPathName, GetFileExInfoStandard, &fileAttributeData);
  5553     if (!result) {
  5573     if (!result) {
  5554         __threadErrno = __WIN32_ERR(GetLastError());
  5574 	__threadErrno = __WIN32_ERR(GetLastError());
  5555     }
  5575     }
  5556 #endif
  5576 #endif
  5557 
  5577 
  5558     if (!result) {
  5578     if (!result) {
  5559         @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  5579 	@global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  5560     } else {
  5580     } else {
  5561         id = __mkSmallInteger(0);   /* could get it by opening ... */
  5581 	id = __mkSmallInteger(0);   /* could get it by opening ... */
  5562         size = __MKLARGEINT64(1, fileAttributeData.nFileSizeLow, fileAttributeData.nFileSizeHigh);
  5582 	size = __MKLARGEINT64(1, fileAttributeData.nFileSizeLow, fileAttributeData.nFileSizeHigh);
  5563 
  5583 
  5564 //        if (fileAttributeData.cFileName[0] != '\0') {
  5584 //        if (fileAttributeData.cFileName[0] != '\0') {
  5565 //            bcopy(fileAttributeData.cFileName, fileNameBuffer, MAX_PATH*sizeof(wchar_t));
  5585 //            bcopy(fileAttributeData.cFileName, fileNameBuffer, MAX_PATH*sizeof(wchar_t));
  5566 //            fileNameBuffer[MAX_PATH] = '\0';
  5586 //            fileNameBuffer[MAX_PATH] = '\0';
  5567 //            fileName = __MKU16STRING(fileNameBuffer);             /* FULL name */
  5587 //            fileName = __MKU16STRING(fileNameBuffer);             /* FULL name */
  5571 //            bcopy(fileAttributeData.cAlternateFileName, alternativeFileNameBuffer, 14*sizeof(wchar_t));
  5591 //            bcopy(fileAttributeData.cAlternateFileName, alternativeFileNameBuffer, 14*sizeof(wchar_t));
  5572 //            alternativeFileNameBuffer[14] = '\0';
  5592 //            alternativeFileNameBuffer[14] = '\0';
  5573 //            alternativeName = __MKU16STRING(alternativeFileNameBuffer); /* DOS name */
  5593 //            alternativeName = __MKU16STRING(alternativeFileNameBuffer); /* DOS name */
  5574 //        }
  5594 //        }
  5575 
  5595 
  5576         /*
  5596 	/*
  5577          * simulate access bits
  5597 	 * simulate access bits
  5578          */
  5598 	 */
  5579         if (fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_READONLY) {
  5599 	if (fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_READONLY) {
  5580             modeBits = 0444;
  5600 	    modeBits = 0444;
  5581         } else {
  5601 	} else {
  5582             modeBits = 0666;
  5602 	    modeBits = 0666;
  5583         }
  5603 	}
  5584 
  5604 
  5585         if (fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
  5605 	if (fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
  5586             type = @symbol(directory);
  5606 	    type = @symbol(directory);
  5587             modeBits = 0777;   /* executable and WRITABLE - refer to comment in #isWritable: */
  5607 	    modeBits = 0777;   /* executable and WRITABLE - refer to comment in #isWritable: */
  5588         } else if (fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
  5608 	} else if (fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
  5589             type = @symbol(symbolicLink);
  5609 	    type = @symbol(symbolicLink);
  5590             modeBits = 0777;   /* even in UNIX symlinks have 0777 */
  5610 	    modeBits = 0777;   /* even in UNIX symlinks have 0777 */
  5591         } else {
  5611 	} else {
  5592             type = @symbol(regular);
  5612 	    type = @symbol(regular);
  5593         }
  5613 	}
  5594 
  5614 
  5595         mode = __mkSmallInteger(modeBits);
  5615 	mode = __mkSmallInteger(modeBits);
  5596 
  5616 
  5597         cOsTime = FileTimeToOsTime(&fileAttributeData.ftCreationTime);
  5617 	cOsTime = FileTimeToOsTime(&fileAttributeData.ftCreationTime);
  5598         aOsTime = FileTimeToOsTime(&fileAttributeData.ftLastAccessTime);
  5618 	aOsTime = FileTimeToOsTime(&fileAttributeData.ftLastAccessTime);
  5599         mOsTime = FileTimeToOsTime(&fileAttributeData.ftLastWriteTime);
  5619 	mOsTime = FileTimeToOsTime(&fileAttributeData.ftLastWriteTime);
  5600     }
  5620     }
  5601 
  5621 
  5602   badArgument: ;
  5622   badArgument: ;
  5603 %}.
  5623 %}.
  5604 
  5624 
  5605     (aPathName endsWith:'.lnk') ifTrue:[
  5625     (aPathName endsWith:'.lnk') ifTrue:[
  5606         type := #symbolicLink.
  5626 	type := #symbolicLink.
  5607         "/ now done lazyly in FileStatusInfo, when the path is accessed
  5627 	"/ now done lazyly in FileStatusInfo, when the path is accessed
  5608         "/ path := self getLinkTarget:aPathName.
  5628 	"/ path := self getLinkTarget:aPathName.
  5609     ].
  5629     ].
  5610 
  5630 
  5611     mode isNil ifTrue:[
  5631     mode isNil ifTrue:[
  5612         (self isDirectory:aPathName) ifTrue:[
  5632 	(self isDirectory:aPathName) ifTrue:[
  5613             "/ the code above fails for root directories (these do not exist).
  5633 	    "/ the code above fails for root directories (these do not exist).
  5614             "/ simulate here
  5634 	    "/ simulate here
  5615             mode := 8r777.
  5635 	    mode := 8r777.
  5616             type := #directory.
  5636 	    type := #directory.
  5617             uid := gid := 0.
  5637 	    uid := gid := 0.
  5618             size := 0.
  5638 	    size := 0.
  5619             id := 0.
  5639 	    id := 0.
  5620             atime := mtime := ctime := Timestamp now.
  5640 	    atime := mtime := ctime := Timestamp now.
  5621         ].
  5641 	].
  5622     ].
  5642     ].
  5623     mode notNil ifTrue:[
  5643     mode notNil ifTrue:[
  5624         atime isNil ifTrue:[
  5644 	atime isNil ifTrue:[
  5625             atime := Timestamp new fromOSTime:aOsTime.
  5645 	    atime := Timestamp new fromOSTime:aOsTime.
  5626         ].
  5646 	].
  5627         mtime isNil ifTrue:[
  5647 	mtime isNil ifTrue:[
  5628             mtime := Timestamp new fromOSTime:mOsTime.
  5648 	    mtime := Timestamp new fromOSTime:mOsTime.
  5629         ].
  5649 	].
  5630         ctime isNil ifTrue:[
  5650 	ctime isNil ifTrue:[
  5631             ctime := Timestamp new fromOSTime:cOsTime.
  5651 	    ctime := Timestamp new fromOSTime:cOsTime.
  5632         ].
  5652 	].
  5633         fileName notNil ifTrue:[
  5653 	fileName notNil ifTrue:[
  5634             fileName := fileName asSingleByteStringIfPossible
  5654 	    fileName := fileName asSingleByteStringIfPossible
  5635         ].
  5655 	].
  5636         alternativeName notNil ifTrue:[
  5656 	alternativeName notNil ifTrue:[
  5637             alternativeName := alternativeName asSingleByteStringIfPossible
  5657 	    alternativeName := alternativeName asSingleByteStringIfPossible
  5638         ].
  5658 	].
  5639         info := FileStatusInfo
  5659 	info := FileStatusInfo
  5640                     type:type
  5660 		    type:type
  5641                     mode:mode
  5661 		    mode:mode
  5642                     uid:uid
  5662 		    uid:uid
  5643                     gid:gid
  5663 		    gid:gid
  5644                     size:size
  5664 		    size:size
  5645                     id:id
  5665 		    id:id
  5646                     accessed:atime
  5666 		    accessed:atime
  5647                     modified:mtime
  5667 		    modified:mtime
  5648                     created:ctime
  5668 		    created:ctime
  5649                     sourcePath:aPathName
  5669 		    sourcePath:aPathName
  5650                     fullName:fileName
  5670 		    fullName:fileName
  5651                     alternativeName:alternativeName.
  5671 		    alternativeName:alternativeName.
  5652         ^ info
  5672 	^ info
  5653    ].
  5673    ].
  5654    ^ nil
  5674    ^ nil
  5655 
  5675 
  5656    "
  5676    "
  5657     OperatingSystem linkInfoOf:'c:\windows'
  5677     OperatingSystem linkInfoOf:'c:\windows'
  5668     "given a file suffix, return a corresponding mimeType.
  5688     "given a file suffix, return a corresponding mimeType.
  5669      Here, the Registry is consulted.
  5689      Here, the Registry is consulted.
  5670      Returns nil if no mimeType for the given suffix is known."
  5690      Returns nil if no mimeType for the given suffix is known."
  5671 
  5691 
  5672     ^ RegistryEntry
  5692     ^ RegistryEntry
  5673         stringValueFor:'Content Type'
  5693 	stringValueFor:'Content Type'
  5674         atKey:('HKEY_CLASSES_ROOT\.' , aFileSuffix)
  5694 	atKey:('HKEY_CLASSES_ROOT\.' , aFileSuffix)
  5675 
  5695 
  5676     "
  5696     "
  5677      self mimeTypeForSuffix:'au'
  5697      self mimeTypeForSuffix:'au'
  5678      self mimeTypeForSuffix:'st'
  5698      self mimeTypeForSuffix:'st'
  5679      self mimeTypeForSuffix:'dll'
  5699      self mimeTypeForSuffix:'dll'
  5702 
  5722 
  5703     "some systems have a convenient function for this ..."
  5723     "some systems have a convenient function for this ..."
  5704     path := self primPathNameOf:pathName.
  5724     path := self primPathNameOf:pathName.
  5705 
  5725 
  5706     path isNil ifTrue:[
  5726     path isNil ifTrue:[
  5707         (self isValidPath:pathName) ifFalse:[
  5727 	(self isValidPath:pathName) ifFalse:[
  5708             p := pathName.
  5728 	    p := pathName.
  5709             [(p size > 1)
  5729 	    [(p size > 1)
  5710              and:[p endsWith:(self fileSeparator)]
  5730 	     and:[p endsWith:(self fileSeparator)]
  5711             ] whileTrue:[
  5731 	    ] whileTrue:[
  5712                 p := p copyWithoutLast:1.
  5732 		p := p copyWithoutLast:1.
  5713             ].
  5733 	    ].
  5714             ^ p
  5734 	    ^ p
  5715         ].
  5735 	].
  5716 
  5736 
  5717         "/
  5737 	"/
  5718         "/ return the original - there is nothing else can we do
  5738 	"/ return the original - there is nothing else can we do
  5719         "/
  5739 	"/
  5720         path := self compressPath:pathName
  5740 	path := self compressPath:pathName
  5721     ].
  5741     ].
  5722     ^ path.
  5742     ^ path.
  5723 
  5743 
  5724     "
  5744     "
  5725      OperatingSystem pathNameOf:'.'
  5745      OperatingSystem pathNameOf:'.'
  5770 %{
  5790 %{
  5771     int ret;
  5791     int ret;
  5772 
  5792 
  5773     if (__isStringLike(aPathName)) {
  5793     if (__isStringLike(aPathName)) {
  5774 #ifdef DO_WRAP_CALLS
  5794 #ifdef DO_WRAP_CALLS
  5775         char _aPathName[MAXPATHLEN];
  5795 	char _aPathName[MAXPATHLEN];
  5776 
  5796 
  5777         strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  5797 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  5778         do {
  5798 	do {
  5779             __threadErrno = 0;
  5799 	    __threadErrno = 0;
  5780             ret = STX_API_NOINT_CALL1( "GetFileAttributesA", GetFileAttributesA, _aPathName);
  5800 	    ret = STX_API_NOINT_CALL1( "GetFileAttributesA", GetFileAttributesA, _aPathName);
  5781         } while ((ret < 0) && (__threadErrno == EINTR));
  5801 	} while ((ret < 0) && (__threadErrno == EINTR));
  5782 #else
  5802 #else
  5783         ret = GetFileAttributesA((char *) __stringVal(aPathName));
  5803 	ret = GetFileAttributesA((char *) __stringVal(aPathName));
  5784         if (ret < 0) {
  5804 	if (ret < 0) {
  5785             __threadErrno = __WIN32_ERR(GetLastError());
  5805 	    __threadErrno = __WIN32_ERR(GetLastError());
  5786         }
  5806 	}
  5787 #endif
  5807 #endif
  5788         if (ret >= 0) {
  5808 	if (ret >= 0) {
  5789             RETURN ( __mkSmallInteger(ret) );
  5809 	    RETURN ( __mkSmallInteger(ret) );
  5790         }
  5810 	}
  5791         __threadErrno = __WIN32_ERR(GetLastError());
  5811 	__threadErrno = __WIN32_ERR(GetLastError());
  5792         RETURN (nil);
  5812 	RETURN (nil);
  5793     }
  5813     }
  5794 
  5814 
  5795     if (__isUnicode16String(aPathName)) {
  5815     if (__isUnicode16String(aPathName)) {
  5796         wchar_t _wPathName[MAXPATHLEN+1];
  5816 	wchar_t _wPathName[MAXPATHLEN+1];
  5797         int i, l;
  5817 	int i, l;
  5798 
  5818 
  5799         l = __unicode16StringSize(aPathName);
  5819 	l = __unicode16StringSize(aPathName);
  5800         if (l > MAXPATHLEN) l = MAXPATHLEN;
  5820 	if (l > MAXPATHLEN) l = MAXPATHLEN;
  5801         for (i=0; i<l; i++) {
  5821 	for (i=0; i<l; i++) {
  5802             _wPathName[i] = __unicode16StringVal(aPathName)[i];
  5822 	    _wPathName[i] = __unicode16StringVal(aPathName)[i];
  5803         }
  5823 	}
  5804         _wPathName[i] = 0;
  5824 	_wPathName[i] = 0;
  5805 #ifdef DO_WRAP_CALLS
  5825 #ifdef DO_WRAP_CALLS
  5806         do {
  5826 	do {
  5807             __threadErrno = 0;
  5827 	    __threadErrno = 0;
  5808             ret = STX_API_NOINT_CALL1( "GetFileAttributesW", GetFileAttributesW, _wPathName);
  5828 	    ret = STX_API_NOINT_CALL1( "GetFileAttributesW", GetFileAttributesW, _wPathName);
  5809         } while ((ret < 0) && (__threadErrno == EINTR));
  5829 	} while ((ret < 0) && (__threadErrno == EINTR));
  5810 #else
  5830 #else
  5811         ret = GetFileAttributesW(_wPathName);
  5831 	ret = GetFileAttributesW(_wPathName);
  5812         if (ret < 0) {
  5832 	if (ret < 0) {
  5813             __threadErrno = __WIN32_ERR(GetLastError());
  5833 	    __threadErrno = __WIN32_ERR(GetLastError());
  5814         }
  5834 	}
  5815 #endif
  5835 #endif
  5816         if (ret >= 0) {
  5836 	if (ret >= 0) {
  5817             RETURN ( __mkSmallInteger(ret) );
  5837 	    RETURN ( __mkSmallInteger(ret) );
  5818         }
  5838 	}
  5819         __threadErrno = __WIN32_ERR(GetLastError());
  5839 	__threadErrno = __WIN32_ERR(GetLastError());
  5820         RETURN (nil);
  5840 	RETURN (nil);
  5821     }
  5841     }
  5822 %}.
  5842 %}.
  5823     ^ self primitiveFailed
  5843     ^ self primitiveFailed
  5824 
  5844 
  5825     "
  5845     "
  5845      Notice: if symbolic links are involved, the result may look different
  5865      Notice: if symbolic links are involved, the result may look different
  5846      from what you expect."
  5866      from what you expect."
  5847 
  5867 
  5848 %{  /* xxSTACK: 16000 */
  5868 %{  /* xxSTACK: 16000 */
  5849     if (__isStringLike(aPathName)) {
  5869     if (__isStringLike(aPathName)) {
  5850         char nameBuffer[MAXPATHLEN + 1 + MAXPATHLEN + 1];
  5870 	char nameBuffer[MAXPATHLEN + 1 + MAXPATHLEN + 1];
  5851         char *pFinal;
  5871 	char *pFinal;
  5852         int rslt;
  5872 	int rslt;
  5853 
  5873 
  5854 #ifdef DO_WRAP_CALLS
  5874 #ifdef DO_WRAP_CALLS
  5855         char _aPathName[MAXPATHLEN];
  5875 	char _aPathName[MAXPATHLEN];
  5856 
  5876 
  5857         strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  5877 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  5858         do {
  5878 	do {
  5859             __threadErrno = 0;
  5879 	    __threadErrno = 0;
  5860             rslt = STX_API_NOINT_CALL4( "GetFullPathName", GetFullPathName, _aPathName, sizeof(nameBuffer), nameBuffer, &pFinal);
  5880 	    rslt = STX_API_NOINT_CALL4( "GetFullPathName", GetFullPathName, _aPathName, sizeof(nameBuffer), nameBuffer, &pFinal);
  5861         } while ((rslt < 0) && (__threadErrno == EINTR));
  5881 	} while ((rslt < 0) && (__threadErrno == EINTR));
  5862 #else
  5882 #else
  5863         rslt = GetFullPathName(__stringVal(aPathName), sizeof(nameBuffer), nameBuffer, &pFinal);
  5883 	rslt = GetFullPathName(__stringVal(aPathName), sizeof(nameBuffer), nameBuffer, &pFinal);
  5864 #endif
  5884 #endif
  5865 
  5885 
  5866         if (rslt > 0) {
  5886 	if (rslt > 0) {
  5867             /*
  5887 	    /*
  5868              * Attention: GetLongPathName is not available on old NT4.0/W95/W98
  5888 	     * Attention: GetLongPathName is not available on old NT4.0/W95/W98
  5869              */
  5889 	     */
  5870             static FARPROC GetLongPathName_entry = NULL;
  5890 	    static FARPROC GetLongPathName_entry = NULL;
  5871 #ifdef NO_NT4_0_COMPATIBILITY
  5891 #ifdef NO_NT4_0_COMPATIBILITY
  5872             GetLongPathName_entry = (FARPROC) GetLongPathName;
  5892 	    GetLongPathName_entry = (FARPROC) GetLongPathName;
  5873 #else
  5893 #else
  5874             if (GetLongPathName_entry == NULL) {
  5894 	    if (GetLongPathName_entry == NULL) {
  5875                 GetLongPathName_entry = __get_kernel32_functionAddress("GetLongPathNameA");
  5895 		GetLongPathName_entry = __get_kernel32_functionAddress("GetLongPathNameA");
  5876             }
  5896 	    }
  5877 #endif /* NO_NT4_0_COMPATIBILITY */
  5897 #endif /* NO_NT4_0_COMPATIBILITY */
  5878 
  5898 
  5879             if (GetLongPathName_entry) {
  5899 	    if (GetLongPathName_entry) {
  5880 #ifdef DO_WRAP_CALLS
  5900 #ifdef DO_WRAP_CALLS
  5881                 do {
  5901 		do {
  5882                     __threadErrno = 0;
  5902 		    __threadErrno = 0;
  5883                     rslt = STX_API_NOINT_CALL3( "GetLongPathName", GetLongPathName_entry, nameBuffer, nameBuffer, sizeof(nameBuffer));
  5903 		    rslt = STX_API_NOINT_CALL3( "GetLongPathName", GetLongPathName_entry, nameBuffer, nameBuffer, sizeof(nameBuffer));
  5884                 } while ((rslt < 0) && (__threadErrno == EINTR));
  5904 		} while ((rslt < 0) && (__threadErrno == EINTR));
  5885 #else
  5905 #else
  5886                 rslt = (*GetLongPathName_entry)(nameBuffer, nameBuffer, sizeof(nameBuffer));
  5906 		rslt = (*GetLongPathName_entry)(nameBuffer, nameBuffer, sizeof(nameBuffer));
  5887 #endif
  5907 #endif
  5888             }
  5908 	    }
  5889         }
  5909 	}
  5890         if (rslt > 0) {
  5910 	if (rslt > 0) {
  5891             RETURN ( __MKSTRING(nameBuffer) );
  5911 	    RETURN ( __MKSTRING(nameBuffer) );
  5892         }
  5912 	}
  5893         __threadErrno = __WIN32_ERR(GetLastError());
  5913 	__threadErrno = __WIN32_ERR(GetLastError());
  5894         RETURN (nil);
  5914 	RETURN (nil);
  5895     }
  5915     }
  5896     if (__isUnicode16String(aPathName)) {
  5916     if (__isUnicode16String(aPathName)) {
  5897         wchar_t nameBuffer[MAXPATHLEN + 1 + MAXPATHLEN + 1];
  5917 	wchar_t nameBuffer[MAXPATHLEN + 1 + MAXPATHLEN + 1];
  5898         char *pFinal;
  5918 	char *pFinal;
  5899         int rslt;
  5919 	int rslt;
  5900         wchar_t _aPathName[MAXPATHLEN+1];
  5920 	wchar_t _aPathName[MAXPATHLEN+1];
  5901         int i, l;
  5921 	int i, l;
  5902 
  5922 
  5903         l = __unicode16StringSize(aPathName);
  5923 	l = __unicode16StringSize(aPathName);
  5904         if (l > MAXPATHLEN) l = MAXPATHLEN;
  5924 	if (l > MAXPATHLEN) l = MAXPATHLEN;
  5905         for (i=0; i<l; i++) {
  5925 	for (i=0; i<l; i++) {
  5906             _aPathName[i] = __unicode16StringVal(aPathName)[i];
  5926 	    _aPathName[i] = __unicode16StringVal(aPathName)[i];
  5907         }
  5927 	}
  5908         _aPathName[i] = 0;
  5928 	_aPathName[i] = 0;
  5909 
  5929 
  5910 #ifdef DO_WRAP_CALLS
  5930 #ifdef DO_WRAP_CALLS
  5911         do {
  5931 	do {
  5912             __threadErrno = 0;
  5932 	    __threadErrno = 0;
  5913             rslt = STX_API_NOINT_CALL4( "GetFullPathNameW", GetFullPathNameW, _aPathName, MAXPATHLEN, nameBuffer, &pFinal);
  5933 	    rslt = STX_API_NOINT_CALL4( "GetFullPathNameW", GetFullPathNameW, _aPathName, MAXPATHLEN, nameBuffer, &pFinal);
  5914         } while ((rslt < 0) && (__threadErrno == EINTR));
  5934 	} while ((rslt < 0) && (__threadErrno == EINTR));
  5915 #else
  5935 #else
  5916         rslt = GetFullPathName(_aPathName, MAXPATHLEN, nameBuffer, &pFinal);
  5936 	rslt = GetFullPathName(_aPathName, MAXPATHLEN, nameBuffer, &pFinal);
  5917 #endif
  5937 #endif
  5918         if (rslt > 0) {
  5938 	if (rslt > 0) {
  5919             /*
  5939 	    /*
  5920              * Attention: GetLongPathName is not available on old NT4.0/W95/W98
  5940 	     * Attention: GetLongPathName is not available on old NT4.0/W95/W98
  5921              */
  5941 	     */
  5922             static FARPROC GetLongPathNameW_entry = NULL;
  5942 	    static FARPROC GetLongPathNameW_entry = NULL;
  5923 #ifdef NO_NT4_0_COMPATIBILITY
  5943 #ifdef NO_NT4_0_COMPATIBILITY
  5924             GetLongPathNameW_entry = (FARPROC) GetLongPathNameW;
  5944 	    GetLongPathNameW_entry = (FARPROC) GetLongPathNameW;
  5925 #else
  5945 #else
  5926             if (GetLongPathNameW_entry == NULL) {
  5946 	    if (GetLongPathNameW_entry == NULL) {
  5927                 GetLongPathNameW_entry = __get_kernel32_functionAddress("GetLongPathNameW");
  5947 		GetLongPathNameW_entry = __get_kernel32_functionAddress("GetLongPathNameW");
  5928             }
  5948 	    }
  5929 #endif /* NO_NT4_0_COMPATIBILITY */
  5949 #endif /* NO_NT4_0_COMPATIBILITY */
  5930 
  5950 
  5931             if (GetLongPathNameW_entry) {
  5951 	    if (GetLongPathNameW_entry) {
  5932 #ifdef DO_WRAP_CALLS
  5952 #ifdef DO_WRAP_CALLS
  5933                 do {
  5953 		do {
  5934                     __threadErrno = 0;
  5954 		    __threadErrno = 0;
  5935                     rslt = STX_API_NOINT_CALL3( "GetLongPathNameW", GetLongPathNameW_entry, nameBuffer, nameBuffer, MAXPATHLEN);
  5955 		    rslt = STX_API_NOINT_CALL3( "GetLongPathNameW", GetLongPathNameW_entry, nameBuffer, nameBuffer, MAXPATHLEN);
  5936                 } while ((rslt < 0) && (__threadErrno == EINTR));
  5956 		} while ((rslt < 0) && (__threadErrno == EINTR));
  5937 #else
  5957 #else
  5938                 rslt = (*GetLongPathNameW_entry)(nameBuffer, nameBuffer, MAXPATHLEN);
  5958 		rslt = (*GetLongPathNameW_entry)(nameBuffer, nameBuffer, MAXPATHLEN);
  5939 #endif
  5959 #endif
  5940             }
  5960 	    }
  5941         }
  5961 	}
  5942         if (rslt > 0) {
  5962 	if (rslt > 0) {
  5943             RETURN ( __MKU16STRING(nameBuffer) );
  5963 	    RETURN ( __MKU16STRING(nameBuffer) );
  5944         }
  5964 	}
  5945         __threadErrno = __WIN32_ERR(GetLastError());
  5965 	__threadErrno = __WIN32_ERR(GetLastError());
  5946     }
  5966     }
  5947 %}.
  5967 %}.
  5948     ^ nil
  5968     ^ nil
  5949 
  5969 
  5950     "
  5970     "
  5978 
  5998 
  5979 %{
  5999 %{
  5980     int ret;
  6000     int ret;
  5981 
  6001 
  5982     if (__isSmallInteger(anInteger)) {
  6002     if (__isSmallInteger(anInteger)) {
  5983         if (__isStringLike(aPathName)) {
  6003 	if (__isStringLike(aPathName)) {
  5984 #ifdef DO_WRAP_CALLS
  6004 #ifdef DO_WRAP_CALLS
  5985             char _aPathName[MAXPATHLEN];
  6005 	    char _aPathName[MAXPATHLEN];
  5986 
  6006 
  5987             strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  6007 	    strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  5988             do {
  6008 	    do {
  5989                 __threadErrno = 0;
  6009 		__threadErrno = 0;
  5990                 ret = STX_API_NOINT_CALL2( "SetFileAttributesA", SetFileAttributesA, _aPathName, __intVal(anInteger) );
  6010 		ret = STX_API_NOINT_CALL2( "SetFileAttributesA", SetFileAttributesA, _aPathName, __intVal(anInteger) );
  5991             } while ((ret < 0) && (__threadErrno == EINTR));
  6011 	    } while ((ret < 0) && (__threadErrno == EINTR));
  5992 #else
  6012 #else
  5993             ret = SetFileAttributesA((char *) __stringVal(aPathName), __intVal(anInteger));
  6013 	    ret = SetFileAttributesA((char *) __stringVal(aPathName), __intVal(anInteger));
  5994             if (ret < 0) {
  6014 	    if (ret < 0) {
  5995                 __threadErrno = __WIN32_ERR(GetLastError());
  6015 		__threadErrno = __WIN32_ERR(GetLastError());
  5996             }
  6016 	    }
  5997 #endif
  6017 #endif
  5998             if (ret >= 0) {
  6018 	    if (ret >= 0) {
  5999                 RETURN ( true );
  6019 		RETURN ( true );
  6000             }
  6020 	    }
  6001             __threadErrno = __WIN32_ERR(GetLastError());
  6021 	    __threadErrno = __WIN32_ERR(GetLastError());
  6002             RETURN (false);
  6022 	    RETURN (false);
  6003         }
  6023 	}
  6004 
  6024 
  6005         if (__isUnicode16String(aPathName)) {
  6025 	if (__isUnicode16String(aPathName)) {
  6006             wchar_t _wPathName[MAXPATHLEN+1];
  6026 	    wchar_t _wPathName[MAXPATHLEN+1];
  6007             int i, l;
  6027 	    int i, l;
  6008 
  6028 
  6009             l = __unicode16StringSize(aPathName);
  6029 	    l = __unicode16StringSize(aPathName);
  6010             if (l > MAXPATHLEN) l = MAXPATHLEN;
  6030 	    if (l > MAXPATHLEN) l = MAXPATHLEN;
  6011             for (i=0; i<l; i++) {
  6031 	    for (i=0; i<l; i++) {
  6012                 _wPathName[i] = __unicode16StringVal(aPathName)[i];
  6032 		_wPathName[i] = __unicode16StringVal(aPathName)[i];
  6013             }
  6033 	    }
  6014             _wPathName[i] = 0;
  6034 	    _wPathName[i] = 0;
  6015 #ifdef DO_WRAP_CALLS
  6035 #ifdef DO_WRAP_CALLS
  6016             do {
  6036 	    do {
  6017                 __threadErrno = 0;
  6037 		__threadErrno = 0;
  6018                 ret = STX_API_NOINT_CALL2( "SetFileAttributesW", SetFileAttributesW, _wPathName, __intVal(anInteger) );
  6038 		ret = STX_API_NOINT_CALL2( "SetFileAttributesW", SetFileAttributesW, _wPathName, __intVal(anInteger) );
  6019             } while ((ret < 0) && (__threadErrno == EINTR));
  6039 	    } while ((ret < 0) && (__threadErrno == EINTR));
  6020 #else
  6040 #else
  6021             ret = SetFileAttributesW(_wPathName, __intVal(anInteger));
  6041 	    ret = SetFileAttributesW(_wPathName, __intVal(anInteger));
  6022             if (ret < 0) {
  6042 	    if (ret < 0) {
  6023                 __threadErrno = __WIN32_ERR(GetLastError());
  6043 		__threadErrno = __WIN32_ERR(GetLastError());
  6024             }
  6044 	    }
  6025 #endif
  6045 #endif
  6026             if (ret >= 0) {
  6046 	    if (ret >= 0) {
  6027                 RETURN ( true );
  6047 		RETURN ( true );
  6028             }
  6048 	    }
  6029             __threadErrno = __WIN32_ERR(GetLastError());
  6049 	    __threadErrno = __WIN32_ERR(GetLastError());
  6030             RETURN (false);
  6050 	    RETURN (false);
  6031         }
  6051 	}
  6032     }
  6052     }
  6033 %}.
  6053 %}.
  6034     ^ self primitiveFailed
  6054     ^ self primitiveFailed
  6035 !
  6055 !
  6036 
  6056 
  6037 setCurrentDirectory:pathName
  6057 setCurrentDirectory:pathName
  6038     pathName bitsPerCharacter == 16 ifTrue:[
  6058     pathName bitsPerCharacter == 16 ifTrue:[
  6039         self primSetCurrentDirectoryW:(pathName copyWith:(Character value:0))
  6059 	self primSetCurrentDirectoryW:(pathName copyWith:(Character value:0))
  6040     ] ifFalse:[
  6060     ] ifFalse:[
  6041         self primSetCurrentDirectoryA:pathName
  6061 	self primSetCurrentDirectoryA:pathName
  6042     ].
  6062     ].
  6043 
  6063 
  6044     "
  6064     "
  6045      self getCurrentDirectory
  6065      self getCurrentDirectory
  6046      self setCurrentDirectory:'C:\Users\cg\work\stx\projects'
  6066      self setCurrentDirectory:'C:\Users\cg\work\stx\projects'
  6054 
  6074 
  6055     |attr|
  6075     |attr|
  6056 
  6076 
  6057     attr := self primGetFileAttributes:aPathName.
  6077     attr := self primGetFileAttributes:aPathName.
  6058     (attr bitTest:FILE_ATTRIBUTE_HIDDEN ) ifFalse:[
  6078     (attr bitTest:FILE_ATTRIBUTE_HIDDEN ) ifFalse:[
  6059         ^ self primSetFileAttributes:aPathName to:(attr bitOr:2).
  6079 	^ self primSetFileAttributes:aPathName to:(attr bitOr:2).
  6060     ].
  6080     ].
  6061     ^ true  "/ aready set
  6081     ^ true  "/ aready set
  6062 
  6082 
  6063     "Modified: / 29-07-2010 / 11:32:26 / sr"
  6083     "Modified: / 29-07-2010 / 11:32:26 / sr"
  6064 !
  6084 !
  6069 
  6089 
  6070     |attr|
  6090     |attr|
  6071 
  6091 
  6072     attr := self primGetFileAttributes:aPathName.
  6092     attr := self primGetFileAttributes:aPathName.
  6073     (attr bitTest:FILE_ATTRIBUTE_NORMAL ) ifFalse:[
  6093     (attr bitTest:FILE_ATTRIBUTE_NORMAL ) ifFalse:[
  6074         ^ self primSetFileAttributes:aPathName to:(attr bitOr:2).
  6094 	^ self primSetFileAttributes:aPathName to:(attr bitOr:2).
  6075     ].
  6095     ].
  6076     ^ true  "/ aready set
  6096     ^ true  "/ aready set
  6077 !
  6097 !
  6078 
  6098 
  6079 setTemporary:aPathName
  6099 setTemporary:aPathName
  6081 
  6101 
  6082     |attr|
  6102     |attr|
  6083 
  6103 
  6084     attr := self primGetFileAttributes:aPathName.
  6104     attr := self primGetFileAttributes:aPathName.
  6085     (attr bitTest:FILE_ATTRIBUTE_TEMPORARY ) ifFalse:[
  6105     (attr bitTest:FILE_ATTRIBUTE_TEMPORARY ) ifFalse:[
  6086         ^ self primSetFileAttributes:aPathName to:(attr bitOr:2).
  6106 	^ self primSetFileAttributes:aPathName to:(attr bitOr:2).
  6087     ].
  6107     ].
  6088     ^ true  "/ aready set
  6108     ^ true  "/ aready set
  6089 !
  6109 !
  6090 
  6110 
  6091 timeOfLastAccess:aPathName
  6111 timeOfLastAccess:aPathName
  6092     "return the time, when the file was last accessed.
  6112     "return the time, when the file was last accessed.
  6093      For nonexistent files, nil is returned."
  6113      For nonexistent files, nil is returned."
  6094 
  6114 
  6095     "could be implemented as:
  6115     "could be implemented as:
  6096         (self infoOf:aPathName) accessed
  6116 	(self infoOf:aPathName) accessed
  6097     "
  6117     "
  6098     | i|
  6118     | i|
  6099 
  6119 
  6100     i := self infoOf:aPathName.
  6120     i := self infoOf:aPathName.
  6101     i notNil ifTrue:[^ i accessTime].
  6121     i notNil ifTrue:[^ i accessTime].
  6109 timeOfLastChange:aPathName
  6129 timeOfLastChange:aPathName
  6110     "return the time, when the file was last changed.
  6130     "return the time, when the file was last changed.
  6111      For nonexistent files, nil is returned."
  6131      For nonexistent files, nil is returned."
  6112 
  6132 
  6113     "could be implemented as:
  6133     "could be implemented as:
  6114         (self infoOf:aPathName) modified
  6134 	(self infoOf:aPathName) modified
  6115     "
  6135     "
  6116 
  6136 
  6117     | i|
  6137     | i|
  6118 
  6138 
  6119     i := self infoOf:aPathName.
  6139     i := self infoOf:aPathName.
  6132 
  6152 
  6133     |i|
  6153     |i|
  6134 
  6154 
  6135     "
  6155     "
  6136      this could have been implemented as:
  6156      this could have been implemented as:
  6137         (self infoOf:aPathName) type
  6157 	(self infoOf:aPathName) type
  6138     "
  6158     "
  6139 
  6159 
  6140     i := self infoOf:aPathName.
  6160     i := self infoOf:aPathName.
  6141     i notNil ifTrue:[^ i type].
  6161     i notNil ifTrue:[^ i type].
  6142     ^ nil.
  6162     ^ nil.
  6149     "
  6169     "
  6150 !
  6170 !
  6151 
  6171 
  6152 volumeLabelOf: aFilenameOrString
  6172 volumeLabelOf: aFilenameOrString
  6153 
  6173 
  6154         "Answer the volume label of the disk containing aFilenameOrString."
  6174 	"Answer the volume label of the disk containing aFilenameOrString."
  6155 
  6175 
  6156     | volName |
  6176     | volName |
  6157 
  6177 
  6158     volName := String new: 255.
  6178     volName := String new: 255.
  6159     ( self
  6179     ( self
  6160         getVolumeInformation: aFilenameOrString asFilename volume, '\'
  6180 	getVolumeInformation: aFilenameOrString asFilename volume, '\'
  6161         name: volName
  6181 	name: volName
  6162         nameSize: volName size
  6182 	nameSize: volName size
  6163         serialNumber: nil
  6183 	serialNumber: nil
  6164         maximumComponentLength: nil
  6184 	maximumComponentLength: nil
  6165         fileSystemFlags: nil
  6185 	fileSystemFlags: nil
  6166         fileSystemName: nil
  6186 	fileSystemName: nil
  6167         fileSystemNameSize: 0 )
  6187 	fileSystemNameSize: 0 )
  6168             ifFalse: [
  6188 	    ifFalse: [
  6169                 Transcript showCR:'GetVolumeInformation error'.
  6189 		Transcript showCR:'GetVolumeInformation error'.
  6170                 ^ ''
  6190 		^ ''
  6171         ].
  6191 	].
  6172     ^ volName copyUpTo: Character null
  6192     ^ volName copyUpTo: Character null
  6173 
  6193 
  6174     "
  6194     "
  6175         self volumeLabelOf: 'C:\pepe.pep'
  6195 	self volumeLabelOf: 'C:\pepe.pep'
  6176         self volumeLabelOf: 'C:'
  6196 	self volumeLabelOf: 'C:'
  6177         self volumeLabelOf: 'C:\\'
  6197 	self volumeLabelOf: 'C:\\'
  6178         self volumeLabelOf: 'C:\'
  6198 	self volumeLabelOf: 'C:\'
  6179 
  6199 
  6180     "
  6200     "
  6181 !
  6201 !
  6182 
  6202 
  6183 volumeNameOf:aPathString
  6203 volumeNameOf:aPathString
  6186      Not all OperatingSystem support/use volumes; on unix,
  6206      Not all OperatingSystem support/use volumes; on unix,
  6187      this always returns an empty string."
  6207      this always returns an empty string."
  6188 
  6208 
  6189     aPathString size < 2 ifTrue:[^ ''].
  6209     aPathString size < 2 ifTrue:[^ ''].
  6190     (aPathString at:2) == $: ifTrue:[
  6210     (aPathString at:2) == $: ifTrue:[
  6191         ^ (aPathString at:1) asString.
  6211 	^ (aPathString at:1) asString.
  6192     ].
  6212     ].
  6193     ^ ''
  6213     ^ ''
  6194 ! !
  6214 ! !
  6195 
  6215 
  6196 !Win32OperatingSystem class methodsFor:'help support'!
  6216 !Win32OperatingSystem class methodsFor:'help support'!
  6203     "open a windows-shell application to present the document contained in aFilenameOrString.
  6223     "open a windows-shell application to present the document contained in aFilenameOrString.
  6204      This looks for the files extension, and is typically used to present help-files,
  6224      This looks for the files extension, and is typically used to present help-files,
  6205      html documents, pdf documents etc."
  6225      html documents, pdf documents etc."
  6206 
  6226 
  6207     Error
  6227     Error
  6208         handle:[:ex |
  6228 	handle:[:ex |
  6209             Dialog warn:'Shell execution failed'
  6229 	    Dialog warn:'Shell execution failed'
  6210         ] do:[
  6230 	] do:[
  6211             self openApplicationForDocument:aFilenameOrString operation:#open
  6231 	    self openApplicationForDocument:aFilenameOrString operation:#open
  6212         ]
  6232 	]
  6213 
  6233 
  6214     "
  6234     "
  6215      self openDocumentationFilename: 'C:\WINDOWS\Help\clipbrd.chm' asFilename
  6235      self openDocumentationFilename: 'C:\WINDOWS\Help\clipbrd.chm' asFilename
  6216      self openDocumentationFilename: Filename currentDirectory
  6236      self openDocumentationFilename: Filename currentDirectory
  6217     "
  6237     "
  6264     "this is a test method;
  6284     "this is a test method;
  6265      For testing double CTRL-C in blocking primitives"
  6285      For testing double CTRL-C in blocking primitives"
  6266 
  6286 
  6267 %{
  6287 %{
  6268     while(1) {
  6288     while(1) {
  6269         console_printf("blocking...");
  6289 	console_printf("blocking...");
  6270         Sleep(50);
  6290 	Sleep(50);
  6271     }
  6291     }
  6272 %}.
  6292 %}.
  6273     "
  6293     "
  6274      OperatingSystem blockingTest
  6294      OperatingSystem blockingTest
  6275     "
  6295     "
  6279     "this is a test method;
  6299     "this is a test method;
  6280      For testing single CTRL-C in blocking primitives"
  6300      For testing single CTRL-C in blocking primitives"
  6281 
  6301 
  6282 %{
  6302 %{
  6283     while(1) {
  6303     while(1) {
  6284         console_printf("blocking...");
  6304 	console_printf("blocking...");
  6285         STX_API_CALL1("Sleep", Sleep, 50);
  6305 	STX_API_CALL1("Sleep", Sleep, 50);
  6286     }
  6306     }
  6287 %}.
  6307 %}.
  6288     "
  6308     "
  6289      OperatingSystem blockingTest2
  6309      OperatingSystem blockingTest2
  6290     "
  6310     "
  6297 
  6317 
  6298 %{
  6318 %{
  6299     int ret;
  6319     int ret;
  6300 
  6320 
  6301     do {
  6321     do {
  6302         ret = STX_API_NOINT_CALL1("Sleep", Sleep, 60000);
  6322 	ret = STX_API_NOINT_CALL1("Sleep", Sleep, 60000);
  6303     } while (ret < 0 && __threadErrno == EINTR);
  6323     } while (ret < 0 && __threadErrno == EINTR);
  6304 %}.
  6324 %}.
  6305     "
  6325     "
  6306      OperatingSystem blockingTest3
  6326      OperatingSystem blockingTest3
  6307     "
  6327     "
  6314 
  6334 
  6315 %{
  6335 %{
  6316     int ret;
  6336     int ret;
  6317 
  6337 
  6318     do {
  6338     do {
  6319         ret = STX_API_CALL1("Sleep", Sleep, 60000);
  6339 	ret = STX_API_CALL1("Sleep", Sleep, 60000);
  6320     } while (ret < 0 && __threadErrno == EINTR);
  6340     } while (ret < 0 && __threadErrno == EINTR);
  6321 %}.
  6341 %}.
  6322     "
  6342     "
  6323      OperatingSystem blockingTest4
  6343      OperatingSystem blockingTest4
  6324     "
  6344     "
  6336 
  6356 
  6337 %{  /* NOCONTEXT */
  6357 %{  /* NOCONTEXT */
  6338 
  6358 
  6339     if (__isSmallInteger(signalNumber)) {
  6359     if (__isSmallInteger(signalNumber)) {
  6340 #ifdef SIG_DFL
  6360 #ifdef SIG_DFL
  6341         signal(__intVal(signalNumber), SIG_DFL);
  6361 	signal(__intVal(signalNumber), SIG_DFL);
  6342         RETURN (self);
  6362 	RETURN (self);
  6343 #endif
  6363 #endif
  6344     }
  6364     }
  6345 %}.
  6365 %}.
  6346     "
  6366     "
  6347      this error is triggered on non-integer argument
  6367      this error is triggered on non-integer argument
  6380      Use only for fully debugged stand alone applications."
  6400      Use only for fully debugged stand alone applications."
  6381 
  6401 
  6382 %{  /* NOCONTEXT */
  6402 %{  /* NOCONTEXT */
  6383 
  6403 
  6384     if (__isSmallInteger(signalNumber)) {
  6404     if (__isSmallInteger(signalNumber)) {
  6385         int sigNo = __intVal(signalNumber);
  6405 	int sigNo = __intVal(signalNumber);
  6386 
  6406 
  6387         if (sigNo == 0) {
  6407 	if (sigNo == 0) {
  6388             RETURN (self);
  6408 	    RETURN (self);
  6389         }
  6409 	}
  6390 #ifdef SIG_IGN
  6410 #ifdef SIG_IGN
  6391         signal(sigNo, SIG_IGN);
  6411 	signal(sigNo, SIG_IGN);
  6392         RETURN (self);
  6412 	RETURN (self);
  6393 #endif
  6413 #endif
  6394     }
  6414     }
  6395 %}.
  6415 %}.
  6396     "
  6416     "
  6397      this error is triggered on non-integer argument
  6417      this error is triggered on non-integer argument
  6408 !
  6428 !
  6409 
  6429 
  6410 disableTimer
  6430 disableTimer
  6411     "disable timer interrupts.
  6431     "disable timer interrupts.
  6412      WARNING:
  6432      WARNING:
  6413         the system will not operate correctly with timer interrupts
  6433 	the system will not operate correctly with timer interrupts
  6414         disabled, because no scheduling or timeouts are possible."
  6434 	disabled, because no scheduling or timeouts are possible."
  6415 
  6435 
  6416 %{  /* NOCONTEXT */
  6436 %{  /* NOCONTEXT */
  6417 
  6437 
  6418     extern void __win32ClearTimer();
  6438     extern void __win32ClearTimer();
  6419 
  6439 
  6535      && ((sigNr = __intVal(signalNumber)) >= 0)
  6555      && ((sigNr = __intVal(signalNumber)) >= 0)
  6536 #ifdef SIG_LIMIT
  6556 #ifdef SIG_LIMIT
  6537      &&  (sigNr <= SIG_LIMIT)
  6557      &&  (sigNr <= SIG_LIMIT)
  6538 #endif
  6558 #endif
  6539     ) {
  6559     ) {
  6540         /*
  6560 	/*
  6541          * standard signals are forced into standard handlers
  6561 	 * standard signals are forced into standard handlers
  6542          * - all others go into general signalInterrupt
  6562 	 * - all others go into general signalInterrupt
  6543          */
  6563 	 */
  6544 #if defined(SIGPOLL) && defined(SIGIO)
  6564 #if defined(SIGPOLL) && defined(SIGIO)
  6545         if (sigNr == SIGPOLL)
  6565 	if (sigNr == SIGPOLL)
  6546             sigNr = SIGIO;
  6566 	    sigNr = SIGIO;
  6547 #endif
  6567 #endif
  6548         switch (sigNr) {
  6568 	switch (sigNr) {
  6549             case 0:
  6569 	    case 0:
  6550                 /* enabling a non-supported signal */
  6570 		/* enabling a non-supported signal */
  6551                 RETURN (self);
  6571 		RETURN (self);
  6552 
  6572 
  6553 #ifdef SIGBREAK
  6573 #ifdef SIGBREAK
  6554             case SIGBREAK:
  6574 	    case SIGBREAK:
  6555 #endif
  6575 #endif
  6556 #ifdef SIGINT
  6576 #ifdef SIGINT
  6557             case SIGINT:
  6577 	    case SIGINT:
  6558 #endif
  6578 #endif
  6559 #ifdef SIGQUIT
  6579 #ifdef SIGQUIT
  6560             case SIGQUIT:
  6580 	    case SIGQUIT:
  6561 #endif
  6581 #endif
  6562 #ifdef SIGNALDEBUGWIN32
  6582 #ifdef SIGNALDEBUGWIN32
  6563                 console_printf("ConsoleSignal %d\n",sigNr);
  6583 		console_printf("ConsoleSignal %d\n",sigNr);
  6564 #endif
  6584 #endif
  6565                 SetConsoleCtrlHandler((PHANDLER_ROUTINE)__signalUserInterruptWIN32,TRUE);
  6585 		SetConsoleCtrlHandler((PHANDLER_ROUTINE)__signalUserInterruptWIN32,TRUE);
  6566                 RETURN (self);
  6586 		RETURN (self);
  6567 #ifdef SIGFPE
  6587 #ifdef SIGFPE
  6568             case SIGFPE:
  6588 	    case SIGFPE:
  6569                 handler = __signalFpExceptionInterrupt;
  6589 		handler = __signalFpExceptionInterrupt;
  6570                 break;
  6590 		break;
  6571 #endif
  6591 #endif
  6572 
  6592 
  6573 #ifdef SIGPIPE
  6593 #ifdef SIGPIPE
  6574             case SIGPIPE:
  6594 	    case SIGPIPE:
  6575                 handler = __signalPIPEInterrupt;
  6595 		handler = __signalPIPEInterrupt;
  6576                 break;
  6596 		break;
  6577 #endif
  6597 #endif
  6578 #ifdef SIGBUS
  6598 #ifdef SIGBUS
  6579             case SIGBUS:
  6599 	    case SIGBUS:
  6580                 handler = __signalBUSInterrupt;
  6600 		handler = __signalBUSInterrupt;
  6581                 break;
  6601 		break;
  6582 #endif
  6602 #endif
  6583 #ifdef SIGSEGV
  6603 #ifdef SIGSEGV
  6584             case SIGSEGV:
  6604 	    case SIGSEGV:
  6585                 handler = __signalSEGVInterrupt;
  6605 		handler = __signalSEGVInterrupt;
  6586                 break;
  6606 		break;
  6587 #endif
  6607 #endif
  6588 #ifdef SIGILL
  6608 #ifdef SIGILL
  6589             case SIGILL:
  6609 	    case SIGILL:
  6590                 handler = __signalTrapInterrupt;
  6610 		handler = __signalTrapInterrupt;
  6591                 break;
  6611 		break;
  6592 #endif
  6612 #endif
  6593 #ifdef SIGEMT
  6613 #ifdef SIGEMT
  6594             case SIGEMT:
  6614 	    case SIGEMT:
  6595                 handler = __signalTrapInterrupt;
  6615 		handler = __signalTrapInterrupt;
  6596                 break;
  6616 		break;
  6597 #endif
  6617 #endif
  6598 #ifdef SIGIO
  6618 #ifdef SIGIO
  6599             case SIGIO:
  6619 	    case SIGIO:
  6600                 handler = __signalIoInterrupt;
  6620 		handler = __signalIoInterrupt;
  6601                 break;
  6621 		break;
  6602 #endif
  6622 #endif
  6603 
  6623 
  6604 #ifdef CHILD_SIGNAL
  6624 #ifdef CHILD_SIGNAL
  6605             case CHILD_SIGNAL:
  6625 	    case CHILD_SIGNAL:
  6606                 handler = __signalChildInterrupt;
  6626 		handler = __signalChildInterrupt;
  6607                 break;
  6627 		break;
  6608 #endif
  6628 #endif
  6609 
  6629 
  6610             default:
  6630 	    default:
  6611                 handler = __signalInterrupt;
  6631 		handler = __signalInterrupt;
  6612                 break;
  6632 		break;
  6613         }
  6633 	}
  6614 
  6634 
  6615         {
  6635 	{
  6616 #ifdef HAS_SIGACTION
  6636 #ifdef HAS_SIGACTION
  6617             struct sigaction act;
  6637 	    struct sigaction act;
  6618 
  6638 
  6619             /*
  6639 	    /*
  6620              * Do not add SA_RESTART here. A signal can cause a
  6640 	     * Do not add SA_RESTART here. A signal can cause a
  6621              * thread switch, another thread can do a garbage collect
  6641 	     * thread switch, another thread can do a garbage collect
  6622              * and restarted system calls may write into old
  6642 	     * and restarted system calls may write into old
  6623              * (collected) addresses.
  6643 	     * (collected) addresses.
  6624              */
  6644 	     */
  6625 
  6645 
  6626             act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
  6646 	    act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
  6627             sigemptyset(&act.sa_mask);
  6647 	    sigemptyset(&act.sa_mask);
  6628             act.sa_handler = handler;
  6648 	    act.sa_handler = handler;
  6629             sigaction(sigNr, &act, 0);
  6649 	    sigaction(sigNr, &act, 0);
  6630 #else
  6650 #else
  6631 # ifdef HAS_SIGVEC
  6651 # ifdef HAS_SIGVEC
  6632             struct sigvec vec;
  6652 	    struct sigvec vec;
  6633 
  6653 
  6634             vec.sv_flags = SV_INTERRUPT;
  6654 	    vec.sv_flags = SV_INTERRUPT;
  6635             sigemptyset(&vec.sv_mask);
  6655 	    sigemptyset(&vec.sv_mask);
  6636             vec.sv_handler = handler;
  6656 	    vec.sv_handler = handler;
  6637             sigvec(sigNr, &vec, NULL);
  6657 	    sigvec(sigNr, &vec, NULL);
  6638 # else
  6658 # else
  6639 #  ifdef WIN32
  6659 #  ifdef WIN32
  6640 #   ifdef SIGNALDEBUGWIN32
  6660 #   ifdef SIGNALDEBUGWIN32
  6641             console_printf("signal %d can't change handler\n",sigNr);
  6661 	    console_printf("signal %d can't change handler\n",sigNr);
  6642 #   endif
  6662 #   endif
  6643 #  else
  6663 #  else
  6644             (void) signal(sigNr, handler);
  6664 	    (void) signal(sigNr, handler);
  6645 #  endif
  6665 #  endif
  6646 # endif
  6666 # endif
  6647 #endif
  6667 #endif
  6648         }
  6668 	}
  6649 
  6669 
  6650         /*
  6670 	/*
  6651          * maybe, we should Return the old enable-status
  6671 	 * maybe, we should Return the old enable-status
  6652          * as boolean here ...
  6672 	 * as boolean here ...
  6653          */
  6673 	 */
  6654         RETURN (self);
  6674 	RETURN (self);
  6655     }
  6675     }
  6656 %}.
  6676 %}.
  6657 
  6677 
  6658     "
  6678     "
  6659      this error is triggered on non-integer argument, or
  6679      this error is triggered on non-integer argument, or
  6667 
  6687 
  6668 %{  /* NOCONTEXT */
  6688 %{  /* NOCONTEXT */
  6669     extern void __win32SetTimer();
  6689     extern void __win32SetTimer();
  6670 
  6690 
  6671     if (__isSmallInteger(milliSeconds)) {
  6691     if (__isSmallInteger(milliSeconds)) {
  6672         __win32SetTimer( __intVal(milliSeconds) );
  6692 	__win32SetTimer( __intVal(milliSeconds) );
  6673         RETURN (true);
  6693 	RETURN (true);
  6674     }
  6694     }
  6675 %}.
  6695 %}.
  6676     ^ false
  6696     ^ false
  6677 !
  6697 !
  6678 
  6698 
  6688 killProcess:processId
  6708 killProcess:processId
  6689     "kill a process.
  6709     "kill a process.
  6690      The process terminates immediately and has no chance to perform any cleanup actions.
  6710      The process terminates immediately and has no chance to perform any cleanup actions.
  6691 
  6711 
  6692      WARNING: in order to avoid zombie processes (on unix),
  6712      WARNING: in order to avoid zombie processes (on unix),
  6693               you have to fetch the processes exitstatus with
  6713 	      you have to fetch the processes exitstatus with
  6694               OperatingSystem>>getStatusOfProcess:aProcessId."
  6714 	      OperatingSystem>>getStatusOfProcess:aProcessId."
  6695 
  6715 
  6696     self terminateProcess:processId
  6716     self terminateProcess:processId
  6697 !
  6717 !
  6698 
  6718 
  6699 sendSignal:signalNumber to:processId
  6719 sendSignal:signalNumber to:processId
  6701      Returns false if any error occurred, true otherwise.
  6721      Returns false if any error occurred, true otherwise.
  6702 
  6722 
  6703      Do not confuse UNIX signals with Smalltalk-Signals.
  6723      Do not confuse UNIX signals with Smalltalk-Signals.
  6704 
  6724 
  6705      WARNING: in order to avoid zombie processes (on unix),
  6725      WARNING: in order to avoid zombie processes (on unix),
  6706               you may have to fetch the processes exitstatus with
  6726 	      you may have to fetch the processes exitstatus with
  6707               OperatingSystem>>getStatusOfProcess:aProcessId
  6727 	      OperatingSystem>>getStatusOfProcess:aProcessId
  6708               if the signal terminates that process."
  6728 	      if the signal terminates that process."
  6709 
  6729 
  6710     "/
  6730     "/
  6711     "/ either invalid argument (non-integers)
  6731     "/ either invalid argument (non-integers)
  6712     "/ or not supported by OS
  6732     "/ or not supported by OS
  6713     "/
  6733     "/
  6716 
  6736 
  6717 terminateProcess:processHandleOrPid
  6737 terminateProcess:processHandleOrPid
  6718     "terminate a process.
  6738     "terminate a process.
  6719      The process has a chance to do some cleanup.
  6739      The process has a chance to do some cleanup.
  6720      WIN32:
  6740      WIN32:
  6721          Under unix, we have terminateProcess, which does a soft
  6741 	 Under unix, we have terminateProcess, which does a soft
  6722          terminate (giving the process a chance to cleanup) and
  6742 	 terminate (giving the process a chance to cleanup) and
  6723          killProcess, which does a hard terminate.
  6743 	 killProcess, which does a hard terminate.
  6724          Under WIN32, both (currently) use the TerminateProcess
  6744 	 Under WIN32, both (currently) use the TerminateProcess
  6725          function, which unconditionally causes a process to exit.
  6745 	 function, which unconditionally causes a process to exit.
  6726          I.e. under WIN32, the process has no chance to perform cleanup.
  6746 	 I.e. under WIN32, the process has no chance to perform cleanup.
  6727          Use it only in extreme circumstances. The state of
  6747 	 Use it only in extreme circumstances. The state of
  6728          global data maintained by dynamic-link libraries (DLLs)
  6748 	 global data maintained by dynamic-link libraries (DLLs)
  6729          may be compromised if TerminateProcess is used.
  6749 	 may be compromised if TerminateProcess is used.
  6730      TODO: send it a WM_QUIT instead, to allow for proper shutdown."
  6750      TODO: send it a WM_QUIT instead, to allow for proper shutdown."
  6731 
  6751 
  6732     self terminateProcess:processHandleOrPid exitCode:0
  6752     self terminateProcess:processHandleOrPid exitCode:0
  6733 !
  6753 !
  6734 
  6754 
  6735 terminateProcess:processHandleOrPid exitCode:exitCode
  6755 terminateProcess:processHandleOrPid exitCode:exitCode
  6736     "terminate a process.
  6756     "terminate a process.
  6737      The process should have a chance to do some cleanup.
  6757      The process should have a chance to do some cleanup.
  6738      WIN32:
  6758      WIN32:
  6739          Under unix, we have terminateProcess, which does a soft
  6759 	 Under unix, we have terminateProcess, which does a soft
  6740          terminate (giving the process a chance to cleanup) and
  6760 	 terminate (giving the process a chance to cleanup) and
  6741          killProcess, which does a hard terminate.
  6761 	 killProcess, which does a hard terminate.
  6742          Under WIN32, both (currently) use the TerminateProcess
  6762 	 Under WIN32, both (currently) use the TerminateProcess
  6743          function, which unconditionally causes a process to exit.
  6763 	 function, which unconditionally causes a process to exit.
  6744          I.e. under WIN32, the process has no chance to perform cleanup.
  6764 	 I.e. under WIN32, the process has no chance to perform cleanup.
  6745          Use it only in extreme circumstances. The state of
  6765 	 Use it only in extreme circumstances. The state of
  6746          global data maintained by dynamic-link libraries (DLLs)
  6766 	 global data maintained by dynamic-link libraries (DLLs)
  6747          may be compromised if TerminateProcess is used.
  6767 	 may be compromised if TerminateProcess is used.
  6748      TODO: send it a WM_QUIT instead, to allow for proper shutdown."
  6768      TODO: send it a WM_QUIT instead, to allow for proper shutdown."
  6749 
  6769 
  6750 %{
  6770 %{
  6751     if (__isExternalAddressLike(processHandleOrPid) ) {
  6771     if (__isExternalAddressLike(processHandleOrPid) ) {
  6752         HANDLE hProcess = _HANDLEVal(processHandleOrPid);
  6772 	HANDLE hProcess = _HANDLEVal(processHandleOrPid);
  6753 
  6773 
  6754         if (hProcess != 0) {
  6774 	if (hProcess != 0) {
  6755             TerminateProcess( hProcess, __intVal(exitCode) );
  6775 	    TerminateProcess( hProcess, __intVal(exitCode) );
  6756         }
  6776 	}
  6757         RETURN( true );
  6777 	RETURN( true );
  6758     } else if( __isSmallInteger(processHandleOrPid) ) {
  6778     } else if( __isSmallInteger(processHandleOrPid) ) {
  6759         HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, 0, __smallIntegerVal(processHandleOrPid));
  6779 	HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, 0, __smallIntegerVal(processHandleOrPid));
  6760 
  6780 
  6761         if( hProcess != 0 ) {
  6781 	if( hProcess != 0 ) {
  6762             TerminateProcess( hProcess, __intVal(exitCode) );
  6782 	    TerminateProcess( hProcess, __intVal(exitCode) );
  6763             CloseHandle(hProcess);
  6783 	    CloseHandle(hProcess);
  6764         }
  6784 	}
  6765         RETURN( true );
  6785 	RETURN( true );
  6766     }
  6786     }
  6767 %}.
  6787 %}.
  6768     self primitiveFailed:#invalidParameter.
  6788     self primitiveFailed:#invalidParameter.
  6769 
  6789 
  6770 
  6790 
  6774 
  6794 
  6775 terminateProcessGroup:processGroupHandleOrPid
  6795 terminateProcessGroup:processGroupHandleOrPid
  6776     "terminate a process group.
  6796     "terminate a process group.
  6777      The processes should have a chance to do some cleanup.
  6797      The processes should have a chance to do some cleanup.
  6778      WIN32:
  6798      WIN32:
  6779          The processGroup is terminated by sending it a CTRL-C
  6799 	 The processGroup is terminated by sending it a CTRL-C
  6780          using GenerateConsoleCtrlEvent."
  6800 	 using GenerateConsoleCtrlEvent."
  6781 
  6801 
  6782     | pid list |
  6802     | pid list |
  6783 
  6803 
  6784     list := self getAllProcesses.
  6804     list := self getAllProcesses.
  6785     list size == 0 ifTrue:[^ self ].
  6805     list size == 0 ifTrue:[^ self ].
  6786 
  6806 
  6787     processGroupHandleOrPid isInteger ifTrue:[
  6807     processGroupHandleOrPid isInteger ifTrue:[
  6788         pid := processGroupHandleOrPid
  6808 	pid := processGroupHandleOrPid
  6789     ] ifFalse:[
  6809     ] ifFalse:[
  6790         pid := processGroupHandleOrPid pid.
  6810 	pid := processGroupHandleOrPid pid.
  6791     ].
  6811     ].
  6792     list do:[:anOSProcess |
  6812     list do:[:anOSProcess |
  6793         ( anOSProcess parentPid == pid ) ifTrue:[
  6813 	( anOSProcess parentPid == pid ) ifTrue:[
  6794             self terminateProcess:( anOSProcess pid ).
  6814 	    self terminateProcess:( anOSProcess pid ).
  6795         ].
  6815 	].
  6796     ].
  6816     ].
  6797 
  6817 
  6798 ! !
  6818 ! !
  6799 
  6819 
  6800 !Win32OperatingSystem class methodsFor:'ipc support'!
  6820 !Win32OperatingSystem class methodsFor:'ipc support'!
  6817     sa.nLength = sizeof(SECURITY_ATTRIBUTES);
  6837     sa.nLength = sizeof(SECURITY_ATTRIBUTES);
  6818     sa.lpSecurityDescriptor = NULL;
  6838     sa.lpSecurityDescriptor = NULL;
  6819     sa.bInheritHandle = TRUE;
  6839     sa.bInheritHandle = TRUE;
  6820 
  6840 
  6821     if( ! CreatePipe( &pipeRead, &pipeWrite, &sa, 0 ) ) {
  6841     if( ! CreatePipe( &pipeRead, &pipeWrite, &sa, 0 ) ) {
  6822         @global(LastErrorNumber) = error = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
  6842 	@global(LastErrorNumber) = error = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
  6823         goto out;
  6843 	goto out;
  6824     }
  6844     }
  6825 
  6845 
  6826 #if 1
  6846 #if 1
  6827     fd1 = __MKEXTERNALADDRESS(pipeRead);
  6847     fd1 = __MKEXTERNALADDRESS(pipeRead);
  6828     fd2 = __MKEXTERNALADDRESS(pipeWrite);
  6848     fd2 = __MKEXTERNALADDRESS(pipeWrite);
  6838     fd2 = __mkSmallInteger(_open_osfhandle(pipeWrite, O_BINARY));
  6858     fd2 = __mkSmallInteger(_open_osfhandle(pipeWrite, O_BINARY));
  6839 #endif
  6859 #endif
  6840 out:;
  6860 out:;
  6841 %}.
  6861 %}.
  6842     (fd1 notNil and:[fd2 notNil]) ifTrue:[
  6862     (fd1 notNil and:[fd2 notNil]) ifTrue:[
  6843         (fd1 ~~ -1 and:[fd2 ~~ -1]) ifTrue:[
  6863 	(fd1 ~~ -1 and:[fd2 ~~ -1]) ifTrue:[
  6844             ^ Array with:fd1 with:fd2.
  6864 	    ^ Array with:fd1 with:fd2.
  6845         ].
  6865 	].
  6846     ].
  6866     ].
  6847 
  6867 
  6848     ^ nil
  6868     ^ nil
  6849 ! !
  6869 ! !
  6850 
  6870 
  6852 
  6872 
  6853 closePid:pid
  6873 closePid:pid
  6854     "free pid resource"
  6874     "free pid resource"
  6855 %{
  6875 %{
  6856     if (__isExternalAddressLike(pid) ) {
  6876     if (__isExternalAddressLike(pid) ) {
  6857         HANDLE __pid = _HANDLEVal(pid);
  6877 	HANDLE __pid = _HANDLEVal(pid);
  6858 
  6878 
  6859         if (__pid != 0) {
  6879 	if (__pid != 0) {
  6860 #ifdef PROCESSDEBUGWIN32
  6880 #ifdef PROCESSDEBUGWIN32
  6861             console_printf("Close ProcessHandle %x\n", __pid);
  6881 	    console_printf("Close ProcessHandle %x\n", __pid);
  6862 #endif
  6882 #endif
  6863             CloseHandle(__pid);
  6883 	    CloseHandle(__pid);
  6864             _HANDLEVal(pid) = 0;
  6884 	    _HANDLEVal(pid) = 0;
  6865         }
  6885 	}
  6866     }
  6886     }
  6867 %}.
  6887 %}.
  6868     ^ true.
  6888     ^ true.
  6869 
  6889 
  6870     "Created: 28.1.1998 / 14:23:04 / md"
  6890     "Created: 28.1.1998 / 14:23:04 / md"
  6875     |hMe spaceForTargetHandle rslt|
  6895     |hMe spaceForTargetHandle rslt|
  6876 
  6896 
  6877     spaceForTargetHandle := ExternalLong new.
  6897     spaceForTargetHandle := ExternalLong new.
  6878     hMe := self getCurrentProcess.
  6898     hMe := self getCurrentProcess.
  6879     rslt := self
  6899     rslt := self
  6880                 primDuplicateHandle_hSourcProcessHandle:hMe
  6900 		primDuplicateHandle_hSourcProcessHandle:hMe
  6881                 hSourceHandle:aHandle
  6901 		hSourceHandle:aHandle
  6882                 hTargetProcesshandle:targetProcessHandle
  6902 		hTargetProcesshandle:targetProcessHandle
  6883                 lpTargetHandle:spaceForTargetHandle
  6903 		lpTargetHandle:spaceForTargetHandle
  6884                 dwDesiredAccess:0
  6904 		dwDesiredAccess:0
  6885                 bInheritHandle:false
  6905 		bInheritHandle:false
  6886                 dwOptions:2 "DUPLICATE_SAME_ACCESS".
  6906 		dwOptions:2 "DUPLICATE_SAME_ACCESS".
  6887 
  6907 
  6888     rslt ifFalse:[
  6908     rslt ifFalse:[
  6889         self primitiveFailed.
  6909 	self primitiveFailed.
  6890         ^ nil
  6910 	^ nil
  6891     ].
  6911     ].
  6892     ^ ExternalAddress newAddress:(spaceForTargetHandle value).
  6912     ^ ExternalAddress newAddress:(spaceForTargetHandle value).
  6893 
  6913 
  6894     "Created: / 18-09-2007 / 16:34:25 / cg"
  6914     "Created: / 18-09-2007 / 16:34:25 / cg"
  6895 !
  6915 !
  6907     HANDLE hProcessSnap;
  6927     HANDLE hProcessSnap;
  6908     PROCESSENTRY32 pe32;
  6928     PROCESSENTRY32 pe32;
  6909     hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  6929     hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  6910 
  6930 
  6911     if( hProcessSnap != INVALID_HANDLE_VALUE ) {
  6931     if( hProcessSnap != INVALID_HANDLE_VALUE ) {
  6912         pe32.dwSize = sizeof(PROCESSENTRY32);
  6932 	pe32.dwSize = sizeof(PROCESSENTRY32);
  6913         Process32First( hProcessSnap, & pe32 );
  6933 	Process32First( hProcessSnap, & pe32 );
  6914 
  6934 
  6915         do {
  6935 	do {
  6916             st_perProc = __SSEND0(@global(OSProcess), @symbol(new), 0);
  6936 	    st_perProc = __SSEND0(@global(OSProcess), @symbol(new), 0);
  6917 
  6937 
  6918             __SSEND1(st_perProc, @symbol(commandLine:), 0, __MKSTRING(pe32.szExeFile) );
  6938 	    __SSEND1(st_perProc, @symbol(commandLine:), 0, __MKSTRING(pe32.szExeFile) );
  6919             __SSEND1(st_perProc, @symbol(pid:), 0, __mkSmallInteger(pe32.th32ProcessID) );
  6939 	    __SSEND1(st_perProc, @symbol(pid:), 0, __mkSmallInteger(pe32.th32ProcessID) );
  6920             __SSEND1(st_perProc, @symbol(parentPid:), 0, __mkSmallInteger(pe32.th32ParentProcessID) );
  6940 	    __SSEND1(st_perProc, @symbol(parentPid:), 0, __mkSmallInteger(pe32.th32ParentProcessID) );
  6921 
  6941 
  6922             __SSEND1(list, @symbol(add:), 0, st_perProc );
  6942 	    __SSEND1(list, @symbol(add:), 0, st_perProc );
  6923         }
  6943 	}
  6924         while(Process32Next(hProcessSnap,&pe32));
  6944 	while(Process32Next(hProcessSnap,&pe32));
  6925         CloseHandle( hProcessSnap );
  6945 	CloseHandle( hProcessSnap );
  6926     }
  6946     }
  6927 
  6947 
  6928 #endif  /* TLHELP32_H_INCLUDE */
  6948 #endif  /* TLHELP32_H_INCLUDE */
  6929 
  6949 
  6930 %}.
  6950 %}.
  6941     "Created: / 18-09-2007 / 16:32:22 / cg"
  6961     "Created: / 18-09-2007 / 16:32:22 / cg"
  6942 !
  6962 !
  6943 
  6963 
  6944 getPrivateProfileString:appNameString key:keyNameString default:defaultString fileName:fileName
  6964 getPrivateProfileString:appNameString key:keyNameString default:defaultString fileName:fileName
  6945     ^ self
  6965     ^ self
  6946         getProfileString:appNameString key:keyNameString default:defaultString
  6966 	getProfileString:appNameString key:keyNameString default:defaultString
  6947         fileName:fileName private:true
  6967 	fileName:fileName private:true
  6948 
  6968 
  6949     "Modified: / 27-07-2006 / 11:57:03 / fm"
  6969     "Modified: / 27-07-2006 / 11:57:03 / fm"
  6950 !
  6970 !
  6951 
  6971 
  6952 getProfileString:appNameString key:keyNameString default:defaultString
  6972 getProfileString:appNameString key:keyNameString default:defaultString
  6960     int bufferSize = sizeof(quickBuffer);
  6980     int bufferSize = sizeof(quickBuffer);
  6961     int nChars;
  6981     int nChars;
  6962     OBJ retVal;
  6982     OBJ retVal;
  6963 
  6983 
  6964     if (__isStringLike(appNameString)) {
  6984     if (__isStringLike(appNameString)) {
  6965         __appNameString = __stringVal(appNameString);
  6985 	__appNameString = __stringVal(appNameString);
  6966     } else if (appNameString != nil)
  6986     } else if (appNameString != nil)
  6967         goto primitiveFail;
  6987 	goto primitiveFail;
  6968 
  6988 
  6969     if (__isStringLike(keyNameString)) {
  6989     if (__isStringLike(keyNameString)) {
  6970         __keyNameString = __stringVal(keyNameString);
  6990 	__keyNameString = __stringVal(keyNameString);
  6971     } else if (keyNameString != nil)
  6991     } else if (keyNameString != nil)
  6972         goto primitiveFail;
  6992 	goto primitiveFail;
  6973 
  6993 
  6974     if (__isStringLike(defaultString)) {
  6994     if (__isStringLike(defaultString)) {
  6975         __defaultString = __stringVal(defaultString);
  6995 	__defaultString = __stringVal(defaultString);
  6976     } else if (defaultString != nil)
  6996     } else if (defaultString != nil)
  6977         goto primitiveFail;
  6997 	goto primitiveFail;
  6978 
  6998 
  6979     do {
  6999     do {
  6980         nChars = GetProfileString(__appNameString, __keyNameString, __defaultString, usedBuffer, bufferSize);
  7000 	nChars = GetProfileString(__appNameString, __keyNameString, __defaultString, usedBuffer, bufferSize);
  6981         if (nChars >= 0) {
  7001 	if (nChars >= 0) {
  6982             if (nChars != bufferSize-1) {
  7002 	    if (nChars != bufferSize-1) {
  6983                 retVal = __MKSTRING_L(usedBuffer, nChars);
  7003 		retVal = __MKSTRING_L(usedBuffer, nChars);
  6984                 if (usedBuffer != quickBuffer) free(usedBuffer);
  7004 		if (usedBuffer != quickBuffer) free(usedBuffer);
  6985                 RETURN (retVal);
  7005 		RETURN (retVal);
  6986             }
  7006 	    }
  6987 
  7007 
  6988             {
  7008 	    {
  6989                 /* use a bigger buffer */
  7009 		/* use a bigger buffer */
  6990                 char *newBuffer;
  7010 		char *newBuffer;
  6991                 int newBufferSize = bufferSize * 2;
  7011 		int newBufferSize = bufferSize * 2;
  6992 
  7012 
  6993                 newBuffer = (char *)malloc( newBufferSize );
  7013 		newBuffer = (char *)malloc( newBufferSize );
  6994                 if (usedBuffer != quickBuffer) free(usedBuffer);
  7014 		if (usedBuffer != quickBuffer) free(usedBuffer);
  6995                 usedBuffer = newBuffer;
  7015 		usedBuffer = newBuffer;
  6996                 bufferSize = newBufferSize;
  7016 		bufferSize = newBufferSize;
  6997             }
  7017 	    }
  6998         }
  7018 	}
  6999 
  7019 
  7000     } while (nChars > 0);
  7020     } while (nChars > 0);
  7001     RETURN (nil);
  7021     RETURN (nil);
  7002   primitiveFail: ;
  7022   primitiveFail: ;
  7003 %}.
  7023 %}.
  7018     int bufferSize = sizeof(quickBuffer);
  7038     int bufferSize = sizeof(quickBuffer);
  7019     int nChars;
  7039     int nChars;
  7020     OBJ retVal;
  7040     OBJ retVal;
  7021 
  7041 
  7022     if (__isStringLike(appNameString)) {
  7042     if (__isStringLike(appNameString)) {
  7023         __appNameString = __stringVal(appNameString);
  7043 	__appNameString = __stringVal(appNameString);
  7024     } else if (appNameString != nil)
  7044     } else if (appNameString != nil)
  7025         goto primitiveFail;
  7045 	goto primitiveFail;
  7026 
  7046 
  7027     if (__isStringLike(keyNameString)) {
  7047     if (__isStringLike(keyNameString)) {
  7028         __keyNameString = __stringVal(keyNameString);
  7048 	__keyNameString = __stringVal(keyNameString);
  7029     } else if (keyNameString != nil)
  7049     } else if (keyNameString != nil)
  7030         goto primitiveFail;
  7050 	goto primitiveFail;
  7031 
  7051 
  7032     if (__isStringLike(defaultString)) {
  7052     if (__isStringLike(defaultString)) {
  7033         __defaultString = __stringVal(defaultString);
  7053 	__defaultString = __stringVal(defaultString);
  7034     } else if (defaultString != nil)
  7054     } else if (defaultString != nil)
  7035         goto primitiveFail;
  7055 	goto primitiveFail;
  7036 
  7056 
  7037     if (private == true) {
  7057     if (private == true) {
  7038         if (! __isStringLike(fileName)) goto primitiveFail;
  7058 	if (! __isStringLike(fileName)) goto primitiveFail;
  7039         __fileName = __stringVal(fileName);
  7059 	__fileName = __stringVal(fileName);
  7040     }
  7060     }
  7041 
  7061 
  7042     do {
  7062     do {
  7043         if (private == true) {
  7063 	if (private == true) {
  7044             nChars = GetPrivateProfileString(__appNameString, __keyNameString, __defaultString, usedBuffer, bufferSize, __fileName);
  7064 	    nChars = GetPrivateProfileString(__appNameString, __keyNameString, __defaultString, usedBuffer, bufferSize, __fileName);
  7045         } else {
  7065 	} else {
  7046             nChars = GetProfileString(__appNameString, __keyNameString, __defaultString, usedBuffer, bufferSize);
  7066 	    nChars = GetProfileString(__appNameString, __keyNameString, __defaultString, usedBuffer, bufferSize);
  7047         }
  7067 	}
  7048         if (nChars >= 0) {
  7068 	if (nChars >= 0) {
  7049             if (nChars != bufferSize-1) {
  7069 	    if (nChars != bufferSize-1) {
  7050                 retVal = __MKSTRING_L(usedBuffer, nChars);
  7070 		retVal = __MKSTRING_L(usedBuffer, nChars);
  7051                 if (usedBuffer != quickBuffer) free(usedBuffer);
  7071 		if (usedBuffer != quickBuffer) free(usedBuffer);
  7052                 RETURN (retVal);
  7072 		RETURN (retVal);
  7053             }
  7073 	    }
  7054 
  7074 
  7055             {
  7075 	    {
  7056                 /* use a bigger buffer */
  7076 		/* use a bigger buffer */
  7057                 char *newBuffer;
  7077 		char *newBuffer;
  7058                 int newBufferSize = bufferSize * 2;
  7078 		int newBufferSize = bufferSize * 2;
  7059 
  7079 
  7060                 newBuffer = (char *)malloc( newBufferSize );
  7080 		newBuffer = (char *)malloc( newBufferSize );
  7061                 if (usedBuffer != quickBuffer) free(usedBuffer);
  7081 		if (usedBuffer != quickBuffer) free(usedBuffer);
  7062                 usedBuffer = newBuffer;
  7082 		usedBuffer = newBuffer;
  7063                 bufferSize = newBufferSize;
  7083 		bufferSize = newBufferSize;
  7064             }
  7084 	    }
  7065         }
  7085 	}
  7066 
  7086 
  7067     } while (nChars > 0);
  7087     } while (nChars > 0);
  7068     RETURN (nil);
  7088     RETURN (nil);
  7069   primitiveFail: ;
  7089   primitiveFail: ;
  7070 %}.
  7090 %}.
  7089 
  7109 
  7090 multiByteToWideCharCp: cp flags: flags lpstr: lpstr cchstr: cchstr lpwstr: lpwstr cchwstr: cchwstr
  7110 multiByteToWideCharCp: cp flags: flags lpstr: lpstr cchstr: cchstr lpwstr: lpwstr cchwstr: cchwstr
  7091     "Convert the multi-byte string encoding in <lpstr> to a Unicode encoding in <lpwstr>."
  7111     "Convert the multi-byte string encoding in <lpstr> to a Unicode encoding in <lpwstr>."
  7092 
  7112 
  7093     " int MultiByteToWideChar(
  7113     " int MultiByteToWideChar(
  7094         UINT  CodePage,    // code page
  7114 	UINT  CodePage,    // code page
  7095         DWORD  dwFlags,    // character-type options
  7115 	DWORD  dwFlags,    // character-type options
  7096         LPCSTR  lpMultiByteStr,    // address of string to map
  7116 	LPCSTR  lpMultiByteStr,    // address of string to map
  7097         int  cchMultiByte,    // number of characters in string
  7117 	int  cchMultiByte,    // number of characters in string
  7098         LPWSTR  lpWideCharStr,    // address of wide-character buffer
  7118 	LPWSTR  lpWideCharStr,    // address of wide-character buffer
  7099         int  cchWideChar     // size of buffer
  7119 	int  cchWideChar     // size of buffer
  7100         );"
  7120 	);"
  7101 
  7121 
  7102     <apicall: ulongReturn "MultiByteToWideChar" ( uint32 uint32 structIn int32 structOut int32) module: "kernel32.dll" >
  7122     <apicall: ulongReturn "MultiByteToWideChar" ( uint32 uint32 structIn int32 structOut int32) module: "kernel32.dll" >
  7103     ^self primitiveFailed
  7123     ^self primitiveFailed
  7104 
  7124 
  7105     "Modified (comment): / 12-08-2011 / 16:37:06 / cg"
  7125     "Modified (comment): / 12-08-2011 / 16:37:06 / cg"
  7114 "/#define SND_LOOP            0x0008  /* loop the sound until next sndPlaySound */
  7134 "/#define SND_LOOP            0x0008  /* loop the sound until next sndPlaySound */
  7115 "/#define SND_NOSTOP          0x0010  /* don't stop any currently playing sound */
  7135 "/#define SND_NOSTOP          0x0010  /* don't stop any currently playing sound */
  7116 
  7136 
  7117     "
  7137     "
  7118      self
  7138      self
  7119         playSound:'C:\Dokumente und Einstellungen\cg\work\exept\expecco\resources\sounds\start.wav'
  7139 	playSound:'C:\Dokumente und Einstellungen\cg\work\exept\expecco\resources\sounds\start.wav'
  7120     "
  7140     "
  7121 
  7141 
  7122     "Created: / 06-11-2007 / 00:46:57 / cg"
  7142     "Created: / 06-11-2007 / 00:46:57 / cg"
  7123 !
  7143 !
  7124 
  7144 
  7132 "/#define SND_LOOP            0x0008  /* loop the sound until next sndPlaySound */
  7152 "/#define SND_LOOP            0x0008  /* loop the sound until next sndPlaySound */
  7133 "/#define SND_NOSTOP          0x0010  /* don't stop any currently playing sound */
  7153 "/#define SND_NOSTOP          0x0010  /* don't stop any currently playing sound */
  7134 
  7154 
  7135     "
  7155     "
  7136      self
  7156      self
  7137         playSound:'C:\Dokumente und Einstellungen\cg\work\exept\expecco\resources\sounds\start.wav'
  7157 	playSound:'C:\Dokumente und Einstellungen\cg\work\exept\expecco\resources\sounds\start.wav'
  7138         mode:1
  7158 	mode:1
  7139     "
  7159     "
  7140 
  7160 
  7141     "Modified: / 06-11-2007 / 00:46:27 / cg"
  7161     "Modified: / 06-11-2007 / 00:46:27 / cg"
  7142 !
  7162 !
  7143 
  7163 
  7163 primGetLastError
  7183 primGetLastError
  7164 
  7184 
  7165     <apicall: dword "GetLastError" () module: "kernel32.dll" >
  7185     <apicall: dword "GetLastError" () module: "kernel32.dll" >
  7166 
  7186 
  7167     "
  7187     "
  7168         self primGetLastError
  7188 	self primGetLastError
  7169     "
  7189     "
  7170 !
  7190 !
  7171 
  7191 
  7172 primSetLastError: int
  7192 primSetLastError: int
  7173 
  7193 
  7174     <apicall: void "SetLastError" (dword) module: "kernel32.dll" >
  7194     <apicall: void "SetLastError" (dword) module: "kernel32.dll" >
  7175 
  7195 
  7176     "
  7196     "
  7177         self primSetLastError: 0
  7197 	self primSetLastError: 0
  7178     "
  7198     "
  7179 !
  7199 !
  7180 
  7200 
  7181 primWritePrivateProfileString: appName keyName: keyName profileString: profString fileName: aString
  7201 primWritePrivateProfileString: appName keyName: keyName profileString: profString fileName: aString
  7182 
  7202 
  7196     defaultUsed: defaultUsed
  7216     defaultUsed: defaultUsed
  7197 
  7217 
  7198     "Convert the Unicode encoding in <lpWideCharStr> to a multi-byte string encoding in <lpstr>."
  7218     "Convert the Unicode encoding in <lpWideCharStr> to a multi-byte string encoding in <lpstr>."
  7199 
  7219 
  7200     "int WideCharToMultiByte(
  7220     "int WideCharToMultiByte(
  7201         UINT  CodePage,    // code page
  7221 	UINT  CodePage,    // code page
  7202         DWORD  dwFlags,    // performance and mapping flags
  7222 	DWORD  dwFlags,    // performance and mapping flags
  7203         LPCWSTR  lpWideCharStr,    // address of wide-character string
  7223 	LPCWSTR  lpWideCharStr,    // address of wide-character string
  7204         int  cchWideChar,    // number of characters in string
  7224 	int  cchWideChar,    // number of characters in string
  7205         LPSTR  lpMultiByteStr,    // address of buffer for new string
  7225 	LPSTR  lpMultiByteStr,    // address of buffer for new string
  7206         int  cchMultiByte,    // size of buffer
  7226 	int  cchMultiByte,    // size of buffer
  7207         LPCSTR  lpDefaultChar,    // address of default for unmappable characters
  7227 	LPCSTR  lpDefaultChar,    // address of default for unmappable characters
  7208         LPBOOL  lpUsedDefaultChar     // address of flag set when default char. used
  7228 	LPBOOL  lpUsedDefaultChar     // address of flag set when default char. used
  7209         );"
  7229 	);"
  7210 
  7230 
  7211     <apicall: ulongReturn "MultiByteToWideChar" ( uint32 uint32 structIn int32 structOut int32 structIn structOut) module: "kernel32.dll" >
  7231     <apicall: ulongReturn "MultiByteToWideChar" ( uint32 uint32 structIn int32 structOut int32 structIn structOut) module: "kernel32.dll" >
  7212     ^self primitiveFailed
  7232     ^self primitiveFailed
  7213 
  7233 
  7214     "Modified (comment): / 12-08-2011 / 16:37:14 / cg"
  7234     "Modified (comment): / 12-08-2011 / 16:37:14 / cg"
  7246 
  7266 
  7247 "/    self assert: lastErrorCode == 0.
  7267 "/    self assert: lastErrorCode == 0.
  7248 "/    lastErrorCode == 5 "ERROR_ACCESS_DENIED" ifTrue:[Transcript showCR: 'Mutex not accesible (GetLastError = ERROR_ACCESS_DENIED)'.].
  7268 "/    lastErrorCode == 5 "ERROR_ACCESS_DENIED" ifTrue:[Transcript showCR: 'Mutex not accesible (GetLastError = ERROR_ACCESS_DENIED)'.].
  7249 "/    lastErrorCode == 183 "ERROR_ALREADY_EXISTS" ifTrue:[Transcript showCR: 'Mutex already exists (GetLastError = ERROR_ALREADY_EXISTS)'.].
  7269 "/    lastErrorCode == 183 "ERROR_ALREADY_EXISTS" ifTrue:[Transcript showCR: 'Mutex already exists (GetLastError = ERROR_ALREADY_EXISTS)'.].
  7250     (handle isNil or:[handle address ~~ 0]) ifFalse:[
  7270     (handle isNil or:[handle address ~~ 0]) ifFalse:[
  7251         Transcript showCR: 'CreateMutexNamed: "', name printString, '" failed'.
  7271 	Transcript showCR: 'CreateMutexNamed: "', name printString, '" failed'.
  7252         handle := nil.
  7272 	handle := nil.
  7253     ].
  7273     ].
  7254     ^ Array with: handle with: lastErrorCode
  7274     ^ Array with: handle with: lastErrorCode
  7255 
  7275 
  7256     "
  7276     "
  7257      self createMutexNamed: '8906f5e0-54ed-11dd-9da4-001558137da0'
  7277      self createMutexNamed: '8906f5e0-54ed-11dd-9da4-001558137da0'
  7267     handleAndLastErrorCode := self createMutexNamed: name.
  7287     handleAndLastErrorCode := self createMutexNamed: name.
  7268     handle := handleAndLastErrorCode first.
  7288     handle := handleAndLastErrorCode first.
  7269     lastErrorCode := handleAndLastErrorCode second.
  7289     lastErrorCode := handleAndLastErrorCode second.
  7270 "/    self assert: lastErrorCode == 0.
  7290 "/    self assert: lastErrorCode == 0.
  7271     ^ handle isNil
  7291     ^ handle isNil
  7272         or:[lastErrorCode == 183 "ERROR_ALREADY_EXISTS"
  7292 	or:[lastErrorCode == 183 "ERROR_ALREADY_EXISTS"
  7273             or:[ lastErrorCode == 5 "ERROR_ACCESS_DENIED"]]
  7293 	    or:[ lastErrorCode == 5 "ERROR_ACCESS_DENIED"]]
  7274 
  7294 
  7275     "Modified: / 03-08-2010 / 16:59:41 / cg"
  7295     "Modified: / 03-08-2010 / 16:59:41 / cg"
  7276 !
  7296 !
  7277 
  7297 
  7278 openMutexNamed: name
  7298 openMutexNamed: name
  7285     handle := self primOpenMutex:nil initialOwner: true name: name.
  7305     handle := self primOpenMutex:nil initialOwner: true name: name.
  7286 "/    lastErrorCode := self primGetLastError.
  7306 "/    lastErrorCode := self primGetLastError.
  7287 "/    lastErrorCode = 2 ifTrue:[Transcript showCR: 'Mutex does not exist (GetLastError = ERROR_FILE_NOT_FOUND)'.].
  7307 "/    lastErrorCode = 2 ifTrue:[Transcript showCR: 'Mutex does not exist (GetLastError = ERROR_FILE_NOT_FOUND)'.].
  7288 "/    lastErrorCode = 5 ifTrue:[Transcript showCR: 'Mutex not accesible (GetLastError = ERROR_ACCESS_DENIED)'.].
  7308 "/    lastErrorCode = 5 ifTrue:[Transcript showCR: 'Mutex not accesible (GetLastError = ERROR_ACCESS_DENIED)'.].
  7289     (handle isNil or:[handle address ~~ 0]) ifFalse:[
  7309     (handle isNil or:[handle address ~~ 0]) ifFalse:[
  7290         Transcript showCR: 'OpenMutexNamed: "', name printString, '" failed'.
  7310 	Transcript showCR: 'OpenMutexNamed: "', name printString, '" failed'.
  7291         ^ nil.
  7311 	^ nil.
  7292     ].
  7312     ].
  7293 
  7313 
  7294     ^ handle
  7314     ^ handle
  7295 
  7315 
  7296 
  7316 
  7343     "Returns true if the Mutex was released. Otherwise, returns false."
  7363     "Returns true if the Mutex was released. Otherwise, returns false."
  7344 
  7364 
  7345     | released|
  7365     | released|
  7346 
  7366 
  7347     hMutex isNil ifTrue:[
  7367     hMutex isNil ifTrue:[
  7348         Transcript showCR: 'hMutex is nil - cannot release'.
  7368 	Transcript showCR: 'hMutex is nil - cannot release'.
  7349         ^ false
  7369 	^ false
  7350     ].
  7370     ].
  7351     released := self primReleaseMutex: hMutex.
  7371     released := self primReleaseMutex: hMutex.
  7352     released ifFalse:[Transcript showCR: 'Release Mutex failed'.].
  7372     released ifFalse:[Transcript showCR: 'Release Mutex failed'.].
  7353     ^ released
  7373     ^ released
  7354 
  7374 
  7360 
  7380 
  7361     | hMutex |
  7381     | hMutex |
  7362 
  7382 
  7363     hMutex := self openMutexNamed: name.
  7383     hMutex := self openMutexNamed: name.
  7364     hMutex isNil ifTrue:[
  7384     hMutex isNil ifTrue:[
  7365         Transcript showCR: 'Cannot release Mutex named: "', name printString,'"'.
  7385 	Transcript showCR: 'Cannot release Mutex named: "', name printString,'"'.
  7366         ^ false
  7386 	^ false
  7367     ].
  7387     ].
  7368     ^ self releaseMutex: hMutex.
  7388     ^ self releaseMutex: hMutex.
  7369 
  7389 
  7370     "Modified: / 03-08-2010 / 16:58:25 / cg"
  7390     "Modified: / 03-08-2010 / 16:58:25 / cg"
  7371 !
  7391 !
  7392 !
  7412 !
  7393 
  7413 
  7394 getDomainName
  7414 getDomainName
  7395     "return the DNS domain this host is in.
  7415     "return the DNS domain this host is in.
  7396      Notice:
  7416      Notice:
  7397         not all systems support this; on some, 'unknown' is returned."
  7417 	not all systems support this; on some, 'unknown' is returned."
  7398 
  7418 
  7399     |domainName idx hostName k|
  7419     |domainName idx hostName k|
  7400 
  7420 
  7401     DomainName notNil ifTrue:[
  7421     DomainName notNil ifTrue:[
  7402         ^ DomainName
  7422 	^ DomainName
  7403     ].
  7423     ].
  7404 
  7424 
  7405     "/ sometimes, we can extract the domainName from the hostName ...
  7425     "/ sometimes, we can extract the domainName from the hostName ...
  7406     hostName := self getHostName.
  7426     hostName := self getHostName.
  7407     hostName notEmptyOrNil ifTrue:[
  7427     hostName notEmptyOrNil ifTrue:[
  7408         idx := hostName indexOf:$..
  7428 	idx := hostName indexOf:$..
  7409         idx ~~ 0 ifTrue:[
  7429 	idx ~~ 0 ifTrue:[
  7410             domainName := hostName copyFrom:idx+1.
  7430 	    domainName := hostName copyFrom:idx+1.
  7411         ]
  7431 	]
  7412     ].
  7432     ].
  7413 
  7433 
  7414     domainName isNil ifTrue:[
  7434     domainName isNil ifTrue:[
  7415         domainName := self getEnvironment:'DOMAIN'.
  7435 	domainName := self getEnvironment:'DOMAIN'.
  7416         domainName isNil ifTrue:[
  7436 	domainName isNil ifTrue:[
  7417             domainName := self getEnvironment:'DOMAINNAME'.
  7437 	    domainName := self getEnvironment:'DOMAINNAME'.
  7418         ].
  7438 	].
  7419 
  7439 
  7420         domainName isNil ifTrue:[
  7440 	domainName isNil ifTrue:[
  7421             "/ ok, search the registry ...
  7441 	    "/ ok, search the registry ...
  7422             "/ under NT and later, it is found there ...
  7442 	    "/ under NT and later, it is found there ...
  7423             k := RegistryEntry key:'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters'.
  7443 	    k := RegistryEntry key:'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters'.
  7424             k notNil ifTrue:[
  7444 	    k notNil ifTrue:[
  7425                 domainName := k valueNamed:'Domain'.
  7445 		domainName := k valueNamed:'Domain'.
  7426                 k close.
  7446 		k close.
  7427             ].
  7447 	    ].
  7428         ].
  7448 	].
  7429 
  7449 
  7430         domainName isNil ifTrue:[
  7450 	domainName isNil ifTrue:[
  7431             "/ under Win95/Win98, it is found there ...
  7451 	    "/ under Win95/Win98, it is found there ...
  7432             k := RegistryEntry key:'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\MSTCP'.
  7452 	    k := RegistryEntry key:'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\MSTCP'.
  7433             k notNil ifTrue:[
  7453 	    k notNil ifTrue:[
  7434                 domainName := k valueNamed:'Domain'.
  7454 		domainName := k valueNamed:'Domain'.
  7435                 k close.
  7455 		k close.
  7436             ]
  7456 	    ]
  7437         ].
  7457 	].
  7438 
  7458 
  7439         domainName isNil ifTrue:[
  7459 	domainName isNil ifTrue:[
  7440             'Win32OperatingSystem [warning]: cannot find out domainName' errorPrintCR.
  7460 	    'Win32OperatingSystem [warning]: cannot find out domainName' errorPrintCR.
  7441             domainName := 'unknown'.
  7461 	    domainName := 'unknown'.
  7442         ].
  7462 	].
  7443         DomainName := domainName.     "cache only, if it is fixed"
  7463 	DomainName := domainName.     "cache only, if it is fixed"
  7444     ].
  7464     ].
  7445     ^ domainName
  7465     ^ domainName
  7446 
  7466 
  7447     "
  7467     "
  7448      DomainName := nil.
  7468      DomainName := nil.
  7458 
  7478 
  7459 %{  /* NOCONTEXT */
  7479 %{  /* NOCONTEXT */
  7460     char *env;
  7480     char *env;
  7461 
  7481 
  7462     if (__isStringLike(aStringOrSymbol)) {
  7482     if (__isStringLike(aStringOrSymbol)) {
  7463         char buff[1024];
  7483 	char buff[1024];
  7464         int nNeeded;
  7484 	int nNeeded;
  7465         OBJ ret = nil;
  7485 	OBJ ret = nil;
  7466 
  7486 
  7467         nNeeded = GetEnvironmentVariable(__stringVal(aStringOrSymbol),
  7487 	nNeeded = GetEnvironmentVariable(__stringVal(aStringOrSymbol),
  7468                                    buff,
  7488 				   buff,
  7469                                    sizeof(buff));
  7489 				   sizeof(buff));
  7470         if (nNeeded > sizeof(buff)) {
  7490 	if (nNeeded > sizeof(buff)) {
  7471             char *buff2;
  7491 	    char *buff2;
  7472 
  7492 
  7473             buff2 = (char *)malloc(nNeeded);
  7493 	    buff2 = (char *)malloc(nNeeded);
  7474             GetEnvironmentVariable(__stringVal(aStringOrSymbol),
  7494 	    GetEnvironmentVariable(__stringVal(aStringOrSymbol),
  7475                                    buff2,
  7495 				   buff2,
  7476                                    nNeeded);
  7496 				   nNeeded);
  7477             ret = __MKSTRING(buff2);
  7497 	    ret = __MKSTRING(buff2);
  7478             free(buff2);
  7498 	    free(buff2);
  7479         } else {
  7499 	} else {
  7480             if (nNeeded > 0) {
  7500 	    if (nNeeded > 0) {
  7481                 ret = __MKSTRING(buff);
  7501 		ret = __MKSTRING(buff);
  7482             }
  7502 	    }
  7483         }
  7503 	}
  7484         RETURN (ret);
  7504 	RETURN (ret);
  7485     }
  7505     }
  7486 %}
  7506 %}
  7487 .
  7507 .
  7488     ^ nil
  7508     ^ nil
  7489 
  7509 
  7508 %{  /* STACK: 2048 */
  7528 %{  /* STACK: 2048 */
  7509     char buffer[512];
  7529     char buffer[512];
  7510     DWORD buffSize = sizeof(buffer);
  7530     DWORD buffSize = sizeof(buffer);
  7511 
  7531 
  7512     if (GetComputerNameEx(ComputerNameDnsFullyQualified, buffer, &buffSize) == TRUE) {
  7532     if (GetComputerNameEx(ComputerNameDnsFullyQualified, buffer, &buffSize) == TRUE) {
  7513         hostName = __MKSTRING(buffer);
  7533 	hostName = __MKSTRING(buffer);
  7514     }
  7534     }
  7515 %}.
  7535 %}.
  7516     ^ hostName
  7536     ^ hostName
  7517 
  7537 
  7518     "
  7538     "
  7526 
  7546 
  7527     |lang|
  7547     |lang|
  7528 
  7548 
  7529     lang := self getEnvironment:'LANG'.
  7549     lang := self getEnvironment:'LANG'.
  7530     (lang isNil or:[lang = 'default']) ifTrue:[
  7550     (lang isNil or:[lang = 'default']) ifTrue:[
  7531         "/ ok, search the registry ...
  7551 	"/ ok, search the registry ...
  7532         "/ under XP, it is found there ...
  7552 	"/ under XP, it is found there ...
  7533         lang := RegistryEntry
  7553 	lang := RegistryEntry
  7534                     stringValueFor:'sLanguage'
  7554 		    stringValueFor:'sLanguage'
  7535                     atKey:'HKEY_CURRENT_USER\Control Panel\International'.
  7555 		    atKey:'HKEY_CURRENT_USER\Control Panel\International'.
  7536         lang notNil ifTrue:[
  7556 	lang notNil ifTrue:[
  7537             lang := self mapLanguage:lang.
  7557 	    lang := self mapLanguage:lang.
  7538         ].
  7558 	].
  7539     ].
  7559     ].
  7540     ^ lang
  7560     ^ lang
  7541 
  7561 
  7542     "
  7562     "
  7543      OperatingSystem getLanguage
  7563      OperatingSystem getLanguage
  7547 
  7567 
  7548 getLocaleInfo
  7568 getLocaleInfo
  7549     "return a dictionary filled with values from the locale information;
  7569     "return a dictionary filled with values from the locale information;
  7550      Not all fields may be present, depending on the OS's setup and capabilities.
  7570      Not all fields may be present, depending on the OS's setup and capabilities.
  7551      Possible fields are:
  7571      Possible fields are:
  7552         decimalPoint                    <String>
  7572 	decimalPoint                    <String>
  7553 
  7573 
  7554         thousandsSep                    <String>
  7574 	thousandsSep                    <String>
  7555 
  7575 
  7556         internationalCurrencySymbol     <String>
  7576 	internationalCurrencySymbol     <String>
  7557 
  7577 
  7558         currencySymbol                  <String>
  7578 	currencySymbol                  <String>
  7559 
  7579 
  7560         monetaryDecimalPoint            <String>
  7580 	monetaryDecimalPoint            <String>
  7561 
  7581 
  7562         monetaryThousandsSeparator      <String>
  7582 	monetaryThousandsSeparator      <String>
  7563 
  7583 
  7564         positiveSign                    <String>
  7584 	positiveSign                    <String>
  7565 
  7585 
  7566         negativeSign                    <String>
  7586 	negativeSign                    <String>
  7567 
  7587 
  7568         internationalFractionalDigits   <Integer>
  7588 	internationalFractionalDigits   <Integer>
  7569 
  7589 
  7570         fractionalDigits                <Integer>
  7590 	fractionalDigits                <Integer>
  7571 
  7591 
  7572         positiveSignPrecedesCurrencySymbol      <Boolean>
  7592 	positiveSignPrecedesCurrencySymbol      <Boolean>
  7573 
  7593 
  7574         negativeSignPrecedesCurrencySymbol      <Boolean>
  7594 	negativeSignPrecedesCurrencySymbol      <Boolean>
  7575 
  7595 
  7576         positiveSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
  7596 	positiveSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
  7577 
  7597 
  7578         negativeSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
  7598 	negativeSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
  7579 
  7599 
  7580         positiveSignPosition                            <Symbol>
  7600 	positiveSignPosition                            <Symbol>
  7581                                                         one of: #parenthesesAround,
  7601 							one of: #parenthesesAround,
  7582                                                                 #signPrecedes,
  7602 								#signPrecedes,
  7583                                                                 #signSuceeds,
  7603 								#signSuceeds,
  7584                                                                 #signPrecedesCurrencySymbol,
  7604 								#signPrecedesCurrencySymbol,
  7585                                                                 #signSuceedsCurrencySymbol
  7605 								#signSuceedsCurrencySymbol
  7586 
  7606 
  7587         negativeSignPosition                            <like above>
  7607 	negativeSignPosition                            <like above>
  7588 
  7608 
  7589      it is up to the application to deal with undefined values.
  7609      it is up to the application to deal with undefined values.
  7590 
  7610 
  7591      Notice, that (for now), the system does not use this information;
  7611      Notice, that (for now), the system does not use this information;
  7592      it should be used by applications as required.
  7612      it should be used by applications as required.
  7593     "
  7613     "
  7594 
  7614 
  7595     |info val|
  7615     |info val|
  7596 
  7616 
  7597     LocaleInfo notNil ifTrue:[
  7617     LocaleInfo notNil ifTrue:[
  7598         "/ return the internal info; useful on systems which do not
  7618 	"/ return the internal info; useful on systems which do not
  7599         "/ support this.
  7619 	"/ support this.
  7600         ^ LocaleInfo
  7620 	^ LocaleInfo
  7601     ].
  7621     ].
  7602 
  7622 
  7603     info := IdentityDictionary new.
  7623     info := IdentityDictionary new.
  7604 %{
  7624 %{
  7605     char *decimalPoint;         /* something like "." (US) or "," (german) */
  7625     char *decimalPoint;         /* something like "." (US) or "," (german) */
  7616     int   csNegPrecedes;        /* money: 1 if currency symbol precedes a negative value; 0 if it sceeds */
  7636     int   csNegPrecedes;        /* money: 1 if currency symbol precedes a negative value; 0 if it sceeds */
  7617     int   csPosSepBySpace;      /* money: 1 if currency symbol should be separated by a space from a positive value; 0 if no space */
  7637     int   csPosSepBySpace;      /* money: 1 if currency symbol should be separated by a space from a positive value; 0 if no space */
  7618     int   csNegSepBySpace;      /* money: 1 if currency symbol should be separated by a space from a negative value; 0 if no space */
  7638     int   csNegSepBySpace;      /* money: 1 if currency symbol should be separated by a space from a negative value; 0 if no space */
  7619     int   csPosSignPosition;    /* money: 0: ()'s around the value & currency symbol */
  7639     int   csPosSignPosition;    /* money: 0: ()'s around the value & currency symbol */
  7620     int   csNegSignPosition;    /*        1: sign precedes the value & currency symbol */
  7640     int   csNegSignPosition;    /*        1: sign precedes the value & currency symbol */
  7621                                 /*        2: sign succeeds the value & currency symbol */
  7641 				/*        2: sign succeeds the value & currency symbol */
  7622                                 /*        3: sign immediately precedes the currency symbol */
  7642 				/*        3: sign immediately precedes the currency symbol */
  7623                                 /*        4: sign immediately suceeds the currency symbol */
  7643 				/*        4: sign immediately suceeds the currency symbol */
  7624 
  7644 
  7625 #if defined(HAS_LOCALECONV)
  7645 #if defined(HAS_LOCALECONV)
  7626     struct lconv *conf;
  7646     struct lconv *conf;
  7627 
  7647 
  7628     conf = localeconv();
  7648     conf = localeconv();
  7629     if (conf) {
  7649     if (conf) {
  7630         decimalPoint = conf->decimal_point;
  7650 	decimalPoint = conf->decimal_point;
  7631         thousandsSep = conf->thousands_sep;
  7651 	thousandsSep = conf->thousands_sep;
  7632         intCurrencySymbol = conf->int_curr_symbol;
  7652 	intCurrencySymbol = conf->int_curr_symbol;
  7633         currencySymbol = conf->currency_symbol;
  7653 	currencySymbol = conf->currency_symbol;
  7634         monDecimalPoint = conf->mon_decimal_point;
  7654 	monDecimalPoint = conf->mon_decimal_point;
  7635         monThousandsSep = conf->mon_thousands_sep;
  7655 	monThousandsSep = conf->mon_thousands_sep;
  7636         positiveSign = conf->positive_sign;
  7656 	positiveSign = conf->positive_sign;
  7637         negativeSign = conf->negative_sign;
  7657 	negativeSign = conf->negative_sign;
  7638         intFractDigits = conf->int_frac_digits;
  7658 	intFractDigits = conf->int_frac_digits;
  7639         fractDigits = conf->frac_digits;
  7659 	fractDigits = conf->frac_digits;
  7640         csPosPrecedes = conf->p_cs_precedes;
  7660 	csPosPrecedes = conf->p_cs_precedes;
  7641         csNegPrecedes = conf->n_cs_precedes;
  7661 	csNegPrecedes = conf->n_cs_precedes;
  7642         csPosSepBySpace = conf->p_sep_by_space;
  7662 	csPosSepBySpace = conf->p_sep_by_space;
  7643         csNegSepBySpace = conf->n_sep_by_space;
  7663 	csNegSepBySpace = conf->n_sep_by_space;
  7644         csPosSignPosition = conf->p_sign_posn;
  7664 	csPosSignPosition = conf->p_sign_posn;
  7645         csNegSignPosition = conf->n_sign_posn;
  7665 	csNegSignPosition = conf->n_sign_posn;
  7646     }
  7666     }
  7647 #else
  7667 #else
  7648     decimalPoint = (char *)0;
  7668     decimalPoint = (char *)0;
  7649     thousandsSep = (char *)0;
  7669     thousandsSep = (char *)0;
  7650     intCurrencySymbol = (char *)0;
  7670     intCurrencySymbol = (char *)0;
  7661     csNegSepBySpace = -1;
  7681     csNegSepBySpace = -1;
  7662     csPosSignPosition = -1;
  7682     csPosSignPosition = -1;
  7663     csNegSignPosition = -1;
  7683     csNegSignPosition = -1;
  7664 #endif
  7684 #endif
  7665     if (decimalPoint) {
  7685     if (decimalPoint) {
  7666         val = __MKSTRING(decimalPoint);
  7686 	val = __MKSTRING(decimalPoint);
  7667         __AT_PUT_(info, @symbol(decimalPoint), val);
  7687 	__AT_PUT_(info, @symbol(decimalPoint), val);
  7668     }
  7688     }
  7669     if (thousandsSep) {
  7689     if (thousandsSep) {
  7670         val = __MKSTRING(thousandsSep);
  7690 	val = __MKSTRING(thousandsSep);
  7671         __AT_PUT_(info, @symbol(thousandsSeparator), val);
  7691 	__AT_PUT_(info, @symbol(thousandsSeparator), val);
  7672     }
  7692     }
  7673     if (intCurrencySymbol) {
  7693     if (intCurrencySymbol) {
  7674         val = __MKSTRING(intCurrencySymbol);
  7694 	val = __MKSTRING(intCurrencySymbol);
  7675         __AT_PUT_(info, @symbol(internationCurrencySymbol), val);
  7695 	__AT_PUT_(info, @symbol(internationCurrencySymbol), val);
  7676     }
  7696     }
  7677     if (currencySymbol) {
  7697     if (currencySymbol) {
  7678         val = __MKSTRING(currencySymbol);
  7698 	val = __MKSTRING(currencySymbol);
  7679         __AT_PUT_(info, @symbol(currencySymbol), val);
  7699 	__AT_PUT_(info, @symbol(currencySymbol), val);
  7680     }
  7700     }
  7681     if (monDecimalPoint) {
  7701     if (monDecimalPoint) {
  7682         val = __MKSTRING(monDecimalPoint);
  7702 	val = __MKSTRING(monDecimalPoint);
  7683         __AT_PUT_(info, @symbol(monetaryDecimalPoint), val);
  7703 	__AT_PUT_(info, @symbol(monetaryDecimalPoint), val);
  7684     }
  7704     }
  7685     if (monThousandsSep) {
  7705     if (monThousandsSep) {
  7686         val = __MKSTRING(monThousandsSep);
  7706 	val = __MKSTRING(monThousandsSep);
  7687         __AT_PUT_(info, @symbol(monetaryThousandsSeparator), val);
  7707 	__AT_PUT_(info, @symbol(monetaryThousandsSeparator), val);
  7688     }
  7708     }
  7689     if (positiveSign) {
  7709     if (positiveSign) {
  7690         val = __MKSTRING(positiveSign);
  7710 	val = __MKSTRING(positiveSign);
  7691         __AT_PUT_(info, @symbol(positiveSign), val);
  7711 	__AT_PUT_(info, @symbol(positiveSign), val);
  7692     }
  7712     }
  7693     if (negativeSign) {
  7713     if (negativeSign) {
  7694         val = __MKSTRING(negativeSign);
  7714 	val = __MKSTRING(negativeSign);
  7695         __AT_PUT_(info, @symbol(negativeSign), val);
  7715 	__AT_PUT_(info, @symbol(negativeSign), val);
  7696     }
  7716     }
  7697     if (intFractDigits >= 0) {
  7717     if (intFractDigits >= 0) {
  7698         __AT_PUT_(info, @symbol(internationalFractionalDigits),  __mkSmallInteger(intFractDigits));
  7718 	__AT_PUT_(info, @symbol(internationalFractionalDigits),  __mkSmallInteger(intFractDigits));
  7699     }
  7719     }
  7700     if (fractDigits >= 0) {
  7720     if (fractDigits >= 0) {
  7701         __AT_PUT_(info, @symbol(fractionalDigits),  __mkSmallInteger(fractDigits));
  7721 	__AT_PUT_(info, @symbol(fractionalDigits),  __mkSmallInteger(fractDigits));
  7702     }
  7722     }
  7703     if (csPosPrecedes >= 0) {
  7723     if (csPosPrecedes >= 0) {
  7704         if (csPosPrecedes == 0) {
  7724 	if (csPosPrecedes == 0) {
  7705             val = false;
  7725 	    val = false;
  7706         } else {
  7726 	} else {
  7707             val = true;
  7727 	    val = true;
  7708         }
  7728 	}
  7709         __AT_PUT_(info, @symbol(positiveSignPrecedesCurrencySymbol), val );
  7729 	__AT_PUT_(info, @symbol(positiveSignPrecedesCurrencySymbol), val );
  7710     }
  7730     }
  7711     if (csNegPrecedes >= 0) {
  7731     if (csNegPrecedes >= 0) {
  7712         if (csNegPrecedes == 0) {
  7732 	if (csNegPrecedes == 0) {
  7713             val = false;
  7733 	    val = false;
  7714         } else {
  7734 	} else {
  7715             val = true;
  7735 	    val = true;
  7716         }
  7736 	}
  7717         __AT_PUT_(info, @symbol(negativeSignPrecedesCurrencySymbol), val );
  7737 	__AT_PUT_(info, @symbol(negativeSignPrecedesCurrencySymbol), val );
  7718     }
  7738     }
  7719     if (csPosSepBySpace >= 0) {
  7739     if (csPosSepBySpace >= 0) {
  7720         if (csPosSepBySpace == 0) {
  7740 	if (csPosSepBySpace == 0) {
  7721             val = false;
  7741 	    val = false;
  7722         } else {
  7742 	} else {
  7723             val = true;
  7743 	    val = true;
  7724         }
  7744 	}
  7725         __AT_PUT_(info, @symbol(positiveSignSeparatedBySpaceFromCurrencySymbol), val);
  7745 	__AT_PUT_(info, @symbol(positiveSignSeparatedBySpaceFromCurrencySymbol), val);
  7726     }
  7746     }
  7727     if (csNegSepBySpace >= 0) {
  7747     if (csNegSepBySpace >= 0) {
  7728         if (csNegSepBySpace == 0) {
  7748 	if (csNegSepBySpace == 0) {
  7729             val = false;
  7749 	    val = false;
  7730         } else {
  7750 	} else {
  7731             val = true;
  7751 	    val = true;
  7732         }
  7752 	}
  7733         __AT_PUT_(info, @symbol(negativeSignSeparatedBySpaceFromCurrencySymbol), val);
  7753 	__AT_PUT_(info, @symbol(negativeSignSeparatedBySpaceFromCurrencySymbol), val);
  7734     }
  7754     }
  7735     switch (csPosSignPosition) {
  7755     switch (csPosSignPosition) {
  7736         case 0:
  7756 	case 0:
  7737             val = @symbol(parenthesesAround);
  7757 	    val = @symbol(parenthesesAround);
  7738             break;
  7758 	    break;
  7739 
  7759 
  7740         case 1:
  7760 	case 1:
  7741             val = @symbol(signPrecedes);
  7761 	    val = @symbol(signPrecedes);
  7742             break;
  7762 	    break;
  7743 
  7763 
  7744         case 2:
  7764 	case 2:
  7745             val = @symbol(signSuceeds);
  7765 	    val = @symbol(signSuceeds);
  7746             break;
  7766 	    break;
  7747 
  7767 
  7748         case 3:
  7768 	case 3:
  7749             val = @symbol(signPrecedesCurrencySymbol);
  7769 	    val = @symbol(signPrecedesCurrencySymbol);
  7750             break;
  7770 	    break;
  7751 
  7771 
  7752         case 4:
  7772 	case 4:
  7753             val = @symbol(signSuceedsCurrencySymbol);
  7773 	    val = @symbol(signSuceedsCurrencySymbol);
  7754             break;
  7774 	    break;
  7755 
  7775 
  7756         default:
  7776 	default:
  7757             val = nil;
  7777 	    val = nil;
  7758     }
  7778     }
  7759     if (val != nil) {
  7779     if (val != nil) {
  7760         __AT_PUT_(info, @symbol(positiveSignPosition), val);
  7780 	__AT_PUT_(info, @symbol(positiveSignPosition), val);
  7761     }
  7781     }
  7762 
  7782 
  7763     switch (csNegSignPosition) {
  7783     switch (csNegSignPosition) {
  7764         case 0:
  7784 	case 0:
  7765             val = @symbol(parenthesesAround);
  7785 	    val = @symbol(parenthesesAround);
  7766             break;
  7786 	    break;
  7767 
  7787 
  7768         case 1:
  7788 	case 1:
  7769             val = @symbol(signPrecedes);
  7789 	    val = @symbol(signPrecedes);
  7770             break;
  7790 	    break;
  7771 
  7791 
  7772         case 2:
  7792 	case 2:
  7773             val = @symbol(signSuceeds);
  7793 	    val = @symbol(signSuceeds);
  7774             break;
  7794 	    break;
  7775 
  7795 
  7776         case 3:
  7796 	case 3:
  7777             val = @symbol(signPrecedesCurrencySymbol);
  7797 	    val = @symbol(signPrecedesCurrencySymbol);
  7778             break;
  7798 	    break;
  7779 
  7799 
  7780         case 4:
  7800 	case 4:
  7781             val = @symbol(signSuceedsCurrencySymbol);
  7801 	    val = @symbol(signSuceedsCurrencySymbol);
  7782             break;
  7802 	    break;
  7783 
  7803 
  7784         default:
  7804 	default:
  7785             val = nil;
  7805 	    val = nil;
  7786     }
  7806     }
  7787     if (val != nil) {
  7807     if (val != nil) {
  7788         __AT_PUT_(info, @symbol(negativeSignPosition), val);
  7808 	__AT_PUT_(info, @symbol(negativeSignPosition), val);
  7789     }
  7809     }
  7790 %}.
  7810 %}.
  7791     ^ info
  7811     ^ info
  7792 
  7812 
  7793     "
  7813     "
  7797     "Created: 23.12.1995 / 14:19:20 / cg"
  7817     "Created: 23.12.1995 / 14:19:20 / cg"
  7798 !
  7818 !
  7799 
  7819 
  7800 getNetworkMACAddresses
  7820 getNetworkMACAddresses
  7801     "return a dictionary filled with
  7821     "return a dictionary filled with
  7802         key -> name of interface
  7822 	key -> name of interface
  7803         value -> the MAC adress (as ByteArray)
  7823 	value -> the MAC adress (as ByteArray)
  7804      for each interface
  7824      for each interface
  7805     "
  7825     "
  7806 
  7826 
  7807     |info nAdapters rawData entry
  7827     |info nAdapters rawData entry
  7808      name description macAddress ipAddress ipAddressMask|
  7828      name description macAddress ipAddress ipAddressMask|
  7827      */
  7847      */
  7828 #ifdef NO_NT4_0_COMPATIBILITY
  7848 #ifdef NO_NT4_0_COMPATIBILITY
  7829     GetAdaptersInfo_entry = (FARPROC) GetAdaptersInfo;
  7849     GetAdaptersInfo_entry = (FARPROC) GetAdaptersInfo;
  7830 #else
  7850 #else
  7831     if (GetAdaptersInfo_entry == NULL) {
  7851     if (GetAdaptersInfo_entry == NULL) {
  7832         GetAdaptersInfo_entry = __get_iphlpapi_functionAddress("GetAdaptersInfo");
  7852 	GetAdaptersInfo_entry = __get_iphlpapi_functionAddress("GetAdaptersInfo");
  7833     }
  7853     }
  7834 #endif /* NO_NT4_0_COMPATIBILITY */
  7854 #endif /* NO_NT4_0_COMPATIBILITY */
  7835 
  7855 
  7836     if (GetAdaptersInfo_entry) {
  7856     if (GetAdaptersInfo_entry) {
  7837         dwStatus = (*GetAdaptersInfo_entry)(
  7857 	dwStatus = (*GetAdaptersInfo_entry)(
  7838                                 AdapterInfo,                 // [out] buffer to receive data
  7858 				AdapterInfo,                 // [out] buffer to receive data
  7839                                 &dwBufLen);                  // [in] size of receive data buffer
  7859 				&dwBufLen);                  // [in] size of receive data buffer
  7840         if (dwStatus == ERROR_SUCCESS) {
  7860 	if (dwStatus == ERROR_SUCCESS) {
  7841             PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo;
  7861 	    PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo;
  7842             unsigned char *bP;
  7862 	    unsigned char *bP;
  7843             int nA = 0;
  7863 	    int nA = 0;
  7844 
  7864 
  7845             bP = __byteArrayVal(rawData);
  7865 	    bP = __byteArrayVal(rawData);
  7846             do {
  7866 	    do {
  7847                 name = __MKSTRING(pAdapterInfo->AdapterName);
  7867 		name = __MKSTRING(pAdapterInfo->AdapterName);
  7848                 description = __MKSTRING(pAdapterInfo->Description);
  7868 		description = __MKSTRING(pAdapterInfo->Description);
  7849                 macAddress = __MKBYTEARRAY(pAdapterInfo->Address, 6);
  7869 		macAddress = __MKBYTEARRAY(pAdapterInfo->Address, 6);
  7850                 ipAddress = __MKSTRING(pAdapterInfo->IpAddressList.IpAddress.String);
  7870 		ipAddress = __MKSTRING(pAdapterInfo->IpAddressList.IpAddress.String);
  7851                 ipAddressMask = __MKSTRING(pAdapterInfo->IpAddressList.IpMask.String);
  7871 		ipAddressMask = __MKSTRING(pAdapterInfo->IpAddressList.IpMask.String);
  7852                 entry = __ARRAY_NEW_INT(5);
  7872 		entry = __ARRAY_NEW_INT(5);
  7853 /*
  7873 /*
  7854  * back to ST/X's String definition
  7874  * back to ST/X's String definition
  7855  */
  7875  */
  7856 # ifdef __DEF_String
  7876 # ifdef __DEF_String
  7857 #  define String __DEF_String
  7877 #  define String __DEF_String
  7858 # endif
  7878 # endif
  7859 # ifdef __DEF_String
  7879 # ifdef __DEF_String
  7860 #  define Context __DEF_Context
  7880 #  define Context __DEF_Context
  7861 # endif
  7881 # endif
  7862                 __ArrayInstPtr(entry)->a_element[0] = name; __STORE(entry, name);
  7882 		__ArrayInstPtr(entry)->a_element[0] = name; __STORE(entry, name);
  7863                 __ArrayInstPtr(entry)->a_element[1] = description; __STORE(entry, description);
  7883 		__ArrayInstPtr(entry)->a_element[1] = description; __STORE(entry, description);
  7864                 __ArrayInstPtr(entry)->a_element[2] = macAddress; __STORE(entry, macAddress);
  7884 		__ArrayInstPtr(entry)->a_element[2] = macAddress; __STORE(entry, macAddress);
  7865                 __ArrayInstPtr(entry)->a_element[3] = ipAddress; __STORE(entry, ipAddress);
  7885 		__ArrayInstPtr(entry)->a_element[3] = ipAddress; __STORE(entry, ipAddress);
  7866                 __ArrayInstPtr(entry)->a_element[4] = ipAddressMask; __STORE(entry, ipAddressMask);
  7886 		__ArrayInstPtr(entry)->a_element[4] = ipAddressMask; __STORE(entry, ipAddressMask);
  7867 
  7887 
  7868                 __ArrayInstPtr(rawData)->a_element[nA] = entry; __STORE(rawData, entry);
  7888 		__ArrayInstPtr(rawData)->a_element[nA] = entry; __STORE(rawData, entry);
  7869                 nA++;
  7889 		nA++;
  7870                 pAdapterInfo = pAdapterInfo->Next;
  7890 		pAdapterInfo = pAdapterInfo->Next;
  7871             } while(pAdapterInfo);
  7891 	    } while(pAdapterInfo);
  7872             nAdapters = __mkSmallInteger(nA);
  7892 	    nAdapters = __mkSmallInteger(nA);
  7873         }
  7893 	}
  7874     }
  7894     }
  7875 #endif /* NO_GETADAPTERSINFO */
  7895 #endif /* NO_GETADAPTERSINFO */
  7876 %}.
  7896 %}.
  7877     info := Dictionary new.
  7897     info := Dictionary new.
  7878     nAdapters notNil ifTrue:[
  7898     nAdapters notNil ifTrue:[
  7879         1 to:nAdapters do:[:i |
  7899 	1 to:nAdapters do:[:i |
  7880             |entry name description macAddr ipAddr|
  7900 	    |entry name description macAddr ipAddr|
  7881 
  7901 
  7882             entry := rawData at:i.
  7902 	    entry := rawData at:i.
  7883             name := entry at:1.
  7903 	    name := entry at:1.
  7884             "/ description := entry at:2.
  7904 	    "/ description := entry at:2.
  7885             macAddr := entry at:3.
  7905 	    macAddr := entry at:3.
  7886             "/ ipAddr := entry at:4.
  7906 	    "/ ipAddr := entry at:4.
  7887             info at:name put:macAddr.
  7907 	    info at:name put:macAddr.
  7888         ].
  7908 	].
  7889     ].
  7909     ].
  7890     ^ info
  7910     ^ info
  7891 
  7911 
  7892     "
  7912     "
  7893      OperatingSystem getNetworkMACAddresses
  7913      OperatingSystem getNetworkMACAddresses
  7896 
  7916 
  7897 getNumberOfProcessors
  7917 getNumberOfProcessors
  7898     "answer the number of physical processors in the system"
  7918     "answer the number of physical processors in the system"
  7899 
  7919 
  7900     %{
  7920     %{
  7901         SYSTEM_INFO sInfo;
  7921 	SYSTEM_INFO sInfo;
  7902         GetSystemInfo(&sInfo);
  7922 	GetSystemInfo(&sInfo);
  7903 
  7923 
  7904         return __mkSmallInteger(sInfo.dwNumberOfProcessors);
  7924 	return __mkSmallInteger(sInfo.dwNumberOfProcessors);
  7905     %}.
  7925     %}.
  7906 
  7926 
  7907     "
  7927     "
  7908         self getNumberOfProcessors
  7928 	self getNumberOfProcessors
  7909     "
  7929     "
  7910 !
  7930 !
  7911 
  7931 
  7912 getProcessId
  7932 getProcessId
  7913     "return the (unix-)processId"
  7933     "return the (unix-)processId"
  7926 
  7946 
  7927 getSystemID
  7947 getSystemID
  7928     "if supported by the OS, return the systemID;
  7948     "if supported by the OS, return the systemID;
  7929      a unique per machine identification.
  7949      a unique per machine identification.
  7930      WARNING:
  7950      WARNING:
  7931         not all systems support this; on some, 'unknown' is returned."
  7951 	not all systems support this; on some, 'unknown' is returned."
  7932 
  7952 
  7933 %{  /* NO_CONTEXT */
  7953 %{  /* NO_CONTEXT */
  7934 #if defined(HAS_GETHOSTID)
  7954 #if defined(HAS_GETHOSTID)
  7935     int runningId;
  7955     int runningId;
  7936     OBJ arr;
  7956     OBJ arr;
  7940     *(int *)(__ByteArrayInstPtr(arr)->ba_element) = runningId;
  7960     *(int *)(__ByteArrayInstPtr(arr)->ba_element) = runningId;
  7941     RETURN (arr);
  7961     RETURN (arr);
  7942 #endif
  7962 #endif
  7943 #if defined(HAS_SYSINFO) && defined(SI_HW_SERIAL)
  7963 #if defined(HAS_SYSINFO) && defined(SI_HW_SERIAL)
  7944     {
  7964     {
  7945         char buffer[128];
  7965 	char buffer[128];
  7946 
  7966 
  7947         buffer[0] = 0;
  7967 	buffer[0] = 0;
  7948         if (sysinfo(SI_HW_SERIAL, buffer, sizeof(buffer))) {
  7968 	if (sysinfo(SI_HW_SERIAL, buffer, sizeof(buffer))) {
  7949             buffer[127] = 0;
  7969 	    buffer[127] = 0;
  7950             if (strlen(buffer) > 0) {
  7970 	    if (strlen(buffer) > 0) {
  7951                 RETURN(__MKSTRING(buffer));
  7971 		RETURN(__MKSTRING(buffer));
  7952             }
  7972 	    }
  7953         }
  7973 	}
  7954     }
  7974     }
  7955 #endif
  7975 #endif
  7956 %}.
  7976 %}.
  7957     ^ 'unknown'
  7977     ^ 'unknown'
  7958 
  7978 
  7972        OS, for example, linux returns 'ix86', while WIN32 returns 'x86'.
  7992        OS, for example, linux returns 'ix86', while WIN32 returns 'x86'.
  7973 
  7993 
  7974        This method is mainly provided to augment error reports with some system
  7994        This method is mainly provided to augment error reports with some system
  7975        information.
  7995        information.
  7976        (in case of system/version specific OS errors, conditional workarounds and patches
  7996        (in case of system/version specific OS errors, conditional workarounds and patches
  7977         may be based upon this info).
  7997 	may be based upon this info).
  7978        Your application should NOT depend upon this in any way.
  7998        Your application should NOT depend upon this in any way.
  7979 
  7999 
  7980      The returned info may (or may not) contain:
  8000      The returned info may (or may not) contain:
  7981         #system -> some operating system identification (irix, Linux, nt, win32s ...)
  8001 	#system -> some operating system identification (irix, Linux, nt, win32s ...)
  7982         #version -> OS version (some os version identification)
  8002 	#version -> OS version (some os version identification)
  7983         #release -> OS release (3.5, 1.2.1 ...)
  8003 	#release -> OS release (3.5, 1.2.1 ...)
  7984         #node   -> some host identification (hostname)
  8004 	#node   -> some host identification (hostname)
  7985         #domain  -> domain name (hosts domain)
  8005 	#domain  -> domain name (hosts domain)
  7986         #machine -> type of machine (i586, mips ...)
  8006 	#machine -> type of machine (i586, mips ...)
  7987 
  8007 
  7988      win32:
  8008      win32:
  7989         #physicalRam -> total amount of physical memory
  8009 	#physicalRam -> total amount of physical memory
  7990         #freeRam -> amount of free memory
  8010 	#freeRam -> amount of free memory
  7991         #swapSize -> size of swapSpace (page file)
  8011 	#swapSize -> size of swapSpace (page file)
  7992         #freeSwap -> free bytes in swapSpace
  8012 	#freeSwap -> free bytes in swapSpace
  7993         #virtualRam -> total amount of virtual memory
  8013 	#virtualRam -> total amount of virtual memory
  7994         #freeVirtual -> amount of free virtual memory
  8014 	#freeVirtual -> amount of free virtual memory
  7995         #memoryLoad -> percentage of memory usage (useless)
  8015 	#memoryLoad -> percentage of memory usage (useless)
  7996     "
  8016     "
  7997 
  8017 
  7998     |sys node rel ver minorVer majorVer mach dom info arch
  8018     |sys node rel ver minorVer majorVer mach dom info arch
  7999      physicalRam freeRam swapSize freeSwap
  8019      physicalRam freeRam swapSize freeSwap
  8000      virtualRam freeVirtual memoryLoad numberOfCPUs|
  8020      virtualRam freeVirtual memoryLoad numberOfCPUs|
  8016 
  8036 
  8017     minorVer = __mkSmallInteger(verMinor);
  8037     minorVer = __mkSmallInteger(verMinor);
  8018     majorVer = __mkSmallInteger(verMajor);
  8038     majorVer = __mkSmallInteger(verMajor);
  8019 
  8039 
  8020     if (HIWORD(vsn) & 0x8000) {
  8040     if (HIWORD(vsn) & 0x8000) {
  8021         sys = @symbol(win95);
  8041 	sys = @symbol(win95);
  8022     } else {
  8042     } else {
  8023         if ((verMajor > 5)
  8043 	if ((verMajor > 5)
  8024          || ((verMajor == 5) && (verMinor >= 1))) {
  8044 	 || ((verMajor == 5) && (verMinor >= 1))) {
  8025             sys = @symbol(xp);
  8045 	    sys = @symbol(xp);
  8026             if (verMajor >= 6) {
  8046 	    if (verMajor >= 6) {
  8027                 sys = @symbol(vista);
  8047 		sys = @symbol(vista);
  8028                 if (verMinor >= 1) {
  8048 		if (verMinor >= 1) {
  8029                     sys = @symbol(win7);
  8049 		    sys = @symbol(win7);
  8030                 }
  8050 		}
  8031             }
  8051 	    }
  8032         } else {
  8052 	} else {
  8033             sys = @symbol(nt);
  8053 	    sys = @symbol(nt);
  8034         }
  8054 	}
  8035     }
  8055     }
  8036     len = snprintf(vsnBuffer, sizeof(vsnBuffer), "%d.%d", verMajor, verMinor);
  8056     len = snprintf(vsnBuffer, sizeof(vsnBuffer), "%d.%d", verMajor, verMinor);
  8037     rel = __MKSTRING_L(vsnBuffer, len);
  8057     rel = __MKSTRING_L(vsnBuffer, len);
  8038 
  8058 
  8039     GetSystemInfo(&sysInfo);
  8059     GetSystemInfo(&sysInfo);
  8055     /* MSC, BorlandC4 ... */
  8075     /* MSC, BorlandC4 ... */
  8056     switch (sysInfo.wProcessorArchitecture)
  8076     switch (sysInfo.wProcessorArchitecture)
  8057 #endif
  8077 #endif
  8058     {
  8078     {
  8059 #ifdef PROCESSOR_ARCHITECTURE_INTEL
  8079 #ifdef PROCESSOR_ARCHITECTURE_INTEL
  8060         case PROCESSOR_ARCHITECTURE_INTEL:
  8080 	case PROCESSOR_ARCHITECTURE_INTEL:
  8061             arch = @symbol(intel);
  8081 	    arch = @symbol(intel);
  8062             break;
  8082 	    break;
  8063 #endif
  8083 #endif
  8064 #ifdef PROCESSOR_ARCHITECTURE_AMD64
  8084 #ifdef PROCESSOR_ARCHITECTURE_AMD64
  8065         case PROCESSOR_ARCHITECTURE_AMD64:
  8085 	case PROCESSOR_ARCHITECTURE_AMD64:
  8066             arch = @symbol(x64);
  8086 	    arch = @symbol(x64);
  8067             break;
  8087 	    break;
  8068 #endif
  8088 #endif
  8069 #ifdef PROCESSOR_ARCHITECTURE_MIPS
  8089 #ifdef PROCESSOR_ARCHITECTURE_MIPS
  8070         case PROCESSOR_ARCHITECTURE_MIPS:
  8090 	case PROCESSOR_ARCHITECTURE_MIPS:
  8071             arch = @symbol(mips);
  8091 	    arch = @symbol(mips);
  8072             break;
  8092 	    break;
  8073 #endif
  8093 #endif
  8074 #ifdef PROCESSOR_ARCHITECTURE_ALPHA
  8094 #ifdef PROCESSOR_ARCHITECTURE_ALPHA
  8075         case PROCESSOR_ARCHITECTURE_ALPHA:
  8095 	case PROCESSOR_ARCHITECTURE_ALPHA:
  8076             arch = @symbol(alpha);
  8096 	    arch = @symbol(alpha);
  8077             break;
  8097 	    break;
  8078 #endif
  8098 #endif
  8079 #ifdef PROCESSOR_ARCHITECTURE_ALPHA64
  8099 #ifdef PROCESSOR_ARCHITECTURE_ALPHA64
  8080         case PROCESSOR_ARCHITECTURE_ALPHA64:
  8100 	case PROCESSOR_ARCHITECTURE_ALPHA64:
  8081             arch = @symbol(alpha64);
  8101 	    arch = @symbol(alpha64);
  8082             break;
  8102 	    break;
  8083 #endif
  8103 #endif
  8084 #ifdef PROCESSOR_ARCHITECTURE_PPC
  8104 #ifdef PROCESSOR_ARCHITECTURE_PPC
  8085         case PROCESSOR_ARCHITECTURE_PPC:
  8105 	case PROCESSOR_ARCHITECTURE_PPC:
  8086             arch = @symbol(ppc);
  8106 	    arch = @symbol(ppc);
  8087             break;
  8107 	    break;
  8088 #endif
  8108 #endif
  8089 #ifdef PROCESSOR_ARCHITECTURE_ARM
  8109 #ifdef PROCESSOR_ARCHITECTURE_ARM
  8090         case PROCESSOR_ARCHITECTURE_ARM:
  8110 	case PROCESSOR_ARCHITECTURE_ARM:
  8091             arch = @symbol(arm);
  8111 	    arch = @symbol(arm);
  8092             break;
  8112 	    break;
  8093 #endif
  8113 #endif
  8094 #ifdef PROCESSOR_ARCHITECTURE_SHX
  8114 #ifdef PROCESSOR_ARCHITECTURE_SHX
  8095         case PROCESSOR_ARCHITECTURE_SHX:
  8115 	case PROCESSOR_ARCHITECTURE_SHX:
  8096             arch = @symbol(shx);
  8116 	    arch = @symbol(shx);
  8097             break;
  8117 	    break;
  8098 #endif
  8118 #endif
  8099 #ifdef PROCESSOR_ARCHITECTURE_IA64
  8119 #ifdef PROCESSOR_ARCHITECTURE_IA64
  8100         case PROCESSOR_ARCHITECTURE_IA64:
  8120 	case PROCESSOR_ARCHITECTURE_IA64:
  8101             arch = @symbol(ia64);
  8121 	    arch = @symbol(ia64);
  8102             break;
  8122 	    break;
  8103 #endif
  8123 #endif
  8104 #ifdef PROCESSOR_ARCHITECTURE_MSIL
  8124 #ifdef PROCESSOR_ARCHITECTURE_MSIL
  8105         case PROCESSOR_ARCHITECTURE_MSIL:
  8125 	case PROCESSOR_ARCHITECTURE_MSIL:
  8106             arch = @symbol(msil);
  8126 	    arch = @symbol(msil);
  8107             break;
  8127 	    break;
  8108 #endif
  8128 #endif
  8109         default:
  8129 	default:
  8110             arch = @symbol(unknown);
  8130 	    arch = @symbol(unknown);
  8111             break;
  8131 	    break;
  8112     }
  8132     }
  8113 
  8133 
  8114     switch (sysInfo.dwProcessorType) {
  8134     switch (sysInfo.dwProcessorType) {
  8115 #ifdef PROCESSOR_INTEL_386
  8135 #ifdef PROCESSOR_INTEL_386
  8116         case PROCESSOR_INTEL_386:
  8136 	case PROCESSOR_INTEL_386:
  8117             mach = @symbol(i386);
  8137 	    mach = @symbol(i386);
  8118             break;
  8138 	    break;
  8119 #endif
  8139 #endif
  8120 #ifdef PROCESSOR_INTEL_486
  8140 #ifdef PROCESSOR_INTEL_486
  8121         case PROCESSOR_INTEL_486:
  8141 	case PROCESSOR_INTEL_486:
  8122             mach = @symbol(i486);
  8142 	    mach = @symbol(i486);
  8123             break;
  8143 	    break;
  8124 #endif
  8144 #endif
  8125 #ifdef PROCESSOR_INTEL_PENTIUM
  8145 #ifdef PROCESSOR_INTEL_PENTIUM
  8126         case PROCESSOR_INTEL_PENTIUM:
  8146 	case PROCESSOR_INTEL_PENTIUM:
  8127             mach = @symbol(i586);
  8147 	    mach = @symbol(i586);
  8128             break;
  8148 	    break;
  8129 #endif
  8149 #endif
  8130 #ifdef PROCESSOR_INTEL_860
  8150 #ifdef PROCESSOR_INTEL_860
  8131         case PROCESSOR_INTEL_860:
  8151 	case PROCESSOR_INTEL_860:
  8132             mach = @symbol(i860);
  8152 	    mach = @symbol(i860);
  8133             break;
  8153 	    break;
  8134 #endif
  8154 #endif
  8135 #ifdef PROCESSOR_INTEL_IA64
  8155 #ifdef PROCESSOR_INTEL_IA64
  8136         case PROCESSOR_INTEL_IA64:
  8156 	case PROCESSOR_INTEL_IA64:
  8137             mach = @symbol(ia64);
  8157 	    mach = @symbol(ia64);
  8138             break;
  8158 	    break;
  8139 #endif
  8159 #endif
  8140 #ifdef PROCESSOR_MIPS_R2000
  8160 #ifdef PROCESSOR_MIPS_R2000
  8141         case PROCESSOR_MIPS_R2000:
  8161 	case PROCESSOR_MIPS_R2000:
  8142             mach = @symbol(r2000);
  8162 	    mach = @symbol(r2000);
  8143             break;
  8163 	    break;
  8144 #endif
  8164 #endif
  8145 #ifdef PROCESSOR_MIPS_R3000
  8165 #ifdef PROCESSOR_MIPS_R3000
  8146         case PROCESSOR_MIPS_R3000:
  8166 	case PROCESSOR_MIPS_R3000:
  8147             mach = @symbol(r3000);
  8167 	    mach = @symbol(r3000);
  8148             break;
  8168 	    break;
  8149 #endif
  8169 #endif
  8150 #ifdef PROCESSOR_MIPS_R4000
  8170 #ifdef PROCESSOR_MIPS_R4000
  8151         case PROCESSOR_MIPS_R4000:
  8171 	case PROCESSOR_MIPS_R4000:
  8152             mach = @symbol(r4000);
  8172 	    mach = @symbol(r4000);
  8153             break;
  8173 	    break;
  8154 #endif
  8174 #endif
  8155 #ifdef PROCESSOR_ALPHA_21064
  8175 #ifdef PROCESSOR_ALPHA_21064
  8156         case PROCESSOR_ALPHA_21064:
  8176 	case PROCESSOR_ALPHA_21064:
  8157             mach = @symbol(alpha21064);
  8177 	    mach = @symbol(alpha21064);
  8158             break;
  8178 	    break;
  8159 #endif
  8179 #endif
  8160 #ifdef PROCESSOR_ARM720
  8180 #ifdef PROCESSOR_ARM720
  8161         case PROCESSOR_ARM720:
  8181 	case PROCESSOR_ARM720:
  8162             mach = @symbol(arm720);
  8182 	    mach = @symbol(arm720);
  8163             break;
  8183 	    break;
  8164 #endif
  8184 #endif
  8165 #ifdef PROCESSOR_ARM820
  8185 #ifdef PROCESSOR_ARM820
  8166         case PROCESSOR_ARM820:
  8186 	case PROCESSOR_ARM820:
  8167             mach = @symbol(arm820);
  8187 	    mach = @symbol(arm820);
  8168             break;
  8188 	    break;
  8169 #endif
  8189 #endif
  8170 #ifdef PROCESSOR_ARM920
  8190 #ifdef PROCESSOR_ARM920
  8171         case PROCESSOR_ARM920:
  8191 	case PROCESSOR_ARM920:
  8172             mach = @symbol(arm920);
  8192 	    mach = @symbol(arm920);
  8173             break;
  8193 	    break;
  8174 #endif
  8194 #endif
  8175 #ifdef PROCESSOR_ARM_7TDMI
  8195 #ifdef PROCESSOR_ARM_7TDMI
  8176         case PROCESSOR_ARM_7TDMI:
  8196 	case PROCESSOR_ARM_7TDMI:
  8177             mach = @symbol(arm70001);
  8197 	    mach = @symbol(arm70001);
  8178             break;
  8198 	    break;
  8179 #endif
  8199 #endif
  8180 #ifdef PROCESSOR_PPC_601
  8200 #ifdef PROCESSOR_PPC_601
  8181         case PROCESSOR_PPC_601:
  8201 	case PROCESSOR_PPC_601:
  8182             mach = @symbol(ppc601);
  8202 	    mach = @symbol(ppc601);
  8183             break;
  8203 	    break;
  8184 #endif
  8204 #endif
  8185 #ifdef PROCESSOR_PPC_603
  8205 #ifdef PROCESSOR_PPC_603
  8186         case PROCESSOR_PPC_603:
  8206 	case PROCESSOR_PPC_603:
  8187             mach = @symbol(ppc603);
  8207 	    mach = @symbol(ppc603);
  8188             break;
  8208 	    break;
  8189 #endif
  8209 #endif
  8190 #ifdef PROCESSOR_PPC_604
  8210 #ifdef PROCESSOR_PPC_604
  8191         case PROCESSOR_PPC_604:
  8211 	case PROCESSOR_PPC_604:
  8192             mach = @symbol(ppc604);
  8212 	    mach = @symbol(ppc604);
  8193             break;
  8213 	    break;
  8194 #endif
  8214 #endif
  8195 #ifdef PROCESSOR_PPC_620
  8215 #ifdef PROCESSOR_PPC_620
  8196         case PROCESSOR_PPC_620:
  8216 	case PROCESSOR_PPC_620:
  8197             mach = @symbol(ppc620);
  8217 	    mach = @symbol(ppc620);
  8198             break;
  8218 	    break;
  8199 #endif
  8219 #endif
  8200 
  8220 
  8201         default:
  8221 	default:
  8202             sprintf(vsnBuffer, "%d", sysInfo.dwProcessorType);
  8222 	    sprintf(vsnBuffer, "%d", sysInfo.dwProcessorType);
  8203             mach =  __MKSTRING(vsnBuffer);
  8223 	    mach =  __MKSTRING(vsnBuffer);
  8204             break;
  8224 	    break;
  8205     }
  8225     }
  8206 
  8226 
  8207     numberOfCPUs = __MKUINT(sysInfo.dwNumberOfProcessors);
  8227     numberOfCPUs = __MKUINT(sysInfo.dwNumberOfProcessors);
  8208 %}.
  8228 %}.
  8209     node isNil ifTrue:[
  8229     node isNil ifTrue:[
  8210         node := self getHostName.
  8230 	node := self getHostName.
  8211     ].
  8231     ].
  8212     dom isNil ifTrue:[
  8232     dom isNil ifTrue:[
  8213         dom := self getDomainName.
  8233 	dom := self getDomainName.
  8214     ].
  8234     ].
  8215 
  8235 
  8216     info := IdentityDictionary new.
  8236     info := IdentityDictionary new.
  8217     info at:#system put:sys.
  8237     info at:#system put:sys.
  8218     info at:#node put:node.
  8238     info at:#node put:node.
  8279 
  8299 
  8280 %{
  8300 %{
  8281     char buffer[MAXPATHLEN];
  8301     char buffer[MAXPATHLEN];
  8282 
  8302 
  8283     if (GetWindowsDirectory(buffer, MAXPATHLEN)) {
  8303     if (GetWindowsDirectory(buffer, MAXPATHLEN)) {
  8284         RETURN (__MKSTRING(buffer));
  8304 	RETURN (__MKSTRING(buffer));
  8285     }
  8305     }
  8286 %}.
  8306 %}.
  8287     ^ nil
  8307     ^ nil
  8288 
  8308 
  8289     "
  8309     "
  8300 
  8320 
  8301 %{
  8321 %{
  8302     char buffer[MAXPATHLEN];
  8322     char buffer[MAXPATHLEN];
  8303 
  8323 
  8304     if (GetSystemDirectory(buffer, MAXPATHLEN)) {
  8324     if (GetSystemDirectory(buffer, MAXPATHLEN)) {
  8305         RETURN (__MKSTRING(buffer));
  8325 	RETURN (__MKSTRING(buffer));
  8306     }
  8326     }
  8307 %}.
  8327 %}.
  8308     ^ nil
  8328     ^ nil
  8309 
  8329 
  8310     "
  8330     "
  8338 isMSWINDOWSNTlike
  8358 isMSWINDOWSNTlike
  8339     "This returns true if running in a Windows-NT system."
  8359     "This returns true if running in a Windows-NT system."
  8340 
  8360 
  8341 %{   /* NOCONTEXT */
  8361 %{   /* NOCONTEXT */
  8342      if (__isWinNT)
  8362      if (__isWinNT)
  8343         RETURN(true);
  8363 	RETURN(true);
  8344 %}.
  8364 %}.
  8345      ^ false.
  8365      ^ false.
  8346 !
  8366 !
  8347 
  8367 
  8348 isMSWINDOWSlike
  8368 isMSWINDOWSlike
  8361 %{
  8381 %{
  8362     HANDLE processHandle;
  8382     HANDLE processHandle;
  8363     int err;
  8383     int err;
  8364 
  8384 
  8365     if (__isExternalAddressLike(processHandleOrPid) ) {
  8385     if (__isExternalAddressLike(processHandleOrPid) ) {
  8366         DWORD exitCode;
  8386 	DWORD exitCode;
  8367 
  8387 
  8368         processHandle = _HANDLEVal(processHandleOrPid);
  8388 	processHandle = _HANDLEVal(processHandleOrPid);
  8369 
  8389 
  8370         if (processHandle == 0) {
  8390 	if (processHandle == 0) {
  8371             error = @symbol(invalidParameter);
  8391 	    error = @symbol(invalidParameter);
  8372         } else {
  8392 	} else {
  8373             /* check if the handle still refers to a running process */
  8393 	    /* check if the handle still refers to a running process */
  8374             if (GetExitCodeProcess(processHandle, &exitCode) != 0) {
  8394 	    if (GetExitCodeProcess(processHandle, &exitCode) != 0) {
  8375                 if (exitCode == STILL_ACTIVE) {
  8395 		if (exitCode == STILL_ACTIVE) {
  8376                     RETURN(true);
  8396 		    RETURN(true);
  8377                 } else {
  8397 		} else {
  8378                     RETURN(false);
  8398 		    RETURN(false);
  8379                 }
  8399 		}
  8380             } else {
  8400 	    } else {
  8381                 goto checkError;
  8401 		goto checkError;
  8382             }
  8402 	    }
  8383        }
  8403        }
  8384     } else if( __isSmallInteger(processHandleOrPid) ) {
  8404     } else if( __isSmallInteger(processHandleOrPid) ) {
  8385         // assume, that synchronize needs less privilege...
  8405 	// assume, that synchronize needs less privilege...
  8386         processHandle = OpenProcess(SYNCHRONIZE, FALSE, __smallIntegerVal(processHandleOrPid));
  8406 	processHandle = OpenProcess(SYNCHRONIZE, FALSE, __smallIntegerVal(processHandleOrPid));
  8387         if (processHandle) {
  8407 	if (processHandle) {
  8388             CloseHandle(processHandle);
  8408 	    CloseHandle(processHandle);
  8389             RETURN(true);
  8409 	    RETURN(true);
  8390         }
  8410 	}
  8391 
  8411 
  8392 checkError:
  8412 checkError:
  8393         err = GetLastError();
  8413 	err = GetLastError();
  8394         // we do not have access to the process (so pid does exist ;-))
  8414 	// we do not have access to the process (so pid does exist ;-))
  8395         if (err == ERROR_ACCESS_DENIED) {
  8415 	if (err == ERROR_ACCESS_DENIED) {
  8396             RETURN(true);
  8416 	    RETURN(true);
  8397         }
  8417 	}
  8398         // pid does not exist
  8418 	// pid does not exist
  8399         if (err == ERROR_INVALID_PARAMETER) {
  8419 	if (err == ERROR_INVALID_PARAMETER) {
  8400             RETURN(false);
  8420 	    RETURN(false);
  8401         }
  8421 	}
  8402 
  8422 
  8403         // any other error - raise signal
  8423 	// any other error - raise signal
  8404         __threadErrno = __WIN32_ERR(err);
  8424 	__threadErrno = __WIN32_ERR(err);
  8405         error = __mkSmallInteger(__threadErrno);
  8425 	error = __mkSmallInteger(__threadErrno);
  8406     } else {
  8426     } else {
  8407         error = @symbol(invalidParameter);
  8427 	error = @symbol(invalidParameter);
  8408     }
  8428     }
  8409 %}.
  8429 %}.
  8410 
  8430 
  8411     self primitiveFailed:error.
  8431     self primitiveFailed:error.
  8412 
  8432 
  8445 !
  8465 !
  8446 
  8466 
  8447 maxFileNameLength
  8467 maxFileNameLength
  8448     "return the max number of characters in a filename.
  8468     "return the max number of characters in a filename.
  8449      CAVEAT:
  8469      CAVEAT:
  8450          Actually, the following is somewhat wrong - some systems
  8470 	 Actually, the following is somewhat wrong - some systems
  8451          support different sizes, depending on the volume.
  8471 	 support different sizes, depending on the volume.
  8452          We return a somewhat conservative number here.
  8472 	 We return a somewhat conservative number here.
  8453          Another entry, to query for volume specific max
  8473 	 Another entry, to query for volume specific max
  8454          will be added in the future."
  8474 	 will be added in the future."
  8455 
  8475 
  8456 %{  /* NOCONTEXT */
  8476 %{  /* NOCONTEXT */
  8457 
  8477 
  8458     /*
  8478     /*
  8459      * TODO: newer systems provide a query function for this ... use it
  8479      * TODO: newer systems provide a query function for this ... use it
  8482 osName
  8502 osName
  8483     |osVersion|
  8503     |osVersion|
  8484 
  8504 
  8485     osVersion := OperatingSystem osVersion.
  8505     osVersion := OperatingSystem osVersion.
  8486     ^ 'Windows ',
  8506     ^ 'Windows ',
  8487         (#('NT' '2000' 'XP' 'VISTA' '7')
  8507 	(#('NT' '2000' 'XP' 'VISTA' '7')
  8488             at: (#('4.1' '5.0' '5.1' '6.0' '6.1') indexOf:osVersion)
  8508 	    at: (#('4.1' '5.0' '5.1' '6.0' '6.1') indexOf:osVersion)
  8489             ifAbsent:osVersion).
  8509 	    ifAbsent:osVersion).
  8490 
  8510 
  8491     "
  8511     "
  8492      self osName  
  8512      self osName
  8493     "
  8513     "
  8494 
  8514 
  8495     "Modified (comment): / 30-07-2011 / 17:00:50 / cg"
  8515     "Modified (comment): / 30-07-2011 / 17:00:50 / cg"
  8496 !
  8516 !
  8497 
  8517 
  8525     "Modified: 20.6.1997 / 17:37:26 / cg"
  8545     "Modified: 20.6.1997 / 17:37:26 / cg"
  8526 !
  8546 !
  8527 
  8547 
  8528 randomBytesInto:bufferOrInteger
  8548 randomBytesInto:bufferOrInteger
  8529     "If bufferOrInteger is a String or a ByteArray,
  8549     "If bufferOrInteger is a String or a ByteArray,
  8530         fill a given buffer with random bytes from the RtlGenRandom function
  8550 	fill a given buffer with random bytes from the RtlGenRandom function
  8531         and nswer the buffer.
  8551 	and nswer the buffer.
  8532 
  8552 
  8533      If bufferOrInteger is a SmallInteger,
  8553      If bufferOrInteger is a SmallInteger,
  8534         return this many bytes (max 4) as a SmallInteger.
  8554 	return this many bytes (max 4) as a SmallInteger.
  8535 
  8555 
  8536      Return nil on error (and raise PrimitiveFailure).
  8556      Return nil on error (and raise PrimitiveFailure).
  8537 
  8557 
  8538      NOTE: This is a private interface, please use RandomGenerator!!"
  8558      NOTE: This is a private interface, please use RandomGenerator!!"
  8539 
  8559 
  8547     int __bufferSize;
  8567     int __bufferSize;
  8548     int __useLocalBuffer = 0;
  8568     int __useLocalBuffer = 0;
  8549     unsigned int __localBuffer = 0;
  8569     unsigned int __localBuffer = 0;
  8550 
  8570 
  8551     if (__isSmallInteger(bufferOrInteger)) {
  8571     if (__isSmallInteger(bufferOrInteger)) {
  8552         __useLocalBuffer = 1;
  8572 	__useLocalBuffer = 1;
  8553         __buffer = (unsigned char *)&__localBuffer;
  8573 	__buffer = (unsigned char *)&__localBuffer;
  8554         __bufferSize = __smallIntegerVal(bufferOrInteger);
  8574 	__bufferSize = __smallIntegerVal(bufferOrInteger);
  8555         if (__bufferSize > sizeof(INT))
  8575 	if (__bufferSize > sizeof(INT))
  8556             __bufferSize = sizeof(INT);
  8576 	    __bufferSize = sizeof(INT);
  8557     } else if (__isString(bufferOrInteger)) {
  8577     } else if (__isString(bufferOrInteger)) {
  8558         __buffer = __stringVal(bufferOrInteger);
  8578 	__buffer = __stringVal(bufferOrInteger);
  8559         __bufferSize = __stringSize(bufferOrInteger);
  8579 	__bufferSize = __stringSize(bufferOrInteger);
  8560     } else if (__isByteArray(bufferOrInteger)) {
  8580     } else if (__isByteArray(bufferOrInteger)) {
  8561         __buffer = __byteArrayVal(bufferOrInteger);
  8581 	__buffer = __byteArrayVal(bufferOrInteger);
  8562         __bufferSize = __byteArraySize(bufferOrInteger);
  8582 	__bufferSize = __byteArraySize(bufferOrInteger);
  8563     } else {
  8583     } else {
  8564         goto error;
  8584 	goto error;
  8565     }
  8585     }
  8566 
  8586 
  8567     if (P_RtlGenRandom == 0) {
  8587     if (P_RtlGenRandom == 0) {
  8568         HINSTANCE hAdvapi32 = LoadLibrary("advapi32.dll");
  8588 	HINSTANCE hAdvapi32 = LoadLibrary("advapi32.dll");
  8569         // console_printf("hAdvapi32: %x\n", hAdvapi32);
  8589 	// console_printf("hAdvapi32: %x\n", hAdvapi32);
  8570         if (hAdvapi32) {
  8590 	if (hAdvapi32) {
  8571             P_RtlGenRandom = (BOOL (__stdcall *)(PVOID , ULONG))
  8591 	    P_RtlGenRandom = (BOOL (__stdcall *)(PVOID , ULONG))
  8572                                 GetProcAddress(hAdvapi32, "SystemFunction036");
  8592 				GetProcAddress(hAdvapi32, "SystemFunction036");
  8573             // console_printf("P_RtlGenRandom: %x\n", P_RtlGenRandom);
  8593 	    // console_printf("P_RtlGenRandom: %x\n", P_RtlGenRandom);
  8574             if (P_RtlGenRandom == 0) {
  8594 	    if (P_RtlGenRandom == 0) {
  8575                 goto error;
  8595 		goto error;
  8576             }
  8596 	    }
  8577         }
  8597 	}
  8578     }
  8598     }
  8579     if ((*P_RtlGenRandom)(__buffer, __bufferSize)) {
  8599     if ((*P_RtlGenRandom)(__buffer, __bufferSize)) {
  8580         if (__useLocalBuffer) {
  8600 	if (__useLocalBuffer) {
  8581             RETURN(__mkSmallInteger(__localBuffer & _MAX_INT));
  8601 	    RETURN(__mkSmallInteger(__localBuffer & _MAX_INT));
  8582         }
  8602 	}
  8583         RETURN (bufferOrInteger);
  8603 	RETURN (bufferOrInteger);
  8584     }
  8604     }
  8585 error: ;
  8605 error: ;
  8586 %}.
  8606 %}.
  8587     self primitiveFailed.
  8607     self primitiveFailed.
  8588     ^ nil
  8608     ^ nil
  8600 %{  /* NOCONTEXT */
  8620 %{  /* NOCONTEXT */
  8601     char *env;
  8621     char *env;
  8602 
  8622 
  8603     if (__isStringLike(aStringOrSymbol)
  8623     if (__isStringLike(aStringOrSymbol)
  8604      && __isStringLike(newValueString) ) {
  8624      && __isStringLike(newValueString) ) {
  8605         if (SetEnvironmentVariable(__stringVal(aStringOrSymbol), __stringVal(newValueString)) != 0) {
  8625 	if (SetEnvironmentVariable(__stringVal(aStringOrSymbol), __stringVal(newValueString)) != 0) {
  8606             RETURN(self);
  8626 	    RETURN(self);
  8607         }
  8627 	}
  8608     }
  8628     }
  8609 %}.
  8629 %}.
  8610     self primitiveFailed
  8630     self primitiveFailed
  8611 
  8631 
  8612     "
  8632     "
  8766     |pPath pkgDirPath dirs p|
  8786     |pPath pkgDirPath dirs p|
  8767 
  8787 
  8768     pPath := super defaultPackagePath.
  8788     pPath := super defaultPackagePath.
  8769     pkgDirPath := self stxPackageDirPath.
  8789     pkgDirPath := self stxPackageDirPath.
  8770     pkgDirPath notNil ifTrue:[
  8790     pkgDirPath notNil ifTrue:[
  8771         "/ and also add the packageDirPath from the registry ...
  8791 	"/ and also add the packageDirPath from the registry ...
  8772         dirs := pkgDirPath asCollectionOfSubstringsSeparatedBy:$;.
  8792 	dirs := pkgDirPath asCollectionOfSubstringsSeparatedBy:$;.
  8773         dirs do:[:aDir |
  8793 	dirs do:[:aDir |
  8774             (pPath includes:aDir) ifFalse:[
  8794 	    (pPath includes:aDir) ifFalse:[
  8775                 pPath add:aDir.
  8795 		pPath add:aDir.
  8776             ]
  8796 	    ]
  8777         ]
  8797 	]
  8778     ] ifFalse:[
  8798     ] ifFalse:[
  8779 "/        #(
  8799 "/        #(
  8780 "/            '\smalltalk'
  8800 "/            '\smalltalk'
  8781 "/            '\programme\smalltalk'
  8801 "/            '\programme\smalltalk'
  8782 "/            '\programme\eXept\smalltalk'
  8802 "/            '\programme\eXept\smalltalk'
  8795     ].
  8815     ].
  8796 
  8816 
  8797     "/ under windows, the commandName includes the path - good.
  8817     "/ under windows, the commandName includes the path - good.
  8798     p := Smalltalk commandName.
  8818     p := Smalltalk commandName.
  8799     p notNil ifTrue:[
  8819     p notNil ifTrue:[
  8800         p := p asFilename directory constructString:'packages'.
  8820 	p := p asFilename directory constructString:'packages'.
  8801         (pPath includes:p) ifFalse:[
  8821 	(pPath includes:p) ifFalse:[
  8802             pPath add:p.
  8822 	    pPath add:p.
  8803         ]
  8823 	]
  8804     ].
  8824     ].
  8805     pPath := pPath select:[:p | p asFilename exists].
  8825     pPath := pPath select:[:p | p asFilename exists].
  8806     ^ pPath
  8826     ^ pPath
  8807 
  8827 
  8808     "
  8828     "
  8818 
  8838 
  8819     sysPath := super defaultSystemPath.
  8839     sysPath := super defaultSystemPath.
  8820 
  8840 
  8821     libDirPath := self stxLibDirPath.
  8841     libDirPath := self stxLibDirPath.
  8822     libDirPath notNil ifTrue:[
  8842     libDirPath notNil ifTrue:[
  8823         "/ and also add the libDirPath from the registry ...
  8843 	"/ and also add the libDirPath from the registry ...
  8824         (sysPath includes:libDirPath) ifFalse:[
  8844 	(sysPath includes:libDirPath) ifFalse:[
  8825             sysPath add:libDirPath
  8845 	    sysPath add:libDirPath
  8826         ].
  8846 	].
  8827     ].
  8847     ].
  8828 "/    #(
  8848 "/    #(
  8829 "/        '\programs\eXept\smalltalk'
  8849 "/        '\programs\eXept\smalltalk'
  8830 "/        '\programme\eXept\smalltalk'
  8850 "/        '\programme\eXept\smalltalk'
  8831 "/        '\programs\smalltalk'
  8851 "/        '\programs\smalltalk'
  8857 
  8877 
  8858     |k p|
  8878     |k p|
  8859 
  8879 
  8860     k := RegistryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X\' , Smalltalk versionString.
  8880     k := RegistryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X\' , Smalltalk versionString.
  8861     k notNil ifTrue:[
  8881     k notNil ifTrue:[
  8862         p := k valueNamed:'BinDir'.
  8882 	p := k valueNamed:'BinDir'.
  8863     ].
  8883     ].
  8864     ^ p
  8884     ^ p
  8865 
  8885 
  8866     "
  8886     "
  8867      OperatingSystem stxBinDirPath
  8887      OperatingSystem stxBinDirPath
  8870 
  8890 
  8871 stxLibDirPath
  8891 stxLibDirPath
  8872     "ask the registry for the lib directory"
  8892     "ask the registry for the lib directory"
  8873 
  8893 
  8874     (Array
  8894     (Array
  8875         with:('HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X\' , Smalltalk versionString)
  8895 	with:('HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X\' , Smalltalk versionString)
  8876         with:('HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'))
  8896 	with:('HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'))
  8877     do:[:eachKeyToTry |
  8897     do:[:eachKeyToTry |
  8878         |k p|
  8898 	|k p|
  8879 
  8899 
  8880         k := RegistryEntry key:eachKeyToTry.
  8900 	k := RegistryEntry key:eachKeyToTry.
  8881         k notNil ifTrue:[
  8901 	k notNil ifTrue:[
  8882             p := k valueNamed:'LibDir'.
  8902 	    p := k valueNamed:'LibDir'.
  8883             k closeKey.
  8903 	    k closeKey.
  8884             ^ p
  8904 	    ^ p
  8885         ].
  8905 	].
  8886     ].
  8906     ].
  8887     ^ nil
  8907     ^ nil
  8888 
  8908 
  8889     "
  8909     "
  8890      OperatingSystem stxLibDirPath
  8910      OperatingSystem stxLibDirPath
  8896 
  8916 
  8897     |k p|
  8917     |k p|
  8898 
  8918 
  8899     k := RegistryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X\' , Smalltalk versionString.
  8919     k := RegistryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X\' , Smalltalk versionString.
  8900     k notNil ifTrue:[
  8920     k notNil ifTrue:[
  8901         p := k valueNamed:'PackageDirPath'.
  8921 	p := k valueNamed:'PackageDirPath'.
  8902     ].
  8922     ].
  8903     ^ p
  8923     ^ p
  8904 
  8924 
  8905     "
  8925     "
  8906      OperatingSystem stxPackageDirPath
  8926      OperatingSystem stxPackageDirPath
  8974 #define DM_IN_PROMPT        DM_PROMPT
  8994 #define DM_IN_PROMPT        DM_PROMPT
  8975 #define DM_OUT_BUFFER       DM_COPY
  8995 #define DM_OUT_BUFFER       DM_COPY
  8976 #define DM_OUT_DEFAULT      DM_UPDATE
  8996 #define DM_OUT_DEFAULT      DM_UPDATE
  8977 "
  8997 "
  8978     nBytesNeeded := self
  8998     nBytesNeeded := self
  8979            primDocumentProperties:nil
  8999 	   primDocumentProperties:nil
  8980            hPrinter:hPrinter
  9000 	   hPrinter:hPrinter
  8981            pDeviceName: deviceName
  9001 	   pDeviceName: deviceName
  8982            pDevModeOutput:nil
  9002 	   pDevModeOutput:nil
  8983            pDevModeInput:nil
  9003 	   pDevModeInput:nil
  8984            fMode:0.
  9004 	   fMode:0.
  8985 
  9005 
  8986     devModeOutput := DevModeStructure new:(nBytesNeeded * 2 "never trust MS !!").
  9006     devModeOutput := DevModeStructure new:(nBytesNeeded * 2 "never trust MS !!").
  8987 
  9007 
  8988     rslt := self
  9008     rslt := self
  8989            primDocumentProperties:nil
  9009 	   primDocumentProperties:nil
  8990            hPrinter:hPrinter
  9010 	   hPrinter:hPrinter
  8991            pDeviceName: deviceName
  9011 	   pDeviceName: deviceName
  8992            pDevModeOutput:devModeOutput
  9012 	   pDevModeOutput:devModeOutput
  8993            pDevModeInput:pDevModeInputOrNil
  9013 	   pDevModeInput:pDevModeInputOrNil
  8994            fMode:4+2.
  9014 	   fMode:4+2.
  8995 
  9015 
  8996     ^ devModeOutput
  9016     ^ devModeOutput
  8997 
  9017 
  8998     "
  9018     "
  8999      |h|
  9019      |h|
  9054 #define DM_IN_PROMPT        DM_PROMPT
  9074 #define DM_IN_PROMPT        DM_PROMPT
  9055 #define DM_OUT_BUFFER       DM_COPY
  9075 #define DM_OUT_BUFFER       DM_COPY
  9056 #define DM_OUT_DEFAULT      DM_UPDATE
  9076 #define DM_OUT_DEFAULT      DM_UPDATE
  9057 "
  9077 "
  9058     nBytesNeeded := self
  9078     nBytesNeeded := self
  9059            primDocumentProperties:nil
  9079 	   primDocumentProperties:nil
  9060            hPrinter:hPrinter
  9080 	   hPrinter:hPrinter
  9061            pDeviceName: deviceName
  9081 	   pDeviceName: deviceName
  9062            pDevModeOutput:nil
  9082 	   pDevModeOutput:nil
  9063            pDevModeInput:nil
  9083 	   pDevModeInput:nil
  9064            fMode:0.
  9084 	   fMode:0.
  9065 
  9085 
  9066     nBytesNeeded < 0 ifTrue:[^nil].
  9086     nBytesNeeded < 0 ifTrue:[^nil].
  9067     devModeOutput := DevModeStructure new:(nBytesNeeded * 2 "never trust MS !!").
  9087     devModeOutput := DevModeStructure new:(nBytesNeeded * 2 "never trust MS !!").
  9068 
  9088 
  9069     rslt := self
  9089     rslt := self
  9070            primDocumentProperties:nil
  9090 	   primDocumentProperties:nil
  9071            hPrinter:hPrinter
  9091 	   hPrinter:hPrinter
  9072            pDeviceName: deviceName
  9092 	   pDeviceName: deviceName
  9073            pDevModeOutput:devModeOutput
  9093 	   pDevModeOutput:devModeOutput
  9074            pDevModeInput:nil
  9094 	   pDevModeInput:nil
  9075            fMode:2.
  9095 	   fMode:2.
  9076 
  9096 
  9077      ^ devModeOutput
  9097      ^ devModeOutput
  9078 
  9098 
  9079     "
  9099     "
  9080      |h|
  9100      |h|
  9093 
  9113 
  9094      hPrinter := self openPrinter: printerName .
  9114      hPrinter := self openPrinter: printerName .
  9095      sizeBytesArray := ByteArray new:4.
  9115      sizeBytesArray := ByteArray new:4.
  9096 
  9116 
  9097      bytesNeeded := self
  9117      bytesNeeded := self
  9098                 primGetPrinter:hPrinter
  9118 		primGetPrinter:hPrinter
  9099                 level:2
  9119 		level:2
  9100                 informationBuffer: nil
  9120 		informationBuffer: nil
  9101                 bufferSize: 0
  9121 		bufferSize: 0
  9102                 bufferNeededSize:sizeBytesArray.
  9122 		bufferNeededSize:sizeBytesArray.
  9103      bytesNeeded := sizeBytesArray longAt:1.
  9123      bytesNeeded := sizeBytesArray longAt:1.
  9104      informationBuffer := PrinterInfo2Structure new: bytesNeeded.
  9124      informationBuffer := PrinterInfo2Structure new: bytesNeeded.
  9105      rslt := self
  9125      rslt := self
  9106                 primGetPrinter:hPrinter
  9126 		primGetPrinter:hPrinter
  9107                 level:2
  9127 		level:2
  9108                 informationBuffer:informationBuffer
  9128 		informationBuffer:informationBuffer
  9109                 bufferSize: bytesNeeded
  9129 		bufferSize: bytesNeeded
  9110                 bufferNeededSize:sizeBytesArray.
  9130 		bufferNeededSize:sizeBytesArray.
  9111      self closePrinter: printerName.
  9131      self closePrinter: printerName.
  9112      ^informationBuffer
  9132      ^informationBuffer
  9113 
  9133 
  9114     "
  9134     "
  9115      OperatingSystem getPrinterInfo2:(OperatingSystem getDefaultPrinterName)
  9135      OperatingSystem getPrinterInfo2:(OperatingSystem getDefaultPrinterName)
  9125     |printerNames collectedInfo|
  9145     |printerNames collectedInfo|
  9126 
  9146 
  9127     printerNames := self getPrintersNames.
  9147     printerNames := self getPrintersNames.
  9128     collectedInfo := OrderedCollection new.
  9148     collectedInfo := OrderedCollection new.
  9129     printerNames do:[:eachName |
  9149     printerNames do:[:eachName |
  9130         |fn vol attributes nm deviceInfo infoFields driverName|
  9150 	|fn vol attributes nm deviceInfo infoFields driverName|
  9131 
  9151 
  9132         attributes := Dictionary new.
  9152 	attributes := Dictionary new.
  9133 
  9153 
  9134         fn := eachName asFilename.
  9154 	fn := eachName asFilename.
  9135         vol := fn volume.
  9155 	vol := fn volume.
  9136         vol notEmptyOrNil ifTrue:[
  9156 	vol notEmptyOrNil ifTrue:[
  9137             (vol startsWith:'\\') ifTrue:[
  9157 	    (vol startsWith:'\\') ifTrue:[
  9138                 "/ a remote printer
  9158 		"/ a remote printer
  9139                 attributes at:#isRemotePrinter put:true.
  9159 		attributes at:#isRemotePrinter put:true.
  9140                 attributes at:#remotePrinterName put:(fn baseName).
  9160 		attributes at:#remotePrinterName put:(fn baseName).
  9141                 attributes at:#remotePrinterHost put:(fn directoryName copyFrom:3).
  9161 		attributes at:#remotePrinterHost put:(fn directoryName copyFrom:3).
  9142             ] ifFalse:[
  9162 	    ] ifFalse:[
  9143                 "/ some other printer
  9163 		"/ some other printer
  9144             ].
  9164 	    ].
  9145         ] ifFalse:[
  9165 	] ifFalse:[
  9146             "/ some other printer
  9166 	    "/ some other printer
  9147         ].
  9167 	].
  9148 
  9168 
  9149         deviceInfo := self getProfileString:'PrinterPorts' key:eachName default:''.
  9169 	deviceInfo := self getProfileString:'PrinterPorts' key:eachName default:''.
  9150         "gives us smething like 'winspool,Ne00:,15,45',
  9170 	"gives us smething like 'winspool,Ne00:,15,45',
  9151          which is: driverName, deviceName, ? , ?"
  9171 	 which is: driverName, deviceName, ? , ?"
  9152 
  9172 
  9153         infoFields := deviceInfo asCollectionOfSubstringsSeparatedBy:$,.
  9173 	infoFields := deviceInfo asCollectionOfSubstringsSeparatedBy:$,.
  9154         driverName := infoFields at:1.
  9174 	driverName := infoFields at:1.
  9155         2 to: infoFields size by:3 do:[:i |
  9175 	2 to: infoFields size by:3 do:[:i |
  9156             |medium longName|
  9176 	    |medium longName|
  9157 
  9177 
  9158             medium := infoFields at:i.
  9178 	    medium := infoFields at:i.
  9159             longName := eachName ,',' , driverName , ',' , medium.
  9179 	    longName := eachName ,',' , driverName , ',' , medium.
  9160             attributes at:#driverName put:driverName.
  9180 	    attributes at:#driverName put:driverName.
  9161             attributes at:#longName put:longName.
  9181 	    attributes at:#longName put:longName.
  9162             attributes at:#medium put:medium.
  9182 	    attributes at:#medium put:medium.
  9163 
  9183 
  9164             collectedInfo add:
  9184 	    collectedInfo add:
  9165                 (AbstractOperatingSystem::PrinterInfo new
  9185 		(AbstractOperatingSystem::PrinterInfo new
  9166                     printerName:eachName
  9186 		    printerName:eachName
  9167                     attributes:attributes;
  9187 		    attributes:attributes;
  9168                     setDocumentProperties;
  9188 		    setDocumentProperties;
  9169                     yourself)
  9189 		    yourself)
  9170         ].
  9190 	].
  9171     ].
  9191     ].
  9172     ^ collectedInfo
  9192     ^ collectedInfo
  9173 
  9193 
  9174     "
  9194     "
  9175      OperatingSystem getPrinters
  9195      OperatingSystem getPrinters
  9183     "return a collection of Printer names"
  9203     "return a collection of Printer names"
  9184 
  9204 
  9185     |printerNames|
  9205     |printerNames|
  9186 
  9206 
  9187     printerNames := (self getProfileString:'PrinterPorts' key:nil default:'')
  9207     printerNames := (self getProfileString:'PrinterPorts' key:nil default:'')
  9188                        asCollectionOfSubstringsSeparatedBy:(Character value:0).
  9208 		       asCollectionOfSubstringsSeparatedBy:(Character value:0).
  9189     printerNames := printerNames reject:[:nm | nm isEmpty].
  9209     printerNames := printerNames reject:[:nm | nm isEmpty].
  9190     ^printerNames
  9210     ^printerNames
  9191 
  9211 
  9192     "
  9212     "
  9193      OperatingSystem getPrintersNames
  9213      OperatingSystem getPrintersNames
  9272     "
  9292     "
  9273      |hPrinter rslt|
  9293      |hPrinter rslt|
  9274 
  9294 
  9275      hPrinter := self openPrinter:'\\http://exept.exept.de:631\lj4' .
  9295      hPrinter := self openPrinter:'\\http://exept.exept.de:631\lj4' .
  9276      rslt := self
  9296      rslt := self
  9277             primDocumentProperties:nil
  9297 	    primDocumentProperties:nil
  9278             hPrinter:hPrinter
  9298 	    hPrinter:hPrinter
  9279             pDeviceName: '\\http://exept.exept.de:631\lj4'
  9299 	    pDeviceName: '\\http://exept.exept.de:631\lj4'
  9280             pDevModeOutput:nil
  9300 	    pDevModeOutput:nil
  9281             pDevModeInput:nil
  9301 	    pDevModeInput:nil
  9282             fMode:0.
  9302 	    fMode:0.
  9283 
  9303 
  9284      self halt.
  9304      self halt.
  9285     "
  9305     "
  9286 
  9306 
  9287     "Created: / 27-07-2006 / 15:02:14 / fm"
  9307     "Created: / 27-07-2006 / 15:02:14 / fm"
  9294     "
  9314     "
  9295      |hPrinter rslt|
  9315      |hPrinter rslt|
  9296 
  9316 
  9297      hPrinter := self openPrinter:'\\http://exept.exept.de:631\lj4' .
  9317      hPrinter := self openPrinter:'\\http://exept.exept.de:631\lj4' .
  9298      rslt := self
  9318      rslt := self
  9299             primDocumentProperties:nil
  9319 	    primDocumentProperties:nil
  9300             hPrinter:hPrinter
  9320 	    hPrinter:hPrinter
  9301             pDeviceName: '\\http://exept.exept.de:631\lj4'
  9321 	    pDeviceName: '\\http://exept.exept.de:631\lj4'
  9302             pDevModeOutput:nil
  9322 	    pDevModeOutput:nil
  9303             pDevModeInput:nil
  9323 	    pDevModeInput:nil
  9304             fMode:0.
  9324 	    fMode:0.
  9305 
  9325 
  9306      self halt.
  9326      self halt.
  9307     "
  9327     "
  9308 
  9328 
  9309     "Created: / 27-07-2006 / 19:31:31 / fm"
  9329     "Created: / 27-07-2006 / 19:31:31 / fm"
  9316     "
  9336     "
  9317      |hPrinter rslt|
  9337      |hPrinter rslt|
  9318 
  9338 
  9319      hPrinter := self openPrinter:'\\http://exept.exept.de:631\lj4' .
  9339      hPrinter := self openPrinter:'\\http://exept.exept.de:631\lj4' .
  9320      rslt := self
  9340      rslt := self
  9321             primDocumentProperties:nil
  9341 	    primDocumentProperties:nil
  9322             hPrinter:hPrinter
  9342 	    hPrinter:hPrinter
  9323             pDeviceName: '\\http://exept.exept.de:631\lj4'
  9343 	    pDeviceName: '\\http://exept.exept.de:631\lj4'
  9324             pDevModeOutput:nil
  9344 	    pDevModeOutput:nil
  9325             pDevModeInput:nil
  9345 	    pDevModeInput:nil
  9326             fMode:0.
  9346 	    fMode:0.
  9327 
  9347 
  9328      self halt.
  9348      self halt.
  9329     "
  9349     "
  9330 
  9350 
  9331     "Created: / 27-07-2006 / 19:30:50 / fm"
  9351     "Created: / 27-07-2006 / 19:30:50 / fm"
  9350      printerName := '\\http://exept.exept.de:631\lj4'.
  9370      printerName := '\\http://exept.exept.de:631\lj4'.
  9351      hPrinter := self openPrinter: printerName .
  9371      hPrinter := self openPrinter: printerName .
  9352 
  9372 
  9353      sizeBytesArray := ByteArray new:4.
  9373      sizeBytesArray := ByteArray new:4.
  9354      ok := self
  9374      ok := self
  9355                 primGetPrinter:hPrinter
  9375 		primGetPrinter:hPrinter
  9356                 level:2
  9376 		level:2
  9357                 informationBuffer: nil
  9377 		informationBuffer: nil
  9358                 bufferSize: 0
  9378 		bufferSize: 0
  9359                 bufferNeededSize:sizeBytesArray.
  9379 		bufferNeededSize:sizeBytesArray.
  9360      bytesNeeded := sizeBytesArray longAt:1.
  9380      bytesNeeded := sizeBytesArray longAt:1.
  9361 
  9381 
  9362      informationBuffer := PrinterInfo2Structure new: bytesNeeded.
  9382      informationBuffer := PrinterInfo2Structure new: bytesNeeded.
  9363      rslt := self
  9383      rslt := self
  9364                 primGetPrinter:hPrinter
  9384 		primGetPrinter:hPrinter
  9365                 level:2
  9385 		level:2
  9366                 informationBuffer:informationBuffer
  9386 		informationBuffer:informationBuffer
  9367                 bufferSize: bytesNeeded
  9387 		bufferSize: bytesNeeded
  9368                 bufferNeededSize:sizeBytesArray.
  9388 		bufferNeededSize:sizeBytesArray.
  9369      self assert: rslt.
  9389      self assert: rslt.
  9370      informationBuffer inspect.
  9390      informationBuffer inspect.
  9371      self closePrinter: printerName.
  9391      self closePrinter: printerName.
  9372 "
  9392 "
  9373 
  9393 
  9493       'CSY'     'cs_CS'
  9513       'CSY'     'cs_CS'
  9494       'ELL'     'el_EL'
  9514       'ELL'     'el_EL'
  9495       'NON'     'no_NO'
  9515       'NON'     'no_NO'
  9496       'NOR'     'no_NO'
  9516       'NOR'     'no_NO'
  9497      ) pairWiseDo:[:key :mappedValue|
  9517      ) pairWiseDo:[:key :mappedValue|
  9498         key = windowsLanguageString ifTrue:[
  9518 	key = windowsLanguageString ifTrue:[
  9499             ^ mappedValue
  9519 	    ^ mappedValue
  9500         ]
  9520 	]
  9501     ].
  9521     ].
  9502 
  9522 
  9503     "no mapping"
  9523     "no mapping"
  9504     ^ windowsLanguageString.
  9524     ^ windowsLanguageString.
  9505 
  9525 
  9515 ! !
  9535 ! !
  9516 
  9536 
  9517 !Win32OperatingSystem class methodsFor:'regional settings'!
  9537 !Win32OperatingSystem class methodsFor:'regional settings'!
  9518 
  9538 
  9519 country
  9539 country
  9520         "Answer the current system value for country."
  9540 	"Answer the current system value for country."
  9521 
  9541 
  9522     ^self queryNationalProfileString: 'iCountry' default: 0
  9542     ^self queryNationalProfileString: 'iCountry' default: 0
  9523 
  9543 
  9524     "
  9544     "
  9525         self country
  9545 	self country
  9526     "
  9546     "
  9527 
  9547 
  9528     "Modified: / 22-12-2006 / 16:45:32 / User"
  9548     "Modified: / 22-12-2006 / 16:45:32 / User"
  9529 !
  9549 !
  9530 
  9550 
  9531 countryName
  9551 countryName
  9532         "Answer the current system value for country name."
  9552 	"Answer the current system value for country name."
  9533 
  9553 
  9534     ^self queryNationalProfileString: 'sCountry' default: 'Deutschland'
  9554     ^self queryNationalProfileString: 'sCountry' default: 'Deutschland'
  9535 
  9555 
  9536     "
  9556     "
  9537         self countryName
  9557 	self countryName
  9538     "
  9558     "
  9539 
  9559 
  9540     "Modified: / 22-12-2006 / 16:45:32 / User"
  9560     "Modified: / 22-12-2006 / 16:45:32 / User"
  9541 !
  9561 !
  9542 
  9562 
  9543 dateFormat
  9563 dateFormat
  9544     "Answer the current system value for date format.
  9564     "Answer the current system value for date format.
  9545      Answer DfMDY = Month-Day-Year
  9565      Answer DfMDY = Month-Day-Year
  9546             DfDMY = Day-Month-Year
  9566 	    DfDMY = Day-Month-Year
  9547             DfYMD = Year-Month-Day."
  9567 	    DfYMD = Year-Month-Day."
  9548 
  9568 
  9549     |separatorString code|
  9569     |separatorString code|
  9550 
  9570 
  9551     separatorString := self dateSeparator.
  9571     separatorString := self dateSeparator.
  9552 
  9572 
  9564     "Modified: / 22-12-2006 / 16:43:30 / User"
  9584     "Modified: / 22-12-2006 / 16:43:30 / User"
  9565     "Modified: / 28-03-2011 / 17:10:01 / cg"
  9585     "Modified: / 28-03-2011 / 17:10:01 / cg"
  9566 !
  9586 !
  9567 
  9587 
  9568 dateFormatCode
  9588 dateFormatCode
  9569         "Answer the current system value for date format.
  9589 	"Answer the current system value for date format.
  9570          Answer DfMDY = Month-Day-Year = 0
  9590 	 Answer DfMDY = Month-Day-Year = 0
  9571                 DfDMY = Day-Month-Year = 1
  9591 		DfDMY = Day-Month-Year = 1
  9572                 DfYMD = Year-Month-Day = 2"
  9592 		DfYMD = Year-Month-Day = 2"
  9573 
  9593 
  9574     ^self queryNationalProfileInt: 'iDate' default: 0
  9594     ^self queryNationalProfileInt: 'iDate' default: 0
  9575 
  9595 
  9576     "
  9596     "
  9577         self dateFormatCode
  9597 	self dateFormatCode
  9578     "
  9598     "
  9579 
  9599 
  9580     "Modified: / 22-12-2006 / 16:45:53 / User"
  9600     "Modified: / 22-12-2006 / 16:45:53 / User"
  9581 !
  9601 !
  9582 
  9602 
  9583 dateSeparator
  9603 dateSeparator
  9584         "Answer the current system value for date separator."
  9604 	"Answer the current system value for date separator."
  9585 
  9605 
  9586     ^self queryNationalProfileString: 'sDate' default: '/'
  9606     ^self queryNationalProfileString: 'sDate' default: '/'
  9587 
  9607 
  9588     "
  9608     "
  9589         self dateSeparator
  9609 	self dateSeparator
  9590     "
  9610     "
  9591 
  9611 
  9592     "Modified: / 22-12-2006 / 16:45:32 / User"
  9612     "Modified: / 22-12-2006 / 16:45:32 / User"
  9593 !
  9613 !
  9594 
  9614 
  9595 decimalSeparator
  9615 decimalSeparator
  9596         "Answer the current system value for decimal separator."
  9616 	"Answer the current system value for decimal separator."
  9597 
  9617 
  9598     ^self queryNationalProfileString: 'sDecimal' default: '.'
  9618     ^self queryNationalProfileString: 'sDecimal' default: '.'
  9599 
  9619 
  9600     "
  9620     "
  9601         self decimalSeparator
  9621 	self decimalSeparator
  9602     "
  9622     "
  9603 
  9623 
  9604     "Created: / 22-12-2006 / 16:45:11 / User"
  9624     "Created: / 22-12-2006 / 16:45:11 / User"
  9605 !
  9625 !
  9606 
  9626 
  9607 isDateFormatDMY
  9627 isDateFormatDMY
  9608         "Answer the current system value for date format.
  9628 	"Answer the current system value for date format.
  9609          Answer DfMDY = Month-Day-Year
  9629 	 Answer DfMDY = Month-Day-Year
  9610                 DfDMY = Day-Month-Year
  9630 		DfDMY = Day-Month-Year
  9611                 DfYMD = Year-Month-Day."
  9631 		DfYMD = Year-Month-Day."
  9612 
  9632 
  9613     ^self dateFormatCode = 1
  9633     ^self dateFormatCode = 1
  9614 
  9634 
  9615     "Created: / 18-01-2007 / 14:56:23 / User"
  9635     "Created: / 18-01-2007 / 14:56:23 / User"
  9616 !
  9636 !
  9617 
  9637 
  9618 isDateFormatMDY
  9638 isDateFormatMDY
  9619         "Answer the current system value for date format.
  9639 	"Answer the current system value for date format.
  9620          Answer DfMDY = Month-Day-Year
  9640 	 Answer DfMDY = Month-Day-Year
  9621                 DfDMY = Day-Month-Year
  9641 		DfDMY = Day-Month-Year
  9622                 DfYMD = Year-Month-Day."
  9642 		DfYMD = Year-Month-Day."
  9623 
  9643 
  9624     ^self dateFormatCode = 0
  9644     ^self dateFormatCode = 0
  9625 
  9645 
  9626     "Created: / 18-01-2007 / 14:56:07 / User"
  9646     "Created: / 18-01-2007 / 14:56:07 / User"
  9627 !
  9647 !
  9628 
  9648 
  9629 isDateFormatYMD
  9649 isDateFormatYMD
  9630         "Answer the current system value for date format.
  9650 	"Answer the current system value for date format.
  9631          Answer DfMDY = Month-Day-Year
  9651 	 Answer DfMDY = Month-Day-Year
  9632                 DfDMY = Day-Month-Year
  9652 		DfDMY = Day-Month-Year
  9633                 DfYMD = Year-Month-Day."
  9653 		DfYMD = Year-Month-Day."
  9634 
  9654 
  9635     ^self dateFormatCode = 2
  9655     ^self dateFormatCode = 2
  9636 
  9656 
  9637     "Created: / 18-01-2007 / 14:56:30 / User"
  9657     "Created: / 18-01-2007 / 14:56:30 / User"
  9638 !
  9658 !
  9639 
  9659 
  9640 isTimeFormat12Hour
  9660 isTimeFormat12Hour
  9641         "Answer whether the current system time format is 12-hour."
  9661 	"Answer whether the current system time format is 12-hour."
  9642 
  9662 
  9643     ^self timeFormat = 0
  9663     ^self timeFormat = 0
  9644 
  9664 
  9645     "Created: / 22-12-2006 / 16:48:17 / User"
  9665     "Created: / 22-12-2006 / 16:48:17 / User"
  9646 !
  9666 !
  9663 
  9683 
  9664 queryNationalProfileInt: aKeyName default: defaultValue
  9684 queryNationalProfileInt: aKeyName default: defaultValue
  9665 
  9685 
  9666     | answer |
  9686     | answer |
  9667     answer := self primGetProfileInt: 'Intl'
  9687     answer := self primGetProfileInt: 'Intl'
  9668         keyName: aKeyName
  9688 	keyName: aKeyName
  9669         default: -1 asUnsigned32.
  9689 	default: -1 asUnsigned32.
  9670     ^answer = -1 asUnsigned32
  9690     ^answer = -1 asUnsigned32
  9671         ifTrue: [ defaultValue ]
  9691 	ifTrue: [ defaultValue ]
  9672         ifFalse: [ answer ]
  9692 	ifFalse: [ answer ]
  9673 
  9693 
  9674 "
  9694 "
  9675     self queryNationalProfileInt: 'iDate' default: 0
  9695     self queryNationalProfileInt: 'iDate' default: 0
  9676 "
  9696 "
  9677 
  9697 
  9678     "Modified: / 22-12-2006 / 16:23:05 / User"
  9698     "Modified: / 22-12-2006 / 16:23:05 / User"
  9679 !
  9699 !
  9680 
  9700 
  9681 queryNationalProfileString: aKeyName default: defaultValue
  9701 queryNationalProfileString: aKeyName default: defaultValue
  9682         "Answer the string value of key aKeyName in
  9702 	"Answer the string value of key aKeyName in
  9683         the [Intl] application section of the WIN.INI profile file.
  9703 	the [Intl] application section of the WIN.INI profile file.
  9684         Answer defaultValue if aKeyName cannot be found."
  9704 	Answer defaultValue if aKeyName cannot be found."
  9685     | extString result |
  9705     | extString result |
  9686     extString := String new: 80.
  9706     extString := String new: 80.
  9687     result := self primGetProfileString: 'Intl'
  9707     result := self primGetProfileString: 'Intl'
  9688         keyName: aKeyName
  9708 	keyName: aKeyName
  9689         default: ''
  9709 	default: ''
  9690         returnedString: extString
  9710 	returnedString: extString
  9691         size: extString size.
  9711 	size: extString size.
  9692     ^result > 0
  9712     ^result > 0
  9693         ifTrue: [extString copyFrom: 1 to: result]
  9713 	ifTrue: [extString copyFrom: 1 to: result]
  9694         ifFalse: [ defaultValue ]
  9714 	ifFalse: [ defaultValue ]
  9695 
  9715 
  9696     "Created: / 22-12-2006 / 16:13:01 / User"
  9716     "Created: / 22-12-2006 / 16:13:01 / User"
  9697 !
  9717 !
  9698 
  9718 
  9699 thousandsSeparator
  9719 thousandsSeparator
  9700         "Answer the current system value
  9720 	"Answer the current system value
  9701         for the thousands separator."
  9721 	for the thousands separator."
  9702 
  9722 
  9703     ^self queryNationalProfileString: 'sThousand' default: ','
  9723     ^self queryNationalProfileString: 'sThousand' default: ','
  9704 
  9724 
  9705     "
  9725     "
  9706         self thousandsSeparator
  9726 	self thousandsSeparator
  9707     "
  9727     "
  9708 
  9728 
  9709     "Created: / 22-12-2006 / 16:46:50 / User"
  9729     "Created: / 22-12-2006 / 16:46:50 / User"
  9710 !
  9730 !
  9711 
  9731 
  9712 timeFormat
  9732 timeFormat
  9713         "Answer the current system value for time format."
  9733 	"Answer the current system value for time format."
  9714 
  9734 
  9715     ^self queryNationalProfileInt: 'iTime' default: 0
  9735     ^self queryNationalProfileInt: 'iTime' default: 0
  9716 
  9736 
  9717     "
  9737     "
  9718         self timeFormat
  9738 	self timeFormat
  9719     "
  9739     "
  9720 
  9740 
  9721     "Created: / 22-12-2006 / 16:48:27 / User"
  9741     "Created: / 22-12-2006 / 16:48:27 / User"
  9722 ! !
  9742 ! !
  9723 
  9743 
  9742 openApplicationForDocument:aFilenameOrString operation:operationSymbol
  9762 openApplicationForDocument:aFilenameOrString operation:operationSymbol
  9743     "open a windows-shell application to present the document contained in aFilenameOrString.
  9763     "open a windows-shell application to present the document contained in aFilenameOrString.
  9744      This looks for the files extension, and is typically used to present help-files,
  9764      This looks for the files extension, and is typically used to present help-files,
  9745      html documents, pdf documents etc.
  9765      html documents, pdf documents etc.
  9746      operationSymbol is one of:
  9766      operationSymbol is one of:
  9747         open
  9767 	open
  9748         edit
  9768 	edit
  9749         explore
  9769 	explore
  9750         print
  9770 	print
  9751     "
  9771     "
  9752 
  9772 
  9753     |result filename|
  9773     |result filename|
  9754 
  9774 
  9755     filename := aFilenameOrString asFilename.
  9775     filename := aFilenameOrString asFilename.
  9756     result := self
  9776     result := self
  9757         shellExecute:nil
  9777 	shellExecute:nil
  9758         lpOperation:operationSymbol
  9778 	lpOperation:operationSymbol
  9759         lpFile:filename pathName
  9779 	lpFile:filename pathName
  9760         lpParameters:nil
  9780 	lpParameters:nil
  9761         lpDirectory:filename directory pathName
  9781 	lpDirectory:filename directory pathName
  9762         nShowCmd:#SW_SHOWNORMAL.
  9782 	nShowCmd:#SW_SHOWNORMAL.
  9763     ^ self.
  9783     ^ self.
  9764 
  9784 
  9765     "
  9785     "
  9766      self openApplicationForDocument: Filename currentDirectory operation:#open
  9786      self openApplicationForDocument: Filename currentDirectory operation:#open
  9767      self openApplicationForDocument: '..\..\doc\books\ArtOfSmalltalk\artMissing186187Fix1.pdf' asFilename operation:#open
  9787      self openApplicationForDocument: '..\..\doc\books\ArtOfSmalltalk\artMissing186187Fix1.pdf' asFilename operation:#open
  9794      since my windows system menu crashes so often
  9814      since my windows system menu crashes so often
  9795      (even CTRL-ALT-DEL does no longer function, but ST/X is still alive),
  9815      (even CTRL-ALT-DEL does no longer function, but ST/X is still alive),
  9796      I added this in order to be able to shutdown w95 cleanly"
  9816      I added this in order to be able to shutdown w95 cleanly"
  9797 
  9817 
  9798     confirmationMessageOrNil notNil ifTrue:[
  9818     confirmationMessageOrNil notNil ifTrue:[
  9799         (Dialog confirm:confirmationMessageOrNil) ifFalse:[
  9819 	(Dialog confirm:confirmationMessageOrNil) ifFalse:[
  9800             ^ false
  9820 	    ^ false
  9801         ].
  9821 	].
  9802     ].
  9822     ].
  9803 %{
  9823 %{
  9804     int flag;
  9824     int flag;
  9805 
  9825 
  9806     if (how == @symbol(shutdown)) {
  9826     if (how == @symbol(shutdown)) {
  9807         flag = EWX_SHUTDOWN;
  9827 	flag = EWX_SHUTDOWN;
  9808     } else if (how == @symbol(reboot)) {
  9828     } else if (how == @symbol(reboot)) {
  9809         flag = EWX_REBOOT;
  9829 	flag = EWX_REBOOT;
  9810     } else if (how == @symbol(logoff)) {
  9830     } else if (how == @symbol(logoff)) {
  9811         flag = EWX_LOGOFF;
  9831 	flag = EWX_LOGOFF;
  9812     } else if (how == @symbol(forceShutdown)) {
  9832     } else if (how == @symbol(forceShutdown)) {
  9813         flag = EWX_SHUTDOWN | EWX_FORCE;
  9833 	flag = EWX_SHUTDOWN | EWX_FORCE;
  9814     } else if (how == @symbol(forceReboot)) {
  9834     } else if (how == @symbol(forceReboot)) {
  9815         flag = EWX_REBOOT | EWX_FORCE;
  9835 	flag = EWX_REBOOT | EWX_FORCE;
  9816     } else if (how == @symbol(forceLogoff)) {
  9836     } else if (how == @symbol(forceLogoff)) {
  9817         flag = EWX_LOGOFF | EWX_FORCE;
  9837 	flag = EWX_LOGOFF | EWX_FORCE;
  9818     } else {
  9838     } else {
  9819         RETURN (false);
  9839 	RETURN (false);
  9820     }
  9840     }
  9821     RETURN ((ExitWindowsEx(flag, 0) == TRUE) ? true : false);
  9841     RETURN ((ExitWindowsEx(flag, 0) == TRUE) ? true : false);
  9822 %}
  9842 %}
  9823 ! !
  9843 ! !
  9824 
  9844 
  9831 %{
  9851 %{
  9832     if (__bothSmallInteger(y, m)
  9852     if (__bothSmallInteger(y, m)
  9833      && __bothSmallInteger(d, h)
  9853      && __bothSmallInteger(d, h)
  9834      && __bothSmallInteger(min, s)
  9854      && __bothSmallInteger(min, s)
  9835      && __isSmallInteger(millis)) {
  9855      && __isSmallInteger(millis)) {
  9836         SYSTEMTIME sysTime;
  9856 	SYSTEMTIME sysTime;
  9837         FILETIME fileTime;
  9857 	FILETIME fileTime;
  9838 
  9858 
  9839         sysTime.wHour = __intVal(h);
  9859 	sysTime.wHour = __intVal(h);
  9840         sysTime.wMinute = __intVal(min);
  9860 	sysTime.wMinute = __intVal(min);
  9841         sysTime.wSecond = __intVal(s);
  9861 	sysTime.wSecond = __intVal(s);
  9842         sysTime.wMilliseconds = __intVal(millis);
  9862 	sysTime.wMilliseconds = __intVal(millis);
  9843 
  9863 
  9844         sysTime.wYear = __intVal(y);
  9864 	sysTime.wYear = __intVal(y);
  9845         sysTime.wMonth = __intVal(m);
  9865 	sysTime.wMonth = __intVal(m);
  9846         sysTime.wDay = __intVal(d);
  9866 	sysTime.wDay = __intVal(d);
  9847 
  9867 
  9848         if (SystemTimeToFileTime(&sysTime, &fileTime) == 0)
  9868 	if (SystemTimeToFileTime(&sysTime, &fileTime) == 0)
  9849             goto error;
  9869 	    goto error;
  9850 
  9870 
  9851         RETURN(FileTimeToOsTime(&fileTime));
  9871 	RETURN(FileTimeToOsTime(&fileTime));
  9852     }
  9872     }
  9853 error:;
  9873 error:;
  9854 %}.
  9874 %}.
  9855     "Error, some invalid date ot time"
  9875     "Error, some invalid date ot time"
  9856     ^ TimeConversionError raiseRequest
  9876     ^ TimeConversionError raiseRequest
  9872 %{
  9892 %{
  9873     if (__bothSmallInteger(y, m)
  9893     if (__bothSmallInteger(y, m)
  9874      && __bothSmallInteger(d, h)
  9894      && __bothSmallInteger(d, h)
  9875      && __bothSmallInteger(min, s)
  9895      && __bothSmallInteger(min, s)
  9876      && __isSmallInteger(millis)) {
  9896      && __isSmallInteger(millis)) {
  9877         SYSTEMTIME sysTime;
  9897 	SYSTEMTIME sysTime;
  9878         FILETIME fileTime;
  9898 	FILETIME fileTime;
  9879 
  9899 
  9880         sysTime.wHour = __intVal(h);
  9900 	sysTime.wHour = __intVal(h);
  9881         sysTime.wMinute = __intVal(min);
  9901 	sysTime.wMinute = __intVal(min);
  9882         sysTime.wSecond = __intVal(s);
  9902 	sysTime.wSecond = __intVal(s);
  9883         sysTime.wMilliseconds = __intVal(millis);
  9903 	sysTime.wMilliseconds = __intVal(millis);
  9884 
  9904 
  9885         sysTime.wYear = __intVal(y);
  9905 	sysTime.wYear = __intVal(y);
  9886         sysTime.wMonth = __intVal(m);
  9906 	sysTime.wMonth = __intVal(m);
  9887         sysTime.wDay = __intVal(d);
  9907 	sysTime.wDay = __intVal(d);
  9888 
  9908 
  9889 #if 0
  9909 #if 0
  9890         /* Sorry, but this function is not supported in Win2000
  9910 	/* Sorry, but this function is not supported in Win2000
  9891            - we use LocalFileTimeToFileTime */
  9911 	   - we use LocalFileTimeToFileTime */
  9892         if (TzSpecificLocalTimeToSystemTime(0, &sysTime, &sysTime) == 0)
  9912 	if (TzSpecificLocalTimeToSystemTime(0, &sysTime, &sysTime) == 0)
  9893             goto error;
  9913 	    goto error;
  9894 #endif
  9914 #endif
  9895         if (SystemTimeToFileTime(&sysTime, &fileTime) == 0)
  9915 	if (SystemTimeToFileTime(&sysTime, &fileTime) == 0)
  9896             goto error;
  9916 	    goto error;
  9897         if (LocalFileTimeToFileTime(&fileTime, &fileTime) == 0)
  9917 	if (LocalFileTimeToFileTime(&fileTime, &fileTime) == 0)
  9898             goto error;
  9918 	    goto error;
  9899 
  9919 
  9900         RETURN(FileTimeToOsTime(&fileTime));
  9920 	RETURN(FileTimeToOsTime(&fileTime));
  9901     }
  9921     }
  9902 error:;
  9922 error:;
  9903 %}.
  9923 %}.
  9904     "Error, some invalid date ot time"
  9924     "Error, some invalid date ot time"
  9905     ^ TimeConversionError raiseRequest
  9925     ^ TimeConversionError raiseRequest
  9925     static LONGLONG divisor;
  9945     static LONGLONG divisor;
  9926     LONGLONG tick;     // A point in time
  9946     LONGLONG tick;     // A point in time
  9927     LONGLONG micros;
  9947     LONGLONG micros;
  9928 
  9948 
  9929     if (! frequencyKnown) {
  9949     if (! frequencyKnown) {
  9930         // get the high resolution counter's accuracy
  9950 	// get the high resolution counter's accuracy
  9931         QueryPerformanceFrequency(&ticksPerSecond);
  9951 	QueryPerformanceFrequency(&ticksPerSecond);
  9932         frequencyKnown = 1;
  9952 	frequencyKnown = 1;
  9933         divisor = ticksPerSecond / (LONGLONG)1000000;
  9953 	divisor = ticksPerSecond / (LONGLONG)1000000;
  9934     }
  9954     }
  9935 
  9955 
  9936     // what time is it?
  9956     // what time is it?
  9937     QueryPerformanceCounter(&tick);
  9957     QueryPerformanceCounter(&tick);
  9938 
  9958 
  9964      Since this value is wrapping around in regular intervals (approx. every 6.21 days),
  9984      Since this value is wrapping around in regular intervals (approx. every 6.21 days),
  9965      this can only be used for short relative time deltas.
  9985      this can only be used for short relative time deltas.
  9966      Use the millisecondTimeXXX:-methods to compare and add time deltas - these know about the wrap.
  9986      Use the millisecondTimeXXX:-methods to compare and add time deltas - these know about the wrap.
  9967 
  9987 
  9968      BAD DESIGN:
  9988      BAD DESIGN:
  9969         This should be changed to return some instance of RelativeTime,
  9989 	This should be changed to return some instance of RelativeTime,
  9970         and these computations moved there.
  9990 	and these computations moved there.
  9971 
  9991 
  9972      Don't use this method in application code since it is an internal (private)
  9992      Don't use this method in application code since it is an internal (private)
  9973      interface. For compatibility with ST-80, use Time millisecondClockValue.
  9993      interface. For compatibility with ST-80, use Time millisecondClockValue.
  9974     "
  9994     "
  9975 
  9995 
 10023     DWORD retVal;
 10043     DWORD retVal;
 10024     WCHAR nm[33];
 10044     WCHAR nm[33];
 10025 
 10045 
 10026     retVal = GetTimeZoneInformation(&tzInfo);
 10046     retVal = GetTimeZoneInformation(&tzInfo);
 10027     switch (retVal) {
 10047     switch (retVal) {
 10028         case TIME_ZONE_ID_INVALID:
 10048 	case TIME_ZONE_ID_INVALID:
 10029             error = __mkSmallInteger(__WIN32_ERR(GetLastError()));
 10049 	    error = __mkSmallInteger(__WIN32_ERR(GetLastError()));
 10030             break;
 10050 	    break;
 10031 
 10051 
 10032         case TIME_ZONE_ID_UNKNOWN:
 10052 	case TIME_ZONE_ID_UNKNOWN:
 10033         case TIME_ZONE_ID_STANDARD:
 10053 	case TIME_ZONE_ID_STANDARD:
 10034         case TIME_ZONE_ID_DAYLIGHT:
 10054 	case TIME_ZONE_ID_DAYLIGHT:
 10035         default:
 10055 	default:
 10036             bias = __mkSmallInteger(tzInfo.Bias);
 10056 	    bias = __mkSmallInteger(tzInfo.Bias);
 10037             memmove(nm, tzInfo.StandardName, 32*sizeof(WCHAR));
 10057 	    memmove(nm, tzInfo.StandardName, 32*sizeof(WCHAR));
 10038             nm[32] = 0;
 10058 	    nm[32] = 0;
 10039             standardName = __MKU16STRING(nm);
 10059 	    standardName = __MKU16STRING(nm);
 10040             standardDate_y = __mkSmallInteger(tzInfo.StandardDate.wYear);
 10060 	    standardDate_y = __mkSmallInteger(tzInfo.StandardDate.wYear);
 10041             standardDate_m = __mkSmallInteger(tzInfo.StandardDate.wMonth);
 10061 	    standardDate_m = __mkSmallInteger(tzInfo.StandardDate.wMonth);
 10042             standardDate_d = __mkSmallInteger(tzInfo.StandardDate.wDay);
 10062 	    standardDate_d = __mkSmallInteger(tzInfo.StandardDate.wDay);
 10043             standardDate_wd = __mkSmallInteger(tzInfo.StandardDate.wDayOfWeek);
 10063 	    standardDate_wd = __mkSmallInteger(tzInfo.StandardDate.wDayOfWeek);
 10044             standardDate_h = __mkSmallInteger(tzInfo.StandardDate.wHour);
 10064 	    standardDate_h = __mkSmallInteger(tzInfo.StandardDate.wHour);
 10045             standardDate_min = __mkSmallInteger(tzInfo.StandardDate.wMinute);
 10065 	    standardDate_min = __mkSmallInteger(tzInfo.StandardDate.wMinute);
 10046             standardDate_s = __mkSmallInteger(tzInfo.StandardDate.wSecond);
 10066 	    standardDate_s = __mkSmallInteger(tzInfo.StandardDate.wSecond);
 10047             standardBias =  __mkSmallInteger(tzInfo.StandardBias);
 10067 	    standardBias =  __mkSmallInteger(tzInfo.StandardBias);
 10048             memmove(nm, tzInfo.DaylightName, 32*sizeof(WCHAR));
 10068 	    memmove(nm, tzInfo.DaylightName, 32*sizeof(WCHAR));
 10049             nm[32] = 0;
 10069 	    nm[32] = 0;
 10050             daylightName = __MKU16STRING(nm);
 10070 	    daylightName = __MKU16STRING(nm);
 10051             daylightDate_y = __mkSmallInteger(tzInfo.DaylightDate.wYear);
 10071 	    daylightDate_y = __mkSmallInteger(tzInfo.DaylightDate.wYear);
 10052             daylightDate_m = __mkSmallInteger(tzInfo.DaylightDate.wMonth);
 10072 	    daylightDate_m = __mkSmallInteger(tzInfo.DaylightDate.wMonth);
 10053             daylightDate_d = __mkSmallInteger(tzInfo.DaylightDate.wDay);
 10073 	    daylightDate_d = __mkSmallInteger(tzInfo.DaylightDate.wDay);
 10054             daylightDate_wd = __mkSmallInteger(tzInfo.DaylightDate.wDayOfWeek);
 10074 	    daylightDate_wd = __mkSmallInteger(tzInfo.DaylightDate.wDayOfWeek);
 10055             daylightDate_h = __mkSmallInteger(tzInfo.DaylightDate.wHour);
 10075 	    daylightDate_h = __mkSmallInteger(tzInfo.DaylightDate.wHour);
 10056             daylightDate_min = __mkSmallInteger(tzInfo.DaylightDate.wMinute);
 10076 	    daylightDate_min = __mkSmallInteger(tzInfo.DaylightDate.wMinute);
 10057             daylightDate_s = __mkSmallInteger(tzInfo.DaylightDate.wSecond);
 10077 	    daylightDate_s = __mkSmallInteger(tzInfo.DaylightDate.wSecond);
 10058             daylightBias =  __mkSmallInteger(tzInfo.DaylightBias);
 10078 	    daylightBias =  __mkSmallInteger(tzInfo.DaylightBias);
 10059             break;
 10079 	    break;
 10060     }
 10080     }
 10061 %}.
 10081 %}.
 10062     error notNil ifTrue:[
 10082     error notNil ifTrue:[
 10063         self primitiveFailed.
 10083 	self primitiveFailed.
 10064     ].
 10084     ].
 10065 
 10085 
 10066     info := AbstractOperatingSystem::TimeZoneInfo new.
 10086     info := AbstractOperatingSystem::TimeZoneInfo new.
 10067     info
 10087     info
 10068         bias:bias
 10088 	bias:bias
 10069         name:standardName standardBias:standardBias
 10089 	name:standardName standardBias:standardBias
 10070         daylightName:daylightName daylightBias:daylightBias.
 10090 	daylightName:daylightName daylightBias:daylightBias.
 10071 
 10091 
 10072     standardDate_m ~~ 0 ifTrue:[
 10092     standardDate_m ~~ 0 ifTrue:[
 10073         info standardYear:standardDate_y standardMonth:standardDate_m standardDay:standardDate_d
 10093 	info standardYear:standardDate_y standardMonth:standardDate_m standardDay:standardDate_d
 10074              standardWeekDay:standardDate_wd standardHour:standardDate_h standardMinute:standardDate_min.
 10094 	     standardWeekDay:standardDate_wd standardHour:standardDate_h standardMinute:standardDate_min.
 10075     ].
 10095     ].
 10076     daylightDate_m ~~ 0 ifTrue:[
 10096     daylightDate_m ~~ 0 ifTrue:[
 10077         info daylightYear:daylightDate_y daylightMonth:daylightDate_m daylightDay:daylightDate_d
 10097 	info daylightYear:daylightDate_y daylightMonth:daylightDate_m daylightDay:daylightDate_d
 10078              daylightWeekDay:daylightDate_wd daylightHour:daylightDate_h daylightMinute:daylightDate_min.
 10098 	     daylightWeekDay:daylightDate_wd daylightHour:daylightDate_h daylightMinute:daylightDate_min.
 10079     ].
 10099     ].
 10080 
 10100 
 10081     ^ info
 10101     ^ info
 10082 
 10102 
 10083     "
 10103     "
 10097      only the calling thread sleep)."
 10117      only the calling thread sleep)."
 10098 
 10118 
 10099 %{  /* NOCONTEXT */
 10119 %{  /* NOCONTEXT */
 10100 
 10120 
 10101     if (__isSmallInteger(numberOfSeconds)) {
 10121     if (__isSmallInteger(numberOfSeconds)) {
 10102         sleep(__intVal(numberOfSeconds));
 10122 	sleep(__intVal(numberOfSeconds));
 10103         RETURN ( self );
 10123 	RETURN ( self );
 10104     }
 10124     }
 10105 %}.
 10125 %}.
 10106     "
 10126     "
 10107      argument not integer
 10127      argument not integer
 10108     "
 10128     "
 10128 
 10148 
 10129     t = __longIntVal(osSeconds);
 10149     t = __longIntVal(osSeconds);
 10130 
 10150 
 10131     /* try cache */
 10151     /* try cache */
 10132     {
 10152     {
 10133         OBJ lastSeconds, lastTimeInfo;
 10153 	OBJ lastSeconds, lastTimeInfo;
 10134 
 10154 
 10135         lastSeconds = @global(LastTimeInfoSeconds);
 10155 	lastSeconds = @global(LastTimeInfoSeconds);
 10136         if (lastSeconds
 10156 	if (lastSeconds
 10137          && (__longIntVal(lastSeconds) == t)
 10157 	 && (__longIntVal(lastSeconds) == t)
 10138          && (@global(LastTimeInfoMilliseconds) == osMilliseconds)
 10158 	 && (@global(LastTimeInfoMilliseconds) == osMilliseconds)
 10139          && (@global(LastTimeInfoIsLocal) == isLocalTime)
 10159 	 && (@global(LastTimeInfoIsLocal) == isLocalTime)
 10140         ) {
 10160 	) {
 10141             lastTimeInfo = @global(LastTimeInfo);
 10161 	    lastTimeInfo = @global(LastTimeInfo);
 10142             if (lastTimeInfo != nil) {
 10162 	    if (lastTimeInfo != nil) {
 10143                 RETURN (lastTimeInfo);
 10163 		RETURN (lastTimeInfo);
 10144             }
 10164 	    }
 10145         }
 10165 	}
 10146     }
 10166     }
 10147 
 10167 
 10148     TimetToFileTime((time_t)t, &fileTime);
 10168     TimetToFileTime((time_t)t, &fileTime);
 10149 
 10169 
 10150     if (isLocalTime == true) {
 10170     if (isLocalTime == true) {
 10151         TIME_ZONE_INFORMATION tzInfo;
 10171 	TIME_ZONE_INFORMATION tzInfo;
 10152         int tzState;
 10172 	int tzState;
 10153         LONGLONG longTime;
 10173 	LONGLONG longTime;
 10154 
 10174 
 10155         FileTimeToLocalFileTime(&fileTime, &localFileTime);
 10175 	FileTimeToLocalFileTime(&fileTime, &localFileTime);
 10156         FileTimeToSystemTime(&localFileTime, &sysTime);
 10176 	FileTimeToSystemTime(&localFileTime, &sysTime);
 10157 
 10177 
 10158         longTime = ((LONGLONG)fileTime.dwHighDateTime << 32) + fileTime.dwLowDateTime;
 10178 	longTime = ((LONGLONG)fileTime.dwHighDateTime << 32) + fileTime.dwLowDateTime;
 10159         longTime -= ((LONGLONG)localFileTime.dwHighDateTime << 32) + localFileTime.dwLowDateTime;
 10179 	longTime -= ((LONGLONG)localFileTime.dwHighDateTime << 32) + localFileTime.dwLowDateTime;
 10160         utcOffset = __mkSmallInteger((INT)(longTime / 10000000));
 10180 	utcOffset = __mkSmallInteger((INT)(longTime / 10000000));
 10161 
 10181 
 10162         if ((tzState = GetTimeZoneInformation(&tzInfo)) < 0) {
 10182 	if ((tzState = GetTimeZoneInformation(&tzInfo)) < 0) {
 10163             reason = @symbol(getTimeZoneFailed);
 10183 	    reason = @symbol(getTimeZoneFailed);
 10164             goto error;
 10184 	    goto error;
 10165         }
 10185 	}
 10166         dstOffset = __mkSmallInteger((tzInfo.Bias + tzInfo.DaylightBias) * 60);
 10186 	dstOffset = __mkSmallInteger((tzInfo.Bias + tzInfo.DaylightBias) * 60);
 10167     } else {
 10187     } else {
 10168         FileTimeToSystemTime(&fileTime, &sysTime);
 10188 	FileTimeToSystemTime(&fileTime, &sysTime);
 10169         utcOffset = __mkSmallInteger(0);
 10189 	utcOffset = __mkSmallInteger(0);
 10170     }
 10190     }
 10171 
 10191 
 10172     hours = __mkSmallInteger(sysTime.wHour);
 10192     hours = __mkSmallInteger(sysTime.wHour);
 10173     minutes = __mkSmallInteger(sysTime.wMinute);
 10193     minutes = __mkSmallInteger(sysTime.wMinute);
 10174     seconds = __mkSmallInteger(sysTime.wSecond);
 10194     seconds = __mkSmallInteger(sysTime.wSecond);
 10179 
 10199 
 10180     weekDay = __mkSmallInteger(sysTime.wDayOfWeek == 0 ? 7 : sysTime.wDayOfWeek);
 10200     weekDay = __mkSmallInteger(sysTime.wDayOfWeek == 0 ? 7 : sysTime.wDayOfWeek);
 10181 error:;
 10201 error:;
 10182 %}.
 10202 %}.
 10183     year isNil ifTrue:[
 10203     year isNil ifTrue:[
 10184         ^ self primitiveFailed
 10204 	^ self primitiveFailed
 10185     ].
 10205     ].
 10186 
 10206 
 10187     info := self timeInfoClass new.
 10207     info := self timeInfoClass new.
 10188     info
 10208     info
 10189         year:year
 10209 	year:year
 10190         month:month
 10210 	month:month
 10191         day:day
 10211 	day:day
 10192         hours:hours
 10212 	hours:hours
 10193         minutes:minutes
 10213 	minutes:minutes
 10194         seconds:seconds
 10214 	seconds:seconds
 10195         milliseconds:osMilliseconds
 10215 	milliseconds:osMilliseconds
 10196         utcOffset:utcOffset
 10216 	utcOffset:utcOffset
 10197         dst:(utcOffset = dstOffset)
 10217 	dst:(utcOffset = dstOffset)
 10198         dayInYear:yDay
 10218 	dayInYear:yDay
 10199         dayInWeek:weekDay.
 10219 	dayInWeek:weekDay.
 10200 
 10220 
 10201     LastTimeInfo := info.
 10221     LastTimeInfo := info.
 10202     LastTimeInfoSeconds := osSeconds.
 10222     LastTimeInfoSeconds := osSeconds.
 10203     LastTimeInfoMilliseconds := osMilliseconds.
 10223     LastTimeInfoMilliseconds := osMilliseconds.
 10204     LastTimeInfoIsLocal := isLocalTime.
 10224     LastTimeInfoIsLocal := isLocalTime.
 10246 
 10266 
 10247     |appDataDirFromEnv appDataDirFromRegistry|
 10267     |appDataDirFromEnv appDataDirFromRegistry|
 10248 
 10268 
 10249     appDataDirFromEnv := self getEnvironment:'APPDATA'.
 10269     appDataDirFromEnv := self getEnvironment:'APPDATA'.
 10250     appDataDirFromEnv notNil ifTrue:[
 10270     appDataDirFromEnv notNil ifTrue:[
 10251         ^ appDataDirFromEnv , '\' , appName
 10271 	^ appDataDirFromEnv , '\' , appName
 10252     ].
 10272     ].
 10253     appDataDirFromRegistry :=
 10273     appDataDirFromRegistry :=
 10254         (self registryEntry key:'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders')
 10274 	(self registryEntry key:'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders')
 10255             valueNamed:'AppData'.
 10275 	    valueNamed:'AppData'.
 10256     appDataDirFromRegistry notNil ifTrue:[
 10276     appDataDirFromRegistry notNil ifTrue:[
 10257         ^ appDataDirFromRegistry , '\' , appName
 10277 	^ appDataDirFromRegistry , '\' , appName
 10258     ].
 10278     ].
 10259     ^ super getApplicationDataDirectoryFor:appName
 10279     ^ super getApplicationDataDirectoryFor:appName
 10260 
 10280 
 10261     "
 10281     "
 10262      OperatingSystem getApplicationDataDirectoryFor:'expecco'
 10282      OperatingSystem getApplicationDataDirectoryFor:'expecco'
 10271     "{ Pragma: +optSpace }"
 10291     "{ Pragma: +optSpace }"
 10272 
 10292 
 10273     |dir path|
 10293     |dir path|
 10274 
 10294 
 10275     path := (self registryEntry
 10295     path := (self registryEntry
 10276                 key:'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders')
 10296 		key:'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders')
 10277             valueNamed:'Desktop'.
 10297 	    valueNamed:'Desktop'.
 10278 
 10298 
 10279     path isNil ifTrue:[
 10299     path isNil ifTrue:[
 10280         "Fallback"
 10300 	"Fallback"
 10281         dir := self getHomeDirectory.
 10301 	dir := self getHomeDirectory.
 10282         dir isNil ifTrue:[ ^ nil ].
 10302 	dir isNil ifTrue:[ ^ nil ].
 10283 
 10303 
 10284         path := dir , '\Desktop'.
 10304 	path := dir , '\Desktop'.
 10285     ].
 10305     ].
 10286 
 10306 
 10287     (self isValidPath:path) ifFalse:[ ^ nil ].
 10307     (self isValidPath:path) ifFalse:[ ^ nil ].
 10288     ^ path
 10308     ^ path
 10289 
 10309 
 10300     "{ Pragma: +optSpace }"
 10320     "{ Pragma: +optSpace }"
 10301 
 10321 
 10302     |dir|
 10322     |dir|
 10303 
 10323 
 10304     dir := (self registryEntry
 10324     dir := (self registryEntry
 10305                 key:'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders')
 10325 		key:'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders')
 10306             valueNamed:'Personal'.
 10326 	    valueNamed:'Personal'.
 10307 
 10327 
 10308     dir isNil ifTrue:[
 10328     dir isNil ifTrue:[
 10309         dir := self getHomeDirectory.
 10329 	dir := self getHomeDirectory.
 10310     ].
 10330     ].
 10311 
 10331 
 10312     ^ dir.
 10332     ^ dir.
 10313 
 10333 
 10314     "
 10334     "
 10353     |info gecos|
 10373     |info gecos|
 10354 
 10374 
 10355     info := self userInfoOf:userID.
 10375     info := self userInfoOf:userID.
 10356     (info notNil
 10376     (info notNil
 10357     and:[info includesKey:#gecos]) ifTrue:[
 10377     and:[info includesKey:#gecos]) ifTrue:[
 10358         gecos := info at:#gecos.
 10378 	gecos := info at:#gecos.
 10359         (gecos includes:$,) ifTrue:[
 10379 	(gecos includes:$,) ifTrue:[
 10360             ^ gecos copyTo:(gecos indexOf:$,) - 1
 10380 	    ^ gecos copyTo:(gecos indexOf:$,) - 1
 10361         ].
 10381 	].
 10362         ^ gecos
 10382 	^ gecos
 10363     ].
 10383     ].
 10364     ^ self getUserNameFromID:userID
 10384     ^ self getUserNameFromID:userID
 10365 
 10385 
 10366     "
 10386     "
 10367      OperatingSystem getFullUserNameFromID:0
 10387      OperatingSystem getFullUserNameFromID:0
 10405 
 10425 
 10406     |dir|
 10426     |dir|
 10407 
 10427 
 10408     dir := self getEnvironment:'USERPROFILE'.
 10428     dir := self getEnvironment:'USERPROFILE'.
 10409     dir isNil ifTrue:[
 10429     dir isNil ifTrue:[
 10410         dir := '.'.
 10430 	dir := '.'.
 10411     ].
 10431     ].
 10412     ^ dir.
 10432     ^ dir.
 10413 
 10433 
 10414     "
 10434     "
 10415      OperatingSystem getHomeDirectory
 10435      OperatingSystem getHomeDirectory
 10430     extern char *getenv();
 10450     extern char *getenv();
 10431 #endif
 10451 #endif
 10432     char *name = (char *)0;
 10452     char *name = (char *)0;
 10433 
 10453 
 10434     if (firstCall) {
 10454     if (firstCall) {
 10435         DWORD nameSize = sizeof(cachedName);
 10455 	DWORD nameSize = sizeof(cachedName);
 10436 
 10456 
 10437         if (GetUserName(cachedName, &nameSize) == TRUE) {
 10457 	if (GetUserName(cachedName, &nameSize) == TRUE) {
 10438             name = cachedName;
 10458 	    name = cachedName;
 10439             firstCall = 0;
 10459 	    firstCall = 0;
 10440         }
 10460 	}
 10441     } else {
 10461     } else {
 10442         name = cachedName;
 10462 	name = cachedName;
 10443     }
 10463     }
 10444 
 10464 
 10445     /*
 10465     /*
 10446      * try a few common environment variables ...
 10466      * try a few common environment variables ...
 10447      */
 10467      */
 10448     if (! name || (name[0] == 0) ) {
 10468     if (! name || (name[0] == 0) ) {
 10449         name = getenv("LOGIN");
 10469 	name = getenv("LOGIN");
 10450         if (! name || (name[0] == 0) ) {
 10470 	if (! name || (name[0] == 0) ) {
 10451             name = getenv("LOGNAME");
 10471 	    name = getenv("LOGNAME");
 10452             if (! name || (name[0] == 0) ) {
 10472 	    if (! name || (name[0] == 0) ) {
 10453                 name = getenv("USER");
 10473 		name = getenv("USER");
 10454             }
 10474 	    }
 10455         }
 10475 	}
 10456     }
 10476     }
 10457     /*
 10477     /*
 10458      * nope - I really font know who you are.
 10478      * nope - I really font know who you are.
 10459      */
 10479      */
 10460     if (! name || (name[0] == 0) ) {
 10480     if (! name || (name[0] == 0) ) {
 10461         name = "you";
 10481 	name = "you";
 10462     }
 10482     }
 10463 
 10483 
 10464     RETURN ( __MKSTRING(name) );
 10484     RETURN ( __MKSTRING(name) );
 10465 %}.
 10485 %}.
 10466     "
 10486     "
 10485 
 10505 
 10486     "return the user-name-string for a given numeric user-id.
 10506     "return the user-name-string for a given numeric user-id.
 10487      This is the login name, not the fullName."
 10507      This is the login name, not the fullName."
 10488 
 10508 
 10489     aNumber == self getUserID ifTrue:[
 10509     aNumber == self getUserID ifTrue:[
 10490         ^ self getLoginName
 10510 	^ self getLoginName
 10491     ].
 10511     ].
 10492 
 10512 
 10493     ^ '? (' , aNumber printString , ')'
 10513     ^ '? (' , aNumber printString , ')'
 10494 
 10514 
 10495     "
 10515     "
 10510 
 10530 
 10511     |info name "uid gid" dir|
 10531     |info name "uid gid" dir|
 10512 
 10532 
 10513     info := IdentityDictionary new.
 10533     info := IdentityDictionary new.
 10514     name isNil ifTrue:[
 10534     name isNil ifTrue:[
 10515         aNameOrID == self getUserID ifTrue:[
 10535 	aNameOrID == self getUserID ifTrue:[
 10516             name := self getLoginName
 10536 	    name := self getLoginName
 10517         ].
 10537 	].
 10518     ].
 10538     ].
 10519     name notNil ifTrue:[
 10539     name notNil ifTrue:[
 10520         info at:#name put:name.
 10540 	info at:#name put:name.
 10521     ] ifFalse:[
 10541     ] ifFalse:[
 10522         info at:#name put:'unknown'
 10542 	info at:#name put:'unknown'
 10523     ].
 10543     ].
 10524     dir isNil ifTrue:[
 10544     dir isNil ifTrue:[
 10525         aNameOrID == self getUserID ifTrue:[
 10545 	aNameOrID == self getUserID ifTrue:[
 10526             dir := self getHomeDirectory
 10546 	    dir := self getHomeDirectory
 10527         ]
 10547 	]
 10528     ].
 10548     ].
 10529     dir notNil ifTrue:[info at:#dir put:dir].
 10549     dir notNil ifTrue:[info at:#dir put:dir].
 10530     "/ uid notNil ifTrue:[info at:#uid put:uid].
 10550     "/ uid notNil ifTrue:[info at:#uid put:uid].
 10531     "/ gid  notNil ifTrue:[info at:#gid put:gid].
 10551     "/ gid  notNil ifTrue:[info at:#gid put:gid].
 10532     ^ info
 10552     ^ info
 10563     |pid status code core|
 10583     |pid status code core|
 10564 %{
 10584 %{
 10565     DWORD endStatus;
 10585     DWORD endStatus;
 10566 
 10586 
 10567     if (__isExternalAddressLike(pidToWait) ) {
 10587     if (__isExternalAddressLike(pidToWait) ) {
 10568         HANDLE __pidToWait = _HANDLEVal(pidToWait);
 10588 	HANDLE __pidToWait = _HANDLEVal(pidToWait);
 10569         int t;
 10589 	int t;
 10570 
 10590 
 10571 #ifdef PROCESSDEBUG_CHILDPROCESSWAIT
 10591 #ifdef PROCESSDEBUG_CHILDPROCESSWAIT
 10572         console_printf("childProcessWait %x b %d\n",__pidToWait,blocking==true);
 10592 	console_printf("childProcessWait %x b %d\n",__pidToWait,blocking==true);
 10573 #endif
 10593 #endif
 10574         t = (blocking==true) ? INFINITE : 0;
 10594 	t = (blocking==true) ? INFINITE : 0;
 10575 
 10595 
 10576 #ifdef DO_WRAP_CALLS
 10596 #ifdef DO_WRAP_CALLS
 10577         if (t == 0) {
 10597 	if (t == 0) {
 10578             /* no need for WRAP-call; does not block */
 10598 	    /* no need for WRAP-call; does not block */
 10579             endStatus = WaitForSingleObject(__pidToWait, t);
 10599 	    endStatus = WaitForSingleObject(__pidToWait, t);
 10580             if (endStatus < 0) {
 10600 	    if (endStatus < 0) {
 10581                 __threadErrno = __WIN32_ERR(GetLastError());
 10601 		__threadErrno = __WIN32_ERR(GetLastError());
 10582             }
 10602 	    }
 10583         } else {
 10603 	} else {
 10584             do {
 10604 	    do {
 10585                 __threadErrno = 0;
 10605 		__threadErrno = 0;
 10586                 endStatus = STX_API_CALL2( "WaitForSingleObject", WaitForSingleObject, __pidToWait, t);
 10606 		endStatus = STX_API_CALL2( "WaitForSingleObject", WaitForSingleObject, __pidToWait, t);
 10587             } while ((endStatus < 0) && (__threadErrno == EINTR));
 10607 	    } while ((endStatus < 0) && (__threadErrno == EINTR));
 10588         }
 10608 	}
 10589 #else
 10609 #else
 10590         endStatus = WaitForSingleObject(__pidToWait, t);
 10610 	endStatus = WaitForSingleObject(__pidToWait, t);
 10591         if (endStatus < 0) {
 10611 	if (endStatus < 0) {
 10592             __threadErrno = __WIN32_ERR(GetLastError());
 10612 	    __threadErrno = __WIN32_ERR(GetLastError());
 10593         }
 10613 	}
 10594 #endif
 10614 #endif
 10595         if ( endStatus == WAIT_TIMEOUT ) {
 10615 	if ( endStatus == WAIT_TIMEOUT ) {
 10596             if (blocking==true)
 10616 	    if (blocking==true)
 10597                 status = @symbol(timeout);
 10617 		status = @symbol(timeout);
 10598             else {
 10618 	    else {
 10599                 status = @symbol(continue);
 10619 		status = @symbol(continue);
 10600 #ifdef PROCESSDEBUG_CHILDPROCESSWAIT
 10620 #ifdef PROCESSDEBUG_CHILDPROCESSWAIT
 10601                 console_printf("ret nil\n");
 10621 		console_printf("ret nil\n");
 10602 #endif
 10622 #endif
 10603                 RETURN(nil);
 10623 		RETURN(nil);
 10604             }
 10624 	    }
 10605         } else {
 10625 	} else {
 10606             status = @symbol(exit);
 10626 	    status = @symbol(exit);
 10607 #ifdef PROCESSDEBUG_CHILDPROCESSWAIT
 10627 #ifdef PROCESSDEBUG_CHILDPROCESSWAIT
 10608             console_printf("exit\n");
 10628 	    console_printf("exit\n");
 10609 #endif
 10629 #endif
 10610             if (endStatus == WAIT_OBJECT_0) {
 10630 	    if (endStatus == WAIT_OBJECT_0) {
 10611                 DWORD exitCode;
 10631 		DWORD exitCode;
 10612 
 10632 
 10613                 if (GetExitCodeProcess(__pidToWait, &exitCode)) {
 10633 		if (GetExitCodeProcess(__pidToWait, &exitCode)) {
 10614 #ifdef PROCESSDEBUG_CHILDPROCESSWAIT
 10634 #ifdef PROCESSDEBUG_CHILDPROCESSWAIT
 10615                     console_printf("exitCode: %d\n", exitCode);
 10635 		    console_printf("exitCode: %d\n", exitCode);
 10616 #endif
 10636 #endif
 10617                     if (exitCode == STILL_ACTIVE) {
 10637 		    if (exitCode == STILL_ACTIVE) {
 10618                         RETURN(nil);
 10638 			RETURN(nil);
 10619                     }
 10639 		    }
 10620 #ifdef PROCESSDEBUG_CHILDPROCESSWAIT
 10640 #ifdef PROCESSDEBUG_CHILDPROCESSWAIT
 10621                     console_printf("exit %d\n", exitCode);
 10641 		    console_printf("exit %d\n", exitCode);
 10622 #endif
 10642 #endif
 10623                     code = __mkSmallInteger(exitCode);
 10643 		    code = __mkSmallInteger(exitCode);
 10624                 } else {
 10644 		} else {
 10625 #ifdef PROCESSDEBUG_CHILDPROCESSWAIT
 10645 #ifdef PROCESSDEBUG_CHILDPROCESSWAIT
 10626                     console_printf("GetExitCodeProcess failed\n");
 10646 		    console_printf("GetExitCodeProcess failed\n");
 10627 #endif
 10647 #endif
 10628                     code = __mkSmallInteger(GetLastError());
 10648 		    code = __mkSmallInteger(GetLastError());
 10629                 }
 10649 		}
 10630             } else {
 10650 	    } else {
 10631                 code = __mkSmallInteger(-1);
 10651 		code = __mkSmallInteger(-1);
 10632             }
 10652 	    }
 10633         }
 10653 	}
 10634         core = false;
 10654 	core = false;
 10635         pid = pidToWait;
 10655 	pid = pidToWait;
 10636     }
 10656     }
 10637 %}.
 10657 %}.
 10638 
 10658 
 10639     (status isNil or:[pid isNil]) ifTrue:[
 10659     (status isNil or:[pid isNil]) ifTrue:[
 10640         ^ self primitiveFailed
 10660 	^ self primitiveFailed
 10641     ].
 10661     ].
 10642 
 10662 
 10643 "/ Transcript show:'pid: '; show:pid; show:' status: '; show:status;
 10663 "/ Transcript show:'pid: '; show:pid; show:' status: '; show:status;
 10644 "/ show:' code: '; show:code; show:' core:'; showCR:core.
 10664 "/ show:' code: '; show:code; show:' core:'; showCR:core.
 10645 
 10665 
 10681     int    readCount;
 10701     int    readCount;
 10682     int    writeCount;
 10702     int    writeCount;
 10683     int    exceptCount;
 10703     int    exceptCount;
 10684 
 10704 
 10685     if (__isNonNilObject(readFdArray)) {
 10705     if (__isNonNilObject(readFdArray)) {
 10686         if (! __isArrayLike(readFdArray)) goto fail;
 10706 	if (! __isArrayLike(readFdArray)) goto fail;
 10687         readCount = __arraySize(readFdArray);
 10707 	readCount = __arraySize(readFdArray);
 10688     } else {
 10708     } else {
 10689         readCount = 0;
 10709 	readCount = 0;
 10690     }
 10710     }
 10691 
 10711 
 10692     if (__isNonNilObject(writeFdArray)) {
 10712     if (__isNonNilObject(writeFdArray)) {
 10693         if (! __isArrayLike(writeFdArray)) goto fail;
 10713 	if (! __isArrayLike(writeFdArray)) goto fail;
 10694         writeCount = __arraySize(writeFdArray);
 10714 	writeCount = __arraySize(writeFdArray);
 10695     } else {
 10715     } else {
 10696         writeCount = 0;
 10716 	writeCount = 0;
 10697     }
 10717     }
 10698 
 10718 
 10699     if (__isNonNilObject(exceptFdArray)) {
 10719     if (__isNonNilObject(exceptFdArray)) {
 10700         if (! __isArrayLike(exceptFdArray)) goto fail;
 10720 	if (! __isArrayLike(exceptFdArray)) goto fail;
 10701         exceptCount = __arraySize(exceptFdArray);
 10721 	exceptCount = __arraySize(exceptFdArray);
 10702     } else {
 10722     } else {
 10703         exceptCount = 0;
 10723 	exceptCount = 0;
 10704     }
 10724     }
 10705 
 10725 
 10706     for (i = 0; (i < readCount) && (numHandles < MAXHANDLE);i++) {
 10726     for (i = 0; (i < readCount) && (numHandles < MAXHANDLE);i++) {
 10707         fd = __ArrayInstPtr(readFdArray)->a_element[i];
 10727 	fd = __ArrayInstPtr(readFdArray)->a_element[i];
 10708 
 10728 
 10709         if (fd != nil) {
 10729 	if (fd != nil) {
 10710             if (__isExternalAddressLike(fd)) {
 10730 	    if (__isExternalAddressLike(fd)) {
 10711                 hArray  [numHandles] = _HANDLEVal(fd);
 10731 		hArray  [numHandles] = _HANDLEVal(fd);
 10712                 retArray[numHandles] = i;
 10732 		retArray[numHandles] = i;
 10713                 ++numHandles;
 10733 		++numHandles;
 10714             } else {
 10734 	    } else {
 10715                 int canRead = _canReadWithoutBlocking (__intVal(fd) );
 10735 		int canRead = _canReadWithoutBlocking (__intVal(fd) );
 10716 
 10736 
 10717                 if (canRead > 0 ) {
 10737 		if (canRead > 0 ) {
 10718                     RETURN (fd);
 10738 		    RETURN (fd);
 10719                 } else {
 10739 		} else {
 10720                     if (canRead < 0 ) {
 10740 		    if (canRead < 0 ) {
 10721                         @global(LastErrorNumber) = __mkSmallInteger(EBADF);
 10741 			@global(LastErrorNumber) = __mkSmallInteger(EBADF);
 10722                         RETURN ( @symbol(error) );
 10742 			RETURN ( @symbol(error) );
 10723                     }
 10743 		    }
 10724                 }
 10744 		}
 10725             }
 10745 	    }
 10726         }
 10746 	}
 10727     }
 10747     }
 10728 
 10748 
 10729     for (i = 0; (i < writeCount) && (numHandles < MAXHANDLE);i++) {
 10749     for (i = 0; (i < writeCount) && (numHandles < MAXHANDLE);i++) {
 10730         fd = __ArrayInstPtr(writeFdArray)->a_element[i];
 10750 	fd = __ArrayInstPtr(writeFdArray)->a_element[i];
 10731 
 10751 
 10732         if (fd != nil) {
 10752 	if (fd != nil) {
 10733             if (__isExternalAddressLike(fd)) {
 10753 	    if (__isExternalAddressLike(fd)) {
 10734                 hArray  [numHandles] = _HANDLEVal(fd);
 10754 		hArray  [numHandles] = _HANDLEVal(fd);
 10735                 retArray[numHandles] = i + 10000;
 10755 		retArray[numHandles] = i + 10000;
 10736                 ++numHandles;
 10756 		++numHandles;
 10737             } else {
 10757 	    } else {
 10738                 int canWrite = _canWriteWithoutBlocking (__intVal(fd) );
 10758 		int canWrite = _canWriteWithoutBlocking (__intVal(fd) );
 10739 
 10759 
 10740                 if (canWrite > 0 ) {
 10760 		if (canWrite > 0 ) {
 10741                     RETURN (fd);
 10761 		    RETURN (fd);
 10742                 } else {
 10762 		} else {
 10743                     if (canWrite < 0 ) {
 10763 		    if (canWrite < 0 ) {
 10744                         @global(LastErrorNumber) = __mkSmallInteger(EBADF);
 10764 			@global(LastErrorNumber) = __mkSmallInteger(EBADF);
 10745                         RETURN ( @symbol(error) );
 10765 			RETURN ( @symbol(error) );
 10746                     }
 10766 		    }
 10747                 }
 10767 		}
 10748             }
 10768 	    }
 10749         }
 10769 	}
 10750     }
 10770     }
 10751 
 10771 
 10752     for (i = 0; (i < exceptCount) && (numHandles < MAXHANDLE);i++) {
 10772     for (i = 0; (i < exceptCount) && (numHandles < MAXHANDLE);i++) {
 10753         fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
 10773 	fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
 10754 
 10774 
 10755         if (fd != nil) {
 10775 	if (fd != nil) {
 10756             if (__isExternalAddressLike(fd)) {
 10776 	    if (__isExternalAddressLike(fd)) {
 10757                 hArray  [numHandles] = _HANDLEVal(fd);
 10777 		hArray  [numHandles] = _HANDLEVal(fd);
 10758                 retArray[numHandles] = i + 20000;
 10778 		retArray[numHandles] = i + 20000;
 10759                 ++numHandles;
 10779 		++numHandles;
 10760             }
 10780 	    }
 10761         }
 10781 	}
 10762     }
 10782     }
 10763 
 10783 
 10764     if (__isSmallInteger(millis)) {
 10784     if (__isSmallInteger(millis)) {
 10765         t = __intVal(millis);
 10785 	t = __intVal(millis);
 10766 
 10786 
 10767         if (t <= 0 && numHandles == 0) {
 10787 	if (t <= 0 && numHandles == 0) {
 10768             RETURN (nil);
 10788 	    RETURN (nil);
 10769         }
 10789 	}
 10770     } else {
 10790     } else {
 10771         t = INFINITE;
 10791 	t = INFINITE;
 10772     }
 10792     }
 10773 
 10793 
 10774 #ifdef SELECT3DEBUGWIN32
 10794 #ifdef SELECT3DEBUGWIN32
 10775     console_printf("wait Handles = %d timeout = %d\n",numHandles, t);
 10795     console_printf("wait Handles = %d timeout = %d\n",numHandles, t);
 10776 #endif
 10796 #endif
 10777 
 10797 
 10778     res = __vmWait (numHandles, hArray, MAXHANDLE, t);
 10798     res = __vmWait (numHandles, hArray, MAXHANDLE, t);
 10779 
 10799 
 10780     if (numHandles) {
 10800     if (numHandles) {
 10781         if (res == WAIT_FAILED) {
 10801 	if (res == WAIT_FAILED) {
 10782 #ifdef SELECT2DEBUGWIN32
 10802 #ifdef SELECT2DEBUGWIN32
 10783             console_printf("- error %d; ret nil\n",GetLastError());
 10803 	    console_printf("- error %d; ret nil\n",GetLastError());
 10784 #endif
 10804 #endif
 10785             if (__threadErrno == EINTR) {
 10805 	    if (__threadErrno == EINTR) {
 10786                 __threadErrno = 0;
 10806 		__threadErrno = 0;
 10787                 @global(LastErrorNumber) = nil;
 10807 		@global(LastErrorNumber) = nil;
 10788             } else {
 10808 	    } else {
 10789                 __threadErrno = EBADF;
 10809 		__threadErrno = EBADF;
 10790                 if (@global(InfoPrinting) == true) {
 10810 		if (@global(InfoPrinting) == true) {
 10791                     console_fprintf(stderr, "Win32OS [info]: select errno = %d\n", __threadErrno);
 10811 		    console_fprintf(stderr, "Win32OS [info]: select errno = %d\n", __threadErrno);
 10792                 }
 10812 		}
 10793                 @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
 10813 		@global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
 10794                 RETURN ( @symbol(error) );
 10814 		RETURN ( @symbol(error) );
 10795             }
 10815 	    }
 10796             RETURN ( nil );
 10816 	    RETURN ( nil );
 10797         }
 10817 	}
 10798 
 10818 
 10799         if (res == WAIT_TIMEOUT) {
 10819 	if (res == WAIT_TIMEOUT) {
 10800 #ifdef SELECT3DEBUGWIN32
 10820 #ifdef SELECT3DEBUGWIN32
 10801             console_printf("- timeOut; ret nil\n" );
 10821 	    console_printf("- timeOut; ret nil\n" );
 10802 #endif
 10822 #endif
 10803             goto polling;
 10823 	    goto polling;
 10804         }
 10824 	}
 10805 
 10825 
 10806         if (res == numHandles) {
 10826 	if (res == numHandles) {
 10807             if (1 /* @global(InfoPrinting) == true */) {
 10827 	    if (1 /* @global(InfoPrinting) == true */) {
 10808                 console_fprintf(stderr, "Win32OS [info]: plugIn event has been handled\n");
 10828 		console_fprintf(stderr, "Win32OS [info]: plugIn event has been handled\n");
 10809             }
 10829 	    }
 10810             __threadErrno = 0;
 10830 	    __threadErrno = 0;
 10811             @global(LastErrorNumber) = nil;
 10831 	    @global(LastErrorNumber) = nil;
 10812             RETURN ( nil );
 10832 	    RETURN ( nil );
 10813         }
 10833 	}
 10814         if ((res < 0) || (res > numHandles)) {
 10834 	if ((res < 0) || (res > numHandles)) {
 10815 #ifdef SELECTDEBUGWIN32
 10835 #ifdef SELECTDEBUGWIN32
 10816             console_printf("- res=%d error1 %d\n", res, GetLastError());
 10836 	    console_printf("- res=%d error1 %d\n", res, GetLastError());
 10817 #endif
 10837 #endif
 10818             __threadErrno = 0;
 10838 	    __threadErrno = 0;
 10819             @global(LastErrorNumber) = nil;
 10839 	    @global(LastErrorNumber) = nil;
 10820             RETURN ( nil );
 10840 	    RETURN ( nil );
 10821         }
 10841 	}
 10822 
 10842 
 10823         ret = res;
 10843 	ret = res;
 10824 
 10844 
 10825         if (ret < numHandles) {
 10845 	if (ret < numHandles) {
 10826             int fd = retArray[ret];
 10846 	    int fd = retArray[ret];
 10827 
 10847 
 10828             @global(LastErrorNumber) = nil;
 10848 	    @global(LastErrorNumber) = nil;
 10829 
 10849 
 10830 #ifdef SELECTDEBUGWIN32
 10850 #ifdef SELECTDEBUGWIN32
 10831             if (ret) console_printf("wait Handles %d %d ret\n", ret, fd);
 10851 	    if (ret) console_printf("wait Handles %d %d ret\n", ret, fd);
 10832 #endif
 10852 #endif
 10833             if (fd < 10000) {
 10853 	    if (fd < 10000) {
 10834                 RETURN ( __ArrayInstPtr(readFdArray)->a_element[fd] );
 10854 		RETURN ( __ArrayInstPtr(readFdArray)->a_element[fd] );
 10835             }
 10855 	    }
 10836             if (fd < 20000) {
 10856 	    if (fd < 20000) {
 10837                 RETURN ( __ArrayInstPtr(writeFdArray)->a_element[fd-10000] );
 10857 		RETURN ( __ArrayInstPtr(writeFdArray)->a_element[fd-10000] );
 10838             }
 10858 	    }
 10839             RETURN ( __ArrayInstPtr(exceptFdArray)->a_element[fd-20000] );
 10859 	    RETURN ( __ArrayInstPtr(exceptFdArray)->a_element[fd-20000] );
 10840         }
 10860 	}
 10841         console_fprintf(stderr, "Win32OS [info]: wait Handles ret = %d error2 %d\n", ret, GetLastError());
 10861 	console_fprintf(stderr, "Win32OS [info]: wait Handles ret = %d error2 %d\n", ret, GetLastError());
 10842         goto fail;
 10862 	goto fail;
 10843     } else {
 10863     } else {
 10844 
 10864 
 10845 polling:
 10865 polling:
 10846 
 10866 
 10847         for (i=0; i < readCount;i++) {
 10867 	for (i=0; i < readCount;i++) {
 10848             fd = __ArrayInstPtr(readFdArray)->a_element[i];
 10868 	    fd = __ArrayInstPtr(readFdArray)->a_element[i];
 10849 
 10869 
 10850             if (fd != nil) {
 10870 	    if (fd != nil) {
 10851                 if (! __isExternalAddressLike(fd)) {
 10871 		if (! __isExternalAddressLike(fd)) {
 10852                     int canRead = _canReadWithoutBlocking (__intVal(fd));
 10872 		    int canRead = _canReadWithoutBlocking (__intVal(fd));
 10853 
 10873 
 10854                     if (canRead > 0 ) {
 10874 		    if (canRead > 0 ) {
 10855                         RETURN (fd);
 10875 			RETURN (fd);
 10856                     } else {
 10876 		    } else {
 10857                         if (canRead < 0 ) {
 10877 			if (canRead < 0 ) {
 10858                             @global(LastErrorNumber) = __mkSmallInteger(EBADF);
 10878 			    @global(LastErrorNumber) = __mkSmallInteger(EBADF);
 10859                             RETURN ( @symbol(error) );
 10879 			    RETURN ( @symbol(error) );
 10860                         }
 10880 			}
 10861                     }
 10881 		    }
 10862                 }
 10882 		}
 10863             }
 10883 	    }
 10864         }
 10884 	}
 10865 
 10885 
 10866         for (i=0; i < writeCount;i++) {
 10886 	for (i=0; i < writeCount;i++) {
 10867             fd = __ArrayInstPtr(writeFdArray)->a_element[i];
 10887 	    fd = __ArrayInstPtr(writeFdArray)->a_element[i];
 10868 
 10888 
 10869             if (fd != nil) {
 10889 	    if (fd != nil) {
 10870                 if (! __isExternalAddressLike(fd)) {
 10890 		if (! __isExternalAddressLike(fd)) {
 10871                     int canWrite = _canWriteWithoutBlocking (__intVal(fd));
 10891 		    int canWrite = _canWriteWithoutBlocking (__intVal(fd));
 10872 
 10892 
 10873                     if (canWrite > 0 ) {
 10893 		    if (canWrite > 0 ) {
 10874                         RETURN (fd);
 10894 			RETURN (fd);
 10875                     } else {
 10895 		    } else {
 10876                         if (canWrite < 0 ) {
 10896 			if (canWrite < 0 ) {
 10877                             @global(LastErrorNumber) = __mkSmallInteger(EBADF);
 10897 			    @global(LastErrorNumber) = __mkSmallInteger(EBADF);
 10878                             RETURN ( @symbol(error) );
 10898 			    RETURN ( @symbol(error) );
 10879                         }
 10899 			}
 10880                     }
 10900 		    }
 10881                 }
 10901 		}
 10882             }
 10902 	    }
 10883         }
 10903 	}
 10884 
 10904 
 10885         @global(LastErrorNumber) = nil;
 10905 	@global(LastErrorNumber) = nil;
 10886         RETURN ( nil );
 10906 	RETURN ( nil );
 10887     }
 10907     }
 10888 
 10908 
 10889 fail: ;
 10909 fail: ;
 10890 %}.
 10910 %}.
 10891     "
 10911     "
 10922     DWORD res;
 10942     DWORD res;
 10923     HANDLE hArray[MAXHANDLE];
 10943     HANDLE hArray[MAXHANDLE];
 10924     INT i, count;
 10944     INT i, count;
 10925 
 10945 
 10926     if (! __isArrayLike(fdOrHandleArray)) {
 10946     if (! __isArrayLike(fdOrHandleArray)) {
 10927         goto fail;
 10947 	goto fail;
 10928     }
 10948     }
 10929     count = __arraySize(fdOrHandleArray);
 10949     count = __arraySize(fdOrHandleArray);
 10930 
 10950 
 10931     for (i=0; i<count; i++) {
 10951     for (i=0; i<count; i++) {
 10932         OBJ fdOrHandle = __ArrayInstPtr(fdOrHandleArray)->a_element[i];
 10952 	OBJ fdOrHandle = __ArrayInstPtr(fdOrHandleArray)->a_element[i];
 10933         HANDLE h;
 10953 	HANDLE h;
 10934 
 10954 
 10935         if (__isExternalAddressLike(fdOrHandle)) {
 10955 	if (__isExternalAddressLike(fdOrHandle)) {
 10936             h = _HANDLEVal(fdOrHandle);
 10956 	    h = _HANDLEVal(fdOrHandle);
 10937         } else {
 10957 	} else {
 10938             if (__isSmallInteger(fdOrHandle)) {
 10958 	    if (__isSmallInteger(fdOrHandle)) {
 10939                 h = (HANDLE) _get_osfhandle (__intVal(fdOrHandle));
 10959 		h = (HANDLE) _get_osfhandle (__intVal(fdOrHandle));
 10940             } else {
 10960 	    } else {
 10941                 goto fail;
 10961 		goto fail;
 10942             }
 10962 	    }
 10943         }
 10963 	}
 10944         hArray[i] = h;
 10964 	hArray[i] = h;
 10945     }
 10965     }
 10946 
 10966 
 10947     if (__isSmallInteger(millis)) {
 10967     if (__isSmallInteger(millis)) {
 10948         t = __intVal(millis);
 10968 	t = __intVal(millis);
 10949     } else {
 10969     } else {
 10950         t = INFINITE;
 10970 	t = INFINITE;
 10951     }
 10971     }
 10952 
 10972 
 10953 #ifdef DO_WRAP_CALLS
 10973 #ifdef DO_WRAP_CALLS
 10954     do {
 10974     do {
 10955         __threadErrno = 0;
 10975 	__threadErrno = 0;
 10956         res = STX_API_CALL4( "WaitForMultipleObjects", WaitForMultipleObjects, count, hArray, FALSE, t);
 10976 	res = STX_API_CALL4( "WaitForMultipleObjects", WaitForMultipleObjects, count, hArray, FALSE, t);
 10957     } while ((res < 0) && (__threadErrno == EINTR));
 10977     } while ((res < 0) && (__threadErrno == EINTR));
 10958 #else
 10978 #else
 10959     res = WaitForMultipleObjects(count, hArray, FALSE, t);
 10979     res = WaitForMultipleObjects(count, hArray, FALSE, t);
 10960     if (res < 0) {
 10980     if (res < 0) {
 10961         __threadErrno = __WIN32_ERR(GetLastError());
 10981 	__threadErrno = __WIN32_ERR(GetLastError());
 10962     }
 10982     }
 10963 #endif
 10983 #endif
 10964     if (res == WAIT_FAILED) {
 10984     if (res == WAIT_FAILED) {
 10965         RETURN (nil);
 10985 	RETURN (nil);
 10966     }
 10986     }
 10967     if (res == WAIT_TIMEOUT) {
 10987     if (res == WAIT_TIMEOUT) {
 10968         RETURN (nil);
 10988 	RETURN (nil);
 10969     }
 10989     }
 10970     if ((res >= WAIT_OBJECT_0) && (res < (WAIT_OBJECT_0+count))) {
 10990     if ((res >= WAIT_OBJECT_0) && (res < (WAIT_OBJECT_0+count))) {
 10971         RETURN (__ArrayInstPtr(fdOrHandleArray)->a_element[res-WAIT_OBJECT_0]);
 10991 	RETURN (__ArrayInstPtr(fdOrHandleArray)->a_element[res-WAIT_OBJECT_0]);
 10972     }
 10992     }
 10973 
 10993 
 10974     RETURN (nil);
 10994     RETURN (nil);
 10975 fail: ;
 10995 fail: ;
 10976 %}.
 10996 %}.
 10991     INT t;
 11011     INT t;
 10992     DWORD res;
 11012     DWORD res;
 10993     HANDLE h = NULL;
 11013     HANDLE h = NULL;
 10994 
 11014 
 10995     if (__isExternalAddressLike(fdOrHandle)) {
 11015     if (__isExternalAddressLike(fdOrHandle)) {
 10996         h = _HANDLEVal(fdOrHandle);
 11016 	h = _HANDLEVal(fdOrHandle);
 10997     } else {
 11017     } else {
 10998         if (__isSmallInteger(fdOrHandle)) {
 11018 	if (__isSmallInteger(fdOrHandle)) {
 10999             h = (HANDLE) _get_osfhandle (__intVal(fdOrHandle));
 11019 	    h = (HANDLE) _get_osfhandle (__intVal(fdOrHandle));
 11000         } else {
 11020 	} else {
 11001             goto fail;
 11021 	    goto fail;
 11002         }
 11022 	}
 11003     }
 11023     }
 11004 
 11024 
 11005     if (__isSmallInteger(millis)) {
 11025     if (__isSmallInteger(millis)) {
 11006         t = __intVal(millis);
 11026 	t = __intVal(millis);
 11007     } else {
 11027     } else {
 11008         t = INFINITE;
 11028 	t = INFINITE;
 11009     }
 11029     }
 11010 
 11030 
 11011 #ifdef DO_WRAP_CALLS
 11031 #ifdef DO_WRAP_CALLS
 11012     do {
 11032     do {
 11013         __threadErrno = 0;
 11033 	__threadErrno = 0;
 11014         res = STX_API_CALL2( "WaitForSingleObject", WaitForSingleObject, h,  t);
 11034 	res = STX_API_CALL2( "WaitForSingleObject", WaitForSingleObject, h,  t);
 11015     } while ((res < 0) && (__threadErrno == EINTR));
 11035     } while ((res < 0) && (__threadErrno == EINTR));
 11016 #else
 11036 #else
 11017     res = WaitForSingleObject(h, t);
 11037     res = WaitForSingleObject(h, t);
 11018     if (res < 0) {
 11038     if (res < 0) {
 11019         __threadErrno = __WIN32_ERR(GetLastError());
 11039 	__threadErrno = __WIN32_ERR(GetLastError());
 11020     }
 11040     }
 11021 #endif
 11041 #endif
 11022     if (res == WAIT_FAILED) {
 11042     if (res == WAIT_FAILED) {
 11023         RETURN (nil);
 11043 	RETURN (nil);
 11024     }
 11044     }
 11025     if (res == WAIT_TIMEOUT) {
 11045     if (res == WAIT_TIMEOUT) {
 11026         RETURN (nil);
 11046 	RETURN (nil);
 11027     }
 11047     }
 11028 
 11048 
 11029     RETURN (fdOrHandle);
 11049     RETURN (fdOrHandle);
 11030 fail: ;
 11050 fail: ;
 11031 %}.
 11051 %}.
 11216 
 11236 
 11217 !Win32OperatingSystem::FileStatusInfo class methodsFor:'instance creation'!
 11237 !Win32OperatingSystem::FileStatusInfo class methodsFor:'instance creation'!
 11218 
 11238 
 11219 type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT created:cT sourcePath:lP fullName:fullName alternativeName:name2
 11239 type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT created:cT sourcePath:lP fullName:fullName alternativeName:name2
 11220     ^ self basicNew
 11240     ^ self basicNew
 11221         type:t mode:m uid:u gid:g size:s
 11241 	type:t mode:m uid:u gid:g size:s
 11222         id:i accessed:aT modified:mT created:cT
 11242 	id:i accessed:aT modified:mT created:cT
 11223         sourcePath:lP
 11243 	sourcePath:lP
 11224         fullName:fullName
 11244 	fullName:fullName
 11225         alternativeName:name2
 11245 	alternativeName:name2
 11226 ! !
 11246 ! !
 11227 
 11247 
 11228 !Win32OperatingSystem::FileStatusInfo methodsFor:'accessing'!
 11248 !Win32OperatingSystem::FileStatusInfo methodsFor:'accessing'!
 11229 
 11249 
 11230 accessTime
 11250 accessTime
 11241 
 11261 
 11242     |path idx|
 11262     |path idx|
 11243 
 11263 
 11244     path := self alternativePathName.
 11264     path := self alternativePathName.
 11245     path notNil ifTrue:[
 11265     path notNil ifTrue:[
 11246         idx := path lastIndexOf:$\ startingAt:path size-1.
 11266 	idx := path lastIndexOf:$\ startingAt:path size-1.
 11247         idx ~~ 0 ifTrue:[
 11267 	idx ~~ 0 ifTrue:[
 11248             path := path copyFrom:(idx+1).
 11268 	    path := path copyFrom:(idx+1).
 11249         ].
 11269 	].
 11250     ].
 11270     ].
 11251 
 11271 
 11252     ^ path
 11272     ^ path
 11253 
 11273 
 11254     "
 11274     "
 11255         'C:\' asFilename info alternativeName
 11275 	'C:\' asFilename info alternativeName
 11256         'C:\Dokumente und Einstellungen\' asFilename info alternativeName
 11276 	'C:\Dokumente und Einstellungen\' asFilename info alternativeName
 11257         'C:\Dokumente und Einstellungen' asFilename info alternativeName
 11277 	'C:\Dokumente und Einstellungen' asFilename info alternativeName
 11258     "
 11278     "
 11259 !
 11279 !
 11260 
 11280 
 11261 alternativePathName
 11281 alternativePathName
 11262     "return the files real name (non-DOS name on windows).
 11282     "return the files real name (non-DOS name on windows).
 11263      Nil if there is no other name"
 11283      Nil if there is no other name"
 11264 
 11284 
 11265     "/ access lazily...
 11285     "/ access lazily...
 11266     alternativePathName isNil ifTrue:[
 11286     alternativePathName isNil ifTrue:[
 11267         alternativePathName := (OperatingSystem getShortPathName:sourcePath) asSingleByteString.
 11287 	alternativePathName := (OperatingSystem getShortPathName:sourcePath) asSingleByteString.
 11268     ].
 11288     ].
 11269 
 11289 
 11270     ^ alternativePathName
 11290     ^ alternativePathName
 11271 
 11291 
 11272     "
 11292     "
 11273         'C:\' asFilename info alternativePathName
 11293 	'C:\' asFilename info alternativePathName
 11274         'C:\Dokumente und Einstellungen' asFilename info alternativePathName
 11294 	'C:\Dokumente und Einstellungen' asFilename info alternativePathName
 11275     "
 11295     "
 11276 !
 11296 !
 11277 
 11297 
 11278 creationTime
 11298 creationTime
 11279     ^ created
 11299     ^ created
 11293 
 11313 
 11294     |path idx|
 11314     |path idx|
 11295 
 11315 
 11296     path := self fullPathName.
 11316     path := self fullPathName.
 11297     path notNil ifTrue:[
 11317     path notNil ifTrue:[
 11298         idx := path lastIndexOf:$\ startingAt:path size-1.
 11318 	idx := path lastIndexOf:$\ startingAt:path size-1.
 11299         idx ~~ 0 ifTrue:[
 11319 	idx ~~ 0 ifTrue:[
 11300             path := path copyFrom:(idx+1).
 11320 	    path := path copyFrom:(idx+1).
 11301         ].
 11321 	].
 11302     ].
 11322     ].
 11303 
 11323 
 11304     ^ path
 11324     ^ path
 11305 
 11325 
 11306     "
 11326     "
 11307         '\' asFilename info fullName
 11327 	'\' asFilename info fullName
 11308         'C:\' asFilename info fullName
 11328 	'C:\' asFilename info fullName
 11309         'C:\Dokumente und Einstellungen' asFilename info fullName
 11329 	'C:\Dokumente und Einstellungen' asFilename info fullName
 11310     "
 11330     "
 11311 !
 11331 !
 11312 
 11332 
 11313 fullPathName
 11333 fullPathName
 11314     "return the files real name (non-DOS name on windows).
 11334     "return the files real name (non-DOS name on windows).
 11315      Nil if there is no other name"
 11335      Nil if there is no other name"
 11316 
 11336 
 11317     "/ access lazily...
 11337     "/ access lazily...
 11318     fullPathName isNil ifTrue:[
 11338     fullPathName isNil ifTrue:[
 11319         fullPathName := (OperatingSystem getLongPathName:sourcePath) asSingleByteStringIfPossible.
 11339 	fullPathName := (OperatingSystem getLongPathName:sourcePath) asSingleByteStringIfPossible.
 11320     ].
 11340     ].
 11321 
 11341 
 11322     ^ fullPathName
 11342     ^ fullPathName
 11323 
 11343 
 11324     "
 11344     "
 11325         'C:\' asFilename info fullPathName
 11345 	'C:\' asFilename info fullPathName
 11326         'C:\Dokumente und Einstellungen' asFilename info fullPathName
 11346 	'C:\Dokumente und Einstellungen' asFilename info fullPathName
 11327     "
 11347     "
 11328 !
 11348 !
 11329 
 11349 
 11330 gid
 11350 gid
 11331     "return gid"
 11351     "return gid"
 11342 linkTargetPath
 11362 linkTargetPath
 11343     "for symbolic links only: return the path where the symbolic link points to"
 11363     "for symbolic links only: return the path where the symbolic link points to"
 11344 
 11364 
 11345     "/ access lazily...
 11365     "/ access lazily...
 11346     linkTargetPath isNil ifTrue:[
 11366     linkTargetPath isNil ifTrue:[
 11347         type == #symbolicLink ifTrue:[
 11367 	type == #symbolicLink ifTrue:[
 11348             linkTargetPath := OperatingSystem getLinkTarget:sourcePath.
 11368 	    linkTargetPath := OperatingSystem getLinkTarget:sourcePath.
 11349         ]
 11369 	]
 11350     ].
 11370     ].
 11351 
 11371 
 11352     ^ linkTargetPath
 11372     ^ linkTargetPath
 11353 
 11373 
 11354     "Modified: / 07-02-2007 / 10:31:56 / cg"
 11374     "Modified: / 07-02-2007 / 10:31:56 / cg"
 11606     This is an auxillary class, that holds information about status changes of
 11626     This is an auxillary class, that holds information about status changes of
 11607     operating system processes (these are no smalltalk processes!!).
 11627     operating system processes (these are no smalltalk processes!!).
 11608 
 11628 
 11609     [Instance variables:]
 11629     [Instance variables:]
 11610 
 11630 
 11611         pid     <Integer>       OS-Process identifier
 11631 	pid     <Integer>       OS-Process identifier
 11612 
 11632 
 11613         status  <Symbol>        either #exit #signal #stop #continue
 11633 	status  <Symbol>        either #exit #signal #stop #continue
 11614 
 11634 
 11615         code    <Integer>       either exitcode or signalnumber
 11635 	code    <Integer>       either exitcode or signalnumber
 11616 
 11636 
 11617         core    <Boolean>       true if core has been dumped
 11637 	core    <Boolean>       true if core has been dumped
 11618 
 11638 
 11619 
 11639 
 11620     [author:]
 11640     [author:]
 11621         Stefan Vogel
 11641 	Stefan Vogel
 11622 
 11642 
 11623     [see also:]
 11643     [see also:]
 11624         OperatingSystem
 11644 	OperatingSystem
 11625 "
 11645 "
 11626 ! !
 11646 ! !
 11627 
 11647 
 11628 !Win32OperatingSystem::OSProcessStatus class methodsFor:'instance creation'!
 11648 !Win32OperatingSystem::OSProcessStatus class methodsFor:'instance creation'!
 11629 
 11649 
 11760 !Win32OperatingSystem::PerformanceData class methodsFor:'accessing'!
 11780 !Win32OperatingSystem::PerformanceData class methodsFor:'accessing'!
 11761 
 11781 
 11762 counterIndexTextDictionary
 11782 counterIndexTextDictionary
 11763 
 11783 
 11764     "
 11784     "
 11765         self counterIndexTextDictionary
 11785 	self counterIndexTextDictionary
 11766     "
 11786     "
 11767 
 11787 
 11768     CounterIndexTextDictionary isNil ifTrue:[
 11788     CounterIndexTextDictionary isNil ifTrue:[
 11769         self synchronized:[
 11789 	self synchronized:[
 11770             CounterIndexTextDictionary isNil ifTrue:[
 11790 	    CounterIndexTextDictionary isNil ifTrue:[
 11771                 |performanceText counterIndexTextDictionary|
 11791 		|performanceText counterIndexTextDictionary|
 11772 
 11792 
 11773                 performanceText := self getPerformanceText valueNamed:'Counter'.
 11793 		performanceText := self getPerformanceText valueNamed:'Counter'.
 11774                 counterIndexTextDictionary := IdentityDictionary new.
 11794 		counterIndexTextDictionary := IdentityDictionary new.
 11775 
 11795 
 11776                 1 to:performanceText size by:2 do:[:index|
 11796 		1 to:performanceText size by:2 do:[:index|
 11777                     counterIndexTextDictionary at:(performanceText at:index) asInteger put:(performanceText at:index + 1).
 11797 		    counterIndexTextDictionary at:(performanceText at:index) asInteger put:(performanceText at:index + 1).
 11778                 ].
 11798 		].
 11779 
 11799 
 11780                 CounterIndexTextDictionary := counterIndexTextDictionary.
 11800 		CounterIndexTextDictionary := counterIndexTextDictionary.
 11781             ].
 11801 	    ].
 11782         ].
 11802 	].
 11783     ].
 11803     ].
 11784 
 11804 
 11785     ^ CounterIndexTextDictionary
 11805     ^ CounterIndexTextDictionary
 11786 !
 11806 !
 11787 
 11807 
 11788 helpIndexTextDictionary
 11808 helpIndexTextDictionary
 11789 
 11809 
 11790     "
 11810     "
 11791         self helpIndexTextDictionary
 11811 	self helpIndexTextDictionary
 11792     "
 11812     "
 11793 
 11813 
 11794     HelpIndexTextDictionary isNil ifTrue:[
 11814     HelpIndexTextDictionary isNil ifTrue:[
 11795         self synchronized:[
 11815 	self synchronized:[
 11796             HelpIndexTextDictionary isNil ifTrue:[
 11816 	    HelpIndexTextDictionary isNil ifTrue:[
 11797                 |performanceText helpIndexTextDictionary|
 11817 		|performanceText helpIndexTextDictionary|
 11798 
 11818 
 11799                 performanceText := self getPerformanceText valueNamed:'Help'.
 11819 		performanceText := self getPerformanceText valueNamed:'Help'.
 11800                 helpIndexTextDictionary := IdentityDictionary new.
 11820 		helpIndexTextDictionary := IdentityDictionary new.
 11801 
 11821 
 11802                 1 to:performanceText size by:2 do:[:index|
 11822 		1 to:performanceText size by:2 do:[:index|
 11803                     helpIndexTextDictionary at:(performanceText at:index) asInteger put:(performanceText at:index + 1).
 11823 		    helpIndexTextDictionary at:(performanceText at:index) asInteger put:(performanceText at:index + 1).
 11804                 ].
 11824 		].
 11805 
 11825 
 11806                 HelpIndexTextDictionary := helpIndexTextDictionary.
 11826 		HelpIndexTextDictionary := helpIndexTextDictionary.
 11807             ].
 11827 	    ].
 11808         ].
 11828 	].
 11809     ].
 11829     ].
 11810 
 11830 
 11811     ^ HelpIndexTextDictionary
 11831     ^ HelpIndexTextDictionary
 11812 ! !
 11832 ! !
 11813 
 11833 
 11840 !Win32OperatingSystem::PerformanceData class methodsFor:'documentation'!
 11860 !Win32OperatingSystem::PerformanceData class methodsFor:'documentation'!
 11841 
 11861 
 11842 documentation
 11862 documentation
 11843 
 11863 
 11844     "
 11864     "
 11845         VISTA:
 11865 	VISTA:
 11846 
 11866 
 11847         Wer versucht unter Vista die Registy HKEY_PERFORMANCE_DATA abzufragen wird zunächst enttäuscht.
 11867 	Wer versucht unter Vista die Registy HKEY_PERFORMANCE_DATA abzufragen wird zunächst enttäuscht.
 11848         Die UAC UserAccessControl verhindern dies nämlich (selbs für den admin).
 11868 	Die UAC UserAccessControl verhindern dies nämlich (selbs für den admin).
 11849 
 11869 
 11850         Um dies zu umgehen:
 11870 	Um dies zu umgehen:
 11851 
 11871 
 11852         To turn off UAC
 11872 	To turn off UAC
 11853 
 11873 
 11854         1. Click Start, and then click Control Panel.
 11874 	1. Click Start, and then click Control Panel.
 11855         2. In Control Panel, click User Accounts.
 11875 	2. In Control Panel, click User Accounts.
 11856         3. In the User Accounts window, click User Accounts.
 11876 	3. In the User Accounts window, click User Accounts.
 11857         4. In the User Accounts tasks window, click Turn User Account Control on or off.
 11877 	4. In the User Accounts tasks window, click Turn User Account Control on or off.
 11858         5. If UAC is currently configured in Admin Approval Mode, the User Account Control message appears. Click Continue.
 11878 	5. If UAC is currently configured in Admin Approval Mode, the User Account Control message appears. Click Continue.
 11859         6. Clear the Use User Account Control (UAC) to help protect your computer check box, and then click OK.
 11879 	6. Clear the Use User Account Control (UAC) to help protect your computer check box, and then click OK.
 11860         7. Click Restart Now to apply the change right away, or click Restart Later and close the User Accounts tasks window.
 11880 	7. Click Restart Now to apply the change right away, or click Restart Later and close the User Accounts tasks window.
 11861     "
 11881     "
 11862 !
 11882 !
 11863 
 11883 
 11864 examples
 11884 examples
 11865 
 11885 
 11866     "
 11886     "
 11867         ######################################### PRIMITIVE
 11887 	######################################### PRIMITIVE
 11868         self getUsedMemoryInPercentage.
 11888 	self getUsedMemoryInPercentage.
 11869 
 11889 
 11870         self getPhysicalMemoryInKB.
 11890 	self getPhysicalMemoryInKB.
 11871         self getPhysicalMemoryInMB.
 11891 	self getPhysicalMemoryInMB.
 11872 
 11892 
 11873         self getFreePhysicalMemoryInKB.
 11893 	self getFreePhysicalMemoryInKB.
 11874         self getFreePhysicalMemoryInMB.
 11894 	self getFreePhysicalMemoryInMB.
 11875 
 11895 
 11876         self getPageFileSizeInKB.
 11896 	self getPageFileSizeInKB.
 11877         self getPageFileSizeInMB.
 11897 	self getPageFileSizeInMB.
 11878 
 11898 
 11879         self getFreePageFileSizeInKB.
 11899 	self getFreePageFileSizeInKB.
 11880         self getFreePageFileSizeInMB.
 11900 	self getFreePageFileSizeInMB.
 11881 
 11901 
 11882         self getVirtualMemoryInKB.
 11902 	self getVirtualMemoryInKB.
 11883         self getVirtualMemoryInMB.
 11903 	self getVirtualMemoryInMB.
 11884 
 11904 
 11885         ######################################### REGISTRY
 11905 	######################################### REGISTRY
 11886         self helpIndexTextDictionary
 11906 	self helpIndexTextDictionary
 11887         self counterIndexTextDictionary
 11907 	self counterIndexTextDictionary
 11888 
 11908 
 11889         self global getCounterNameIndexArray.
 11909 	self global getCounterNameIndexArray.
 11890         self global getObjectNameIndexArray.
 11910 	self global getObjectNameIndexArray.
 11891 
 11911 
 11892         self processor getCounterNameIndexArray.
 11912 	self processor getCounterNameIndexArray.
 11893         self processor processorUsage.
 11913 	self processor processorUsage.
 11894         self processor processorUsageFromLast.
 11914 	self processor processorUsageFromLast.
 11895         self processor interruptsPerSecond.
 11915 	self processor interruptsPerSecond.
 11896         self processor interruptsPerSecondFromLast.
 11916 	self processor interruptsPerSecondFromLast.
 11897 
 11917 
 11898         self process getCounterNameIndexArray.
 11918 	self process getCounterNameIndexArray.
 11899         self process processUsage.
 11919 	self process processUsage.
 11900         self process processUsageFromLast.
 11920 	self process processUsageFromLast.
 11901         self process runningProcesses.
 11921 	self process runningProcesses.
 11902         self process runningProcessNameList.
 11922 	self process runningProcessNameList.
 11903 
 11923 
 11904         self network getCounterNameIndexArray.
 11924 	self network getCounterNameIndexArray.
 11905         self network kBytesReceivedPerSecond.
 11925 	self network kBytesReceivedPerSecond.
 11906         self network kBytesReceivedPerSecondFromLast.
 11926 	self network kBytesReceivedPerSecondFromLast.
 11907         self network kBytesSentPerSecond.
 11927 	self network kBytesSentPerSecond.
 11908         self network kBytesSentPerSecondFromLast.
 11928 	self network kBytesSentPerSecondFromLast.
 11909 
 11929 
 11910         self memory getCounterNameIndexArray.
 11930 	self memory getCounterNameIndexArray.
 11911         self memory availableMBytes.
 11931 	self memory availableMBytes.
 11912         self memory availableKBytes.
 11932 	self memory availableKBytes.
 11913 
 11933 
 11914         self diskIO getCounterNameIndexArray.
 11934 	self diskIO getCounterNameIndexArray.
 11915         self diskIO diskSpaceFreeInMegaByte.
 11935 	self diskIO diskSpaceFreeInMegaByte.
 11916         self diskIO diskQueueLength.
 11936 	self diskIO diskQueueLength.
 11917         self diskIO diskTransfersPerSecond.
 11937 	self diskIO diskTransfersPerSecond.
 11918         self diskIO diskTransfersPerSecondFromlast.
 11938 	self diskIO diskTransfersPerSecondFromlast.
 11919         self diskIO diskReadsPerSecond.
 11939 	self diskIO diskReadsPerSecond.
 11920         self diskIO diskReadsPerSecondFromLast.
 11940 	self diskIO diskReadsPerSecondFromLast.
 11921         self diskIO diskWritesPerSecond.
 11941 	self diskIO diskWritesPerSecond.
 11922         self diskIO diskWritesPerSecondFromLast.
 11942 	self diskIO diskWritesPerSecondFromLast.
 11923         self diskIO diskBytesPerSecond.
 11943 	self diskIO diskBytesPerSecond.
 11924         self diskIO diskBytesPerSecondFromLast.
 11944 	self diskIO diskBytesPerSecondFromLast.
 11925     "
 11945     "
 11926 ! !
 11946 ! !
 11927 
 11947 
 11928 !Win32OperatingSystem::PerformanceData class methodsFor:'initialization'!
 11948 !Win32OperatingSystem::PerformanceData class methodsFor:'initialization'!
 11929 
 11949 
 11930 initialize
 11950 initialize
 11931 
 11951 
 11932     "
 11952     "
 11933         self initialize
 11953 	self initialize
 11934     "
 11954     "
 11935 
 11955 
 11936     PerformanceText := CounterIndexTextDictionary := HelpIndexTextDictionary := nil.
 11956     PerformanceText := CounterIndexTextDictionary := HelpIndexTextDictionary := nil.
 11937 ! !
 11957 ! !
 11938 
 11958 
 11939 !Win32OperatingSystem::PerformanceData class methodsFor:'private'!
 11959 !Win32OperatingSystem::PerformanceData class methodsFor:'private'!
 11940 
 11960 
 11941 getPerformanceText
 11961 getPerformanceText
 11942 
 11962 
 11943     PerformanceText isNil ifTrue:[
 11963     PerformanceText isNil ifTrue:[
 11944         PerformanceText := Win32OperatingSystem registryEntry key:'HKEY_PERFORMANCE_TEXT'.
 11964 	PerformanceText := Win32OperatingSystem registryEntry key:'HKEY_PERFORMANCE_TEXT'.
 11945     ].
 11965     ].
 11946 
 11966 
 11947     ^ PerformanceText
 11967     ^ PerformanceText
 11948 ! !
 11968 ! !
 11949 
 11969 
 11951 
 11971 
 11952 getFreePageFileSizeInKB
 11972 getFreePageFileSizeInKB
 11953     |ret|
 11973     |ret|
 11954 
 11974 
 11955     %{
 11975     %{
 11956         MEMORYSTATUS mState;
 11976 	MEMORYSTATUS mState;
 11957         GlobalMemoryStatus (&mState);
 11977 	GlobalMemoryStatus (&mState);
 11958 
 11978 
 11959         ret = __mkSmallInteger(mState.dwAvailPageFile / 1024);
 11979 	ret = __mkSmallInteger(mState.dwAvailPageFile / 1024);
 11960     %}.
 11980     %}.
 11961 
 11981 
 11962     ^ ret
 11982     ^ ret
 11963 
 11983 
 11964     "
 11984     "
 11965         self getFreePageFileSizeInKB
 11985 	self getFreePageFileSizeInKB
 11966     "
 11986     "
 11967 !
 11987 !
 11968 
 11988 
 11969 getFreePageFileSizeInMB
 11989 getFreePageFileSizeInMB
 11970     ^ (self getFreePageFileSizeInKB / 1024) asInteger
 11990     ^ (self getFreePageFileSizeInKB / 1024) asInteger
 11971 
 11991 
 11972     "
 11992     "
 11973         self getFreePageFileSizeInMB
 11993 	self getFreePageFileSizeInMB
 11974     "
 11994     "
 11975 !
 11995 !
 11976 
 11996 
 11977 getFreePhysicalMemoryInKB
 11997 getFreePhysicalMemoryInKB
 11978     |ret|
 11998     |ret|
 11979 
 11999 
 11980     %{
 12000     %{
 11981         MEMORYSTATUS mState;
 12001 	MEMORYSTATUS mState;
 11982         GlobalMemoryStatus (&mState);
 12002 	GlobalMemoryStatus (&mState);
 11983 
 12003 
 11984         ret = __mkSmallInteger(mState.dwAvailPhys / 1024);
 12004 	ret = __mkSmallInteger(mState.dwAvailPhys / 1024);
 11985     %}.
 12005     %}.
 11986 
 12006 
 11987     ^ ret
 12007     ^ ret
 11988 
 12008 
 11989     "
 12009     "
 11990         self getFreePhysicalMemoryInKB
 12010 	self getFreePhysicalMemoryInKB
 11991     "
 12011     "
 11992 !
 12012 !
 11993 
 12013 
 11994 getFreePhysicalMemoryInMB
 12014 getFreePhysicalMemoryInMB
 11995     ^ (self getFreePhysicalMemoryInKB / 1024) asInteger
 12015     ^ (self getFreePhysicalMemoryInKB / 1024) asInteger
 11996 
 12016 
 11997     "
 12017     "
 11998         self getFreePhysicalMemoryInMB
 12018 	self getFreePhysicalMemoryInMB
 11999     "
 12019     "
 12000 !
 12020 !
 12001 
 12021 
 12002 getPageFileSizeInKB
 12022 getPageFileSizeInKB
 12003     ^ self getPageFileSizeInMB * 1024
 12023     ^ self getPageFileSizeInMB * 1024
 12004 
 12024 
 12005     "
 12025     "
 12006         self getPageFileSizeInKB
 12026 	self getPageFileSizeInKB
 12007     "
 12027     "
 12008 !
 12028 !
 12009 
 12029 
 12010 getPageFileSizeInMB
 12030 getPageFileSizeInMB
 12011     |ret|
 12031     |ret|
 12012 
 12032 
 12013     %{
 12033     %{
 12014         SYSTEM_INFO sInfo;
 12034 	SYSTEM_INFO sInfo;
 12015         GetSystemInfo(&sInfo);
 12035 	GetSystemInfo(&sInfo);
 12016 
 12036 
 12017         ret = __mkSmallInteger(sInfo.dwPageSize);
 12037 	ret = __mkSmallInteger(sInfo.dwPageSize);
 12018     %}.
 12038     %}.
 12019 
 12039 
 12020     ^ ret
 12040     ^ ret
 12021 
 12041 
 12022     "
 12042     "
 12023         self getPageFileSizeInMB
 12043 	self getPageFileSizeInMB
 12024     "
 12044     "
 12025 !
 12045 !
 12026 
 12046 
 12027 getPhysicalMemoryInKB
 12047 getPhysicalMemoryInKB
 12028     |ret|
 12048     |ret|
 12029 
 12049 
 12030     %{
 12050     %{
 12031         MEMORYSTATUS mState;
 12051 	MEMORYSTATUS mState;
 12032         GlobalMemoryStatus (&mState);
 12052 	GlobalMemoryStatus (&mState);
 12033 
 12053 
 12034         ret = __mkSmallInteger(mState.dwTotalPhys / 1024);
 12054 	ret = __mkSmallInteger(mState.dwTotalPhys / 1024);
 12035     %}.
 12055     %}.
 12036 
 12056 
 12037     ^ ret
 12057     ^ ret
 12038 
 12058 
 12039     "
 12059     "
 12040         self getPhysicalMemoryInKB
 12060 	self getPhysicalMemoryInKB
 12041     "
 12061     "
 12042 !
 12062 !
 12043 
 12063 
 12044 getPhysicalMemoryInMB
 12064 getPhysicalMemoryInMB
 12045     ^ (self getPhysicalMemoryInKB / 1024) asInteger
 12065     ^ (self getPhysicalMemoryInKB / 1024) asInteger
 12046 
 12066 
 12047     "
 12067     "
 12048         self getPhysicalMemoryInMB
 12068 	self getPhysicalMemoryInMB
 12049     "
 12069     "
 12050 !
 12070 !
 12051 
 12071 
 12052 getUsedMemoryInPercentage
 12072 getUsedMemoryInPercentage
 12053     |ret|
 12073     |ret|
 12054 
 12074 
 12055     %{
 12075     %{
 12056         MEMORYSTATUS mState;
 12076 	MEMORYSTATUS mState;
 12057         GlobalMemoryStatus (&mState);
 12077 	GlobalMemoryStatus (&mState);
 12058 
 12078 
 12059         ret = __mkSmallInteger(mState.dwMemoryLoad);
 12079 	ret = __mkSmallInteger(mState.dwMemoryLoad);
 12060     %}.
 12080     %}.
 12061 
 12081 
 12062     ^ ret
 12082     ^ ret
 12063 
 12083 
 12064     "
 12084     "
 12065         self getUsedMemoryInPercentage
 12085 	self getUsedMemoryInPercentage
 12066     "
 12086     "
 12067 !
 12087 !
 12068 
 12088 
 12069 getVirtualMemoryInKB
 12089 getVirtualMemoryInKB
 12070     |ret|
 12090     |ret|
 12071 
 12091 
 12072     %{
 12092     %{
 12073         MEMORYSTATUS mState;
 12093 	MEMORYSTATUS mState;
 12074         GlobalMemoryStatus (&mState);
 12094 	GlobalMemoryStatus (&mState);
 12075 
 12095 
 12076         ret = __mkSmallInteger(mState.dwTotalVirtual / 1024);
 12096 	ret = __mkSmallInteger(mState.dwTotalVirtual / 1024);
 12077     %}.
 12097     %}.
 12078 
 12098 
 12079     ^ ret
 12099     ^ ret
 12080 
 12100 
 12081     "
 12101     "
 12082         self getVirtualMemoryInKB
 12102 	self getVirtualMemoryInKB
 12083     "
 12103     "
 12084 !
 12104 !
 12085 
 12105 
 12086 getVirtualMemoryInMB
 12106 getVirtualMemoryInMB
 12087     ^ (self getVirtualMemoryInKB / 1024) asInteger
 12107     ^ (self getVirtualMemoryInKB / 1024) asInteger
 12088 
 12108 
 12089     "
 12109     "
 12090         self getVirtualMemoryInMB
 12110 	self getVirtualMemoryInMB
 12091     "
 12111     "
 12092 ! !
 12112 ! !
 12093 
 12113 
 12094 !Win32OperatingSystem::PerformanceData methodsFor:'accessing'!
 12114 !Win32OperatingSystem::PerformanceData methodsFor:'accessing'!
 12095 
 12115 
 12151     st_objectArray = __ARRAY_NEW_INT(numObjectTypes);
 12171     st_objectArray = __ARRAY_NEW_INT(numObjectTypes);
 12152     perfObjectPtr = (PERF_OBJECT_TYPE *)((char *)perfData + perfData->HeaderLength);
 12172     perfObjectPtr = (PERF_OBJECT_TYPE *)((char *)perfData + perfData->HeaderLength);
 12153 
 12173 
 12154     //iterate all following objetcs
 12174     //iterate all following objetcs
 12155     for (objectIterator=0; objectIterator<numObjectTypes; objectIterator++) {
 12175     for (objectIterator=0; objectIterator<numObjectTypes; objectIterator++) {
 12156         //add the st_perObject dictionary to st_objectArray
 12176 	//add the st_perObject dictionary to st_objectArray
 12157         st_perObject = __SSEND0(@global(Dictionary), @symbol(new), 0);
 12177 	st_perObject = __SSEND0(@global(Dictionary), @symbol(new), 0);
 12158         __AT_PUT_(st_objectArray, __mkSmallInteger(objectIterator+1), st_perObject);
 12178 	__AT_PUT_(st_objectArray, __mkSmallInteger(objectIterator+1), st_perObject);
 12159 
 12179 
 12160         //get the object data
 12180 	//get the object data
 12161         __AT_PUT_(st_perObject, @symbol(ObjectNameTitleIndex), __mkSmallInteger(perfObjectPtr->ObjectNameTitleIndex));
 12181 	__AT_PUT_(st_perObject, @symbol(ObjectNameTitleIndex), __mkSmallInteger(perfObjectPtr->ObjectNameTitleIndex));
 12162         __AT_PUT_(st_perObject, @symbol(DetailLevel), __mkSmallInteger(perfObjectPtr->DetailLevel));
 12182 	__AT_PUT_(st_perObject, @symbol(DetailLevel), __mkSmallInteger(perfObjectPtr->DetailLevel));
 12163         __AT_PUT_(st_perObject, @symbol(NumCounters), __mkSmallInteger(perfObjectPtr->NumCounters));
 12183 	__AT_PUT_(st_perObject, @symbol(NumCounters), __mkSmallInteger(perfObjectPtr->NumCounters));
 12164         __AT_PUT_(st_perObject, @symbol(NumInstances), __mkSmallInteger(perfObjectPtr->NumInstances));
 12184 	__AT_PUT_(st_perObject, @symbol(NumInstances), __mkSmallInteger(perfObjectPtr->NumInstances));
 12165 
 12185 
 12166         //setup counter array and initialize its pointer
 12186 	//setup counter array and initialize its pointer
 12167         st_counterArray = __ARRAY_NEW_INT(perfObjectPtr->NumCounters);
 12187 	st_counterArray = __ARRAY_NEW_INT(perfObjectPtr->NumCounters);
 12168         perfCounterPtr = (PERF_COUNTER_DEFINITION *)((char *)perfObjectPtr + perfObjectPtr->HeaderLength);
 12188 	perfCounterPtr = (PERF_COUNTER_DEFINITION *)((char *)perfObjectPtr + perfObjectPtr->HeaderLength);
 12169 
 12189 
 12170         //add the st_counterArray to st_perObject dictionary
 12190 	//add the st_counterArray to st_perObject dictionary
 12171         __AT_PUT_(st_perObject, @symbol(Counters), st_counterArray);
 12191 	__AT_PUT_(st_perObject, @symbol(Counters), st_counterArray);
 12172 
 12192 
 12173         //iterate all following counter definition
 12193 	//iterate all following counter definition
 12174         for (counterIterator=0; counterIterator<perfObjectPtr->NumCounters; counterIterator++) {
 12194 	for (counterIterator=0; counterIterator<perfObjectPtr->NumCounters; counterIterator++) {
 12175             //add the st_perCounter dictionary to st_counterArray
 12195 	    //add the st_perCounter dictionary to st_counterArray
 12176             st_perCounter = __SSEND0(@global(Dictionary), @symbol(new), 0);
 12196 	    st_perCounter = __SSEND0(@global(Dictionary), @symbol(new), 0);
 12177             __AT_PUT_(st_counterArray, __mkSmallInteger(counterIterator+1), st_perCounter);
 12197 	    __AT_PUT_(st_counterArray, __mkSmallInteger(counterIterator+1), st_perCounter);
 12178 
 12198 
 12179             //get the counter data
 12199 	    //get the counter data
 12180             __AT_PUT_(st_perCounter, @symbol(CounterNameTitleIndex), __mkSmallInteger(perfCounterPtr->CounterNameTitleIndex));
 12200 	    __AT_PUT_(st_perCounter, @symbol(CounterNameTitleIndex), __mkSmallInteger(perfCounterPtr->CounterNameTitleIndex));
 12181             __AT_PUT_(st_perCounter, @symbol(CounterTypeBits), __mkSmallInteger(perfCounterPtr->CounterType));
 12201 	    __AT_PUT_(st_perCounter, @symbol(CounterTypeBits), __mkSmallInteger(perfCounterPtr->CounterType));
 12182             __AT_PUT_(st_perCounter, @symbol(CounterSize), __mkSmallInteger(perfCounterPtr->CounterSize));
 12202 	    __AT_PUT_(st_perCounter, @symbol(CounterSize), __mkSmallInteger(perfCounterPtr->CounterSize));
 12183             __AT_PUT_(st_perCounter, @symbol(CounterOffset), __mkSmallInteger(perfCounterPtr->CounterOffset));
 12203 	    __AT_PUT_(st_perCounter, @symbol(CounterOffset), __mkSmallInteger(perfCounterPtr->CounterOffset));
 12184 
 12204 
 12185             //put the counter type size
 12205 	    //put the counter type size
 12186             switch (perfCounterPtr->CounterType & PERF_SIZE_MASK) {
 12206 	    switch (perfCounterPtr->CounterType & PERF_SIZE_MASK) {
 12187                 case PERF_SIZE_DWORD:
 12207 		case PERF_SIZE_DWORD:
 12188                     __AT_PUT_(st_perCounter, @symbol(SIZE),@symbol(DWORD));
 12208 		    __AT_PUT_(st_perCounter, @symbol(SIZE),@symbol(DWORD));
 12189                     break;
 12209 		    break;
 12190                 case PERF_SIZE_LARGE:
 12210 		case PERF_SIZE_LARGE:
 12191                     __AT_PUT_(st_perCounter, @symbol(SIZE),@symbol(LARGE));
 12211 		    __AT_PUT_(st_perCounter, @symbol(SIZE),@symbol(LARGE));
 12192                     break;
 12212 		    break;
 12193                 case PERF_SIZE_ZERO:
 12213 		case PERF_SIZE_ZERO:
 12194                     __AT_PUT_(st_perCounter, @symbol(SIZE),@symbol(ZERO));
 12214 		    __AT_PUT_(st_perCounter, @symbol(SIZE),@symbol(ZERO));
 12195                     break;
 12215 		    break;
 12196                 case PERF_SIZE_VARIABLE_LEN:
 12216 		case PERF_SIZE_VARIABLE_LEN:
 12197                     __AT_PUT_(st_perCounter, @symbol(SIZE),@symbol(VARIABLE_LEN));
 12217 		    __AT_PUT_(st_perCounter, @symbol(SIZE),@symbol(VARIABLE_LEN));
 12198                     break;
 12218 		    break;
 12199             }
 12219 	    }
 12200             switch (perfCounterPtr->CounterType & PERF_TYPE_MASK) {
 12220 	    switch (perfCounterPtr->CounterType & PERF_TYPE_MASK) {
 12201                 case PERF_TYPE_NUMBER:
 12221 		case PERF_TYPE_NUMBER:
 12202                     __AT_PUT_(st_perCounter, @symbol(TYPE),@symbol(NUMBER));
 12222 		    __AT_PUT_(st_perCounter, @symbol(TYPE),@symbol(NUMBER));
 12203                     switch (perfCounterPtr->CounterType & PERF_NUMBERTYPE_MASK) {
 12223 		    switch (perfCounterPtr->CounterType & PERF_NUMBERTYPE_MASK) {
 12204                         case PERF_NUMBER_HEX:
 12224 			case PERF_NUMBER_HEX:
 12205                             __AT_PUT_(st_perCounter, @symbol(NUMBER),@symbol(HEX));
 12225 			    __AT_PUT_(st_perCounter, @symbol(NUMBER),@symbol(HEX));
 12206                             break;
 12226 			    break;
 12207                         case PERF_NUMBER_DECIMAL:
 12227 			case PERF_NUMBER_DECIMAL:
 12208                             __AT_PUT_(st_perCounter, @symbol(NUMBER),@symbol(DECIMAL));
 12228 			    __AT_PUT_(st_perCounter, @symbol(NUMBER),@symbol(DECIMAL));
 12209                             break;
 12229 			    break;
 12210                         case PERF_NUMBER_DEC_1000:
 12230 			case PERF_NUMBER_DEC_1000:
 12211                             __AT_PUT_(st_perCounter, @symbol(NUMBER),@symbol(DEC_1000));
 12231 			    __AT_PUT_(st_perCounter, @symbol(NUMBER),@symbol(DEC_1000));
 12212                             break;
 12232 			    break;
 12213                     }
 12233 		    }
 12214                     break;
 12234 		    break;
 12215                 case PERF_TYPE_COUNTER:
 12235 		case PERF_TYPE_COUNTER:
 12216                     __AT_PUT_(st_perCounter, @symbol(TYPE),@symbol(COUNTER));
 12236 		    __AT_PUT_(st_perCounter, @symbol(TYPE),@symbol(COUNTER));
 12217                     switch (perfCounterPtr->CounterType & PERF_COUNTERTYPE_MASK) {
 12237 		    switch (perfCounterPtr->CounterType & PERF_COUNTERTYPE_MASK) {
 12218                         case PERF_COUNTER_VALUE:
 12238 			case PERF_COUNTER_VALUE:
 12219                             __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(VALUE));
 12239 			    __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(VALUE));
 12220                             break;
 12240 			    break;
 12221                         case PERF_COUNTER_RATE:
 12241 			case PERF_COUNTER_RATE:
 12222                             __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(RATE));
 12242 			    __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(RATE));
 12223                             break;
 12243 			    break;
 12224                         case PERF_COUNTER_FRACTION:
 12244 			case PERF_COUNTER_FRACTION:
 12225                             __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(FRACTION));
 12245 			    __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(FRACTION));
 12226                             break;
 12246 			    break;
 12227                         case PERF_COUNTER_BASE:
 12247 			case PERF_COUNTER_BASE:
 12228                             __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(BASE));
 12248 			    __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(BASE));
 12229                             break;
 12249 			    break;
 12230                         case PERF_COUNTER_ELAPSED:
 12250 			case PERF_COUNTER_ELAPSED:
 12231                             __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(ELAPSED));
 12251 			    __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(ELAPSED));
 12232                             break;
 12252 			    break;
 12233                         case PERF_COUNTER_QUEUELEN:
 12253 			case PERF_COUNTER_QUEUELEN:
 12234                             __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(QUEUELEN));
 12254 			    __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(QUEUELEN));
 12235                             break;
 12255 			    break;
 12236                         case PERF_COUNTER_HISTOGRAM:
 12256 			case PERF_COUNTER_HISTOGRAM:
 12237                             __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(HISTOGRAM));
 12257 			    __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(HISTOGRAM));
 12238                             break;
 12258 			    break;
 12239                         case PERF_COUNTER_PRECISION:
 12259 			case PERF_COUNTER_PRECISION:
 12240                             __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(PRECISION));
 12260 			    __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(PRECISION));
 12241                             break;
 12261 			    break;
 12242                     }
 12262 		    }
 12243                     break;
 12263 		    break;
 12244                 case PERF_TYPE_TEXT:
 12264 		case PERF_TYPE_TEXT:
 12245                     __AT_PUT_(st_perCounter, @symbol(TYPE),@symbol(TEXT));
 12265 		    __AT_PUT_(st_perCounter, @symbol(TYPE),@symbol(TEXT));
 12246                     switch (perfCounterPtr->CounterType & PERF_TEXTTYPE_MASK) {
 12266 		    switch (perfCounterPtr->CounterType & PERF_TEXTTYPE_MASK) {
 12247                         case PERF_TEXT_UNICODE:
 12267 			case PERF_TEXT_UNICODE:
 12248                             __AT_PUT_(st_perCounter, @symbol(TEXT),@symbol(UNICODE));
 12268 			    __AT_PUT_(st_perCounter, @symbol(TEXT),@symbol(UNICODE));
 12249                             break;
 12269 			    break;
 12250                         case PERF_TEXT_ASCII:
 12270 			case PERF_TEXT_ASCII:
 12251                             __AT_PUT_(st_perCounter, @symbol(TEXT),@symbol(ASCII));
 12271 			    __AT_PUT_(st_perCounter, @symbol(TEXT),@symbol(ASCII));
 12252                             break;
 12272 			    break;
 12253                     }
 12273 		    }
 12254                     break;
 12274 		    break;
 12255                 case PERF_TYPE_ZERO:
 12275 		case PERF_TYPE_ZERO:
 12256                     __AT_PUT_(st_perCounter, @symbol(TYPE),@symbol(ZERO));
 12276 		    __AT_PUT_(st_perCounter, @symbol(TYPE),@symbol(ZERO));
 12257                     break;
 12277 		    break;
 12258             }
 12278 	    }
 12259 
 12279 
 12260             //setup the counter pointer to the next counter definition
 12280 	    //setup the counter pointer to the next counter definition
 12261             perfCounterPtr = (PERF_COUNTER_DEFINITION *)((char *)perfCounterPtr + perfCounterPtr->ByteLength);
 12281 	    perfCounterPtr = (PERF_COUNTER_DEFINITION *)((char *)perfCounterPtr + perfCounterPtr->ByteLength);
 12262         }
 12282 	}
 12263 
 12283 
 12264         //goon dependent on the count of instances
 12284 	//goon dependent on the count of instances
 12265         if (perfObjectPtr->NumInstances < 1) {
 12285 	if (perfObjectPtr->NumInstances < 1) {
 12266             perfCounterBlockPtr = (PERF_COUNTER_BLOCK *)(perfCounterPtr);
 12286 	    perfCounterBlockPtr = (PERF_COUNTER_BLOCK *)(perfCounterPtr);
 12267             __AT_PUT_(st_perObject, @symbol(RawData), __MKBYTEARRAY(perfCounterBlockPtr, perfCounterBlockPtr->ByteLength));
 12287 	    __AT_PUT_(st_perObject, @symbol(RawData), __MKBYTEARRAY(perfCounterBlockPtr, perfCounterBlockPtr->ByteLength));
 12268         } else {
 12288 	} else {
 12269             //setup the instance pointer to the end of all counters
 12289 	    //setup the instance pointer to the end of all counters
 12270             perfInstancePtr = (PERF_INSTANCE_DEFINITION *)(perfCounterPtr);
 12290 	    perfInstancePtr = (PERF_INSTANCE_DEFINITION *)(perfCounterPtr);
 12271 
 12291 
 12272             //setup st_instanceArray and add it to st_perObject
 12292 	    //setup st_instanceArray and add it to st_perObject
 12273             st_instanceArray = __ARRAY_NEW_INT(perfObjectPtr->NumInstances);
 12293 	    st_instanceArray = __ARRAY_NEW_INT(perfObjectPtr->NumInstances);
 12274             __AT_PUT_(st_perObject, @symbol(Instances), st_instanceArray);
 12294 	    __AT_PUT_(st_perObject, @symbol(Instances), st_instanceArray);
 12275 
 12295 
 12276             //iterate the instances
 12296 	    //iterate the instances
 12277             for (instanceIterator=0; instanceIterator<perfObjectPtr->NumInstances; instanceIterator++) {
 12297 	    for (instanceIterator=0; instanceIterator<perfObjectPtr->NumInstances; instanceIterator++) {
 12278                 //setup st_perInstance and add it to st_instanceArray
 12298 		//setup st_perInstance and add it to st_instanceArray
 12279                 st_perInstance = __SSEND0(@global(Dictionary), @symbol(new), 0);
 12299 		st_perInstance = __SSEND0(@global(Dictionary), @symbol(new), 0);
 12280                 __AT_PUT_(st_instanceArray, __mkSmallInteger(instanceIterator+1), st_perInstance);
 12300 		__AT_PUT_(st_instanceArray, __mkSmallInteger(instanceIterator+1), st_perInstance);
 12281 
 12301 
 12282                 //get the instance data
 12302 		//get the instance data
 12283                 __AT_PUT_(st_perInstance, @symbol(Name), __MKBYTEARRAY((wchar_t *)((BYTE *)perfInstancePtr + perfInstancePtr->NameOffset),perfInstancePtr->NameLength));
 12303 		__AT_PUT_(st_perInstance, @symbol(Name), __MKBYTEARRAY((wchar_t *)((BYTE *)perfInstancePtr + perfInstancePtr->NameOffset),perfInstancePtr->NameLength));
 12284                 __AT_PUT_(st_perInstance, @symbol(ParentObjectTitleIndex), __mkSmallInteger(perfInstancePtr->ParentObjectTitleIndex));
 12304 		__AT_PUT_(st_perInstance, @symbol(ParentObjectTitleIndex), __mkSmallInteger(perfInstancePtr->ParentObjectTitleIndex));
 12285                 __AT_PUT_(st_perInstance, @symbol(ParentObjectInstance), __mkSmallInteger(perfInstancePtr->ParentObjectInstance));
 12305 		__AT_PUT_(st_perInstance, @symbol(ParentObjectInstance), __mkSmallInteger(perfInstancePtr->ParentObjectInstance));
 12286                 __AT_PUT_(st_perInstance, @symbol(NameOffset), __mkSmallInteger(perfInstancePtr->NameOffset));
 12306 		__AT_PUT_(st_perInstance, @symbol(NameOffset), __mkSmallInteger(perfInstancePtr->NameOffset));
 12287                 __AT_PUT_(st_perInstance, @symbol(NameLength), __mkSmallInteger(perfInstancePtr->NameLength));
 12307 		__AT_PUT_(st_perInstance, @symbol(NameLength), __mkSmallInteger(perfInstancePtr->NameLength));
 12288 
 12308 
 12289                 //setup the instance pointer to the its end
 12309 		//setup the instance pointer to the its end
 12290                 perfInstancePtr = (PERF_INSTANCE_DEFINITION *)((char *)perfInstancePtr + perfInstancePtr->ByteLength);
 12310 		perfInstancePtr = (PERF_INSTANCE_DEFINITION *)((char *)perfInstancePtr + perfInstancePtr->ByteLength);
 12291 
 12311 
 12292                 //setup the counter block pointer
 12312 		//setup the counter block pointer
 12293                 perfCounterBlockPtr = (PERF_COUNTER_BLOCK *)(perfInstancePtr);
 12313 		perfCounterBlockPtr = (PERF_COUNTER_BLOCK *)(perfInstancePtr);
 12294 
 12314 
 12295                 //get the instance raw data
 12315 		//get the instance raw data
 12296                 __AT_PUT_(st_perInstance, @symbol(RawData), __MKBYTEARRAY(perfCounterBlockPtr, perfCounterBlockPtr->ByteLength));
 12316 		__AT_PUT_(st_perInstance, @symbol(RawData), __MKBYTEARRAY(perfCounterBlockPtr, perfCounterBlockPtr->ByteLength));
 12297 
 12317 
 12298                 //setup the instance pointer to the next instance
 12318 		//setup the instance pointer to the next instance
 12299                 perfInstancePtr = (PERF_INSTANCE_DEFINITION *)((char *)perfCounterBlockPtr + perfCounterBlockPtr->ByteLength);
 12319 		perfInstancePtr = (PERF_INSTANCE_DEFINITION *)((char *)perfCounterBlockPtr + perfCounterBlockPtr->ByteLength);
 12300             }
 12320 	    }
 12301         }
 12321 	}
 12302 
 12322 
 12303         //setup the object pointer to the next object
 12323 	//setup the object pointer to the next object
 12304         perfObjectPtr = (PERF_OBJECT_TYPE *)((char *)perfObjectPtr + perfObjectPtr->TotalByteLength);
 12324 	perfObjectPtr = (PERF_OBJECT_TYPE *)((char *)perfObjectPtr + perfObjectPtr->TotalByteLength);
 12305     }
 12325     }
 12306 %}.
 12326 %}.
 12307     objectArray := st_objectArray.
 12327     objectArray := st_objectArray.
 12308     perfTime := st_perfTime.
 12328     perfTime := st_perfTime.
 12309     perfFreq := st_perfFreq.
 12329     perfFreq := st_perfFreq.
 12310     perfTime100nSec := st_perfTime100nSec.
 12330     perfTime100nSec := st_perfTime100nSec.
 12311 
 12331 
 12312     getNameBlock := [:i|
 12332     getNameBlock := [:i|
 12313         self class counterIndexTextDictionary at:i ifAbsent:['<<no name>>'].
 12333 	self class counterIndexTextDictionary at:i ifAbsent:['<<no name>>'].
 12314     ].
 12334     ].
 12315 
 12335 
 12316     getCounterValueBlock := [:counter :rawData|
 12336     getCounterValueBlock := [:counter :rawData|
 12317         |offset counterValue|
 12337 	|offset counterValue|
 12318 
 12338 
 12319         offset := counter at:#CounterOffset.
 12339 	offset := counter at:#CounterOffset.
 12320         offset >= rawData size ifTrue:[
 12340 	offset >= rawData size ifTrue:[
 12321             counterValue := nil.
 12341 	    counterValue := nil.
 12322         ] ifFalse:[
 12342 	] ifFalse:[
 12323             (counter at:#SIZE) == #LARGE ifTrue:[
 12343 	    (counter at:#SIZE) == #LARGE ifTrue:[
 12324                 counterValue := rawData unsignedLongLongAt:offset + 1 bigEndian:false.
 12344 		counterValue := rawData unsignedLongLongAt:offset + 1 bigEndian:false.
 12325             ] ifFalse:[
 12345 	    ] ifFalse:[
 12326                 (counter at:#SIZE) == #DWORD ifTrue:[
 12346 		(counter at:#SIZE) == #DWORD ifTrue:[
 12327                     counterValue := rawData unsignedLongAt:offset + 1 bigEndian:false.
 12347 		    counterValue := rawData unsignedLongAt:offset + 1 bigEndian:false.
 12328                 ] ifFalse:[
 12348 		] ifFalse:[
 12329                     self halt.
 12349 		    self halt.
 12330                 ].
 12350 		].
 12331             ].
 12351 	    ].
 12332         ].
 12352 	].
 12333 
 12353 
 12334         counterValue
 12354 	counterValue
 12335     ].
 12355     ].
 12336 
 12356 
 12337     objectArray do:[:anObject|
 12357     objectArray do:[:anObject|
 12338         "setup the object name"
 12358 	"setup the object name"
 12339         anObject at:#ObjectNameTitle put:(getNameBlock value:(anObject at:#ObjectNameTitleIndex)).
 12359 	anObject at:#ObjectNameTitle put:(getNameBlock value:(anObject at:#ObjectNameTitleIndex)).
 12340 
 12360 
 12341         "setup the name and a counter value array to each counter"
 12361 	"setup the name and a counter value array to each counter"
 12342         (anObject at:#Counters) do:[:aCounter|
 12362 	(anObject at:#Counters) do:[:aCounter|
 12343             aCounter at:#CounterNameTitle put:(getNameBlock value:(aCounter at:#CounterNameTitleIndex)).
 12363 	    aCounter at:#CounterNameTitle put:(getNameBlock value:(aCounter at:#CounterNameTitleIndex)).
 12344             aCounter at:#CounterValueArray put:OrderedCollection new.
 12364 	    aCounter at:#CounterValueArray put:OrderedCollection new.
 12345         ].
 12365 	].
 12346 
 12366 
 12347         (anObject at:#NumInstances) < 1 ifTrue:[
 12367 	(anObject at:#NumInstances) < 1 ifTrue:[
 12348             |rawData|
 12368 	    |rawData|
 12349 
 12369 
 12350             rawData := anObject at:#RawData.
 12370 	    rawData := anObject at:#RawData.
 12351 
 12371 
 12352             (anObject at:#Counters) do:[:aCounter|
 12372 	    (anObject at:#Counters) do:[:aCounter|
 12353                 (aCounter at:#CounterValueArray) add:(getCounterValueBlock value:aCounter value:rawData).
 12373 		(aCounter at:#CounterValueArray) add:(getCounterValueBlock value:aCounter value:rawData).
 12354             ].
 12374 	    ].
 12355         ] ifFalse:[
 12375 	] ifFalse:[
 12356             (anObject at:#Instances) do:[:anInstance|
 12376 	    (anObject at:#Instances) do:[:anInstance|
 12357                 |rawData|
 12377 		|rawData|
 12358 
 12378 
 12359                 rawData := anInstance at:#RawData.
 12379 		rawData := anInstance at:#RawData.
 12360 
 12380 
 12361                 anInstance at:#Name put:((Unicode16String fromBytes:(anInstance at:#Name) copy swapBytes) copyWithoutLast:1).
 12381 		anInstance at:#Name put:((Unicode16String fromBytes:(anInstance at:#Name) copy swapBytes) copyWithoutLast:1).
 12362 
 12382 
 12363                 (anObject at:#Counters) do:[:aCounter|
 12383 		(anObject at:#Counters) do:[:aCounter|
 12364                     (aCounter at:#CounterValueArray) add:(getCounterValueBlock value:aCounter value:rawData).
 12384 		    (aCounter at:#CounterValueArray) add:(getCounterValueBlock value:aCounter value:rawData).
 12365                 ].
 12385 		].
 12366             ].
 12386 	    ].
 12367         ].
 12387 	].
 12368     ].
 12388     ].
 12369 
 12389 
 12370     ^ self
 12390     ^ self
 12371 ! !
 12391 ! !
 12372 
 12392 
 12373 !Win32OperatingSystem::PerformanceData::Abstract methodsFor:'accessing'!
 12393 !Win32OperatingSystem::PerformanceData::Abstract methodsFor:'accessing'!
 12374 
 12394 
 12375 cachedResults
 12395 cachedResults
 12376 
 12396 
 12377     cachedResults isNil ifTrue:[
 12397     cachedResults isNil ifTrue:[
 12378         cachedResults := IdentityDictionary new.
 12398 	cachedResults := IdentityDictionary new.
 12379     ].
 12399     ].
 12380 
 12400 
 12381     ^ cachedResults
 12401     ^ cachedResults
 12382 !
 12402 !
 12383 
 12403 
 12400 !Win32OperatingSystem::PerformanceData::Abstract methodsFor:'definitions'!
 12420 !Win32OperatingSystem::PerformanceData::Abstract methodsFor:'definitions'!
 12401 
 12421 
 12402 aliveTime
 12422 aliveTime
 12403 
 12423 
 12404     "
 12424     "
 12405         returns the time a data stays alive, in milliseconds
 12425 	returns the time a data stays alive, in milliseconds
 12406         before we push a new call and overwrite the data
 12426 	before we push a new call and overwrite the data
 12407     "
 12427     "
 12408 
 12428 
 12409     ^ self subclassResponsibility
 12429     ^ self subclassResponsibility
 12410 !
 12430 !
 12411 
 12431 
 12424 !Win32OperatingSystem::PerformanceData::Abstract methodsFor:'private'!
 12444 !Win32OperatingSystem::PerformanceData::Abstract methodsFor:'private'!
 12425 
 12445 
 12426 data
 12446 data
 12427 
 12447 
 12428     self synchronized:[
 12448     self synchronized:[
 12429         |lastTS|
 12449 	|lastTS|
 12430 
 12450 
 12431         lastTS := self lastTimestamp.
 12451 	lastTS := self lastTimestamp.
 12432         lastTS isNil ifTrue:[
 12452 	lastTS isNil ifTrue:[
 12433             ^ self dataBasic
 12453 	    ^ self dataBasic
 12434         ] ifFalse:[
 12454 	] ifFalse:[
 12435             Timestamp now asMilliseconds - lastTS >= self aliveTime ifTrue:[
 12455 	    Timestamp now asMilliseconds - lastTS >= self aliveTime ifTrue:[
 12436                 ^ self dataBasic
 12456 		^ self dataBasic
 12437             ] ifFalse:[
 12457 	    ] ifFalse:[
 12438                 ^ self lastData
 12458 		^ self lastData
 12439             ].
 12459 	    ].
 12440         ].
 12460 	].
 12441     ].
 12461     ].
 12442 !
 12462 !
 12443 
 12463 
 12444 dataBasic
 12464 dataBasic
 12445     |regEntry|
 12465     |regEntry|
 12459     |data object debugBlock|
 12479     |data object debugBlock|
 12460 
 12480 
 12461     data := self data.
 12481     data := self data.
 12462 
 12482 
 12463     self indexedNameNumbered == 0 ifTrue:[
 12483     self indexedNameNumbered == 0 ifTrue:[
 12464         object := data objectArray at:1 ifAbsent:[debugBlock value:(object at:#ObjectNameTitle)].
 12484 	object := data objectArray at:1 ifAbsent:[debugBlock value:(object at:#ObjectNameTitle)].
 12465     ] ifFalse:[
 12485     ] ifFalse:[
 12466         object := data objectArray detect:[:el|(el at:#ObjectNameTitleIndex) == self indexedNameNumbered] ifNone:[self error:'counter not found'].
 12486 	object := data objectArray detect:[:el|(el at:#ObjectNameTitleIndex) == self indexedNameNumbered] ifNone:[self error:'counter not found'].
 12467     ].
 12487     ].
 12468 
 12488 
 12469     ^ (object at:#Counters) collect:[:el|Array with:(el at:#CounterNameTitle) with:(el at:#CounterNameTitleIndex)].
 12489     ^ (object at:#Counters) collect:[:el|Array with:(el at:#CounterNameTitle) with:(el at:#CounterNameTitleIndex)].
 12470 ! !
 12490 ! !
 12471 
 12491 
 12474 getPerSecondFromLast:aSelector
 12494 getPerSecondFromLast:aSelector
 12475     |cachedResult return|
 12495     |cachedResult return|
 12476 
 12496 
 12477     cachedResult := self cachedResults at:aSelector ifAbsent:nil.
 12497     cachedResult := self cachedResults at:aSelector ifAbsent:nil.
 12478     cachedResult notNil ifTrue:[
 12498     cachedResult notNil ifTrue:[
 12479         |currentResult|
 12499 	|currentResult|
 12480 
 12500 
 12481         currentResult := self perform:aSelector.
 12501 	currentResult := self perform:aSelector.
 12482         return := self getPerSecondViaResult1:cachedResult result2:currentResult.
 12502 	return := self getPerSecondViaResult1:cachedResult result2:currentResult.
 12483 
 12503 
 12484         self cachedResults at:aSelector put:currentResult.
 12504 	self cachedResults at:aSelector put:currentResult.
 12485     ] ifFalse:[
 12505     ] ifFalse:[
 12486         self cachedResults at:aSelector put:(self perform:aSelector).
 12506 	self cachedResults at:aSelector put:(self perform:aSelector).
 12487     ].
 12507     ].
 12488 
 12508 
 12489     ^ return
 12509     ^ return
 12490 !
 12510 !
 12491 
 12511 
 12505     values2 := result2 at:#values.
 12525     values2 := result2 at:#values.
 12506 
 12526 
 12507     globalResult := Dictionary new.
 12527     globalResult := Dictionary new.
 12508 
 12528 
 12509     values2 keysDo:[:key|
 12529     values2 keysDo:[:key|
 12510         |difference|
 12530 	|difference|
 12511 
 12531 
 12512         difference := (values2 at:key) - (values1 at:key).
 12532 	difference := (values2 at:key) - (values1 at:key).
 12513 
 12533 
 12514         runTimeInS = 0 ifTrue:[
 12534 	runTimeInS = 0 ifTrue:[
 12515             globalResult at:key put:0.
 12535 	    globalResult at:key put:0.
 12516         ] ifFalse:[
 12536 	] ifFalse:[
 12517             globalResult at:key put:(difference / runTimeInS) asFloat.
 12537 	    globalResult at:key put:(difference / runTimeInS) asFloat.
 12518         ].
 12538 	].
 12519     ].
 12539     ].
 12520 
 12540 
 12521     ^ globalResult
 12541     ^ globalResult
 12522 !
 12542 !
 12523 
 12543 
 12531     values2 := result2 at:#values.
 12551     values2 := result2 at:#values.
 12532 
 12552 
 12533     globalResult := Dictionary new.
 12553     globalResult := Dictionary new.
 12534 
 12554 
 12535     values2 keysDo:[:key|
 12555     values2 keysDo:[:key|
 12536         |difference|
 12556 	|difference|
 12537 
 12557 
 12538         difference := (values2 at:key) - (values1 at:key).
 12558 	difference := (values2 at:key) - (values1 at:key).
 12539 
 12559 
 12540         runTimeInS = 0 ifTrue:[
 12560 	runTimeInS = 0 ifTrue:[
 12541             globalResult at:key put:0.
 12561 	    globalResult at:key put:0.
 12542         ] ifFalse:[
 12562 	] ifFalse:[
 12543             globalResult at:key put:(difference / runTimeInS) asFloat.
 12563 	    globalResult at:key put:(difference / runTimeInS) asFloat.
 12544         ].
 12564 	].
 12545     ].
 12565     ].
 12546 
 12566 
 12547     ^ globalResult
 12567     ^ globalResult
 12548 !
 12568 !
 12549 
 12569 
 12550 getUsageFromLast:aSelector
 12570 getUsageFromLast:aSelector
 12551     |cachedResult return|
 12571     |cachedResult return|
 12552 
 12572 
 12553     cachedResult := self cachedResults at:aSelector ifAbsent:nil.
 12573     cachedResult := self cachedResults at:aSelector ifAbsent:nil.
 12554     cachedResult notNil ifTrue:[
 12574     cachedResult notNil ifTrue:[
 12555         |currentResult|
 12575 	|currentResult|
 12556 
 12576 
 12557         currentResult := self perform:aSelector.
 12577 	currentResult := self perform:aSelector.
 12558         return := self getUsageViaResult1:cachedResult result2:currentResult.
 12578 	return := self getUsageViaResult1:cachedResult result2:currentResult.
 12559 
 12579 
 12560         self cachedResults at:aSelector put:currentResult.
 12580 	self cachedResults at:aSelector put:currentResult.
 12561     ] ifFalse:[
 12581     ] ifFalse:[
 12562         self cachedResults at:aSelector put:(self perform:aSelector).
 12582 	self cachedResults at:aSelector put:(self perform:aSelector).
 12563     ].
 12583     ].
 12564 
 12584 
 12565     ^ return
 12585     ^ return
 12566 !
 12586 !
 12567 
 12587 
 12580 
 12600 
 12581     value1 := result1 at:#values.
 12601     value1 := result1 at:#values.
 12582     value2 := result2 at:#values.
 12602     value2 := result2 at:#values.
 12583 
 12603 
 12584     value1 keysDo:[:key|
 12604     value1 keysDo:[:key|
 12585         |diff dPerSecond load1024 res|
 12605 	|diff dPerSecond load1024 res|
 12586 
 12606 
 12587         diff := (value2 at:key) - (value1 at:key).
 12607 	diff := (value2 at:key) - (value1 at:key).
 12588         diff := diff bitShift:10.
 12608 	diff := diff bitShift:10.
 12589 
 12609 
 12590         deltaTIn100Ns = 0 ifTrue:[
 12610 	deltaTIn100Ns = 0 ifTrue:[
 12591             dPerSecond := 0.
 12611 	    dPerSecond := 0.
 12592         ] ifFalse:[
 12612 	] ifFalse:[
 12593             dPerSecond := (diff / deltaTIn100Ns) asFloat.
 12613 	    dPerSecond := (diff / deltaTIn100Ns) asFloat.
 12594         ].
 12614 	].
 12595         load1024 := 1024 - dPerSecond.
 12615 	load1024 := 1024 - dPerSecond.
 12596 
 12616 
 12597         res := (load1024 / 1024 * 100) asFloat.
 12617 	res := (load1024 / 1024 * 100) asFloat.
 12598         res < 0 ifTrue:[res := 0].
 12618 	res < 0 ifTrue:[res := 0].
 12599 
 12619 
 12600         globalResult at:key put:res.
 12620 	globalResult at:key put:res.
 12601     ].
 12621     ].
 12602 
 12622 
 12603     ^ globalResult
 12623     ^ globalResult
 12604 !
 12624 !
 12605 
 12625 
 12611 
 12631 
 12612     value1 := result1 at:#values.
 12632     value1 := result1 at:#values.
 12613     value2 := result2 at:#values.
 12633     value2 := result2 at:#values.
 12614 
 12634 
 12615     value1 keysDo:[:key|
 12635     value1 keysDo:[:key|
 12616         |diff dPerSecond load1024 res|
 12636 	|diff dPerSecond load1024 res|
 12617 
 12637 
 12618         diff := (value2 at:key) - (value1 at:key).
 12638 	diff := (value2 at:key) - (value1 at:key).
 12619         diff := diff bitShift:10.
 12639 	diff := diff bitShift:10.
 12620 
 12640 
 12621         deltaTIn100Ns = 0 ifTrue:[
 12641 	deltaTIn100Ns = 0 ifTrue:[
 12622             dPerSecond := 0.
 12642 	    dPerSecond := 0.
 12623         ] ifFalse:[
 12643 	] ifFalse:[
 12624             dPerSecond := (diff / deltaTIn100Ns) asFloat.
 12644 	    dPerSecond := (diff / deltaTIn100Ns) asFloat.
 12625         ].
 12645 	].
 12626         load1024 := 1024 - dPerSecond.
 12646 	load1024 := 1024 - dPerSecond.
 12627 
 12647 
 12628         res := (load1024 / 1024 * 100) asFloat.
 12648 	res := (load1024 / 1024 * 100) asFloat.
 12629         res < 0 ifTrue:[res := 0].
 12649 	res < 0 ifTrue:[res := 0].
 12630 
 12650 
 12631         globalResult at:key put:res.
 12651 	globalResult at:key put:res.
 12632     ].
 12652     ].
 12633 
 12653 
 12634     ^ globalResult
 12654     ^ globalResult
 12635 ! !
 12655 ! !
 12636 
 12656 
 12650 
 12670 
 12651 getBasicValuesByObject:objectIndex counter:counterIndex timed:boolean
 12671 getBasicValuesByObject:objectIndex counter:counterIndex timed:boolean
 12652     |data object counter values debugBlock numInstances|
 12672     |data object counter values debugBlock numInstances|
 12653 
 12673 
 12654     debugBlock := [:obj|
 12674     debugBlock := [:obj|
 12655         ^ 'obj:', obj , ' this:', self printString , ' idx:', self indexedName
 12675 	^ 'obj:', obj , ' this:', self printString , ' idx:', self indexedName
 12656     ].
 12676     ].
 12657 
 12677 
 12658     data := self dataBasic.
 12678     data := self dataBasic.
 12659 
 12679 
 12660     objectIndex == 0 ifTrue:[
 12680     objectIndex == 0 ifTrue:[
 12661         object := data objectArray at:1 ifAbsent:[debugBlock value:(object at:#ObjectNameTitle)].
 12681 	object := data objectArray at:1 ifAbsent:[debugBlock value:(object at:#ObjectNameTitle)].
 12662     ] ifFalse:[
 12682     ] ifFalse:[
 12663         object := data objectArray detect:[:el|(el at:#ObjectNameTitleIndex) == objectIndex] ifNone:[debugBlock value:(object at:#ObjectNameTitle)].
 12683 	object := data objectArray detect:[:el|(el at:#ObjectNameTitleIndex) == objectIndex] ifNone:[debugBlock value:(object at:#ObjectNameTitle)].
 12664     ].
 12684     ].
 12665 
 12685 
 12666     counter := (object at:#Counters) detect:[:aCounter|(aCounter at:#CounterNameTitleIndex) == counterIndex] ifNone:[debugBlock value:(object at:#ObjectNameTitle)].
 12686     counter := (object at:#Counters) detect:[:aCounter|(aCounter at:#CounterNameTitleIndex) == counterIndex] ifNone:[debugBlock value:(object at:#ObjectNameTitle)].
 12667 
 12687 
 12668     values := Dictionary new.
 12688     values := Dictionary new.
 12669     numInstances := object at:#NumInstances.
 12689     numInstances := object at:#NumInstances.
 12670 
 12690 
 12671     numInstances > 0 ifTrue:[
 12691     numInstances > 0 ifTrue:[
 12672         1 to:numInstances do:[:idx|
 12692 	1 to:numInstances do:[:idx|
 12673             |value instanceName|
 12693 	    |value instanceName|
 12674 
 12694 
 12675             value := (counter at:#CounterValueArray) at:idx.
 12695 	    value := (counter at:#CounterValueArray) at:idx.
 12676             instanceName := ((object at:#Instances) at:idx) at:#Name.
 12696 	    instanceName := ((object at:#Instances) at:idx) at:#Name.
 12677 
 12697 
 12678             values at:instanceName put:value.
 12698 	    values at:instanceName put:value.
 12679         ].
 12699 	].
 12680     ] ifFalse:[
 12700     ] ifFalse:[
 12681         values at:'<<singleton>>' put:(counter at:#CounterValueArray) first.
 12701 	values at:'<<singleton>>' put:(counter at:#CounterValueArray) first.
 12682     ].
 12702     ].
 12683 
 12703 
 12684     boolean ifTrue:[
 12704     boolean ifTrue:[
 12685         |return|
 12705 	|return|
 12686 
 12706 
 12687         return := IdentityDictionary new.
 12707 	return := IdentityDictionary new.
 12688         return at:#time put:data perfTime.
 12708 	return at:#time put:data perfTime.
 12689         return at:#frequence put:data perfFreq.
 12709 	return at:#frequence put:data perfFreq.
 12690         return at:#time100nSec put:data perfTime100nSec.
 12710 	return at:#time100nSec put:data perfTime100nSec.
 12691         return at:#values put:values.
 12711 	return at:#values put:values.
 12692 
 12712 
 12693         ^ return
 12713 	^ return
 12694     ].
 12714     ].
 12695 
 12715 
 12696     ^ values
 12716     ^ values
 12697 !
 12717 !
 12698 
 12718 
 12710 
 12730 
 12711 getValuesByObject:objectIndex counter:counterIndex timed:boolean
 12731 getValuesByObject:objectIndex counter:counterIndex timed:boolean
 12712     |data object counter values debugBlock numInstances|
 12732     |data object counter values debugBlock numInstances|
 12713 
 12733 
 12714     debugBlock := [:obj|
 12734     debugBlock := [:obj|
 12715         ^ 'obj:', obj , ' this:', self printString , ' idx:', self indexedName
 12735 	^ 'obj:', obj , ' this:', self printString , ' idx:', self indexedName
 12716     ].
 12736     ].
 12717 
 12737 
 12718     data := self data.
 12738     data := self data.
 12719 
 12739 
 12720     objectIndex == 0 ifTrue:[
 12740     objectIndex == 0 ifTrue:[
 12721         object := data objectArray at:1 ifAbsent:[debugBlock value:(object at:#ObjectNameTitle)].
 12741 	object := data objectArray at:1 ifAbsent:[debugBlock value:(object at:#ObjectNameTitle)].
 12722     ] ifFalse:[
 12742     ] ifFalse:[
 12723         object := data objectArray detect:[:el|(el at:#ObjectNameTitleIndex) == objectIndex] ifNone:[debugBlock value:(object at:#ObjectNameTitle)].
 12743 	object := data objectArray detect:[:el|(el at:#ObjectNameTitleIndex) == objectIndex] ifNone:[debugBlock value:(object at:#ObjectNameTitle)].
 12724     ].
 12744     ].
 12725 
 12745 
 12726     counter := (object at:#Counters) detect:[:aCounter|(aCounter at:#CounterNameTitleIndex) == counterIndex] ifNone:[debugBlock value:(object at:#ObjectNameTitle)].
 12746     counter := (object at:#Counters) detect:[:aCounter|(aCounter at:#CounterNameTitleIndex) == counterIndex] ifNone:[debugBlock value:(object at:#ObjectNameTitle)].
 12727 
 12747 
 12728     values := Dictionary new.
 12748     values := Dictionary new.
 12729     numInstances := object at:#NumInstances.
 12749     numInstances := object at:#NumInstances.
 12730 
 12750 
 12731     numInstances > 0 ifTrue:[
 12751     numInstances > 0 ifTrue:[
 12732         1 to:numInstances do:[:idx|
 12752 	1 to:numInstances do:[:idx|
 12733             |value instanceName|
 12753 	    |value instanceName|
 12734 
 12754 
 12735             value := (counter at:#CounterValueArray) at:idx.
 12755 	    value := (counter at:#CounterValueArray) at:idx.
 12736             instanceName := ((object at:#Instances) at:idx) at:#Name.
 12756 	    instanceName := ((object at:#Instances) at:idx) at:#Name.
 12737 
 12757 
 12738             values at:instanceName put:value.
 12758 	    values at:instanceName put:value.
 12739         ].
 12759 	].
 12740     ] ifFalse:[
 12760     ] ifFalse:[
 12741         values at:'<<singleton>>' put:(counter at:#CounterValueArray) first.
 12761 	values at:'<<singleton>>' put:(counter at:#CounterValueArray) first.
 12742     ].
 12762     ].
 12743 
 12763 
 12744     boolean ifTrue:[
 12764     boolean ifTrue:[
 12745         |return|
 12765 	|return|
 12746 
 12766 
 12747         return := IdentityDictionary new.
 12767 	return := IdentityDictionary new.
 12748         return at:#time put:data perfTime.
 12768 	return at:#time put:data perfTime.
 12749         return at:#frequence put:data perfFreq.
 12769 	return at:#frequence put:data perfFreq.
 12750         return at:#time100nSec put:data perfTime100nSec.
 12770 	return at:#time100nSec put:data perfTime100nSec.
 12751         return at:#values put:values.
 12771 	return at:#values put:values.
 12752 
 12772 
 12753         ^ return
 12773 	^ return
 12754     ].
 12774     ].
 12755 
 12775 
 12756     ^ values
 12776     ^ values
 12757 ! !
 12777 ! !
 12758 
 12778 
 12759 !Win32OperatingSystem::PerformanceData::DiskIO class methodsFor:'accessing'!
 12779 !Win32OperatingSystem::PerformanceData::DiskIO class methodsFor:'accessing'!
 12760 
 12780 
 12761 current
 12781 current
 12762 
 12782 
 12763     TheOneAndOnlyInstance isNil ifTrue:[
 12783     TheOneAndOnlyInstance isNil ifTrue:[
 12764         TheOneAndOnlyInstance := self new.
 12784 	TheOneAndOnlyInstance := self new.
 12765     ].
 12785     ].
 12766 
 12786 
 12767     ^ TheOneAndOnlyInstance
 12787     ^ TheOneAndOnlyInstance
 12768 ! !
 12788 ! !
 12769 
 12789 
 12781 
 12801 
 12782 diskBytes
 12802 diskBytes
 12783     ^ self getValuesByCounter:218 timed:true
 12803     ^ self getValuesByCounter:218 timed:true
 12784 
 12804 
 12785     "
 12805     "
 12786         self current diskBytes
 12806 	self current diskBytes
 12787     "
 12807     "
 12788 !
 12808 !
 12789 
 12809 
 12790 diskBytesBasic
 12810 diskBytesBasic
 12791     ^ self getBasicValuesByCounter:218 timed:true
 12811     ^ self getBasicValuesByCounter:218 timed:true
 12792 
 12812 
 12793     "
 12813     "
 12794         self current diskBytesBasic
 12814 	self current diskBytesBasic
 12795     "
 12815     "
 12796 !
 12816 !
 12797 
 12817 
 12798 diskBytesPerSecond
 12818 diskBytesPerSecond
 12799     ^ self getPerSecondViaPerformBlock:[self diskBytes]
 12819     ^ self getPerSecondViaPerformBlock:[self diskBytes]
 12800 
 12820 
 12801     "
 12821     "
 12802         self current diskBytesPerSecond
 12822 	self current diskBytesPerSecond
 12803     "
 12823     "
 12804 !
 12824 !
 12805 
 12825 
 12806 diskBytesPerSecondFromLast
 12826 diskBytesPerSecondFromLast
 12807     ^ self getPerSecondFromLast:#diskBytesBasic
 12827     ^ self getPerSecondFromLast:#diskBytesBasic
 12808 
 12828 
 12809     "
 12829     "
 12810         self current diskBytesPerSecondFromLast
 12830 	self current diskBytesPerSecondFromLast
 12811     "
 12831     "
 12812 !
 12832 !
 12813 
 12833 
 12814 diskQueueLength
 12834 diskQueueLength
 12815     ^ self getValuesByCounter:198
 12835     ^ self getValuesByCounter:198
 12816 
 12836 
 12817     "
 12837     "
 12818         self current diskQueueLength
 12838 	self current diskQueueLength
 12819     "
 12839     "
 12820 !
 12840 !
 12821 
 12841 
 12822 diskRead
 12842 diskRead
 12823     ^ self getValuesByCounter:214 timed:true
 12843     ^ self getValuesByCounter:214 timed:true
 12824 
 12844 
 12825     "
 12845     "
 12826         self current diskRead
 12846 	self current diskRead
 12827     "
 12847     "
 12828 !
 12848 !
 12829 
 12849 
 12830 diskReadBasic
 12850 diskReadBasic
 12831     ^ self getBasicValuesByCounter:214 timed:true
 12851     ^ self getBasicValuesByCounter:214 timed:true
 12832 
 12852 
 12833     "
 12853     "
 12834         self current diskReadBasic
 12854 	self current diskReadBasic
 12835     "
 12855     "
 12836 !
 12856 !
 12837 
 12857 
 12838 diskReadsPerSecond
 12858 diskReadsPerSecond
 12839     ^ self getPerSecondViaPerformBlock:[self diskRead]
 12859     ^ self getPerSecondViaPerformBlock:[self diskRead]
 12840 
 12860 
 12841     "
 12861     "
 12842         self current diskReadsPerSecond
 12862 	self current diskReadsPerSecond
 12843     "
 12863     "
 12844 !
 12864 !
 12845 
 12865 
 12846 diskReadsPerSecondFromLast
 12866 diskReadsPerSecondFromLast
 12847     ^ self getPerSecondFromLast:#diskReadBasic
 12867     ^ self getPerSecondFromLast:#diskReadBasic
 12848 
 12868 
 12849     "
 12869     "
 12850         self current diskReadsPerSecondFromLast
 12870 	self current diskReadsPerSecondFromLast
 12851     "
 12871     "
 12852 !
 12872 !
 12853 
 12873 
 12854 diskSpaceFreeInMegaByte
 12874 diskSpaceFreeInMegaByte
 12855     ^ self getValuesByCounter:408
 12875     ^ self getValuesByCounter:408
 12856 
 12876 
 12857     "
 12877     "
 12858         self current diskSpaceFreeInMegaByte
 12878 	self current diskSpaceFreeInMegaByte
 12859     "
 12879     "
 12860 !
 12880 !
 12861 
 12881 
 12862 diskTransfers
 12882 diskTransfers
 12863     ^ self getValuesByCounter:212 timed:true
 12883     ^ self getValuesByCounter:212 timed:true
 12864 
 12884 
 12865     "
 12885     "
 12866         self current diskTransfers
 12886 	self current diskTransfers
 12867     "
 12887     "
 12868 !
 12888 !
 12869 
 12889 
 12870 diskTransfersBasic
 12890 diskTransfersBasic
 12871     ^ self getBasicValuesByCounter:212 timed:true
 12891     ^ self getBasicValuesByCounter:212 timed:true
 12872 
 12892 
 12873     "
 12893     "
 12874         self current diskTransfersBasic
 12894 	self current diskTransfersBasic
 12875     "
 12895     "
 12876 !
 12896 !
 12877 
 12897 
 12878 diskTransfersPerSecond
 12898 diskTransfersPerSecond
 12879     ^ self getPerSecondViaPerformBlock:[self diskTransfers]
 12899     ^ self getPerSecondViaPerformBlock:[self diskTransfers]
 12880 
 12900 
 12881     "
 12901     "
 12882         self current diskTransfersPerSecond
 12902 	self current diskTransfersPerSecond
 12883     "
 12903     "
 12884 !
 12904 !
 12885 
 12905 
 12886 diskTransfersPerSecondFromLast
 12906 diskTransfersPerSecondFromLast
 12887     ^ self getPerSecondFromLast:#diskTransfersBasic
 12907     ^ self getPerSecondFromLast:#diskTransfersBasic
 12888 
 12908 
 12889     "
 12909     "
 12890         self current diskTransfersPerSecondFromlast
 12910 	self current diskTransfersPerSecondFromlast
 12891     "
 12911     "
 12892 !
 12912 !
 12893 
 12913 
 12894 diskWrite
 12914 diskWrite
 12895     ^ self getValuesByCounter:216 timed:true
 12915     ^ self getValuesByCounter:216 timed:true
 12896 
 12916 
 12897     "
 12917     "
 12898         self current diskWrite
 12918 	self current diskWrite
 12899     "
 12919     "
 12900 !
 12920 !
 12901 
 12921 
 12902 diskWriteBasic
 12922 diskWriteBasic
 12903     ^ self getBasicValuesByCounter:216 timed:true
 12923     ^ self getBasicValuesByCounter:216 timed:true
 12904 
 12924 
 12905     "
 12925     "
 12906         self current diskWriteBasic
 12926 	self current diskWriteBasic
 12907     "
 12927     "
 12908 !
 12928 !
 12909 
 12929 
 12910 diskWritesPerSecond
 12930 diskWritesPerSecond
 12911     ^ self getPerSecondViaPerformBlock:[self diskWrite]
 12931     ^ self getPerSecondViaPerformBlock:[self diskWrite]
 12912 
 12932 
 12913     "
 12933     "
 12914         self current diskWritesPerSecond
 12934 	self current diskWritesPerSecond
 12915     "
 12935     "
 12916 !
 12936 !
 12917 
 12937 
 12918 diskWritesPerSecondFromLast
 12938 diskWritesPerSecondFromLast
 12919     ^ self getPerSecondFromLast:#diskWriteBasic
 12939     ^ self getPerSecondFromLast:#diskWriteBasic
 12920 
 12940 
 12921     "
 12941     "
 12922         self current diskWritesPerSecondFromLast
 12942 	self current diskWritesPerSecondFromLast
 12923     "
 12943     "
 12924 ! !
 12944 ! !
 12925 
 12945 
 12926 !Win32OperatingSystem::PerformanceData::Global class methodsFor:'accessing'!
 12946 !Win32OperatingSystem::PerformanceData::Global class methodsFor:'accessing'!
 12927 
 12947 
 12928 current
 12948 current
 12929 
 12949 
 12930     TheOneAndOnlyInstance isNil ifTrue:[
 12950     TheOneAndOnlyInstance isNil ifTrue:[
 12931         TheOneAndOnlyInstance := self new.
 12951 	TheOneAndOnlyInstance := self new.
 12932     ].
 12952     ].
 12933 
 12953 
 12934     ^ TheOneAndOnlyInstance
 12954     ^ TheOneAndOnlyInstance
 12935 ! !
 12955 ! !
 12936 
 12956 
 12955 
 12975 
 12956     data := self data.
 12976     data := self data.
 12957     indexNameArray := OrderedCollection new.
 12977     indexNameArray := OrderedCollection new.
 12958 
 12978 
 12959     data objectArray do:[:anObject|
 12979     data objectArray do:[:anObject|
 12960         |index name|
 12980 	|index name|
 12961 
 12981 
 12962         index := anObject at:#ObjectNameTitleIndex.
 12982 	index := anObject at:#ObjectNameTitleIndex.
 12963         name := Win32OperatingSystem::PerformanceData counterIndexTextDictionary at:index.
 12983 	name := Win32OperatingSystem::PerformanceData counterIndexTextDictionary at:index.
 12964 
 12984 
 12965         indexNameArray add:(Array with:name with:index).
 12985 	indexNameArray add:(Array with:name with:index).
 12966     ].
 12986     ].
 12967 
 12987 
 12968     ^ indexNameArray
 12988     ^ indexNameArray
 12969 ! !
 12989 ! !
 12970 
 12990 
 12971 !Win32OperatingSystem::PerformanceData::Memory class methodsFor:'accessing'!
 12991 !Win32OperatingSystem::PerformanceData::Memory class methodsFor:'accessing'!
 12972 
 12992 
 12973 current
 12993 current
 12974 
 12994 
 12975     TheOneAndOnlyInstance isNil ifTrue:[
 12995     TheOneAndOnlyInstance isNil ifTrue:[
 12976         TheOneAndOnlyInstance := self new.
 12996 	TheOneAndOnlyInstance := self new.
 12977     ].
 12997     ].
 12978 
 12998 
 12979     ^ TheOneAndOnlyInstance
 12999     ^ TheOneAndOnlyInstance
 12980 ! !
 13000 ! !
 12981 
 13001 
 12993 
 13013 
 12994 availableKBytes
 13014 availableKBytes
 12995     ^ self getValuesByCounter:1380
 13015     ^ self getValuesByCounter:1380
 12996 
 13016 
 12997     "
 13017     "
 12998         self current availableKBytes
 13018 	self current availableKBytes
 12999     "
 13019     "
 13000 !
 13020 !
 13001 
 13021 
 13002 availableMBytes
 13022 availableMBytes
 13003     ^ self getValuesByCounter:1382
 13023     ^ self getValuesByCounter:1382
 13004 
 13024 
 13005     "
 13025     "
 13006         self current availableMBytes
 13026 	self current availableMBytes
 13007     "
 13027     "
 13008 ! !
 13028 ! !
 13009 
 13029 
 13010 !Win32OperatingSystem::PerformanceData::Network class methodsFor:'accessing'!
 13030 !Win32OperatingSystem::PerformanceData::Network class methodsFor:'accessing'!
 13011 
 13031 
 13012 current
 13032 current
 13013 
 13033 
 13014     TheOneAndOnlyInstance isNil ifTrue:[
 13034     TheOneAndOnlyInstance isNil ifTrue:[
 13015         TheOneAndOnlyInstance := self new.
 13035 	TheOneAndOnlyInstance := self new.
 13016     ].
 13036     ].
 13017 
 13037 
 13018     ^ TheOneAndOnlyInstance
 13038     ^ TheOneAndOnlyInstance
 13019 ! !
 13039 ! !
 13020 
 13040 
 13036 
 13056 
 13037 bytesReceived
 13057 bytesReceived
 13038     ^ self getValuesByCounter:264 timed:true
 13058     ^ self getValuesByCounter:264 timed:true
 13039 
 13059 
 13040     "
 13060     "
 13041         self current bytesReceived
 13061 	self current bytesReceived
 13042     "
 13062     "
 13043 !
 13063 !
 13044 
 13064 
 13045 bytesReceivedBasic
 13065 bytesReceivedBasic
 13046     ^ self getBasicValuesByCounter:264 timed:true
 13066     ^ self getBasicValuesByCounter:264 timed:true
 13047 
 13067 
 13048     "
 13068     "
 13049         self current bytesReceivedBasic
 13069 	self current bytesReceivedBasic
 13050     "
 13070     "
 13051 !
 13071 !
 13052 
 13072 
 13053 bytesReceivedPerSecond
 13073 bytesReceivedPerSecond
 13054     ^ self getPerSecondViaPerformBlock:[self bytesReceived]
 13074     ^ self getPerSecondViaPerformBlock:[self bytesReceived]
 13055 
 13075 
 13056     "
 13076     "
 13057         self current bytesReceivedPerSecond
 13077 	self current bytesReceivedPerSecond
 13058     "
 13078     "
 13059 !
 13079 !
 13060 
 13080 
 13061 bytesReceivedPerSecondFromlast
 13081 bytesReceivedPerSecondFromlast
 13062     ^ self getPerSecondFromLast:#bytesReceivedBasic
 13082     ^ self getPerSecondFromLast:#bytesReceivedBasic
 13063 
 13083 
 13064     "
 13084     "
 13065         self current bytesReceivedPerSecondFromlast
 13085 	self current bytesReceivedPerSecondFromlast
 13066     "
 13086     "
 13067 !
 13087 !
 13068 
 13088 
 13069 bytesSent
 13089 bytesSent
 13070     ^ self getValuesByCounter:506 timed:true
 13090     ^ self getValuesByCounter:506 timed:true
 13071 
 13091 
 13072     "
 13092     "
 13073         self current bytesSent
 13093 	self current bytesSent
 13074     "
 13094     "
 13075 !
 13095 !
 13076 
 13096 
 13077 bytesSentBasic
 13097 bytesSentBasic
 13078     ^ self getBasicValuesByCounter:506 timed:true
 13098     ^ self getBasicValuesByCounter:506 timed:true
 13079 
 13099 
 13080     "
 13100     "
 13081         self current bytesSentBasic
 13101 	self current bytesSentBasic
 13082     "
 13102     "
 13083 !
 13103 !
 13084 
 13104 
 13085 bytesSentPerSecond
 13105 bytesSentPerSecond
 13086     ^ self getPerSecondViaPerformBlock:[self bytesSent]
 13106     ^ self getPerSecondViaPerformBlock:[self bytesSent]
 13087 
 13107 
 13088     "
 13108     "
 13089         self current bytesSentPerSecond
 13109 	self current bytesSentPerSecond
 13090     "
 13110     "
 13091 !
 13111 !
 13092 
 13112 
 13093 bytesSentPerSecondFromlast
 13113 bytesSentPerSecondFromlast
 13094     ^ self getPerSecondFromLast:#bytesSentBasic
 13114     ^ self getPerSecondFromLast:#bytesSentBasic
 13095 
 13115 
 13096     "
 13116     "
 13097         self current bytesSentPerSecondFromlast
 13117 	self current bytesSentPerSecondFromlast
 13098     "
 13118     "
 13099 !
 13119 !
 13100 
 13120 
 13101 kBytesReceivedPerSecond
 13121 kBytesReceivedPerSecond
 13102     |modifiedDictionary|
 13122     |modifiedDictionary|
 13103 
 13123 
 13104     modifiedDictionary := Dictionary new.
 13124     modifiedDictionary := Dictionary new.
 13105 
 13125 
 13106     (self getPerSecondViaPerformBlock:[self bytesReceived]) keysAndValuesDo:[:key :value|
 13126     (self getPerSecondViaPerformBlock:[self bytesReceived]) keysAndValuesDo:[:key :value|
 13107         modifiedDictionary at:key put:(value / 1024).
 13127 	modifiedDictionary at:key put:(value / 1024).
 13108     ].
 13128     ].
 13109 
 13129 
 13110     ^ modifiedDictionary
 13130     ^ modifiedDictionary
 13111 
 13131 
 13112     "
 13132     "
 13113         self current kBytesReceivedPerSecond
 13133 	self current kBytesReceivedPerSecond
 13114     "
 13134     "
 13115 !
 13135 !
 13116 
 13136 
 13117 kBytesReceivedPerSecondFromLast
 13137 kBytesReceivedPerSecondFromLast
 13118     |return modifiedDictionary|
 13138     |return modifiedDictionary|
 13121     return isNil ifTrue:[^ nil].
 13141     return isNil ifTrue:[^ nil].
 13122 
 13142 
 13123     modifiedDictionary := Dictionary new.
 13143     modifiedDictionary := Dictionary new.
 13124 
 13144 
 13125     return keysAndValuesDo:[:key :value|
 13145     return keysAndValuesDo:[:key :value|
 13126         modifiedDictionary at:key put:(value / 1024).
 13146 	modifiedDictionary at:key put:(value / 1024).
 13127     ].
 13147     ].
 13128 
 13148 
 13129     ^ modifiedDictionary
 13149     ^ modifiedDictionary
 13130 
 13150 
 13131     "
 13151     "
 13132         self current kBytesReceivedPerSecondFromLast
 13152 	self current kBytesReceivedPerSecondFromLast
 13133     "
 13153     "
 13134 !
 13154 !
 13135 
 13155 
 13136 kBytesSentPerSecond
 13156 kBytesSentPerSecond
 13137     |modifiedDictionary|
 13157     |modifiedDictionary|
 13138 
 13158 
 13139     modifiedDictionary := Dictionary new.
 13159     modifiedDictionary := Dictionary new.
 13140 
 13160 
 13141     (self getPerSecondViaPerformBlock:[self bytesSent]) keysAndValuesDo:[:key :value|
 13161     (self getPerSecondViaPerformBlock:[self bytesSent]) keysAndValuesDo:[:key :value|
 13142         modifiedDictionary at:key put:(value / 1024).
 13162 	modifiedDictionary at:key put:(value / 1024).
 13143     ].
 13163     ].
 13144 
 13164 
 13145     ^ modifiedDictionary
 13165     ^ modifiedDictionary
 13146 
 13166 
 13147     "
 13167     "
 13148         self current kBytesSentPerSecond
 13168 	self current kBytesSentPerSecond
 13149     "
 13169     "
 13150 !
 13170 !
 13151 
 13171 
 13152 kBytesSentPerSecondFromLast
 13172 kBytesSentPerSecondFromLast
 13153     |return modifiedDictionary|
 13173     |return modifiedDictionary|
 13156     return isNil ifTrue:[^ nil].
 13176     return isNil ifTrue:[^ nil].
 13157 
 13177 
 13158     modifiedDictionary := Dictionary new.
 13178     modifiedDictionary := Dictionary new.
 13159 
 13179 
 13160     return keysAndValuesDo:[:key :value|
 13180     return keysAndValuesDo:[:key :value|
 13161         modifiedDictionary at:key put:(value / 1024).
 13181 	modifiedDictionary at:key put:(value / 1024).
 13162     ].
 13182     ].
 13163 
 13183 
 13164     ^ modifiedDictionary
 13184     ^ modifiedDictionary
 13165 
 13185 
 13166     "
 13186     "
 13167         self current kBytesSentPerSecondFromLast
 13187 	self current kBytesSentPerSecondFromLast
 13168     "
 13188     "
 13169 ! !
 13189 ! !
 13170 
 13190 
 13171 !Win32OperatingSystem::PerformanceData::Process class methodsFor:'accessing'!
 13191 !Win32OperatingSystem::PerformanceData::Process class methodsFor:'accessing'!
 13172 
 13192 
 13173 current
 13193 current
 13174 
 13194 
 13175     TheOneAndOnlyInstance isNil ifTrue:[
 13195     TheOneAndOnlyInstance isNil ifTrue:[
 13176         TheOneAndOnlyInstance := self new.
 13196 	TheOneAndOnlyInstance := self new.
 13177     ].
 13197     ].
 13178 
 13198 
 13179     ^ TheOneAndOnlyInstance
 13199     ^ TheOneAndOnlyInstance
 13180 ! !
 13200 ! !
 13181 
 13201 
 13193 
 13213 
 13194 processTime
 13214 processTime
 13195     ^ self getValuesByCounter:6 timed:true
 13215     ^ self getValuesByCounter:6 timed:true
 13196 
 13216 
 13197     "
 13217     "
 13198         self current processTime
 13218 	self current processTime
 13199     "
 13219     "
 13200 !
 13220 !
 13201 
 13221 
 13202 processTimeBasic
 13222 processTimeBasic
 13203     ^ self getBasicValuesByCounter:6 timed:true
 13223     ^ self getBasicValuesByCounter:6 timed:true
 13204 
 13224 
 13205     "
 13225     "
 13206         self current processTimeBasic
 13226 	self current processTimeBasic
 13207     "
 13227     "
 13208 !
 13228 !
 13209 
 13229 
 13210 processUsage
 13230 processUsage
 13211     |modifiedDictionary|
 13231     |modifiedDictionary|
 13212 
 13232 
 13213     modifiedDictionary := Dictionary new.
 13233     modifiedDictionary := Dictionary new.
 13214 
 13234 
 13215     (self getUsageViaPerformBlock:[self processTime]) keysAndValuesDo:[:key :value|
 13235     (self getUsageViaPerformBlock:[self processTime]) keysAndValuesDo:[:key :value|
 13216         modifiedDictionary at:key put:(100 - value).
 13236 	modifiedDictionary at:key put:(100 - value).
 13217     ].
 13237     ].
 13218 
 13238 
 13219     ^ modifiedDictionary
 13239     ^ modifiedDictionary
 13220 
 13240 
 13221     "
 13241     "
 13222         self current processUsage
 13242 	self current processUsage
 13223     "
 13243     "
 13224 !
 13244 !
 13225 
 13245 
 13226 processUsageFromLast
 13246 processUsageFromLast
 13227     |return modifiedDictionary|
 13247     |return modifiedDictionary|
 13230     return isNil ifTrue:[^ nil].
 13250     return isNil ifTrue:[^ nil].
 13231 
 13251 
 13232     modifiedDictionary := Dictionary new.
 13252     modifiedDictionary := Dictionary new.
 13233 
 13253 
 13234     return keysAndValuesDo:[:key :value|
 13254     return keysAndValuesDo:[:key :value|
 13235         modifiedDictionary at:key put:(100 - value).
 13255 	modifiedDictionary at:key put:(100 - value).
 13236     ].
 13256     ].
 13237 
 13257 
 13238     ^ modifiedDictionary
 13258     ^ modifiedDictionary
 13239 
 13259 
 13240     "
 13260     "
 13241         self current processUsageFromLast
 13261 	self current processUsageFromLast
 13242     "
 13262     "
 13243 !
 13263 !
 13244 
 13264 
 13245 runningProcessNameList
 13265 runningProcessNameList
 13246     "_Total ~ pseudo process; Idle ~ pseudo process represents the free resources"
 13266     "_Total ~ pseudo process; Idle ~ pseudo process represents the free resources"
 13247     ^ (self data objectArray first at:#Instances) collect:[:el|el at:#Name]
 13267     ^ (self data objectArray first at:#Instances) collect:[:el|el at:#Name]
 13248 
 13268 
 13249     "
 13269     "
 13250         self current runningProcessNameList
 13270 	self current runningProcessNameList
 13251     "
 13271     "
 13252 !
 13272 !
 13253 
 13273 
 13254 runningProcesses
 13274 runningProcesses
 13255     "_Total ~ pseudo process; Idle ~ pseudo process represents the free resources"
 13275     "_Total ~ pseudo process; Idle ~ pseudo process represents the free resources"
 13256     ^ (self data objectArray first at:#NumInstances)
 13276     ^ (self data objectArray first at:#NumInstances)
 13257 
 13277 
 13258     "
 13278     "
 13259         self current runningProcesses
 13279 	self current runningProcesses
 13260     "
 13280     "
 13261 ! !
 13281 ! !
 13262 
 13282 
 13263 !Win32OperatingSystem::PerformanceData::Processor class methodsFor:'accessing'!
 13283 !Win32OperatingSystem::PerformanceData::Processor class methodsFor:'accessing'!
 13264 
 13284 
 13265 current
 13285 current
 13266 
 13286 
 13267     TheOneAndOnlyInstance isNil ifTrue:[
 13287     TheOneAndOnlyInstance isNil ifTrue:[
 13268         TheOneAndOnlyInstance := self new.
 13288 	TheOneAndOnlyInstance := self new.
 13269     ].
 13289     ].
 13270 
 13290 
 13271     ^ TheOneAndOnlyInstance
 13291     ^ TheOneAndOnlyInstance
 13272 ! !
 13292 ! !
 13273 
 13293 
 13285 
 13305 
 13286 interrupts
 13306 interrupts
 13287     ^ self getValuesByCounter:148 timed:true
 13307     ^ self getValuesByCounter:148 timed:true
 13288 
 13308 
 13289     "
 13309     "
 13290         self current interrupts
 13310 	self current interrupts
 13291     "
 13311     "
 13292 !
 13312 !
 13293 
 13313 
 13294 interruptsBasic
 13314 interruptsBasic
 13295     ^ self getBasicValuesByCounter:148 timed:true
 13315     ^ self getBasicValuesByCounter:148 timed:true
 13296 
 13316 
 13297     "
 13317     "
 13298         self current interruptsBasic
 13318 	self current interruptsBasic
 13299     "
 13319     "
 13300 !
 13320 !
 13301 
 13321 
 13302 interruptsPerSecond
 13322 interruptsPerSecond
 13303     ^ self getPerSecondViaPerformBlock:[self interrupts]
 13323     ^ self getPerSecondViaPerformBlock:[self interrupts]
 13304 
 13324 
 13305     "
 13325     "
 13306         self current interruptsPerSecond
 13326 	self current interruptsPerSecond
 13307     "
 13327     "
 13308 !
 13328 !
 13309 
 13329 
 13310 interruptsPerSecondFromLast
 13330 interruptsPerSecondFromLast
 13311     ^ self getPerSecondFromLast:#interruptsBasic
 13331     ^ self getPerSecondFromLast:#interruptsBasic
 13312 
 13332 
 13313     "
 13333     "
 13314         self current interruptsPerSecondFromLast
 13334 	self current interruptsPerSecondFromLast
 13315     "
 13335     "
 13316 !
 13336 !
 13317 
 13337 
 13318 processorTime
 13338 processorTime
 13319     ^ self getValuesByCounter:6 timed:true
 13339     ^ self getValuesByCounter:6 timed:true
 13320 
 13340 
 13321     "
 13341     "
 13322         self current processorTime
 13342 	self current processorTime
 13323     "
 13343     "
 13324 !
 13344 !
 13325 
 13345 
 13326 processorTimeBasic
 13346 processorTimeBasic
 13327     ^ self getBasicValuesByCounter:6 timed:true
 13347     ^ self getBasicValuesByCounter:6 timed:true
 13328 
 13348 
 13329     "
 13349     "
 13330         self current processorTimeBasic
 13350 	self current processorTimeBasic
 13331     "
 13351     "
 13332 !
 13352 !
 13333 
 13353 
 13334 processorUsage
 13354 processorUsage
 13335     ^ self getUsageViaPerformBlock:[self processorTime]
 13355     ^ self getUsageViaPerformBlock:[self processorTime]
 13336 
 13356 
 13337     "
 13357     "
 13338         self current processorUsage
 13358 	self current processorUsage
 13339     "
 13359     "
 13340 !
 13360 !
 13341 
 13361 
 13342 processorUsageFromLast
 13362 processorUsageFromLast
 13343     ^ self getUsageFromLast:#processorTimeBasic
 13363     ^ self getUsageFromLast:#processorTimeBasic
 13344 
 13364 
 13345     "
 13365     "
 13346         self current processorUsageFromLast
 13366 	self current processorUsageFromLast
 13347     "
 13367     "
 13348 ! !
 13368 ! !
 13349 
 13369 
 13350 !Win32OperatingSystem::PrinterInfo2Structure methodsFor:'accessing'!
 13370 !Win32OperatingSystem::PrinterInfo2Structure methodsFor:'accessing'!
 13351 
 13371 
 13352 defaultPriority
 13372 defaultPriority
 13353 
 13373 
 13354     |defaultPriority|
 13374     |defaultPriority|
 13355 
 13375 
 13356     Error handle:[:ex |
 13376     Error handle:[:ex |
 13357         Transcript showCR: 'PrinterInfo2 error getting defaultPriority - ', ex description.
 13377 	Transcript showCR: 'PrinterInfo2 error getting defaultPriority - ', ex description.
 13358         defaultPriority := 0.
 13378 	defaultPriority := 0.
 13359     ] do:[
 13379     ] do:[
 13360         defaultPriority := self unsignedLongAt:(60 + 1)
 13380 	defaultPriority := self unsignedLongAt:(60 + 1)
 13361     ].
 13381     ].
 13362     ^ defaultPriority
 13382     ^ defaultPriority
 13363 
 13383 
 13364     "Created: / 01-08-2006 / 12:46:50 / fm"
 13384     "Created: / 01-08-2006 / 12:46:50 / fm"
 13365     "Modified: / 16-04-2007 / 13:08:33 / cg"
 13385     "Modified: / 16-04-2007 / 13:08:33 / cg"
 13367 
 13387 
 13368 pComment
 13388 pComment
 13369     |pComment|
 13389     |pComment|
 13370 
 13390 
 13371     Error handle:[:ex |
 13391     Error handle:[:ex |
 13372         Transcript showCR: 'PrinterInfo2 error getting pComment - ', ex description.
 13392 	Transcript showCR: 'PrinterInfo2 error getting pComment - ', ex description.
 13373         pComment := 0.
 13393 	pComment := 0.
 13374     ] do:[
 13394     ] do:[
 13375         pComment := self unsignedLongAt:(20 + 1).
 13395 	pComment := self unsignedLongAt:(20 + 1).
 13376     ].
 13396     ].
 13377 
 13397 
 13378     ^ pComment == 0
 13398     ^ pComment == 0
 13379         ifTrue:''
 13399 	ifTrue:''
 13380         ifFalse:[ (ExternalBytes address:pComment) stringAt:1 ]
 13400 	ifFalse:[ (ExternalBytes address:pComment) stringAt:1 ]
 13381 
 13401 
 13382     "Created: / 01-08-2006 / 14:02:55 / fm"
 13402     "Created: / 01-08-2006 / 14:02:55 / fm"
 13383     "Modified: / 16-04-2007 / 13:08:39 / cg"
 13403     "Modified: / 16-04-2007 / 13:08:39 / cg"
 13384 !
 13404 !
 13385 
 13405 
 13386 pDriverName
 13406 pDriverName
 13387     |pName|
 13407     |pName|
 13388 
 13408 
 13389     Error handle:[:ex |
 13409     Error handle:[:ex |
 13390         Transcript showCR: 'PrinterInfo2 error getting pDriverName - ', ex description.
 13410 	Transcript showCR: 'PrinterInfo2 error getting pDriverName - ', ex description.
 13391         pName := 0.
 13411 	pName := 0.
 13392     ] do:[
 13412     ] do:[
 13393         pName := self unsignedLongAt:(16 + 1).
 13413 	pName := self unsignedLongAt:(16 + 1).
 13394     ].
 13414     ].
 13395     pName == 0 ifTrue:[^ ''].
 13415     pName == 0 ifTrue:[^ ''].
 13396     ^ (ExternalBytes address:pName) stringAt:1
 13416     ^ (ExternalBytes address:pName) stringAt:1
 13397 
 13417 
 13398     "Created: / 01-08-2006 / 14:05:18 / fm"
 13418     "Created: / 01-08-2006 / 14:05:18 / fm"
 13401 
 13421 
 13402 pLocation
 13422 pLocation
 13403     |pLocation externalBytes|
 13423     |pLocation externalBytes|
 13404 
 13424 
 13405     Error handle:[:ex |
 13425     Error handle:[:ex |
 13406         Transcript showCR: 'PrinterInfo2 error getting pLocation - ', ex description.
 13426 	Transcript showCR: 'PrinterInfo2 error getting pLocation - ', ex description.
 13407         pLocation := 0.
 13427 	pLocation := 0.
 13408     ] do:[
 13428     ] do:[
 13409         pLocation := self unsignedLongAt:(24 + 1).
 13429 	pLocation := self unsignedLongAt:(24 + 1).
 13410     ].
 13430     ].
 13411 
 13431 
 13412     pLocation == 0 ifTrue:[^ nil].
 13432     pLocation == 0 ifTrue:[^ nil].
 13413 
 13433 
 13414     externalBytes := ExternalBytes address:pLocation.
 13434     externalBytes := ExternalBytes address:pLocation.
 13415     ^ externalBytes isEmpty
 13435     ^ externalBytes isEmpty
 13416         ifTrue:[ nil ]
 13436 	ifTrue:[ nil ]
 13417         ifFalse:[ externalBytes stringAt:1 ]
 13437 	ifFalse:[ externalBytes stringAt:1 ]
 13418 
 13438 
 13419     "Created: / 01-08-2006 / 14:03:21 / fm"
 13439     "Created: / 01-08-2006 / 14:03:21 / fm"
 13420     "Modified: / 18-10-2006 / 12:06:45 / User"
 13440     "Modified: / 18-10-2006 / 12:06:45 / User"
 13421     "Modified: / 16-04-2007 / 13:08:27 / cg"
 13441     "Modified: / 16-04-2007 / 13:08:27 / cg"
 13422 !
 13442 !
 13424 priority
 13444 priority
 13425 
 13445 
 13426     |priority|
 13446     |priority|
 13427 
 13447 
 13428     Error handle:[:ex |
 13448     Error handle:[:ex |
 13429         Transcript showCR: 'PrinterInfo2 error getting priority - ', ex description.
 13449 	Transcript showCR: 'PrinterInfo2 error getting priority - ', ex description.
 13430         priority := 0.
 13450 	priority := 0.
 13431     ] do:[
 13451     ] do:[
 13432         priority := self unsignedLongAt: 56 + 1
 13452 	priority := self unsignedLongAt: 56 + 1
 13433     ].
 13453     ].
 13434     ^ priority
 13454     ^ priority
 13435 
 13455 
 13436     "Created: / 01-08-2006 / 14:40:08 / fm"
 13456     "Created: / 01-08-2006 / 14:40:08 / fm"
 13437     "Modified: / 16-04-2007 / 13:09:02 / cg"
 13457     "Modified: / 16-04-2007 / 13:09:02 / cg"
 13440 status
 13460 status
 13441 
 13461 
 13442     |status|
 13462     |status|
 13443 
 13463 
 13444     Error handle:[:ex |
 13464     Error handle:[:ex |
 13445         Transcript showCR: 'PrinterInfo2 error getting status - ', ex description.
 13465 	Transcript showCR: 'PrinterInfo2 error getting status - ', ex description.
 13446         status := -1.
 13466 	status := -1.
 13447     ] do:[
 13467     ] do:[
 13448         status := self unsignedLongAt: 72 + 1
 13468 	status := self unsignedLongAt: 72 + 1
 13449     ].
 13469     ].
 13450     ^ status
 13470     ^ status
 13451 
 13471 
 13452     "Created: / 31-07-2006 / 11:08:05 / fm"
 13472     "Created: / 31-07-2006 / 11:08:05 / fm"
 13453     "Modified: / 16-04-2007 / 13:08:59 / cg"
 13473     "Modified: / 16-04-2007 / 13:08:59 / cg"
 13457 
 13477 
 13458 rootKeyNames
 13478 rootKeyNames
 13459     "returns a collection of root keyNames"
 13479     "returns a collection of root keyNames"
 13460 
 13480 
 13461     ^ #(
 13481     ^ #(
 13462         'HKEY_CLASSES_ROOT'
 13482 	'HKEY_CLASSES_ROOT'
 13463         'HKEY_CURRENT_USER'
 13483 	'HKEY_CURRENT_USER'
 13464         'HKEY_LOCAL_MACHINE'
 13484 	'HKEY_LOCAL_MACHINE'
 13465         'HKEY_USERS'
 13485 	'HKEY_USERS'
 13466         'HKEY_PERFORMANCE_DATA'
 13486 	'HKEY_PERFORMANCE_DATA'
 13467         'HKEY_CURRENT_CONFIG'
 13487 	'HKEY_CURRENT_CONFIG'
 13468         'HKEY_DYN_DATA'
 13488 	'HKEY_DYN_DATA'
 13469       )
 13489       )
 13470 !
 13490 !
 13471 
 13491 
 13472 separator
 13492 separator
 13473     "returns the registry-key-path separator character"
 13493     "returns the registry-key-path separator character"
 13480 documentation
 13500 documentation
 13481 "
 13501 "
 13482     Interface to a WIN32 registry.
 13502     Interface to a WIN32 registry.
 13483 
 13503 
 13484     As this is a private class, access it via
 13504     As this is a private class, access it via
 13485         Win32OperatingSystem registryEntry
 13505 	Win32OperatingSystem registryEntry
 13486 
 13506 
 13487     [author:]
 13507     [author:]
 13488         Claus Gittinger (initial version & cleanup)
 13508 	Claus Gittinger (initial version & cleanup)
 13489 "
 13509 "
 13490 !
 13510 !
 13491 
 13511 
 13492 examples
 13512 examples
 13493 "
 13513 "
 13494     retrieve an existing entry by key:
 13514     retrieve an existing entry by key:
 13495                                                                         [exBegin]
 13515 									[exBegin]
 13496         |k|
 13516 	|k|
 13497 
 13517 
 13498         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X'
 13518 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X'
 13499                                                                         [exEnd]
 13519 									[exEnd]
 13500 
 13520 
 13501 
 13521 
 13502     retrieve a non-existing entry by key:
 13522     retrieve a non-existing entry by key:
 13503                                                                         [exBegin]
 13523 									[exBegin]
 13504         |k|
 13524 	|k|
 13505 
 13525 
 13506         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\xxx'
 13526 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\xxx'
 13507                                                                         [exEnd]
 13527 									[exEnd]
 13508 
 13528 
 13509 
 13529 
 13510     ask a keys value:
 13530     ask a keys value:
 13511                                                                         [exBegin]
 13531 									[exBegin]
 13512         |k|
 13532 	|k|
 13513 
 13533 
 13514         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion'.
 13534 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion'.
 13515         Transcript show:'Windows serial NR:'; showCR:(k valueNamed:'ProductId').
 13535 	Transcript show:'Windows serial NR:'; showCR:(k valueNamed:'ProductId').
 13516 
 13536 
 13517         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X'.
 13537 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X'.
 13518         Transcript showCR:(k valueNamed:'CurrentVersion').
 13538 	Transcript showCR:(k valueNamed:'CurrentVersion').
 13519                                                                         [exEnd]
 13539 									[exEnd]
 13520 
 13540 
 13521 
 13541 
 13522     create a sub-key (if not already present):
 13542     create a sub-key (if not already present):
 13523                                                                         [exBegin]
 13543 									[exBegin]
 13524         |k subKey|
 13544 	|k subKey|
 13525 
 13545 
 13526         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X'.
 13546 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X'.
 13527         subKey := k createSubKeyNamed:'RegistryDemo'
 13547 	subKey := k createSubKeyNamed:'RegistryDemo'
 13528                                                                         [exEnd]
 13548 									[exEnd]
 13529 
 13549 
 13530 
 13550 
 13531     change a keys value:
 13551     change a keys value:
 13532                                                                         [exBegin]
 13552 									[exBegin]
 13533         |k|
 13553 	|k|
 13534 
 13554 
 13535         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X\RegistryDemo'.
 13555 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X\RegistryDemo'.
 13536         k valueNamed:'FooBarBaz' put:'a foo bar baz string'.
 13556 	k valueNamed:'FooBarBaz' put:'a foo bar baz string'.
 13537                                                                         [exEnd]
 13557 									[exEnd]
 13538 
 13558 
 13539     delete a value:
 13559     delete a value:
 13540                                                                         [exBegin]
 13560 									[exBegin]
 13541         |k|
 13561 	|k|
 13542 
 13562 
 13543         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X\RegistryDemo'.
 13563 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X\RegistryDemo'.
 13544         k deleteValueNamed:'FooBarBaz'.
 13564 	k deleteValueNamed:'FooBarBaz'.
 13545                                                                         [exEnd]
 13565 									[exEnd]
 13546 
 13566 
 13547     delete a key:
 13567     delete a key:
 13548                                                                         [exBegin]
 13568 									[exBegin]
 13549         |k|
 13569 	|k|
 13550 
 13570 
 13551         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X'.
 13571 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X'.
 13552         k deleteSubKeyNamed:'RegistryDemo'.
 13572 	k deleteSubKeyNamed:'RegistryDemo'.
 13553                                                                         [exEnd]
 13573 									[exEnd]
 13554 
 13574 
 13555     enumerate keys:
 13575     enumerate keys:
 13556                                                                         [exBegin]
 13576 									[exBegin]
 13557         |k|
 13577 	|k|
 13558 
 13578 
 13559         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software'.
 13579 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software'.
 13560         k subKeysDo:[:subKey |
 13580 	k subKeysDo:[:subKey |
 13561             Transcript showCR:subKey path
 13581 	    Transcript showCR:subKey path
 13562         ]
 13582 	]
 13563                                                                         [exEnd]
 13583 									[exEnd]
 13564 
 13584 
 13565     enumerate all keys (recursive):
 13585     enumerate all keys (recursive):
 13566                                                                         [exBegin]
 13586 									[exBegin]
 13567         |k|
 13587 	|k|
 13568 
 13588 
 13569         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software'.
 13589 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software'.
 13570         k allSubKeysDo:[:subKey |
 13590 	k allSubKeysDo:[:subKey |
 13571             Transcript showCR:subKey path
 13591 	    Transcript showCR:subKey path
 13572         ]
 13592 	]
 13573                                                                         [exEnd]
 13593 									[exEnd]
 13574 
 13594 
 13575     fetch value by index:
 13595     fetch value by index:
 13576                                                                         [exBegin]
 13596 									[exBegin]
 13577         |k|
 13597 	|k|
 13578 
 13598 
 13579         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'.
 13599 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'.
 13580         Transcript showCR:(k valueNameAtIndex:0)
 13600 	Transcript showCR:(k valueNameAtIndex:0)
 13581                                                                         [exEnd]
 13601 									[exEnd]
 13582 
 13602 
 13583 
 13603 
 13584     enumerate value names:
 13604     enumerate value names:
 13585                                                                         [exBegin]
 13605 									[exBegin]
 13586         |k|
 13606 	|k|
 13587 
 13607 
 13588         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'.
 13608 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'.
 13589         k valueNamesDo:[:nm  |
 13609 	k valueNamesDo:[:nm  |
 13590            Transcript showCR:nm.
 13610 	   Transcript showCR:nm.
 13591         ]
 13611 	]
 13592                                                                         [exEnd]
 13612 									[exEnd]
 13593 
 13613 
 13594     enumerate values:
 13614     enumerate values:
 13595                                                                         [exBegin]
 13615 									[exBegin]
 13596         |k|
 13616 	|k|
 13597 
 13617 
 13598         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'.
 13618 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'.
 13599         k valueNamesAndValuesDo:[:nm :val |
 13619 	k valueNamesAndValuesDo:[:nm :val |
 13600             Transcript showCR:(nm , ' -> ' , val storeString).
 13620 	    Transcript showCR:(nm , ' -> ' , val storeString).
 13601         ]
 13621 	]
 13602                                                                         [exEnd]
 13622 									[exEnd]
 13603 
 13623 
 13604     search for a value (where does NT store the domain ?):
 13624     search for a value (where does NT store the domain ?):
 13605                                                                         [exBegin]
 13625 									[exBegin]
 13606         |k|
 13626 	|k|
 13607 
 13627 
 13608         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\System'.
 13628 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\System'.
 13609         k subKeysDo:[:subKey |
 13629 	k subKeysDo:[:subKey |
 13610             subKey subKeysDo:[:subSubKey |
 13630 	    subKey subKeysDo:[:subSubKey |
 13611                 |tcp params|
 13631 		|tcp params|
 13612 
 13632 
 13613                 (subSubKey path asLowercase endsWith:'services') ifTrue:[
 13633 		(subSubKey path asLowercase endsWith:'services') ifTrue:[
 13614                     tcp := subSubKey subKeyNamed:'tcpip'.
 13634 		    tcp := subSubKey subKeyNamed:'tcpip'.
 13615                     tcp notNil ifTrue:[
 13635 		    tcp notNil ifTrue:[
 13616                         params := tcp subKeyNamed:'parameters'.
 13636 			params := tcp subKeyNamed:'parameters'.
 13617                         params notNil ifTrue:[
 13637 			params notNil ifTrue:[
 13618                             Transcript showCR:'Domain is found in ' , params path ,
 13638 			    Transcript showCR:'Domain is found in ' , params path ,
 13619                                         ' value: ' , (params valueNamed:'Domain').
 13639 					' value: ' , (params valueNamed:'Domain').
 13620                             params close.
 13640 			    params close.
 13621                         ].
 13641 			].
 13622                         tcp close.
 13642 			tcp close.
 13623                     ]
 13643 		    ]
 13624                 ]
 13644 		]
 13625             ]
 13645 	    ]
 13626         ]
 13646 	]
 13627                                                                         [exEnd]
 13647 									[exEnd]
 13628 
 13648 
 13629 
 13649 
 13630 "
 13650 "
 13631 ! !
 13651 ! !
 13632 
 13652 
 13670      (these are shared and not finalized, as opposed to all other keys)"
 13690      (these are shared and not finalized, as opposed to all other keys)"
 13671 
 13691 
 13672     HKEY_CLASSES_ROOT isNil ifTrue:[self initialize].
 13692     HKEY_CLASSES_ROOT isNil ifTrue:[self initialize].
 13673 
 13693 
 13674     specialKeyStringOrSymbol = #'HKEY_CLASSES_ROOT' ifTrue:[
 13694     specialKeyStringOrSymbol = #'HKEY_CLASSES_ROOT' ifTrue:[
 13675         ^ HKEY_CLASSES_ROOT.
 13695 	^ HKEY_CLASSES_ROOT.
 13676     ].
 13696     ].
 13677     specialKeyStringOrSymbol = #'HKEY_CURRENT_USER' ifTrue:[
 13697     specialKeyStringOrSymbol = #'HKEY_CURRENT_USER' ifTrue:[
 13678         ^ HKEY_CURRENT_USER.
 13698 	^ HKEY_CURRENT_USER.
 13679     ].
 13699     ].
 13680     specialKeyStringOrSymbol = #'HKEY_LOCAL_MACHINE' ifTrue:[
 13700     specialKeyStringOrSymbol = #'HKEY_LOCAL_MACHINE' ifTrue:[
 13681         ^ HKEY_LOCAL_MACHINE.
 13701 	^ HKEY_LOCAL_MACHINE.
 13682     ].
 13702     ].
 13683     specialKeyStringOrSymbol = #'HKEY_USERS' ifTrue:[
 13703     specialKeyStringOrSymbol = #'HKEY_USERS' ifTrue:[
 13684         ^ HKEY_USERS.
 13704 	^ HKEY_USERS.
 13685     ].
 13705     ].
 13686     specialKeyStringOrSymbol = #'HKEY_PERFORMANCE_DATA' ifTrue:[
 13706     specialKeyStringOrSymbol = #'HKEY_PERFORMANCE_DATA' ifTrue:[
 13687         ^ HKEY_PERFORMANCE_DATA.
 13707 	^ HKEY_PERFORMANCE_DATA.
 13688     ].
 13708     ].
 13689     specialKeyStringOrSymbol = #'HKEY_CURRENT_CONFIG' ifTrue:[
 13709     specialKeyStringOrSymbol = #'HKEY_CURRENT_CONFIG' ifTrue:[
 13690         ^ HKEY_CURRENT_CONFIG.
 13710 	^ HKEY_CURRENT_CONFIG.
 13691     ].
 13711     ].
 13692     specialKeyStringOrSymbol = #'HKEY_DYN_DATA' ifTrue:[
 13712     specialKeyStringOrSymbol = #'HKEY_DYN_DATA' ifTrue:[
 13693         ^ HKEY_DYN_DATA.
 13713 	^ HKEY_DYN_DATA.
 13694     ].
 13714     ].
 13695     specialKeyStringOrSymbol = #'HKEY_PERFORMANCE_TEXT' ifTrue:[
 13715     specialKeyStringOrSymbol = #'HKEY_PERFORMANCE_TEXT' ifTrue:[
 13696         ^ HKEY_PERFORMANCE_TEXT.
 13716 	^ HKEY_PERFORMANCE_TEXT.
 13697     ].
 13717     ].
 13698     specialKeyStringOrSymbol = #'HKEY_PERFORMANCE_NLSTEXT' ifTrue:[
 13718     specialKeyStringOrSymbol = #'HKEY_PERFORMANCE_NLSTEXT' ifTrue:[
 13699         ^ HKEY_PERFORMANCE_NLSTEXT.
 13719 	^ HKEY_PERFORMANCE_NLSTEXT.
 13700     ].
 13720     ].
 13701 
 13721 
 13702     ^ nil
 13722     ^ nil
 13703 
 13723 
 13704     "Created: / 19.5.1999 / 21:40:30 / cg"
 13724     "Created: / 19.5.1999 / 21:40:30 / cg"
 13707 
 13727 
 13708 update:something with:aParameter from:changedObject
 13728 update:something with:aParameter from:changedObject
 13709     "handle image restarts and refetch registry handles"
 13729     "handle image restarts and refetch registry handles"
 13710 
 13730 
 13711     (something == #returnFromSnapshot) ifTrue:[
 13731     (something == #returnFromSnapshot) ifTrue:[
 13712         self initialize
 13732 	self initialize
 13713     ]
 13733     ]
 13714 
 13734 
 13715     "Created: 15.6.1996 / 15:14:03 / cg"
 13735     "Created: 15.6.1996 / 15:14:03 / cg"
 13716     "Modified: 24.2.1997 / 22:08:05 / cg"
 13736     "Modified: 24.2.1997 / 22:08:05 / cg"
 13717 ! !
 13737 ! !
 13720 
 13740 
 13721 immediateHandle:aHandleValue
 13741 immediateHandle:aHandleValue
 13722     |h newEntry|
 13742     |h newEntry|
 13723 
 13743 
 13724     aHandleValue isInteger ifTrue:[
 13744     aHandleValue isInteger ifTrue:[
 13725         h := ExternalAddress newAddress:aHandleValue
 13745 	h := ExternalAddress newAddress:aHandleValue
 13726     ] ifFalse:[
 13746     ] ifFalse:[
 13727         h := aHandleValue
 13747 	h := aHandleValue
 13728     ].
 13748     ].
 13729 
 13749 
 13730     "/ rootKeys are not registered for RegClose ...
 13750     "/ rootKeys are not registered for RegClose ...
 13731     newEntry := self basicNew setHandle:h path:nil.
 13751     newEntry := self basicNew setHandle:h path:nil.
 13732     newEntry registerForFinalization.
 13752     newEntry registerForFinalization.
 13760 
 13780 
 13761     HKEY_CLASSES_ROOT isNil ifTrue:[self initialize].
 13781     HKEY_CLASSES_ROOT isNil ifTrue:[self initialize].
 13762 
 13782 
 13763     idx := aKeyNamePath indexOf:(self separator).
 13783     idx := aKeyNamePath indexOf:(self separator).
 13764     idx == 0 ifTrue:[
 13784     idx == 0 ifTrue:[
 13765         first := aKeyNamePath.
 13785 	first := aKeyNamePath.
 13766         rest := nil.
 13786 	rest := nil.
 13767     ] ifFalse:[
 13787     ] ifFalse:[
 13768         first := aKeyNamePath copyTo:idx-1.
 13788 	first := aKeyNamePath copyTo:idx-1.
 13769         rest := aKeyNamePath copyFrom:idx+1
 13789 	rest := aKeyNamePath copyFrom:idx+1
 13770     ].
 13790     ].
 13771 
 13791 
 13772     first := first asUppercase.
 13792     first := first asUppercase.
 13773 
 13793 
 13774     "/ the first is a pseudo name
 13794     "/ the first is a pseudo name
 13775     root := self rootKey:first.
 13795     root := self rootKey:first.
 13776     root isNil ifTrue:[
 13796     root isNil ifTrue:[
 13777         ^ nil
 13797 	^ nil
 13778     ].
 13798     ].
 13779 
 13799 
 13780     rest size == 0 ifTrue:[
 13800     rest size == 0 ifTrue:[
 13781         ^ root
 13801 	^ root
 13782     ].
 13802     ].
 13783 
 13803 
 13784     Error handle:[:ex |
 13804     Error handle:[:ex |
 13785         ^ nil
 13805 	^ nil
 13786     ] do:[
 13806     ] do:[
 13787         ^ root subKeyNamed:rest createIfAbsent:createIfAbsent.
 13807 	^ root subKeyNamed:rest createIfAbsent:createIfAbsent.
 13788     ].
 13808     ].
 13789 
 13809 
 13790     "
 13810     "
 13791      self key:'HKEY_LOCAL_MACHINE'
 13811      self key:'HKEY_LOCAL_MACHINE'
 13792      self key:'HKEY_LOCAL_MACHINE\Software'
 13812      self key:'HKEY_LOCAL_MACHINE\Software'
 13919 
 13939 
 13920     |k suffix|
 13940     |k suffix|
 13921 
 13941 
 13922     k := self key:'HKEY_CLASSES_ROOT\MIME\Database\Content Type\',mimeType.
 13942     k := self key:'HKEY_CLASSES_ROOT\MIME\Database\Content Type\',mimeType.
 13923     k notNil ifTrue:[
 13943     k notNil ifTrue:[
 13924         suffix := k valueNamed:'extension'.
 13944 	suffix := k valueNamed:'extension'.
 13925     ].
 13945     ].
 13926     ^ suffix
 13946     ^ suffix
 13927 !
 13947 !
 13928 
 13948 
 13929 shellCommandTemplateFor:operation onSuffix:suffixArg
 13949 shellCommandTemplateFor:operation onSuffix:suffixArg
 13933 
 13953 
 13934     suffix := suffixArg.
 13954     suffix := suffixArg.
 13935     suffix isNil ifTrue:[^ nil].
 13955     suffix isNil ifTrue:[^ nil].
 13936 
 13956 
 13937     (suffix startsWith:'.') ifTrue:[
 13957     (suffix startsWith:'.') ifTrue:[
 13938         suffix := suffix copyFrom:2
 13958 	suffix := suffix copyFrom:2
 13939     ].
 13959     ].
 13940     k := self key:'HKEY_CLASSES_ROOT\.',suffix.
 13960     k := self key:'HKEY_CLASSES_ROOT\.',suffix.
 13941 
 13961 
 13942     k notNil ifTrue:[
 13962     k notNil ifTrue:[
 13943         fkey := (k valueNamed:'').
 13963 	fkey := (k valueNamed:'').
 13944     ].
 13964     ].
 13945     fkey isNil ifTrue:[
 13965     fkey isNil ifTrue:[
 13946         fkey := suffix,'_auto_file'
 13966 	fkey := suffix,'_auto_file'
 13947     ].
 13967     ].
 13948 
 13968 
 13949     fkey notEmptyOrNil ifTrue:[
 13969     fkey notEmptyOrNil ifTrue:[
 13950 
 13970 
 13951         redirect := nil.
 13971 	redirect := nil.
 13952 
 13972 
 13953         k := Win32OperatingSystem::RegistryEntry key:('HKEY_CLASSES_ROOT\' , fkey , '\CurVer').
 13973 	k := Win32OperatingSystem::RegistryEntry key:('HKEY_CLASSES_ROOT\' , fkey , '\CurVer').
 13954         k notNil ifTrue:[
 13974 	k notNil ifTrue:[
 13955             redirect := k defaultValue
 13975 	    redirect := k defaultValue
 13956         ].
 13976 	].
 13957 
 13977 
 13958         redirect isNil ifTrue:[
 13978 	redirect isNil ifTrue:[
 13959              k := Win32OperatingSystem::RegistryEntry key:('HKEY_CLASSES_ROOT\' , (fkey) , '\shell\',operation,'\command').
 13979 	     k := Win32OperatingSystem::RegistryEntry key:('HKEY_CLASSES_ROOT\' , (fkey) , '\shell\',operation,'\command').
 13960         ] ifFalse:[
 13980 	] ifFalse:[
 13961              k := Win32OperatingSystem::RegistryEntry key:('HKEY_CLASSES_ROOT\' , (redirect) , '\shell\',operation,'\command').
 13981 	     k := Win32OperatingSystem::RegistryEntry key:('HKEY_CLASSES_ROOT\' , (redirect) , '\shell\',operation,'\command').
 13962         ].
 13982 	].
 13963 
 13983 
 13964         k notNil ifTrue:[
 13984 	k notNil ifTrue:[
 13965             cmd := k defaultValue
 13985 	    cmd := k defaultValue
 13966         ].
 13986 	].
 13967     ].
 13987     ].
 13968 
 13988 
 13969 
 13989 
 13970     ^ cmd
 13990     ^ cmd
 13971 ! !
 13991 ! !
 13986     v isString ifFalse:[^ nil].
 14006     v isString ifFalse:[^ nil].
 13987     ^ v
 14007     ^ v
 13988 
 14008 
 13989     "
 14009     "
 13990      self
 14010      self
 13991         stringValueFor:'Content Type'
 14011 	stringValueFor:'Content Type'
 13992         atKey:'HKEY_CLASSES_ROOT\.au'
 14012 	atKey:'HKEY_CLASSES_ROOT\.au'
 13993     "
 14013     "
 13994 ! !
 14014 ! !
 13995 
 14015 
 13996 !Win32OperatingSystem::RegistryEntry methodsFor:'accessing'!
 14016 !Win32OperatingSystem::RegistryEntry methodsFor:'accessing'!
 13997 
 14017 
 14029     HKEY myKey, subKey = 0;
 14049     HKEY myKey, subKey = 0;
 14030     int _retVal;
 14050     int _retVal;
 14031 
 14051 
 14032     if (__isExternalAddressLike(__INST(handle))
 14052     if (__isExternalAddressLike(__INST(handle))
 14033      && __isStringLike(subKeyString)) {
 14053      && __isStringLike(subKeyString)) {
 14034         myKey = (HKEY)__externalAddressVal(__INST(handle));
 14054 	myKey = (HKEY)__externalAddressVal(__INST(handle));
 14035         if ((_retVal = RegCreateKey(myKey, __stringVal(subKeyString), &subKey)) == ERROR_SUCCESS) {
 14055 	if ((_retVal = RegCreateKey(myKey, __stringVal(subKeyString), &subKey)) == ERROR_SUCCESS) {
 14036             subHandle = __MKEXTERNALADDRESS(subKey);
 14056 	    subHandle = __MKEXTERNALADDRESS(subKey);
 14037         } else {
 14057 	} else {
 14038             if ((_retVal != ERROR_PATH_NOT_FOUND)
 14058 	    if ((_retVal != ERROR_PATH_NOT_FOUND)
 14039              && (_retVal != ERROR_FILE_NOT_FOUND)) {
 14059 	     && (_retVal != ERROR_FILE_NOT_FOUND)) {
 14040                 errorNumber = __MKSMALLINT(_retVal);
 14060 		errorNumber = __MKSMALLINT(_retVal);
 14041             }
 14061 	    }
 14042         }
 14062 	}
 14043     }
 14063     }
 14044 %}.
 14064 %}.
 14045     subHandle notNil ifTrue:[
 14065     subHandle notNil ifTrue:[
 14046         newEntry := self class basicNew
 14066 	newEntry := self class basicNew
 14047                         setHandle:subHandle
 14067 			setHandle:subHandle
 14048                         path:(path , self class separator asString , subKeyString).
 14068 			path:(path , self class separator asString , subKeyString).
 14049         newEntry registerForFinalization.
 14069 	newEntry registerForFinalization.
 14050         ^ newEntry.
 14070 	^ newEntry.
 14051     ].
 14071     ].
 14052     errorNumber notNil ifTrue:[
 14072     errorNumber notNil ifTrue:[
 14053         (OperatingSystem errorHolderForNumber:errorNumber) reportError.
 14073 	(OperatingSystem errorHolderForNumber:errorNumber) reportError.
 14054     ].
 14074     ].
 14055     ^ nil
 14075     ^ nil
 14056 
 14076 
 14057     "
 14077     "
 14058      |top sub|
 14078      |top sub|
 14072     HKEY myKey;
 14092     HKEY myKey;
 14073     int _retVal;
 14093     int _retVal;
 14074 
 14094 
 14075     if (__isExternalAddressLike(__INST(handle))
 14095     if (__isExternalAddressLike(__INST(handle))
 14076      && __isStringLike(subKeyString)) {
 14096      && __isStringLike(subKeyString)) {
 14077         myKey = (HKEY)__externalAddressVal(__INST(handle));
 14097 	myKey = (HKEY)__externalAddressVal(__INST(handle));
 14078         if ((_retVal = RegDeleteKey(myKey, __stringVal(subKeyString))) == ERROR_SUCCESS) {
 14098 	if ((_retVal = RegDeleteKey(myKey, __stringVal(subKeyString))) == ERROR_SUCCESS) {
 14079             RETURN (true);
 14099 	    RETURN (true);
 14080         }
 14100 	}
 14081         if ((_retVal != ERROR_PATH_NOT_FOUND)
 14101 	if ((_retVal != ERROR_PATH_NOT_FOUND)
 14082          && (_retVal != ERROR_FILE_NOT_FOUND)) {
 14102 	 && (_retVal != ERROR_FILE_NOT_FOUND)) {
 14083             errorNumber = __MKSMALLINT(_retVal);
 14103 	    errorNumber = __MKSMALLINT(_retVal);
 14084         }
 14104 	}
 14085     }
 14105     }
 14086 %}.
 14106 %}.
 14087     errorNumber notNil ifTrue:[
 14107     errorNumber notNil ifTrue:[
 14088         (OperatingSystem errorHolderForNumber:errorNumber) reportError.
 14108 	(OperatingSystem errorHolderForNumber:errorNumber) reportError.
 14089     ].
 14109     ].
 14090     ^ false
 14110     ^ false
 14091 
 14111 
 14092     "
 14112     "
 14093      |top sub|
 14113      |top sub|
 14107 %{
 14127 %{
 14108     HKEY myKey, remoteKey = 0;
 14128     HKEY myKey, remoteKey = 0;
 14109     int _retVal;
 14129     int _retVal;
 14110 
 14130 
 14111     if (__isExternalAddressLike(__INST(handle)) && __isStringLike(hostName)) {
 14131     if (__isExternalAddressLike(__INST(handle)) && __isStringLike(hostName)) {
 14112         myKey = (HKEY)__externalAddressVal(__INST(handle));
 14132 	myKey = (HKEY)__externalAddressVal(__INST(handle));
 14113         if ((_retVal = RegConnectRegistryA(__stringVal(hostName), myKey, &remoteKey)) == ERROR_SUCCESS) {
 14133 	if ((_retVal = RegConnectRegistryA(__stringVal(hostName), myKey, &remoteKey)) == ERROR_SUCCESS) {
 14114             remoteHandle = __MKEXTERNALADDRESS(remoteKey);
 14134 	    remoteHandle = __MKEXTERNALADDRESS(remoteKey);
 14115         } else {
 14135 	} else {
 14116             if ((_retVal != ERROR_PATH_NOT_FOUND)
 14136 	    if ((_retVal != ERROR_PATH_NOT_FOUND)
 14117              && (_retVal != ERROR_FILE_NOT_FOUND)) {
 14137 	     && (_retVal != ERROR_FILE_NOT_FOUND)) {
 14118                 errorNumber = __MKSMALLINT(_retVal);
 14138 		errorNumber = __MKSMALLINT(_retVal);
 14119             }
 14139 	    }
 14120         }
 14140 	}
 14121     }
 14141     }
 14122 %}.
 14142 %}.
 14123     remoteHandle notNil ifTrue:[
 14143     remoteHandle notNil ifTrue:[
 14124         newEntry := self class basicNew setHandle:remoteHandle path:path.
 14144 	newEntry := self class basicNew setHandle:remoteHandle path:path.
 14125         newEntry registerForFinalization.
 14145 	newEntry registerForFinalization.
 14126         ^ newEntry.
 14146 	^ newEntry.
 14127     ].
 14147     ].
 14128     errorNumber notNil ifTrue:[
 14148     errorNumber notNil ifTrue:[
 14129         (OperatingSystem errorHolderForNumber:errorNumber) reportError.
 14149 	(OperatingSystem errorHolderForNumber:errorNumber) reportError.
 14130     ].
 14150     ].
 14131     ^ nil
 14151     ^ nil
 14132 
 14152 
 14133     "
 14153     "
 14134      |top remote|
 14154      |top remote|
 14171     FILETIME modificationTime;
 14191     FILETIME modificationTime;
 14172     int _retVal;
 14192     int _retVal;
 14173 
 14193 
 14174     if (__isExternalAddressLike(__INST(handle))
 14194     if (__isExternalAddressLike(__INST(handle))
 14175      && __isSmallInteger(subKeyIndex)) {
 14195      && __isSmallInteger(subKeyIndex)) {
 14176         myKey = (HKEY)__externalAddressVal(__INST(handle));
 14196 	myKey = (HKEY)__externalAddressVal(__INST(handle));
 14177         if ((_retVal = RegEnumKeyExA(myKey, __intVal(subKeyIndex),
 14197 	if ((_retVal = RegEnumKeyExA(myKey, __intVal(subKeyIndex),
 14178                          nameBuffer, &nameSize,
 14198 			 nameBuffer, &nameSize,
 14179                          NULL,
 14199 			 NULL,
 14180                          classNameBuffer, &classNameSize,
 14200 			 classNameBuffer, &classNameSize,
 14181                          &modificationTime)) == ERROR_SUCCESS) {
 14201 			 &modificationTime)) == ERROR_SUCCESS) {
 14182             nameBuffer[nameSize] = '\0';
 14202 	    nameBuffer[nameSize] = '\0';
 14183             classNameBuffer[classNameSize] = '\0';
 14203 	    classNameBuffer[classNameSize] = '\0';
 14184             subKeyName = __MKSTRING(nameBuffer);
 14204 	    subKeyName = __MKSTRING(nameBuffer);
 14185             subKeyClassName = __MKSTRING(classNameBuffer);
 14205 	    subKeyClassName = __MKSTRING(classNameBuffer);
 14186         } else {
 14206 	} else {
 14187             if ((_retVal != ERROR_PATH_NOT_FOUND)
 14207 	    if ((_retVal != ERROR_PATH_NOT_FOUND)
 14188              && (_retVal != ERROR_FILE_NOT_FOUND)
 14208 	     && (_retVal != ERROR_FILE_NOT_FOUND)
 14189              && (_retVal != ERROR_NO_MORE_ITEMS)) {
 14209 	     && (_retVal != ERROR_NO_MORE_ITEMS)) {
 14190                 errorNumber = __MKSMALLINT(_retVal);
 14210 		errorNumber = __MKSMALLINT(_retVal);
 14191             }
 14211 	    }
 14192         }
 14212 	}
 14193     }
 14213     }
 14194 %}.
 14214 %}.
 14195     subKeyName notNil ifTrue:[
 14215     subKeyName notNil ifTrue:[
 14196         ^ self subKeyNamed:subKeyName.
 14216 	^ self subKeyNamed:subKeyName.
 14197     ].
 14217     ].
 14198     errorNumber notNil ifTrue:[
 14218     errorNumber notNil ifTrue:[
 14199         (OperatingSystem errorHolderForNumber:errorNumber) reportError.
 14219 	(OperatingSystem errorHolderForNumber:errorNumber) reportError.
 14200     ].
 14220     ].
 14201     ^ nil
 14221     ^ nil
 14202 
 14222 
 14203     "
 14223     "
 14204      |top sub|
 14224      |top sub|
 14218     HKEY myKey, subKey = 0;
 14238     HKEY myKey, subKey = 0;
 14219     int _retVal;
 14239     int _retVal;
 14220 
 14240 
 14221     if (__isExternalAddressLike(__INST(handle))
 14241     if (__isExternalAddressLike(__INST(handle))
 14222      && __isStringLike(subKeyString)) {
 14242      && __isStringLike(subKeyString)) {
 14223         myKey = (HKEY)__externalAddressVal(__INST(handle));
 14243 	myKey = (HKEY)__externalAddressVal(__INST(handle));
 14224         _retVal = RegOpenKey(myKey, __stringVal(subKeyString), &subKey);
 14244 	_retVal = RegOpenKey(myKey, __stringVal(subKeyString), &subKey);
 14225         if (_retVal == ERROR_SUCCESS) {
 14245 	if (_retVal == ERROR_SUCCESS) {
 14226             subHandle = __MKEXTERNALADDRESS(subKey);
 14246 	    subHandle = __MKEXTERNALADDRESS(subKey);
 14227         } else {
 14247 	} else {
 14228             if ((_retVal != ERROR_PATH_NOT_FOUND)
 14248 	    if ((_retVal != ERROR_PATH_NOT_FOUND)
 14229              && (_retVal != ERROR_FILE_NOT_FOUND)) {
 14249 	     && (_retVal != ERROR_FILE_NOT_FOUND)) {
 14230                 errorNumber = __MKSMALLINT(_retVal);
 14250 		errorNumber = __MKSMALLINT(_retVal);
 14231             }
 14251 	    }
 14232         }
 14252 	}
 14233     }
 14253     }
 14234 %}.
 14254 %}.
 14235     subHandle notNil ifTrue:[
 14255     subHandle notNil ifTrue:[
 14236         newEntry := self class basicNew
 14256 	newEntry := self class basicNew
 14237                         setHandle:subHandle
 14257 			setHandle:subHandle
 14238                         path:((path ? '?') , self class separator asString , subKeyString).
 14258 			path:((path ? '?') , self class separator asString , subKeyString).
 14239 
 14259 
 14240         newEntry registerForFinalization.
 14260 	newEntry registerForFinalization.
 14241         ^ newEntry.
 14261 	^ newEntry.
 14242     ].
 14262     ].
 14243     errorNumber notNil ifTrue:[
 14263     errorNumber notNil ifTrue:[
 14244         (OperatingSystem errorHolderForNumber:errorNumber) reportError.
 14264 	(OperatingSystem errorHolderForNumber:errorNumber) reportError.
 14245     ].
 14265     ].
 14246     ^ nil
 14266     ^ nil
 14247 
 14267 
 14248     "
 14268     "
 14249      |top sub|
 14269      |top sub|
 14259      Otherwise, nil is returned"
 14279      Otherwise, nil is returned"
 14260 
 14280 
 14261     |k|
 14281     |k|
 14262 
 14282 
 14263     (k := self subKeyNamed:subKeyString) isNil ifTrue:[
 14283     (k := self subKeyNamed:subKeyString) isNil ifTrue:[
 14264         createIfAbsent ifTrue:[
 14284 	createIfAbsent ifTrue:[
 14265             ^ self createSubKeyNamed:subKeyString
 14285 	    ^ self createSubKeyNamed:subKeyString
 14266         ].
 14286 	].
 14267     ].
 14287     ].
 14268     ^ k
 14288     ^ k
 14269 
 14289 
 14270     "Created: / 19-01-2011 / 15:58:45 / cg"
 14290     "Created: / 19-01-2011 / 15:58:45 / cg"
 14271 ! !
 14291 ! !
 14280     "
 14300     "
 14281 !
 14301 !
 14282 
 14302 
 14283 defaultValue:datum
 14303 defaultValue:datum
 14284     "store a value; the value type depends upon the stored value:
 14304     "store a value; the value type depends upon the stored value:
 14285         ByteArray       -> REG_BINARY
 14305 	ByteArray       -> REG_BINARY
 14286         String          -> REG_SZ
 14306 	String          -> REG_SZ
 14287         Array of string -> REG_MULTI_SZ
 14307 	Array of string -> REG_MULTI_SZ
 14288         Integer         -> REG_DWORD
 14308 	Integer         -> REG_DWORD
 14289         nil             -> REG_NONE
 14309 	nil             -> REG_NONE
 14290     "
 14310     "
 14291 
 14311 
 14292     ^ self valueNamed:'' put:datum
 14312     ^ self valueNamed:'' put:datum
 14293 
 14313 
 14294     "
 14314     "
 14306     HKEY myKey;
 14326     HKEY myKey;
 14307     int _retVal;
 14327     int _retVal;
 14308 
 14328 
 14309     if (__isExternalAddressLike(__INST(handle))
 14329     if (__isExternalAddressLike(__INST(handle))
 14310      && __isStringLike(aValueName)) {
 14330      && __isStringLike(aValueName)) {
 14311         myKey = (HKEY)__externalAddressVal(__INST(handle));
 14331 	myKey = (HKEY)__externalAddressVal(__INST(handle));
 14312         if ((_retVal = RegDeleteValue(myKey, __stringVal(aValueName))) == ERROR_SUCCESS) {
 14332 	if ((_retVal = RegDeleteValue(myKey, __stringVal(aValueName))) == ERROR_SUCCESS) {
 14313             RETURN (true);
 14333 	    RETURN (true);
 14314         }
 14334 	}
 14315         if ((_retVal != ERROR_PATH_NOT_FOUND)
 14335 	if ((_retVal != ERROR_PATH_NOT_FOUND)
 14316          && (_retVal != ERROR_FILE_NOT_FOUND)) {
 14336 	 && (_retVal != ERROR_FILE_NOT_FOUND)) {
 14317             errorNumber = __MKSMALLINT(_retVal);
 14337 	    errorNumber = __MKSMALLINT(_retVal);
 14318         }
 14338 	}
 14319     }
 14339     }
 14320 %}.
 14340 %}.
 14321     errorNumber notNil ifTrue:[
 14341     errorNumber notNil ifTrue:[
 14322         (OperatingSystem errorHolderForNumber:errorNumber) reportError.
 14342 	(OperatingSystem errorHolderForNumber:errorNumber) reportError.
 14323     ].
 14343     ].
 14324     ^ false
 14344     ^ false
 14325 !
 14345 !
 14326 
 14346 
 14327 valueNameAtIndex:valueIndex
 14347 valueNameAtIndex:valueIndex
 14337     DWORD valueType;
 14357     DWORD valueType;
 14338     int _retVal;
 14358     int _retVal;
 14339 
 14359 
 14340     if (__isExternalAddressLike(__INST(handle))
 14360     if (__isExternalAddressLike(__INST(handle))
 14341      && __isSmallInteger(valueIndex)) {
 14361      && __isSmallInteger(valueIndex)) {
 14342         myKey = (HKEY)__externalAddressVal(__INST(handle));
 14362 	myKey = (HKEY)__externalAddressVal(__INST(handle));
 14343         if ((_retVal = RegEnumValueA(myKey, __intVal(valueIndex),
 14363 	if ((_retVal = RegEnumValueA(myKey, __intVal(valueIndex),
 14344                          nameBuffer, &nameSize,
 14364 			 nameBuffer, &nameSize,
 14345                          NULL,
 14365 			 NULL,
 14346                          &valueType,
 14366 			 &valueType,
 14347                          NULL, NULL)) == ERROR_SUCCESS) {
 14367 			 NULL, NULL)) == ERROR_SUCCESS) {
 14348             nameBuffer[nameSize] = '\0';
 14368 	    nameBuffer[nameSize] = '\0';
 14349             valueName = __MKSTRING(nameBuffer);
 14369 	    valueName = __MKSTRING(nameBuffer);
 14350         } else {
 14370 	} else {
 14351             if ((_retVal != ERROR_PATH_NOT_FOUND)
 14371 	    if ((_retVal != ERROR_PATH_NOT_FOUND)
 14352              && (_retVal != ERROR_FILE_NOT_FOUND)) {
 14372 	     && (_retVal != ERROR_FILE_NOT_FOUND)) {
 14353                 errorNumber = __MKSMALLINT(_retVal);
 14373 		errorNumber = __MKSMALLINT(_retVal);
 14354             }
 14374 	    }
 14355         }
 14375 	}
 14356     }
 14376     }
 14357 %}.
 14377 %}.
 14358     errorNumber notNil ifTrue:[
 14378     errorNumber notNil ifTrue:[
 14359         (OperatingSystem errorHolderForNumber:errorNumber) reportError.
 14379 	(OperatingSystem errorHolderForNumber:errorNumber) reportError.
 14360     ].
 14380     ].
 14361     ^ valueName
 14381     ^ valueName
 14362 
 14382 
 14363     "
 14383     "
 14364      |top sub|
 14384      |top sub|
 14368     "
 14388     "
 14369 !
 14389 !
 14370 
 14390 
 14371 valueNamed:aValueName
 14391 valueNamed:aValueName
 14372     "retrieve a value; the returned object depends upon the type:
 14392     "retrieve a value; the returned object depends upon the type:
 14373         REG_BINARY      -> ByteArray
 14393 	REG_BINARY      -> ByteArray
 14374         REG_SZ          -> String
 14394 	REG_SZ          -> String
 14375         REG_MULTI_SZ    -> Array of strings
 14395 	REG_MULTI_SZ    -> Array of strings
 14376         REG_DWORD       -> Integer
 14396 	REG_DWORD       -> Integer
 14377         REG_NONE        -> nil
 14397 	REG_NONE        -> nil
 14378     "
 14398     "
 14379 
 14399 
 14380     |stringArray retVal errorNumber|
 14400     |stringArray retVal errorNumber|
 14381 
 14401 
 14382 %{
 14402 %{
 14383     HKEY myKey;
 14403     HKEY myKey;
 14384     DWORD valueType;
 14404     DWORD valueType;
 14385     union {
 14405     union {
 14386         DWORD dWord;
 14406 	DWORD dWord;
 14387         unsigned char dWordBytes[4];
 14407 	unsigned char dWordBytes[4];
 14388         unsigned char smallDataBuffer[1024*128];
 14408 	unsigned char smallDataBuffer[1024*128];
 14389     } quickData;
 14409     } quickData;
 14390     int val;
 14410     int val;
 14391     DWORD dataSize = sizeof(quickData);
 14411     DWORD dataSize = sizeof(quickData);
 14392     unsigned char *dataBuffer = NULL;
 14412     unsigned char *dataBuffer = NULL;
 14393 #define xxUSE_UNICODE
 14413 #define xxUSE_UNICODE
 14399 # define CHAR             char
 14419 # define CHAR             char
 14400 #endif
 14420 #endif
 14401 
 14421 
 14402     if (__isExternalAddressLike(__INST(handle))
 14422     if (__isExternalAddressLike(__INST(handle))
 14403      && __isStringLike(aValueName)) {
 14423      && __isStringLike(aValueName)) {
 14404         int ret;
 14424 	int ret;
 14405 
 14425 
 14406         myKey = (HKEY)__externalAddressVal(__INST(handle));
 14426 	myKey = (HKEY)__externalAddressVal(__INST(handle));
 14407 
 14427 
 14408         /*
 14428 	/*
 14409          * try to get it with one call ...
 14429 	 * try to get it with one call ...
 14410          */
 14430 	 */
 14411         ret = RegQueryValueEx(myKey, __stringVal(aValueName),
 14431 	ret = RegQueryValueEx(myKey, __stringVal(aValueName),
 14412                          NULL,
 14432 			 NULL,
 14413                          &valueType,
 14433 			 &valueType,
 14414                          (char *)&quickData,
 14434 			 (char *)&quickData,
 14415                          &dataSize);
 14435 			 &dataSize);
 14416 #if 0
 14436 #if 0
 14417         console_printf("dataSize=%d\n", dataSize);
 14437 	console_printf("dataSize=%d\n", dataSize);
 14418 #endif
 14438 #endif
 14419         while (ret == ERROR_MORE_DATA) {
 14439 	while (ret == ERROR_MORE_DATA) {
 14420 #if 0
 14440 #if 0
 14421             console_printf("ERROR_MORE_DATA dataSize=%d\n", dataSize);
 14441 	    console_printf("ERROR_MORE_DATA dataSize=%d\n", dataSize);
 14422             console_printf("valueType=%d\n", valueType);
 14442 	    console_printf("valueType=%d\n", valueType);
 14423 #endif
 14443 #endif
 14424             /*
 14444 	    /*
 14425              * nope - need another one ...
 14445 	     * nope - need another one ...
 14426              */
 14446 	     */
 14427             if (myKey = HKEY_PERFORMANCE_DATA) {
 14447 	    if (myKey = HKEY_PERFORMANCE_DATA) {
 14428                 dataSize = dataSize * 2;
 14448 		dataSize = dataSize * 2;
 14429             }
 14449 	    }
 14430             switch (valueType) {
 14450 	    switch (valueType) {
 14431                 case REG_BINARY:
 14451 		case REG_BINARY:
 14432                 case REG_MULTI_SZ:
 14452 		case REG_MULTI_SZ:
 14433                     dataBuffer = malloc(dataSize);;
 14453 		    dataBuffer = malloc(dataSize);;
 14434                     break;
 14454 		    break;
 14435                 case REG_SZ:
 14455 		case REG_SZ:
 14436                     dataBuffer = malloc(dataSize);
 14456 		    dataBuffer = malloc(dataSize);
 14437                     break;
 14457 		    break;
 14438                 default:
 14458 		default:
 14439                     console_printf("RegistryEntry [warning]: unhandled valueType: %d\n", valueType);
 14459 		    console_printf("RegistryEntry [warning]: unhandled valueType: %d\n", valueType);
 14440                     break;
 14460 		    break;
 14441             }
 14461 	    }
 14442             if (dataBuffer) {
 14462 	    if (dataBuffer) {
 14443                 ret = RegQueryValueEx(myKey, __stringVal(aValueName),
 14463 		ret = RegQueryValueEx(myKey, __stringVal(aValueName),
 14444                                  NULL,
 14464 				 NULL,
 14445                                  &valueType,
 14465 				 &valueType,
 14446                                  dataBuffer,
 14466 				 dataBuffer,
 14447                                  &dataSize);
 14467 				 &dataSize);
 14448             } else {
 14468 	    } else {
 14449                 break;
 14469 		break;
 14450             }
 14470 	    }
 14451             if (myKey != HKEY_PERFORMANCE_DATA) {
 14471 	    if (myKey != HKEY_PERFORMANCE_DATA) {
 14452                 if (ret != ERROR_SUCCESS) break;
 14472 		if (ret != ERROR_SUCCESS) break;
 14453             }
 14473 	    }
 14454         }
 14474 	}
 14455 
 14475 
 14456         if (ret == ERROR_SUCCESS) {
 14476 	if (ret == ERROR_SUCCESS) {
 14457 #if 0
 14477 #if 0
 14458             console_printf("ERROR_SUCCESS dataSize=%d\n", dataSize);
 14478 	    console_printf("ERROR_SUCCESS dataSize=%d\n", dataSize);
 14459             console_printf("valueType=%d\n", valueType);
 14479 	    console_printf("valueType=%d\n", valueType);
 14460 #endif
 14480 #endif
 14461             switch (valueType) {
 14481 	    switch (valueType) {
 14462                 case REG_NONE:
 14482 		case REG_NONE:
 14463                     /* RETURN (@symbol(none));  */
 14483 		    /* RETURN (@symbol(none));  */
 14464                     retVal = nil;
 14484 		    retVal = nil;
 14465                     break;
 14485 		    break;
 14466 
 14486 
 14467                 case REG_BINARY:
 14487 		case REG_BINARY:
 14468                     retVal = __MKBYTEARRAY(dataBuffer ? dataBuffer : quickData.smallDataBuffer, dataSize);
 14488 		    retVal = __MKBYTEARRAY(dataBuffer ? dataBuffer : quickData.smallDataBuffer, dataSize);
 14469                     break;
 14489 		    break;
 14470 
 14490 
 14471                 case REG_SZ:
 14491 		case REG_SZ:
 14472                 case REG_EXPAND_SZ:
 14492 		case REG_EXPAND_SZ:
 14473 #ifdef USE_UNICODE
 14493 #ifdef USE_UNICODE
 14474                     retVal = __MKU16STRING(dataBuffer ? dataBuffer : quickData.smallDataBuffer);
 14494 		    retVal = __MKU16STRING(dataBuffer ? dataBuffer : quickData.smallDataBuffer);
 14475 #else
 14495 #else
 14476                     retVal = __MKSTRING(dataBuffer ? dataBuffer : quickData.smallDataBuffer);
 14496 		    retVal = __MKSTRING(dataBuffer ? dataBuffer : quickData.smallDataBuffer);
 14477 #endif
 14497 #endif
 14478                     break;
 14498 		    break;
 14479 
 14499 
 14480 #if 0
 14500 #if 0
 14481                 case REG_DWORD:
 14501 		case REG_DWORD:
 14482                     /* int in native format */
 14502 		    /* int in native format */
 14483                     retVal = __MKUINT(quickData.dWord);
 14503 		    retVal = __MKUINT(quickData.dWord);
 14484                     break;
 14504 		    break;
 14485 #endif
 14505 #endif
 14486                 case REG_DWORD_LITTLE_ENDIAN:
 14506 		case REG_DWORD_LITTLE_ENDIAN:
 14487                     val = quickData.dWordBytes[3];
 14507 		    val = quickData.dWordBytes[3];
 14488                     val = (val << 8) | quickData.dWordBytes[2];
 14508 		    val = (val << 8) | quickData.dWordBytes[2];
 14489                     val = (val << 8) | quickData.dWordBytes[1];
 14509 		    val = (val << 8) | quickData.dWordBytes[1];
 14490                     val = (val << 8) | quickData.dWordBytes[0];
 14510 		    val = (val << 8) | quickData.dWordBytes[0];
 14491                     retVal = __MKUINT(val);
 14511 		    retVal = __MKUINT(val);
 14492                     break;
 14512 		    break;
 14493 
 14513 
 14494                 case REG_DWORD_BIG_ENDIAN:
 14514 		case REG_DWORD_BIG_ENDIAN:
 14495                     val = quickData.dWordBytes[0];
 14515 		    val = quickData.dWordBytes[0];
 14496                     val = (val << 8) | quickData.dWordBytes[1];
 14516 		    val = (val << 8) | quickData.dWordBytes[1];
 14497                     val = (val << 8) | quickData.dWordBytes[2];
 14517 		    val = (val << 8) | quickData.dWordBytes[2];
 14498                     val = (val << 8) | quickData.dWordBytes[3];
 14518 		    val = (val << 8) | quickData.dWordBytes[3];
 14499                     retVal = __MKUINT(val);
 14519 		    retVal = __MKUINT(val);
 14500                     break;
 14520 		    break;
 14501 
 14521 
 14502                 case REG_MULTI_SZ:
 14522 		case REG_MULTI_SZ:
 14503                     {
 14523 		    {
 14504                         CHAR *cp, *cp0;
 14524 			CHAR *cp, *cp0;
 14505                         int ns, i;
 14525 			int ns, i;
 14506 
 14526 
 14507                         cp0 = dataBuffer ? dataBuffer : quickData.smallDataBuffer;
 14527 			cp0 = dataBuffer ? dataBuffer : quickData.smallDataBuffer;
 14508 #if 0
 14528 #if 0
 14509                         console_printf("**************\n");
 14529 			console_printf("**************\n");
 14510                         for (i=0;i<50;i++) {
 14530 			for (i=0;i<50;i++) {
 14511                           console_printf("%x ", cp0[i]);
 14531 			  console_printf("%x ", cp0[i]);
 14512                         }
 14532 			}
 14513                         console_printf("\n");
 14533 			console_printf("\n");
 14514                         for (i=0;i<50;i++) {
 14534 			for (i=0;i<50;i++) {
 14515                           if (cp0[i] == 0)
 14535 			  if (cp0[i] == 0)
 14516                             console_printf("\n");
 14536 			    console_printf("\n");
 14517                           else
 14537 			  else
 14518                             console_printf("%c", cp0[i]);
 14538 			    console_printf("%c", cp0[i]);
 14519                         }
 14539 			}
 14520                         console_printf("\n");
 14540 			console_printf("\n");
 14521                         console_printf("**************\n");
 14541 			console_printf("**************\n");
 14522 #endif
 14542 #endif
 14523                         cp = cp0;
 14543 			cp = cp0;
 14524                         ns = 0;
 14544 			ns = 0;
 14525                         while (*cp) {
 14545 			while (*cp) {
 14526                             while (*cp++) ;;
 14546 			    while (*cp++) ;;
 14527                             ns++;
 14547 			    ns++;
 14528                         }
 14548 			}
 14529                         stringArray = __ARRAY_NEW_INT(ns);
 14549 			stringArray = __ARRAY_NEW_INT(ns);
 14530 
 14550 
 14531                         i = 0;
 14551 			i = 0;
 14532                         while (*cp0) {
 14552 			while (*cp0) {
 14533                             OBJ s;
 14553 			    OBJ s;
 14534                             CHAR *cp;
 14554 			    CHAR *cp;
 14535 
 14555 
 14536                             cp = cp0;
 14556 			    cp = cp0;
 14537                             while (*cp++) ;;
 14557 			    while (*cp++) ;;
 14538 #ifdef USE_UNICODE
 14558 #ifdef USE_UNICODE
 14539                             s = __MKU16STRING(cp0); __ArrayInstPtr(stringArray)->a_element[i] = s; __STORE(stringArray, s);
 14559 			    s = __MKU16STRING(cp0); __ArrayInstPtr(stringArray)->a_element[i] = s; __STORE(stringArray, s);
 14540 #else
 14560 #else
 14541                             s = __MKSTRING(cp0); __ArrayInstPtr(stringArray)->a_element[i] = s; __STORE(stringArray, s);
 14561 			    s = __MKSTRING(cp0); __ArrayInstPtr(stringArray)->a_element[i] = s; __STORE(stringArray, s);
 14542 #endif
 14562 #endif
 14543                             cp0 = cp;
 14563 			    cp0 = cp;
 14544                             i++;
 14564 			    i++;
 14545                         }
 14565 			}
 14546                         retVal = stringArray;
 14566 			retVal = stringArray;
 14547                         break;
 14567 			break;
 14548                     }
 14568 		    }
 14549                 default:
 14569 		default:
 14550                     console_printf("RegistryEntry [warning]: unhandled valueType: %d\n", valueType);
 14570 		    console_printf("RegistryEntry [warning]: unhandled valueType: %d\n", valueType);
 14551                     break;
 14571 		    break;
 14552             }
 14572 	    }
 14553         } else {
 14573 	} else {
 14554             if ((ret != ERROR_PATH_NOT_FOUND)
 14574 	    if ((ret != ERROR_PATH_NOT_FOUND)
 14555              && (ret != ERROR_FILE_NOT_FOUND)) {
 14575 	     && (ret != ERROR_FILE_NOT_FOUND)) {
 14556                 errorNumber = __MKSMALLINT(ret);
 14576 		errorNumber = __MKSMALLINT(ret);
 14557             }
 14577 	    }
 14558         }
 14578 	}
 14559     }
 14579     }
 14560     if (dataBuffer) free(dataBuffer);
 14580     if (dataBuffer) free(dataBuffer);
 14561 %}.
 14581 %}.
 14562     errorNumber notNil ifTrue:[
 14582     errorNumber notNil ifTrue:[
 14563         (OperatingSystem errorHolderForNumber:errorNumber) reportError.
 14583 	(OperatingSystem errorHolderForNumber:errorNumber) reportError.
 14564     ].
 14584     ].
 14565 
 14585 
 14566     ^ retVal
 14586     ^ retVal
 14567 
 14587 
 14568     "
 14588     "
 14573     "
 14593     "
 14574 !
 14594 !
 14575 
 14595 
 14576 valueNamed:aValueName put:datum
 14596 valueNamed:aValueName put:datum
 14577     "store a value; the value type depends upon the stored value:
 14597     "store a value; the value type depends upon the stored value:
 14578         ByteArray       -> REG_BINARY
 14598 	ByteArray       -> REG_BINARY
 14579         String          -> REG_SZ
 14599 	String          -> REG_SZ
 14580         Array of string -> REG_MULTI_SZ
 14600 	Array of string -> REG_MULTI_SZ
 14581         Integer         -> REG_DWORD
 14601 	Integer         -> REG_DWORD
 14582         nil             -> REG_NONE
 14602 	nil             -> REG_NONE
 14583     "
 14603     "
 14584 
 14604 
 14585     |data stringArray errorNumber|
 14605     |data stringArray errorNumber|
 14586 %{
 14606 %{
 14587     HKEY myKey;
 14607     HKEY myKey;
 14591     unsigned char *dataPointer = NULL;
 14611     unsigned char *dataPointer = NULL;
 14592     int datumOk = 1, mustFreeData = 0;
 14612     int datumOk = 1, mustFreeData = 0;
 14593 
 14613 
 14594     if (__isExternalAddressLike(__INST(handle))
 14614     if (__isExternalAddressLike(__INST(handle))
 14595      && __isStringLike(aValueName)) {
 14615      && __isStringLike(aValueName)) {
 14596         int ret;
 14616 	int ret;
 14597         OBJ cls;
 14617 	OBJ cls;
 14598 
 14618 
 14599         myKey = (HKEY)__externalAddressVal(__INST(handle));
 14619 	myKey = (HKEY)__externalAddressVal(__INST(handle));
 14600 
 14620 
 14601         if (datum == nil) {
 14621 	if (datum == nil) {
 14602             valueType = REG_NONE;
 14622 	    valueType = REG_NONE;
 14603             dataSize = 0;
 14623 	    dataSize = 0;
 14604         } else if (__isSmallInteger(datum)) {
 14624 	} else if (__isSmallInteger(datum)) {
 14605             valueType = REG_DWORD;
 14625 	    valueType = REG_DWORD;
 14606             val = __intVal(datum);
 14626 	    val = __intVal(datum);
 14607             dataPointer = (unsigned char *)(&val);
 14627 	    dataPointer = (unsigned char *)(&val);
 14608             dataSize = sizeof(val);
 14628 	    dataSize = sizeof(val);
 14609         } else if (__isStringLike(datum)) {
 14629 	} else if (__isStringLike(datum)) {
 14610             valueType = REG_SZ;
 14630 	    valueType = REG_SZ;
 14611             dataPointer = __stringVal(datum);
 14631 	    dataPointer = __stringVal(datum);
 14612             dataSize = __stringSize(datum) + 1;
 14632 	    dataSize = __stringSize(datum) + 1;
 14613         } else if (__Class(datum) == ByteArray) {
 14633 	} else if (__Class(datum) == ByteArray) {
 14614             valueType = REG_BINARY;
 14634 	    valueType = REG_BINARY;
 14615             dataPointer = __ByteArrayInstPtr(datum)->ba_element;
 14635 	    dataPointer = __ByteArrayInstPtr(datum)->ba_element;
 14616             dataSize = __byteArraySize(datum);
 14636 	    dataSize = __byteArraySize(datum);
 14617         } else if (__Class(datum) == LargeInteger) {
 14637 	} else if (__Class(datum) == LargeInteger) {
 14618             valueType = REG_DWORD;
 14638 	    valueType = REG_DWORD;
 14619             val = __longIntVal(datum);
 14639 	    val = __longIntVal(datum);
 14620             if (val) {
 14640 	    if (val) {
 14621                 dataPointer = (unsigned char *)(&val);
 14641 		dataPointer = (unsigned char *)(&val);
 14622                 dataSize = sizeof(val);
 14642 		dataSize = sizeof(val);
 14623             } else {
 14643 	    } else {
 14624                 datumOk = 0;
 14644 		datumOk = 0;
 14625             }
 14645 	    }
 14626         } else if (__Class(datum) == Array) {
 14646 	} else if (__Class(datum) == Array) {
 14627             int i = 0, ns = 0, totalSize = 0;
 14647 	    int i = 0, ns = 0, totalSize = 0;
 14628 
 14648 
 14629             valueType = REG_MULTI_SZ;
 14649 	    valueType = REG_MULTI_SZ;
 14630 
 14650 
 14631             /*
 14651 	    /*
 14632              * must allocate a local buffer
 14652 	     * must allocate a local buffer
 14633              * find size ...
 14653 	     * find size ...
 14634              */
 14654 	     */
 14635             for (i=0; i<__arraySize(datum); i++) {
 14655 	    for (i=0; i<__arraySize(datum); i++) {
 14636                 OBJ s = __ArrayInstPtr(datum)->a_element[i];
 14656 		OBJ s = __ArrayInstPtr(datum)->a_element[i];
 14637 
 14657 
 14638                 if (__isStringLike(s)) {
 14658 		if (__isStringLike(s)) {
 14639                     totalSize += __stringSize(s) + 1;
 14659 		    totalSize += __stringSize(s) + 1;
 14640                 } else {
 14660 		} else {
 14641                     datumOk = 0;
 14661 		    datumOk = 0;
 14642                     break;
 14662 		    break;
 14643                 }
 14663 		}
 14644                 ns++;
 14664 		ns++;
 14645             }
 14665 	    }
 14646             if (datumOk) {
 14666 	    if (datumOk) {
 14647                 char *cp;
 14667 		char *cp;
 14648 
 14668 
 14649                 /*
 14669 		/*
 14650                  * allocate and fill...
 14670 		 * allocate and fill...
 14651                  */
 14671 		 */
 14652                 totalSize ++;
 14672 		totalSize ++;
 14653                 dataPointer = (char *)(malloc(totalSize));
 14673 		dataPointer = (char *)(malloc(totalSize));
 14654                 mustFreeData = 1;
 14674 		mustFreeData = 1;
 14655                 cp = dataPointer;
 14675 		cp = dataPointer;
 14656                 for (i=0; i<__arraySize(datum); i++) {
 14676 		for (i=0; i<__arraySize(datum); i++) {
 14657                     OBJ s = __ArrayInstPtr(datum)->a_element[i];
 14677 		    OBJ s = __ArrayInstPtr(datum)->a_element[i];
 14658 
 14678 
 14659                     strcpy(cp, __stringVal(s));
 14679 		    strcpy(cp, __stringVal(s));
 14660                     cp += __stringSize(s);
 14680 		    cp += __stringSize(s);
 14661                     *cp++ = '\0';
 14681 		    *cp++ = '\0';
 14662                 }
 14682 		}
 14663                 *cp++ = '\0';
 14683 		*cp++ = '\0';
 14664                 dataSize = totalSize;
 14684 		dataSize = totalSize;
 14665             }
 14685 	    }
 14666         } else {
 14686 	} else {
 14667             datumOk = 0;
 14687 	    datumOk = 0;
 14668         }
 14688 	}
 14669 
 14689 
 14670         if (datumOk) {
 14690 	if (datumOk) {
 14671             ret = RegSetValueExA(myKey, __stringVal(aValueName),
 14691 	    ret = RegSetValueExA(myKey, __stringVal(aValueName),
 14672                                 0, valueType,
 14692 				0, valueType,
 14673                                 dataPointer, dataSize);
 14693 				dataPointer, dataSize);
 14674             if (mustFreeData) {
 14694 	    if (mustFreeData) {
 14675                 free(dataPointer);
 14695 		free(dataPointer);
 14676             }
 14696 	    }
 14677             if (ret == ERROR_SUCCESS) {
 14697 	    if (ret == ERROR_SUCCESS) {
 14678                 RETURN (true);
 14698 		RETURN (true);
 14679             }
 14699 	    }
 14680             if ((ret != ERROR_PATH_NOT_FOUND)
 14700 	    if ((ret != ERROR_PATH_NOT_FOUND)
 14681              && (ret != ERROR_FILE_NOT_FOUND)) {
 14701 	     && (ret != ERROR_FILE_NOT_FOUND)) {
 14682                 errorNumber = __MKSMALLINT(ret);
 14702 		errorNumber = __MKSMALLINT(ret);
 14683             }
 14703 	    }
 14684         }
 14704 	}
 14685     }
 14705     }
 14686 %}.
 14706 %}.
 14687     errorNumber notNil ifTrue:[
 14707     errorNumber notNil ifTrue:[
 14688         (OperatingSystem errorHolderForNumber:errorNumber) reportError.
 14708 	(OperatingSystem errorHolderForNumber:errorNumber) reportError.
 14689     ].
 14709     ].
 14690     ^ false
 14710     ^ false
 14691 
 14711 
 14692     "
 14712     "
 14693      |key|
 14713      |key|
 14704 
 14724 
 14705     |idx subEntry|
 14725     |idx subEntry|
 14706 
 14726 
 14707     idx := 0.
 14727     idx := 0.
 14708     [true] whileTrue:[
 14728     [true] whileTrue:[
 14709         subEntry := self subKeyAtIndex:idx.
 14729 	subEntry := self subKeyAtIndex:idx.
 14710         subEntry isNil ifTrue:[
 14730 	subEntry isNil ifTrue:[
 14711             ^self
 14731 	    ^self
 14712         ].
 14732 	].
 14713         aBlock value:subEntry.
 14733 	aBlock value:subEntry.
 14714         subEntry allSubKeysDo:aBlock.
 14734 	subEntry allSubKeysDo:aBlock.
 14715         subEntry close.
 14735 	subEntry close.
 14716         idx := idx + 1.
 14736 	idx := idx + 1.
 14717     ]
 14737     ]
 14718 
 14738 
 14719     "
 14739     "
 14720      |top sub|
 14740      |top sub|
 14721 
 14741 
 14722      top := self key:'HKEY_LOCAL_MACHINE'.
 14742      top := self key:'HKEY_LOCAL_MACHINE'.
 14723      top allSubKeysDo:[:subEntry |
 14743      top allSubKeysDo:[:subEntry |
 14724         Transcript showCR:subEntry path
 14744 	Transcript showCR:subEntry path
 14725      ]
 14745      ]
 14726     "
 14746     "
 14727 !
 14747 !
 14728 
 14748 
 14729 subKeys
 14749 subKeys
 14751 
 14771 
 14752     |idx subEntry|
 14772     |idx subEntry|
 14753 
 14773 
 14754     idx := 0.
 14774     idx := 0.
 14755     [true] whileTrue:[
 14775     [true] whileTrue:[
 14756         subEntry := self subKeyAtIndex:idx.
 14776 	subEntry := self subKeyAtIndex:idx.
 14757         subEntry isNil ifTrue:[
 14777 	subEntry isNil ifTrue:[
 14758             ^self
 14778 	    ^self
 14759         ].
 14779 	].
 14760         aBlock value:subEntry.
 14780 	aBlock value:subEntry.
 14761         subEntry close.
 14781 	subEntry close.
 14762         idx := idx + 1.
 14782 	idx := idx + 1.
 14763     ]
 14783     ]
 14764 
 14784 
 14765     "
 14785     "
 14766      |top sub|
 14786      |top sub|
 14767 
 14787 
 14768      top := self key:'HKEY_LOCAL_MACHINE'.
 14788      top := self key:'HKEY_LOCAL_MACHINE'.
 14769      top subKeysDo:[:subEntry |
 14789      top subKeysDo:[:subEntry |
 14770         Transcript showCR:subEntry path
 14790 	Transcript showCR:subEntry path
 14771      ]
 14791      ]
 14772     "
 14792     "
 14773 !
 14793 !
 14774 
 14794 
 14775 valueNames
 14795 valueNames
 14776     "evaluate aBlock for all value names"
 14796     "evaluate aBlock for all value names"
 14777 
 14797 
 14778     ^ Array streamContents:[:s |
 14798     ^ Array streamContents:[:s |
 14779         self valueNamesDo:[:nm | s nextPut:nm]
 14799 	self valueNamesDo:[:nm | s nextPut:nm]
 14780     ].
 14800     ].
 14781 
 14801 
 14782     "Created: / 18-01-2011 / 20:24:52 / cg"
 14802     "Created: / 18-01-2011 / 20:24:52 / cg"
 14783 !
 14803 !
 14784 
 14804 
 14785 valueNamesAndValuesDo:aBlock
 14805 valueNamesAndValuesDo:aBlock
 14786     "evaluate aBlock for all value names"
 14806     "evaluate aBlock for all value names"
 14787 
 14807 
 14788     self valueNamesDo:[:nm |
 14808     self valueNamesDo:[:nm |
 14789         aBlock value:nm value:(self valueNamed:nm)
 14809 	aBlock value:nm value:(self valueNamed:nm)
 14790     ]
 14810     ]
 14791 
 14811 
 14792     "
 14812     "
 14793      |key|
 14813      |key|
 14794 
 14814 
 14795      key := self key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'.
 14815      key := self key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'.
 14796      key valueNamesAndValuesDo:[:nm :val |
 14816      key valueNamesAndValuesDo:[:nm :val |
 14797         Transcript showCR:(nm , ' -> ' , val storeString).
 14817 	Transcript showCR:(nm , ' -> ' , val storeString).
 14798      ]
 14818      ]
 14799     "
 14819     "
 14800 !
 14820 !
 14801 
 14821 
 14802 valueNamesDo:aBlock
 14822 valueNamesDo:aBlock
 14804 
 14824 
 14805     |idx valueName|
 14825     |idx valueName|
 14806 
 14826 
 14807     idx := 0.
 14827     idx := 0.
 14808     [true] whileTrue:[
 14828     [true] whileTrue:[
 14809         valueName := self valueNameAtIndex:idx.
 14829 	valueName := self valueNameAtIndex:idx.
 14810         valueName isNil ifTrue:[
 14830 	valueName isNil ifTrue:[
 14811             ^self
 14831 	    ^self
 14812         ].
 14832 	].
 14813         aBlock value:valueName.
 14833 	aBlock value:valueName.
 14814         idx := idx + 1.
 14834 	idx := idx + 1.
 14815     ]
 14835     ]
 14816 ! !
 14836 ! !
 14817 
 14837 
 14818 !Win32OperatingSystem::RegistryEntry methodsFor:'instance release'!
 14838 !Win32OperatingSystem::RegistryEntry methodsFor:'instance release'!
 14819 
 14839 
 14829 
 14849 
 14830 %{
 14850 %{
 14831     HKEY myKey;
 14851     HKEY myKey;
 14832 
 14852 
 14833     if (__isExternalAddressLike(__INST(handle))) {
 14853     if (__isExternalAddressLike(__INST(handle))) {
 14834         myKey = (HKEY)(__externalAddressVal(__INST(handle)));
 14854 	myKey = (HKEY)(__externalAddressVal(__INST(handle)));
 14835         __INST(handle) = nil;
 14855 	__INST(handle) = nil;
 14836         RegCloseKey(myKey);
 14856 	RegCloseKey(myKey);
 14837     }
 14857     }
 14838 %}
 14858 %}
 14839 !
 14859 !
 14840 
 14860 
 14841 finalizationLobby
 14861 finalizationLobby
 14844 
 14864 
 14845 finalize
 14865 finalize
 14846     "some entry has been collected - close it"
 14866     "some entry has been collected - close it"
 14847 
 14867 
 14848     handle notNil ifTrue:[
 14868     handle notNil ifTrue:[
 14849         self closeKey.
 14869 	self closeKey.
 14850     ]
 14870     ]
 14851 
 14871 
 14852     "Created: / 19.5.1999 / 22:39:52 / cg"
 14872     "Created: / 19.5.1999 / 22:39:52 / cg"
 14853     "Modified: / 19.5.1999 / 22:44:50 / cg"
 14873     "Modified: / 19.5.1999 / 22:44:50 / cg"
 14854 ! !
 14874 ! !
 14855 
 14875 
 14856 !Win32OperatingSystem::RegistryEntry methodsFor:'printing & storing'!
 14876 !Win32OperatingSystem::RegistryEntry methodsFor:'printing & storing'!
 14857 
 14877 
 14858 printOn:aStream
 14878 printOn:aStream
 14859     aStream
 14879     aStream
 14860         nextPutAll:self className;
 14880 	nextPutAll:self className;
 14861         nextPut:$(;
 14881 	nextPut:$(;
 14862         nextPutAll:path;
 14882 	nextPutAll:path;
 14863         nextPut:$).
 14883 	nextPut:$).
 14864 ! !
 14884 ! !
 14865 
 14885 
 14866 !Win32OperatingSystem::RegistryEntry methodsFor:'private'!
 14886 !Win32OperatingSystem::RegistryEntry methodsFor:'private'!
 14867 
 14887 
 14868 setHandle:aHandle path:aPathString
 14888 setHandle:aHandle path:aPathString
 14881     HKEY key;
 14901     HKEY key;
 14882     OBJ t;
 14902     OBJ t;
 14883 
 14903 
 14884     key = __longIntVal(integerHandleValue);
 14904     key = __longIntVal(integerHandleValue);
 14885     if (! key) {
 14905     if (! key) {
 14886         RETURN (nil);
 14906 	RETURN (nil);
 14887     }
 14907     }
 14888 
 14908 
 14889     t = __MKEXTERNALADDRESS(key); __INST(handle) = t; __STORE(self, t);
 14909     t = __MKEXTERNALADDRESS(key); __INST(handle) = t; __STORE(self, t);
 14890 %}.
 14910 %}.
 14891 
 14911 
 14963     int bufferSize;
 14983     int bufferSize;
 14964     char miniBuffer[32];
 14984     char miniBuffer[32];
 14965     BOOL ok;
 14985     BOOL ok;
 14966 
 14986 
 14967     if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) {
 14987     if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) {
 14968         errSym = @symbol(errorNotOpen);
 14988 	errSym = @symbol(errorNotOpen);
 14969         goto bad;
 14989 	goto bad;
 14970     }
 14990     }
 14971     if (! __bothSmallInteger(count, firstIndex)) {
 14991     if (! __bothSmallInteger(count, firstIndex)) {
 14972         errSym = @symbol(badArgument);
 14992 	errSym = @symbol(badArgument);
 14973         goto bad;
 14993 	goto bad;
 14974     }
 14994     }
 14975     cntWanted = __smallIntegerVal(count);
 14995     cntWanted = __smallIntegerVal(count);
 14976     if (cntWanted <= 0) {
 14996     if (cntWanted <= 0) {
 14977         errSym = @symbol(badCount);
 14997 	errSym = @symbol(badCount);
 14978         goto bad;
 14998 	goto bad;
 14979     }
 14999     }
 14980     offs = __smallIntegerVal(firstIndex) - 1;
 15000     offs = __smallIntegerVal(firstIndex) - 1;
 14981     if (offs < 0) {
 15001     if (offs < 0) {
 14982         errSym = @symbol(badOffset);
 15002 	errSym = @symbol(badOffset);
 14983         goto bad;
 15003 	goto bad;
 14984     }
 15004     }
 14985 
 15005 
 14986     bufferIsExternalBytes = __isExternalBytesLike(aByteBuffer);
 15006     bufferIsExternalBytes = __isExternalBytesLike(aByteBuffer);
 14987     if (! bufferIsExternalBytes) {
 15007     if (! bufferIsExternalBytes) {
 14988         if (__isByteArray(aByteBuffer)) {
 15008 	if (__isByteArray(aByteBuffer)) {
 14989             bufferSize = __byteArraySize(aByteBuffer);
 15009 	    bufferSize = __byteArraySize(aByteBuffer);
 14990         } else if (__isString(aByteBuffer)) {  // not isStringLike here !
 15010 	} else if (__isString(aByteBuffer)) {  // not isStringLike here !
 14991             bufferSize = __stringSize(aByteBuffer);
 15011 	    bufferSize = __stringSize(aByteBuffer);
 14992         } else {
 15012 	} else {
 14993             errSym = @symbol(badBuffer);
 15013 	    errSym = @symbol(badBuffer);
 14994             goto bad;
 15014 	    goto bad;
 14995         }
 15015 	}
 14996         if (bufferSize < (cntWanted + offs)) {
 15016 	if (bufferSize < (cntWanted + offs)) {
 14997             errSym = @symbol(badBufferSize);
 15017 	    errSym = @symbol(badBufferSize);
 14998             goto bad;
 15018 	    goto bad;
 14999         }
 15019 	}
 15000         if (cntWanted <= sizeof(miniBuffer)) {
 15020 	if (cntWanted <= sizeof(miniBuffer)) {
 15001             extPtr = miniBuffer;
 15021 	    extPtr = miniBuffer;
 15002         } else {
 15022 	} else {
 15003             extPtr = malloc(cntWanted);
 15023 	    extPtr = malloc(cntWanted);
 15004             mustFreeBuffer = 1;
 15024 	    mustFreeBuffer = 1;
 15005         }
 15025 	}
 15006     } else {
 15026     } else {
 15007         OBJ sz;
 15027 	OBJ sz;
 15008 
 15028 
 15009         extPtr = (char *)(__externalBytesAddress(aByteBuffer));
 15029 	extPtr = (char *)(__externalBytesAddress(aByteBuffer));
 15010         sz = __externalBytesSize(aByteBuffer);
 15030 	sz = __externalBytesSize(aByteBuffer);
 15011         if (! __isSmallInteger(sz)) {
 15031 	if (! __isSmallInteger(sz)) {
 15012             errSym = @symbol(badBufferSize);
 15032 	    errSym = @symbol(badBufferSize);
 15013             goto bad;
 15033 	    goto bad;
 15014         }
 15034 	}
 15015         bufferSize = __smallIntegerVal(sz);
 15035 	bufferSize = __smallIntegerVal(sz);
 15016         if (bufferSize < (cntWanted + offs)) {
 15036 	if (bufferSize < (cntWanted + offs)) {
 15017             errSym = @symbol(badBufferSize);
 15037 	    errSym = @symbol(badBufferSize);
 15018             goto bad;
 15038 	    goto bad;
 15019         }
 15039 	}
 15020         extPtr = extPtr + offs;
 15040 	extPtr = extPtr + offs;
 15021     }
 15041     }
 15022 
 15042 
 15023     do {
 15043     do {
 15024         __threadErrno = 0;
 15044 	__threadErrno = 0;
 15025         ok = STX_API_NOINT_CALL5( "ReadFile", ReadFile, hFile, extPtr, cntWanted, &cntRead, 0 /* lpOverlapped */);
 15045 	ok = STX_API_NOINT_CALL5( "ReadFile", ReadFile, hFile, extPtr, cntWanted, &cntRead, 0 /* lpOverlapped */);
 15026     } while(__threadErrno == EINTR);
 15046     } while(__threadErrno == EINTR);
 15027 
 15047 
 15028     if (ok == TRUE) {
 15048     if (ok == TRUE) {
 15029         if (! bufferIsExternalBytes) {
 15049 	if (! bufferIsExternalBytes) {
 15030             /* copy over */
 15050 	    /* copy over */
 15031             memcpy(__byteArrayVal(aByteBuffer)+offs, extPtr, cntRead);
 15051 	    memcpy(__byteArrayVal(aByteBuffer)+offs, extPtr, cntRead);
 15032             if (mustFreeBuffer) {
 15052 	    if (mustFreeBuffer) {
 15033                 free(extPtr);
 15053 		free(extPtr);
 15034             }
 15054 	    }
 15035         }
 15055 	}
 15036         RETURN (__mkSmallInteger(cntRead));
 15056 	RETURN (__mkSmallInteger(cntRead));
 15037     }
 15057     }
 15038     errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
 15058     errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
 15039 
 15059 
 15040 bad: ;
 15060 bad: ;
 15041     if (mustFreeBuffer) {
 15061     if (mustFreeBuffer) {
 15042         free(extPtr);
 15062 	free(extPtr);
 15043     }
 15063     }
 15044 %}.
 15064 %}.
 15045 
 15065 
 15046     errorNumber isNil ifTrue:[
 15066     errorNumber isNil ifTrue:[
 15047         self error:'invalid argument(s): ', errSym.
 15067 	self error:'invalid argument(s): ', errSym.
 15048     ] ifFalse:[
 15068     ] ifFalse:[
 15049         (OperatingSystem errorHolderForNumber:errorNumber) reportError
 15069 	(OperatingSystem errorHolderForNumber:errorNumber) reportError
 15050     ].
 15070     ].
 15051 
 15071 
 15052     "
 15072     "
 15053      |h buff n|
 15073      |h buff n|
 15054 
 15074 
 15068     HANDLE hFile = (HANDLE)(__externalAddressVal(self));
 15088     HANDLE hFile = (HANDLE)(__externalAddressVal(self));
 15069     DWORD res;
 15089     DWORD res;
 15070     INT t;
 15090     INT t;
 15071 
 15091 
 15072     if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) {
 15092     if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) {
 15073         errSym = @symbol(errorNotOpen);
 15093 	errSym = @symbol(errorNotOpen);
 15074         goto bad;
 15094 	goto bad;
 15075     }
 15095     }
 15076 
 15096 
 15077 #if 0
 15097 #if 0
 15078     if (ioctlsocket((SOCKET)hFile, FIONREAD, &res)==0) {
 15098     if (ioctlsocket((SOCKET)hFile, FIONREAD, &res)==0) {
 15079         /* its a socket */
 15099 	/* its a socket */
 15080         if (res > 0) {
 15100 	if (res > 0) {
 15081             RETURN ( false );
 15101 	    RETURN ( false );
 15082         }
 15102 	}
 15083     }
 15103     }
 15084     if (PeekNamedPipe(hFile, 0, 0, 0, &res, 0)) {
 15104     if (PeekNamedPipe(hFile, 0, 0, 0, &res, 0)) {
 15085         /* its a namedPipe */
 15105 	/* its a namedPipe */
 15086         if (res > 0) {
 15106 	if (res > 0) {
 15087             RETURN ( false );
 15107 	    RETURN ( false );
 15088         }
 15108 	}
 15089     }
 15109     }
 15090 #endif
 15110 #endif
 15091     if (__isSmallInteger(millis)) {
 15111     if (__isSmallInteger(millis)) {
 15092         t = __intVal(millis);
 15112 	t = __intVal(millis);
 15093     } else {
 15113     } else {
 15094         t = INFINITE;
 15114 	t = INFINITE;
 15095     }
 15115     }
 15096 
 15116 
 15097     do {
 15117     do {
 15098         __threadErrno = 0;
 15118 	__threadErrno = 0;
 15099         res = WaitForSingleObject(hFile, t);
 15119 	res = WaitForSingleObject(hFile, t);
 15100     } while (__threadErrno == EINTR);
 15120     } while (__threadErrno == EINTR);
 15101 
 15121 
 15102     switch (res) {
 15122     switch (res) {
 15103         case WAIT_OBJECT_0:
 15123 	case WAIT_OBJECT_0:
 15104             /* signalled */
 15124 	    /* signalled */
 15105             RETURN ( false );
 15125 	    RETURN ( false );
 15106 
 15126 
 15107         case WAIT_TIMEOUT:
 15127 	case WAIT_TIMEOUT:
 15108             /* signalled */
 15128 	    /* signalled */
 15109             RETURN ( true );
 15129 	    RETURN ( true );
 15110 
 15130 
 15111         default:
 15131 	default:
 15112         case WAIT_ABANDONED:
 15132 	case WAIT_ABANDONED:
 15113             errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
 15133 	    errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
 15114             goto bad;
 15134 	    goto bad;
 15115     }
 15135     }
 15116 
 15136 
 15117 bad: ;
 15137 bad: ;
 15118 %}.
 15138 %}.
 15119     "
 15139     "
 15124     ^ self primitiveFailed
 15144     ^ self primitiveFailed
 15125 !
 15145 !
 15126 
 15146 
 15127 seekTo:newPosition from:whence
 15147 seekTo:newPosition from:whence
 15128     "whence is one of:
 15148     "whence is one of:
 15129         #begin
 15149 	#begin
 15130         #current
 15150 	#current
 15131         #end
 15151 	#end
 15132     "
 15152     "
 15133 
 15153 
 15134     |errSym errorNumber|
 15154     |errSym errorNumber|
 15135 
 15155 
 15136 %{
 15156 %{
 15138     DWORD moveHow;
 15158     DWORD moveHow;
 15139     LONG posLo, posHi = 0;
 15159     LONG posLo, posHi = 0;
 15140     __uint64__ pos64, newPos64;
 15160     __uint64__ pos64, newPos64;
 15141 
 15161 
 15142     if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) {
 15162     if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) {
 15143         errSym = @symbol(errorNotOpen);
 15163 	errSym = @symbol(errorNotOpen);
 15144         goto bad;
 15164 	goto bad;
 15145     }
 15165     }
 15146 
 15166 
 15147     if (whence == @symbol(begin)) {
 15167     if (whence == @symbol(begin)) {
 15148         moveHow = FILE_BEGIN;
 15168 	moveHow = FILE_BEGIN;
 15149     } else if (whence == @symbol(current)) {
 15169     } else if (whence == @symbol(current)) {
 15150         moveHow = FILE_CURRENT;
 15170 	moveHow = FILE_CURRENT;
 15151     } else if (whence == @symbol(end)) {
 15171     } else if (whence == @symbol(end)) {
 15152         moveHow = FILE_END;
 15172 	moveHow = FILE_END;
 15153     } else {
 15173     } else {
 15154         errSym = @symbol(badArgument2);
 15174 	errSym = @symbol(badArgument2);
 15155         goto bad;
 15175 	goto bad;
 15156     }
 15176     }
 15157 
 15177 
 15158     if (__signedLong64IntVal(newPosition, &pos64) == 0) {
 15178     if (__signedLong64IntVal(newPosition, &pos64) == 0) {
 15159         errSym = @symbol(badArgument);
 15179 	errSym = @symbol(badArgument);
 15160         goto bad;
 15180 	goto bad;
 15161     }
 15181     }
 15162     posLo = pos64.lo;
 15182     posLo = pos64.lo;
 15163     posHi = pos64.hi;
 15183     posHi = pos64.hi;
 15164 
 15184 
 15165     posLo = SetFilePointer(hFile, posLo, &posHi, moveHow);
 15185     posLo = SetFilePointer(hFile, posLo, &posHi, moveHow);
 15166     if (posLo == 0xFFFFFFFF) {
 15186     if (posLo == 0xFFFFFFFF) {
 15167         int lastError;
 15187 	int lastError;
 15168 
 15188 
 15169         /* can be either an error, or a valid low-word */
 15189 	/* can be either an error, or a valid low-word */
 15170         lastError = GetLastError();
 15190 	lastError = GetLastError();
 15171         if (lastError != NO_ERROR) {
 15191 	if (lastError != NO_ERROR) {
 15172             errorNumber = __mkSmallInteger( __WIN32_ERR(lastError) );
 15192 	    errorNumber = __mkSmallInteger( __WIN32_ERR(lastError) );
 15173             goto bad;
 15193 	    goto bad;
 15174         }
 15194 	}
 15175     }
 15195     }
 15176 
 15196 
 15177     if (posHi == 0) {
 15197     if (posHi == 0) {
 15178         RETURN (__MKUINT( posLo ));
 15198 	RETURN (__MKUINT( posLo ));
 15179     }
 15199     }
 15180     newPos64.lo = posLo;
 15200     newPos64.lo = posLo;
 15181     newPos64.hi = posHi;
 15201     newPos64.hi = posHi;
 15182 
 15202 
 15183     RETURN ( __MKUINT64(&newPos64) );
 15203     RETURN ( __MKUINT64(&newPos64) );
 15184 
 15204 
 15185 bad: ;
 15205 bad: ;
 15186 %}.
 15206 %}.
 15187 
 15207 
 15188     errorNumber isNil ifTrue:[
 15208     errorNumber isNil ifTrue:[
 15189         self error:'invalid argument(s): ', errSym.
 15209 	self error:'invalid argument(s): ', errSym.
 15190     ] ifFalse:[
 15210     ] ifFalse:[
 15191         (OperatingSystem errorHolderForNumber:errorNumber) reportError
 15211 	(OperatingSystem errorHolderForNumber:errorNumber) reportError
 15192     ].
 15212     ].
 15193 !
 15213 !
 15194 
 15214 
 15195 writeBytes:count from:aByteBuffer startingAt:firstIndex
 15215 writeBytes:count from:aByteBuffer startingAt:firstIndex
 15196     "write count bytes from a byte-buffer;
 15216     "write count bytes from a byte-buffer;
 15207     int bufferSize;
 15227     int bufferSize;
 15208     char miniBuffer[32];
 15228     char miniBuffer[32];
 15209     BOOL ok;
 15229     BOOL ok;
 15210 
 15230 
 15211     if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) {
 15231     if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) {
 15212         errSym = @symbol(errorNotOpen);
 15232 	errSym = @symbol(errorNotOpen);
 15213         goto bad;
 15233 	goto bad;
 15214     }
 15234     }
 15215     if (! __bothSmallInteger(count, firstIndex)) {
 15235     if (! __bothSmallInteger(count, firstIndex)) {
 15216         errSym = @symbol(badArgument);
 15236 	errSym = @symbol(badArgument);
 15217         goto bad;
 15237 	goto bad;
 15218     }
 15238     }
 15219     cntWanted = __smallIntegerVal(count);
 15239     cntWanted = __smallIntegerVal(count);
 15220     if (cntWanted <= 0) {
 15240     if (cntWanted <= 0) {
 15221         errSym = @symbol(badCount);
 15241 	errSym = @symbol(badCount);
 15222         goto bad;
 15242 	goto bad;
 15223     }
 15243     }
 15224     offs = __smallIntegerVal(firstIndex) - 1;
 15244     offs = __smallIntegerVal(firstIndex) - 1;
 15225     if (offs < 0) {
 15245     if (offs < 0) {
 15226         errSym = @symbol(badOffset);
 15246 	errSym = @symbol(badOffset);
 15227         goto bad;
 15247 	goto bad;
 15228     }
 15248     }
 15229 
 15249 
 15230     bufferIsExternalBytes = __isExternalBytesLike(aByteBuffer);
 15250     bufferIsExternalBytes = __isExternalBytesLike(aByteBuffer);
 15231     if (! bufferIsExternalBytes) {
 15251     if (! bufferIsExternalBytes) {
 15232         if (__isByteArray(aByteBuffer)) {
 15252 	if (__isByteArray(aByteBuffer)) {
 15233             bufferSize = __byteArraySize(aByteBuffer);
 15253 	    bufferSize = __byteArraySize(aByteBuffer);
 15234         } else if (__isStringLike(aByteBuffer)) {
 15254 	} else if (__isStringLike(aByteBuffer)) {
 15235             bufferSize = __stringSize(aByteBuffer);
 15255 	    bufferSize = __stringSize(aByteBuffer);
 15236         } else {
 15256 	} else {
 15237             errSym = @symbol(badBuffer);
 15257 	    errSym = @symbol(badBuffer);
 15238             goto bad;
 15258 	    goto bad;
 15239         }
 15259 	}
 15240         if (bufferSize < (cntWanted + offs)) {
 15260 	if (bufferSize < (cntWanted + offs)) {
 15241             errSym = @symbol(badBufferSize);
 15261 	    errSym = @symbol(badBufferSize);
 15242             goto bad;
 15262 	    goto bad;
 15243         }
 15263 	}
 15244         if (cntWanted <= sizeof(miniBuffer)) {
 15264 	if (cntWanted <= sizeof(miniBuffer)) {
 15245             extPtr = miniBuffer;
 15265 	    extPtr = miniBuffer;
 15246         } else {
 15266 	} else {
 15247             extPtr = malloc(cntWanted);
 15267 	    extPtr = malloc(cntWanted);
 15248             mustFreeBuffer = 1;
 15268 	    mustFreeBuffer = 1;
 15249         }
 15269 	}
 15250         memcpy(extPtr, __byteArrayVal(aByteBuffer)+offs, cntWanted);
 15270 	memcpy(extPtr, __byteArrayVal(aByteBuffer)+offs, cntWanted);
 15251     } else {
 15271     } else {
 15252         extPtr = (char *)(__externalBytesAddress(aByteBuffer));
 15272 	extPtr = (char *)(__externalBytesAddress(aByteBuffer));
 15253         bufferSize = __externalBytesSize(aByteBuffer);
 15273 	bufferSize = __externalBytesSize(aByteBuffer);
 15254         if (! __isSmallInteger(bufferSize)) {
 15274 	if (! __isSmallInteger(bufferSize)) {
 15255             errSym = @symbol(badBufferSize);
 15275 	    errSym = @symbol(badBufferSize);
 15256             goto bad;
 15276 	    goto bad;
 15257         }
 15277 	}
 15258         bufferSize = __smallIntegerVal(bufferSize);
 15278 	bufferSize = __smallIntegerVal(bufferSize);
 15259         if (bufferSize < (cntWanted + offs)) {
 15279 	if (bufferSize < (cntWanted + offs)) {
 15260             errSym = @symbol(badBufferSize);
 15280 	    errSym = @symbol(badBufferSize);
 15261             goto bad;
 15281 	    goto bad;
 15262         }
 15282 	}
 15263         extPtr = extPtr + offs;
 15283 	extPtr = extPtr + offs;
 15264     }
 15284     }
 15265 
 15285 
 15266     do {
 15286     do {
 15267         __threadErrno = 0;
 15287 	__threadErrno = 0;
 15268         ok = STX_API_NOINT_CALL5( "WriteFile", WriteFile, hFile, extPtr, cntWanted, &cntWritten, 0 /* lpOverlapped */);
 15288 	ok = STX_API_NOINT_CALL5( "WriteFile", WriteFile, hFile, extPtr, cntWanted, &cntWritten, 0 /* lpOverlapped */);
 15269     } while(__threadErrno == EINTR);
 15289     } while(__threadErrno == EINTR);
 15270 
 15290 
 15271     if (ok == TRUE) {
 15291     if (ok == TRUE) {
 15272         if (mustFreeBuffer) {
 15292 	if (mustFreeBuffer) {
 15273             free(extPtr);
 15293 	    free(extPtr);
 15274         }
 15294 	}
 15275         RETURN (__mkSmallInteger(cntWritten));
 15295 	RETURN (__mkSmallInteger(cntWritten));
 15276     }
 15296     }
 15277     errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
 15297     errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
 15278 
 15298 
 15279 bad: ;
 15299 bad: ;
 15280     if (mustFreeBuffer) {
 15300     if (mustFreeBuffer) {
 15281         free(extPtr);
 15301 	free(extPtr);
 15282     }
 15302     }
 15283 %}.
 15303 %}.
 15284     errorNumber isNil ifTrue:[
 15304     errorNumber isNil ifTrue:[
 15285         self error:'invalid argument(s): ', errSym.
 15305 	self error:'invalid argument(s): ', errSym.
 15286     ] ifFalse:[
 15306     ] ifFalse:[
 15287         (OperatingSystem errorHolderForNumber:errorNumber) reportError
 15307 	(OperatingSystem errorHolderForNumber:errorNumber) reportError
 15288     ].
 15308     ].
 15289 
 15309 
 15290     "
 15310     "
 15291      |h buff n|
 15311      |h buff n|
 15292 
 15312 
 15311 
 15331 
 15312 %{
 15332 %{
 15313     HANDLE h = (HANDLE)(__externalAddressVal(self));
 15333     HANDLE h = (HANDLE)(__externalAddressVal(self));
 15314 
 15334 
 15315     if (h) {
 15335     if (h) {
 15316         __externalAddressVal(self) = (HANDLE)0;
 15336 	__externalAddressVal(self) = (HANDLE)0;
 15317         CloseHandle(h);
 15337 	CloseHandle(h);
 15318     }
 15338     }
 15319 %}.
 15339 %}.
 15320 ! !
 15340 ! !
 15321 
 15341 
 15322 !Win32OperatingSystem::Win32PrinterHandle methodsFor:'release'!
 15342 !Win32OperatingSystem::Win32PrinterHandle methodsFor:'release'!
 15323 
 15343 
 15324 closeHandle
 15344 closeHandle
 15325     self address ~~ 0 ifTrue:[
 15345     self address ~~ 0 ifTrue:[
 15326         OperatingSystem primClosePrinter:self.
 15346 	OperatingSystem primClosePrinter:self.
 15327     ]
 15347     ]
 15328 
 15348 
 15329     "Created: / 27-07-2006 / 14:48:37 / fm"
 15349     "Created: / 27-07-2006 / 14:48:37 / fm"
 15330 ! !
 15350 ! !
 15331 
 15351 
 15346 ! !
 15366 ! !
 15347 
 15367 
 15348 !Win32OperatingSystem::Win32SerialPortHandle methodsFor:'opening'!
 15368 !Win32OperatingSystem::Win32SerialPortHandle methodsFor:'opening'!
 15349 
 15369 
 15350 open:portName baudRate:baudRate stopBitsType:stopBitsType
 15370 open:portName baudRate:baudRate stopBitsType:stopBitsType
 15351                     parityType:parityType dataBits:dataBits
 15371 		    parityType:parityType dataBits:dataBits
 15352                     inFlowCtrl:inFlowCtrlType outFlowCtrl:outFlowCtrlType
 15372 		    inFlowCtrl:inFlowCtrlType outFlowCtrl:outFlowCtrlType
 15353                     xOnChar:xOnChar xOffChar:xOffChar
 15373 		    xOnChar:xOnChar xOffChar:xOffChar
 15354     "portName: COM%d
 15374     "portName: COM%d
 15355      baudRate: Integer
 15375      baudRate: Integer
 15356      stopBitsType: #stop1, #stop2 or #stop1_5
 15376      stopBitsType: #stop1, #stop2 or #stop1_5
 15357      parityType: #odd, #even or #none
 15377      parityType: #odd, #even or #none
 15358      dataBits: #integer
 15378      dataBits: #integer
 15367     HANDLE port;
 15387     HANDLE port;
 15368     COMMTIMEOUTS timeouts;
 15388     COMMTIMEOUTS timeouts;
 15369     DCB dcb;
 15389     DCB dcb;
 15370     char *__portName;
 15390     char *__portName;
 15371     int __setBaudRate = 1,
 15391     int __setBaudRate = 1,
 15372         __setDataBits = 1,
 15392 	__setDataBits = 1,
 15373         __setXOnChar = 1,
 15393 	__setXOnChar = 1,
 15374         __setXOffChar = 1,
 15394 	__setXOffChar = 1,
 15375         __setInFlowCtrl = 1,
 15395 	__setInFlowCtrl = 1,
 15376         __setOutFlowCtrl = 1,
 15396 	__setOutFlowCtrl = 1,
 15377         __setStopBits = 1,
 15397 	__setStopBits = 1,
 15378         __setParityType = 1;
 15398 	__setParityType = 1;
 15379     int __baudRate, __dataBits;
 15399     int __baudRate, __dataBits;
 15380     int __xOnChar, __xOffChar;
 15400     int __xOnChar, __xOffChar;
 15381     int __inFlowCtrl, __outFlowCtrl;
 15401     int __inFlowCtrl, __outFlowCtrl;
 15382     int __stopBits, __parityType;
 15402     int __stopBits, __parityType;
 15383 #   define XONOFF       1
 15403 #   define XONOFF       1
 15388 #   define ODD       1
 15408 #   define ODD       1
 15389 #   define EVEN      2
 15409 #   define EVEN      2
 15390 #   define NONE      3
 15410 #   define NONE      3
 15391 
 15411 
 15392     if (__isStringLike(portName)) {
 15412     if (__isStringLike(portName)) {
 15393         __portName = __stringVal(portName);
 15413 	__portName = __stringVal(portName);
 15394     } else {
 15414     } else {
 15395         goto failure;
 15415 	goto failure;
 15396     }
 15416     }
 15397     if (__isSmallInteger(baudRate)) {
 15417     if (__isSmallInteger(baudRate)) {
 15398         __baudRate = __intVal(baudRate);
 15418 	__baudRate = __intVal(baudRate);
 15399     } else if (baudRate == nil) {
 15419     } else if (baudRate == nil) {
 15400         __setBaudRate = 0;
 15420 	__setBaudRate = 0;
 15401     } else {
 15421     } else {
 15402         goto failure;
 15422 	goto failure;
 15403     }
 15423     }
 15404 
 15424 
 15405     if (__isSmallInteger(dataBits)) {
 15425     if (__isSmallInteger(dataBits)) {
 15406         __dataBits = __intVal(dataBits);
 15426 	__dataBits = __intVal(dataBits);
 15407     } else if (dataBits == nil) {
 15427     } else if (dataBits == nil) {
 15408         __setDataBits = 0;
 15428 	__setDataBits = 0;
 15409     } else {
 15429     } else {
 15410         goto failure;
 15430 	goto failure;
 15411     }
 15431     }
 15412 
 15432 
 15413     if (__isSmallInteger(xOnChar)) {
 15433     if (__isSmallInteger(xOnChar)) {
 15414         __xOnChar = __intVal(xOnChar);
 15434 	__xOnChar = __intVal(xOnChar);
 15415     } else if (__isCharacter(xOnChar)) {
 15435     } else if (__isCharacter(xOnChar)) {
 15416         __xOnChar = __intVal(_characterVal(xOnChar));
 15436 	__xOnChar = __intVal(_characterVal(xOnChar));
 15417     } else if (xOnChar == nil) {
 15437     } else if (xOnChar == nil) {
 15418         __setXOnChar = 0;
 15438 	__setXOnChar = 0;
 15419     } else {
 15439     } else {
 15420         goto failure;
 15440 	goto failure;
 15421     }
 15441     }
 15422 
 15442 
 15423     if (__isSmallInteger(xOffChar)) {
 15443     if (__isSmallInteger(xOffChar)) {
 15424         __xOffChar = __intVal(xOffChar);
 15444 	__xOffChar = __intVal(xOffChar);
 15425     } else if (__isCharacter(xOffChar)) {
 15445     } else if (__isCharacter(xOffChar)) {
 15426         __xOffChar = __intVal(_characterVal(xOffChar));
 15446 	__xOffChar = __intVal(_characterVal(xOffChar));
 15427     } else if (xOffChar == nil) {
 15447     } else if (xOffChar == nil) {
 15428         __setXOffChar = 0;
 15448 	__setXOffChar = 0;
 15429     } else {
 15449     } else {
 15430         goto failure;
 15450 	goto failure;
 15431     }
 15451     }
 15432 
 15452 
 15433     if (inFlowCtrlType == @symbol(xOnOff)) {
 15453     if (inFlowCtrlType == @symbol(xOnOff)) {
 15434         __inFlowCtrl = XONOFF;
 15454 	__inFlowCtrl = XONOFF;
 15435     } else if (inFlowCtrlType == @symbol(hardware)) {
 15455     } else if (inFlowCtrlType == @symbol(hardware)) {
 15436         __inFlowCtrl = HARDWARE;
 15456 	__inFlowCtrl = HARDWARE;
 15437     } else if (inFlowCtrlType == nil) {
 15457     } else if (inFlowCtrlType == nil) {
 15438         __setInFlowCtrl = 0;
 15458 	__setInFlowCtrl = 0;
 15439     } else {
 15459     } else {
 15440         goto failure;
 15460 	goto failure;
 15441     }
 15461     }
 15442 
 15462 
 15443     if (outFlowCtrlType == @symbol(xOnOff)) {
 15463     if (outFlowCtrlType == @symbol(xOnOff)) {
 15444         __outFlowCtrl = XONOFF;
 15464 	__outFlowCtrl = XONOFF;
 15445     } else if (outFlowCtrlType == @symbol(hardware)) {
 15465     } else if (outFlowCtrlType == @symbol(hardware)) {
 15446         __outFlowCtrl = HARDWARE;
 15466 	__outFlowCtrl = HARDWARE;
 15447     } else if (outFlowCtrlType == nil) {
 15467     } else if (outFlowCtrlType == nil) {
 15448         __setOutFlowCtrl = 0;
 15468 	__setOutFlowCtrl = 0;
 15449     } else {
 15469     } else {
 15450         goto failure;
 15470 	goto failure;
 15451     }
 15471     }
 15452 
 15472 
 15453     if (stopBitsType == @symbol(stop1)) {
 15473     if (stopBitsType == @symbol(stop1)) {
 15454         __stopBits = STOP1;
 15474 	__stopBits = STOP1;
 15455     } else if (stopBitsType == @symbol(stop2)) {
 15475     } else if (stopBitsType == @symbol(stop2)) {
 15456         __stopBits = STOP2;
 15476 	__stopBits = STOP2;
 15457     } else if (stopBitsType == @symbol(stop1_5)) {
 15477     } else if (stopBitsType == @symbol(stop1_5)) {
 15458         __stopBits = STOP1_5;
 15478 	__stopBits = STOP1_5;
 15459     } else if (stopBitsType == nil) {
 15479     } else if (stopBitsType == nil) {
 15460         __setStopBits = 0;
 15480 	__setStopBits = 0;
 15461     } else {
 15481     } else {
 15462         goto failure;
 15482 	goto failure;
 15463     }
 15483     }
 15464 
 15484 
 15465     port = CreateFile(__portName,
 15485     port = CreateFile(__portName,
 15466               GENERIC_READ | GENERIC_WRITE,
 15486 	      GENERIC_READ | GENERIC_WRITE,
 15467               0,             /* comm devices must be opened with exclusive access */
 15487 	      0,             /* comm devices must be opened with exclusive access */
 15468               NULL,          /* no security attrs */
 15488 	      NULL,          /* no security attrs */
 15469               OPEN_EXISTING, /* comm devices must use OPEN_EXISTING */
 15489 	      OPEN_EXISTING, /* comm devices must use OPEN_EXISTING */
 15470               0,             /* no overlapped I/O */
 15490 	      0,             /* no overlapped I/O */
 15471               NULL           /* hTemplate must be NULL for comm devices */
 15491 	      NULL           /* hTemplate must be NULL for comm devices */
 15472            );
 15492 	   );
 15473     if (port == INVALID_HANDLE_VALUE) {
 15493     if (port == INVALID_HANDLE_VALUE) {
 15474         console_fprintf(stderr, "Win32OS [info]: serial port open failed\n");
 15494 	console_fprintf(stderr, "Win32OS [info]: serial port open failed\n");
 15475         errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
 15495 	errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
 15476         goto failure;
 15496 	goto failure;
 15477     }
 15497     }
 15478     /* Flush the driver */
 15498     /* Flush the driver */
 15479     PurgeComm( port, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR );
 15499     PurgeComm( port, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR );
 15480 
 15500 
 15481     /* Set driver buffer sizes */
 15501     /* Set driver buffer sizes */
 15498     if (__setDataBits) dcb.ByteSize = __dataBits;
 15518     if (__setDataBits) dcb.ByteSize = __dataBits;
 15499     if (__setXOnChar)  dcb.XonChar = __xOnChar;
 15519     if (__setXOnChar)  dcb.XonChar = __xOnChar;
 15500     if (__setXOffChar) dcb.XoffChar = __xOffChar;
 15520     if (__setXOffChar) dcb.XoffChar = __xOffChar;
 15501 
 15521 
 15502     if (__setStopBits) {
 15522     if (__setStopBits) {
 15503         /* set stop bits */
 15523 	/* set stop bits */
 15504         switch(__stopBits) {
 15524 	switch(__stopBits) {
 15505             case STOP1_5: dcb.StopBits = 1; break; /* 1.5 stop bits */
 15525 	    case STOP1_5: dcb.StopBits = 1; break; /* 1.5 stop bits */
 15506             case STOP1: dcb.StopBits = 0; break; /* 1 stop bit */
 15526 	    case STOP1: dcb.StopBits = 0; break; /* 1 stop bit */
 15507             case STOP2: dcb.StopBits = 2; break; /* 2 stop bits */
 15527 	    case STOP2: dcb.StopBits = 2; break; /* 2 stop bits */
 15508             default: goto errExit;
 15528 	    default: goto errExit;
 15509         }
 15529 	}
 15510     }
 15530     }
 15511 
 15531 
 15512     if (__setParityType) {
 15532     if (__setParityType) {
 15513         /* set parity */
 15533 	/* set parity */
 15514         switch(__parityType) {
 15534 	switch(__parityType) {
 15515             case NONE: dcb.Parity = NOPARITY; break;
 15535 	    case NONE: dcb.Parity = NOPARITY; break;
 15516             case ODD: dcb.Parity = ODDPARITY; break;
 15536 	    case ODD: dcb.Parity = ODDPARITY; break;
 15517             case EVEN: dcb.Parity = EVENPARITY; break;
 15537 	    case EVEN: dcb.Parity = EVENPARITY; break;
 15518             default: goto errExit;
 15538 	    default: goto errExit;
 15519         }
 15539 	}
 15520     }
 15540     }
 15521 
 15541 
 15522     if (__setInFlowCtrl) {
 15542     if (__setInFlowCtrl) {
 15523         /* set control flow */
 15543 	/* set control flow */
 15524         dcb.fInX = FALSE;
 15544 	dcb.fInX = FALSE;
 15525         dcb.fDtrControl = FALSE;
 15545 	dcb.fDtrControl = FALSE;
 15526         if (__inFlowCtrl == XONOFF) dcb.fInX = TRUE;  /* XOn/XOff handshaking */
 15546 	if (__inFlowCtrl == XONOFF) dcb.fInX = TRUE;  /* XOn/XOff handshaking */
 15527         if (__inFlowCtrl == HARDWARE) dcb.fDtrControl = TRUE;  /* hardware handshaking */
 15547 	if (__inFlowCtrl == HARDWARE) dcb.fDtrControl = TRUE;  /* hardware handshaking */
 15528     }
 15548     }
 15529     if (__setOutFlowCtrl) {
 15549     if (__setOutFlowCtrl) {
 15530         dcb.fOutX = FALSE;
 15550 	dcb.fOutX = FALSE;
 15531         dcb.fOutxCtsFlow = FALSE;
 15551 	dcb.fOutxCtsFlow = FALSE;
 15532 
 15552 
 15533         if (__outFlowCtrl == XONOFF) dcb.fOutX = TRUE;  /* XOn/XOff handshaking */
 15553 	if (__outFlowCtrl == XONOFF) dcb.fOutX = TRUE;  /* XOn/XOff handshaking */
 15534         if (__outFlowCtrl == HARDWARE) dcb.fOutxCtsFlow = TRUE;  /* hardware handshaking */
 15554 	if (__outFlowCtrl == HARDWARE) dcb.fOutxCtsFlow = TRUE;  /* hardware handshaking */
 15535     }
 15555     }
 15536 
 15556 
 15537     if (SetCommState(port, &dcb)) {
 15557     if (SetCommState(port, &dcb)) {
 15538         RETURN( true );
 15558 	RETURN( true );
 15539     }
 15559     }
 15540 
 15560 
 15541     console_fprintf(stderr, "Win32OS [info]: serial port comm-setup failed\n");
 15561     console_fprintf(stderr, "Win32OS [info]: serial port comm-setup failed\n");
 15542     errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
 15562     errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
 15543     /* fall into */
 15563     /* fall into */
 15553 #   undef ODD
 15573 #   undef ODD
 15554 #   undef EVEN
 15574 #   undef EVEN
 15555 #   undef NONE
 15575 #   undef NONE
 15556 %}.
 15576 %}.
 15557     errorNumber isNil ifTrue:[
 15577     errorNumber isNil ifTrue:[
 15558         self error:'invalid argument(s)'.
 15578 	self error:'invalid argument(s)'.
 15559     ] ifFalse:[
 15579     ] ifFalse:[
 15560         (OperatingSystem errorHolderForNumber:errorNumber) reportError
 15580 	(OperatingSystem errorHolderForNumber:errorNumber) reportError
 15561     ].
 15581     ].
 15562 ! !
 15582 ! !
 15563 
 15583 
 15564 !Win32OperatingSystem::Win32SerialPortHandle methodsFor:'release'!
 15584 !Win32OperatingSystem::Win32SerialPortHandle methodsFor:'release'!
 15565 
 15585 
 15568 
 15588 
 15569 %{
 15589 %{
 15570     HANDLE port = (HANDLE)(__externalAddressVal(self));
 15590     HANDLE port = (HANDLE)(__externalAddressVal(self));
 15571 
 15591 
 15572     if (port) {
 15592     if (port) {
 15573         __externalAddressVal(self) = (HANDLE)0;
 15593 	__externalAddressVal(self) = (HANDLE)0;
 15574         PurgeComm( port, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR );
 15594 	PurgeComm( port, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR );
 15575         CloseHandle(port);
 15595 	CloseHandle(port);
 15576     }
 15596     }
 15577 %}.
 15597 %}.
 15578 ! !
 15598 ! !
 15579 
 15599 
 15580 !Win32OperatingSystem::Win32SerialPortHandle methodsFor:'setup'!
 15600 !Win32OperatingSystem::Win32SerialPortHandle methodsFor:'setup'!
 15583 %{
 15603 %{
 15584     HANDLE port = (HANDLE)(__externalAddressVal(self));
 15604     HANDLE port = (HANDLE)(__externalAddressVal(self));
 15585 
 15605 
 15586     if (port
 15606     if (port
 15587      && __isSmallInteger(newRate)) {
 15607      && __isSmallInteger(newRate)) {
 15588         DCB dcb;
 15608 	DCB dcb;
 15589 
 15609 
 15590         ZeroMemory(&dcb, sizeof(dcb));
 15610 	ZeroMemory(&dcb, sizeof(dcb));
 15591         dcb.DCBlength = sizeof(dcb);
 15611 	dcb.DCBlength = sizeof(dcb);
 15592         GetCommState(port, &dcb);
 15612 	GetCommState(port, &dcb);
 15593 
 15613 
 15594         dcb.BaudRate = __intVal(newRate);
 15614 	dcb.BaudRate = __intVal(newRate);
 15595 
 15615 
 15596         if (! SetCommState(port, &dcb)) {
 15616 	if (! SetCommState(port, &dcb)) {
 15597             RETURN(false);
 15617 	    RETURN(false);
 15598         }
 15618 	}
 15599         RETURN(true);
 15619 	RETURN(true);
 15600     }
 15620     }
 15601 %}.
 15621 %}.
 15602     self primitiveFailed.
 15622     self primitiveFailed.
 15603 !
 15623 !
 15604 
 15624 
 15606 %{
 15626 %{
 15607     HANDLE port = (HANDLE)(__externalAddressVal(self));
 15627     HANDLE port = (HANDLE)(__externalAddressVal(self));
 15608 
 15628 
 15609     if (port
 15629     if (port
 15610      && __isSmallInteger(newNumberOfBits)) {
 15630      && __isSmallInteger(newNumberOfBits)) {
 15611         DCB dcb;
 15631 	DCB dcb;
 15612 
 15632 
 15613         ZeroMemory(&dcb, sizeof(dcb));
 15633 	ZeroMemory(&dcb, sizeof(dcb));
 15614         dcb.DCBlength = sizeof(dcb);
 15634 	dcb.DCBlength = sizeof(dcb);
 15615         GetCommState(port, &dcb);
 15635 	GetCommState(port, &dcb);
 15616 
 15636 
 15617         dcb.ByteSize = __intVal(newNumberOfBits);
 15637 	dcb.ByteSize = __intVal(newNumberOfBits);
 15618 
 15638 
 15619         if (! SetCommState(port, &dcb)) {
 15639 	if (! SetCommState(port, &dcb)) {
 15620             RETURN(false);
 15640 	    RETURN(false);
 15621         }
 15641 	}
 15622         RETURN(true);
 15642 	RETURN(true);
 15623     }
 15643     }
 15624 %}.
 15644 %}.
 15625     self primitiveFailed.
 15645     self primitiveFailed.
 15626 !
 15646 !
 15627 
 15647 
 15630 
 15650 
 15631 %{
 15651 %{
 15632     HANDLE port = (HANDLE)(__externalAddressVal(self));
 15652     HANDLE port = (HANDLE)(__externalAddressVal(self));
 15633 
 15653 
 15634     if (port) {
 15654     if (port) {
 15635         DCB dcb;
 15655 	DCB dcb;
 15636 
 15656 
 15637         ZeroMemory(&dcb, sizeof(dcb));
 15657 	ZeroMemory(&dcb, sizeof(dcb));
 15638         dcb.DCBlength = sizeof(dcb);
 15658 	dcb.DCBlength = sizeof(dcb);
 15639         GetCommState(port, &dcb);
 15659 	GetCommState(port, &dcb);
 15640 
 15660 
 15641 
 15661 
 15642         if ((newParityTypeSymbol == nil) || (newParityTypeSymbol == @symbol(none))) {
 15662 	if ((newParityTypeSymbol == nil) || (newParityTypeSymbol == @symbol(none))) {
 15643             dcb.Parity = NOPARITY;
 15663 	    dcb.Parity = NOPARITY;
 15644         } else if (newParityTypeSymbol == @symbol(odd)) {
 15664 	} else if (newParityTypeSymbol == @symbol(odd)) {
 15645             dcb.Parity = ODDPARITY;
 15665 	    dcb.Parity = ODDPARITY;
 15646         } else if (newParityTypeSymbol == @symbol(even)) {
 15666 	} else if (newParityTypeSymbol == @symbol(even)) {
 15647             dcb.Parity = EVENPARITY;
 15667 	    dcb.Parity = EVENPARITY;
 15648         } else {
 15668 	} else {
 15649             goto failure;
 15669 	    goto failure;
 15650         }
 15670 	}
 15651 
 15671 
 15652         if (! SetCommState(port, &dcb)) {
 15672 	if (! SetCommState(port, &dcb)) {
 15653             RETURN(false);
 15673 	    RETURN(false);
 15654         }
 15674 	}
 15655         RETURN(true);
 15675 	RETURN(true);
 15656     }
 15676     }
 15657   failure: ;
 15677   failure: ;
 15658 %}.
 15678 %}.
 15659     self primitiveFailed.
 15679     self primitiveFailed.
 15660 !
 15680 !
 15663     "newParityTypeSymbol must be one of #stop1, #stop2 or #stop1_5"
 15683     "newParityTypeSymbol must be one of #stop1, #stop2 or #stop1_5"
 15664 %{
 15684 %{
 15665     HANDLE port = (HANDLE)(__externalAddressVal(self));
 15685     HANDLE port = (HANDLE)(__externalAddressVal(self));
 15666 
 15686 
 15667     if (port) {
 15687     if (port) {
 15668         DCB dcb;
 15688 	DCB dcb;
 15669 
 15689 
 15670         ZeroMemory(&dcb, sizeof(dcb));
 15690 	ZeroMemory(&dcb, sizeof(dcb));
 15671         dcb.DCBlength = sizeof(dcb);
 15691 	dcb.DCBlength = sizeof(dcb);
 15672         GetCommState(port, &dcb);
 15692 	GetCommState(port, &dcb);
 15673 
 15693 
 15674         if (newStopBitsSymbol == @symbol(stop1)) {
 15694 	if (newStopBitsSymbol == @symbol(stop1)) {
 15675             dcb.Parity = 0 /* STOP1 */;
 15695 	    dcb.Parity = 0 /* STOP1 */;
 15676         } else if (newStopBitsSymbol == @symbol(stop2)) {
 15696 	} else if (newStopBitsSymbol == @symbol(stop2)) {
 15677             dcb.Parity = 2 /* STOP2 */;
 15697 	    dcb.Parity = 2 /* STOP2 */;
 15678         } else if (newStopBitsSymbol == @symbol(stop1_5)) {
 15698 	} else if (newStopBitsSymbol == @symbol(stop1_5)) {
 15679             dcb.Parity = 1 /* STOP1_5 */;
 15699 	    dcb.Parity = 1 /* STOP1_5 */;
 15680         } else {
 15700 	} else {
 15681             goto failure;
 15701 	    goto failure;
 15682         }
 15702 	}
 15683 
 15703 
 15684         if (! SetCommState(port, &dcb)) {
 15704 	if (! SetCommState(port, &dcb)) {
 15685             RETURN(false);
 15705 	    RETURN(false);
 15686         }
 15706 	}
 15687         RETURN(true);
 15707 	RETURN(true);
 15688     }
 15708     }
 15689   failure: ;
 15709   failure: ;
 15690 %}.
 15710 %}.
 15691     self primitiveFailed.
 15711     self primitiveFailed.
 15692 ! !
 15712 ! !
 15740 
 15760 
 15741     domain := OperatingSystem domainCodeOf:domainArg.
 15761     domain := OperatingSystem domainCodeOf:domainArg.
 15742     type := OperatingSystem socketTypeCodeOf:typeArg.
 15762     type := OperatingSystem socketTypeCodeOf:typeArg.
 15743     proto := self protocolCodeOf:protoArg.
 15763     proto := self protocolCodeOf:protoArg.
 15744     serviceNameArg notNil ifTrue:[
 15764     serviceNameArg notNil ifTrue:[
 15745         serviceName := serviceNameArg printString.      "convert integer port numbers"
 15765 	serviceName := serviceNameArg printString.      "convert integer port numbers"
 15746         serviceNameArg isInteger ifTrue:[
 15766 	serviceNameArg isInteger ifTrue:[
 15747             port := serviceNameArg.
 15767 	    port := serviceNameArg.
 15748         ].
 15768 	].
 15749     ]. "ifFalse:[serviceName := nil]"
 15769     ]. "ifFalse:[serviceName := nil]"
 15750 
 15770 
 15751 %{ /* STACK:32000 */
 15771 %{ /* STACK:32000 */
 15752 #if !defined(NO_SOCKET)
 15772 #if !defined(NO_SOCKET)
 15753     char *__hostName, *__serviceName;
 15773     char *__hostName, *__serviceName;
 15754     int ret, cnt = 0;
 15774     int ret, cnt = 0;
 15755 
 15775 
 15756     if (hostName == nil) {
 15776     if (hostName == nil) {
 15757         __hostName = 0;
 15777 	__hostName = 0;
 15758     } else if (__isStringLike(hostName)) {
 15778     } else if (__isStringLike(hostName)) {
 15759         __hostName = __stringVal(hostName);
 15779 	__hostName = __stringVal(hostName);
 15760     } else {
 15780     } else {
 15761         error = @symbol(badArgument1);
 15781 	error = @symbol(badArgument1);
 15762         goto exitPrim;
 15782 	goto exitPrim;
 15763     }
 15783     }
 15764     if (serviceName == nil) {
 15784     if (serviceName == nil) {
 15765         __serviceName = 0;
 15785 	__serviceName = 0;
 15766     } else if (__isStringLike(serviceName)) {
 15786     } else if (__isStringLike(serviceName)) {
 15767         __serviceName = __stringVal(serviceName);
 15787 	__serviceName = __stringVal(serviceName);
 15768     } else {
 15788     } else {
 15769         error = @symbol(badArgument2);
 15789 	error = @symbol(badArgument2);
 15770         goto exitPrim;
 15790 	goto exitPrim;
 15771     }
 15791     }
 15772     if (__hostName == 0 && __serviceName == 0) {
 15792     if (__hostName == 0 && __serviceName == 0) {
 15773         error = @symbol(badArgument);
 15793 	error = @symbol(badArgument);
 15774         goto exitPrim;
 15794 	goto exitPrim;
 15775     }
 15795     }
 15776 
 15796 
 15777 {
 15797 {
 15778 # if defined(AI_NUMERICHOST)
 15798 # if defined(AI_NUMERICHOST)
 15779     /*
 15799     /*
 15782     struct addrinfo hints;
 15802     struct addrinfo hints;
 15783     struct addrinfo *info = NULL, *infop;
 15803     struct addrinfo *info = NULL, *infop;
 15784 
 15804 
 15785     memset(&hints, 0, sizeof(hints));
 15805     memset(&hints, 0, sizeof(hints));
 15786     if (__isSmallInteger(domain))
 15806     if (__isSmallInteger(domain))
 15787         hints.ai_family = __intVal(domain);
 15807 	hints.ai_family = __intVal(domain);
 15788     if (__isSmallInteger(type))
 15808     if (__isSmallInteger(type))
 15789         hints.ai_socktype = __intVal(type);
 15809 	hints.ai_socktype = __intVal(type);
 15790     if (__isSmallInteger(proto))
 15810     if (__isSmallInteger(proto))
 15791         hints.ai_protocol = __intVal(proto);
 15811 	hints.ai_protocol = __intVal(proto);
 15792 
 15812 
 15793     do {
 15813     do {
 15794         /* must refetch in loop */
 15814 	/* must refetch in loop */
 15795         if (hostName == nil) {
 15815 	if (hostName == nil) {
 15796             __hostName = 0;
 15816 	    __hostName = 0;
 15797         } else if (__isStringLike(hostName)) {
 15817 	} else if (__isStringLike(hostName)) {
 15798             __hostName = __stringVal(hostName);
 15818 	    __hostName = __stringVal(hostName);
 15799         }
 15819 	}
 15800         if (serviceName == nil) {
 15820 	if (serviceName == nil) {
 15801             __serviceName = 0;
 15821 	    __serviceName = 0;
 15802         } else if (__isStringLike(serviceName)) {
 15822 	} else if (__isStringLike(serviceName)) {
 15803             __serviceName = __stringVal(serviceName);
 15823 	    __serviceName = __stringVal(serviceName);
 15804         }
 15824 	}
 15805 
 15825 
 15806 # ifdef DO_WRAP_CALLS
 15826 # ifdef DO_WRAP_CALLS
 15807         do {
 15827 	do {
 15808             __threadErrno = 0;
 15828 	    __threadErrno = 0;
 15809             res = STX_WSA_NOINT_CALL4( "getaddrinfo", getaddrinfo, __hostName, __serviceName, &hints, &info);
 15829 	    res = STX_WSA_NOINT_CALL4( "getaddrinfo", getaddrinfo, __hostName, __serviceName, &hints, &info);
 15810         } while ((res < 0) && (__threadErrno == EINTR));
 15830 	} while ((res < 0) && (__threadErrno == EINTR));
 15811 # else
 15831 # else
 15812         __BEGIN_INTERRUPTABLE__
 15832 	__BEGIN_INTERRUPTABLE__
 15813         ret = getaddrinfo(__hostName, __serviceName, &hints, &info);
 15833 	ret = getaddrinfo(__hostName, __serviceName, &hints, &info);
 15814         __END_INTERRUPTABLE__
 15834 	__END_INTERRUPTABLE__
 15815 # endif
 15835 # endif
 15816     } while (ret == EAI_SYSTEM && errno == EINTR);
 15836     } while (ret == EAI_SYSTEM && errno == EINTR);
 15817     if (ret != 0) {
 15837     if (ret != 0) {
 15818         switch (ret) {
 15838 	switch (ret) {
 15819         case EAI_FAMILY:
 15839 	case EAI_FAMILY:
 15820             error = @symbol(badProtocol);
 15840 	    error = @symbol(badProtocol);
 15821             break;
 15841 	    break;
 15822         case EAI_SOCKTYPE:
 15842 	case EAI_SOCKTYPE:
 15823             error = @symbol(badSocketType);
 15843 	    error = @symbol(badSocketType);
 15824             break;
 15844 	    break;
 15825         case EAI_BADFLAGS:
 15845 	case EAI_BADFLAGS:
 15826             error = @symbol(badFlags);
 15846 	    error = @symbol(badFlags);
 15827             break;
 15847 	    break;
 15828         case EAI_NONAME:
 15848 	case EAI_NONAME:
 15829             error = @symbol(unknownHost);
 15849 	    error = @symbol(unknownHost);
 15830             break;
 15850 	    break;
 15831         case EAI_SERVICE:
 15851 	case EAI_SERVICE:
 15832             error = @symbol(unknownService);
 15852 	    error = @symbol(unknownService);
 15833             break;
 15853 	    break;
 15834         case EAI_ADDRFAMILY :
 15854 	case EAI_ADDRFAMILY :
 15835             error = @symbol(unknownHostForProtocol);
 15855 	    error = @symbol(unknownHostForProtocol);
 15836             break;
 15856 	    break;
 15837         case EAI_NODATA:
 15857 	case EAI_NODATA:
 15838             error = @symbol(noAddress);
 15858 	    error = @symbol(noAddress);
 15839             break;
 15859 	    break;
 15840         case EAI_MEMORY:
 15860 	case EAI_MEMORY:
 15841             error = @symbol(allocationFailure);
 15861 	    error = @symbol(allocationFailure);
 15842             break;
 15862 	    break;
 15843         case EAI_FAIL:
 15863 	case EAI_FAIL:
 15844             error = @symbol(permanentFailure);
 15864 	    error = @symbol(permanentFailure);
 15845             break;
 15865 	    break;
 15846         case EAI_AGAIN:
 15866 	case EAI_AGAIN:
 15847             error = @symbol(tryAgain);
 15867 	    error = @symbol(tryAgain);
 15848             break;
 15868 	    break;
 15849         case EAI_SYSTEM:
 15869 	case EAI_SYSTEM:
 15850             error = @symbol(systemError);
 15870 	    error = @symbol(systemError);
 15851             break;
 15871 	    break;
 15852         default:
 15872 	default:
 15853             error = @symbol(unknownError);
 15873 	    error = @symbol(unknownError);
 15854         }
 15874 	}
 15855         errorString = __MKSTRING(gai_strerror(ret));
 15875 	errorString = __MKSTRING(gai_strerror(ret));
 15856         goto err;
 15876 	goto err;
 15857     }
 15877     }
 15858     for (cnt=0, infop=info; infop; infop=infop->ai_next)
 15878     for (cnt=0, infop=info; infop; infop=infop->ai_next)
 15859         cnt++;
 15879 	cnt++;
 15860 
 15880 
 15861     result = __ARRAY_NEW_INT(cnt);
 15881     result = __ARRAY_NEW_INT(cnt);
 15862     if (result == nil) {
 15882     if (result == nil) {
 15863         error = @symbol(allocationFailure);
 15883 	error = @symbol(allocationFailure);
 15864         goto err;
 15884 	goto err;
 15865     }
 15885     }
 15866     for (infop=info, cnt=0; infop; infop=infop->ai_next, cnt++) {
 15886     for (infop=info, cnt=0; infop; infop=infop->ai_next, cnt++) {
 15867         OBJ o, resp;
 15887 	OBJ o, resp;
 15868 
 15888 
 15869         resp = __ARRAY_NEW_INT(6);
 15889 	resp = __ARRAY_NEW_INT(6);
 15870         if (resp == nil) {
 15890 	if (resp == nil) {
 15871             error = @symbol(allocationFailure);
 15891 	    error = @symbol(allocationFailure);
 15872             goto err;
 15892 	    goto err;
 15873         }
 15893 	}
 15874 
 15894 
 15875         __ArrayInstPtr(result)->a_element[cnt] = resp; __STORE(result, resp);
 15895 	__ArrayInstPtr(result)->a_element[cnt] = resp; __STORE(result, resp);
 15876 
 15896 
 15877         __ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(infop->ai_flags);
 15897 	__ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(infop->ai_flags);
 15878         __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(infop->ai_family);
 15898 	__ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(infop->ai_family);
 15879         __ArrayInstPtr(resp)->a_element[2] = __mkSmallInteger(infop->ai_socktype);
 15899 	__ArrayInstPtr(resp)->a_element[2] = __mkSmallInteger(infop->ai_socktype);
 15880         __ArrayInstPtr(resp)->a_element[3] = __mkSmallInteger(infop->ai_protocol);
 15900 	__ArrayInstPtr(resp)->a_element[3] = __mkSmallInteger(infop->ai_protocol);
 15881 
 15901 
 15882         __PROTECT__(resp);
 15902 	__PROTECT__(resp);
 15883         o = __BYTEARRAY_NEW_INT(infop->ai_addrlen);
 15903 	o = __BYTEARRAY_NEW_INT(infop->ai_addrlen);
 15884         __UNPROTECT__(resp);
 15904 	__UNPROTECT__(resp);
 15885         if (o == nil) {
 15905 	if (o == nil) {
 15886             error = @symbol(allocationFailure);
 15906 	    error = @symbol(allocationFailure);
 15887             goto err;
 15907 	    goto err;
 15888         }
 15908 	}
 15889         memcpy(__byteArrayVal(o), infop->ai_addr, infop->ai_addrlen);
 15909 	memcpy(__byteArrayVal(o), infop->ai_addr, infop->ai_addrlen);
 15890        __ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
 15910        __ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
 15891 
 15911 
 15892         if (infop->ai_canonname) {
 15912 	if (infop->ai_canonname) {
 15893             __PROTECT__(resp);
 15913 	    __PROTECT__(resp);
 15894             o = __MKSTRING(infop->ai_canonname);
 15914 	    o = __MKSTRING(infop->ai_canonname);
 15895             __UNPROTECT__(resp);
 15915 	    __UNPROTECT__(resp);
 15896             if (o == nil) {
 15916 	    if (o == nil) {
 15897                 error = @symbol(allocationFailure);
 15917 		error = @symbol(allocationFailure);
 15898                 goto err;
 15918 		goto err;
 15899             }
 15919 	    }
 15900             __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
 15920 	    __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
 15901         }
 15921 	}
 15902     }
 15922     }
 15903 
 15923 
 15904 err:
 15924 err:
 15905     if (info) freeaddrinfo(info);
 15925     if (info) freeaddrinfo(info);
 15906 
 15926 
 15913     char **addrpp;
 15933     char **addrpp;
 15914     int __port = 0;
 15934     int __port = 0;
 15915     int i;
 15935     int i;
 15916 
 15936 
 15917     if (__isSmallInteger(port)) {
 15937     if (__isSmallInteger(port)) {
 15918         __port = htons(__smallIntegerVal(port));
 15938 	__port = htons(__smallIntegerVal(port));
 15919     } else if (__serviceName) {
 15939     } else if (__serviceName) {
 15920         struct servent *sp;
 15940 	struct servent *sp;
 15921         char *__proto = 0;
 15941 	char *__proto = 0;
 15922 
 15942 
 15923         if (__isStringLike(protoArg))
 15943 	if (__isStringLike(protoArg))
 15924             __proto = __stringVal(protoArg);
 15944 	    __proto = __stringVal(protoArg);
 15925 
 15945 
 15926         sp = getservbyname(__serviceName, __proto);
 15946 	sp = getservbyname(__serviceName, __proto);
 15927         if (sp == NULL) {
 15947 	if (sp == NULL) {
 15928             __port = atoi(__serviceName);
 15948 	    __port = atoi(__serviceName);
 15929             if (__port <= 0) {
 15949 	    if (__port <= 0) {
 15930                 errorString = @symbol(unknownService);
 15950 		errorString = @symbol(unknownService);
 15931                 error = __mkSmallInteger(-3);
 15951 		error = __mkSmallInteger(-3);
 15932                 goto err;
 15952 		goto err;
 15933             }
 15953 	    }
 15934             __port = htons(__port);
 15954 	    __port = htons(__port);
 15935         } else
 15955 	} else
 15936             __port = sp->s_port;
 15956 	    __port = sp->s_port;
 15937     }
 15957     }
 15938 
 15958 
 15939     if (__hostName) {
 15959     if (__hostName) {
 15940 #  ifdef USE_H_ERRNO
 15960 #  ifdef USE_H_ERRNO
 15941         do {
 15961 	do {
 15942             /* must refetch in loop */
 15962 	    /* must refetch in loop */
 15943             if (hostName == nil) {
 15963 	    if (hostName == nil) {
 15944                 __hostName = 0;
 15964 		__hostName = 0;
 15945             } else if (__isStringLike(hostName)) {
 15965 	    } else if (__isStringLike(hostName)) {
 15946                 __hostName = __stringVal(hostName);
 15966 		__hostName = __stringVal(hostName);
 15947             }
 15967 	    }
 15948 # ifdef DO_WRAP_CALLS
 15968 # ifdef DO_WRAP_CALLS
 15949             hp = STX_WSA_NOINT_CALL1("gethostbyname", gethostbyname, __hostName);
 15969 	    hp = STX_WSA_NOINT_CALL1("gethostbyname", gethostbyname, __hostName);
 15950             if ((INT)hp < 0) hp = NULL;
 15970 	    if ((INT)hp < 0) hp = NULL;
 15951 # else
 15971 # else
 15952             /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname
 15972 	    /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname
 15953              * uses a static data area
 15973 	     * uses a static data area
 15954              */
 15974 	     */
 15955             __BEGIN_INTERRUPTABLE__
 15975 	    __BEGIN_INTERRUPTABLE__
 15956             hp = gethostbyname(__hostName);
 15976 	    hp = gethostbyname(__hostName);
 15957             __END_INTERRUPTABLE__
 15977 	    __END_INTERRUPTABLE__
 15958 #endif
 15978 #endif
 15959         } while ((hp == NULL)
 15979 	} while ((hp == NULL)
 15960                   && (
 15980 		  && (
 15961                         (h_errno == TRY_AGAIN)
 15981 			(h_errno == TRY_AGAIN)
 15962                       || errno == EINTR
 15982 		      || errno == EINTR
 15963 #   ifdef IRIX5_3
 15983 #   ifdef IRIX5_3
 15964                       || (errno == ECONNREFUSED)
 15984 		      || (errno == ECONNREFUSED)
 15965 #   endif
 15985 #   endif
 15966                      )
 15986 		     )
 15967         );
 15987 	);
 15968         if (hp == 0) {
 15988 	if (hp == 0) {
 15969             switch (h_errno) {
 15989 	    switch (h_errno) {
 15970             case HOST_NOT_FOUND:
 15990 	    case HOST_NOT_FOUND:
 15971                 errorString = @symbol(unknownHost);
 15991 		errorString = @symbol(unknownHost);
 15972                 break;
 15992 		break;
 15973             case NO_ADDRESS:
 15993 	    case NO_ADDRESS:
 15974                 errorString = @symbol(noAddress);
 15994 		errorString = @symbol(noAddress);
 15975                 break;
 15995 		break;
 15976             case NO_RECOVERY:
 15996 	    case NO_RECOVERY:
 15977                 errorString = @symbol(permanentFailure);
 15997 		errorString = @symbol(permanentFailure);
 15978                 break;
 15998 		break;
 15979             case TRY_AGAIN:
 15999 	    case TRY_AGAIN:
 15980                 errorString = @symbol(tryAgain);
 16000 		errorString = @symbol(tryAgain);
 15981                 break;
 16001 		break;
 15982             default:
 16002 	    default:
 15983                 errorString = @symbol(unknownError);
 16003 		errorString = @symbol(unknownError);
 15984                 break;
 16004 		break;
 15985             }
 16005 	    }
 15986             error = __mkSmallInteger(h_errno);
 16006 	    error = __mkSmallInteger(h_errno);
 15987             goto err;
 16007 	    goto err;
 15988         }
 16008 	}
 15989 #  else /* !USE_H_ERRNO */
 16009 #  else /* !USE_H_ERRNO */
 15990         hp = gethostbyname(__hostName);
 16010 	hp = gethostbyname(__hostName);
 15991         if (hp == 0) {
 16011 	if (hp == 0) {
 15992             errorString = @symbol(unknownHost);
 16012 	    errorString = @symbol(unknownHost);
 15993             error = __mkSmallInteger(-1);
 16013 	    error = __mkSmallInteger(-1);
 15994             goto err;
 16014 	    goto err;
 15995         }
 16015 	}
 15996 #  endif /* !USE_H_ERRNO*/
 16016 #  endif /* !USE_H_ERRNO*/
 15997 
 16017 
 15998         if (__isSmallInteger(domain) && hp->h_addrtype != __smallIntegerVal(domain)) {
 16018 	if (__isSmallInteger(domain) && hp->h_addrtype != __smallIntegerVal(domain)) {
 15999             errorString = @symbol(unknownHost);
 16019 	    errorString = @symbol(unknownHost);
 16000             error = __mkSmallInteger(-2);
 16020 	    error = __mkSmallInteger(-2);
 16001             goto err;
 16021 	    goto err;
 16002         }
 16022 	}
 16003 
 16023 
 16004         for (cnt = 0, addrpp = hp->h_addr_list; *addrpp; addrpp++)
 16024 	for (cnt = 0, addrpp = hp->h_addr_list; *addrpp; addrpp++)
 16005             cnt++;
 16025 	    cnt++;
 16006         addrpp = hp->h_addr_list;
 16026 	addrpp = hp->h_addr_list;
 16007     } else {
 16027     } else {
 16008         cnt = 1;
 16028 	cnt = 1;
 16009     }
 16029     }
 16010 
 16030 
 16011     result = __ARRAY_NEW_INT(cnt);
 16031     result = __ARRAY_NEW_INT(cnt);
 16012     if (result == nil) {
 16032     if (result == nil) {
 16013         error = @symbol(allocationFailure);
 16033 	error = @symbol(allocationFailure);
 16014         goto err;
 16034 	goto err;
 16015     }
 16035     }
 16016 
 16036 
 16017     for (i = 0; i < cnt; i++) {
 16037     for (i = 0; i < cnt; i++) {
 16018         OBJ o, resp;
 16038 	OBJ o, resp;
 16019         struct sockaddr_in *sa;
 16039 	struct sockaddr_in *sa;
 16020 
 16040 
 16021         resp = __ARRAY_NEW_INT(6);
 16041 	resp = __ARRAY_NEW_INT(6);
 16022         if (resp == nil) {
 16042 	if (resp == nil) {
 16023             error = @symbol(allocationFailure);
 16043 	    error = @symbol(allocationFailure);
 16024             goto err;
 16044 	    goto err;
 16025         }
 16045 	}
 16026 
 16046 
 16027         __ArrayInstPtr(result)->a_element[i] = resp; __STORE(result, resp);
 16047 	__ArrayInstPtr(result)->a_element[i] = resp; __STORE(result, resp);
 16028         __ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(0);
 16048 	__ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(0);
 16029         __ArrayInstPtr(resp)->a_element[2] = type; __STORE(result, type);
 16049 	__ArrayInstPtr(resp)->a_element[2] = type; __STORE(result, type);
 16030         __ArrayInstPtr(resp)->a_element[3] = proto; __STORE(result, proto);
 16050 	__ArrayInstPtr(resp)->a_element[3] = proto; __STORE(result, proto);
 16031         __PROTECT__(resp);
 16051 	__PROTECT__(resp);
 16032         o = __BYTEARRAY_NEW_INT(sizeof(*sa));
 16052 	o = __BYTEARRAY_NEW_INT(sizeof(*sa));
 16033         __UNPROTECT__(resp);
 16053 	__UNPROTECT__(resp);
 16034         if (o == nil) {
 16054 	if (o == nil) {
 16035             error = @symbol(allocationFailure);
 16055 	    error = @symbol(allocationFailure);
 16036             goto err;
 16056 	    goto err;
 16037         }
 16057 	}
 16038         __ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
 16058 	__ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
 16039         sa = (struct sockaddr_in *)__byteArrayVal(o);
 16059 	sa = (struct sockaddr_in *)__byteArrayVal(o);
 16040         sa->sin_port = __port;
 16060 	sa->sin_port = __port;
 16041 
 16061 
 16042         if (__hostName) {
 16062 	if (__hostName) {
 16043             sa->sin_family = hp->h_addrtype;
 16063 	    sa->sin_family = hp->h_addrtype;
 16044             memcpy(&sa->sin_addr, *addrpp, hp->h_length);
 16064 	    memcpy(&sa->sin_addr, *addrpp, hp->h_length);
 16045             __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(hp->h_addrtype);
 16065 	    __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(hp->h_addrtype);
 16046             if (hp->h_name) {
 16066 	    if (hp->h_name) {
 16047                 __PROTECT__(resp);
 16067 		__PROTECT__(resp);
 16048                 o = __MKSTRING(hp->h_name);
 16068 		o = __MKSTRING(hp->h_name);
 16049                 __UNPROTECT__(resp);
 16069 		__UNPROTECT__(resp);
 16050                 if (o == nil) {
 16070 		if (o == nil) {
 16051                     error = @symbol(allocationFailure);
 16071 		    error = @symbol(allocationFailure);
 16052                     goto err;
 16072 		    goto err;
 16053                 }
 16073 		}
 16054                 __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
 16074 		__ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
 16055             }
 16075 	    }
 16056             addrpp++;
 16076 	    addrpp++;
 16057         } else{
 16077 	} else{
 16058             __ArrayInstPtr(resp)->a_element[1] = domain; __STORE(resp, domain);
 16078 	    __ArrayInstPtr(resp)->a_element[1] = domain; __STORE(resp, domain);
 16059         }
 16079 	}
 16060     }
 16080     }
 16061 
 16081 
 16062 err:;
 16082 err:;
 16063 # endif /* ! AI_NUMERICHOST */
 16083 # endif /* ! AI_NUMERICHOST */
 16064 }
 16084 }
 16066     error = @symbol(notImplemented);
 16086     error = @symbol(notImplemented);
 16067 #endif
 16087 #endif
 16068 exitPrim:;
 16088 exitPrim:;
 16069 %}.
 16089 %}.
 16070     error notNil ifTrue:[
 16090     error notNil ifTrue:[
 16071         |request|
 16091 	|request|
 16072         request := SocketAddressInfo new
 16092 	request := SocketAddressInfo new
 16073             domain:domainArg;
 16093 	    domain:domainArg;
 16074             type:typeArg;
 16094 	    type:typeArg;
 16075             protocol:protoArg;
 16095 	    protocol:protoArg;
 16076             canonicalName:hostName;
 16096 	    canonicalName:hostName;
 16077             serviceName:serviceName.
 16097 	    serviceName:serviceName.
 16078         ^ (HostNameLookupError new
 16098 	^ (HostNameLookupError new
 16079                 parameter:error;
 16099 		parameter:error;
 16080                 messageText:' - ', (errorString ? error printString);
 16100 		messageText:' - ', (errorString ? error printString);
 16081                 request:request) raiseRequest.
 16101 		request:request) raiseRequest.
 16082     ].
 16102     ].
 16083     1 to:result size do:[:i |
 16103     1 to:result size do:[:i |
 16084         |entry dom info|
 16104 	|entry dom info|
 16085 
 16105 
 16086         info := SocketAddressInfo new.
 16106 	info := SocketAddressInfo new.
 16087         entry := result at:i.
 16107 	entry := result at:i.
 16088         info flags:(entry at:1).
 16108 	info flags:(entry at:1).
 16089         info domain:(dom := OperatingSystem domainSymbolOf:(entry at:2)).
 16109 	info domain:(dom := OperatingSystem domainSymbolOf:(entry at:2)).
 16090         info type:(OperatingSystem socketTypeSymbolOf:(entry at:3)).
 16110 	info type:(OperatingSystem socketTypeSymbolOf:(entry at:3)).
 16091         info protocol:(self protocolSymbolOf:(entry at:4)).
 16111 	info protocol:(self protocolSymbolOf:(entry at:4)).
 16092         info socketAddress:((SocketAddress newDomain:dom) fromBytes:(entry at:5)).
 16112 	info socketAddress:((SocketAddress newDomain:dom) fromBytes:(entry at:5)).
 16093         info canonicalName:(entry at:6).
 16113 	info canonicalName:(entry at:6).
 16094         result at:i put:info
 16114 	result at:i put:info
 16095     ].
 16115     ].
 16096     ^ result
 16116     ^ result
 16097 
 16117 
 16098     "
 16118     "
 16099      self getAddressInfo:'localhost' serviceName:nil
 16119      self getAddressInfo:'localhost' serviceName:nil
 16100             domain:nil type:nil protocol:nil flags:nil
 16120 	    domain:nil type:nil protocol:nil flags:nil
 16101      self getAddressInfo:'localhost' serviceName:nil
 16121      self getAddressInfo:'localhost' serviceName:nil
 16102             domain:#inet type:#stream protocol:nil flags:nil
 16122 	    domain:#inet type:#stream protocol:nil flags:nil
 16103      self getAddressInfo:'localhost' serviceName:nil
 16123      self getAddressInfo:'localhost' serviceName:nil
 16104             domain:#inet type:#stream protocol:#tcp flags:nil
 16124 	    domain:#inet type:#stream protocol:#tcp flags:nil
 16105      self getAddressInfo:'localhost' serviceName:10
 16125      self getAddressInfo:'localhost' serviceName:10
 16106             domain:#inet type:#stream protocol:#tcp flags:nil
 16126 	    domain:#inet type:#stream protocol:#tcp flags:nil
 16107      self getAddressInfo:'localhost' serviceName:'10'
 16127      self getAddressInfo:'localhost' serviceName:'10'
 16108             domain:#inet type:#stream protocol:#tcp flags:nil
 16128 	    domain:#inet type:#stream protocol:#tcp flags:nil
 16109      self getAddressInfo:'blurb.exept.de' serviceName:nil
 16129      self getAddressInfo:'blurb.exept.de' serviceName:nil
 16110             domain:#inet type:nil protocol:nil flags:nil
 16130 	    domain:#inet type:nil protocol:nil flags:nil
 16111      self getAddressInfo:'1.2.3.4' serviceName:'bla'
 16131      self getAddressInfo:'1.2.3.4' serviceName:'bla'
 16112             domain:#inet type:nil protocol:nil flags:nil
 16132 	    domain:#inet type:nil protocol:nil flags:nil
 16113      self getAddressInfo:'localhost' serviceName:'echo'
 16133      self getAddressInfo:'localhost' serviceName:'echo'
 16114             domain:#inet type:nil protocol:nil flags:nil
 16134 	    domain:#inet type:nil protocol:nil flags:nil
 16115      self getAddressInfo:nil serviceName:'echo'
 16135      self getAddressInfo:nil serviceName:'echo'
 16116             domain:#inet type:nil protocol:nil flags:nil
 16136 	    domain:#inet type:nil protocol:nil flags:nil
 16117      self getAddressInfo:nil serviceName:nil
 16137      self getAddressInfo:nil serviceName:nil
 16118             domain:#inet type:nil protocol:nil flags:nil
 16138 	    domain:#inet type:nil protocol:nil flags:nil
 16119      self getAddressInfo:'www.google.de' serviceName:nil
 16139      self getAddressInfo:'www.google.de' serviceName:nil
 16120             domain:nil type:nil protocol:nil flags:nil
 16140 	    domain:nil type:nil protocol:nil flags:nil
 16121      self getAddressInfo:'smc1' serviceName:nil
 16141      self getAddressInfo:'smc1' serviceName:nil
 16122             domain:nil type:nil protocol:nil flags:nil
 16142 	    domain:nil type:nil protocol:nil flags:nil
 16123     "
 16143     "
 16124 !
 16144 !
 16125 
 16145 
 16126 getNameInfo:socketAddress wantHostName:wantHostName wantServiceName:wantServiceName datagram:useDatagram flags:flags
 16146 getNameInfo:socketAddress wantHostName:wantHostName wantServiceName:wantServiceName datagram:useDatagram flags:flags
 16127     "answer an Array containing the hostName and serviceName
 16147     "answer an Array containing the hostName and serviceName
 16147     int ret, __flags;
 16167     int ret, __flags;
 16148     char *bp;
 16168     char *bp;
 16149     int nInstBytes, sockAddrSize;
 16169     int nInstBytes, sockAddrSize;
 16150 
 16170 
 16151     if (wantHostName == true) {
 16171     if (wantHostName == true) {
 16152         hp = host;
 16172 	hp = host;
 16153         hsz = sizeof(host);
 16173 	hsz = sizeof(host);
 16154     }
 16174     }
 16155     if (wantServiceName == true) {
 16175     if (wantServiceName == true) {
 16156         sp = service;
 16176 	sp = service;
 16157         ssz = sizeof(service);
 16177 	ssz = sizeof(service);
 16158     }
 16178     }
 16159     if (hp == 0 && sp == 0) {
 16179     if (hp == 0 && sp == 0) {
 16160         error = @symbol(badArgument);
 16180 	error = @symbol(badArgument);
 16161         goto err;
 16181 	goto err;
 16162     }
 16182     }
 16163     if (!__isBytes(socketAddress)) {
 16183     if (!__isBytes(socketAddress)) {
 16164         error = @symbol(badArgument1);
 16184 	error = @symbol(badArgument1);
 16165         goto err;
 16185 	goto err;
 16166     }
 16186     }
 16167 
 16187 
 16168     nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_ninstvars));
 16188     nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_ninstvars));
 16169     sockAddrSize = __byteArraySize(socketAddress);
 16189     sockAddrSize = __byteArraySize(socketAddress);
 16170     sockAddrSize -= nInstBytes;
 16190     sockAddrSize -= nInstBytes;
 16171 
 16191 
 16172     if (!__isSmallInteger(flags)) {
 16192     if (!__isSmallInteger(flags)) {
 16173         error = @symbol(badArgument5);
 16193 	error = @symbol(badArgument5);
 16174         goto err;
 16194 	goto err;
 16175     }
 16195     }
 16176     __flags = __intVal(flags);
 16196     __flags = __intVal(flags);
 16177 
 16197 
 16178 #if defined(NI_NUMERICHOST)
 16198 #if defined(NI_NUMERICHOST)
 16179     if (useDatagram == true) {
 16199     if (useDatagram == true) {
 16180         __flags |= NI_DGRAM;
 16200 	__flags |= NI_DGRAM;
 16181     }
 16201     }
 16182 
 16202 
 16183     {
 16203     {
 16184         bp = (char *)(__byteArrayVal(socketAddress));
 16204 	bp = (char *)(__byteArrayVal(socketAddress));
 16185         bp += nInstBytes;
 16205 	bp += nInstBytes;
 16186         __BEGIN_INTERRUPTABLE__
 16206 	__BEGIN_INTERRUPTABLE__
 16187         ret = getnameinfo((struct sockaddr *)bp, sockAddrSize,
 16207 	ret = getnameinfo((struct sockaddr *)bp, sockAddrSize,
 16188                           hp, hsz, sp, ssz, __flags);
 16208 			  hp, hsz, sp, ssz, __flags);
 16189         __END_INTERRUPTABLE__
 16209 	__END_INTERRUPTABLE__
 16190     } while (ret == EAI_SYSTEM && errno == EINTR);
 16210     } while (ret == EAI_SYSTEM && errno == EINTR);
 16191     if (ret != 0) {
 16211     if (ret != 0) {
 16192         switch (ret) {
 16212 	switch (ret) {
 16193         case EAI_FAMILY:
 16213 	case EAI_FAMILY:
 16194             error = @symbol(badProtocol);
 16214 	    error = @symbol(badProtocol);
 16195             break;
 16215 	    break;
 16196         case EAI_SOCKTYPE:
 16216 	case EAI_SOCKTYPE:
 16197             error = @symbol(badSocketType);
 16217 	    error = @symbol(badSocketType);
 16198             break;
 16218 	    break;
 16199         case EAI_BADFLAGS:
 16219 	case EAI_BADFLAGS:
 16200             error = @symbol(badFlags);
 16220 	    error = @symbol(badFlags);
 16201             break;
 16221 	    break;
 16202         case EAI_NONAME:
 16222 	case EAI_NONAME:
 16203             error = @symbol(unknownHost);
 16223 	    error = @symbol(unknownHost);
 16204             break;
 16224 	    break;
 16205         case EAI_SERVICE:
 16225 	case EAI_SERVICE:
 16206             error = @symbol(unknownService);
 16226 	    error = @symbol(unknownService);
 16207             break;
 16227 	    break;
 16208         case EAI_ADDRFAMILY :
 16228 	case EAI_ADDRFAMILY :
 16209             error = @symbol(unknownHostForProtocol);
 16229 	    error = @symbol(unknownHostForProtocol);
 16210             break;
 16230 	    break;
 16211         case EAI_NODATA:
 16231 	case EAI_NODATA:
 16212             error = @symbol(noAddress);
 16232 	    error = @symbol(noAddress);
 16213             break;
 16233 	    break;
 16214         case EAI_MEMORY:
 16234 	case EAI_MEMORY:
 16215             error = @symbol(allocationFailure);
 16235 	    error = @symbol(allocationFailure);
 16216             break;
 16236 	    break;
 16217         case EAI_FAIL:
 16237 	case EAI_FAIL:
 16218             error = @symbol(permanentFailure);
 16238 	    error = @symbol(permanentFailure);
 16219             break;
 16239 	    break;
 16220         case EAI_AGAIN:
 16240 	case EAI_AGAIN:
 16221             error = @symbol(tryAgain);
 16241 	    error = @symbol(tryAgain);
 16222             break;
 16242 	    break;
 16223         case EAI_SYSTEM:
 16243 	case EAI_SYSTEM:
 16224             error = @symbol(systemError);
 16244 	    error = @symbol(systemError);
 16225             break;
 16245 	    break;
 16226         default:
 16246 	default:
 16227             error = @symbol(unknownError);
 16247 	    error = @symbol(unknownError);
 16228         }
 16248 	}
 16229         errorString = __MKSTRING(gai_strerror(ret));
 16249 	errorString = __MKSTRING(gai_strerror(ret));
 16230         goto err;
 16250 	goto err;
 16231     }
 16251     }
 16232 # else /* ! NI_NUMERICHOST */
 16252 # else /* ! NI_NUMERICHOST */
 16233     {
 16253     {
 16234         /*
 16254 	/*
 16235          * Do it using gethostbyaddr()
 16255 	 * Do it using gethostbyaddr()
 16236          */
 16256 	 */
 16237         struct sockaddr_in *sa;
 16257 	struct sockaddr_in *sa;
 16238 
 16258 
 16239         if (sockAddrSize < sizeof(*sa)) {
 16259 	if (sockAddrSize < sizeof(*sa)) {
 16240             error = @symbol(badArgument1);
 16260 	    error = @symbol(badArgument1);
 16241             goto err;
 16261 	    goto err;
 16242         }
 16262 	}
 16243         bp = (char *)(__byteArrayVal(socketAddress));
 16263 	bp = (char *)(__byteArrayVal(socketAddress));
 16244         bp += nInstBytes;
 16264 	bp += nInstBytes;
 16245         sa = (struct sockaddr_in *)bp;
 16265 	sa = (struct sockaddr_in *)bp;
 16246 
 16266 
 16247         if (sp) {
 16267 	if (sp) {
 16248             struct servent *servp;
 16268 	    struct servent *servp;
 16249             char *__proto = 0;
 16269 	    char *__proto = 0;
 16250 
 16270 
 16251             __proto = (useDatagram == true ? "udp" : "tcp");
 16271 	    __proto = (useDatagram == true ? "udp" : "tcp");
 16252 
 16272 
 16253             servp = getservbyport(sa->sin_port, __proto);
 16273 	    servp = getservbyport(sa->sin_port, __proto);
 16254             if (servp) {
 16274 	    if (servp) {
 16255                 sp = servp->s_name;
 16275 		sp = servp->s_name;
 16256             }
 16276 	    }
 16257         }
 16277 	}
 16258         if (hp) {
 16278 	if (hp) {
 16259             struct hostent *hostp;
 16279 	    struct hostent *hostp;
 16260 #  ifdef USE_H_ERRNO
 16280 #  ifdef USE_H_ERRNO
 16261             do {
 16281 	    do {
 16262                 /* must refetch in loop */
 16282 		/* must refetch in loop */
 16263                 bp = (char *)(__byteArrayVal(socketAddress));
 16283 		bp = (char *)(__byteArrayVal(socketAddress));
 16264                 bp += nInstBytes;
 16284 		bp += nInstBytes;
 16265                 sa = (struct sockaddr_in *)bp;
 16285 		sa = (struct sockaddr_in *)bp;
 16266                 /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname uses a static data area
 16286 		/* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname uses a static data area
 16267                  */
 16287 		 */
 16268                 hostp = gethostbyaddr((char *)&sa->sin_addr, sockAddrSize, sa->sin_family);
 16288 		hostp = gethostbyaddr((char *)&sa->sin_addr, sockAddrSize, sa->sin_family);
 16269                 /* __END_INTERRUPTABLE__ */
 16289 		/* __END_INTERRUPTABLE__ */
 16270             } while ((hostp == NULL)
 16290 	    } while ((hostp == NULL)
 16271                       && ((h_errno == TRY_AGAIN)
 16291 		      && ((h_errno == TRY_AGAIN)
 16272                           || errno == EINTR
 16292 			  || errno == EINTR
 16273 #   ifdef IRIX5_3
 16293 #   ifdef IRIX5_3
 16274                           || (errno == ECONNREFUSED)
 16294 			  || (errno == ECONNREFUSED)
 16275 #   endif
 16295 #   endif
 16276                          )
 16296 			 )
 16277             );
 16297 	    );
 16278             if (hostp == 0) {
 16298 	    if (hostp == 0) {
 16279                 switch (h_errno) {
 16299 		switch (h_errno) {
 16280                 case HOST_NOT_FOUND:
 16300 		case HOST_NOT_FOUND:
 16281                     errorString = @symbol(unknownHost);
 16301 		    errorString = @symbol(unknownHost);
 16282                     break;
 16302 		    break;
 16283                 case NO_ADDRESS:
 16303 		case NO_ADDRESS:
 16284                     errorString = @symbol(noAddress);
 16304 		    errorString = @symbol(noAddress);
 16285                     break;
 16305 		    break;
 16286                 case NO_RECOVERY:
 16306 		case NO_RECOVERY:
 16287                     errorString = @symbol(permanentFailure);
 16307 		    errorString = @symbol(permanentFailure);
 16288                     break;
 16308 		    break;
 16289                 case TRY_AGAIN:
 16309 		case TRY_AGAIN:
 16290                     errorString = @symbol(tryAgain);
 16310 		    errorString = @symbol(tryAgain);
 16291                     break;
 16311 		    break;
 16292                 default:
 16312 		default:
 16293                     errorString = @symbol(unknownError);
 16313 		    errorString = @symbol(unknownError);
 16294                     break;
 16314 		    break;
 16295                 }
 16315 		}
 16296                 error = __mkSmallInteger(h_errno);
 16316 		error = __mkSmallInteger(h_errno);
 16297                 goto err;
 16317 		goto err;
 16298             }
 16318 	    }
 16299 #  else /* !USE_H_ERRNO */
 16319 #  else /* !USE_H_ERRNO */
 16300             hostp = gethostbyaddr((char *)&sa->sin_addr, sockAddrSize, sa->sin_family);
 16320 	    hostp = gethostbyaddr((char *)&sa->sin_addr, sockAddrSize, sa->sin_family);
 16301             if (hostp == 0) {
 16321 	    if (hostp == 0) {
 16302                 errorString = @symbol(unknownHost);
 16322 		errorString = @symbol(unknownHost);
 16303                 error = __mkSmallInteger(-1);
 16323 		error = __mkSmallInteger(-1);
 16304                 goto err;
 16324 		goto err;
 16305             }
 16325 	    }
 16306 #  endif /* !USE_H_ERRNO*/
 16326 #  endif /* !USE_H_ERRNO*/
 16307             hp = hostp->h_name;
 16327 	    hp = hostp->h_name;
 16308         }
 16328 	}
 16309     }
 16329     }
 16310 # endif /* ! NI_NUMERICHOST */
 16330 # endif /* ! NI_NUMERICHOST */
 16311 
 16331 
 16312     if (hp)
 16332     if (hp)
 16313         hostName = __MKSTRING(hp);
 16333 	hostName = __MKSTRING(hp);
 16314     if (sp)
 16334     if (sp)
 16315         serviceName = __MKSTRING(sp);
 16335 	serviceName = __MKSTRING(sp);
 16316 err:;
 16336 err:;
 16317 #else
 16337 #else
 16318     error = @symbol(notImplemented);
 16338     error = @symbol(notImplemented);
 16319 #endif
 16339 #endif
 16320 %}.
 16340 %}.
 16321     error notNil ifTrue:[
 16341     error notNil ifTrue:[
 16322         ^ (HostAddressLookupError new
 16342 	^ (HostAddressLookupError new
 16323                 parameter:error;
 16343 		parameter:error;
 16324                 messageText:' - ', errorString;
 16344 		messageText:' - ', errorString;
 16325                 request:thisContext message) raiseRequest.
 16345 		request:thisContext message) raiseRequest.
 16326     ].
 16346     ].
 16327 
 16347 
 16328     ^ Array with:hostName with:serviceName
 16348     ^ Array with:hostName with:serviceName
 16329 
 16349 
 16330     "
 16350     "
 16331      self getNameInfo:
 16351      self getNameInfo:
 16332         (self getAddressInfo:'localhost' serviceName:'echo'
 16352 	(self getAddressInfo:'localhost' serviceName:'echo'
 16333                 domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
 16353 		domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
 16334          wantHostName:true wantServiceName:true datagram:false flags:0
 16354 	 wantHostName:true wantServiceName:true datagram:false flags:0
 16335 
 16355 
 16336      self getNameInfo:
 16356      self getNameInfo:
 16337         (self getAddressInfo:'exept.exept.de' serviceName:'echo'
 16357 	(self getAddressInfo:'exept.exept.de' serviceName:'echo'
 16338                 domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
 16358 		domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
 16339          wantHostName:true wantServiceName:true datagram:false flags:0
 16359 	 wantHostName:true wantServiceName:true datagram:false flags:0
 16340 
 16360 
 16341      self getNameInfo:#[1 2 3 4]
 16361      self getNameInfo:#[1 2 3 4]
 16342          wantHostName:true wantServiceName:true datagram:false flags:0
 16362 	 wantHostName:true wantServiceName:true datagram:false flags:0
 16343     "
 16363     "
 16344 ! !
 16364 ! !
 16345 
 16365 
 16346 !Win32OperatingSystem::WinPointStructure class methodsFor:'instance creation'!
 16366 !Win32OperatingSystem::WinPointStructure class methodsFor:'instance creation'!
 16347 
 16367 
 16360 ! !
 16380 ! !
 16361 
 16381 
 16362 !Win32OperatingSystem::WinPointStructure methodsFor:'accessing'!
 16382 !Win32OperatingSystem::WinPointStructure methodsFor:'accessing'!
 16363 
 16383 
 16364 asPoint
 16384 asPoint
 16365         "Private - Answer the receiver as a Point."
 16385 	"Private - Answer the receiver as a Point."
 16366     ^self x @ self y
 16386     ^self x @ self y
 16367 
 16387 
 16368     "Created: / 03-08-2006 / 10:45:55 / fm"
 16388     "Created: / 03-08-2006 / 10:45:55 / fm"
 16369 !
 16389 !
 16370 
 16390 
 16371 x
 16391 x
 16372         "Private - Answer the x coordinate of the point."
 16392 	"Private - Answer the x coordinate of the point."
 16373     ^self longAt: 0 + 1
 16393     ^self longAt: 0 + 1
 16374 
 16394 
 16375     "Created: / 03-08-2006 / 10:46:11 / fm"
 16395     "Created: / 03-08-2006 / 10:46:11 / fm"
 16376 !
 16396 !
 16377 
 16397 
 16378 x: anInteger
 16398 x: anInteger
 16379         "Private - Set the x coordinate of the point."
 16399 	"Private - Set the x coordinate of the point."
 16380     self longAt: 0 + 1 put: anInteger
 16400     self longAt: 0 + 1 put: anInteger
 16381 
 16401 
 16382     "Created: / 03-08-2006 / 10:46:41 / fm"
 16402     "Created: / 03-08-2006 / 10:46:41 / fm"
 16383 !
 16403 !
 16384 
 16404 
 16385 y
 16405 y
 16386         "Private - Answer the y coordinate of the point."
 16406 	"Private - Answer the y coordinate of the point."
 16387     ^self longAt: 4 + 1
 16407     ^self longAt: 4 + 1
 16388 
 16408 
 16389     "Created: / 03-08-2006 / 10:46:26 / fm"
 16409     "Created: / 03-08-2006 / 10:46:26 / fm"
 16390 !
 16410 !
 16391 
 16411 
 16392 y: anInteger
 16412 y: anInteger
 16393         "Private - Set the y coordinate of the point."
 16413 	"Private - Set the y coordinate of the point."
 16394     self longAt: 4 + 1 put: anInteger
 16414     self longAt: 4 + 1 put: anInteger
 16395 
 16415 
 16396     "Created: / 03-08-2006 / 10:46:56 / fm"
 16416     "Created: / 03-08-2006 / 10:46:56 / fm"
 16397 ! !
 16417 ! !
 16398 
 16418 
 16399 !Win32OperatingSystem::WinPointStructure methodsFor:'printing'!
 16419 !Win32OperatingSystem::WinPointStructure methodsFor:'printing'!
 16400 
 16420 
 16401 printOn: aStream
 16421 printOn: aStream
 16402         "Append a textual representation of the receiver to aStream."
 16422 	"Append a textual representation of the receiver to aStream."
 16403     aStream nextPutAll: self class name, ' { ', self asPoint printString, ' } '
 16423     aStream nextPutAll: self class name, ' { ', self asPoint printString, ' } '
 16404 
 16424 
 16405     "Created: / 03-08-2006 / 10:45:40 / fm"
 16425     "Created: / 03-08-2006 / 10:45:40 / fm"
 16406 ! !
 16426 ! !
 16407 
 16427 
 16408 !Win32OperatingSystem class methodsFor:'documentation'!
 16428 !Win32OperatingSystem class methodsFor:'documentation'!
 16409 
 16429 
 16410 version
 16430 version
 16411     ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.426 2011-08-24 13:44:54 vrany Exp $'
 16431     ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.427 2011-09-29 11:18:57 cg Exp $'
 16412 !
 16432 !
 16413 
 16433 
 16414 version_CVS
 16434 version_CVS
 16415 
 16435 
 16416     ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.426 2011-08-24 13:44:54 vrany Exp $'
 16436     ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.427 2011-09-29 11:18:57 cg Exp $'
 16417 !
 16437 !
 16418 
 16438 
 16419 version_SVN
 16439 version_SVN
 16420     ^ '§Id§'
 16440     ^ '§Id§'
 16421 
 16441