Win32OperatingSystem.st
changeset 10627 bef737d1b8a7
parent 10622 87a51cae9161
child 10664 1b41c869040a
equal deleted inserted replaced
10626:e6ce341ac09b 10627:bef737d1b8a7
     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
   402 
   402 
   403     tv.tv_sec  = 0;
   403     tv.tv_sec  = 0;
   404     tv.tv_usec = 0;
   404     tv.tv_usec = 0;
   405 
   405 
   406     if (readMode) {
   406     if (readMode) {
   407         n = select (sock + 1, & fds, NULL, NULL, & tv);
   407 	n = select (sock + 1, & fds, NULL, NULL, & tv);
   408     } else {
   408     } else {
   409         n = select (sock + 1, NULL, & fds, NULL, & tv);
   409 	n = select (sock + 1, NULL, & fds, NULL, & tv);
   410     }
   410     }
   411 
   411 
   412     if (n == 0) {
   412     if (n == 0) {
   413         return (0);
   413 	return (0);
   414     }
   414     }
   415 
   415 
   416     if (n > 0) {
   416     if (n > 0) {
   417         return ((FD_ISSET (sock, & fds)) ? 1 : 0);
   417 	return ((FD_ISSET (sock, & fds)) ? 1 : 0);
   418     }
   418     }
   419 
   419 
   420     winErrNo = WSAGetLastError();
   420     winErrNo = WSAGetLastError();
   421     switch (winErrNo) {
   421     switch (winErrNo) {
   422         case WSAENOTSOCK:
   422 	case WSAENOTSOCK:
   423             if (readMode) {
   423 	    if (readMode) {
   424 
   424 
   425                 DWORD  w = 0;
   425 		DWORD  w = 0;
   426                 HANDLE h = (HANDLE) _get_osfhandle (aFD);
   426 		HANDLE h = (HANDLE) _get_osfhandle (aFD);
   427 
   427 
   428                 if (PeekNamedPipe (h, 0, 0, 0, & w, 0)) {
   428 		if (PeekNamedPipe (h, 0, 0, 0, & w, 0)) {
   429                     if( !__isWinNT || w > 0 )
   429 		    if( !__isWinNT || w > 0 )
   430                         return (1);
   430 			return (1);
   431 
   431 
   432                     return (0);
   432 		    return (0);
   433                 }
   433 		}
   434 #if 0
   434 #if 0
   435                 console_fprintf(stderr, "_canAccessIOWithoutBlocking non Socket\n");
   435 		console_fprintf(stderr, "_canAccessIOWithoutBlocking non Socket\n");
   436 #endif
   436 #endif
   437                 return (-1);
   437 		return (-1);
   438             }
   438 	    }
   439             /* in writeMode we return allways true for none-sockets */
   439 	    /* in writeMode we return allways true for none-sockets */
   440             return (1);
   440 	    return (1);
   441 
   441 
   442         case WSAEINPROGRESS:
   442 	case WSAEINPROGRESS:
   443         case WSAEWOULDBLOCK:
   443 	case WSAEWOULDBLOCK:
   444             return (0);
   444 	    return (0);
   445 
   445 
   446         default:
   446 	default:
   447             console_fprintf(stderr, "_canAccessIOWithoutBlocking -> %d (0x%x)\n", winErrNo, winErrNo);
   447 	    console_fprintf(stderr, "_canAccessIOWithoutBlocking -> %d (0x%x)\n", winErrNo, winErrNo);
   448             return (-1);
   448 	    return (-1);
   449     }
   449     }
   450 
   450 
   451     /* not reached */
   451     /* not reached */
   452     return (0);
   452     return (0);
   453 }
   453 }
   464      */
   464      */
   465     FARPROC entry;
   465     FARPROC entry;
   466     static HINSTANCE handle = NULL;
   466     static HINSTANCE handle = NULL;
   467 
   467 
   468     if (handle == NULL) {
   468     if (handle == NULL) {
   469         handle = LoadLibrary("KERNEL32.DLL");
   469 	handle = LoadLibrary("KERNEL32.DLL");
   470     }
   470     }
   471     entry = GetProcAddress(handle, functionName);
   471     entry = GetProcAddress(handle, functionName);
   472     return entry;
   472     return entry;
   473 }
   473 }
   474 
   474 
   481      */
   481      */
   482     FARPROC entry;
   482     FARPROC entry;
   483     static HINSTANCE handle2 = NULL;
   483     static HINSTANCE handle2 = NULL;
   484 
   484 
   485     if (handle2 == NULL) {
   485     if (handle2 == NULL) {
   486         handle2 = LoadLibrary("iphlpapi.DLL");
   486 	handle2 = LoadLibrary("iphlpapi.DLL");
   487     }
   487     }
   488     entry = GetProcAddress(handle2, functionName);
   488     entry = GetProcAddress(handle2, functionName);
   489     return entry;
   489     return entry;
   490 }
   490 }
   491 
   491 
   496 
   496 
   497 copyright
   497 copyright
   498 "
   498 "
   499  COPYRIGHT (c) 1988 by Claus Gittinger
   499  COPYRIGHT (c) 1988 by Claus Gittinger
   500  COPYRIGHT (c) 1998-2004 by eXept Software AG
   500  COPYRIGHT (c) 1998-2004 by eXept Software AG
   501               All Rights Reserved
   501 	      All Rights Reserved
   502 
   502 
   503  This software is furnished under a license and may be used
   503  This software is furnished under a license and may be used
   504  only in accordance with the terms of that license and with the
   504  only in accordance with the terms of that license and with the
   505  inclusion of the above copyright notice.   This software may not
   505  inclusion of the above copyright notice.   This software may not
   506  be provided or otherwise made available to, or used by, any
   506  be provided or otherwise made available to, or used by, any
   526      able to get down to a select or fork system call easily (at least on Unix systems).
   526      able to get down to a select or fork system call easily (at least on Unix systems).
   527      You decide - portability vs. functionality)
   527      You decide - portability vs. functionality)
   528 
   528 
   529     [Class variables:]
   529     [Class variables:]
   530 
   530 
   531         HostName        <String>        remembered hostname
   531 	HostName        <String>        remembered hostname
   532 
   532 
   533         DomainName      <String>        remembered domainname
   533 	DomainName      <String>        remembered domainname
   534 
   534 
   535         CurrentDirectory <String>       remembered currentDirectories path
   535 	CurrentDirectory <String>       remembered currentDirectories path
   536 
   536 
   537     [author:]
   537     [author:]
   538         Claus Gittinger (initial version & cleanup)
   538 	Claus Gittinger (initial version & cleanup)
   539         Manfred Dierolf (many features)
   539 	Manfred Dierolf (many features)
   540 
   540 
   541     [see also:]
   541     [see also:]
   542         OSProcessStatus
   542 	OSProcessStatus
   543         Filename Date Time
   543 	Filename Date Time
   544         ExternalStream FileStream PipeStream Socket
   544 	ExternalStream FileStream PipeStream Socket
   545 "
   545 "
   546 !
   546 !
   547 
   547 
   548 examples
   548 examples
   549 "
   549 "
   550   various queries
   550   various queries
   551                                                                 [exBegin]
   551 								[exBegin]
   552     Transcript
   552     Transcript
   553         showCR:'hello ' , (OperatingSystem getLoginName)
   553 	showCR:'hello ' , (OperatingSystem getLoginName)
   554                                                                 [exEnd]
   554 								[exEnd]
   555 
   555 
   556                                                                 [exBegin]
   556 								[exBegin]
   557     OperatingSystem isUNIXlike ifTrue:[
   557     OperatingSystem isUNIXlike ifTrue:[
   558         Transcript showCR:'this is some UNIX-like OS'
   558 	Transcript showCR:'this is some UNIX-like OS'
   559     ] ifFalse:[
   559     ] ifFalse:[
   560         Transcript showCR:'this OS is not UNIX-like'
   560 	Transcript showCR:'this OS is not UNIX-like'
   561     ]
   561     ]
   562                                                                 [exEnd]
   562 								[exEnd]
   563 
   563 
   564                                                                 [exBegin]
   564 								[exBegin]
   565     Transcript
   565     Transcript
   566         showCR:'this machine is called ' , OperatingSystem getHostName
   566 	showCR:'this machine is called ' , OperatingSystem getHostName
   567                                                                 [exEnd]
   567 								[exEnd]
   568 
   568 
   569                                                                 [exBegin]
   569 								[exBegin]
   570     Transcript
   570     Transcript
   571         showCR:('this machine is in the '
   571 	showCR:('this machine is in the '
   572                , OperatingSystem getDomainName
   572 	       , OperatingSystem getDomainName
   573                , ' domain')
   573 	       , ' domain')
   574                                                                 [exEnd]
   574 								[exEnd]
   575 
   575 
   576                                                                 [exBegin]
   576 								[exBegin]
   577     Transcript
   577     Transcript
   578         showCR:('this machine''s CPU is a '
   578 	showCR:('this machine''s CPU is a '
   579                , OperatingSystem getCPUType
   579 	       , OperatingSystem getCPUType
   580                )
   580 	       )
   581                                                                 [exEnd]
   581 								[exEnd]
   582 
   582 
   583                                                                 [exBegin]
   583 								[exBegin]
   584     Transcript showCR:'executing ls command ...'.
   584     Transcript showCR:'executing ls command ...'.
   585     OperatingSystem executeCommand:'ls'.
   585     OperatingSystem executeCommand:'ls'.
   586     Transcript showCR:'... done.'.
   586     Transcript showCR:'... done.'.
   587                                                                 [exEnd]
   587 								[exEnd]
   588 
   588 
   589   locking a file
   589   locking a file
   590   (should be executed on two running smalltalks - not in two threads):
   590   (should be executed on two running smalltalks - not in two threads):
   591                                                                 [exBegin]
   591 								[exBegin]
   592     |f|
   592     |f|
   593 
   593 
   594     f := 'testFile' asFilename readWriteStream.
   594     f := 'testFile' asFilename readWriteStream.
   595 
   595 
   596     10 timesRepeat:[
   596     10 timesRepeat:[
   597         'about to lock ...' printCR.
   597 	'about to lock ...' printCR.
   598         [
   598 	[
   599           OperatingSystem
   599 	  OperatingSystem
   600             lockFD:(f fileDescriptor)
   600 	    lockFD:(f fileDescriptor)
   601             shared:false
   601 	    shared:false
   602             blocking:false
   602 	    blocking:false
   603         ] whileFalse:[
   603 	] whileFalse:[
   604             'process ' print. OperatingSystem getProcessId print. ' is waiting' printCR.
   604 	    'process ' print. OperatingSystem getProcessId print. ' is waiting' printCR.
   605             Delay waitForSeconds:1
   605 	    Delay waitForSeconds:1
   606         ].
   606 	].
   607         'LOCKED ...' printCR.
   607 	'LOCKED ...' printCR.
   608         Delay waitForSeconds:10.
   608 	Delay waitForSeconds:10.
   609         'unlock ...' printCR.
   609 	'unlock ...' printCR.
   610         (OperatingSystem
   610 	(OperatingSystem
   611             unlockFD:(f fileDescriptor)) printCR.
   611 	    unlockFD:(f fileDescriptor)) printCR.
   612         Delay waitForSeconds:3.
   612 	Delay waitForSeconds:3.
   613     ]
   613     ]
   614                                                                 [exBegin]
   614 								[exBegin]
   615 "
   615 "
   616 ! !
   616 ! !
   617 
   617 
   618 !Win32OperatingSystem class methodsFor:'initialization'!
   618 !Win32OperatingSystem class methodsFor:'initialization'!
   619 
   619 
   627     memset(&osvi, 0, sizeof(OSVERSIONINFO));
   627     memset(&osvi, 0, sizeof(OSVERSIONINFO));
   628     osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
   628     osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
   629     GetVersionEx (&osvi);
   629     GetVersionEx (&osvi);
   630 
   630 
   631     if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
   631     if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
   632         __isWinNT = 1;
   632 	__isWinNT = 1;
   633     } else {
   633     } else {
   634         __isWinNT = 0;
   634 	__isWinNT = 0;
   635     }
   635     }
   636 %}.
   636 %}.
   637 !
   637 !
   638 
   638 
   639 initialize
   639 initialize
   651 
   651 
   652 update:something with:aParameter from:changedObject
   652 update:something with:aParameter from:changedObject
   653     "catch image restart and flush some cached data"
   653     "catch image restart and flush some cached data"
   654 
   654 
   655     something == #earlyRestart ifTrue:[
   655     something == #earlyRestart ifTrue:[
   656         "
   656 	"
   657          flush cached data
   657 	 flush cached data
   658         "
   658 	"
   659         HostName := nil.
   659 	HostName := nil.
   660         DomainName := nil.
   660 	DomainName := nil.
   661         LastErrorNumber := nil.
   661 	LastErrorNumber := nil.
   662         PipeFailed := false.
   662 	PipeFailed := false.
   663         self initOSType
   663 	self initOSType
   664     ]
   664     ]
   665 
   665 
   666     "Modified: 22.4.1996 / 13:10:43 / cg"
   666     "Modified: 22.4.1996 / 13:10:43 / cg"
   667     "Created: 15.6.1996 / 15:22:37 / cg"
   667     "Created: 15.6.1996 / 15:22:37 / cg"
   668     "Modified: 7.1.1997 / 19:36:11 / stefan"
   668     "Modified: 7.1.1997 / 19:36:11 / stefan"
  1239     "change the file, into which log info is written"
  1239     "change the file, into which log info is written"
  1240 
  1240 
  1241     |logFilePath|
  1241     |logFilePath|
  1242 
  1242 
  1243     aFilenameOrNil notNil ifTrue:[
  1243     aFilenameOrNil notNil ifTrue:[
  1244         logFilePath := aFilenameOrNil asFilename pathName
  1244 	logFilePath := aFilenameOrNil asFilename pathName
  1245     ].
  1245     ].
  1246 
  1246 
  1247 %{
  1247 %{
  1248     extern void __win32_setLogFile();
  1248     extern void __win32_setLogFile();
  1249 
  1249 
  1250     if (__isString(logFilePath)) {
  1250     if (__isString(logFilePath)) {
  1251         __win32_setLogFile(__stringVal(logFilePath));
  1251 	__win32_setLogFile(__stringVal(logFilePath));
  1252     } else {
  1252     } else {
  1253         __win32_setLogFile( NULL );
  1253 	__win32_setLogFile( NULL );
  1254     }
  1254     }
  1255 %}
  1255 %}
  1256 
  1256 
  1257     "
  1257     "
  1258      Win32OperatingSystem win32LogFile:'myLog.log'
  1258      Win32OperatingSystem win32LogFile:'myLog.log'
  1295 
  1295 
  1296     if (__isSmallInteger(errNr) || (__unsignedLongIntVal(errNr) > 0)) {
  1296     if (__isSmallInteger(errNr) || (__unsignedLongIntVal(errNr) > 0)) {
  1297       int __eno = __unsignedLongIntVal(errNr);
  1297       int __eno = __unsignedLongIntVal(errNr);
  1298 
  1298 
  1299       if (__isWIN32Error(__eno)) {
  1299       if (__isWIN32Error(__eno)) {
  1300         switch (__eno & 0xFFFF) {
  1300 	switch (__eno & 0xFFFF) {
  1301             /*
  1301 	    /*
  1302              * WIN32 GetLastError returns
  1302 	     * WIN32 GetLastError returns
  1303              */
  1303 	     */
  1304             case ERROR_INVALID_FUNCTION:
  1304 	    case ERROR_INVALID_FUNCTION:
  1305                 sym = @symbol(ERROR_INVALID_FUNCTION);
  1305 		sym = @symbol(ERROR_INVALID_FUNCTION);
  1306                 typ = @symbol(illegalOperationSignal);
  1306 		typ = @symbol(illegalOperationSignal);
  1307                 break;
  1307 		break;
  1308 
  1308 
  1309             case ERROR_BAD_FORMAT:
  1309 	    case ERROR_BAD_FORMAT:
  1310                 sym = @symbol(ERROR_BAD_FORMAT);
  1310 		sym = @symbol(ERROR_BAD_FORMAT);
  1311                 typ = @symbol(invalidArgumentsSignal);
  1311 		typ = @symbol(invalidArgumentsSignal);
  1312                 break;
  1312 		break;
  1313 
  1313 
  1314             case ERROR_FILE_NOT_FOUND:
  1314 	    case ERROR_FILE_NOT_FOUND:
  1315                 sym = @symbol(ERROR_FILE_NOT_FOUND);
  1315 		sym = @symbol(ERROR_FILE_NOT_FOUND);
  1316                 typ = @symbol(nonexistentSignal);
  1316 		typ = @symbol(nonexistentSignal);
  1317                 break;
  1317 		break;
  1318 
  1318 
  1319             case ERROR_PATH_NOT_FOUND:
  1319 	    case ERROR_PATH_NOT_FOUND:
  1320                 sym = @symbol(ERROR_PATH_NOT_FOUND);
  1320 		sym = @symbol(ERROR_PATH_NOT_FOUND);
  1321                 typ = @symbol(nonexistentSignal);
  1321 		typ = @symbol(nonexistentSignal);
  1322                 break;
  1322 		break;
  1323 
  1323 
  1324             case ERROR_TOO_MANY_OPEN_FILES:
  1324 	    case ERROR_TOO_MANY_OPEN_FILES:
  1325                 sym = @symbol(ERROR_TOO_MANY_OPEN_FILES);
  1325 		sym = @symbol(ERROR_TOO_MANY_OPEN_FILES);
  1326                 typ = @symbol(noResourcesSignal);
  1326 		typ = @symbol(noResourcesSignal);
  1327                 break;
  1327 		break;
  1328 
  1328 
  1329             /*
  1329 	    /*
  1330              * what a nice errorCode - thats the most "useful" one I ever
  1330 	     * what a nice errorCode - thats the most "useful" one I ever
  1331              * encountered ... (... those stupid micro-softies ...)
  1331 	     * encountered ... (... those stupid micro-softies ...)
  1332              */
  1332 	     */
  1333             case ERROR_OPEN_FAILED:
  1333 	    case ERROR_OPEN_FAILED:
  1334                 sym = @symbol(ERROR_OPEN_FAILED);
  1334 		sym = @symbol(ERROR_OPEN_FAILED);
  1335                 typ = @symbol(noResourcesSignal);
  1335 		typ = @symbol(noResourcesSignal);
  1336                 break;
  1336 		break;
  1337 
  1337 
  1338             case ERROR_ACCESS_DENIED:
  1338 	    case ERROR_ACCESS_DENIED:
  1339                 sym = @symbol(ERROR_ACCESS_DENIED);
  1339 		sym = @symbol(ERROR_ACCESS_DENIED);
  1340                 typ = @symbol(noPermissionsSignal);
  1340 		typ = @symbol(noPermissionsSignal);
  1341                 break;
  1341 		break;
  1342 
  1342 
  1343             case ERROR_INVALID_HANDLE:
  1343 	    case ERROR_INVALID_HANDLE:
  1344                 sym = @symbol(ERROR_INVALID_HANDLE);
  1344 		sym = @symbol(ERROR_INVALID_HANDLE);
  1345                 typ = @symbol(invalidArgumentsSignal);
  1345 		typ = @symbol(invalidArgumentsSignal);
  1346                 break;
  1346 		break;
  1347 
  1347 
  1348             case ERROR_NOT_ENOUGH_MEMORY:
  1348 	    case ERROR_NOT_ENOUGH_MEMORY:
  1349                 sym = @symbol(ERROR_NOT_ENOUGH_MEMORY);
  1349 		sym = @symbol(ERROR_NOT_ENOUGH_MEMORY);
  1350                 typ = @symbol(noResourcesSignal);
  1350 		typ = @symbol(noResourcesSignal);
  1351                 break;
  1351 		break;
  1352 
  1352 
  1353             case ERROR_INVALID_ACCESS:
  1353 	    case ERROR_INVALID_ACCESS:
  1354                 sym = @symbol(ERROR_INVALID_ACCESS);
  1354 		sym = @symbol(ERROR_INVALID_ACCESS);
  1355                 typ = @symbol(inappropriateOperationSignal);
  1355 		typ = @symbol(inappropriateOperationSignal);
  1356                 break;
  1356 		break;
  1357 
  1357 
  1358             case ERROR_INVALID_DATA:
  1358 	    case ERROR_INVALID_DATA:
  1359                 sym = @symbol(ERROR_INVALID_DATA);
  1359 		sym = @symbol(ERROR_INVALID_DATA);
  1360                 typ = @symbol(invalidArgumentsSignal);
  1360 		typ = @symbol(invalidArgumentsSignal);
  1361                 break;
  1361 		break;
  1362 
  1362 
  1363             case ERROR_INVALID_NAME:
  1363 	    case ERROR_INVALID_NAME:
  1364                 sym = @symbol(ERROR_INVALID_NAME);
  1364 		sym = @symbol(ERROR_INVALID_NAME);
  1365                 typ = @symbol(invalidArgumentsSignal);
  1365 		typ = @symbol(invalidArgumentsSignal);
  1366                 break;
  1366 		break;
  1367 
  1367 
  1368             case ERROR_ARENA_TRASHED:
  1368 	    case ERROR_ARENA_TRASHED:
  1369                 sym = @symbol(ERROR_ARENA_TRASHED);
  1369 		sym = @symbol(ERROR_ARENA_TRASHED);
  1370                 typ = @symbol(noResourcesSignal);
  1370 		typ = @symbol(noResourcesSignal);
  1371                 break;
  1371 		break;
  1372 
  1372 
  1373             case ERROR_OUTOFMEMORY:
  1373 	    case ERROR_OUTOFMEMORY:
  1374                 sym = @symbol(ERROR_OUTOFMEMORY);
  1374 		sym = @symbol(ERROR_OUTOFMEMORY);
  1375                 typ = @symbol(noResourcesSignal);
  1375 		typ = @symbol(noResourcesSignal);
  1376                 break;
  1376 		break;
  1377 
  1377 
  1378             case ERROR_BROKEN_PIPE:
  1378 	    case ERROR_BROKEN_PIPE:
  1379                 sym = @symbol(ERROR_BROKEN_PIPE);
  1379 		sym = @symbol(ERROR_BROKEN_PIPE);
  1380                 typ = @symbol(peerFaultSignal);
  1380 		typ = @symbol(peerFaultSignal);
  1381                 break;
  1381 		break;
  1382 
  1382 
  1383             case ERROR_GEN_FAILURE:
  1383 	    case ERROR_GEN_FAILURE:
  1384                 sym = @symbol(ERROR_GEN_FAILURE);
  1384 		sym = @symbol(ERROR_GEN_FAILURE);
  1385                 break;
  1385 		break;
  1386 
  1386 
  1387             case ERROR_WRITE_PROTECT:
  1387 	    case ERROR_WRITE_PROTECT:
  1388                 sym = @symbol(ERROR_WRITE_PROTECT);
  1388 		sym = @symbol(ERROR_WRITE_PROTECT);
  1389                 typ = @symbol(inappropriateOperationSignal);
  1389 		typ = @symbol(inappropriateOperationSignal);
  1390                 break;
  1390 		break;
  1391 
  1391 
  1392             case ERROR_WRITE_FAULT:
  1392 	    case ERROR_WRITE_FAULT:
  1393                 sym = @symbol(ERROR_WRITE_FAULT);
  1393 		sym = @symbol(ERROR_WRITE_FAULT);
  1394                 typ = @symbol(transferFaultSignal);
  1394 		typ = @symbol(transferFaultSignal);
  1395                 break;
  1395 		break;
  1396 
  1396 
  1397             case ERROR_READ_FAULT:
  1397 	    case ERROR_READ_FAULT:
  1398                 sym = @symbol(ERROR_READ_FAULT);
  1398 		sym = @symbol(ERROR_READ_FAULT);
  1399                 typ = @symbol(transferFaultSignal);
  1399 		typ = @symbol(transferFaultSignal);
  1400                 break;
  1400 		break;
  1401 
  1401 
  1402             case ERROR_HANDLE_DISK_FULL:
  1402 	    case ERROR_HANDLE_DISK_FULL:
  1403                 sym = @symbol(ERROR_HANDLE_DISK_FULL);
  1403 		sym = @symbol(ERROR_HANDLE_DISK_FULL);
  1404                 typ = @symbol(volumeFullSignal);
  1404 		typ = @symbol(volumeFullSignal);
  1405                 break;
  1405 		break;
  1406 
  1406 
  1407             case ERROR_DISK_FULL:
  1407 	    case ERROR_DISK_FULL:
  1408                 sym = @symbol(ERROR_DISK_FULL);
  1408 		sym = @symbol(ERROR_DISK_FULL);
  1409                 typ = @symbol(volumeFullSignal);
  1409 		typ = @symbol(volumeFullSignal);
  1410                 break;
  1410 		break;
  1411 
  1411 
  1412             case ERROR_SHARING_VIOLATION:
  1412 	    case ERROR_SHARING_VIOLATION:
  1413                 sym = @symbol(ERROR_SHARING_VIOLATION);
  1413 		sym = @symbol(ERROR_SHARING_VIOLATION);
  1414                 typ = @symbol(noPermissionsSignal);
  1414 		typ = @symbol(noPermissionsSignal);
  1415                 break;
  1415 		break;
  1416 
  1416 
  1417             case ERROR_LOCK_VIOLATION:
  1417 	    case ERROR_LOCK_VIOLATION:
  1418                 sym = @symbol(ERROR_LOCK_VIOLATION);
  1418 		sym = @symbol(ERROR_LOCK_VIOLATION);
  1419                 typ = @symbol(noPermissionsSignal);
  1419 		typ = @symbol(noPermissionsSignal);
  1420                 break;
  1420 		break;
  1421 
  1421 
  1422             case ERROR_INVALID_PARAMETER:
  1422 	    case ERROR_INVALID_PARAMETER:
  1423                 sym = @symbol(ERROR_INVALID_PARAMETER);
  1423 		sym = @symbol(ERROR_INVALID_PARAMETER);
  1424                 typ = @symbol(invalidArgumentsSignal);
  1424 		typ = @symbol(invalidArgumentsSignal);
  1425                 break;
  1425 		break;
  1426 
  1426 
  1427             case ERROR_NET_WRITE_FAULT:
  1427 	    case ERROR_NET_WRITE_FAULT:
  1428                 sym = @symbol(ERROR_NET_WRITE_FAULT);
  1428 		sym = @symbol(ERROR_NET_WRITE_FAULT);
  1429                 typ = @symbol(transferFaultSignal);
  1429 		typ = @symbol(transferFaultSignal);
  1430                 break;
  1430 		break;
  1431 
  1431 
  1432             case ERROR_NOT_SUPPORTED:
  1432 	    case ERROR_NOT_SUPPORTED:
  1433                 sym = @symbol(ERROR_NOT_SUPPORTED);
  1433 		sym = @symbol(ERROR_NOT_SUPPORTED);
  1434                 typ = @symbol(inappropriateOperationSignal);
  1434 		typ = @symbol(inappropriateOperationSignal);
  1435                 break;
  1435 		break;
  1436 
  1436 
  1437             case ERROR_REM_NOT_LIST:
  1437 	    case ERROR_REM_NOT_LIST:
  1438                 sym = @symbol(ERROR_REM_NOT_LIST);
  1438 		sym = @symbol(ERROR_REM_NOT_LIST);
  1439                 typ = @symbol(noResourcesSignal);
  1439 		typ = @symbol(noResourcesSignal);
  1440                 break;
  1440 		break;
  1441 
  1441 
  1442             case ERROR_NETWORK_ACCESS_DENIED:
  1442 	    case ERROR_NETWORK_ACCESS_DENIED:
  1443                 sym = @symbol(ERROR_NETWORK_ACCESS_DENIED);
  1443 		sym = @symbol(ERROR_NETWORK_ACCESS_DENIED);
  1444                 typ = @symbol(noPermissionsSignal);
  1444 		typ = @symbol(noPermissionsSignal);
  1445                 break;
  1445 		break;
  1446 
  1446 
  1447             case ERROR_DUP_NAME:
  1447 	    case ERROR_DUP_NAME:
  1448                 sym = @symbol(ERROR_DUP_NAME);
  1448 		sym = @symbol(ERROR_DUP_NAME);
  1449                 typ = @symbol(noResourcesSignal);
  1449 		typ = @symbol(noResourcesSignal);
  1450                 break;
  1450 		break;
  1451 
  1451 
  1452             case ERROR_BAD_NETPATH:
  1452 	    case ERROR_BAD_NETPATH:
  1453                 sym = @symbol(ERROR_BAD_NETPATH);
  1453 		sym = @symbol(ERROR_BAD_NETPATH);
  1454                 typ = @symbol(noResourcesSignal);
  1454 		typ = @symbol(noResourcesSignal);
  1455                 break;
  1455 		break;
  1456 
  1456 
  1457             case ERROR_NETWORK_BUSY:
  1457 	    case ERROR_NETWORK_BUSY:
  1458                 sym = @symbol(ERROR_NETWORK_BUSY);
  1458 		sym = @symbol(ERROR_NETWORK_BUSY);
  1459                 typ = @symbol(noResourcesSignal);
  1459 		typ = @symbol(noResourcesSignal);
  1460                 break;
  1460 		break;
  1461 
  1461 
  1462             case ERROR_DRIVE_LOCKED:
  1462 	    case ERROR_DRIVE_LOCKED:
  1463                 sym = @symbol(ERROR_DRIVE_LOCKED);
  1463 		sym = @symbol(ERROR_DRIVE_LOCKED);
  1464                 typ = @symbol(inappropriateOperationSignal);
  1464 		typ = @symbol(inappropriateOperationSignal);
  1465                 break;
  1465 		break;
  1466 
  1466 
  1467             case ERROR_INVALID_DRIVE:
  1467 	    case ERROR_INVALID_DRIVE:
  1468                 sym = @symbol(ERROR_INVALID_DRIVE);
  1468 		sym = @symbol(ERROR_INVALID_DRIVE);
  1469                 typ = @symbol(invalidArgumentsSignal);
  1469 		typ = @symbol(invalidArgumentsSignal);
  1470                 break;
  1470 		break;
  1471 
  1471 
  1472             case ERROR_WRONG_DISK:
  1472 	    case ERROR_WRONG_DISK:
  1473                 sym = @symbol(ERROR_WRONG_DISK);
  1473 		sym = @symbol(ERROR_WRONG_DISK);
  1474                 typ = @symbol(noResourcesSignal);
  1474 		typ = @symbol(noResourcesSignal);
  1475                 break;
  1475 		break;
  1476 
  1476 
  1477             case ERROR_CURRENT_DIRECTORY:
  1477 	    case ERROR_CURRENT_DIRECTORY:
  1478                 sym = @symbol(ERROR_CURRENT_DIRECTORY);
  1478 		sym = @symbol(ERROR_CURRENT_DIRECTORY);
  1479                 typ = @symbol(invalidArgumentsSignal);
  1479 		typ = @symbol(invalidArgumentsSignal);
  1480                 break;
  1480 		break;
  1481 
  1481 
  1482             /*
  1482 	    /*
  1483              * what a nice errorCode - thats the most "useful" one I ever
  1483 	     * what a nice errorCode - thats the most "useful" one I ever
  1484              * encountered ... (... those stupid micro-softies ...)
  1484 	     * encountered ... (... those stupid micro-softies ...)
  1485              */
  1485 	     */
  1486             case ERROR_CANNOT_MAKE:
  1486 	    case ERROR_CANNOT_MAKE:
  1487                 sym = @symbol(ERROR_CANNOT_MAKE);
  1487 		sym = @symbol(ERROR_CANNOT_MAKE);
  1488                 typ = @symbol(inappropriateOperationSignal);
  1488 		typ = @symbol(inappropriateOperationSignal);
  1489                 break;
  1489 		break;
  1490 
  1490 
  1491             case ERROR_NO_MORE_FILES:
  1491 	    case ERROR_NO_MORE_FILES:
  1492                 sym = @symbol(ERROR_NO_MORE_FILES);
  1492 		sym = @symbol(ERROR_NO_MORE_FILES);
  1493                 typ = @symbol(noResourcesSignal);
  1493 		typ = @symbol(noResourcesSignal);
  1494                 break;
  1494 		break;
  1495 
  1495 
  1496             case ERROR_NOT_READY:
  1496 	    case ERROR_NOT_READY:
  1497                 sym = @symbol(ERROR_NOT_READY);
  1497 		sym = @symbol(ERROR_NOT_READY);
  1498                 typ = @symbol(noResourcesSignal);
  1498 		typ = @symbol(noResourcesSignal);
  1499                 break;
  1499 		break;
  1500 
  1500 
  1501             case ERROR_NOT_DOS_DISK:
  1501 	    case ERROR_NOT_DOS_DISK:
  1502                 sym = @symbol(ERROR_NOT_DOS_DISK);
  1502 		sym = @symbol(ERROR_NOT_DOS_DISK);
  1503                 typ = @symbol(invalidArgumentsSignal);
  1503 		typ = @symbol(invalidArgumentsSignal);
  1504                 break;
  1504 		break;
  1505 
  1505 
  1506             case ERROR_OUT_OF_PAPER:
  1506 	    case ERROR_OUT_OF_PAPER:
  1507                 sym = @symbol(ERROR_OUT_OF_PAPER);
  1507 		sym = @symbol(ERROR_OUT_OF_PAPER);
  1508                 typ = @symbol(noResourcesSignal);
  1508 		typ = @symbol(noResourcesSignal);
  1509                 break;
  1509 		break;
  1510 
  1510 
  1511             case ERROR_PRINTQ_FULL:
  1511 	    case ERROR_PRINTQ_FULL:
  1512                 sym = @symbol(ERROR_PRINTQ_FULL);
  1512 		sym = @symbol(ERROR_PRINTQ_FULL);
  1513                 typ = @symbol(noResourcesSignal);
  1513 		typ = @symbol(noResourcesSignal);
  1514                 break;
  1514 		break;
  1515 
  1515 
  1516             default:
  1516 	    default:
  1517                 sym = nil;
  1517 		sym = nil;
  1518                 break;
  1518 		break;
  1519         }
  1519 	}
  1520       } else {
  1520       } else {
  1521         switch (__eno) {
  1521 	switch (__eno) {
  1522             /*
  1522 	    /*
  1523              * POSIX errnos - these should be defined
  1523 	     * POSIX errnos - these should be defined
  1524              */
  1524 	     */
  1525 #ifdef EPERM
  1525 #ifdef EPERM
  1526             case EPERM:
  1526 	    case EPERM:
  1527                 sym = @symbol(EPERM);
  1527 		sym = @symbol(EPERM);
  1528                 typ = @symbol(noPermissionsSignal);
  1528 		typ = @symbol(noPermissionsSignal);
  1529                 break;
  1529 		break;
  1530 #endif
  1530 #endif
  1531 #ifdef ENOENT
  1531 #ifdef ENOENT
  1532             case ENOENT:
  1532 	    case ENOENT:
  1533                 sym = @symbol(ENOENT);
  1533 		sym = @symbol(ENOENT);
  1534                 typ = @symbol(nonexistentSignal);
  1534 		typ = @symbol(nonexistentSignal);
  1535                 break;
  1535 		break;
  1536 #endif
  1536 #endif
  1537 #ifdef ESRCH
  1537 #ifdef ESRCH
  1538             case ESRCH:
  1538 	    case ESRCH:
  1539                 sym = @symbol(ESRCH);
  1539 		sym = @symbol(ESRCH);
  1540                 typ = @symbol(unavailableReferentSignal);
  1540 		typ = @symbol(unavailableReferentSignal);
  1541                 break;
  1541 		break;
  1542 #endif
  1542 #endif
  1543 #ifdef EINTR
  1543 #ifdef EINTR
  1544             case EINTR:
  1544 	    case EINTR:
  1545                 sym = @symbol(EINTR);
  1545 		sym = @symbol(EINTR);
  1546                 typ = @symbol(transientErrorSignal);
  1546 		typ = @symbol(transientErrorSignal);
  1547                 break;
  1547 		break;
  1548 #endif
  1548 #endif
  1549 #ifdef EIO
  1549 #ifdef EIO
  1550             case EIO:
  1550 	    case EIO:
  1551                 sym = @symbol(EIO);
  1551 		sym = @symbol(EIO);
  1552                 typ = @symbol(transferFaultSignal);
  1552 		typ = @symbol(transferFaultSignal);
  1553                 break;
  1553 		break;
  1554 #endif
  1554 #endif
  1555 #ifdef ENXIO
  1555 #ifdef ENXIO
  1556             case ENXIO:
  1556 	    case ENXIO:
  1557                 sym = @symbol(ENXIO);
  1557 		sym = @symbol(ENXIO);
  1558                 typ = @symbol(unavailableReferentSignal);
  1558 		typ = @symbol(unavailableReferentSignal);
  1559                 break;
  1559 		break;
  1560 #endif
  1560 #endif
  1561 #ifdef E2BIG
  1561 #ifdef E2BIG
  1562             case E2BIG:
  1562 	    case E2BIG:
  1563                 sym = @symbol(E2BIG);
  1563 		sym = @symbol(E2BIG);
  1564                 typ = @symbol(invalidArgumentsSignal);
  1564 		typ = @symbol(invalidArgumentsSignal);
  1565                 break;
  1565 		break;
  1566 #endif
  1566 #endif
  1567 #ifdef ENOEXEC
  1567 #ifdef ENOEXEC
  1568             case ENOEXEC:
  1568 	    case ENOEXEC:
  1569                 sym = @symbol(ENOEXEC);
  1569 		sym = @symbol(ENOEXEC);
  1570                 typ = @symbol(inappropriateOperationSignal);
  1570 		typ = @symbol(inappropriateOperationSignal);
  1571                 break;
  1571 		break;
  1572 #endif
  1572 #endif
  1573 #ifdef EBADF
  1573 #ifdef EBADF
  1574             case EBADF:
  1574 	    case EBADF:
  1575                 sym = @symbol(EBADF);
  1575 		sym = @symbol(EBADF);
  1576                 typ = @symbol(badAccessorSignal);
  1576 		typ = @symbol(badAccessorSignal);
  1577                 break;
  1577 		break;
  1578 #endif
  1578 #endif
  1579 #ifdef ECHILD
  1579 #ifdef ECHILD
  1580             case ECHILD:
  1580 	    case ECHILD:
  1581                 sym = @symbol(ECHILD);
  1581 		sym = @symbol(ECHILD);
  1582                 typ = @symbol(informationSignal);
  1582 		typ = @symbol(informationSignal);
  1583                 break;
  1583 		break;
  1584 #endif
  1584 #endif
  1585 #if !defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN)
  1585 #if !defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN)
  1586             case EAGAIN:
  1586 	    case EAGAIN:
  1587                 sym = @symbol(EAGAIN);
  1587 		sym = @symbol(EAGAIN);
  1588                 typ = @symbol(notReadySignal);
  1588 		typ = @symbol(notReadySignal);
  1589                 break;
  1589 		break;
  1590 #endif
  1590 #endif
  1591 #ifdef ENOMEM
  1591 #ifdef ENOMEM
  1592             case ENOMEM:
  1592 	    case ENOMEM:
  1593                 sym = @symbol(ENOMEM);
  1593 		sym = @symbol(ENOMEM);
  1594                 typ = @symbol(noMemorySignal);
  1594 		typ = @symbol(noMemorySignal);
  1595                 break;
  1595 		break;
  1596 #endif
  1596 #endif
  1597 #ifdef EACCES
  1597 #ifdef EACCES
  1598             case EACCES:
  1598 	    case EACCES:
  1599                 sym = @symbol(EACCES);
  1599 		sym = @symbol(EACCES);
  1600                 typ = @symbol(noPermissionsSignal);
  1600 		typ = @symbol(noPermissionsSignal);
  1601                 break;
  1601 		break;
  1602 #endif
  1602 #endif
  1603 #ifdef EFAULT
  1603 #ifdef EFAULT
  1604             case EFAULT:
  1604 	    case EFAULT:
  1605                 sym = @symbol(EFAULT);
  1605 		sym = @symbol(EFAULT);
  1606                 typ = @symbol(invalidArgumentsSignal);
  1606 		typ = @symbol(invalidArgumentsSignal);
  1607                 break;
  1607 		break;
  1608 #endif
  1608 #endif
  1609 #ifdef EBUSY
  1609 #ifdef EBUSY
  1610             case EBUSY:
  1610 	    case EBUSY:
  1611                 sym = @symbol(EBUSY);
  1611 		sym = @symbol(EBUSY);
  1612                 typ = @symbol(unavailableReferentSignal);
  1612 		typ = @symbol(unavailableReferentSignal);
  1613                 break;
  1613 		break;
  1614 #endif
  1614 #endif
  1615 #ifdef EEXIST
  1615 #ifdef EEXIST
  1616             case EEXIST:
  1616 	    case EEXIST:
  1617                 sym = @symbol(EEXIST);
  1617 		sym = @symbol(EEXIST);
  1618                 typ = @symbol(existingReferentSignal);
  1618 		typ = @symbol(existingReferentSignal);
  1619                 break;
  1619 		break;
  1620 #endif
  1620 #endif
  1621 #ifdef EXDEV
  1621 #ifdef EXDEV
  1622             case EXDEV:
  1622 	    case EXDEV:
  1623                 sym = @symbol(EXDEV);
  1623 		sym = @symbol(EXDEV);
  1624                 typ = @symbol(inappropriateReferentSignal);
  1624 		typ = @symbol(inappropriateReferentSignal);
  1625                 break;
  1625 		break;
  1626 #endif
  1626 #endif
  1627 #ifdef ENODEV
  1627 #ifdef ENODEV
  1628             case ENODEV:
  1628 	    case ENODEV:
  1629                 sym = @symbol(ENODEV);
  1629 		sym = @symbol(ENODEV);
  1630                 typ = @symbol(inaccessibleSignal);
  1630 		typ = @symbol(inaccessibleSignal);
  1631                 break;
  1631 		break;
  1632 #endif
  1632 #endif
  1633 #ifdef ENOTDIR
  1633 #ifdef ENOTDIR
  1634             case ENOTDIR:
  1634 	    case ENOTDIR:
  1635                 sym = @symbol(ENOTDIR);
  1635 		sym = @symbol(ENOTDIR);
  1636                 typ = @symbol(inappropriateOperationSignal);
  1636 		typ = @symbol(inappropriateOperationSignal);
  1637                 break;
  1637 		break;
  1638 #endif
  1638 #endif
  1639 #ifdef EISDIR
  1639 #ifdef EISDIR
  1640             case EISDIR:
  1640 	    case EISDIR:
  1641                 sym = @symbol(EISDIR);
  1641 		sym = @symbol(EISDIR);
  1642                 typ = @symbol(inappropriateOperationSignal);
  1642 		typ = @symbol(inappropriateOperationSignal);
  1643                 break;
  1643 		break;
  1644 #endif
  1644 #endif
  1645 #ifdef EINVAL
  1645 #ifdef EINVAL
  1646             case EINVAL:
  1646 	    case EINVAL:
  1647                 sym = @symbol(EINVAL);
  1647 		sym = @symbol(EINVAL);
  1648                 typ = @symbol(invalidArgumentsSignal);
  1648 		typ = @symbol(invalidArgumentsSignal);
  1649                 break;
  1649 		break;
  1650 #endif
  1650 #endif
  1651 #ifdef ENFILE
  1651 #ifdef ENFILE
  1652             case ENFILE:
  1652 	    case ENFILE:
  1653                 sym = @symbol(ENFILE);
  1653 		sym = @symbol(ENFILE);
  1654                 typ = @symbol(noResourcesSignal);
  1654 		typ = @symbol(noResourcesSignal);
  1655                 break;
  1655 		break;
  1656 #endif
  1656 #endif
  1657 #ifdef EMFILE
  1657 #ifdef EMFILE
  1658             case EMFILE:
  1658 	    case EMFILE:
  1659                 sym = @symbol(EMFILE);
  1659 		sym = @symbol(EMFILE);
  1660                 typ = @symbol(noResourcesSignal);
  1660 		typ = @symbol(noResourcesSignal);
  1661                 break;
  1661 		break;
  1662 #endif
  1662 #endif
  1663 #ifdef ENOTTY
  1663 #ifdef ENOTTY
  1664             case ENOTTY:
  1664 	    case ENOTTY:
  1665                 sym = @symbol(ENOTTY);
  1665 		sym = @symbol(ENOTTY);
  1666                 typ = @symbol(inappropriateOperationSignal);
  1666 		typ = @symbol(inappropriateOperationSignal);
  1667                 break;
  1667 		break;
  1668 #endif
  1668 #endif
  1669 #ifdef EFBIG
  1669 #ifdef EFBIG
  1670             case EFBIG:
  1670 	    case EFBIG:
  1671                 sym = @symbol(EFBIG);
  1671 		sym = @symbol(EFBIG);
  1672                 typ = @symbol(noResourcesSignal);
  1672 		typ = @symbol(noResourcesSignal);
  1673                 break;
  1673 		break;
  1674 #endif
  1674 #endif
  1675 #ifdef ENOSPC
  1675 #ifdef ENOSPC
  1676             case ENOSPC:
  1676 	    case ENOSPC:
  1677                 sym = @symbol(ENOSPC);
  1677 		sym = @symbol(ENOSPC);
  1678                 typ = @symbol(noResourcesSignal);
  1678 		typ = @symbol(noResourcesSignal);
  1679                 break;
  1679 		break;
  1680 #endif
  1680 #endif
  1681 #ifdef ESPIPE
  1681 #ifdef ESPIPE
  1682             case ESPIPE:
  1682 	    case ESPIPE:
  1683                 sym = @symbol(ESPIPE);
  1683 		sym = @symbol(ESPIPE);
  1684                 typ = @symbol(inappropriateOperationSignal);
  1684 		typ = @symbol(inappropriateOperationSignal);
  1685                 break;
  1685 		break;
  1686 #endif
  1686 #endif
  1687 #ifdef EROFS
  1687 #ifdef EROFS
  1688             case EROFS:
  1688 	    case EROFS:
  1689                 sym = @symbol(EROFS);
  1689 		sym = @symbol(EROFS);
  1690                 typ = @symbol(inappropriateOperationSignal);
  1690 		typ = @symbol(inappropriateOperationSignal);
  1691                 break;
  1691 		break;
  1692 #endif
  1692 #endif
  1693 #ifdef EMLINK
  1693 #ifdef EMLINK
  1694             case EMLINK:
  1694 	    case EMLINK:
  1695                 sym = @symbol(EMLINK);
  1695 		sym = @symbol(EMLINK);
  1696                 typ = @symbol(rangeErrorSignal);
  1696 		typ = @symbol(rangeErrorSignal);
  1697                 break;
  1697 		break;
  1698 #endif
  1698 #endif
  1699 #ifdef EPIPE
  1699 #ifdef EPIPE
  1700             case EPIPE:
  1700 	    case EPIPE:
  1701                 sym = @symbol(EPIPE);
  1701 		sym = @symbol(EPIPE);
  1702                 typ = @symbol(peerFaultSignal);
  1702 		typ = @symbol(peerFaultSignal);
  1703                 break;
  1703 		break;
  1704 #endif
  1704 #endif
  1705 #ifdef EDOM
  1705 #ifdef EDOM
  1706             case EDOM:
  1706 	    case EDOM:
  1707                 sym = @symbol(EDOM);
  1707 		sym = @symbol(EDOM);
  1708                 typ = @symbol(rangeErrorSignal);
  1708 		typ = @symbol(rangeErrorSignal);
  1709                 break;
  1709 		break;
  1710 #endif
  1710 #endif
  1711 #ifdef ERANGE
  1711 #ifdef ERANGE
  1712             case ERANGE:
  1712 	    case ERANGE:
  1713                 sym = @symbol(ERANGE);
  1713 		sym = @symbol(ERANGE);
  1714                 typ = @symbol(rangeErrorSignal);
  1714 		typ = @symbol(rangeErrorSignal);
  1715                 break;
  1715 		break;
  1716 #endif
  1716 #endif
  1717 #ifdef EDEADLK
  1717 #ifdef EDEADLK
  1718 # if EDEADLK != EWOULDBLOCK
  1718 # if EDEADLK != EWOULDBLOCK
  1719             case EDEADLK:
  1719 	    case EDEADLK:
  1720                 sym = @symbol(EDEADLK);
  1720 		sym = @symbol(EDEADLK);
  1721                 typ = @symbol(noResourcesSignal);
  1721 		typ = @symbol(noResourcesSignal);
  1722                 break;
  1722 		break;
  1723 # endif
  1723 # endif
  1724 #endif
  1724 #endif
  1725 #ifdef ENAMETOOLONG
  1725 #ifdef ENAMETOOLONG
  1726             case ENAMETOOLONG:
  1726 	    case ENAMETOOLONG:
  1727                 sym = @symbol(ENAMETOOLONG);
  1727 		sym = @symbol(ENAMETOOLONG);
  1728                 typ = @symbol(rangeErrorSignal);
  1728 		typ = @symbol(rangeErrorSignal);
  1729                 break;
  1729 		break;
  1730 #endif
  1730 #endif
  1731 #ifdef ENOLCK
  1731 #ifdef ENOLCK
  1732             case ENOLCK:
  1732 	    case ENOLCK:
  1733                 sym = @symbol(ENOLCK);
  1733 		sym = @symbol(ENOLCK);
  1734                 typ = @symbol(inappropriateOperationSignal);
  1734 		typ = @symbol(inappropriateOperationSignal);
  1735                 break;
  1735 		break;
  1736 #endif
  1736 #endif
  1737 #ifdef ENOSYS
  1737 #ifdef ENOSYS
  1738             case ENOSYS:
  1738 	    case ENOSYS:
  1739                 sym = @symbol(ENOSYS);
  1739 		sym = @symbol(ENOSYS);
  1740                 typ = @symbol(inappropriateOperationSignal);
  1740 		typ = @symbol(inappropriateOperationSignal);
  1741                 break;
  1741 		break;
  1742 #endif
  1742 #endif
  1743 #if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST)
  1743 #if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST)
  1744             case ENOTEMPTY:
  1744 	    case ENOTEMPTY:
  1745                 sym = @symbol(ENOTEMPTY);
  1745 		sym = @symbol(ENOTEMPTY);
  1746                 typ = @symbol(inappropriateReferentSignal);
  1746 		typ = @symbol(inappropriateReferentSignal);
  1747                 break;
  1747 		break;
  1748 #endif
  1748 #endif
  1749 #ifdef EILSEQ
  1749 #ifdef EILSEQ
  1750             case EILSEQ:
  1750 	    case EILSEQ:
  1751                 sym = @symbol(EILSEQ);
  1751 		sym = @symbol(EILSEQ);
  1752                 typ = @symbol(transferFaultSignal);
  1752 		typ = @symbol(transferFaultSignal);
  1753                 break;
  1753 		break;
  1754 #endif
  1754 #endif
  1755             /*
  1755 	    /*
  1756              * XPG3 errnos - defined on most systems
  1756 	     * XPG3 errnos - defined on most systems
  1757              */
  1757 	     */
  1758 #ifdef ENOTBLK
  1758 #ifdef ENOTBLK
  1759             case ENOTBLK:
  1759 	    case ENOTBLK:
  1760                 sym = @symbol(ENOTBLK);
  1760 		sym = @symbol(ENOTBLK);
  1761                 typ = @symbol(inappropriateReferentSignal);
  1761 		typ = @symbol(inappropriateReferentSignal);
  1762                 break;
  1762 		break;
  1763 #endif
  1763 #endif
  1764 #ifdef ETXTBSY
  1764 #ifdef ETXTBSY
  1765             case ETXTBSY:
  1765 	    case ETXTBSY:
  1766                 sym = @symbol(ETXTBSY);
  1766 		sym = @symbol(ETXTBSY);
  1767                 typ = @symbol(inaccessibleSignal);
  1767 		typ = @symbol(inaccessibleSignal);
  1768                 break;
  1768 		break;
  1769 #endif
  1769 #endif
  1770             /*
  1770 	    /*
  1771              * some others
  1771 	     * some others
  1772              */
  1772 	     */
  1773 #ifdef EWOULDBLOCK
  1773 #ifdef EWOULDBLOCK
  1774             case EWOULDBLOCK:
  1774 	    case EWOULDBLOCK:
  1775                 sym = @symbol(EWOULDBLOCK);
  1775 		sym = @symbol(EWOULDBLOCK);
  1776                 typ = @symbol(notReadySignal);
  1776 		typ = @symbol(notReadySignal);
  1777                 break;
  1777 		break;
  1778 #endif
  1778 #endif
  1779 #ifdef ENOMSG
  1779 #ifdef ENOMSG
  1780             case ENOMSG:
  1780 	    case ENOMSG:
  1781                 sym = @symbol(ENOMSG);
  1781 		sym = @symbol(ENOMSG);
  1782                 typ = @symbol(noDataSignal);
  1782 		typ = @symbol(noDataSignal);
  1783                 break;
  1783 		break;
  1784 #endif
  1784 #endif
  1785 #ifdef ELOOP
  1785 #ifdef ELOOP
  1786             case ELOOP:
  1786 	    case ELOOP:
  1787                 sym = @symbol(ELOOP);
  1787 		sym = @symbol(ELOOP);
  1788                 typ = @symbol(rangeErrorSignal);
  1788 		typ = @symbol(rangeErrorSignal);
  1789                 break;
  1789 		break;
  1790 #endif
  1790 #endif
  1791 
  1791 
  1792             /*
  1792 	    /*
  1793              * some stream errors
  1793 	     * some stream errors
  1794              */
  1794 	     */
  1795 #ifdef ETIME
  1795 #ifdef ETIME
  1796             case ETIME:
  1796 	    case ETIME:
  1797                 sym = @symbol(ETIME);
  1797 		sym = @symbol(ETIME);
  1798                 typ = @symbol(peerFaultSignal);
  1798 		typ = @symbol(peerFaultSignal);
  1799                 break;
  1799 		break;
  1800 #endif
  1800 #endif
  1801 #ifdef ENOSR
  1801 #ifdef ENOSR
  1802             case ENOSR:
  1802 	    case ENOSR:
  1803                 sym = @symbol(ENOSR);
  1803 		sym = @symbol(ENOSR);
  1804                 typ = @symbol(noResourcesSignal);
  1804 		typ = @symbol(noResourcesSignal);
  1805                 break;
  1805 		break;
  1806 #endif
  1806 #endif
  1807 #ifdef ENOSTR
  1807 #ifdef ENOSTR
  1808             case ENOSTR:
  1808 	    case ENOSTR:
  1809                 sym = @symbol(ENOSTR);
  1809 		sym = @symbol(ENOSTR);
  1810                 typ = @symbol(inappropriateReferentSignal);
  1810 		typ = @symbol(inappropriateReferentSignal);
  1811                 break;
  1811 		break;
  1812 #endif
  1812 #endif
  1813 #ifdef ECOMM
  1813 #ifdef ECOMM
  1814             case ECOMM:
  1814 	    case ECOMM:
  1815                 sym = @symbol(ECOMM);
  1815 		sym = @symbol(ECOMM);
  1816                 typ = @symbol(transferFaultSignal);
  1816 		typ = @symbol(transferFaultSignal);
  1817                 break;
  1817 		break;
  1818 #endif
  1818 #endif
  1819 #ifdef EPROTO
  1819 #ifdef EPROTO
  1820             case EPROTO:
  1820 	    case EPROTO:
  1821                 sym = @symbol(EPROTO);
  1821 		sym = @symbol(EPROTO);
  1822                 typ = @symbol(inappropriateOperationSignal);
  1822 		typ = @symbol(inappropriateOperationSignal);
  1823                 break;
  1823 		break;
  1824 #endif
  1824 #endif
  1825             /*
  1825 	    /*
  1826              * nfs errors
  1826 	     * nfs errors
  1827              */
  1827 	     */
  1828 #ifdef ESTALE
  1828 #ifdef ESTALE
  1829             case ESTALE:
  1829 	    case ESTALE:
  1830                 sym = @symbol(ESTALE);
  1830 		sym = @symbol(ESTALE);
  1831                 typ = @symbol(unavailableReferentSignal);
  1831 		typ = @symbol(unavailableReferentSignal);
  1832                 break;
  1832 		break;
  1833 #endif
  1833 #endif
  1834 #ifdef EREMOTE
  1834 #ifdef EREMOTE
  1835             case EREMOTE:
  1835 	    case EREMOTE:
  1836                 sym = @symbol(EREMOTE);
  1836 		sym = @symbol(EREMOTE);
  1837                 typ = @symbol(rangeErrorSignal);
  1837 		typ = @symbol(rangeErrorSignal);
  1838                 break;
  1838 		break;
  1839 #endif
  1839 #endif
  1840             /*
  1840 	    /*
  1841              * some networking errors
  1841 	     * some networking errors
  1842              */
  1842 	     */
  1843 #ifdef EINPROGRESS
  1843 #ifdef EINPROGRESS
  1844             case EINPROGRESS:
  1844 	    case EINPROGRESS:
  1845                 sym = @symbol(EINPROGRESS);
  1845 		sym = @symbol(EINPROGRESS);
  1846                 typ = @symbol(operationStartedSignal);
  1846 		typ = @symbol(operationStartedSignal);
  1847                 break;
  1847 		break;
  1848 #endif
  1848 #endif
  1849 #ifdef EALREADY
  1849 #ifdef EALREADY
  1850             case EALREADY:
  1850 	    case EALREADY:
  1851                 sym = @symbol(EALREADY);
  1851 		sym = @symbol(EALREADY);
  1852                 typ = @symbol(operationStartedSignal);
  1852 		typ = @symbol(operationStartedSignal);
  1853                 break;
  1853 		break;
  1854 #endif
  1854 #endif
  1855 #ifdef ENOTSOCK
  1855 #ifdef ENOTSOCK
  1856             case ENOTSOCK:
  1856 	    case ENOTSOCK:
  1857                 sym = @symbol(ENOTSOCK);
  1857 		sym = @symbol(ENOTSOCK);
  1858                 typ = @symbol(inappropriateOperationSignal);
  1858 		typ = @symbol(inappropriateOperationSignal);
  1859                 break;
  1859 		break;
  1860 #endif
  1860 #endif
  1861 #ifdef EDESTADDRREQ
  1861 #ifdef EDESTADDRREQ
  1862             case EDESTADDRREQ:
  1862 	    case EDESTADDRREQ:
  1863                 sym = @symbol(EDESTADDRREQ);
  1863 		sym = @symbol(EDESTADDRREQ);
  1864                 typ = @symbol(underspecifiedSignal);
  1864 		typ = @symbol(underspecifiedSignal);
  1865                 break;
  1865 		break;
  1866 #endif
  1866 #endif
  1867 #ifdef EMSGSIZE
  1867 #ifdef EMSGSIZE
  1868             case EMSGSIZE:
  1868 	    case EMSGSIZE:
  1869                 sym = @symbol(EMSGSIZE);
  1869 		sym = @symbol(EMSGSIZE);
  1870                 typ = @symbol(rangeErrorSignal);
  1870 		typ = @symbol(rangeErrorSignal);
  1871                 break;
  1871 		break;
  1872 #endif
  1872 #endif
  1873 #ifdef EPROTOTYPE
  1873 #ifdef EPROTOTYPE
  1874             case EPROTOTYPE:
  1874 	    case EPROTOTYPE:
  1875                 sym = @symbol(EPROTOTYPE);
  1875 		sym = @symbol(EPROTOTYPE);
  1876                 typ = @symbol(wrongSubtypeForOperationSignal);
  1876 		typ = @symbol(wrongSubtypeForOperationSignal);
  1877                 break;
  1877 		break;
  1878 #endif
  1878 #endif
  1879 #ifdef ENOPROTOOPT
  1879 #ifdef ENOPROTOOPT
  1880             case ENOPROTOOPT:
  1880 	    case ENOPROTOOPT:
  1881                 sym = @symbol(ENOPROTOOPT);
  1881 		sym = @symbol(ENOPROTOOPT);
  1882                 typ = @symbol(unsupportedOperationSignal);
  1882 		typ = @symbol(unsupportedOperationSignal);
  1883                 break;
  1883 		break;
  1884 #endif
  1884 #endif
  1885 #ifdef EPROTONOSUPPORT
  1885 #ifdef EPROTONOSUPPORT
  1886             case EPROTONOSUPPORT:
  1886 	    case EPROTONOSUPPORT:
  1887                 sym = @symbol(EPROTONOSUPPORT);
  1887 		sym = @symbol(EPROTONOSUPPORT);
  1888                 typ = @symbol(unsupportedOperationSignal);
  1888 		typ = @symbol(unsupportedOperationSignal);
  1889                 break;
  1889 		break;
  1890 #endif
  1890 #endif
  1891 #ifdef ESOCKTNOSUPPORT
  1891 #ifdef ESOCKTNOSUPPORT
  1892             case ESOCKTNOSUPPORT:
  1892 	    case ESOCKTNOSUPPORT:
  1893                 sym = @symbol(ESOCKTNOSUPPORT);
  1893 		sym = @symbol(ESOCKTNOSUPPORT);
  1894                 typ = @symbol(unsupportedOperationSignal);
  1894 		typ = @symbol(unsupportedOperationSignal);
  1895                 break;
  1895 		break;
  1896 #endif
  1896 #endif
  1897 #ifdef EOPNOTSUPP
  1897 #ifdef EOPNOTSUPP
  1898             case EOPNOTSUPP:
  1898 	    case EOPNOTSUPP:
  1899                 sym = @symbol(EOPNOTSUPP);
  1899 		sym = @symbol(EOPNOTSUPP);
  1900                 typ = @symbol(inappropriateOperationSignal);
  1900 		typ = @symbol(inappropriateOperationSignal);
  1901                 break;
  1901 		break;
  1902 #endif
  1902 #endif
  1903 #ifdef EPFNOSUPPORT
  1903 #ifdef EPFNOSUPPORT
  1904             case EPFNOSUPPORT:
  1904 	    case EPFNOSUPPORT:
  1905                 sym = @symbol(EPFNOSUPPORT);
  1905 		sym = @symbol(EPFNOSUPPORT);
  1906                 typ = @symbol(unsupportedOperationSignal);
  1906 		typ = @symbol(unsupportedOperationSignal);
  1907                 break;
  1907 		break;
  1908 #endif
  1908 #endif
  1909 #ifdef EAFNOSUPPORT
  1909 #ifdef EAFNOSUPPORT
  1910             case EAFNOSUPPORT:
  1910 	    case EAFNOSUPPORT:
  1911                 sym = @symbol(EAFNOSUPPORT);
  1911 		sym = @symbol(EAFNOSUPPORT);
  1912                 typ = @symbol(unsupportedOperationSignal);
  1912 		typ = @symbol(unsupportedOperationSignal);
  1913                 break;
  1913 		break;
  1914 #endif
  1914 #endif
  1915 #ifdef EADDRINUSE
  1915 #ifdef EADDRINUSE
  1916             case EADDRINUSE:
  1916 	    case EADDRINUSE:
  1917                 sym = @symbol(EADDRINUSE);
  1917 		sym = @symbol(EADDRINUSE);
  1918                 typ = @symbol(existingReferentSignal);
  1918 		typ = @symbol(existingReferentSignal);
  1919                 break;
  1919 		break;
  1920 #endif
  1920 #endif
  1921 #ifdef EADDRNOTAVAIL
  1921 #ifdef EADDRNOTAVAIL
  1922             case EADDRNOTAVAIL:
  1922 	    case EADDRNOTAVAIL:
  1923                 sym = @symbol(EADDRNOTAVAIL);
  1923 		sym = @symbol(EADDRNOTAVAIL);
  1924                 typ = @symbol(noPermissionsSignal);
  1924 		typ = @symbol(noPermissionsSignal);
  1925                 break;
  1925 		break;
  1926 #endif
  1926 #endif
  1927 #ifdef ETIMEDOUT
  1927 #ifdef ETIMEDOUT
  1928             case ETIMEDOUT:
  1928 	    case ETIMEDOUT:
  1929                 sym = @symbol(ETIMEDOUT);
  1929 		sym = @symbol(ETIMEDOUT);
  1930                 typ = @symbol(peerFaultSignal);
  1930 		typ = @symbol(peerFaultSignal);
  1931                 break;
  1931 		break;
  1932 #endif
  1932 #endif
  1933 #ifdef ECONNREFUSED
  1933 #ifdef ECONNREFUSED
  1934             case ECONNREFUSED:
  1934 	    case ECONNREFUSED:
  1935                 sym = @symbol(ECONNREFUSED);
  1935 		sym = @symbol(ECONNREFUSED);
  1936                 typ = @symbol(peerFaultSignal);
  1936 		typ = @symbol(peerFaultSignal);
  1937                 break;
  1937 		break;
  1938 #endif
  1938 #endif
  1939 #ifdef ENETDOWN
  1939 #ifdef ENETDOWN
  1940             case ENETDOWN:
  1940 	    case ENETDOWN:
  1941                 sym = @symbol(ENETDOWN);
  1941 		sym = @symbol(ENETDOWN);
  1942                 typ = @symbol(peerFaultSignal);
  1942 		typ = @symbol(peerFaultSignal);
  1943                 break;
  1943 		break;
  1944 #endif
  1944 #endif
  1945 #ifdef ENETUNREACH
  1945 #ifdef ENETUNREACH
  1946             case ENETUNREACH:
  1946 	    case ENETUNREACH:
  1947                 sym = @symbol(ENETUNREACH);
  1947 		sym = @symbol(ENETUNREACH);
  1948                 typ = @symbol(peerFaultSignal);
  1948 		typ = @symbol(peerFaultSignal);
  1949                 break;
  1949 		break;
  1950 #endif
  1950 #endif
  1951 #ifdef ENETRESET
  1951 #ifdef ENETRESET
  1952             case ENETRESET:
  1952 	    case ENETRESET:
  1953                 sym = @symbol(ENETRESET);
  1953 		sym = @symbol(ENETRESET);
  1954                 typ = @symbol(peerFaultSignal);
  1954 		typ = @symbol(peerFaultSignal);
  1955                 break;
  1955 		break;
  1956 #endif
  1956 #endif
  1957 #ifdef ECONNABORTED
  1957 #ifdef ECONNABORTED
  1958             case ECONNABORTED:
  1958 	    case ECONNABORTED:
  1959                 sym = @symbol(ECONNABORTED);
  1959 		sym = @symbol(ECONNABORTED);
  1960                 typ = @symbol(peerFaultSignal);
  1960 		typ = @symbol(peerFaultSignal);
  1961                 break;
  1961 		break;
  1962 #endif
  1962 #endif
  1963 #ifdef ECONNRESET
  1963 #ifdef ECONNRESET
  1964             case ECONNRESET:
  1964 	    case ECONNRESET:
  1965                 sym = @symbol(ECONNRESET);
  1965 		sym = @symbol(ECONNRESET);
  1966                 typ = @symbol(peerFaultSignal);
  1966 		typ = @symbol(peerFaultSignal);
  1967                 break;
  1967 		break;
  1968 #endif
  1968 #endif
  1969 #ifdef EISCONN
  1969 #ifdef EISCONN
  1970             case EISCONN:
  1970 	    case EISCONN:
  1971                 sym = @symbol(EISCONN);
  1971 		sym = @symbol(EISCONN);
  1972                 typ = @symbol(unpreparedOperationSignal);
  1972 		typ = @symbol(unpreparedOperationSignal);
  1973                 break;
  1973 		break;
  1974 #endif
  1974 #endif
  1975 #ifdef ENOTCONN
  1975 #ifdef ENOTCONN
  1976             case ENOTCONN:
  1976 	    case ENOTCONN:
  1977                 sym = @symbol(ENOTCONN);
  1977 		sym = @symbol(ENOTCONN);
  1978                 typ = @symbol(unpreparedOperationSignal);
  1978 		typ = @symbol(unpreparedOperationSignal);
  1979                 break;
  1979 		break;
  1980 #endif
  1980 #endif
  1981 #ifdef ESHUTDOWN
  1981 #ifdef ESHUTDOWN
  1982             case ESHUTDOWN:
  1982 	    case ESHUTDOWN:
  1983                 sym = @symbol(ESHUTDOWN);
  1983 		sym = @symbol(ESHUTDOWN);
  1984                 typ = @symbol(unpreparedOperationSignal);
  1984 		typ = @symbol(unpreparedOperationSignal);
  1985                 break;
  1985 		break;
  1986 #endif
  1986 #endif
  1987 #ifdef EHOSTDOWN
  1987 #ifdef EHOSTDOWN
  1988             case EHOSTDOWN:
  1988 	    case EHOSTDOWN:
  1989                 sym = @symbol(EHOSTDOWN);
  1989 		sym = @symbol(EHOSTDOWN);
  1990                 typ = @symbol(peerFaultSignal);
  1990 		typ = @symbol(peerFaultSignal);
  1991                 break;
  1991 		break;
  1992 #endif
  1992 #endif
  1993 #ifdef EHOSTUNREACH
  1993 #ifdef EHOSTUNREACH
  1994             case EHOSTUNREACH:
  1994 	    case EHOSTUNREACH:
  1995                 sym = @symbol(EHOSTUNREACH);
  1995 		sym = @symbol(EHOSTUNREACH);
  1996                 typ = @symbol(peerFaultSignal);
  1996 		typ = @symbol(peerFaultSignal);
  1997                 break;
  1997 		break;
  1998 #endif
  1998 #endif
  1999 
  1999 
  2000 #ifdef WSAEFAULT
  2000 #ifdef WSAEFAULT
  2001             case WSAEFAULT:
  2001 	    case WSAEFAULT:
  2002                 sym = @symbol(WSAEFAULT);
  2002 		sym = @symbol(WSAEFAULT);
  2003                 typ = @symbol(invalidArgumentsSignal);
  2003 		typ = @symbol(invalidArgumentsSignal);
  2004                 break;
  2004 		break;
  2005 #endif
  2005 #endif
  2006 #ifdef WSAEINTR
  2006 #ifdef WSAEINTR
  2007             case WSAEINTR:
  2007 	    case WSAEINTR:
  2008                 sym = @symbol(WSAEINTR);
  2008 		sym = @symbol(WSAEINTR);
  2009                 typ = @symbol(transientErrorSignal);
  2009 		typ = @symbol(transientErrorSignal);
  2010                 break;
  2010 		break;
  2011 #endif
  2011 #endif
  2012 #ifdef WSAEBADF
  2012 #ifdef WSAEBADF
  2013             case WSAEBADF:
  2013 	    case WSAEBADF:
  2014                 sym = @symbol(WSAEBADF);
  2014 		sym = @symbol(WSAEBADF);
  2015                 typ = @symbol(badAccessorSignal);
  2015 		typ = @symbol(badAccessorSignal);
  2016                 break;
  2016 		break;
  2017 #endif
  2017 #endif
  2018 #ifdef WSAEACCESS
  2018 #ifdef WSAEACCESS
  2019             case WSAEACCESS:
  2019 	    case WSAEACCESS:
  2020                 sym = @symbol(WSAEACCESS);
  2020 		sym = @symbol(WSAEACCESS);
  2021                 typ = @symbol(badAccessorSignal);
  2021 		typ = @symbol(badAccessorSignal);
  2022                 break;
  2022 		break;
  2023 #endif
  2023 #endif
  2024 #ifdef WSAEINVAL
  2024 #ifdef WSAEINVAL
  2025             case WSAEINVAL:
  2025 	    case WSAEINVAL:
  2026                 sym = @symbol(WSAEINVAL);
  2026 		sym = @symbol(WSAEINVAL);
  2027                 typ = @symbol(invalidArgumentsSignal);
  2027 		typ = @symbol(invalidArgumentsSignal);
  2028                 break;
  2028 		break;
  2029 #endif
  2029 #endif
  2030 #ifdef WSAEMFILE
  2030 #ifdef WSAEMFILE
  2031             case WSAEMFILE:
  2031 	    case WSAEMFILE:
  2032                 sym = @symbol(WSAEMFILE);
  2032 		sym = @symbol(WSAEMFILE);
  2033                 typ = @symbol(noResourcesSignal);
  2033 		typ = @symbol(noResourcesSignal);
  2034                 break;
  2034 		break;
  2035 #endif
  2035 #endif
  2036 #ifdef WSAEWOULDBLOCK
  2036 #ifdef WSAEWOULDBLOCK
  2037             case WSAEWOULDBLOCK:
  2037 	    case WSAEWOULDBLOCK:
  2038                 sym = @symbol(WSAEWOULDBLOCK);
  2038 		sym = @symbol(WSAEWOULDBLOCK);
  2039                 typ = @symbol(notReadySignal);
  2039 		typ = @symbol(notReadySignal);
  2040                 break;
  2040 		break;
  2041 #endif
  2041 #endif
  2042 #ifdef WSAEINPROGRESS
  2042 #ifdef WSAEINPROGRESS
  2043             case WSAEINPROGRESS:
  2043 	    case WSAEINPROGRESS:
  2044                 sym = @symbol(WSAEINPROGRESS);
  2044 		sym = @symbol(WSAEINPROGRESS);
  2045                 typ = @symbol(operationStartedSignal);
  2045 		typ = @symbol(operationStartedSignal);
  2046                 break;
  2046 		break;
  2047 #endif
  2047 #endif
  2048 #ifdef WSAEALREADY
  2048 #ifdef WSAEALREADY
  2049             case WSAEALREADY:
  2049 	    case WSAEALREADY:
  2050                 sym = @symbol(WSAEALREADY);
  2050 		sym = @symbol(WSAEALREADY);
  2051                 typ = @symbol(operationStartedSignal);
  2051 		typ = @symbol(operationStartedSignal);
  2052                 break;
  2052 		break;
  2053 #endif
  2053 #endif
  2054 #ifdef WSAENOTSOCK
  2054 #ifdef WSAENOTSOCK
  2055             case WSAENOTSOCK:
  2055 	    case WSAENOTSOCK:
  2056                 sym = @symbol(WSAENOTSOCK);
  2056 		sym = @symbol(WSAENOTSOCK);
  2057                 typ = @symbol(inappropriateOperationSignal);
  2057 		typ = @symbol(inappropriateOperationSignal);
  2058                 break;
  2058 		break;
  2059 #endif
  2059 #endif
  2060 #ifdef WSAEPROTONOSUPPORT
  2060 #ifdef WSAEPROTONOSUPPORT
  2061             case WSAEPROTONOSUPPORT:
  2061 	    case WSAEPROTONOSUPPORT:
  2062                 sym = @symbol(WSAEPROTONOSUPPORT);
  2062 		sym = @symbol(WSAEPROTONOSUPPORT);
  2063                 typ = @symbol(unsupportedOperationSignal);
  2063 		typ = @symbol(unsupportedOperationSignal);
  2064                 break;
  2064 		break;
  2065 #endif
  2065 #endif
  2066 #ifdef WSAESOCKTNOSUPPORT
  2066 #ifdef WSAESOCKTNOSUPPORT
  2067             case WSAESOCKTNOSUPPORT:
  2067 	    case WSAESOCKTNOSUPPORT:
  2068                 sym = @symbol(WSAESOCKTNOSUPPORT);
  2068 		sym = @symbol(WSAESOCKTNOSUPPORT);
  2069                 typ = @symbol(unsupportedOperationSignal);
  2069 		typ = @symbol(unsupportedOperationSignal);
  2070                 break;
  2070 		break;
  2071 #endif
  2071 #endif
  2072 #ifdef E_NOINTERFACE
  2072 #ifdef E_NOINTERFACE
  2073             case E_NOINTERFACE:
  2073 	    case E_NOINTERFACE:
  2074                 sym = @symbol(E_NOINTERFACE);
  2074 		sym = @symbol(E_NOINTERFACE);
  2075                 typ = @symbol(noInterfaceSignal);
  2075 		typ = @symbol(noInterfaceSignal);
  2076                 break;
  2076 		break;
  2077 #endif
  2077 #endif
  2078 #ifdef CO_E_NOTINITIALIZED
  2078 #ifdef CO_E_NOTINITIALIZED
  2079             case CO_E_NOTINITIALIZED:
  2079 	    case CO_E_NOTINITIALIZED:
  2080                 sym = @symbol(CO_E_NOTINITIALIZED);
  2080 		sym = @symbol(CO_E_NOTINITIALIZED);
  2081                 typ = @symbol(coNotInitializedSignal);
  2081 		typ = @symbol(coNotInitializedSignal);
  2082                 break;
  2082 		break;
  2083 #endif
  2083 #endif
  2084 #ifdef REGDB_E_CLASSNOTREG
  2084 #ifdef REGDB_E_CLASSNOTREG
  2085             case REGDB_E_CLASSNOTREG:
  2085 	    case REGDB_E_CLASSNOTREG:
  2086                 sym = @symbol(REGDB_E_CLASSNOTREG);
  2086 		sym = @symbol(REGDB_E_CLASSNOTREG);
  2087                 typ = @symbol(classNotRegisteredSignal);
  2087 		typ = @symbol(classNotRegisteredSignal);
  2088                 break;
  2088 		break;
  2089 #endif
  2089 #endif
  2090 #ifdef CLASS_E_NOAGGREGATION
  2090 #ifdef CLASS_E_NOAGGREGATION
  2091             case CLASS_E_NOAGGREGATION:
  2091 	    case CLASS_E_NOAGGREGATION:
  2092                 sym = @symbol(CLASS_E_NOAGGREGATION);
  2092 		sym = @symbol(CLASS_E_NOAGGREGATION);
  2093                 typ = @symbol(noAggregationSignal);
  2093 		typ = @symbol(noAggregationSignal);
  2094                 break;
  2094 		break;
  2095 #endif
  2095 #endif
  2096 #ifdef DISP_E_UNKNOWNNAME
  2096 #ifdef DISP_E_UNKNOWNNAME
  2097             case DISP_E_UNKNOWNNAME:
  2097 	    case DISP_E_UNKNOWNNAME:
  2098                 sym = @symbol(DISP_E_UNKNOWNNAME);
  2098 		sym = @symbol(DISP_E_UNKNOWNNAME);
  2099                 typ = @symbol(unknownNameSignal);
  2099 		typ = @symbol(unknownNameSignal);
  2100                 break;
  2100 		break;
  2101 #endif
  2101 #endif
  2102 #ifdef OLEOBJ_E_NOVERBS
  2102 #ifdef OLEOBJ_E_NOVERBS
  2103             case OLEOBJ_E_NOVERBS:
  2103 	    case OLEOBJ_E_NOVERBS:
  2104                 sym = @symbol(OLEOBJ_E_NOVERBS);
  2104 		sym = @symbol(OLEOBJ_E_NOVERBS);
  2105                 typ = @symbol(noVerbsSignal);
  2105 		typ = @symbol(noVerbsSignal);
  2106                 break;
  2106 		break;
  2107 #endif
  2107 #endif
  2108 
  2108 
  2109             default:
  2109 	    default:
  2110                 break;
  2110 		break;
  2111         }
  2111 	}
  2112       }
  2112       }
  2113     }
  2113     }
  2114 %}.
  2114 %}.
  2115     holder := OSErrorHolder new.
  2115     holder := OSErrorHolder new.
  2116     holder errorSymbol:sym errorCategory:typ.
  2116     holder errorSymbol:sym errorCategory:typ.
  2136     /*
  2136     /*
  2137      * WIN32 GetLastError returns
  2137      * WIN32 GetLastError returns
  2138      */
  2138      */
  2139 #ifdef ERROR_INVALID_FUNCTION
  2139 #ifdef ERROR_INVALID_FUNCTION
  2140     if (sym == @symbol(ERROR_INVALID_FUNCTION)) {
  2140     if (sym == @symbol(ERROR_INVALID_FUNCTION)) {
  2141         RETURN ( __mkSmallInteger(ERROR_INVALID_FUNCTION) );
  2141 	RETURN ( __mkSmallInteger(ERROR_INVALID_FUNCTION) );
  2142     }
  2142     }
  2143 #endif
  2143 #endif
  2144 #ifdef ERROR_BAD_FORMAT
  2144 #ifdef ERROR_BAD_FORMAT
  2145     if (sym == @symbol(ERROR_BAD_FORMAT)) {
  2145     if (sym == @symbol(ERROR_BAD_FORMAT)) {
  2146         RETURN ( __mkSmallInteger(ERROR_BAD_FORMAT) );
  2146 	RETURN ( __mkSmallInteger(ERROR_BAD_FORMAT) );
  2147     }
  2147     }
  2148 #endif
  2148 #endif
  2149 #ifdef ERROR_FILE_NOT_FOUND
  2149 #ifdef ERROR_FILE_NOT_FOUND
  2150     if (sym == @symbol(ERROR_FILE_NOT_FOUND)) {
  2150     if (sym == @symbol(ERROR_FILE_NOT_FOUND)) {
  2151         RETURN ( __mkSmallInteger(ERROR_FILE_NOT_FOUND) );
  2151 	RETURN ( __mkSmallInteger(ERROR_FILE_NOT_FOUND) );
  2152     }
  2152     }
  2153 #endif
  2153 #endif
  2154 #ifdef ERROR_PATH_NOT_FOUND
  2154 #ifdef ERROR_PATH_NOT_FOUND
  2155     if (sym == @symbol(ERROR_PATH_NOT_FOUND)) {
  2155     if (sym == @symbol(ERROR_PATH_NOT_FOUND)) {
  2156         RETURN ( __mkSmallInteger(ERROR_PATH_NOT_FOUND) );
  2156 	RETURN ( __mkSmallInteger(ERROR_PATH_NOT_FOUND) );
  2157     }
  2157     }
  2158 #endif
  2158 #endif
  2159 #ifdef ERROR_TOO_MANY_OPEN_FILES
  2159 #ifdef ERROR_TOO_MANY_OPEN_FILES
  2160     if (sym == @symbol(ERROR_TOO_MANY_OPEN_FILES)) {
  2160     if (sym == @symbol(ERROR_TOO_MANY_OPEN_FILES)) {
  2161         RETURN ( __mkSmallInteger(ERROR_TOO_MANY_OPEN_FILES) );
  2161 	RETURN ( __mkSmallInteger(ERROR_TOO_MANY_OPEN_FILES) );
  2162     }
  2162     }
  2163 #endif
  2163 #endif
  2164 #ifdef ERROR_OPEN_FAILED
  2164 #ifdef ERROR_OPEN_FAILED
  2165     if (sym == @symbol(ERROR_OPEN_FAILED)) {
  2165     if (sym == @symbol(ERROR_OPEN_FAILED)) {
  2166         RETURN ( __mkSmallInteger(ERROR_OPEN_FAILED) );
  2166 	RETURN ( __mkSmallInteger(ERROR_OPEN_FAILED) );
  2167     }
  2167     }
  2168 #endif
  2168 #endif
  2169 #ifdef ERROR_ACCESS_DENIED
  2169 #ifdef ERROR_ACCESS_DENIED
  2170     if (sym == @symbol(ERROR_ACCESS_DENIED)) {
  2170     if (sym == @symbol(ERROR_ACCESS_DENIED)) {
  2171         RETURN ( __mkSmallInteger(ERROR_ACCESS_DENIED) );
  2171 	RETURN ( __mkSmallInteger(ERROR_ACCESS_DENIED) );
  2172     }
  2172     }
  2173 #endif
  2173 #endif
  2174 #ifdef ERROR_INVALID_HANDLE
  2174 #ifdef ERROR_INVALID_HANDLE
  2175     if (sym == @symbol(ERROR_INVALID_HANDLE)) {
  2175     if (sym == @symbol(ERROR_INVALID_HANDLE)) {
  2176         RETURN ( __mkSmallInteger(ERROR_INVALID_HANDLE) );
  2176 	RETURN ( __mkSmallInteger(ERROR_INVALID_HANDLE) );
  2177     }
  2177     }
  2178 #endif
  2178 #endif
  2179 #ifdef ERROR_NOT_ENOUGH_MEMORY
  2179 #ifdef ERROR_NOT_ENOUGH_MEMORY
  2180     if (sym == @symbol(ERROR_NOT_ENOUGH_MEMORY)) {
  2180     if (sym == @symbol(ERROR_NOT_ENOUGH_MEMORY)) {
  2181         RETURN ( __mkSmallInteger(ERROR_NOT_ENOUGH_MEMORY) );
  2181 	RETURN ( __mkSmallInteger(ERROR_NOT_ENOUGH_MEMORY) );
  2182     }
  2182     }
  2183 #endif
  2183 #endif
  2184 #ifdef ERROR_INVALID_ACCESS
  2184 #ifdef ERROR_INVALID_ACCESS
  2185     if (sym == @symbol(ERROR_INVALID_ACCESS)) {
  2185     if (sym == @symbol(ERROR_INVALID_ACCESS)) {
  2186         RETURN ( __mkSmallInteger(ERROR_INVALID_ACCESS) );
  2186 	RETURN ( __mkSmallInteger(ERROR_INVALID_ACCESS) );
  2187     }
  2187     }
  2188 #endif
  2188 #endif
  2189 #ifdef ERROR_INVALID_DATA
  2189 #ifdef ERROR_INVALID_DATA
  2190     if (sym == @symbol(ERROR_INVALID_DATA)) {
  2190     if (sym == @symbol(ERROR_INVALID_DATA)) {
  2191         RETURN ( __mkSmallInteger(ERROR_INVALID_DATA) );
  2191 	RETURN ( __mkSmallInteger(ERROR_INVALID_DATA) );
  2192     }
  2192     }
  2193 #endif
  2193 #endif
  2194 #ifdef ERROR_INVALID_NAME
  2194 #ifdef ERROR_INVALID_NAME
  2195     if (sym == @symbol(ERROR_INVALID_NAME)) {
  2195     if (sym == @symbol(ERROR_INVALID_NAME)) {
  2196         RETURN ( __mkSmallInteger(ERROR_INVALID_NAME) );
  2196 	RETURN ( __mkSmallInteger(ERROR_INVALID_NAME) );
  2197     }
  2197     }
  2198 #endif
  2198 #endif
  2199 #ifdef ERROR_ARENA_TRASHED
  2199 #ifdef ERROR_ARENA_TRASHED
  2200     if (sym == @symbol(ERROR_ARENA_TRASHED)) {
  2200     if (sym == @symbol(ERROR_ARENA_TRASHED)) {
  2201         RETURN ( __mkSmallInteger(ERROR_ARENA_TRASHED) );
  2201 	RETURN ( __mkSmallInteger(ERROR_ARENA_TRASHED) );
  2202     }
  2202     }
  2203 #endif
  2203 #endif
  2204 #ifdef ERROR_OUTOFMEMORY
  2204 #ifdef ERROR_OUTOFMEMORY
  2205     if (sym == @symbol(ERROR_OUTOFMEMORY)) {
  2205     if (sym == @symbol(ERROR_OUTOFMEMORY)) {
  2206         RETURN ( __mkSmallInteger(ERROR_OUTOFMEMORY) );
  2206 	RETURN ( __mkSmallInteger(ERROR_OUTOFMEMORY) );
  2207     }
  2207     }
  2208 #endif
  2208 #endif
  2209 #ifdef ERROR_BROKEN_PIPE
  2209 #ifdef ERROR_BROKEN_PIPE
  2210     if (sym == @symbol(ERROR_BROKEN_PIPE)) {
  2210     if (sym == @symbol(ERROR_BROKEN_PIPE)) {
  2211         RETURN ( __mkSmallInteger(ERROR_BROKEN_PIPE) );
  2211 	RETURN ( __mkSmallInteger(ERROR_BROKEN_PIPE) );
  2212     }
  2212     }
  2213 #endif
  2213 #endif
  2214 #ifdef ERROR_GEN_FAILURE
  2214 #ifdef ERROR_GEN_FAILURE
  2215     if (sym == @symbol(ERROR_GEN_FAILURE)) {
  2215     if (sym == @symbol(ERROR_GEN_FAILURE)) {
  2216         RETURN ( __mkSmallInteger(ERROR_GEN_FAILURE) );
  2216 	RETURN ( __mkSmallInteger(ERROR_GEN_FAILURE) );
  2217     }
  2217     }
  2218 #endif
  2218 #endif
  2219 #ifdef ERROR_WRITE_PROTECT
  2219 #ifdef ERROR_WRITE_PROTECT
  2220     if (sym == @symbol(ERROR_WRITE_PROTECT)) {
  2220     if (sym == @symbol(ERROR_WRITE_PROTECT)) {
  2221         RETURN ( __mkSmallInteger(ERROR_WRITE_PROTECT) );
  2221 	RETURN ( __mkSmallInteger(ERROR_WRITE_PROTECT) );
  2222     }
  2222     }
  2223 #endif
  2223 #endif
  2224 #ifdef ERROR_WRITE_FAULT
  2224 #ifdef ERROR_WRITE_FAULT
  2225     if (sym == @symbol(ERROR_WRITE_FAULT)) {
  2225     if (sym == @symbol(ERROR_WRITE_FAULT)) {
  2226         RETURN ( __mkSmallInteger(ERROR_WRITE_FAULT) );
  2226 	RETURN ( __mkSmallInteger(ERROR_WRITE_FAULT) );
  2227     }
  2227     }
  2228 #endif
  2228 #endif
  2229 #ifdef ERROR_READ_FAULT
  2229 #ifdef ERROR_READ_FAULT
  2230     if (sym == @symbol(ERROR_READ_FAULT)) {
  2230     if (sym == @symbol(ERROR_READ_FAULT)) {
  2231         RETURN ( __mkSmallInteger(ERROR_READ_FAULT) );
  2231 	RETURN ( __mkSmallInteger(ERROR_READ_FAULT) );
  2232     }
  2232     }
  2233 #endif
  2233 #endif
  2234 #ifdef ERROR_HANDLE_DISK_FULL
  2234 #ifdef ERROR_HANDLE_DISK_FULL
  2235     if (sym == @symbol(ERROR_HANDLE_DISK_FULL)) {
  2235     if (sym == @symbol(ERROR_HANDLE_DISK_FULL)) {
  2236         RETURN ( __mkSmallInteger(ERROR_HANDLE_DISK_FULL) );
  2236 	RETURN ( __mkSmallInteger(ERROR_HANDLE_DISK_FULL) );
  2237     }
  2237     }
  2238 #endif
  2238 #endif
  2239 #ifdef ERROR_DISK_FULL
  2239 #ifdef ERROR_DISK_FULL
  2240     if (sym == @symbol(ERROR_DISK_FULL)) {
  2240     if (sym == @symbol(ERROR_DISK_FULL)) {
  2241         RETURN ( __mkSmallInteger(ERROR_DISK_FULL) );
  2241 	RETURN ( __mkSmallInteger(ERROR_DISK_FULL) );
  2242     }
  2242     }
  2243 #endif
  2243 #endif
  2244 #ifdef ERROR_ERROR_SHARING_VIOLATION
  2244 #ifdef ERROR_ERROR_SHARING_VIOLATION
  2245     if (sym == @symbol(ERROR_ERROR_SHARING_VIOLATION)) {
  2245     if (sym == @symbol(ERROR_ERROR_SHARING_VIOLATION)) {
  2246         RETURN ( __mkSmallInteger(ERROR_ERROR_SHARING_VIOLATION) );
  2246 	RETURN ( __mkSmallInteger(ERROR_ERROR_SHARING_VIOLATION) );
  2247     }
  2247     }
  2248 #endif
  2248 #endif
  2249 #ifdef ERROR_LOCK_VIOLATION
  2249 #ifdef ERROR_LOCK_VIOLATION
  2250     if (sym == @symbol(ERROR_LOCK_VIOLATION)) {
  2250     if (sym == @symbol(ERROR_LOCK_VIOLATION)) {
  2251         RETURN ( __mkSmallInteger(ERROR_LOCK_VIOLATION) );
  2251 	RETURN ( __mkSmallInteger(ERROR_LOCK_VIOLATION) );
  2252     }
  2252     }
  2253 #endif
  2253 #endif
  2254 #ifdef ERROR_INVALID_PARAMETER
  2254 #ifdef ERROR_INVALID_PARAMETER
  2255     if (sym == @symbol(ERROR_INVALID_PARAMETER)) {
  2255     if (sym == @symbol(ERROR_INVALID_PARAMETER)) {
  2256         RETURN ( __mkSmallInteger(ERROR_INVALID_PARAMETER) );
  2256 	RETURN ( __mkSmallInteger(ERROR_INVALID_PARAMETER) );
  2257     }
  2257     }
  2258 #endif
  2258 #endif
  2259 #ifdef ERROR_NET_WRITE_FAULT
  2259 #ifdef ERROR_NET_WRITE_FAULT
  2260     if (sym == @symbol(ERROR_NET_WRITE_FAULT)) {
  2260     if (sym == @symbol(ERROR_NET_WRITE_FAULT)) {
  2261         RETURN ( __mkSmallInteger(ERROR_NET_WRITE_FAULT) );
  2261 	RETURN ( __mkSmallInteger(ERROR_NET_WRITE_FAULT) );
  2262     }
  2262     }
  2263 #endif
  2263 #endif
  2264 #ifdef ERROR_NOT_SUPPORTED
  2264 #ifdef ERROR_NOT_SUPPORTED
  2265     if (sym == @symbol(ERROR_NOT_SUPPORTED)) {
  2265     if (sym == @symbol(ERROR_NOT_SUPPORTED)) {
  2266         RETURN ( __mkSmallInteger(ERROR_NOT_SUPPORTED) );
  2266 	RETURN ( __mkSmallInteger(ERROR_NOT_SUPPORTED) );
  2267     }
  2267     }
  2268 #endif
  2268 #endif
  2269 #ifdef ERROR_REM_NOT_LIST
  2269 #ifdef ERROR_REM_NOT_LIST
  2270     if (sym == @symbol(ERROR_REM_NOT_LIST)) {
  2270     if (sym == @symbol(ERROR_REM_NOT_LIST)) {
  2271         RETURN ( __mkSmallInteger(ERROR_REM_NOT_LIST) );
  2271 	RETURN ( __mkSmallInteger(ERROR_REM_NOT_LIST) );
  2272     }
  2272     }
  2273 #endif
  2273 #endif
  2274 #ifdef ERROR_NETWORK_ACCESS_DENIED
  2274 #ifdef ERROR_NETWORK_ACCESS_DENIED
  2275     if (sym == @symbol(ERROR_NETWORK_ACCESS_DENIED)) {
  2275     if (sym == @symbol(ERROR_NETWORK_ACCESS_DENIED)) {
  2276         RETURN ( __mkSmallInteger(ERROR_NETWORK_ACCESS_DENIED) );
  2276 	RETURN ( __mkSmallInteger(ERROR_NETWORK_ACCESS_DENIED) );
  2277     }
  2277     }
  2278 #endif
  2278 #endif
  2279 #ifdef ERROR_DUP_NAME
  2279 #ifdef ERROR_DUP_NAME
  2280     if (sym == @symbol(ERROR_DUP_NAME)) {
  2280     if (sym == @symbol(ERROR_DUP_NAME)) {
  2281         RETURN ( __mkSmallInteger(ERROR_DUP_NAME) );
  2281 	RETURN ( __mkSmallInteger(ERROR_DUP_NAME) );
  2282     }
  2282     }
  2283 #endif
  2283 #endif
  2284 #ifdef ERROR_BAD_NETPATH
  2284 #ifdef ERROR_BAD_NETPATH
  2285     if (sym == @symbol(ERROR_BAD_NETPATH)) {
  2285     if (sym == @symbol(ERROR_BAD_NETPATH)) {
  2286         RETURN ( __mkSmallInteger(ERROR_BAD_NETPATH) );
  2286 	RETURN ( __mkSmallInteger(ERROR_BAD_NETPATH) );
  2287     }
  2287     }
  2288 #endif
  2288 #endif
  2289 #ifdef ERROR_NETWORK_BUSY
  2289 #ifdef ERROR_NETWORK_BUSY
  2290     if (sym == @symbol(ERROR_NETWORK_BUSY)) {
  2290     if (sym == @symbol(ERROR_NETWORK_BUSY)) {
  2291         RETURN ( __mkSmallInteger(ERROR_NETWORK_BUSY) );
  2291 	RETURN ( __mkSmallInteger(ERROR_NETWORK_BUSY) );
  2292     }
  2292     }
  2293 #endif
  2293 #endif
  2294 #ifdef ERROR_DRIVE_LOCKED
  2294 #ifdef ERROR_DRIVE_LOCKED
  2295     if (sym == @symbol(ERROR_DRIVE_LOCKED)) {
  2295     if (sym == @symbol(ERROR_DRIVE_LOCKED)) {
  2296         RETURN ( __mkSmallInteger(ERROR_DRIVE_LOCKED) );
  2296 	RETURN ( __mkSmallInteger(ERROR_DRIVE_LOCKED) );
  2297     }
  2297     }
  2298 #endif
  2298 #endif
  2299 #ifdef ERROR_INVALID_DRIVE
  2299 #ifdef ERROR_INVALID_DRIVE
  2300     if (sym == @symbol(ERROR_INVALID_DRIVE)) {
  2300     if (sym == @symbol(ERROR_INVALID_DRIVE)) {
  2301         RETURN ( __mkSmallInteger(ERROR_INVALID_DRIVE) );
  2301 	RETURN ( __mkSmallInteger(ERROR_INVALID_DRIVE) );
  2302     }
  2302     }
  2303 #endif
  2303 #endif
  2304 #ifdef ERROR_WRONG_DISK
  2304 #ifdef ERROR_WRONG_DISK
  2305     if (sym == @symbol(ERROR_WRONG_DISK)) {
  2305     if (sym == @symbol(ERROR_WRONG_DISK)) {
  2306         RETURN ( __mkSmallInteger(ERROR_WRONG_DISK) );
  2306 	RETURN ( __mkSmallInteger(ERROR_WRONG_DISK) );
  2307     }
  2307     }
  2308 #endif
  2308 #endif
  2309 #ifdef ERROR_CURRENT_DIRECTORY
  2309 #ifdef ERROR_CURRENT_DIRECTORY
  2310     if (sym == @symbol(ERROR_CURRENT_DIRECTORY)) {
  2310     if (sym == @symbol(ERROR_CURRENT_DIRECTORY)) {
  2311         RETURN ( __mkSmallInteger(ERROR_CURRENT_DIRECTORY) );
  2311 	RETURN ( __mkSmallInteger(ERROR_CURRENT_DIRECTORY) );
  2312     }
  2312     }
  2313 #endif
  2313 #endif
  2314 #ifdef ERROR_CANNOT_MAKE
  2314 #ifdef ERROR_CANNOT_MAKE
  2315     if (sym == @symbol(ERROR_CANNOT_MAKE)) {
  2315     if (sym == @symbol(ERROR_CANNOT_MAKE)) {
  2316         RETURN ( __mkSmallInteger(ERROR_CANNOT_MAKE) );
  2316 	RETURN ( __mkSmallInteger(ERROR_CANNOT_MAKE) );
  2317     }
  2317     }
  2318 #endif
  2318 #endif
  2319 #ifdef ERROR_NO_MORE_FILES
  2319 #ifdef ERROR_NO_MORE_FILES
  2320     if (sym == @symbol(ERROR_NO_MORE_FILES)) {
  2320     if (sym == @symbol(ERROR_NO_MORE_FILES)) {
  2321         RETURN ( __mkSmallInteger(ERROR_NO_MORE_FILES) );
  2321 	RETURN ( __mkSmallInteger(ERROR_NO_MORE_FILES) );
  2322     }
  2322     }
  2323 #endif
  2323 #endif
  2324 #ifdef ERROR_NOT_READY
  2324 #ifdef ERROR_NOT_READY
  2325     if (sym == @symbol(ERROR_NOT_READY)) {
  2325     if (sym == @symbol(ERROR_NOT_READY)) {
  2326         RETURN ( __mkSmallInteger(ERROR_NOT_READY) );
  2326 	RETURN ( __mkSmallInteger(ERROR_NOT_READY) );
  2327     }
  2327     }
  2328 #endif
  2328 #endif
  2329 #ifdef ERROR_NOT_DOS_DISK
  2329 #ifdef ERROR_NOT_DOS_DISK
  2330     if (sym == @symbol(ERROR_NOT_DOS_DISK)) {
  2330     if (sym == @symbol(ERROR_NOT_DOS_DISK)) {
  2331         RETURN ( __mkSmallInteger(ERROR_NOT_DOS_DISK) );
  2331 	RETURN ( __mkSmallInteger(ERROR_NOT_DOS_DISK) );
  2332     }
  2332     }
  2333 #endif
  2333 #endif
  2334 #ifdef ERROR_OUT_OF_PAPER
  2334 #ifdef ERROR_OUT_OF_PAPER
  2335     if (sym == @symbol(ERROR_OUT_OF_PAPER)) {
  2335     if (sym == @symbol(ERROR_OUT_OF_PAPER)) {
  2336         RETURN ( __mkSmallInteger(ERROR_OUT_OF_PAPER) );
  2336 	RETURN ( __mkSmallInteger(ERROR_OUT_OF_PAPER) );
  2337     }
  2337     }
  2338 #endif
  2338 #endif
  2339 #ifdef ERROR_PRINTQ_FULL
  2339 #ifdef ERROR_PRINTQ_FULL
  2340     if (sym == @symbol(ERROR_PRINTQ_FULL)) {
  2340     if (sym == @symbol(ERROR_PRINTQ_FULL)) {
  2341         RETURN ( __mkSmallInteger(ERROR_PRINTQ_FULL) );
  2341 	RETURN ( __mkSmallInteger(ERROR_PRINTQ_FULL) );
  2342     }
  2342     }
  2343 #endif
  2343 #endif
  2344 
  2344 
  2345     /*
  2345     /*
  2346      * POSIX errnos - these should be defined
  2346      * POSIX errnos - these should be defined
  2347      */
  2347      */
  2348 #ifdef EPERM
  2348 #ifdef EPERM
  2349     if (sym == @symbol(EPERM)) {
  2349     if (sym == @symbol(EPERM)) {
  2350         RETURN ( __mkSmallInteger(EPERM) );
  2350 	RETURN ( __mkSmallInteger(EPERM) );
  2351     }
  2351     }
  2352 #endif
  2352 #endif
  2353 
  2353 
  2354 #ifdef ENOENT
  2354 #ifdef ENOENT
  2355     if (sym == @symbol(ENOENT)) {
  2355     if (sym == @symbol(ENOENT)) {
  2356         RETURN ( __mkSmallInteger(ENOENT) );
  2356 	RETURN ( __mkSmallInteger(ENOENT) );
  2357     }
  2357     }
  2358 #endif
  2358 #endif
  2359 
  2359 
  2360 #ifdef ESRCH
  2360 #ifdef ESRCH
  2361     if (sym == @symbol(ESRCH)) {
  2361     if (sym == @symbol(ESRCH)) {
  2362         RETURN ( __mkSmallInteger(ESRCH) );
  2362 	RETURN ( __mkSmallInteger(ESRCH) );
  2363     }
  2363     }
  2364 #endif
  2364 #endif
  2365 
  2365 
  2366 #ifdef EINTR
  2366 #ifdef EINTR
  2367     if (sym == @symbol(EINTR)) {
  2367     if (sym == @symbol(EINTR)) {
  2368         RETURN ( __mkSmallInteger(EINTR) );
  2368 	RETURN ( __mkSmallInteger(EINTR) );
  2369     }
  2369     }
  2370 #endif
  2370 #endif
  2371 
  2371 
  2372 #ifdef EIO
  2372 #ifdef EIO
  2373     if (sym == @symbol(EIO)) {
  2373     if (sym == @symbol(EIO)) {
  2374         RETURN ( __mkSmallInteger(EIO) );
  2374 	RETURN ( __mkSmallInteger(EIO) );
  2375     }
  2375     }
  2376 #endif
  2376 #endif
  2377 
  2377 
  2378 #ifdef ENXIO
  2378 #ifdef ENXIO
  2379     if (sym == @symbol(ENXIO)) {
  2379     if (sym == @symbol(ENXIO)) {
  2380         RETURN ( __mkSmallInteger(ENXIO) );
  2380 	RETURN ( __mkSmallInteger(ENXIO) );
  2381     }
  2381     }
  2382 #endif
  2382 #endif
  2383 
  2383 
  2384 #ifdef E2BIG
  2384 #ifdef E2BIG
  2385     if (sym == @symbol(E2BIG)) {
  2385     if (sym == @symbol(E2BIG)) {
  2386         RETURN ( __mkSmallInteger(E2BIG) );
  2386 	RETURN ( __mkSmallInteger(E2BIG) );
  2387     }
  2387     }
  2388 #endif
  2388 #endif
  2389 
  2389 
  2390 #ifdef ENOEXEC
  2390 #ifdef ENOEXEC
  2391     if (sym == @symbol(ENOEXEC)) {
  2391     if (sym == @symbol(ENOEXEC)) {
  2392         RETURN ( __mkSmallInteger(ENOEXEC) );
  2392 	RETURN ( __mkSmallInteger(ENOEXEC) );
  2393     }
  2393     }
  2394 #endif
  2394 #endif
  2395 
  2395 
  2396 #ifdef EBADF
  2396 #ifdef EBADF
  2397     if (sym == @symbol(EBADF)) {
  2397     if (sym == @symbol(EBADF)) {
  2398         RETURN ( __mkSmallInteger(EBADF) );
  2398 	RETURN ( __mkSmallInteger(EBADF) );
  2399     }
  2399     }
  2400 #endif
  2400 #endif
  2401 
  2401 
  2402 #ifdef ECHILD
  2402 #ifdef ECHILD
  2403     if (sym == @symbol(ECHILD)) {
  2403     if (sym == @symbol(ECHILD)) {
  2404         RETURN ( __mkSmallInteger(ECHILD) );
  2404 	RETURN ( __mkSmallInteger(ECHILD) );
  2405     }
  2405     }
  2406 #endif
  2406 #endif
  2407 
  2407 
  2408 #if defined(EAGAIN)
  2408 #if defined(EAGAIN)
  2409     if (sym == @symbol(EAGAIN)) {
  2409     if (sym == @symbol(EAGAIN)) {
  2410         RETURN ( __mkSmallInteger(EAGAIN) );
  2410 	RETURN ( __mkSmallInteger(EAGAIN) );
  2411     }
  2411     }
  2412 #endif
  2412 #endif
  2413 
  2413 
  2414 #ifdef ENOMEM
  2414 #ifdef ENOMEM
  2415     if (sym == @symbol(ENOMEM)) {
  2415     if (sym == @symbol(ENOMEM)) {
  2416         RETURN ( __mkSmallInteger(ENOMEM) );
  2416 	RETURN ( __mkSmallInteger(ENOMEM) );
  2417     }
  2417     }
  2418 #endif
  2418 #endif
  2419 
  2419 
  2420 #ifdef EACCES
  2420 #ifdef EACCES
  2421     if (sym == @symbol(EACCES)) {
  2421     if (sym == @symbol(EACCES)) {
  2422         RETURN ( __mkSmallInteger(EACCES) );
  2422 	RETURN ( __mkSmallInteger(EACCES) );
  2423     }
  2423     }
  2424 #endif
  2424 #endif
  2425 
  2425 
  2426 #ifdef EFAULT
  2426 #ifdef EFAULT
  2427     if (sym == @symbol(EFAULT)) {
  2427     if (sym == @symbol(EFAULT)) {
  2428         RETURN ( __mkSmallInteger(EFAULT) );
  2428 	RETURN ( __mkSmallInteger(EFAULT) );
  2429     }
  2429     }
  2430 #endif
  2430 #endif
  2431 
  2431 
  2432 #ifdef EBUSY
  2432 #ifdef EBUSY
  2433     if (sym == @symbol(EBUSY)) {
  2433     if (sym == @symbol(EBUSY)) {
  2434         RETURN ( __mkSmallInteger(EBUSY) );
  2434 	RETURN ( __mkSmallInteger(EBUSY) );
  2435     }
  2435     }
  2436 #endif
  2436 #endif
  2437 
  2437 
  2438 #ifdef EXDEV
  2438 #ifdef EXDEV
  2439     if (sym == @symbol(EXDEV)) {
  2439     if (sym == @symbol(EXDEV)) {
  2440         RETURN ( __mkSmallInteger(EXDEV) );
  2440 	RETURN ( __mkSmallInteger(EXDEV) );
  2441     }
  2441     }
  2442 #endif
  2442 #endif
  2443 
  2443 
  2444 #ifdef ENODEV
  2444 #ifdef ENODEV
  2445     if (sym == @symbol(ENODEV)) {
  2445     if (sym == @symbol(ENODEV)) {
  2446         RETURN ( __mkSmallInteger(ENODEV) );
  2446 	RETURN ( __mkSmallInteger(ENODEV) );
  2447     }
  2447     }
  2448 #endif
  2448 #endif
  2449 
  2449 
  2450 #ifdef ENOTDIR
  2450 #ifdef ENOTDIR
  2451     if (sym == @symbol(ENOTDIR)) {
  2451     if (sym == @symbol(ENOTDIR)) {
  2452         RETURN ( __mkSmallInteger(ENOTDIR) );
  2452 	RETURN ( __mkSmallInteger(ENOTDIR) );
  2453     }
  2453     }
  2454 #endif
  2454 #endif
  2455 
  2455 
  2456 #ifdef EISDIR
  2456 #ifdef EISDIR
  2457     if (sym == @symbol(EISDIR)) {
  2457     if (sym == @symbol(EISDIR)) {
  2458         RETURN ( __mkSmallInteger(EISDIR) );
  2458 	RETURN ( __mkSmallInteger(EISDIR) );
  2459     }
  2459     }
  2460 #endif
  2460 #endif
  2461 
  2461 
  2462 #ifdef EINVAL
  2462 #ifdef EINVAL
  2463     if (sym == @symbol(EINVAL)) {
  2463     if (sym == @symbol(EINVAL)) {
  2464         RETURN ( __mkSmallInteger(EINVAL) );
  2464 	RETURN ( __mkSmallInteger(EINVAL) );
  2465     }
  2465     }
  2466 #endif
  2466 #endif
  2467 
  2467 
  2468 #ifdef ENFILE
  2468 #ifdef ENFILE
  2469     if (sym == @symbol(ENFILE)) {
  2469     if (sym == @symbol(ENFILE)) {
  2470         RETURN ( __mkSmallInteger(ENFILE) );
  2470 	RETURN ( __mkSmallInteger(ENFILE) );
  2471     }
  2471     }
  2472 #endif
  2472 #endif
  2473 
  2473 
  2474 #ifdef EMFILE
  2474 #ifdef EMFILE
  2475     if (sym == @symbol(EMFILE)) {
  2475     if (sym == @symbol(EMFILE)) {
  2476         RETURN ( __mkSmallInteger(EMFILE) );
  2476 	RETURN ( __mkSmallInteger(EMFILE) );
  2477     }
  2477     }
  2478 #endif
  2478 #endif
  2479 
  2479 
  2480 #ifdef ENOTTY
  2480 #ifdef ENOTTY
  2481     if (sym == @symbol(ENOTTY)) {
  2481     if (sym == @symbol(ENOTTY)) {
  2482         RETURN ( __mkSmallInteger(ENOTTY) );
  2482 	RETURN ( __mkSmallInteger(ENOTTY) );
  2483     }
  2483     }
  2484 #endif
  2484 #endif
  2485 
  2485 
  2486 #ifdef EFBIG
  2486 #ifdef EFBIG
  2487     if (sym == @symbol(EFBIG)) {
  2487     if (sym == @symbol(EFBIG)) {
  2488         RETURN ( __mkSmallInteger(EFBIG) );
  2488 	RETURN ( __mkSmallInteger(EFBIG) );
  2489     }
  2489     }
  2490 #endif
  2490 #endif
  2491 
  2491 
  2492 #ifdef ENOSPC
  2492 #ifdef ENOSPC
  2493     if (sym == @symbol(ENOSPC)) {
  2493     if (sym == @symbol(ENOSPC)) {
  2494         RETURN ( __mkSmallInteger(ENOSPC) );
  2494 	RETURN ( __mkSmallInteger(ENOSPC) );
  2495     }
  2495     }
  2496 #endif
  2496 #endif
  2497 
  2497 
  2498 #ifdef ESPIPE
  2498 #ifdef ESPIPE
  2499     if (sym == @symbol(ESPIPE)) {
  2499     if (sym == @symbol(ESPIPE)) {
  2500         RETURN ( __mkSmallInteger(ESPIPE) );
  2500 	RETURN ( __mkSmallInteger(ESPIPE) );
  2501     }
  2501     }
  2502 #endif
  2502 #endif
  2503 
  2503 
  2504 #ifdef EROFS
  2504 #ifdef EROFS
  2505     if (sym == @symbol(EROFS)) {
  2505     if (sym == @symbol(EROFS)) {
  2506         RETURN ( __mkSmallInteger(EROFS) );
  2506 	RETURN ( __mkSmallInteger(EROFS) );
  2507     }
  2507     }
  2508 #endif
  2508 #endif
  2509 
  2509 
  2510 #ifdef EMLINK
  2510 #ifdef EMLINK
  2511     if (sym == @symbol(EMLINK)) {
  2511     if (sym == @symbol(EMLINK)) {
  2512         RETURN ( __mkSmallInteger(EMLINK) );
  2512 	RETURN ( __mkSmallInteger(EMLINK) );
  2513     }
  2513     }
  2514 #endif
  2514 #endif
  2515 
  2515 
  2516 #ifdef EPIPE
  2516 #ifdef EPIPE
  2517     if (sym == @symbol(EPIPE)) {
  2517     if (sym == @symbol(EPIPE)) {
  2518         RETURN ( __mkSmallInteger(EPIPE) );
  2518 	RETURN ( __mkSmallInteger(EPIPE) );
  2519     }
  2519     }
  2520 #endif
  2520 #endif
  2521 
  2521 
  2522 #ifdef EDOM
  2522 #ifdef EDOM
  2523     if (sym == @symbol(EDOM)) {
  2523     if (sym == @symbol(EDOM)) {
  2524         RETURN ( __mkSmallInteger(EDOM) );
  2524 	RETURN ( __mkSmallInteger(EDOM) );
  2525     }
  2525     }
  2526 #endif
  2526 #endif
  2527 
  2527 
  2528 #ifdef ERANGE
  2528 #ifdef ERANGE
  2529     if (sym == @symbol(ERANGE)) {
  2529     if (sym == @symbol(ERANGE)) {
  2530         RETURN ( __mkSmallInteger(ERANGE) );
  2530 	RETURN ( __mkSmallInteger(ERANGE) );
  2531     }
  2531     }
  2532 #endif
  2532 #endif
  2533 
  2533 
  2534 #ifdef EDEADLK
  2534 #ifdef EDEADLK
  2535     if (sym == @symbol(EDEADLK)) {
  2535     if (sym == @symbol(EDEADLK)) {
  2536         RETURN ( __mkSmallInteger(EDEADLK) );
  2536 	RETURN ( __mkSmallInteger(EDEADLK) );
  2537     }
  2537     }
  2538 #endif
  2538 #endif
  2539 
  2539 
  2540 #ifdef ENAMETOOLONG
  2540 #ifdef ENAMETOOLONG
  2541     if (sym == @symbol(ENAMETOOLONG)) {
  2541     if (sym == @symbol(ENAMETOOLONG)) {
  2542         RETURN ( __mkSmallInteger(ENAMETOOLONG) );
  2542 	RETURN ( __mkSmallInteger(ENAMETOOLONG) );
  2543     }
  2543     }
  2544 #endif
  2544 #endif
  2545 
  2545 
  2546 #ifdef ENOLCK
  2546 #ifdef ENOLCK
  2547     if (sym == @symbol(ENOLCK)) {
  2547     if (sym == @symbol(ENOLCK)) {
  2548         RETURN ( __mkSmallInteger(ENOLCK) );
  2548 	RETURN ( __mkSmallInteger(ENOLCK) );
  2549     }
  2549     }
  2550 #endif
  2550 #endif
  2551 
  2551 
  2552 #ifdef ENOSYS
  2552 #ifdef ENOSYS
  2553     if (sym == @symbol(ENOSYS)) {
  2553     if (sym == @symbol(ENOSYS)) {
  2554         RETURN ( __mkSmallInteger(ENOSYS) );
  2554 	RETURN ( __mkSmallInteger(ENOSYS) );
  2555     }
  2555     }
  2556 #endif
  2556 #endif
  2557 
  2557 
  2558 #ifdef ENOTEMPTY
  2558 #ifdef ENOTEMPTY
  2559     if (sym == @symbol(ENOTEMPTY)) {
  2559     if (sym == @symbol(ENOTEMPTY)) {
  2560         RETURN ( __mkSmallInteger(ENOTEMPTY) );
  2560 	RETURN ( __mkSmallInteger(ENOTEMPTY) );
  2561     }
  2561     }
  2562 #endif
  2562 #endif
  2563 
  2563 
  2564 #ifdef EEXIST
  2564 #ifdef EEXIST
  2565     if (sym == @symbol(EEXIST)) {
  2565     if (sym == @symbol(EEXIST)) {
  2566         RETURN ( __mkSmallInteger(EEXIST) );
  2566 	RETURN ( __mkSmallInteger(EEXIST) );
  2567     }
  2567     }
  2568 #endif
  2568 #endif
  2569 
  2569 
  2570 #ifdef EILSEQ
  2570 #ifdef EILSEQ
  2571     if (sym == @symbol(EILSEQ)) {
  2571     if (sym == @symbol(EILSEQ)) {
  2572         RETURN ( __mkSmallInteger(EILSEQ) );
  2572 	RETURN ( __mkSmallInteger(EILSEQ) );
  2573     }
  2573     }
  2574 #endif
  2574 #endif
  2575 
  2575 
  2576     /*
  2576     /*
  2577      * XPG3 errnos - defined on most systems
  2577      * XPG3 errnos - defined on most systems
  2578      */
  2578      */
  2579 #ifdef ENOTBLK
  2579 #ifdef ENOTBLK
  2580     if (sym == @symbol(ENOTBLK)) {
  2580     if (sym == @symbol(ENOTBLK)) {
  2581         RETURN ( __mkSmallInteger(ENOTBLK) );
  2581 	RETURN ( __mkSmallInteger(ENOTBLK) );
  2582     }
  2582     }
  2583 #endif
  2583 #endif
  2584 
  2584 
  2585 #ifdef ETXTBSY
  2585 #ifdef ETXTBSY
  2586     if (sym == @symbol(ETXTBSY)) {
  2586     if (sym == @symbol(ETXTBSY)) {
  2587         RETURN ( __mkSmallInteger(ETXTBSY) );
  2587 	RETURN ( __mkSmallInteger(ETXTBSY) );
  2588     }
  2588     }
  2589 #endif
  2589 #endif
  2590 
  2590 
  2591     /*
  2591     /*
  2592      * some others
  2592      * some others
  2593      */
  2593      */
  2594 #ifdef EWOULDBLOCK
  2594 #ifdef EWOULDBLOCK
  2595     if (sym == @symbol(EWOULDBLOCK)) {
  2595     if (sym == @symbol(EWOULDBLOCK)) {
  2596         RETURN ( __mkSmallInteger(EWOULDBLOCK) );
  2596 	RETURN ( __mkSmallInteger(EWOULDBLOCK) );
  2597     }
  2597     }
  2598 #endif
  2598 #endif
  2599 
  2599 
  2600 #ifdef ENOMSG
  2600 #ifdef ENOMSG
  2601     if (sym == @symbol(ENOMSG)) {
  2601     if (sym == @symbol(ENOMSG)) {
  2602         RETURN ( __mkSmallInteger(ENOMSG) );
  2602 	RETURN ( __mkSmallInteger(ENOMSG) );
  2603     }
  2603     }
  2604 #endif
  2604 #endif
  2605 
  2605 
  2606 #ifdef ELOOP
  2606 #ifdef ELOOP
  2607     if (sym == @symbol(ELOOP)) {
  2607     if (sym == @symbol(ELOOP)) {
  2608         RETURN ( __mkSmallInteger(ELOOP) );
  2608 	RETURN ( __mkSmallInteger(ELOOP) );
  2609     }
  2609     }
  2610 #endif
  2610 #endif
  2611 
  2611 
  2612     /*
  2612     /*
  2613      * some stream errors
  2613      * some stream errors
  2614      */
  2614      */
  2615 #ifdef ETIME
  2615 #ifdef ETIME
  2616     if (sym == @symbol(ETIME)) {
  2616     if (sym == @symbol(ETIME)) {
  2617         RETURN ( __mkSmallInteger(ETIME) );
  2617 	RETURN ( __mkSmallInteger(ETIME) );
  2618     }
  2618     }
  2619 #endif
  2619 #endif
  2620 
  2620 
  2621 #ifdef ENOSR
  2621 #ifdef ENOSR
  2622     if (sym == @symbol(ENOSR)) {
  2622     if (sym == @symbol(ENOSR)) {
  2623         RETURN ( __mkSmallInteger(ENOSR) );
  2623 	RETURN ( __mkSmallInteger(ENOSR) );
  2624     }
  2624     }
  2625 #endif
  2625 #endif
  2626 
  2626 
  2627 #ifdef ENOSTR
  2627 #ifdef ENOSTR
  2628     if (sym == @symbol(ENOSTR)) {
  2628     if (sym == @symbol(ENOSTR)) {
  2629         RETURN ( __mkSmallInteger(ENOSTR) );
  2629 	RETURN ( __mkSmallInteger(ENOSTR) );
  2630     }
  2630     }
  2631 #endif
  2631 #endif
  2632 
  2632 
  2633 #ifdef ECOMM
  2633 #ifdef ECOMM
  2634     if (sym == @symbol(ECOMM)) {
  2634     if (sym == @symbol(ECOMM)) {
  2635         RETURN ( __mkSmallInteger(ECOMM) );
  2635 	RETURN ( __mkSmallInteger(ECOMM) );
  2636     }
  2636     }
  2637 #endif
  2637 #endif
  2638 
  2638 
  2639 #ifdef EPROTO
  2639 #ifdef EPROTO
  2640     if (sym == @symbol(EPROTO)) {
  2640     if (sym == @symbol(EPROTO)) {
  2641         RETURN ( __mkSmallInteger(EPROTO) );
  2641 	RETURN ( __mkSmallInteger(EPROTO) );
  2642     }
  2642     }
  2643 #endif
  2643 #endif
  2644 
  2644 
  2645     /*
  2645     /*
  2646      * nfs errors
  2646      * nfs errors
  2647      */
  2647      */
  2648 #ifdef ESTALE
  2648 #ifdef ESTALE
  2649     if (sym == @symbol(ESTALE)) {
  2649     if (sym == @symbol(ESTALE)) {
  2650         RETURN ( __mkSmallInteger(ESTALE) );
  2650 	RETURN ( __mkSmallInteger(ESTALE) );
  2651     }
  2651     }
  2652 #endif
  2652 #endif
  2653 
  2653 
  2654 #ifdef EREMOTE
  2654 #ifdef EREMOTE
  2655     if (sym == @symbol(EREMOTE)) {
  2655     if (sym == @symbol(EREMOTE)) {
  2656         RETURN ( __mkSmallInteger(EREMOTE) );
  2656 	RETURN ( __mkSmallInteger(EREMOTE) );
  2657     }
  2657     }
  2658 #endif
  2658 #endif
  2659 
  2659 
  2660     /*
  2660     /*
  2661      * some networking errors
  2661      * some networking errors
  2662      */
  2662      */
  2663 #ifdef EINPROGRESS
  2663 #ifdef EINPROGRESS
  2664     if (sym == @symbol(EINPROGRESS)) {
  2664     if (sym == @symbol(EINPROGRESS)) {
  2665         RETURN ( __mkSmallInteger(EINPROGRESS) );
  2665 	RETURN ( __mkSmallInteger(EINPROGRESS) );
  2666     }
  2666     }
  2667 #endif
  2667 #endif
  2668 
  2668 
  2669 #ifdef EALREADY
  2669 #ifdef EALREADY
  2670     if (sym == @symbol(EALREADY)) {
  2670     if (sym == @symbol(EALREADY)) {
  2671         RETURN ( __mkSmallInteger(EALREADY) );
  2671 	RETURN ( __mkSmallInteger(EALREADY) );
  2672     }
  2672     }
  2673 #endif
  2673 #endif
  2674 
  2674 
  2675 #ifdef ENOTSOCK
  2675 #ifdef ENOTSOCK
  2676     if (sym == @symbol(ENOTSOCK)) {
  2676     if (sym == @symbol(ENOTSOCK)) {
  2677         RETURN ( __mkSmallInteger(ENOTSOCK) );
  2677 	RETURN ( __mkSmallInteger(ENOTSOCK) );
  2678     }
  2678     }
  2679 #endif
  2679 #endif
  2680 
  2680 
  2681 #ifdef EDESTADDRREQ
  2681 #ifdef EDESTADDRREQ
  2682     if (sym == @symbol(EDESTADDRREQ)) {
  2682     if (sym == @symbol(EDESTADDRREQ)) {
  2683         RETURN ( __mkSmallInteger(EDESTADDRREQ) );
  2683 	RETURN ( __mkSmallInteger(EDESTADDRREQ) );
  2684     }
  2684     }
  2685 #endif
  2685 #endif
  2686 
  2686 
  2687 #ifdef EMSGSIZE
  2687 #ifdef EMSGSIZE
  2688     if (sym == @symbol(EMSGSIZE)) {
  2688     if (sym == @symbol(EMSGSIZE)) {
  2689         RETURN ( __mkSmallInteger(EMSGSIZE) );
  2689 	RETURN ( __mkSmallInteger(EMSGSIZE) );
  2690     }
  2690     }
  2691 #endif
  2691 #endif
  2692 
  2692 
  2693 #ifdef EPROTOTYPE
  2693 #ifdef EPROTOTYPE
  2694     if (sym == @symbol(EPROTOTYPE)) {
  2694     if (sym == @symbol(EPROTOTYPE)) {
  2695         RETURN ( __mkSmallInteger(EPROTOTYPE) );
  2695 	RETURN ( __mkSmallInteger(EPROTOTYPE) );
  2696     }
  2696     }
  2697 #endif
  2697 #endif
  2698 
  2698 
  2699 #ifdef ENOPROTOOPT
  2699 #ifdef ENOPROTOOPT
  2700     if (sym == @symbol(ENOPROTOOPT)) {
  2700     if (sym == @symbol(ENOPROTOOPT)) {
  2701         RETURN ( __mkSmallInteger(ENOPROTOOPT) );
  2701 	RETURN ( __mkSmallInteger(ENOPROTOOPT) );
  2702     }
  2702     }
  2703 #endif
  2703 #endif
  2704 
  2704 
  2705 #ifdef EPROTONOSUPPORT
  2705 #ifdef EPROTONOSUPPORT
  2706     if (sym == @symbol(EPROTONOSUPPORT)) {
  2706     if (sym == @symbol(EPROTONOSUPPORT)) {
  2707         RETURN ( __mkSmallInteger(EPROTONOSUPPORT) );
  2707 	RETURN ( __mkSmallInteger(EPROTONOSUPPORT) );
  2708     }
  2708     }
  2709 #endif
  2709 #endif
  2710 
  2710 
  2711 #ifdef ESOCKTNOSUPPORT
  2711 #ifdef ESOCKTNOSUPPORT
  2712     if (sym == @symbol(ESOCKTNOSUPPORT)) {
  2712     if (sym == @symbol(ESOCKTNOSUPPORT)) {
  2713         RETURN ( __mkSmallInteger(ESOCKTNOSUPPORT) );
  2713 	RETURN ( __mkSmallInteger(ESOCKTNOSUPPORT) );
  2714     }
  2714     }
  2715 #endif
  2715 #endif
  2716 
  2716 
  2717 #ifdef EOPNOTSUPP
  2717 #ifdef EOPNOTSUPP
  2718     if (sym == @symbol(EOPNOTSUPP)) {
  2718     if (sym == @symbol(EOPNOTSUPP)) {
  2719         RETURN ( __mkSmallInteger(EOPNOTSUPP) );
  2719 	RETURN ( __mkSmallInteger(EOPNOTSUPP) );
  2720     }
  2720     }
  2721 #endif
  2721 #endif
  2722 
  2722 
  2723 #ifdef EPFNOSUPPORT
  2723 #ifdef EPFNOSUPPORT
  2724     if (sym == @symbol(EPFNOSUPPORT)) {
  2724     if (sym == @symbol(EPFNOSUPPORT)) {
  2725         RETURN ( __mkSmallInteger(EPFNOSUPPORT) );
  2725 	RETURN ( __mkSmallInteger(EPFNOSUPPORT) );
  2726     }
  2726     }
  2727 #endif
  2727 #endif
  2728 
  2728 
  2729 #ifdef EAFNOSUPPORT
  2729 #ifdef EAFNOSUPPORT
  2730     if (sym == @symbol(EAFNOSUPPORT)) {
  2730     if (sym == @symbol(EAFNOSUPPORT)) {
  2731         RETURN ( __mkSmallInteger(EAFNOSUPPORT) );
  2731 	RETURN ( __mkSmallInteger(EAFNOSUPPORT) );
  2732     }
  2732     }
  2733 #endif
  2733 #endif
  2734 
  2734 
  2735 #ifdef EADDRINUSE
  2735 #ifdef EADDRINUSE
  2736     if (sym == @symbol(EADDRINUSE)) {
  2736     if (sym == @symbol(EADDRINUSE)) {
  2737         RETURN ( __mkSmallInteger(EADDRINUSE) );
  2737 	RETURN ( __mkSmallInteger(EADDRINUSE) );
  2738     }
  2738     }
  2739 #endif
  2739 #endif
  2740 
  2740 
  2741 #ifdef EADDRNOTAVAIL
  2741 #ifdef EADDRNOTAVAIL
  2742     if (sym == @symbol(EADDRNOTAVAIL)) {
  2742     if (sym == @symbol(EADDRNOTAVAIL)) {
  2743         RETURN ( __mkSmallInteger(EADDRNOTAVAIL) );
  2743 	RETURN ( __mkSmallInteger(EADDRNOTAVAIL) );
  2744     }
  2744     }
  2745 #endif
  2745 #endif
  2746 
  2746 
  2747 #ifdef ETIMEDOUT
  2747 #ifdef ETIMEDOUT
  2748     if (sym == @symbol(ETIMEDOUT)) {
  2748     if (sym == @symbol(ETIMEDOUT)) {
  2749         RETURN ( __mkSmallInteger(ETIMEDOUT) );
  2749 	RETURN ( __mkSmallInteger(ETIMEDOUT) );
  2750     }
  2750     }
  2751 #endif
  2751 #endif
  2752 
  2752 
  2753 #ifdef ECONNREFUSED
  2753 #ifdef ECONNREFUSED
  2754     if (sym == @symbol(ECONNREFUSED)) {
  2754     if (sym == @symbol(ECONNREFUSED)) {
  2755         RETURN ( __mkSmallInteger(ECONNREFUSED) );
  2755 	RETURN ( __mkSmallInteger(ECONNREFUSED) );
  2756     }
  2756     }
  2757 #endif
  2757 #endif
  2758 
  2758 
  2759 #ifdef ENETDOWN
  2759 #ifdef ENETDOWN
  2760     if (sym == @symbol(ENETDOWN)) {
  2760     if (sym == @symbol(ENETDOWN)) {
  2761         RETURN ( __mkSmallInteger(ENETDOWN) );
  2761 	RETURN ( __mkSmallInteger(ENETDOWN) );
  2762     }
  2762     }
  2763 #endif
  2763 #endif
  2764 
  2764 
  2765 #ifdef ENETUNREACH
  2765 #ifdef ENETUNREACH
  2766     if (sym == @symbol(ENETUNREACH)) {
  2766     if (sym == @symbol(ENETUNREACH)) {
  2767         RETURN ( __mkSmallInteger(ENETUNREACH) );
  2767 	RETURN ( __mkSmallInteger(ENETUNREACH) );
  2768     }
  2768     }
  2769 #endif
  2769 #endif
  2770 
  2770 
  2771 #ifdef ENETRESET
  2771 #ifdef ENETRESET
  2772     if (sym == @symbol(ENETRESET)) {
  2772     if (sym == @symbol(ENETRESET)) {
  2773         RETURN ( __mkSmallInteger(ENETRESET) );
  2773 	RETURN ( __mkSmallInteger(ENETRESET) );
  2774     }
  2774     }
  2775 #endif
  2775 #endif
  2776 
  2776 
  2777 #ifdef ECONNABORTED
  2777 #ifdef ECONNABORTED
  2778     if (sym == @symbol(ECONNABORTED)) {
  2778     if (sym == @symbol(ECONNABORTED)) {
  2779         RETURN ( __mkSmallInteger(ECONNABORTED) );
  2779 	RETURN ( __mkSmallInteger(ECONNABORTED) );
  2780     }
  2780     }
  2781 #endif
  2781 #endif
  2782 
  2782 
  2783 #ifdef ECONNRESET
  2783 #ifdef ECONNRESET
  2784     if (sym == @symbol(ECONNRESET)) {
  2784     if (sym == @symbol(ECONNRESET)) {
  2785         RETURN ( __mkSmallInteger(ECONNRESET) );
  2785 	RETURN ( __mkSmallInteger(ECONNRESET) );
  2786     }
  2786     }
  2787 #endif
  2787 #endif
  2788 
  2788 
  2789 #ifdef EISCONN
  2789 #ifdef EISCONN
  2790     if (sym == @symbol(EISCONN)) {
  2790     if (sym == @symbol(EISCONN)) {
  2791         RETURN ( __mkSmallInteger(EISCONN) );
  2791 	RETURN ( __mkSmallInteger(EISCONN) );
  2792     }
  2792     }
  2793 #endif
  2793 #endif
  2794 
  2794 
  2795 #ifdef ENOTCONN
  2795 #ifdef ENOTCONN
  2796     if (sym == @symbol(ENOTCONN)) {
  2796     if (sym == @symbol(ENOTCONN)) {
  2797         RETURN ( __mkSmallInteger(ENOTCONN) );
  2797 	RETURN ( __mkSmallInteger(ENOTCONN) );
  2798     }
  2798     }
  2799 #endif
  2799 #endif
  2800 
  2800 
  2801 #ifdef ESHUTDOWN
  2801 #ifdef ESHUTDOWN
  2802     if (sym == @symbol(ESHUTDOWN)) {
  2802     if (sym == @symbol(ESHUTDOWN)) {
  2803         RETURN ( __mkSmallInteger(ESHUTDOWN) );
  2803 	RETURN ( __mkSmallInteger(ESHUTDOWN) );
  2804     }
  2804     }
  2805 #endif
  2805 #endif
  2806 
  2806 
  2807 #ifdef EHOSTDOWN
  2807 #ifdef EHOSTDOWN
  2808     if (sym == @symbol(EHOSTDOWN)) {
  2808     if (sym == @symbol(EHOSTDOWN)) {
  2809         RETURN ( __mkSmallInteger(EHOSTDOWN) );
  2809 	RETURN ( __mkSmallInteger(EHOSTDOWN) );
  2810     }
  2810     }
  2811 #endif
  2811 #endif
  2812 
  2812 
  2813 #ifdef EHOSTUNREACH
  2813 #ifdef EHOSTUNREACH
  2814     if (sym == @symbol(EHOSTUNREACH)) {
  2814     if (sym == @symbol(EHOSTUNREACH)) {
  2815         RETURN ( __mkSmallInteger(EHOSTUNREACH) );
  2815 	RETURN ( __mkSmallInteger(EHOSTUNREACH) );
  2816     }
  2816     }
  2817 #endif
  2817 #endif
  2818     /*
  2818     /*
  2819      * windows socket errors
  2819      * windows socket errors
  2820      */
  2820      */
  2821 #ifdef WSAEINTR
  2821 #ifdef WSAEINTR
  2822     if (sym == @symbol(WSAEINTR)) {
  2822     if (sym == @symbol(WSAEINTR)) {
  2823         RETURN ( __mkSmallInteger(WSAEINTR) );
  2823 	RETURN ( __mkSmallInteger(WSAEINTR) );
  2824     }
  2824     }
  2825 #endif
  2825 #endif
  2826 #ifdef WSAEBADF
  2826 #ifdef WSAEBADF
  2827     if (sym == @symbol(WSAEBADF)) {
  2827     if (sym == @symbol(WSAEBADF)) {
  2828         RETURN ( __mkSmallInteger(WSAEBADF) );
  2828 	RETURN ( __mkSmallInteger(WSAEBADF) );
  2829     }
  2829     }
  2830 #endif
  2830 #endif
  2831 #ifdef WSAEACCESS
  2831 #ifdef WSAEACCESS
  2832     if (sym == @symbol(WSAEACCESS)) {
  2832     if (sym == @symbol(WSAEACCESS)) {
  2833         RETURN ( __mkSmallInteger(WSAEACCESS) );
  2833 	RETURN ( __mkSmallInteger(WSAEACCESS) );
  2834     }
  2834     }
  2835 #endif
  2835 #endif
  2836 #ifdef WSAEFAULT
  2836 #ifdef WSAEFAULT
  2837     if (sym == @symbol(WSAEFAULT)) {
  2837     if (sym == @symbol(WSAEFAULT)) {
  2838         RETURN ( __mkSmallInteger(WSAEFAULT) );
  2838 	RETURN ( __mkSmallInteger(WSAEFAULT) );
  2839     }
  2839     }
  2840 #endif
  2840 #endif
  2841 #ifdef WSAEINVAL
  2841 #ifdef WSAEINVAL
  2842     if (sym == @symbol(WSAEINVAL)) {
  2842     if (sym == @symbol(WSAEINVAL)) {
  2843         RETURN ( __mkSmallInteger(WSAEINVAL) );
  2843 	RETURN ( __mkSmallInteger(WSAEINVAL) );
  2844     }
  2844     }
  2845 #endif
  2845 #endif
  2846 #ifdef WSAEMFILE
  2846 #ifdef WSAEMFILE
  2847     if (sym == @symbol(WSAEMFILE)) {
  2847     if (sym == @symbol(WSAEMFILE)) {
  2848         RETURN ( __mkSmallInteger(WSAEMFILE) );
  2848 	RETURN ( __mkSmallInteger(WSAEMFILE) );
  2849     }
  2849     }
  2850 #endif
  2850 #endif
  2851 #ifdef WSAEWOULDBLOCK
  2851 #ifdef WSAEWOULDBLOCK
  2852     if (sym == @symbol(WSAEWOULDBLOCK)) {
  2852     if (sym == @symbol(WSAEWOULDBLOCK)) {
  2853         RETURN ( __mkSmallInteger(WSAEWOULDBLOCK) );
  2853 	RETURN ( __mkSmallInteger(WSAEWOULDBLOCK) );
  2854     }
  2854     }
  2855 #endif
  2855 #endif
  2856 #ifdef WSAEINPROGRESS
  2856 #ifdef WSAEINPROGRESS
  2857     if (sym == @symbol(WSAEINPROGRESS)) {
  2857     if (sym == @symbol(WSAEINPROGRESS)) {
  2858         RETURN ( __mkSmallInteger(WSAEINPROGRESS) );
  2858 	RETURN ( __mkSmallInteger(WSAEINPROGRESS) );
  2859     }
  2859     }
  2860 #endif
  2860 #endif
  2861 #ifdef WSAEALREADY
  2861 #ifdef WSAEALREADY
  2862     if (sym == @symbol(WSAEALREADY)) {
  2862     if (sym == @symbol(WSAEALREADY)) {
  2863         RETURN ( __mkSmallInteger(WSAEALREADY) );
  2863 	RETURN ( __mkSmallInteger(WSAEALREADY) );
  2864     }
  2864     }
  2865 #endif
  2865 #endif
  2866 #ifdef WSAENOTSOCK
  2866 #ifdef WSAENOTSOCK
  2867     if (sym == @symbol(WSAENOTSOCK)) {
  2867     if (sym == @symbol(WSAENOTSOCK)) {
  2868         RETURN ( __mkSmallInteger(WSAENOTSOCK) );
  2868 	RETURN ( __mkSmallInteger(WSAENOTSOCK) );
  2869     }
  2869     }
  2870 #endif
  2870 #endif
  2871 #ifdef WSAEPROTONOSUPPORT
  2871 #ifdef WSAEPROTONOSUPPORT
  2872     if (sym == @symbol(WSAEPROTONOSUPPORT)) {
  2872     if (sym == @symbol(WSAEPROTONOSUPPORT)) {
  2873         RETURN ( __mkSmallInteger(WSAEPROTONOSUPPORT) );
  2873 	RETURN ( __mkSmallInteger(WSAEPROTONOSUPPORT) );
  2874     }
  2874     }
  2875 #endif
  2875 #endif
  2876 #ifdef WSAESOCKTNOSUPPORT
  2876 #ifdef WSAESOCKTNOSUPPORT
  2877     if (sym == @symbol(WSAESOCKTNOSUPPORT)) {
  2877     if (sym == @symbol(WSAESOCKTNOSUPPORT)) {
  2878         RETURN ( __mkSmallInteger(WSAESOCKTNOSUPPORT) );
  2878 	RETURN ( __mkSmallInteger(WSAESOCKTNOSUPPORT) );
  2879     }
  2879     }
  2880 #endif
  2880 #endif
  2881 #ifdef E_NOINTERFACE
  2881 #ifdef E_NOINTERFACE
  2882     if (sym == @symbol(E_NOINTERFACE)) {
  2882     if (sym == @symbol(E_NOINTERFACE)) {
  2883         RETURN ( __MKUINT(E_NOINTERFACE) );
  2883 	RETURN ( __MKUINT(E_NOINTERFACE) );
  2884     }
  2884     }
  2885 #endif
  2885 #endif
  2886 #ifdef CO_E_NOTINITIALIZED
  2886 #ifdef CO_E_NOTINITIALIZED
  2887     if (sym == @symbol(CO_E_NOTINITIALIZED)) {
  2887     if (sym == @symbol(CO_E_NOTINITIALIZED)) {
  2888         RETURN ( __MKUINT(CO_E_NOTINITIALIZED) );
  2888 	RETURN ( __MKUINT(CO_E_NOTINITIALIZED) );
  2889     }
  2889     }
  2890 #endif
  2890 #endif
  2891 #ifdef REGDB_E_CLASSNOTREG
  2891 #ifdef REGDB_E_CLASSNOTREG
  2892     if (sym == @symbol(REGDB_E_CLASSNOTREG)) {
  2892     if (sym == @symbol(REGDB_E_CLASSNOTREG)) {
  2893         RETURN ( __MKUINT(REGDB_E_CLASSNOTREG) );
  2893 	RETURN ( __MKUINT(REGDB_E_CLASSNOTREG) );
  2894     }
  2894     }
  2895 #endif
  2895 #endif
  2896 #ifdef CLASS_E_NOAGGREGATION
  2896 #ifdef CLASS_E_NOAGGREGATION
  2897     if (sym == @symbol(CLASS_E_NOAGGREGATION)) {
  2897     if (sym == @symbol(CLASS_E_NOAGGREGATION)) {
  2898         RETURN ( __MKUINT(CLASS_E_NOAGGREGATION) );
  2898 	RETURN ( __MKUINT(CLASS_E_NOAGGREGATION) );
  2899     }
  2899     }
  2900 #endif
  2900 #endif
  2901 #ifdef DISP_E_UNKNOWNNAME
  2901 #ifdef DISP_E_UNKNOWNNAME
  2902     if (sym == @symbol(DISP_E_UNKNOWNNAME)) {
  2902     if (sym == @symbol(DISP_E_UNKNOWNNAME)) {
  2903         RETURN ( __MKUINT(DISP_E_UNKNOWNNAME) );
  2903 	RETURN ( __MKUINT(DISP_E_UNKNOWNNAME) );
  2904     }
  2904     }
  2905 #endif
  2905 #endif
  2906 #ifdef OLEOBJ_E_NOVERBS
  2906 #ifdef OLEOBJ_E_NOVERBS
  2907     if (sym == @symbol(OLEOBJ_E_NOVERBS)) {
  2907     if (sym == @symbol(OLEOBJ_E_NOVERBS)) {
  2908         RETURN ( __MKUINT(OLEOBJ_E_NOVERBS) );
  2908 	RETURN ( __MKUINT(OLEOBJ_E_NOVERBS) );
  2909     }
  2909     }
  2910 #endif
  2910 #endif
  2911 
  2911 
  2912 %}.
  2912 %}.
  2913     ^ -1
  2913     ^ -1
  2962     "/ I know: this is a kludge but should work for now...
  2962     "/ I know: this is a kludge but should work for now...
  2963     "/ ...this will change in an upcoming version to include
  2963     "/ ...this will change in an upcoming version to include
  2964     "/ command.com command-line parsing here (sigh).
  2964     "/ command.com command-line parsing here (sigh).
  2965     hasRedirection := false.
  2965     hasRedirection := false.
  2966     (aCommandString isNil or:[aCommandString includesAny:'<>|']) ifTrue:[
  2966     (aCommandString isNil or:[aCommandString includesAny:'<>|']) ifTrue:[
  2967         hasRedirection := true
  2967 	hasRedirection := true
  2968     ].
  2968     ].
  2969 
  2969 
  2970     self isMSWINDOWSNTlike ifTrue:[
  2970     self isMSWINDOWSNTlike ifTrue:[
  2971         hasRedirection ifFalse:[
  2971 	hasRedirection ifFalse:[
  2972             "/ test whether the commandString is an executable;
  2972 	    "/ test whether the commandString is an executable;
  2973             "/ then, no shell is required
  2973 	    "/ then, no shell is required
  2974             cmdName := aCommandString withoutSeparators.
  2974 	    cmdName := aCommandString withoutSeparators.
  2975             (cmdName notEmpty and:[(cmdName startsWith:$") not]) ifTrue:[
  2975 	    (cmdName notEmpty and:[(cmdName startsWith:$") not]) ifTrue:[
  2976                 |index file suffix|
  2976 		|index file suffix|
  2977 
  2977 
  2978                 index := cmdName indexOfSeparatorStartingAt:1.
  2978 		index := cmdName indexOfSeparatorStartingAt:1.
  2979                 index ~~ 0 ifTrue:[
  2979 		index ~~ 0 ifTrue:[
  2980                     cmdName := cmdName copyFrom:1 to:(index -1).
  2980 		    cmdName := cmdName copyFrom:1 to:(index -1).
  2981                 ].
  2981 		].
  2982 
  2982 
  2983                 file   := cmdName asFilename.
  2983 		file   := cmdName asFilename.
  2984                 suffix := file suffix.
  2984 		suffix := file suffix.
  2985 
  2985 
  2986                 suffix isEmptyOrNil ifTrue:[
  2986 		suffix isEmptyOrNil ifTrue:[
  2987                     suffix := 'exe'.
  2987 		    suffix := 'exe'.
  2988                     file := file withSuffix:suffix.
  2988 		    file := file withSuffix:suffix.
  2989                 ].
  2989 		].
  2990 
  2990 
  2991                 (file exists and:[suffix = 'exe']) ifTrue:[
  2991 		(file exists and:[suffix = 'exe']) ifTrue:[
  2992                     "/ is an executable, no shell required
  2992 		    "/ is an executable, no shell required
  2993                     ^ Array with:nil with:aCommandString.
  2993 		    ^ Array with:nil with:aCommandString.
  2994                 ].
  2994 		].
  2995                 (self pathOfCommand:cmdName) notNil ifTrue:[
  2995 		(self pathOfCommand:cmdName) notNil ifTrue:[
  2996                     "/ is an executable, no shell required
  2996 		    "/ is an executable, no shell required
  2997                     ^ Array with:nil with:aCommandString.
  2997 		    ^ Array with:nil with:aCommandString.
  2998                 ].
  2998 		].
  2999             ].
  2999 	    ].
  3000         ].
  3000 	].
  3001         shell := self getEnvironment:'COMSPEC'.
  3001 	shell := self getEnvironment:'COMSPEC'.
  3002         shell isNil ifTrue:[
  3002 	shell isNil ifTrue:[
  3003             wDir := self getWindowsSystemDirectory asFilename.
  3003 	    wDir := self getWindowsSystemDirectory asFilename.
  3004             shell := (wDir construct:'cmd.exe').
  3004 	    shell := (wDir construct:'cmd.exe').
  3005             shell exists ifFalse:[
  3005 	    shell exists ifFalse:[
  3006                 shell := (wDir construct:'command.com').
  3006 		shell := (wDir construct:'command.com').
  3007                 shell exists ifFalse:[
  3007 		shell exists ifFalse:[
  3008                     self error:'no command.com available'.
  3008 		    self error:'no command.com available'.
  3009                 ]
  3009 		]
  3010             ].
  3010 	    ].
  3011             shell := shell pathName.
  3011 	    shell := shell pathName.
  3012         ].
  3012 	].
  3013         aCommandString isNil ifTrue:[
  3013 	aCommandString isNil ifTrue:[
  3014             ^ Array with:nil with:shell
  3014 	    ^ Array with:nil with:shell
  3015         ].
  3015 	].
  3016 
  3016 
  3017         ^ Array with:nil with:(shell , ' /c ' , '"' , aCommandString , '"' )
  3017 	^ Array with:nil with:(shell , ' /c ' , '"' , aCommandString , '"' )
  3018     ].
  3018     ].
  3019 
  3019 
  3020     "/ I/O redirection is not yet handled directly
  3020     "/ I/O redirection is not yet handled directly
  3021     "/ fallBack to command.com (below) to do it.
  3021     "/ fallBack to command.com (below) to do it.
  3022 
  3022 
  3023     hasRedirection ifFalse:[
  3023     hasRedirection ifFalse:[
  3024         words := aCommandString asCollectionOfSubstringsSeparatedBy:Character space.
  3024 	words := aCommandString asCollectionOfSubstringsSeparatedBy:Character space.
  3025         args := ' '.
  3025 	args := ' '.
  3026         words from:2 to:(words size) do:[:s |
  3026 	words from:2 to:(words size) do:[:s |
  3027             args := args , (s , ' ').
  3027 	    args := args , (s , ' ').
  3028         ].
  3028 	].
  3029 
  3029 
  3030         path := self pathOfCommand:(words at:1).
  3030 	path := self pathOfCommand:(words at:1).
  3031         path notNil ifTrue:[
  3031 	path notNil ifTrue:[
  3032             "/ execute the command directly -
  3032 	    "/ execute the command directly -
  3033             "/ without going through command.com
  3033 	    "/ without going through command.com
  3034 
  3034 
  3035             self isMSWINDOWSNTlike ifTrue:[
  3035 	    self isMSWINDOWSNTlike ifTrue:[
  3036                 args := path , args.
  3036 		args := path , args.
  3037             ].
  3037 	    ].
  3038 
  3038 
  3039             ^ Array with:path with:args
  3039 	    ^ Array with:path with:args
  3040         ].
  3040 	].
  3041     ].
  3041     ].
  3042 
  3042 
  3043     "/ I/O redirection or no executable was found
  3043     "/ I/O redirection or no executable was found
  3044 
  3044 
  3045     shell := self getEnvironment:'COMSPEC'.
  3045     shell := self getEnvironment:'COMSPEC'.
  3046     shell isNil ifTrue:[
  3046     shell isNil ifTrue:[
  3047         wDir := self getWindowsSystemDirectory asFilename.
  3047 	wDir := self getWindowsSystemDirectory asFilename.
  3048         shell := (wDir construct:'cmd.exe').
  3048 	shell := (wDir construct:'cmd.exe').
  3049         shell exists ifFalse:[
  3049 	shell exists ifFalse:[
  3050             shell := (wDir construct:'command.com').
  3050 	    shell := (wDir construct:'command.com').
  3051             shell exists ifFalse:[
  3051 	    shell exists ifFalse:[
  3052                 self error:'no command.com available'.
  3052 		self error:'no command.com available'.
  3053             ]
  3053 	    ]
  3054         ].
  3054 	].
  3055         shell := shell pathName.
  3055 	shell := shell pathName.
  3056     ].
  3056     ].
  3057     aCommandString isNil ifTrue:[
  3057     aCommandString isNil ifTrue:[
  3058         ^ Array with:shell with:shell
  3058 	^ Array with:shell with:shell
  3059     ].
  3059     ].
  3060     ^ Array with:shell with:(shell , ' /c ' , aCommandString)
  3060     ^ Array with:shell with:(shell , ' /c ' , aCommandString)
  3061 
  3061 
  3062     "Modified: / 20-01-1998 / 16:57:19 / md"
  3062     "Modified: / 20-01-1998 / 16:57:19 / md"
  3063     "Modified: / 11-02-2007 / 20:51:08 / cg"
  3063     "Modified: / 11-02-2007 / 20:51:08 / cg"
  3065 
  3065 
  3066 exec:aCommandPath withArguments:argString environment:environment fileDescriptors:fdArray fork:doFork newPgrp:newPgrp inDirectory:aDirectory
  3066 exec:aCommandPath withArguments:argString environment:environment fileDescriptors:fdArray fork:doFork newPgrp:newPgrp inDirectory:aDirectory
  3067     "Internal lowLevel entry for combined fork & exec for WIN32
  3067     "Internal lowLevel entry for combined fork & exec for WIN32
  3068 
  3068 
  3069      If fork is false (chain a command):
  3069      If fork is false (chain a command):
  3070          execute the OS command specified by the argument, aCommandPath, with
  3070 	 execute the OS command specified by the argument, aCommandPath, with
  3071          arguments in argArray (no arguments, if nil).
  3071 	 arguments in argArray (no arguments, if nil).
  3072          If successful, this method does not return and smalltalk is gone.
  3072 	 If successful, this method does not return and smalltalk is gone.
  3073          If not successful, it does return.
  3073 	 If not successful, it does return.
  3074          Normal use is with forkForCommand.
  3074 	 Normal use is with forkForCommand.
  3075 
  3075 
  3076      If fork is true (subprocess command execution):
  3076      If fork is true (subprocess command execution):
  3077         fork a child to do the above.
  3077 	fork a child to do the above.
  3078         The process id of the child process is returned; nil if the fork failed.
  3078 	The process id of the child process is returned; nil if the fork failed.
  3079 
  3079 
  3080      fdArray contains the filedescriptors, to be used for the child (if fork is true).
  3080      fdArray contains the filedescriptors, to be used for the child (if fork is true).
  3081         fdArray[1] = 15 -> use fd 15 as stdin.
  3081 	fdArray[1] = 15 -> use fd 15 as stdin.
  3082         If an element of the array is set to nil, the corresponding filedescriptor
  3082 	If an element of the array is set to nil, the corresponding filedescriptor
  3083         will be closed for the child.
  3083 	will be closed for the child.
  3084         fdArray[0] == StdIn for child
  3084 	fdArray[0] == StdIn for child
  3085         fdArray[1] == StdOut for child
  3085 	fdArray[1] == StdOut for child
  3086         fdArray[2] == StdErr for child
  3086 	fdArray[2] == StdErr for child
  3087         on VMS, these must be channels as returned by createMailBox.
  3087 	on VMS, these must be channels as returned by createMailBox.
  3088 
  3088 
  3089      NOTE that in WIN32 the fds are HANDLES.
  3089      NOTE that in WIN32 the fds are HANDLES.
  3090 
  3090 
  3091      If newPgrp is true, the subprocess will be established in a new process group.
  3091      If newPgrp is true, the subprocess will be established in a new process group.
  3092         The processgroup will be equal to id.
  3092 	The processgroup will be equal to id.
  3093         newPgrp is not used on WIN32 and VMS systems."
  3093 	newPgrp is not used on WIN32 and VMS systems."
  3094 
  3094 
  3095     |dirPath cmdPath cmdLine rslt|
  3095     |dirPath cmdPath cmdLine rslt|
  3096 
  3096 
  3097     aDirectory notNil ifTrue:[
  3097     aDirectory notNil ifTrue:[
  3098         dirPath := aDirectory asFilename asAbsoluteFilename osNameForDirectory.
  3098 	dirPath := aDirectory asFilename asAbsoluteFilename osNameForDirectory.
  3099         (dirPath endsWith:':') ifTrue:[
  3099 	(dirPath endsWith:':') ifTrue:[
  3100             dirPath := dirPath , '\'.
  3100 	    dirPath := dirPath , '\'.
  3101         ].
  3101 	].
  3102     ].
  3102     ].
  3103 
  3103 
  3104     self isMSWINDOWSNTlike ifTrue:[
  3104     self isMSWINDOWSNTlike ifTrue:[
  3105         cmdPath := aCommandPath.
  3105 	cmdPath := aCommandPath.
  3106         cmdLine := argString
  3106 	cmdLine := argString
  3107     ] ifFalse:[
  3107     ] ifFalse:[
  3108         cmdPath := 'stxspawn.exe'.
  3108 	cmdPath := 'stxspawn.exe'.
  3109         cmdLine := 'stxspawn.exe ' , aCommandPath , ' ' , argString
  3109 	cmdLine := 'stxspawn.exe ' , aCommandPath , ' ' , argString
  3110     ].
  3110     ].
  3111 
  3111 
  3112     rslt := self
  3112     rslt := self
  3113         primExec:cmdPath
  3113 	primExec:cmdPath
  3114         commandLine:cmdLine
  3114 	commandLine:cmdLine
  3115         fileDescriptors:fdArray
  3115 	fileDescriptors:fdArray
  3116         fork:doFork
  3116 	fork:doFork
  3117         newPgrp:newPgrp
  3117 	newPgrp:newPgrp
  3118         inPath:dirPath
  3118 	inPath:dirPath
  3119         createFlags:nil.
  3119 	createFlags:nil.
  3120 
  3120 
  3121 "/ 'created ' print. cmdLine print. ' -> ' print. rslt printCR.
  3121 "/ 'created ' print. cmdLine print. ' -> ' print. rslt printCR.
  3122     ^ rslt
  3122     ^ rslt
  3123 
  3123 
  3124     "Modified: / 31.1.1998 / 10:54:24 / md"
  3124     "Modified: / 31.1.1998 / 10:54:24 / md"
  3132 %{
  3132 %{
  3133     DWORD endStatus;
  3133     DWORD endStatus;
  3134     int status = -1;
  3134     int status = -1;
  3135 
  3135 
  3136     if (__isExternalAddressLike(aProcessId)) {
  3136     if (__isExternalAddressLike(aProcessId)) {
  3137         HANDLE handle = _HANDLEVal(aProcessId);
  3137 	HANDLE handle = _HANDLEVal(aProcessId);
  3138         if (handle) {
  3138 	if (handle) {
  3139 #ifdef DO_WRAP_CALLS
  3139 #ifdef DO_WRAP_CALLS
  3140             do {
  3140 	    do {
  3141                 __threadErrno = 0;
  3141 		__threadErrno = 0;
  3142                 endStatus = STX_API_CALL2( "WaitForSingleObject", WaitForSingleObject, handle, INFINITE);
  3142 		endStatus = STX_API_CALL2( "WaitForSingleObject", WaitForSingleObject, handle, INFINITE);
  3143             } while ((endStatus < 0) && (__threadErrno == EINTR));
  3143 	    } while ((endStatus < 0) && (__threadErrno == EINTR));
  3144 #else
  3144 #else
  3145             endStatus = WaitForSingleObject(handle , INFINITE);
  3145 	    endStatus = WaitForSingleObject(handle , INFINITE);
  3146 #endif
  3146 #endif
  3147             if (endStatus != WAIT_FAILED) {
  3147 	    if (endStatus != WAIT_FAILED) {
  3148                 if (GetExitCodeProcess(handle,&endStatus)) {
  3148 		if (GetExitCodeProcess(handle,&endStatus)) {
  3149                     status = endStatus;
  3149 		    status = endStatus;
  3150 #ifdef PROCESSDEBUGWIN32
  3150 #ifdef PROCESSDEBUGWIN32
  3151                     console_fprintf(stderr, "getexitcode status = %d\n",status);
  3151 		    console_fprintf(stderr, "getexitcode status = %d\n",status);
  3152                 } else {
  3152 		} else {
  3153                     console_fprintf(stderr, "getexitcode failed.\n");
  3153 		    console_fprintf(stderr, "getexitcode failed.\n");
  3154 #endif
  3154 #endif
  3155                 }
  3155 		}
  3156             }
  3156 	    }
  3157         }
  3157 	}
  3158         RETURN ( __mkSmallInteger(status));
  3158 	RETURN ( __mkSmallInteger(status));
  3159     }
  3159     }
  3160 %}.
  3160 %}.
  3161     self primitiveFailed
  3161     self primitiveFailed
  3162 !
  3162 !
  3163 
  3163 
  3167      return nil."
  3167      return nil."
  3168 
  3168 
  3169     |path f fExt|
  3169     |path f fExt|
  3170 
  3170 
  3171     aCommand asFilename isAbsolute ifTrue:[
  3171     aCommand asFilename isAbsolute ifTrue:[
  3172         aCommand asFilename exists ifTrue:[
  3172 	aCommand asFilename exists ifTrue:[
  3173             ^ aCommand
  3173 	    ^ aCommand
  3174         ].
  3174 	].
  3175         ^ nil
  3175 	^ nil
  3176     ].
  3176     ].
  3177 
  3177 
  3178     (aCommand includes:Filename separator) ifTrue:[
  3178     (aCommand includes:Filename separator) ifTrue:[
  3179         path := Filename currentDirectory construct:aCommand.
  3179 	path := Filename currentDirectory construct:aCommand.
  3180         (path exists
  3180 	(path exists
  3181         or:[(path withSuffix:'exe') exists]) ifTrue:[
  3181 	or:[(path withSuffix:'exe') exists]) ifTrue:[
  3182             ^ path pathName
  3182 	    ^ path pathName
  3183         ].
  3183 	].
  3184     ].
  3184     ].
  3185 
  3185 
  3186     path := self getEnvironment:'PATH'.
  3186     path := self getEnvironment:'PATH'.
  3187     path notNil ifTrue:[
  3187     path notNil ifTrue:[
  3188         (path asCollectionOfSubstringsSeparatedBy:(self pathSeparator)) do:[:path |
  3188 	(path asCollectionOfSubstringsSeparatedBy:(self pathSeparator)) do:[:path |
  3189             path isEmpty ifTrue:[
  3189 	    path isEmpty ifTrue:[
  3190                 f := aCommand asFilename
  3190 		f := aCommand asFilename
  3191             ] ifFalse:[
  3191 	    ] ifFalse:[
  3192                 f := path asFilename construct:aCommand.
  3192 		f := path asFilename construct:aCommand.
  3193             ].
  3193 	    ].
  3194             f suffix isEmpty ifTrue:[
  3194 	    f suffix isEmpty ifTrue:[
  3195                 self executableFileExtensions do:[:ext |
  3195 		self executableFileExtensions do:[:ext |
  3196                     ext notEmpty ifTrue:[
  3196 		    ext notEmpty ifTrue:[
  3197                         fExt := (f pathName , '.' , ext) asFilename.
  3197 			fExt := (f pathName , '.' , ext) asFilename.
  3198                     ] ifFalse:[
  3198 		    ] ifFalse:[
  3199                         fExt := f.
  3199 			fExt := f.
  3200                     ].
  3200 		    ].
  3201                     fExt isExecutable ifTrue:[
  3201 		    fExt isExecutable ifTrue:[
  3202                         ^ fExt pathName
  3202 			^ fExt pathName
  3203                     ].
  3203 		    ].
  3204                 ].
  3204 		].
  3205             ] ifFalse:[
  3205 	    ] ifFalse:[
  3206                 f isExecutable ifTrue:[
  3206 		f isExecutable ifTrue:[
  3207                     ^ f pathName
  3207 		    ^ f pathName
  3208                 ].
  3208 		].
  3209             ].
  3209 	    ].
  3210         ].
  3210 	].
  3211     ].
  3211     ].
  3212     ^ nil
  3212     ^ nil
  3213 
  3213 
  3214     "windows:
  3214     "windows:
  3215 
  3215 
  3250     PROCESS_INFORMATION lppiProcInfo;
  3250     PROCESS_INFORMATION lppiProcInfo;
  3251     SECURITY_ATTRIBUTES sa;
  3251     SECURITY_ATTRIBUTES sa;
  3252     SECURITY_DESCRIPTOR sd;
  3252     SECURITY_DESCRIPTOR sd;
  3253 
  3253 
  3254     if (__isString(dirName)) {
  3254     if (__isString(dirName)) {
  3255         dir = __stringVal(dirName);
  3255 	dir = __stringVal(dirName);
  3256     }
  3256     }
  3257     if ((__isString(commandPath) || (commandPath == nil))
  3257     if ((__isString(commandPath) || (commandPath == nil))
  3258      && __isString(commandLine)) {
  3258      && __isString(commandLine)) {
  3259 #if 0
  3259 #if 0
  3260         /*
  3260 	/*
  3261          * generate command line (cmd plus args)
  3261 	 * generate command line (cmd plus args)
  3262          */
  3262 	 */
  3263         if (__isWinNT) {
  3263 	if (__isWinNT) {
  3264             char *d;
  3264 	    char *d;
  3265 
  3265 
  3266             strcpy(fullCmdPath, __stringVal(aCommandPath));
  3266 	    strcpy(fullCmdPath, __stringVal(aCommandPath));
  3267             d = strchr(fullCmdPath,' ');
  3267 	    d = strchr(fullCmdPath,' ');
  3268             if (d) {
  3268 	    if (d) {
  3269                 *d++ = 0;
  3269 		*d++ = 0;
  3270                 strcpy(fullCmdLine, d);
  3270 		strcpy(fullCmdLine, d);
  3271             } else {
  3271 	    } else {
  3272                 fullCmdLine[0] = '\0';
  3272 		fullCmdLine[0] = '\0';
  3273             }
  3273 	    }
  3274         } else {
  3274 	} else {
  3275             //fullCmdPath = 0;
  3275 	    //fullCmdPath = 0;
  3276             strcpy(fullCmdPath,"stxspawn.exe");
  3276 	    strcpy(fullCmdPath,"stxspawn.exe");
  3277             strcpy(fullCmdLine,"stxspawn.exe ");
  3277 	    strcpy(fullCmdLine,"stxspawn.exe ");
  3278             strcat(fullCmdLine, __stringVal(aCommandPath));
  3278 	    strcat(fullCmdLine, __stringVal(aCommandPath));
  3279         }
  3279 	}
  3280 
  3280 
  3281         if (__isString(argArray)) {
  3281 	if (__isString(argArray)) {
  3282             if (strlen(fullCmdLine) > 0) {
  3282 	    if (strlen(fullCmdLine) > 0) {
  3283                 strcat(fullCmdLine, " ");
  3283 		strcat(fullCmdLine, " ");
  3284             }
  3284 	    }
  3285             strcat(fullCmdLine, __stringVal(argArray));
  3285 	    strcat(fullCmdLine, __stringVal(argArray));
  3286         } else {
  3286 	} else {
  3287             int i;
  3287 	    int i;
  3288 
  3288 
  3289             for (i=0; i<__arraySize(argArray); i++) {
  3289 	    for (i=0; i<__arraySize(argArray); i++) {
  3290                 OBJ arg = __ArrayInstPtr(argArray)->a_element[i];
  3290 		OBJ arg = __ArrayInstPtr(argArray)->a_element[i];
  3291 
  3291 
  3292                 if (__isString(arg)) {
  3292 		if (__isString(arg)) {
  3293                     strcat(fullCmdLine, " ");
  3293 		    strcat(fullCmdLine, " ");
  3294                     strcat(fullCmdLine, __stringVal(arg));
  3294 		    strcat(fullCmdLine, __stringVal(arg));
  3295                 } else {
  3295 		} else {
  3296                     /* ignore */
  3296 		    /* ignore */
  3297                     console_fprintf(stderr, "bad (non-string) arg\n");
  3297 		    console_fprintf(stderr, "bad (non-string) arg\n");
  3298                 }
  3298 		}
  3299             }
  3299 	    }
  3300         }
  3300 	}
  3301 #endif
  3301 #endif
  3302         if (commandPath != nil) {
  3302 	if (commandPath != nil) {
  3303             cmdPath = __stringVal(commandPath);
  3303 	    cmdPath = __stringVal(commandPath);
  3304         }
  3304 	}
  3305         cmdLine = __stringVal(commandLine);
  3305 	cmdLine = __stringVal(commandLine);
  3306 
  3306 
  3307         /*
  3307 	/*
  3308          * create descriptors as req'd
  3308 	 * create descriptors as req'd
  3309          */
  3309 	 */
  3310         memset(&sa, 0, sizeof (sa));
  3310 	memset(&sa, 0, sizeof (sa));
  3311         sa.nLength = sizeof( sa );
  3311 	sa.nLength = sizeof( sa );
  3312         sa.lpSecurityDescriptor = NULL;
  3312 	sa.lpSecurityDescriptor = NULL;
  3313         sa.bInheritHandle = TRUE;
  3313 	sa.bInheritHandle = TRUE;
  3314         if (__isWinNT) {
  3314 	if (__isWinNT) {
  3315             InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
  3315 	    InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
  3316             SetSecurityDescriptorDacl(&sd, -1, 0, 0);
  3316 	    SetSecurityDescriptorDacl(&sd, -1, 0, 0);
  3317 
  3317 
  3318             sa.lpSecurityDescriptor = &sd;
  3318 	    sa.lpSecurityDescriptor = &sd;
  3319         }
  3319 	}
  3320         memset(&lppiProcInfo, 0, sizeof (lppiProcInfo));
  3320 	memset(&lppiProcInfo, 0, sizeof (lppiProcInfo));
  3321 
  3321 
  3322         memset(&lpsiStartInfo, 0, sizeof (lpsiStartInfo));
  3322 	memset(&lpsiStartInfo, 0, sizeof (lpsiStartInfo));
  3323         lpsiStartInfo.cb                = sizeof(lpsiStartInfo);
  3323 	lpsiStartInfo.cb                = sizeof(lpsiStartInfo);
  3324         lpsiStartInfo.lpReserved        = NULL;
  3324 	lpsiStartInfo.lpReserved        = NULL;
  3325         lpsiStartInfo.lpDesktop         = NULL;
  3325 	lpsiStartInfo.lpDesktop         = NULL;
  3326         lpsiStartInfo.lpTitle           = NULL;
  3326 	lpsiStartInfo.lpTitle           = NULL;
  3327         lpsiStartInfo.dwX               = 0;
  3327 	lpsiStartInfo.dwX               = 0;
  3328         lpsiStartInfo.dwY               = 0;
  3328 	lpsiStartInfo.dwY               = 0;
  3329         lpsiStartInfo.dwXSize           = 100;
  3329 	lpsiStartInfo.dwXSize           = 100;
  3330         lpsiStartInfo.dwYSize           = 100;
  3330 	lpsiStartInfo.dwYSize           = 100;
  3331         lpsiStartInfo.dwXCountChars     = 0;
  3331 	lpsiStartInfo.dwXCountChars     = 0;
  3332         lpsiStartInfo.dwYCountChars     = 0;
  3332 	lpsiStartInfo.dwYCountChars     = 0;
  3333         lpsiStartInfo.dwFillAttribute   = 0;
  3333 	lpsiStartInfo.dwFillAttribute   = 0;
  3334         if (0 /*__isWinNT*/) {
  3334 	if (0 /*__isWinNT*/) {
  3335             lpsiStartInfo.dwFlags           = STARTF_USESTDHANDLES;
  3335 	    lpsiStartInfo.dwFlags           = STARTF_USESTDHANDLES;
  3336             lpsiStartInfo.wShowWindow       = SW_SHOWDEFAULT;
  3336 	    lpsiStartInfo.wShowWindow       = SW_SHOWDEFAULT;
  3337         } else {
  3337 	} else {
  3338             lpsiStartInfo.dwFlags           = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES /*| STARTF_USEPOSITION*/;
  3338 	    lpsiStartInfo.dwFlags           = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES /*| STARTF_USEPOSITION*/;
  3339             lpsiStartInfo.wShowWindow       = SW_HIDE /*SW_SHOWDEFAULT*/;
  3339 	    lpsiStartInfo.wShowWindow       = SW_HIDE /*SW_SHOWDEFAULT*/;
  3340         }
  3340 	}
  3341         lpsiStartInfo.cbReserved2       = 0;
  3341 	lpsiStartInfo.cbReserved2       = 0;
  3342         lpsiStartInfo.lpReserved2       = NULL;
  3342 	lpsiStartInfo.lpReserved2       = NULL;
  3343         lpsiStartInfo.hStdInput         = NULL;
  3343 	lpsiStartInfo.hStdInput         = NULL;
  3344         lpsiStartInfo.hStdOutput        = NULL;
  3344 	lpsiStartInfo.hStdOutput        = NULL;
  3345         lpsiStartInfo.hStdError         = NULL;
  3345 	lpsiStartInfo.hStdError         = NULL;
  3346 
  3346 
  3347         /*
  3347 	/*
  3348          * set create process flags
  3348 	 * set create process flags
  3349          * if the flags arg is nil, use common defaults;
  3349 	 * if the flags arg is nil, use common defaults;
  3350          * if non-nil, it must be a positive integer containing the fdwCreate bits.
  3350 	 * if non-nil, it must be a positive integer containing the fdwCreate bits.
  3351          */
  3351 	 */
  3352         if (flagsOrNil != nil) {
  3352 	if (flagsOrNil != nil) {
  3353             fdwCreate = __longIntVal(flagsOrNil);
  3353 	    fdwCreate = __longIntVal(flagsOrNil);
  3354         } else {
  3354 	} else {
  3355             if (0 /* __isWinNT */)
  3355 	    if (0 /* __isWinNT */)
  3356                 fdwCreate = 0; //IDLE_PRIORITY_CLASS;
  3356 		fdwCreate = 0; //IDLE_PRIORITY_CLASS;
  3357             else
  3357 	    else
  3358                 fdwCreate = CREATE_NEW_CONSOLE; //|IDLE_PRIORITY_CLASS; // DETACHED_PROCESS; // NORMAL_PRIORITY_CLASS ;
  3358 		fdwCreate = CREATE_NEW_CONSOLE; //|IDLE_PRIORITY_CLASS; // DETACHED_PROCESS; // NORMAL_PRIORITY_CLASS ;
  3359 
  3359 
  3360             if (newPgrp == true) {
  3360 	    if (newPgrp == true) {
  3361                 fdwCreate |= CREATE_NEW_PROCESS_GROUP;
  3361 		fdwCreate |= CREATE_NEW_PROCESS_GROUP;
  3362             }
  3362 	    }
  3363             fdwCreate |= CREATE_DEFAULT_ERROR_MODE;
  3363 	    fdwCreate |= CREATE_DEFAULT_ERROR_MODE;
  3364         }
  3364 	}
  3365 
  3365 
  3366         if (fdArray == nil) {
  3366 	if (fdArray == nil) {
  3367             lpsiStartInfo.hStdInput  = (HANDLE) _get_osfhandle (0);
  3367 	    lpsiStartInfo.hStdInput  = (HANDLE) _get_osfhandle (0);
  3368             lpsiStartInfo.hStdOutput = (HANDLE) _get_osfhandle (1);
  3368 	    lpsiStartInfo.hStdOutput = (HANDLE) _get_osfhandle (1);
  3369             lpsiStartInfo.hStdError  = (HANDLE) _get_osfhandle (2);
  3369 	    lpsiStartInfo.hStdError  = (HANDLE) _get_osfhandle (2);
  3370         } else if (__isArrayLike(fdArray) && (__arraySize(fdArray) >= 3)) {
  3370 	} else if (__isArrayLike(fdArray) && (__arraySize(fdArray) >= 3)) {
  3371             if (__ArrayInstPtr(fdArray)->a_element[0] != nil) {
  3371 	    if (__ArrayInstPtr(fdArray)->a_element[0] != nil) {
  3372                 if (__isExternalAddressLike(__ArrayInstPtr(fdArray)->a_element[0])) {
  3372 		if (__isExternalAddressLike(__ArrayInstPtr(fdArray)->a_element[0])) {
  3373                     lpsiStartInfo.hStdInput = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[0]);
  3373 		    lpsiStartInfo.hStdInput = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[0]);
  3374                 } else {
  3374 		} else {
  3375                     lpsiStartInfo.hStdInput = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[0]));
  3375 		    lpsiStartInfo.hStdInput = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[0]));
  3376                 }
  3376 		}
  3377             }
  3377 	    }
  3378             if (__ArrayInstPtr(fdArray)->a_element[1] != nil) {
  3378 	    if (__ArrayInstPtr(fdArray)->a_element[1] != nil) {
  3379                 if (__isExternalAddressLike(__ArrayInstPtr(fdArray)->a_element[1])) {
  3379 		if (__isExternalAddressLike(__ArrayInstPtr(fdArray)->a_element[1])) {
  3380                     lpsiStartInfo.hStdOutput = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[1]);
  3380 		    lpsiStartInfo.hStdOutput = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[1]);
  3381                 } else {
  3381 		} else {
  3382                     lpsiStartInfo.hStdOutput = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[1]));
  3382 		    lpsiStartInfo.hStdOutput = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[1]));
  3383                 }
  3383 		}
  3384             }
  3384 	    }
  3385             if (__ArrayInstPtr(fdArray)->a_element[2] != nil) {
  3385 	    if (__ArrayInstPtr(fdArray)->a_element[2] != nil) {
  3386                 if (__isExternalAddressLike(__ArrayInstPtr(fdArray)->a_element[2])) {
  3386 		if (__isExternalAddressLike(__ArrayInstPtr(fdArray)->a_element[2])) {
  3387                     lpsiStartInfo.hStdError  = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[2]);
  3387 		    lpsiStartInfo.hStdError  = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[2]);
  3388                 } else {
  3388 		} else {
  3389                     lpsiStartInfo.hStdError = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[2]));
  3389 		    lpsiStartInfo.hStdError = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[2]));
  3390                 }
  3390 		}
  3391             }
  3391 	    }
  3392 #ifdef PROCESSDEBUGWIN32
  3392 #ifdef PROCESSDEBUGWIN32
  3393             console_fprintf(stderr, "stdin %x\n", lpsiStartInfo.hStdInput);
  3393 	    console_fprintf(stderr, "stdin %x\n", lpsiStartInfo.hStdInput);
  3394             console_fprintf(stderr, "stdout %x\n",lpsiStartInfo.hStdOutput);
  3394 	    console_fprintf(stderr, "stdout %x\n",lpsiStartInfo.hStdOutput);
  3395             console_fprintf(stderr, "stderr %x\n",lpsiStartInfo.hStdError);
  3395 	    console_fprintf(stderr, "stderr %x\n",lpsiStartInfo.hStdError);
  3396 #endif
  3396 #endif
  3397         } else {
  3397 	} else {
  3398             console_fprintf(stderr, "Win32OS [warning]: bad fd arg in createProcess\n");
  3398 	    console_fprintf(stderr, "Win32OS [warning]: bad fd arg in createProcess\n");
  3399         }
  3399 	}
  3400 
  3400 
  3401         if (doFork == true) {
  3401 	if (doFork == true) {
  3402 #ifdef PROCESSDEBUGWIN32
  3402 #ifdef PROCESSDEBUGWIN32
  3403             console_fprintf(stderr, "create process cmdPath:<%s> cmdLine:<%s> in <%s>\n", cmdPath, cmdLine, dir);
  3403 	    console_fprintf(stderr, "create process cmdPath:<%s> cmdLine:<%s> in <%s>\n", cmdPath, cmdLine, dir);
  3404 #endif
  3404 #endif
  3405             if (CreateProcess(  cmdPath,
  3405 	    if (CreateProcess(  cmdPath,
  3406                                 cmdLine,
  3406 				cmdLine,
  3407                                 &sa, NULL /* &sa */,           /* sec-attribs */
  3407 				&sa, NULL /* &sa */,           /* sec-attribs */
  3408                                 sa.bInheritHandle,  /* inherit handles */
  3408 				sa.bInheritHandle,  /* inherit handles */
  3409                                 fdwCreate,
  3409 				fdwCreate,
  3410                                 NULL,               /* env */
  3410 				NULL,               /* env */
  3411                                 dir,
  3411 				dir,
  3412                                 &lpsiStartInfo,
  3412 				&lpsiStartInfo,
  3413                                 &lppiProcInfo ))
  3413 				&lppiProcInfo ))
  3414             {
  3414 	    {
  3415                 CloseHandle(lppiProcInfo.hThread);
  3415 		CloseHandle(lppiProcInfo.hThread);
  3416 #ifdef PROCESSDEBUGWIN32
  3416 #ifdef PROCESSDEBUGWIN32
  3417                 console_fprintf(stderr, "created process hProcess=%x\n", lppiProcInfo.hProcess);
  3417 		console_fprintf(stderr, "created process hProcess=%x\n", lppiProcInfo.hProcess);
  3418 #endif
  3418 #endif
  3419                 __externalAddressVal(handle) = lppiProcInfo.hProcess;
  3419 		__externalAddressVal(handle) = lppiProcInfo.hProcess;
  3420                 ((struct __Win32OperatingSystem__Win32ProcessHandle_struct *)(handle))->pid = __mkSmallInteger(lppiProcInfo.dwProcessId);
  3420 		((struct __Win32OperatingSystem__Win32ProcessHandle_struct *)(handle))->pid = __mkSmallInteger(lppiProcInfo.dwProcessId);
  3421                 RETURN (handle);
  3421 		RETURN (handle);
  3422             }
  3422 	    }
  3423 #ifdef PROCESSDEBUGWIN32
  3423 #ifdef PROCESSDEBUGWIN32
  3424             console_fprintf(stderr, "created process error %d\n", GetLastError());
  3424 	    console_fprintf(stderr, "created process error %d\n", GetLastError());
  3425 #endif
  3425 #endif
  3426             RETURN (nil);
  3426 	    RETURN (nil);
  3427         } else {
  3427 	} else {
  3428             ; /* should never be called that way */
  3428 	    ; /* should never be called that way */
  3429         }
  3429 	}
  3430     }
  3430     }
  3431 %}.
  3431 %}.
  3432     "
  3432     "
  3433      path-argument not string
  3433      path-argument not string
  3434      or argArray not an array/nil
  3434      or argArray not an array/nil
  3455     |nullStream in out err shellAndArgs rslt auxFd|
  3455     |nullStream in out err shellAndArgs rslt auxFd|
  3456 
  3456 
  3457     aCommandString isNil ifTrue:[^ nil].
  3457     aCommandString isNil ifTrue:[^ nil].
  3458 
  3458 
  3459     (in := anExternalInStream) isNil ifTrue:[
  3459     (in := anExternalInStream) isNil ifTrue:[
  3460         nullStream := Filename nullDevice readWriteStream.
  3460 	nullStream := Filename nullDevice readWriteStream.
  3461         in := nullStream.
  3461 	in := nullStream.
  3462     ].
  3462     ].
  3463     (out := anExternalOutStream) isNil ifTrue:[
  3463     (out := anExternalOutStream) isNil ifTrue:[
  3464         nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream].
  3464 	nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream].
  3465         out := nullStream.
  3465 	out := nullStream.
  3466     ].
  3466     ].
  3467     (err := anExternalErrStream) isNil ifTrue:[
  3467     (err := anExternalErrStream) isNil ifTrue:[
  3468         err := out
  3468 	err := out
  3469     ].
  3469     ].
  3470     anAuxiliaryStream notNil ifTrue:[
  3470     anAuxiliaryStream notNil ifTrue:[
  3471         auxFd := anAuxiliaryStream fileDescriptor
  3471 	auxFd := anAuxiliaryStream fileDescriptor
  3472     ].
  3472     ].
  3473 
  3473 
  3474     shellAndArgs := self commandAndArgsForOSCommand:aCommandString.
  3474     shellAndArgs := self commandAndArgsForOSCommand:aCommandString.
  3475 
  3475 
  3476     rslt := self
  3476     rslt := self
  3477         exec:(shellAndArgs at:1)
  3477 	exec:(shellAndArgs at:1)
  3478         withArguments:(shellAndArgs at:2)
  3478 	withArguments:(shellAndArgs at:2)
  3479         environment:anEvironmentDictionary
  3479 	environment:anEvironmentDictionary
  3480         fileDescriptors:(Array with:in fileDescriptor
  3480 	fileDescriptors:(Array with:in fileDescriptor
  3481                                with:out fileDescriptor
  3481 			       with:out fileDescriptor
  3482                                with:err fileDescriptor
  3482 			       with:err fileDescriptor
  3483                                with:auxFd)
  3483 			       with:auxFd)
  3484         fork:true
  3484 	fork:true
  3485         newPgrp:true "/ false
  3485 	newPgrp:true "/ false
  3486         inDirectory:dir.
  3486 	inDirectory:dir.
  3487 
  3487 
  3488     nullStream notNil ifTrue:[
  3488     nullStream notNil ifTrue:[
  3489         nullStream close.
  3489 	nullStream close.
  3490     ].
  3490     ].
  3491     ^ rslt
  3491     ^ rslt
  3492 
  3492 
  3493     "blocking at current prio (i.e. only higher prio threads execute):
  3493     "blocking at current prio (i.e. only higher prio threads execute):
  3494 
  3494 
  3507      pid := OperatingSystem startProcess:'sleep 10; grep drw' inputFrom:in outputTo:out errorTo:err.
  3507      pid := OperatingSystem startProcess:'sleep 10; grep drw' inputFrom:in outputTo:out errorTo:err.
  3508 
  3508 
  3509      The following will no longer work. monitorPid has disappeared
  3509      The following will no longer work. monitorPid has disappeared
  3510 
  3510 
  3511      pid notNil ifTrue:[
  3511      pid notNil ifTrue:[
  3512          Processor monitorPid:pid action:[:OSstatus | sema signal ].
  3512 	 Processor monitorPid:pid action:[:OSstatus | sema signal ].
  3513      ].
  3513      ].
  3514      in close.
  3514      in close.
  3515      out close.
  3515      out close.
  3516      err close.
  3516      err close.
  3517      sema wait.
  3517      sema wait.
  3530     "low level close of a filedescriptor"
  3530     "low level close of a filedescriptor"
  3531 
  3531 
  3532 %{
  3532 %{
  3533     if (__isExternalAddressLike(anIntegerOrHandle) ) {
  3533     if (__isExternalAddressLike(anIntegerOrHandle) ) {
  3534        if( !CloseHandle( anIntegerOrHandle ) ) {
  3534        if( !CloseHandle( anIntegerOrHandle ) ) {
  3535            console_fprintf( stderr, "Win32OS [warning]: Could not close handle : %x\n", anIntegerOrHandle);
  3535 	   console_fprintf( stderr, "Win32OS [warning]: Could not close handle : %x\n", anIntegerOrHandle);
  3536        }
  3536        }
  3537        RETURN(self);
  3537        RETURN(self);
  3538     }
  3538     }
  3539     if (__isSmallInteger(anIntegerOrHandle)) {
  3539     if (__isSmallInteger(anIntegerOrHandle)) {
  3540         close(__intVal(anIntegerOrHandle));
  3540 	close(__intVal(anIntegerOrHandle));
  3541         RETURN(self);
  3541 	RETURN(self);
  3542     }
  3542     }
  3543 %}.
  3543 %}.
  3544     ^ self primitiveFailed.
  3544     ^ self primitiveFailed.
  3545 !
  3545 !
  3546 
  3546 
  3554 
  3554 
  3555     (self isDirectory:aPathName) ifTrue:[^ true].
  3555     (self isDirectory:aPathName) ifTrue:[^ true].
  3556 
  3556 
  3557 %{
  3557 %{
  3558     if (__isString(aPathName)) {
  3558     if (__isString(aPathName)) {
  3559         int ret;
  3559 	int ret;
  3560         SECURITY_ATTRIBUTES sa;
  3560 	SECURITY_ATTRIBUTES sa;
  3561 
  3561 
  3562         sa.nLength = sizeof( sa );
  3562 	sa.nLength = sizeof( sa );
  3563         sa.lpSecurityDescriptor = NULL;
  3563 	sa.lpSecurityDescriptor = NULL;
  3564         sa.bInheritHandle = TRUE;
  3564 	sa.bInheritHandle = TRUE;
  3565 
  3565 
  3566         ret = CreateDirectory(__stringVal(aPathName), &sa);
  3566 	ret = CreateDirectory(__stringVal(aPathName), &sa);
  3567         if (ret != TRUE) {
  3567 	if (ret != TRUE) {
  3568             __threadErrno = __WIN32_ERR(GetLastError());
  3568 	    __threadErrno = __WIN32_ERR(GetLastError());
  3569             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  3569 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  3570             RETURN (false);
  3570 	    RETURN (false);
  3571         }
  3571 	}
  3572         RETURN (true);
  3572 	RETURN (true);
  3573     }
  3573     }
  3574 %}.
  3574 %}.
  3575     self primitiveFailed
  3575     self primitiveFailed
  3576 
  3576 
  3577     "
  3577     "
  3610     WIN32_FIND_DATA wfd;
  3610     WIN32_FIND_DATA wfd;
  3611     char szGotPath[MAX_PATH];
  3611     char szGotPath[MAX_PATH];
  3612     IPersistFile *ppf;
  3612     IPersistFile *ppf;
  3613 
  3613 
  3614     if (! __isString(aPathName)) {
  3614     if (! __isString(aPathName)) {
  3615         console_fprintf(stderr, "invalid argument\n");
  3615 	console_fprintf(stderr, "invalid argument\n");
  3616         goto error;
  3616 	goto error;
  3617     }
  3617     }
  3618 
  3618 
  3619     hres = CoInitialize(NULL);
  3619     hres = CoInitialize(NULL);
  3620     if (! SUCCEEDED(hres)) {
  3620     if (! SUCCEEDED(hres)) {
  3621         console_fprintf(stderr, "Could not open the COM library\n");
  3621 	console_fprintf(stderr, "Could not open the COM library\n");
  3622         goto error;
  3622 	goto error;
  3623     }
  3623     }
  3624 
  3624 
  3625     hres = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
  3625     hres = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
  3626                             &IID_IShellLink, (LPVOID *)&psl);
  3626 			    &IID_IShellLink, (LPVOID *)&psl);
  3627     if (SUCCEEDED(hres)) {
  3627     if (SUCCEEDED(hres)) {
  3628         hres = psl->lpVtbl->QueryInterface(psl, &IID_IPersistFile, &ppf);
  3628 	hres = psl->lpVtbl->QueryInterface(psl, &IID_IPersistFile, &ppf);
  3629 
  3629 
  3630         if (SUCCEEDED(hres)) {
  3630 	if (SUCCEEDED(hres)) {
  3631             WORD wsz[MAX_PATH];
  3631 	    WORD wsz[MAX_PATH];
  3632 
  3632 
  3633             MultiByteToWideChar(CP_ACP, 0, __stringVal(aPathName), -1, wsz, MAX_PATH);
  3633 	    MultiByteToWideChar(CP_ACP, 0, __stringVal(aPathName), -1, wsz, MAX_PATH);
  3634 
  3634 
  3635             hres = ppf->lpVtbl->Load(ppf, wsz, STGM_READ);
  3635 	    hres = ppf->lpVtbl->Load(ppf, wsz, STGM_READ);
  3636             if (SUCCEEDED(hres)) {
  3636 	    if (SUCCEEDED(hres)) {
  3637 #if 0
  3637 #if 0
  3638                 hres = psl->lpVtbl->Resolve(psl, 0, SLR_ANY_MATCH|SLR_NO_UI);
  3638 		hres = psl->lpVtbl->Resolve(psl, 0, SLR_ANY_MATCH|SLR_NO_UI);
  3639 #endif
  3639 #endif
  3640                 if (SUCCEEDED(hres)) {
  3640 		if (SUCCEEDED(hres)) {
  3641                     hres = psl->lpVtbl->GetPath(psl, szGotPath, MAX_PATH,
  3641 		    hres = psl->lpVtbl->GetPath(psl, szGotPath, MAX_PATH,
  3642                                 (WIN32_FIND_DATA *)&wfd, 0 /* SLGP_SHORTPATH */ );
  3642 				(WIN32_FIND_DATA *)&wfd, 0 /* SLGP_SHORTPATH */ );
  3643                     if (!SUCCEEDED(hres)) {
  3643 		    if (!SUCCEEDED(hres)) {
  3644                         console_fprintf(stderr, "GetPath failed!\n");
  3644 			console_fprintf(stderr, "GetPath failed!\n");
  3645                     } else {
  3645 		    } else {
  3646 #if 0
  3646 #if 0
  3647                         console_printf("This points to %s\n", wfd.cFileName); console_fflush(stdout);
  3647 			console_printf("This points to %s\n", wfd.cFileName); console_fflush(stdout);
  3648                         console_printf("Path is %s\n", szGotPath); console_fflush(stdout);
  3648 			console_printf("Path is %s\n", szGotPath); console_fflush(stdout);
  3649                         if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
  3649 			if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
  3650                             console_printf("This is a directory\n"); console_fflush(stdout);
  3650 			    console_printf("This is a directory\n"); console_fflush(stdout);
  3651                         }
  3651 			}
  3652 #endif
  3652 #endif
  3653                         resolvedPath = __MKSTRING(szGotPath);
  3653 			resolvedPath = __MKSTRING(szGotPath);
  3654 #if 0
  3654 #if 0
  3655                         hres = psl->lpVtbl->GetWorkingDirectory(psl, szGotPath, MAX_PATH);
  3655 			hres = psl->lpVtbl->GetWorkingDirectory(psl, szGotPath, MAX_PATH);
  3656                         if (!SUCCEEDED(hres)) {
  3656 			if (!SUCCEEDED(hres)) {
  3657                             console_fprintf(stderr, "GetWorkingDirectory failed!\n");
  3657 			    console_fprintf(stderr, "GetWorkingDirectory failed!\n");
  3658                         } else {
  3658 			} else {
  3659                             console_printf("In Directory %s\n", szGotPath);
  3659 			    console_printf("In Directory %s\n", szGotPath);
  3660                         }
  3660 			}
  3661 #endif
  3661 #endif
  3662                     }
  3662 		    }
  3663                 }
  3663 		}
  3664             } else {
  3664 	    } else {
  3665                console_fprintf(stderr, "IPersistFile Load Error\n");
  3665 	       console_fprintf(stderr, "IPersistFile Load Error\n");
  3666             }
  3666 	    }
  3667             ppf->lpVtbl->Release(ppf);
  3667 	    ppf->lpVtbl->Release(ppf);
  3668         } else {
  3668 	} else {
  3669             console_fprintf(stderr, "QueryInterface Error\n");
  3669 	    console_fprintf(stderr, "QueryInterface Error\n");
  3670         }
  3670 	}
  3671         psl->lpVtbl->Release(psl);
  3671 	psl->lpVtbl->Release(psl);
  3672     } else {
  3672     } else {
  3673         console_fprintf(stderr, "CoCreateInstance Error - hres = %08x\n", hres);
  3673 	console_fprintf(stderr, "CoCreateInstance Error - hres = %08x\n", hres);
  3674     }
  3674     }
  3675 error: ;
  3675 error: ;
  3676 %}.
  3676 %}.
  3677     resolvedPath notNil ifTrue:[^ resolvedPath ].
  3677     resolvedPath notNil ifTrue:[^ resolvedPath ].
  3678 
  3678 
  3691 linkFile:oldPath to:newPath
  3691 linkFile:oldPath to:newPath
  3692     "link the file 'oldPath' to 'newPath'. The link will be a hard link.
  3692     "link the file 'oldPath' to 'newPath'. The link will be a hard link.
  3693      Return true if successful, false if not."
  3693      Return true if successful, false if not."
  3694 
  3694 
  3695     (oldPath isString not or:[newPath isString not]) ifTrue:[
  3695     (oldPath isString not or:[newPath isString not]) ifTrue:[
  3696         "/
  3696 	"/
  3697         "/ bad argument(s) given
  3697 	"/ bad argument(s) given
  3698         "/
  3698 	"/
  3699         ^ self primitiveFailed
  3699 	^ self primitiveFailed
  3700     ].
  3700     ].
  3701 
  3701 
  3702     "/
  3702     "/
  3703     "/ this OperatingSystem does not support links
  3703     "/ this OperatingSystem does not support links
  3704     "/
  3704     "/
  3726     int numAttrib = __arraySize(attributeSpec);
  3726     int numAttrib = __arraySize(attributeSpec);
  3727     int i;
  3727     int i;
  3728     DWORD access, share, create, attr;
  3728     DWORD access, share, create, attr;
  3729 
  3729 
  3730     if (! __isString(pathName)) {
  3730     if (! __isString(pathName)) {
  3731         fileHandle = nil;
  3731 	fileHandle = nil;
  3732         argumentError = @symbol(badPathName);
  3732 	argumentError = @symbol(badPathName);
  3733         goto badArgument;
  3733 	goto badArgument;
  3734     }
  3734     }
  3735     if (! __isArrayLike(attributeSpec)) {
  3735     if (! __isArrayLike(attributeSpec)) {
  3736         fileHandle = nil;
  3736 	fileHandle = nil;
  3737         argumentError = @symbol(badAttributeSpec);
  3737 	argumentError = @symbol(badAttributeSpec);
  3738         goto badArgument;
  3738 	goto badArgument;
  3739     }
  3739     }
  3740 
  3740 
  3741     name = __stringVal(pathName);
  3741     name = __stringVal(pathName);
  3742 
  3742 
  3743     share = 0;
  3743     share = 0;
  3744     access = 0;
  3744     access = 0;
  3745     create = 0;
  3745     create = 0;
  3746     attr = 0;
  3746     attr = 0;
  3747 
  3747 
  3748     for (i=0; i<numAttrib;i++) {
  3748     for (i=0; i<numAttrib;i++) {
  3749         OBJ attrSym = ap[i];
  3749 	OBJ attrSym = ap[i];
  3750 
  3750 
  3751         if (attrSym == @symbol(FILE_SHARE_READ)) {
  3751 	if (attrSym == @symbol(FILE_SHARE_READ)) {
  3752             share |= FILE_SHARE_READ;
  3752 	    share |= FILE_SHARE_READ;
  3753         } else if (attrSym == @symbol(FILE_SHARE_WRITE)) {
  3753 	} else if (attrSym == @symbol(FILE_SHARE_WRITE)) {
  3754             share |= FILE_SHARE_WRITE;
  3754 	    share |= FILE_SHARE_WRITE;
  3755 
  3755 
  3756         } else if (attrSym == @symbol(GENERIC_READ)) {
  3756 	} else if (attrSym == @symbol(GENERIC_READ)) {
  3757             access |= GENERIC_READ;
  3757 	    access |= GENERIC_READ;
  3758         } else if (attrSym == @symbol(GENERIC_WRITE)) {
  3758 	} else if (attrSym == @symbol(GENERIC_WRITE)) {
  3759             access |= GENERIC_WRITE;
  3759 	    access |= GENERIC_WRITE;
  3760 
  3760 
  3761         } else if (attrSym == @symbol(CREATE_NEW)) {
  3761 	} else if (attrSym == @symbol(CREATE_NEW)) {
  3762             create |= CREATE_NEW;
  3762 	    create |= CREATE_NEW;
  3763         } else if (attrSym == @symbol(CREATE_ALWAYS)) {
  3763 	} else if (attrSym == @symbol(CREATE_ALWAYS)) {
  3764             create |= CREATE_ALWAYS;
  3764 	    create |= CREATE_ALWAYS;
  3765         } else if (attrSym == @symbol(OPEN_EXISTING)) {
  3765 	} else if (attrSym == @symbol(OPEN_EXISTING)) {
  3766             create |= OPEN_EXISTING;
  3766 	    create |= OPEN_EXISTING;
  3767         } else if (attrSym == @symbol(OPEN_ALWAYS)) {
  3767 	} else if (attrSym == @symbol(OPEN_ALWAYS)) {
  3768             create |= OPEN_ALWAYS;
  3768 	    create |= OPEN_ALWAYS;
  3769         } else if (attrSym == @symbol(TRUNCATE_EXISTING)) {
  3769 	} else if (attrSym == @symbol(TRUNCATE_EXISTING)) {
  3770             create |= TRUNCATE_EXISTING;
  3770 	    create |= TRUNCATE_EXISTING;
  3771 
  3771 
  3772         } else if (attrSym == @symbol(FILE_ATTRIBUTE_HIDDEN)) {
  3772 	} else if (attrSym == @symbol(FILE_ATTRIBUTE_HIDDEN)) {
  3773             attr |= FILE_ATTRIBUTE_HIDDEN;
  3773 	    attr |= FILE_ATTRIBUTE_HIDDEN;
  3774         } else if (attrSym == @symbol(FILE_ATTRIBUTE_READONLY)) {
  3774 	} else if (attrSym == @symbol(FILE_ATTRIBUTE_READONLY)) {
  3775             attr |= FILE_ATTRIBUTE_READONLY;
  3775 	    attr |= FILE_ATTRIBUTE_READONLY;
  3776         } else if (attrSym == @symbol(FILE_ATTRIBUTE_READONLY)) {
  3776 	} else if (attrSym == @symbol(FILE_ATTRIBUTE_READONLY)) {
  3777             attr |= FILE_ATTRIBUTE_READONLY;
  3777 	    attr |= FILE_ATTRIBUTE_READONLY;
  3778         } else if (attrSym == @symbol(FILE_FLAG_WRITE_THROUGH)) {
  3778 	} else if (attrSym == @symbol(FILE_FLAG_WRITE_THROUGH)) {
  3779             attr |= FILE_FLAG_WRITE_THROUGH;
  3779 	    attr |= FILE_FLAG_WRITE_THROUGH;
  3780         } else if (attrSym == @symbol(FILE_FLAG_SEQUENTIAL_SCAN)) {
  3780 	} else if (attrSym == @symbol(FILE_FLAG_SEQUENTIAL_SCAN)) {
  3781             attr |= FILE_FLAG_SEQUENTIAL_SCAN;
  3781 	    attr |= FILE_FLAG_SEQUENTIAL_SCAN;
  3782         } else if (attrSym == @symbol(FILE_FLAG_DELETE_ON_CLOSE)) {
  3782 	} else if (attrSym == @symbol(FILE_FLAG_DELETE_ON_CLOSE)) {
  3783             attr |= FILE_FLAG_DELETE_ON_CLOSE;
  3783 	    attr |= FILE_FLAG_DELETE_ON_CLOSE;
  3784         } else {
  3784 	} else {
  3785             console_fprintf(stderr, "Win32OS [warning]: unsupported open mode\n");
  3785 	    console_fprintf(stderr, "Win32OS [warning]: unsupported open mode\n");
  3786         }
  3786 	}
  3787     }
  3787     }
  3788     if (create == 0) {
  3788     if (create == 0) {
  3789         fileHandle = nil;
  3789 	fileHandle = nil;
  3790         argumentError = @symbol(missingCreateMode);
  3790 	argumentError = @symbol(missingCreateMode);
  3791         goto badArgument;
  3791 	goto badArgument;
  3792     }
  3792     }
  3793 #ifdef PROCESSDEBUGWIN32
  3793 #ifdef PROCESSDEBUGWIN32
  3794     console_fprintf(stderr, "name:<%s> access:%x share:%x create:%x attr:%x\n",
  3794     console_fprintf(stderr, "name:<%s> access:%x share:%x create:%x attr:%x\n",
  3795                 name, access, share, create, attr);
  3795 		name, access, share, create, attr);
  3796 #endif
  3796 #endif
  3797     h = CreateFile(name, access, share, 0 /* sa */, create, attr, 0 /* hTempl */);
  3797     h = CreateFile(name, access, share, 0 /* sa */, create, attr, 0 /* hTempl */);
  3798     if (h != INVALID_HANDLE_VALUE) {
  3798     if (h != INVALID_HANDLE_VALUE) {
  3799         __externalAddressVal(fileHandle) = (void *)h;
  3799 	__externalAddressVal(fileHandle) = (void *)h;
  3800     } else {
  3800     } else {
  3801         fileHandle = nil;
  3801 	fileHandle = nil;
  3802         errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
  3802 	errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
  3803     }
  3803     }
  3804 
  3804 
  3805 badArgument: ;
  3805 badArgument: ;
  3806 %}.
  3806 %}.
  3807     fileHandle notNil ifTrue:[
  3807     fileHandle notNil ifTrue:[
  3808         fileHandle registerForFinalization.
  3808 	fileHandle registerForFinalization.
  3809         ^ fileHandle.
  3809 	^ fileHandle.
  3810     ].
  3810     ].
  3811     errorNumber isNil ifTrue:[
  3811     errorNumber isNil ifTrue:[
  3812         self error:'invalid argument(s): ', argumentError.
  3812 	self error:'invalid argument(s): ', argumentError.
  3813     ] ifFalse:[
  3813     ] ifFalse:[
  3814         (self errorHolderForNumber:errorNumber) reportError
  3814 	(self errorHolderForNumber:errorNumber) reportError
  3815     ].
  3815     ].
  3816 !
  3816 !
  3817 
  3817 
  3818 openFileForAppend:pathName
  3818 openFileForAppend:pathName
  3819     "noone sends this message yet"
  3819     "noone sends this message yet"
  3857 %{
  3857 %{
  3858     int ret;
  3858     int ret;
  3859 
  3859 
  3860     if (__isString(fullPathName)) {
  3860     if (__isString(fullPathName)) {
  3861 #ifdef DO_WRAP_CALLS
  3861 #ifdef DO_WRAP_CALLS
  3862         {
  3862 	{
  3863             char _aPathName[MAXPATHLEN];
  3863 	    char _aPathName[MAXPATHLEN];
  3864 
  3864 
  3865             strncpy(_aPathName, __stringVal(fullPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  3865 	    strncpy(_aPathName, __stringVal(fullPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  3866             do {
  3866 	    do {
  3867                 __threadErrno = 0;
  3867 		__threadErrno = 0;
  3868                 ret = STX_API_CALL1( "RemoveDirectory", RemoveDirectory, _aPathName);
  3868 		ret = STX_API_CALL1( "RemoveDirectory", RemoveDirectory, _aPathName);
  3869             } while ((ret < 0) && (__threadErrno == EINTR));
  3869 	    } while ((ret < 0) && (__threadErrno == EINTR));
  3870         }
  3870 	}
  3871 #else
  3871 #else
  3872         ret = RemoveDirectory((char *)__stringVal(fullPathName));
  3872 	ret = RemoveDirectory((char *)__stringVal(fullPathName));
  3873         __threadErrno = __WIN32_ERR(GetLastError());
  3873 	__threadErrno = __WIN32_ERR(GetLastError());
  3874 #endif
  3874 #endif
  3875         if (ret != TRUE) {
  3875 	if (ret != TRUE) {
  3876             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  3876 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  3877             RETURN (false);
  3877 	    RETURN (false);
  3878         }
  3878 	}
  3879         RETURN (true);
  3879 	RETURN (true);
  3880     }
  3880     }
  3881 %}.
  3881 %}.
  3882     "/
  3882     "/
  3883     "/ either not a string argument,
  3883     "/ either not a string argument,
  3884     "/ or not supported by OS
  3884     "/ or not supported by OS
  3898 %{
  3898 %{
  3899     int ret;
  3899     int ret;
  3900 
  3900 
  3901     if (__isString(fullPathName)) {
  3901     if (__isString(fullPathName)) {
  3902 #ifdef DO_WRAP_CALLS
  3902 #ifdef DO_WRAP_CALLS
  3903         {
  3903 	{
  3904             char _aPathName[MAXPATHLEN];
  3904 	    char _aPathName[MAXPATHLEN];
  3905 
  3905 
  3906             strncpy(_aPathName, __stringVal(fullPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  3906 	    strncpy(_aPathName, __stringVal(fullPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  3907             do {
  3907 	    do {
  3908                 __threadErrno = 0;
  3908 		__threadErrno = 0;
  3909                 ret = STX_API_CALL1( "DeleteFile", DeleteFile, _aPathName);
  3909 		ret = STX_API_CALL1( "DeleteFile", DeleteFile, _aPathName);
  3910             } while ((ret < 0) && (__threadErrno == EINTR));
  3910 	    } while ((ret < 0) && (__threadErrno == EINTR));
  3911         }
  3911 	}
  3912 #else
  3912 #else
  3913         ret = DeleteFile((char *)__stringVal(fullPathName));
  3913 	ret = DeleteFile((char *)__stringVal(fullPathName));
  3914         __threadErrno = __WIN32_ERR(GetLastError());
  3914 	__threadErrno = __WIN32_ERR(GetLastError());
  3915 #endif
  3915 #endif
  3916         if (ret != TRUE) {
  3916 	if (ret != TRUE) {
  3917             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  3917 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  3918             RETURN (false);
  3918 	    RETURN (false);
  3919         }
  3919 	}
  3920         RETURN (true);
  3920 	RETURN (true);
  3921     }
  3921     }
  3922 %}.
  3922 %}.
  3923     ^ self primitiveFailed
  3923     ^ self primitiveFailed
  3924 !
  3924 !
  3925 
  3925 
  3934 %{
  3934 %{
  3935     int ret, eno;
  3935     int ret, eno;
  3936 
  3936 
  3937     if (__isString(oldPath) && __isString(newPath)) {
  3937     if (__isString(oldPath) && __isString(newPath)) {
  3938 #ifdef DO_WRAP_CALLS
  3938 #ifdef DO_WRAP_CALLS
  3939         char _oldPath[MAXPATHLEN], _newPath[MAXPATHLEN];
  3939 	char _oldPath[MAXPATHLEN], _newPath[MAXPATHLEN];
  3940 
  3940 
  3941         strncpy(_oldPath, __stringVal(oldPath), MAXPATHLEN-1); _oldPath[MAXPATHLEN-1] = '\0';
  3941 	strncpy(_oldPath, __stringVal(oldPath), MAXPATHLEN-1); _oldPath[MAXPATHLEN-1] = '\0';
  3942         strncpy(_newPath, __stringVal(newPath), MAXPATHLEN-1); _newPath[MAXPATHLEN-1] = '\0';
  3942 	strncpy(_newPath, __stringVal(newPath), MAXPATHLEN-1); _newPath[MAXPATHLEN-1] = '\0';
  3943 
  3943 
  3944         do {
  3944 	do {
  3945             __threadErrno = 0;
  3945 	    __threadErrno = 0;
  3946             ret = STX_C_CALL2( "rename", rename, _oldPath, _newPath);
  3946 	    ret = STX_C_CALL2( "rename", rename, _oldPath, _newPath);
  3947         } while ((ret < 0) && (__threadErrno == EINTR));
  3947 	} while ((ret < 0) && (__threadErrno == EINTR));
  3948 #else
  3948 #else
  3949         __BEGIN_INTERRUPTABLE__
  3949 	__BEGIN_INTERRUPTABLE__
  3950         do {
  3950 	do {
  3951             __threadErrno = 0;
  3951 	    __threadErrno = 0;
  3952             ret = rename((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
  3952 	    ret = rename((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
  3953         } while ((ret < 0) && (__threadErrno == EINTR));
  3953 	} while ((ret < 0) && (__threadErrno == EINTR));
  3954         __END_INTERRUPTABLE__
  3954 	__END_INTERRUPTABLE__
  3955 
  3955 
  3956         if (ret < 0) {
  3956 	if (ret < 0) {
  3957             __threadErrno = __WIN32_ERR(GetLastError());
  3957 	    __threadErrno = __WIN32_ERR(GetLastError());
  3958         }
  3958 	}
  3959 #endif
  3959 #endif
  3960         if (ret < 0) {
  3960 	if (ret < 0) {
  3961             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  3961 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  3962             RETURN (false);
  3962 	    RETURN (false);
  3963         }
  3963 	}
  3964         RETURN (true);
  3964 	RETURN (true);
  3965     }
  3965     }
  3966 %}.
  3966 %}.
  3967     ^ self primitiveFailed
  3967     ^ self primitiveFailed
  3968 
  3968 
  3969     "
  3969     "
  4018 #   ifndef S_IXOTH
  4018 #   ifndef S_IXOTH
  4019 #    define S_IXOTH 0001
  4019 #    define S_IXOTH 0001
  4020 #   endif
  4020 #   endif
  4021 
  4021 
  4022     if (aSymbol == @symbol(readUser)) {
  4022     if (aSymbol == @symbol(readUser)) {
  4023         RETURN ( __mkSmallInteger(S_IRUSR) );
  4023 	RETURN ( __mkSmallInteger(S_IRUSR) );
  4024     }
  4024     }
  4025     if (aSymbol == @symbol(writeUser)) {
  4025     if (aSymbol == @symbol(writeUser)) {
  4026         RETURN ( __mkSmallInteger(S_IWUSR) );
  4026 	RETURN ( __mkSmallInteger(S_IWUSR) );
  4027     }
  4027     }
  4028     if (aSymbol == @symbol(executeUser)) {
  4028     if (aSymbol == @symbol(executeUser)) {
  4029         RETURN ( __mkSmallInteger(S_IXUSR) );
  4029 	RETURN ( __mkSmallInteger(S_IXUSR) );
  4030     }
  4030     }
  4031     if (aSymbol == @symbol(readGroup)) {
  4031     if (aSymbol == @symbol(readGroup)) {
  4032         RETURN ( __mkSmallInteger(S_IRGRP) );
  4032 	RETURN ( __mkSmallInteger(S_IRGRP) );
  4033     }
  4033     }
  4034     if (aSymbol == @symbol(writeGroup)) {
  4034     if (aSymbol == @symbol(writeGroup)) {
  4035         RETURN ( __mkSmallInteger(S_IWGRP) );
  4035 	RETURN ( __mkSmallInteger(S_IWGRP) );
  4036     }
  4036     }
  4037     if (aSymbol == @symbol(executeGroup)) {
  4037     if (aSymbol == @symbol(executeGroup)) {
  4038         RETURN ( __mkSmallInteger(S_IXGRP) );
  4038 	RETURN ( __mkSmallInteger(S_IXGRP) );
  4039     }
  4039     }
  4040     if (aSymbol == @symbol(readOthers)) {
  4040     if (aSymbol == @symbol(readOthers)) {
  4041         RETURN ( __mkSmallInteger(S_IROTH) );
  4041 	RETURN ( __mkSmallInteger(S_IROTH) );
  4042     }
  4042     }
  4043     if (aSymbol == @symbol(writeOthers)) {
  4043     if (aSymbol == @symbol(writeOthers)) {
  4044         RETURN ( __mkSmallInteger(S_IWOTH) );
  4044 	RETURN ( __mkSmallInteger(S_IWOTH) );
  4045     }
  4045     }
  4046     if (aSymbol == @symbol(executeOthers)) {
  4046     if (aSymbol == @symbol(executeOthers)) {
  4047         RETURN ( __mkSmallInteger(S_IXOTH) );
  4047 	RETURN ( __mkSmallInteger(S_IXOTH) );
  4048     }
  4048     }
  4049 %}.
  4049 %}.
  4050     ^ self primitiveFailed
  4050     ^ self primitiveFailed
  4051 
  4051 
  4052     "
  4052     "
  4060      Notice that the returned number is OS dependent - use the
  4060      Notice that the returned number is OS dependent - use the
  4061      modeMasks as returned by OperatingSystem>>accessMaskFor:"
  4061      modeMasks as returned by OperatingSystem>>accessMaskFor:"
  4062 
  4062 
  4063     "
  4063     "
  4064      this could have been implemented as:
  4064      this could have been implemented as:
  4065         (self infoOf:aPathName) at:#mode
  4065 	(self infoOf:aPathName) at:#mode
  4066      but for huge directory searches the code below is faster
  4066      but for huge directory searches the code below is faster
  4067     "
  4067     "
  4068 
  4068 
  4069 %{
  4069 %{
  4070     struct stat buf;
  4070     struct stat buf;
  4071     int ret;
  4071     int ret;
  4072 
  4072 
  4073     if (__isString(aPathName)) {
  4073     if (__isString(aPathName)) {
  4074 #ifdef DO_WRAP_CALLS
  4074 #ifdef DO_WRAP_CALLS
  4075         char _aPathName[MAXPATHLEN];
  4075 	char _aPathName[MAXPATHLEN];
  4076 
  4076 
  4077         strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4077 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4078 
  4078 
  4079         do {
  4079 	do {
  4080             __threadErrno = 0;
  4080 	    __threadErrno = 0;
  4081             ret = STX_C_CALL2( "stat", stat, _aPathName, &buf);
  4081 	    ret = STX_C_CALL2( "stat", stat, _aPathName, &buf);
  4082         } while ((ret < 0) && (__threadErrno == EINTR));
  4082 	} while ((ret < 0) && (__threadErrno == EINTR));
  4083 #else
  4083 #else
  4084         __BEGIN_INTERRUPTABLE__
  4084 	__BEGIN_INTERRUPTABLE__
  4085         do {
  4085 	do {
  4086             __threadErrno = 0;
  4086 	    __threadErrno = 0;
  4087             ret = stat( (char *)__stringVal(aPathName), &buf);
  4087 	    ret = stat( (char *)__stringVal(aPathName), &buf);
  4088         } while ((ret < 0) && (__threadErrno == EINTR));
  4088 	} while ((ret < 0) && (__threadErrno == EINTR));
  4089         __END_INTERRUPTABLE__
  4089 	__END_INTERRUPTABLE__
  4090         if (ret < 0) {
  4090 	if (ret < 0) {
  4091             __threadErrno = __WIN32_ERR(GetLastError());
  4091 	    __threadErrno = __WIN32_ERR(GetLastError());
  4092         }
  4092 	}
  4093 #endif
  4093 #endif
  4094 
  4094 
  4095         if (ret < 0) {
  4095 	if (ret < 0) {
  4096             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4096 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4097             RETURN ( nil );
  4097 	    RETURN ( nil );
  4098         }
  4098 	}
  4099         RETURN ( __mkSmallInteger(buf.st_mode & 0777) );
  4099 	RETURN ( __mkSmallInteger(buf.st_mode & 0777) );
  4100     }
  4100     }
  4101 %}.
  4101 %}.
  4102    ^ self primitiveFailed
  4102    ^ self primitiveFailed
  4103 
  4103 
  4104    "
  4104    "
  4117 %{
  4117 %{
  4118     int ret;
  4118     int ret;
  4119 
  4119 
  4120     if (__isString(aPathName) && __isSmallInteger(modeBits)) {
  4120     if (__isString(aPathName) && __isSmallInteger(modeBits)) {
  4121 #ifdef DO_WRAP_CALLS
  4121 #ifdef DO_WRAP_CALLS
  4122         int chmod();
  4122 	int chmod();
  4123         char _aPathName[MAXPATHLEN];
  4123 	char _aPathName[MAXPATHLEN];
  4124 
  4124 
  4125         strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4125 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4126         do {
  4126 	do {
  4127             __threadErrno = 0;
  4127 	    __threadErrno = 0;
  4128             ret = STX_C_CALL2( "chmod", chmod, _aPathName, __intVal(modeBits));
  4128 	    ret = STX_C_CALL2( "chmod", chmod, _aPathName, __intVal(modeBits));
  4129         } while ((ret < 0) && (__threadErrno == EINTR));
  4129 	} while ((ret < 0) && (__threadErrno == EINTR));
  4130 #else
  4130 #else
  4131         __BEGIN_INTERRUPTABLE__
  4131 	__BEGIN_INTERRUPTABLE__
  4132         do {
  4132 	do {
  4133             __threadErrno = 0;
  4133 	    __threadErrno = 0;
  4134             ret = chmod((char *)__stringVal(aPathName), __intVal(modeBits));
  4134 	    ret = chmod((char *)__stringVal(aPathName), __intVal(modeBits));
  4135         } while ((ret < 0) && (__threadErrno == EINTR));
  4135 	} while ((ret < 0) && (__threadErrno == EINTR));
  4136         __END_INTERRUPTABLE__
  4136 	__END_INTERRUPTABLE__
  4137         if (ret < 0) {
  4137 	if (ret < 0) {
  4138             __threadErrno = __WIN32_ERR(GetLastError());
  4138 	    __threadErrno = __WIN32_ERR(GetLastError());
  4139         }
  4139 	}
  4140 #endif
  4140 #endif
  4141         if (ret < 0) {
  4141 	if (ret < 0) {
  4142             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4142 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4143             RETURN ( false );
  4143 	    RETURN ( false );
  4144         }
  4144 	}
  4145         RETURN ( true );
  4145 	RETURN ( true );
  4146     }
  4146     }
  4147 %}.
  4147 %}.
  4148     ^ self primitiveFailed
  4148     ^ self primitiveFailed
  4149 
  4149 
  4150    "
  4150    "
  4170      if realPath and popen failed."
  4170      if realPath and popen failed."
  4171 
  4171 
  4172     |names n "{ Class: SmallInteger }" |
  4172     |names n "{ Class: SmallInteger }" |
  4173 
  4173 
  4174     names := pathName
  4174     names := pathName
  4175                 asCollectionOfSubstringsSeparatedBy:self fileSeparator.
  4175 		asCollectionOfSubstringsSeparatedBy:self fileSeparator.
  4176     names := names asOrderedCollection.
  4176     names := names asOrderedCollection.
  4177     "
  4177     "
  4178      cut off initial double-slashes
  4178      cut off initial double-slashes
  4179     "
  4179     "
  4180     [names startsWith:#('' '')] whileTrue:[
  4180     [names startsWith:#('' '')] whileTrue:[
  4181         names removeFirst.
  4181 	names removeFirst.
  4182     ].
  4182     ].
  4183     "
  4183     "
  4184      cut off double-slashes at end
  4184      cut off double-slashes at end
  4185     "
  4185     "
  4186     [names endsWith:#('')] whileTrue:[
  4186     [names endsWith:#('')] whileTrue:[
  4187         names removeLast.
  4187 	names removeLast.
  4188     ].
  4188     ].
  4189     "
  4189     "
  4190      cut off current-dir at beginning
  4190      cut off current-dir at beginning
  4191     "
  4191     "
  4192     n := names size.
  4192     n := names size.
  4193     [(n >= 2) and:[names startsWith:#('.')]] whileTrue:[
  4193     [(n >= 2) and:[names startsWith:#('.')]] whileTrue:[
  4194         names removeFirst.
  4194 	names removeFirst.
  4195         n := n - 1.
  4195 	n := n - 1.
  4196     ].
  4196     ].
  4197 
  4197 
  4198     "
  4198     "
  4199      cut off parent-dirs at end
  4199      cut off parent-dirs at end
  4200     "
  4200     "
  4201     [(n > 2)
  4201     [(n > 2)
  4202      and:[(names endsWith:#('..'))
  4202      and:[(names endsWith:#('..'))
  4203      and:[((names at:(n - 1)) startsWith:'.') not ]]] whileTrue:[
  4203      and:[((names at:(n - 1)) startsWith:'.') not ]]] whileTrue:[
  4204         names removeLast; removeLast.
  4204 	names removeLast; removeLast.
  4205         n := n - 2.
  4205 	n := n - 2.
  4206     ].
  4206     ].
  4207 
  4207 
  4208     ^ names asStringWith:self fileSeparator
  4208     ^ names asStringWith:self fileSeparator
  4209                     from:1
  4209 		    from:1
  4210                     to:n
  4210 		    to:n
  4211                     compressTabs:false final:nil
  4211 		    compressTabs:false final:nil
  4212 
  4212 
  4213     "
  4213     "
  4214      OperatingSystem compressPath:'.\..'
  4214      OperatingSystem compressPath:'.\..'
  4215      OperatingSystem compressPath:'\foo\bar\baz\..'
  4215      OperatingSystem compressPath:'\foo\bar\baz\..'
  4216      OperatingSystem compressPath:'foo\bar\baz\..'
  4216      OperatingSystem compressPath:'foo\bar\baz\..'
  4231     ^ $\
  4231     ^ $\
  4232 !
  4232 !
  4233 
  4233 
  4234 getDiskInfoOf:volumeNameArg
  4234 getDiskInfoOf:volumeNameArg
  4235     "returns a dictionary filled with any of:
  4235     "returns a dictionary filled with any of:
  4236         freeBytes
  4236 	freeBytes
  4237         totalBytes
  4237 	totalBytes
  4238      and possibly additional (OS-specific) information"
  4238      and possibly additional (OS-specific) information"
  4239 
  4239 
  4240     |volumeName info ok sectorsPerCluster bytesPerSector freeClusters totalClusters
  4240     |volumeName info ok sectorsPerCluster bytesPerSector freeClusters totalClusters
  4241      type freeBytesForUsersQuota freeBytes totalBytes |
  4241      type freeBytesForUsersQuota freeBytes totalBytes |
  4242 
  4242 
  4243     volumeName := volumeNameArg.
  4243     volumeName := volumeNameArg.
  4244     (volumeName endsWith:$\) ifFalse:[
  4244     (volumeName endsWith:$\) ifFalse:[
  4245         volumeName := volumeName , '\'
  4245 	volumeName := volumeName , '\'
  4246     ].
  4246     ].
  4247 %{
  4247 %{
  4248     typedef BOOL (WINAPI *P_GDFSE)(LPCTSTR, PULARGE_INTEGER,
  4248     typedef BOOL (WINAPI *P_GDFSE)(LPCTSTR, PULARGE_INTEGER,
  4249                                    PULARGE_INTEGER, PULARGE_INTEGER);
  4249 				   PULARGE_INTEGER, PULARGE_INTEGER);
  4250     P_GDFSE pGetDiskFreeSpaceEx = NULL;
  4250     P_GDFSE pGetDiskFreeSpaceEx = NULL;
  4251 
  4251 
  4252     DWORD __sectorsPerCluster, __bytesPerSector, __freeClusters, __totalClusters;
  4252     DWORD __sectorsPerCluster, __bytesPerSector, __freeClusters, __totalClusters;
  4253     BOOL  fResult = 0;
  4253     BOOL  fResult = 0;
  4254     unsigned __int64 i64FreeBytesForUsersQuota, i64TotalBytes, i64FreeBytes;
  4254     unsigned __int64 i64FreeBytesForUsersQuota, i64TotalBytes, i64FreeBytes;
  4255 
  4255 
  4256     if (__isString(volumeName) || __isSymbol(volumeName)) {
  4256     if (__isString(volumeName) || __isSymbol(volumeName)) {
  4257          /*
  4257 	 /*
  4258           *  Use GetDiskFreeSpaceEx if available; otherwise, use GetDiskFreeSpace.
  4258 	  *  Use GetDiskFreeSpaceEx if available; otherwise, use GetDiskFreeSpace.
  4259           *  Notice that GetDiskFreeSpace does not work correctly under win2k,
  4259 	  *  Notice that GetDiskFreeSpace does not work correctly under win2k,
  4260           *  and GetDiskFreeSpaceEx is not avail. for all win versions (can microsoft ever do something right ?).
  4260 	  *  and GetDiskFreeSpaceEx is not avail. for all win versions (can microsoft ever do something right ?).
  4261           */
  4261 	  */
  4262         pGetDiskFreeSpaceEx = (P_GDFSE)GetProcAddress (
  4262 	pGetDiskFreeSpaceEx = (P_GDFSE)GetProcAddress (
  4263                                             GetModuleHandle ("kernel32.dll"),
  4263 					    GetModuleHandle ("kernel32.dll"),
  4264                                                              "GetDiskFreeSpaceExA");
  4264 							     "GetDiskFreeSpaceExA");
  4265         if (pGetDiskFreeSpaceEx) {
  4265 	if (pGetDiskFreeSpaceEx) {
  4266             fResult = pGetDiskFreeSpaceEx (__stringVal(volumeName),
  4266 	    fResult = pGetDiskFreeSpaceEx (__stringVal(volumeName),
  4267                                  (PULARGE_INTEGER)&i64FreeBytesForUsersQuota,
  4267 				 (PULARGE_INTEGER)&i64FreeBytesForUsersQuota,
  4268                                  (PULARGE_INTEGER)&i64TotalBytes,
  4268 				 (PULARGE_INTEGER)&i64TotalBytes,
  4269                                  (PULARGE_INTEGER)&i64FreeBytes);
  4269 				 (PULARGE_INTEGER)&i64FreeBytes);
  4270             if (fResult) {
  4270 	    if (fResult) {
  4271                 freeBytesForUsersQuota = __MKUINT64(&i64FreeBytesForUsersQuota);
  4271 		freeBytesForUsersQuota = __MKUINT64(&i64FreeBytesForUsersQuota);
  4272                 totalBytes = __MKUINT64(&i64TotalBytes);
  4272 		totalBytes = __MKUINT64(&i64TotalBytes);
  4273                 freeBytes = __MKUINT64(&i64FreeBytes);
  4273 		freeBytes = __MKUINT64(&i64FreeBytes);
  4274             }
  4274 	    }
  4275         }
  4275 	}
  4276         fResult = GetDiskFreeSpace(__stringVal(volumeName),
  4276 	fResult = GetDiskFreeSpace(__stringVal(volumeName),
  4277                              &__sectorsPerCluster,
  4277 			     &__sectorsPerCluster,
  4278                              &__bytesPerSector,
  4278 			     &__bytesPerSector,
  4279                              &__freeClusters,
  4279 			     &__freeClusters,
  4280                              &__totalClusters);
  4280 			     &__totalClusters);
  4281         if (fResult) {
  4281 	if (fResult) {
  4282             sectorsPerCluster = __MKUINT(__sectorsPerCluster);
  4282 	    sectorsPerCluster = __MKUINT(__sectorsPerCluster);
  4283             bytesPerSector = __MKUINT(__bytesPerSector);
  4283 	    bytesPerSector = __MKUINT(__bytesPerSector);
  4284             freeClusters = __MKUINT(__freeClusters);
  4284 	    freeClusters = __MKUINT(__freeClusters);
  4285             totalClusters = __MKUINT(__totalClusters);
  4285 	    totalClusters = __MKUINT(__totalClusters);
  4286         }
  4286 	}
  4287         switch (GetDriveType(__stringVal(volumeName))) {
  4287 	switch (GetDriveType(__stringVal(volumeName))) {
  4288             case DRIVE_REMOVABLE:
  4288 	    case DRIVE_REMOVABLE:
  4289                 type = @symbol(removable); break;
  4289 		type = @symbol(removable); break;
  4290             case DRIVE_FIXED:
  4290 	    case DRIVE_FIXED:
  4291                 type = @symbol(fixed); break;
  4291 		type = @symbol(fixed); break;
  4292             case DRIVE_REMOTE:
  4292 	    case DRIVE_REMOTE:
  4293                 type = @symbol(network); break;
  4293 		type = @symbol(network); break;
  4294             case DRIVE_CDROM:
  4294 	    case DRIVE_CDROM:
  4295                 type = @symbol(cdrom); break;
  4295 		type = @symbol(cdrom); break;
  4296             case DRIVE_RAMDISK:
  4296 	    case DRIVE_RAMDISK:
  4297                 type = @symbol(ramdisk); break;
  4297 		type = @symbol(ramdisk); break;
  4298             case DRIVE_UNKNOWN:
  4298 	    case DRIVE_UNKNOWN:
  4299             default:
  4299 	    default:
  4300                 break;
  4300 		break;
  4301         }
  4301 	}
  4302         if (fResult) {
  4302 	if (fResult) {
  4303             ok = true;
  4303 	    ok = true;
  4304         } else {
  4304 	} else {
  4305             __threadErrno = __WIN32_ERR(GetLastError());
  4305 	    __threadErrno = __WIN32_ERR(GetLastError());
  4306             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4306 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4307         }
  4307 	}
  4308     }
  4308     }
  4309 %}.
  4309 %}.
  4310     ok == true ifFalse:[
  4310     ok == true ifFalse:[
  4311         self primitiveFailed.
  4311 	self primitiveFailed.
  4312         ^ self
  4312 	^ self
  4313     ].
  4313     ].
  4314 
  4314 
  4315     info := IdentityDictionary new.
  4315     info := IdentityDictionary new.
  4316     info at:#sectorsPerCluster put:sectorsPerCluster.
  4316     info at:#sectorsPerCluster put:sectorsPerCluster.
  4317     info at:#bytesPerSector put:bytesPerSector.
  4317     info at:#bytesPerSector put:bytesPerSector.
  4318     info at:#freeClusters put:freeClusters.
  4318     info at:#freeClusters put:freeClusters.
  4319     info at:#totalClusters put:totalClusters.
  4319     info at:#totalClusters put:totalClusters.
  4320 
  4320 
  4321     info at:#freeBytes put:(freeBytes notNil
  4321     info at:#freeBytes put:(freeBytes notNil
  4322                                 ifTrue:[freeBytes]
  4322 				ifTrue:[freeBytes]
  4323                                 ifFalse:[freeClusters * sectorsPerCluster * bytesPerSector]).
  4323 				ifFalse:[freeClusters * sectorsPerCluster * bytesPerSector]).
  4324     info at:#totalBytes put:(totalBytes notNil
  4324     info at:#totalBytes put:(totalBytes notNil
  4325                                 ifTrue:[totalBytes]
  4325 				ifTrue:[totalBytes]
  4326                                 ifFalse:[totalClusters * sectorsPerCluster * bytesPerSector]).
  4326 				ifFalse:[totalClusters * sectorsPerCluster * bytesPerSector]).
  4327     info at:#freeBytesForUsersQuota put:freeBytesForUsersQuota.
  4327     info at:#freeBytesForUsersQuota put:freeBytesForUsersQuota.
  4328     type notNil ifTrue:[
  4328     type notNil ifTrue:[
  4329         info at:#type put:type
  4329 	info at:#type put:type
  4330     ].
  4330     ].
  4331     ^ info
  4331     ^ info
  4332 
  4332 
  4333     "
  4333     "
  4334      self getDiskInfoOf:'c:\'
  4334      self getDiskInfoOf:'c:\'
  4375 %{
  4375 %{
  4376     int sz;
  4376     int sz;
  4377     DWORD dummy;
  4377     DWORD dummy;
  4378 
  4378 
  4379     if (__isString(aPathName)) {
  4379     if (__isString(aPathName)) {
  4380         sz = GetFileVersionInfoSizeA(__stringVal(aPathName), &dummy);
  4380 	sz = GetFileVersionInfoSizeA(__stringVal(aPathName), &dummy);
  4381     } else if (__isUnicode16String(aPathName)) {
  4381     } else if (__isUnicode16String(aPathName)) {
  4382         sz = GetFileVersionInfoSizeW(__unicode16StringVal(aPathName), &dummy);
  4382 	sz = GetFileVersionInfoSizeW(__unicode16StringVal(aPathName), &dummy);
  4383     } else {
  4383     } else {
  4384         goto badArgument;
  4384 	goto badArgument;
  4385     }
  4385     }
  4386 
  4386 
  4387     if (sz > 0) {
  4387     if (sz > 0) {
  4388         OBJ versionData;
  4388 	OBJ versionData;
  4389 
  4389 
  4390         versionData = __BYTEARRAY_UNINITIALIZED_NEW_INT(sz);
  4390 	versionData = __BYTEARRAY_UNINITIALIZED_NEW_INT(sz);
  4391         if (versionData == nil) {
  4391 	if (versionData == nil) {
  4392             RETURN (nil);
  4392 	    RETURN (nil);
  4393         }
  4393 	}
  4394         if (GetFileVersionInfo(__stringVal(aPathName), 0, sz, __ByteArrayInstPtr(versionData)->ba_element) == FALSE) {
  4394 	if (GetFileVersionInfo(__stringVal(aPathName), 0, sz, __ByteArrayInstPtr(versionData)->ba_element) == FALSE) {
  4395             RETURN (nil);
  4395 	    RETURN (nil);
  4396         }
  4396 	}
  4397         RETURN (versionData);
  4397 	RETURN (versionData);
  4398     }
  4398     }
  4399     RETURN (nil);
  4399     RETURN (nil);
  4400 badArgument: ;
  4400 badArgument: ;
  4401 %}.
  4401 %}.
  4402     self primitiveFailed
  4402     self primitiveFailed
  4412 
  4412 
  4413 infoOf:aPathName
  4413 infoOf:aPathName
  4414     "return some object filled with info for the file 'aPathName';
  4414     "return some object filled with info for the file 'aPathName';
  4415      the info (for which corresponding access methods are understood by
  4415      the info (for which corresponding access methods are understood by
  4416      the returned object) is:
  4416      the returned object) is:
  4417          type            - a symbol giving the files type
  4417 	 type            - a symbol giving the files type
  4418          mode            - numeric access mode
  4418 	 mode            - numeric access mode
  4419          uid             - owners user id
  4419 	 uid             - owners user id
  4420          gid             - owners group id
  4420 	 gid             - owners group id
  4421          size            - files size
  4421 	 size            - files size
  4422          id              - files number (i.e. inode number)
  4422 	 id              - files number (i.e. inode number)
  4423          accessed        - last access time (as Timestamp)
  4423 	 accessed        - last access time (as Timestamp)
  4424          modified        - last modification time (as Timestamp)
  4424 	 modified        - last modification time (as Timestamp)
  4425          statusChanged   - last status change time (as Timestamp)
  4425 	 statusChanged   - last status change time (as Timestamp)
  4426          alternativeName - (windows only:) the MSDOS name of the file
  4426 	 alternativeName - (windows only:) the MSDOS name of the file
  4427 
  4427 
  4428      Some of the fields may be returned as nil on systems which do not provide
  4428      Some of the fields may be returned as nil on systems which do not provide
  4429      all of the information.
  4429      all of the information.
  4430      Return nil if such a file does not exist.
  4430      Return nil if such a file does not exist.
  4431      For symbolic links (if supported by the OS),
  4431      For symbolic links (if supported by the OS),
  4435 
  4435 
  4436     |info target|
  4436     |info target|
  4437 
  4437 
  4438     info := self linkInfoOf:aPathName.
  4438     info := self linkInfoOf:aPathName.
  4439     (info notNil and:[info isSymbolicLink]) ifTrue:[
  4439     (info notNil and:[info isSymbolicLink]) ifTrue:[
  4440         target := info path.
  4440 	target := info path.
  4441         target notNil ifTrue:[
  4441 	target notNil ifTrue:[
  4442             ^ self linkInfoOf:target.
  4442 	    ^ self linkInfoOf:target.
  4443         ]
  4443 	]
  4444     ].
  4444     ].
  4445     ^ info
  4445     ^ info
  4446 
  4446 
  4447    "
  4447    "
  4448     OperatingSystem infoOf:'c:\windows'
  4448     OperatingSystem infoOf:'c:\windows'
  4460      This also returns true for symbolic links pointing to a directory;
  4460      This also returns true for symbolic links pointing to a directory;
  4461      if you need to check for this, use #linkInfo:."
  4461      if you need to check for this, use #linkInfo:."
  4462 
  4462 
  4463 %{
  4463 %{
  4464     if (__isString(aPathName)) {
  4464     if (__isString(aPathName)) {
  4465         int ret;
  4465 	int ret;
  4466 
  4466 
  4467 #ifdef DO_WRAP_CALLS
  4467 #ifdef DO_WRAP_CALLS
  4468         char _aPathName[MAXPATHLEN];
  4468 	char _aPathName[MAXPATHLEN];
  4469 
  4469 
  4470         strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4470 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4471         do {
  4471 	do {
  4472             __threadErrno = 0;
  4472 	    __threadErrno = 0;
  4473             ret = STX_API_CALL1( "GetFileAttributesA", GetFileAttributesA, _aPathName);
  4473 	    ret = STX_API_CALL1( "GetFileAttributesA", GetFileAttributesA, _aPathName);
  4474         } while ((ret < 0) && (__threadErrno == EINTR));
  4474 	} while ((ret < 0) && (__threadErrno == EINTR));
  4475 #else
  4475 #else
  4476         ret = GetFileAttributesA((char *) __stringVal(aPathName));
  4476 	ret = GetFileAttributesA((char *) __stringVal(aPathName));
  4477         if (ret < 0) {
  4477 	if (ret < 0) {
  4478             __threadErrno = __WIN32_ERR(GetLastError());
  4478 	    __threadErrno = __WIN32_ERR(GetLastError());
  4479         }
  4479 	}
  4480 #endif
  4480 #endif
  4481         if (ret < 0) {
  4481 	if (ret < 0) {
  4482             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4482 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4483             RETURN ( false );
  4483 	    RETURN ( false );
  4484         }
  4484 	}
  4485         RETURN ( (ret & FILE_ATTRIBUTE_DIRECTORY) ? true : false);
  4485 	RETURN ( (ret & FILE_ATTRIBUTE_DIRECTORY) ? true : false);
  4486     }
  4486     }
  4487 
  4487 
  4488 #ifdef SUPPORT_WIDE_CHAR_FILENAMES
  4488 #ifdef SUPPORT_WIDE_CHAR_FILENAMES
  4489     if (__isUnicode16String(aPathName)) {
  4489     if (__isUnicode16String(aPathName)) {
  4490         int ret;
  4490 	int ret;
  4491 
  4491 
  4492 #ifdef DO_WRAP_CALLS
  4492 #ifdef DO_WRAP_CALLS
  4493         unsigned char _wPathName[MAXPATHLEN];
  4493 	unsigned char _wPathName[MAXPATHLEN];
  4494         int i;
  4494 	int i;
  4495 
  4495 
  4496 # if 1
  4496 # if 1
  4497         for (i=0; i<MAXPATHLEN; i++) {
  4497 	for (i=0; i<MAXPATHLEN; i++) {
  4498             _wPathName[i] = __unicode16StringVal(aPathName)[i];
  4498 	    _wPathName[i] = __unicode16StringVal(aPathName)[i];
  4499             if (_wPathName[i] == 0) break;
  4499 	    if (_wPathName[i] == 0) break;
  4500         }
  4500 	}
  4501 # else
  4501 # else
  4502         wstrncpy(_wPathName, __unicode16StringVal(aPathName), MAXPATHLEN-1); _wPathName[MAXPATHLEN-1] = '\0';
  4502 	wstrncpy(_wPathName, __unicode16StringVal(aPathName), MAXPATHLEN-1); _wPathName[MAXPATHLEN-1] = '\0';
  4503 # endif
  4503 # endif
  4504         do {
  4504 	do {
  4505             __threadErrno = 0;
  4505 	    __threadErrno = 0;
  4506             ret = STX_API_CALL1( "GetFileAttributesW", GetFileAttributesW, _wPathName);
  4506 	    ret = STX_API_CALL1( "GetFileAttributesW", GetFileAttributesW, _wPathName);
  4507         } while ((ret < 0) && (__threadErrno == EINTR));
  4507 	} while ((ret < 0) && (__threadErrno == EINTR));
  4508 #else
  4508 #else
  4509         ret = GetFileAttributesW(__unicode16StringVal(wPathName));
  4509 	ret = GetFileAttributesW(__unicode16StringVal(wPathName));
  4510         if (ret < 0) {
  4510 	if (ret < 0) {
  4511             __threadErrno = __WIN32_ERR(GetLastError());
  4511 	    __threadErrno = __WIN32_ERR(GetLastError());
  4512         }
  4512 	}
  4513 #endif
  4513 #endif
  4514         if (ret < 0) {
  4514 	if (ret < 0) {
  4515             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4515 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4516             RETURN ( false );
  4516 	    RETURN ( false );
  4517         }
  4517 	}
  4518         RETURN ( (ret & FILE_ATTRIBUTE_DIRECTORY) ? true : false);
  4518 	RETURN ( (ret & FILE_ATTRIBUTE_DIRECTORY) ? true : false);
  4519     }
  4519     }
  4520 #endif /* SUPPORT_WIDE_CHAR_FILENAMES */
  4520 #endif /* SUPPORT_WIDE_CHAR_FILENAMES */
  4521 %}.
  4521 %}.
  4522     ^ self primitiveFailed
  4522     ^ self primitiveFailed
  4523 
  4523 
  4524     "an alternative implementation would be:
  4524     "an alternative implementation would be:
  4525         ^ (self infoOf:aPathName) type == #directory
  4525 	^ (self infoOf:aPathName) type == #directory
  4526     "
  4526     "
  4527 
  4527 
  4528     "Modified: / 05-07-2006 / 17:23:42 / cg"
  4528     "Modified: / 05-07-2006 / 17:23:42 / cg"
  4529 !
  4529 !
  4530 
  4530 
  4547 %{
  4547 %{
  4548     int ret;
  4548     int ret;
  4549 
  4549 
  4550     if (__isString(aPathName)) {
  4550     if (__isString(aPathName)) {
  4551 #ifdef DO_WRAP_CALLS
  4551 #ifdef DO_WRAP_CALLS
  4552         char _aPathName[MAXPATHLEN];
  4552 	char _aPathName[MAXPATHLEN];
  4553 
  4553 
  4554         strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4554 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4555         do {
  4555 	do {
  4556             __threadErrno = 0;
  4556 	    __threadErrno = 0;
  4557             ret = STX_API_CALL1( "GetFileAttributes", GetFileAttributes, _aPathName);
  4557 	    ret = STX_API_CALL1( "GetFileAttributes", GetFileAttributes, _aPathName);
  4558         } while ((ret < 0) && (__threadErrno == EINTR));
  4558 	} while ((ret < 0) && (__threadErrno == EINTR));
  4559 #else
  4559 #else
  4560         ret = GetFileAttributes((char *) __stringVal(aPathName));
  4560 	ret = GetFileAttributes((char *) __stringVal(aPathName));
  4561         if (ret < 0) {
  4561 	if (ret < 0) {
  4562             __threadErrno = __WIN32_ERR(GetLastError());
  4562 	    __threadErrno = __WIN32_ERR(GetLastError());
  4563         }
  4563 	}
  4564 #endif
  4564 #endif
  4565         if (ret < 0) {
  4565 	if (ret < 0) {
  4566             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4566 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4567             RETURN ( false );
  4567 	    RETURN ( false );
  4568         }
  4568 	}
  4569         RETURN ( (ret & FILE_ATTRIBUTE_HIDDEN) ? true : false);
  4569 	RETURN ( (ret & FILE_ATTRIBUTE_HIDDEN) ? true : false);
  4570     }
  4570     }
  4571 %}.
  4571 %}.
  4572     ^ self primitiveFailed
  4572     ^ self primitiveFailed
  4573 !
  4573 !
  4574 
  4574 
  4576     "return true, if the file/dir 'aPathName' is readable.
  4576     "return true, if the file/dir 'aPathName' is readable.
  4577      For symbolic links, the pointed-to-file is checked."
  4577      For symbolic links, the pointed-to-file is checked."
  4578 
  4578 
  4579 %{
  4579 %{
  4580     if (__isString(aPathName)) {
  4580     if (__isString(aPathName)) {
  4581         int ret;
  4581 	int ret;
  4582 
  4582 
  4583         /*
  4583 	/*
  4584          * under windows, all files are readable ...
  4584 	 * under windows, all files are readable ...
  4585          * so, only check for the files existence here.
  4585 	 * so, only check for the files existence here.
  4586          */
  4586 	 */
  4587 #ifdef DO_WRAP_CALLS
  4587 #ifdef DO_WRAP_CALLS
  4588         char _aPathName[MAXPATHLEN];
  4588 	char _aPathName[MAXPATHLEN];
  4589 
  4589 
  4590         strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4590 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4591         do {
  4591 	do {
  4592             __threadErrno = 0;
  4592 	    __threadErrno = 0;
  4593             ret = STX_API_CALL1( "GetFileAttributesA", GetFileAttributesA, _aPathName);
  4593 	    ret = STX_API_CALL1( "GetFileAttributesA", GetFileAttributesA, _aPathName);
  4594         } while ((ret < 0) && (__threadErrno == EINTR));
  4594 	} while ((ret < 0) && (__threadErrno == EINTR));
  4595 #else
  4595 #else
  4596         ret = GetFileAttributesA((char *) __stringVal(aPathName));
  4596 	ret = GetFileAttributesA((char *) __stringVal(aPathName));
  4597         if (ret < 0) {
  4597 	if (ret < 0) {
  4598             __threadErrno = __WIN32_ERR(GetLastError());
  4598 	    __threadErrno = __WIN32_ERR(GetLastError());
  4599         }
  4599 	}
  4600 #endif
  4600 #endif
  4601         if (ret < 0) {
  4601 	if (ret < 0) {
  4602             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4602 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4603             RETURN (false);
  4603 	    RETURN (false);
  4604         }
  4604 	}
  4605         RETURN (true);
  4605 	RETURN (true);
  4606     }
  4606     }
  4607 
  4607 
  4608 #ifdef SUPPORT_WIDE_CHAR_FILENAMES
  4608 #ifdef SUPPORT_WIDE_CHAR_FILENAMES
  4609     if (__isUnicode16String(aPathName)) {
  4609     if (__isUnicode16String(aPathName)) {
  4610         int ret;
  4610 	int ret;
  4611 
  4611 
  4612         /*
  4612 	/*
  4613          * under windows, all files are readable ...
  4613 	 * under windows, all files are readable ...
  4614          * so, only check for the files existence here.
  4614 	 * so, only check for the files existence here.
  4615          */
  4615 	 */
  4616 #ifdef DO_WRAP_CALLS
  4616 #ifdef DO_WRAP_CALLS
  4617         unsigned short _wPathName[MAXPATHLEN];
  4617 	unsigned short _wPathName[MAXPATHLEN];
  4618 
  4618 
  4619 # if 1
  4619 # if 1
  4620         int i;
  4620 	int i;
  4621         for (i=0; i<MAXPATHLEN; i++) {
  4621 	for (i=0; i<MAXPATHLEN; i++) {
  4622             _wPathName[i] = __unicode16StringVal(aPathName)[i];
  4622 	    _wPathName[i] = __unicode16StringVal(aPathName)[i];
  4623             if (_wPathName[i] == 0) break;
  4623 	    if (_wPathName[i] == 0) break;
  4624         }
  4624 	}
  4625 # else
  4625 # else
  4626         wstrncpy(_wPathName, __unicode16StringVal(aPathName), MAXPATHLEN-1); _wPathName[MAXPATHLEN-1] = '\0';
  4626 	wstrncpy(_wPathName, __unicode16StringVal(aPathName), MAXPATHLEN-1); _wPathName[MAXPATHLEN-1] = '\0';
  4627 # endif
  4627 # endif
  4628         do {
  4628 	do {
  4629             __threadErrno = 0;
  4629 	    __threadErrno = 0;
  4630             ret = STX_API_CALL1( "GetFileAttributesW", GetFileAttributesW, _wPathName);
  4630 	    ret = STX_API_CALL1( "GetFileAttributesW", GetFileAttributesW, _wPathName);
  4631         } while ((ret < 0) && (__threadErrno == EINTR));
  4631 	} while ((ret < 0) && (__threadErrno == EINTR));
  4632 #else
  4632 #else
  4633         ret = GetFileAttributesW(__unicode16StringVal(aPathName));
  4633 	ret = GetFileAttributesW(__unicode16StringVal(aPathName));
  4634         if (ret < 0) {
  4634 	if (ret < 0) {
  4635             __threadErrno = __WIN32_ERR(GetLastError());
  4635 	    __threadErrno = __WIN32_ERR(GetLastError());
  4636         }
  4636 	}
  4637 #endif
  4637 #endif
  4638         if (ret < 0) {
  4638 	if (ret < 0) {
  4639             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4639 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4640             RETURN (false);
  4640 	    RETURN (false);
  4641         }
  4641 	}
  4642         RETURN (true);
  4642 	RETURN (true);
  4643     }
  4643     }
  4644 #endif /* SUPPORT_WIDE_CHAR_FILENAMES */
  4644 #endif /* SUPPORT_WIDE_CHAR_FILENAMES */
  4645 %}.
  4645 %}.
  4646     ^ self primitiveFailed
  4646     ^ self primitiveFailed
  4647 
  4647 
  4655 %{
  4655 %{
  4656     int ret;
  4656     int ret;
  4657 
  4657 
  4658     if (__isString(aPathName) || __isSymbol(aPathName)) {
  4658     if (__isString(aPathName) || __isSymbol(aPathName)) {
  4659 #ifdef DO_WRAP_CALLS
  4659 #ifdef DO_WRAP_CALLS
  4660         char _aPathName[MAXPATHLEN];
  4660 	char _aPathName[MAXPATHLEN];
  4661 
  4661 
  4662         strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4662 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4663         do {
  4663 	do {
  4664             __threadErrno = 0;
  4664 	    __threadErrno = 0;
  4665             ret = STX_API_CALL1( "GetFileAttributesA", GetFileAttributesA, _aPathName);
  4665 	    ret = STX_API_CALL1( "GetFileAttributesA", GetFileAttributesA, _aPathName);
  4666         } while ((ret < 0) && (__threadErrno == EINTR));
  4666 	} while ((ret < 0) && (__threadErrno == EINTR));
  4667 #else
  4667 #else
  4668         ret = GetFileAttributesA((char *) __stringVal(aPathName));
  4668 	ret = GetFileAttributesA((char *) __stringVal(aPathName));
  4669         if (ret < 0) {
  4669 	if (ret < 0) {
  4670             __threadErrno = __WIN32_ERR(GetLastError());
  4670 	    __threadErrno = __WIN32_ERR(GetLastError());
  4671         }
  4671 	}
  4672 #endif
  4672 #endif
  4673         if (ret < 0) {
  4673 	if (ret < 0) {
  4674             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4674 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4675             RETURN ( false );
  4675 	    RETURN ( false );
  4676         }
  4676 	}
  4677         RETURN (true);
  4677 	RETURN (true);
  4678     }
  4678     }
  4679 
  4679 
  4680 #ifdef SUPPORT_WIDE_CHAR_FILENAMES
  4680 #ifdef SUPPORT_WIDE_CHAR_FILENAMES
  4681     if (__isUnicode16String(aPathName)) {
  4681     if (__isUnicode16String(aPathName)) {
  4682 #ifdef DO_WRAP_CALLS
  4682 #ifdef DO_WRAP_CALLS
  4683         unsigned short _wPathName[MAXPATHLEN];
  4683 	unsigned short _wPathName[MAXPATHLEN];
  4684 # if 1
  4684 # if 1
  4685         int i;
  4685 	int i;
  4686         for (i=0; i<MAXPATHLEN; i++) {
  4686 	for (i=0; i<MAXPATHLEN; i++) {
  4687             _wPathName[i] = __unicode16StringVal(aPathName)[i];
  4687 	    _wPathName[i] = __unicode16StringVal(aPathName)[i];
  4688             if (_wPathName[i] == 0) break;
  4688 	    if (_wPathName[i] == 0) break;
  4689         }
  4689 	}
  4690 # else
  4690 # else
  4691         wstrncpy(_wPathName, __unicode16StringVal(aPathName), MAXPATHLEN-1); _wPathName[MAXPATHLEN-1] = '\0';
  4691 	wstrncpy(_wPathName, __unicode16StringVal(aPathName), MAXPATHLEN-1); _wPathName[MAXPATHLEN-1] = '\0';
  4692 # endif
  4692 # endif
  4693         do {
  4693 	do {
  4694             __threadErrno = 0;
  4694 	    __threadErrno = 0;
  4695             ret = STX_API_CALL1( "GetFileAttributesW", GetFileAttributesW, _wPathName);
  4695 	    ret = STX_API_CALL1( "GetFileAttributesW", GetFileAttributesW, _wPathName);
  4696         } while ((ret < 0) && (__threadErrno == EINTR));
  4696 	} while ((ret < 0) && (__threadErrno == EINTR));
  4697 #else
  4697 #else
  4698         ret = GetFileAttributesW(__unicode16StringVal(wPathName));
  4698 	ret = GetFileAttributesW(__unicode16StringVal(wPathName));
  4699         if (ret < 0) {
  4699 	if (ret < 0) {
  4700             __threadErrno = __WIN32_ERR(GetLastError());
  4700 	    __threadErrno = __WIN32_ERR(GetLastError());
  4701         }
  4701 	}
  4702 #endif
  4702 #endif
  4703         if (ret < 0) {
  4703 	if (ret < 0) {
  4704             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4704 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4705             RETURN ( false );
  4705 	    RETURN ( false );
  4706         }
  4706 	}
  4707         RETURN (true);
  4707 	RETURN (true);
  4708     }
  4708     }
  4709 #endif /* SUPPORT_WIDE_CHAR_FILENAMES */
  4709 #endif /* SUPPORT_WIDE_CHAR_FILENAMES */
  4710 %}.
  4710 %}.
  4711     ^ self primitiveFailed
  4711     ^ self primitiveFailed
  4712 
  4712 
  4720 %{
  4720 %{
  4721     int ret;
  4721     int ret;
  4722 
  4722 
  4723     if (__isString(aPathName)) {
  4723     if (__isString(aPathName)) {
  4724 #ifdef DO_WRAP_CALLS
  4724 #ifdef DO_WRAP_CALLS
  4725         char _aPathName[MAXPATHLEN];
  4725 	char _aPathName[MAXPATHLEN];
  4726 
  4726 
  4727         strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4727 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4728         do {
  4728 	do {
  4729             __threadErrno = 0;
  4729 	    __threadErrno = 0;
  4730             ret = STX_API_CALL1( "GetFileAttributes", GetFileAttributes, _aPathName);
  4730 	    ret = STX_API_CALL1( "GetFileAttributes", GetFileAttributes, _aPathName);
  4731         } while ((ret < 0) && (__threadErrno == EINTR));
  4731 	} while ((ret < 0) && (__threadErrno == EINTR));
  4732 #else
  4732 #else
  4733         ret = GetFileAttributes((char *) __stringVal(aPathName));
  4733 	ret = GetFileAttributes((char *) __stringVal(aPathName));
  4734         if (ret < 0) {
  4734 	if (ret < 0) {
  4735             __threadErrno = __WIN32_ERR(GetLastError());
  4735 	    __threadErrno = __WIN32_ERR(GetLastError());
  4736         }
  4736 	}
  4737 #endif
  4737 #endif
  4738         if (ret < 0) {
  4738 	if (ret < 0) {
  4739             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4739 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4740             RETURN ( false );
  4740 	    RETURN ( false );
  4741         }
  4741 	}
  4742         RETURN ( (ret & FILE_ATTRIBUTE_READONLY) ? false : true);
  4742 	RETURN ( (ret & FILE_ATTRIBUTE_READONLY) ? false : true);
  4743     }
  4743     }
  4744 %}.
  4744 %}.
  4745     ^ self primitiveFailed
  4745     ^ self primitiveFailed
  4746 !
  4746 !
  4747 
  4747 
  4748 linkInfoOf:aPathName
  4748 linkInfoOf:aPathName
  4749     "return some object filled with info for the file 'aPathName';
  4749     "return some object filled with info for the file 'aPathName';
  4750      the info (for which corresponding access methods are understood by
  4750      the info (for which corresponding access methods are understood by
  4751      the returned object) is:
  4751      the returned object) is:
  4752          type            - a symbol giving the files type
  4752 	 type            - a symbol giving the files type
  4753          mode            - numeric access mode
  4753 	 mode            - numeric access mode
  4754          uid             - owners user id
  4754 	 uid             - owners user id
  4755          gid             - owners group id
  4755 	 gid             - owners group id
  4756          size            - files size
  4756 	 size            - files size
  4757          id              - files number (i.e. inode number)
  4757 	 id              - files number (i.e. inode number)
  4758          accessed        - last access time (as Timestamp)
  4758 	 accessed        - last access time (as Timestamp)
  4759          modified        - last modification time (as Timestamp)
  4759 	 modified        - last modification time (as Timestamp)
  4760          statusChanged   - last status change time (as Timestamp)
  4760 	 statusChanged   - last status change time (as Timestamp)
  4761          alternativeName - (windows only:) the MSDOS name of the file
  4761 	 alternativeName - (windows only:) the MSDOS name of the file
  4762 
  4762 
  4763      Some of the fields may be returned as nil on systems which do not provide
  4763      Some of the fields may be returned as nil on systems which do not provide
  4764      all of the information.
  4764      all of the information.
  4765      Return nil if such a file does not exist.
  4765      Return nil if such a file does not exist.
  4766      For symbolic links (if supported by the OS),
  4766      For symbolic links (if supported by the OS),
  4781     char fileNameBuffer[MAX_PATH+1];
  4781     char fileNameBuffer[MAX_PATH+1];
  4782 
  4782 
  4783     unsigned INT ino;
  4783     unsigned INT ino;
  4784 
  4784 
  4785     if (__isString(aPathName)) {
  4785     if (__isString(aPathName)) {
  4786         HANDLE hFile;
  4786 	HANDLE hFile;
  4787         FILETIME tempFileTime;
  4787 	FILETIME tempFileTime;
  4788         SYSTEMTIME creationTime;
  4788 	SYSTEMTIME creationTime;
  4789         SYSTEMTIME accessTime;
  4789 	SYSTEMTIME accessTime;
  4790         SYSTEMTIME modificationTime;
  4790 	SYSTEMTIME modificationTime;
  4791         int modeBits = 0;
  4791 	int modeBits = 0;
  4792         WIN32_FIND_DATA findStruct;
  4792 	WIN32_FIND_DATA findStruct;
  4793 
  4793 
  4794 #ifdef DO_WRAP_CALLS
  4794 #ifdef DO_WRAP_CALLS
  4795         {
  4795 	{
  4796             char _aPathName[MAXPATHLEN];
  4796 	    char _aPathName[MAXPATHLEN];
  4797 
  4797 
  4798             strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4798 	    strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  4799             do {
  4799 	    do {
  4800                 __threadErrno = 0;
  4800 		__threadErrno = 0;
  4801                 hFile = STX_API_CALL2( "FindFirstFile", FindFirstFile, _aPathName, &findStruct);
  4801 		hFile = STX_API_CALL2( "FindFirstFile", FindFirstFile, _aPathName, &findStruct);
  4802             } while ((hFile < 0) && (__threadErrno == EINTR));
  4802 	    } while ((hFile < 0) && (__threadErrno == EINTR));
  4803         }
  4803 	}
  4804 #else
  4804 #else
  4805         hFile = FindFirstFile(__stringVal(aPathName), &findStruct);
  4805 	hFile = FindFirstFile(__stringVal(aPathName), &findStruct);
  4806         if (hFile < 0) {
  4806 	if (hFile < 0) {
  4807             __threadErrno = __WIN32_ERR(GetLastError());
  4807 	    __threadErrno = __WIN32_ERR(GetLastError());
  4808         }
  4808 	}
  4809 #endif
  4809 #endif
  4810         if (! hFile || (hFile == (HANDLE)(-1)) || (hFile == INVALID_HANDLE_VALUE)) {
  4810 	if (! hFile || (hFile == (HANDLE)(-1)) || (hFile == INVALID_HANDLE_VALUE)) {
  4811             @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4811 	    @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  4812         } else {
  4812 	} else {
  4813             FindClose(hFile);
  4813 	    FindClose(hFile);
  4814 
  4814 
  4815             id = __mkSmallInteger(0);   /* could get it by opening ... */
  4815 	    id = __mkSmallInteger(0);   /* could get it by opening ... */
  4816             size = __MKLARGEINT64(1, findStruct.nFileSizeLow, findStruct.nFileSizeHigh);
  4816 	    size = __MKLARGEINT64(1, findStruct.nFileSizeLow, findStruct.nFileSizeHigh);
  4817 
  4817 
  4818             if (findStruct.cFileName[0] != '\0') {
  4818 	    if (findStruct.cFileName[0] != '\0') {
  4819                 bcopy(findStruct.cFileName, fileNameBuffer, MAX_PATH);
  4819 		bcopy(findStruct.cFileName, fileNameBuffer, MAX_PATH);
  4820                 fileNameBuffer[MAX_PATH] = '\0';
  4820 		fileNameBuffer[MAX_PATH] = '\0';
  4821                 fileName = __MKSTRING(fileNameBuffer);             /* FULL name */
  4821 		fileName = __MKSTRING(fileNameBuffer);             /* FULL name */
  4822             }
  4822 	    }
  4823 
  4823 
  4824             if (findStruct.cAlternateFileName[0] != '\0') {
  4824 	    if (findStruct.cAlternateFileName[0] != '\0') {
  4825                 bcopy(findStruct.cAlternateFileName, alternativeFileNameBuffer, 14);
  4825 		bcopy(findStruct.cAlternateFileName, alternativeFileNameBuffer, 14);
  4826                 alternativeFileNameBuffer[14] = '\0';
  4826 		alternativeFileNameBuffer[14] = '\0';
  4827                 alternativeName = __MKSTRING(alternativeFileNameBuffer); /* DOS name */
  4827 		alternativeName = __MKSTRING(alternativeFileNameBuffer); /* DOS name */
  4828             }
  4828 	    }
  4829 
  4829 
  4830             /*
  4830 	    /*
  4831              * simulate access bits
  4831 	     * simulate access bits
  4832              */
  4832 	     */
  4833             if (findStruct.dwFileAttributes & FILE_ATTRIBUTE_READONLY) {
  4833 	    if (findStruct.dwFileAttributes & FILE_ATTRIBUTE_READONLY) {
  4834                 modeBits = 0444;
  4834 		modeBits = 0444;
  4835             } else {
  4835 	    } else {
  4836                 modeBits = 0666;
  4836 		modeBits = 0666;
  4837             }
  4837 	    }
  4838 
  4838 
  4839             if (findStruct.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
  4839 	    if (findStruct.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
  4840                 type = @symbol(directory);
  4840 		type = @symbol(directory);
  4841                 modeBits |= 0111;   /* executable */
  4841 		modeBits |= 0111;   /* executable */
  4842             } else {
  4842 	    } else {
  4843                 type = @symbol(regular);
  4843 		type = @symbol(regular);
  4844             }
  4844 	    }
  4845 
  4845 
  4846             mode = __mkSmallInteger(modeBits);
  4846 	    mode = __mkSmallInteger(modeBits);
  4847 
  4847 
  4848             /*
  4848 	    /*
  4849              * sigh - convert from stupid time to useful time
  4849 	     * sigh - convert from stupid time to useful time
  4850              */
  4850 	     */
  4851             FileTimeToLocalFileTime(&findStruct.ftCreationTime, &tempFileTime);
  4851 	    FileTimeToLocalFileTime(&findStruct.ftCreationTime, &tempFileTime);
  4852             FileTimeToSystemTime(&tempFileTime, &creationTime);
  4852 	    FileTimeToSystemTime(&tempFileTime, &creationTime);
  4853             FileTimeToLocalFileTime(&findStruct.ftLastAccessTime, &tempFileTime);
  4853 	    FileTimeToLocalFileTime(&findStruct.ftLastAccessTime, &tempFileTime);
  4854             FileTimeToSystemTime(&tempFileTime, &accessTime);
  4854 	    FileTimeToSystemTime(&tempFileTime, &accessTime);
  4855             FileTimeToLocalFileTime(&findStruct.ftLastWriteTime, &tempFileTime);
  4855 	    FileTimeToLocalFileTime(&findStruct.ftLastWriteTime, &tempFileTime);
  4856             FileTimeToSystemTime(&tempFileTime, &modificationTime);
  4856 	    FileTimeToSystemTime(&tempFileTime, &modificationTime);
  4857             aYr  = __mkSmallInteger(accessTime.wYear);
  4857 	    aYr  = __mkSmallInteger(accessTime.wYear);
  4858             aMon = __mkSmallInteger(accessTime.wMonth);
  4858 	    aMon = __mkSmallInteger(accessTime.wMonth);
  4859             aDay = __mkSmallInteger(accessTime.wDay);
  4859 	    aDay = __mkSmallInteger(accessTime.wDay);
  4860             aHr  = __mkSmallInteger(accessTime.wHour);
  4860 	    aHr  = __mkSmallInteger(accessTime.wHour);
  4861             aMin = __mkSmallInteger(accessTime.wMinute);
  4861 	    aMin = __mkSmallInteger(accessTime.wMinute);
  4862             aSec = __mkSmallInteger(accessTime.wSecond);
  4862 	    aSec = __mkSmallInteger(accessTime.wSecond);
  4863             aMS  = __mkSmallInteger(accessTime.wMilliseconds);
  4863 	    aMS  = __mkSmallInteger(accessTime.wMilliseconds);
  4864 
  4864 
  4865             mYr  = __mkSmallInteger(modificationTime.wYear);
  4865 	    mYr  = __mkSmallInteger(modificationTime.wYear);
  4866             mMon = __mkSmallInteger(modificationTime.wMonth);
  4866 	    mMon = __mkSmallInteger(modificationTime.wMonth);
  4867             mDay = __mkSmallInteger(modificationTime.wDay);
  4867 	    mDay = __mkSmallInteger(modificationTime.wDay);
  4868             mHr  = __mkSmallInteger(modificationTime.wHour);
  4868 	    mHr  = __mkSmallInteger(modificationTime.wHour);
  4869             mMin = __mkSmallInteger(modificationTime.wMinute);
  4869 	    mMin = __mkSmallInteger(modificationTime.wMinute);
  4870             mSec = __mkSmallInteger(modificationTime.wSecond);
  4870 	    mSec = __mkSmallInteger(modificationTime.wSecond);
  4871             mMS  = __mkSmallInteger(modificationTime.wMilliseconds);
  4871 	    mMS  = __mkSmallInteger(modificationTime.wMilliseconds);
  4872 
  4872 
  4873             cYr  = __mkSmallInteger(creationTime.wYear);
  4873 	    cYr  = __mkSmallInteger(creationTime.wYear);
  4874             cMon = __mkSmallInteger(creationTime.wMonth);
  4874 	    cMon = __mkSmallInteger(creationTime.wMonth);
  4875             cDay = __mkSmallInteger(creationTime.wDay);
  4875 	    cDay = __mkSmallInteger(creationTime.wDay);
  4876             cHr  = __mkSmallInteger(creationTime.wHour);
  4876 	    cHr  = __mkSmallInteger(creationTime.wHour);
  4877             cMin = __mkSmallInteger(creationTime.wMinute);
  4877 	    cMin = __mkSmallInteger(creationTime.wMinute);
  4878             cSec = __mkSmallInteger(creationTime.wSecond);
  4878 	    cSec = __mkSmallInteger(creationTime.wSecond);
  4879             cMS  = __mkSmallInteger(creationTime.wMilliseconds);
  4879 	    cMS  = __mkSmallInteger(creationTime.wMilliseconds);
  4880         }
  4880 	}
  4881     }
  4881     }
  4882 %}.
  4882 %}.
  4883     (aPathName endsWith:'.lnk') ifTrue:[
  4883     (aPathName endsWith:'.lnk') ifTrue:[
  4884         type := #symbolicLink.
  4884 	type := #symbolicLink.
  4885         path := nil.
  4885 	path := nil.
  4886         "/ now done lazyly in FileStatusInfo, when the path is accessed
  4886 	"/ now done lazyly in FileStatusInfo, when the path is accessed
  4887         "/ path := self getLinkTarget:aPathName.
  4887 	"/ path := self getLinkTarget:aPathName.
  4888     ].
  4888     ].
  4889 
  4889 
  4890     mode isNil ifTrue:[
  4890     mode isNil ifTrue:[
  4891         (self isDirectory:aPathName) ifTrue:[
  4891 	(self isDirectory:aPathName) ifTrue:[
  4892             "/ the code above fails for root directories (these do not exist).
  4892 	    "/ the code above fails for root directories (these do not exist).
  4893             "/ simulate
  4893 	    "/ simulate
  4894             mode := 8r777.
  4894 	    mode := 8r777.
  4895             type := #directory.
  4895 	    type := #directory.
  4896             uid := gid := 0.
  4896 	    uid := gid := 0.
  4897             size := 0.
  4897 	    size := 0.
  4898             id := 0.
  4898 	    id := 0.
  4899             atime := mtime := ctime := Timestamp now.
  4899 	    atime := mtime := ctime := Timestamp now.
  4900         ].
  4900 	].
  4901     ].
  4901     ].
  4902     mode notNil ifTrue:[
  4902     mode notNil ifTrue:[
  4903         atime isNil ifTrue:[
  4903 	atime isNil ifTrue:[
  4904             atime := Timestamp day:aDay month:aMon year:aYr hour:aHr minutes:aMin seconds:aSec milliseconds:aMS.
  4904 	    atime := Timestamp day:aDay month:aMon year:aYr hour:aHr minutes:aMin seconds:aSec milliseconds:aMS.
  4905         ].
  4905 	].
  4906         mtime isNil ifTrue:[
  4906 	mtime isNil ifTrue:[
  4907             mtime := Timestamp day:mDay month:mMon year:mYr hour:mHr minutes:mMin seconds:mSec milliseconds:mMS.
  4907 	    mtime := Timestamp day:mDay month:mMon year:mYr hour:mHr minutes:mMin seconds:mSec milliseconds:mMS.
  4908         ].
  4908 	].
  4909         ctime isNil ifTrue:[
  4909 	ctime isNil ifTrue:[
  4910             ctime := Timestamp day:cDay month:cMon year:cYr hour:cHr minutes:cMin seconds:cSec milliseconds:cMS.
  4910 	    ctime := Timestamp day:cDay month:cMon year:cYr hour:cHr minutes:cMin seconds:cSec milliseconds:cMS.
  4911         ].
  4911 	].
  4912 
  4912 
  4913         info := FileStatusInfo
  4913 	info := FileStatusInfo
  4914                     type:type
  4914 		    type:type
  4915                     mode:mode
  4915 		    mode:mode
  4916                     uid:uid
  4916 		    uid:uid
  4917                     gid:gid
  4917 		    gid:gid
  4918                     size:size
  4918 		    size:size
  4919                     id:id
  4919 		    id:id
  4920                     accessed:atime
  4920 		    accessed:atime
  4921                     modified:mtime
  4921 		    modified:mtime
  4922                     created:ctime
  4922 		    created:ctime
  4923                     path:path
  4923 		    path:path
  4924                     fullName:fileName
  4924 		    fullName:fileName
  4925                     alternativeName:alternativeName.
  4925 		    alternativeName:alternativeName.
  4926         ^ info
  4926 	^ info
  4927    ].
  4927    ].
  4928    ^ nil
  4928    ^ nil
  4929 
  4929 
  4930    "
  4930    "
  4931     OperatingSystem linkInfoOf:'c:\windows'
  4931     OperatingSystem linkInfoOf:'c:\windows'
  4942     "given a file suffix, return a corresponding mimeType.
  4942     "given a file suffix, return a corresponding mimeType.
  4943      Here, the Registry is consulted.
  4943      Here, the Registry is consulted.
  4944      Returns nil if no mimeType for the given suffix is known."
  4944      Returns nil if no mimeType for the given suffix is known."
  4945 
  4945 
  4946     ^ RegistryEntry
  4946     ^ RegistryEntry
  4947         stringValueFor:'Content Type'
  4947 	stringValueFor:'Content Type'
  4948         atKey:('HKEY_CLASSES_ROOT\.' , aFileSuffix)
  4948 	atKey:('HKEY_CLASSES_ROOT\.' , aFileSuffix)
  4949 
  4949 
  4950     "
  4950     "
  4951      self mimeTypeForSuffix:'au'
  4951      self mimeTypeForSuffix:'au'
  4952      self mimeTypeForSuffix:'st'
  4952      self mimeTypeForSuffix:'st'
  4953      self mimeTypeForSuffix:'dll'
  4953      self mimeTypeForSuffix:'dll'
  4976 
  4976 
  4977     "some systems have a convenient function for this ..."
  4977     "some systems have a convenient function for this ..."
  4978     path := self primPathNameOf:pathName.
  4978     path := self primPathNameOf:pathName.
  4979 
  4979 
  4980     path isNil ifTrue:[
  4980     path isNil ifTrue:[
  4981         (self isValidPath:pathName) ifFalse:[
  4981 	(self isValidPath:pathName) ifFalse:[
  4982             p := pathName.
  4982 	    p := pathName.
  4983             [(p size > 1)
  4983 	    [(p size > 1)
  4984              and:[p endsWith:(self fileSeparator)]
  4984 	     and:[p endsWith:(self fileSeparator)]
  4985             ] whileTrue:[
  4985 	    ] whileTrue:[
  4986                 p := p copyWithoutLast:1.
  4986 		p := p copyWithoutLast:1.
  4987             ].
  4987 	    ].
  4988             ^ p
  4988 	    ^ p
  4989         ].
  4989 	].
  4990 
  4990 
  4991         "/
  4991 	"/
  4992         "/ return the original - there is nothing else can we do
  4992 	"/ return the original - there is nothing else can we do
  4993         "/
  4993 	"/
  4994         path := self compressPath:pathName
  4994 	path := self compressPath:pathName
  4995     ].
  4995     ].
  4996     ^ path.
  4996     ^ path.
  4997 
  4997 
  4998     "
  4998     "
  4999      OperatingSystem pathNameOf:'.'
  4999      OperatingSystem pathNameOf:'.'
  5025      from what you expect."
  5025      from what you expect."
  5026 
  5026 
  5027 %{  /* xxSTACK: 16000 */
  5027 %{  /* xxSTACK: 16000 */
  5028 
  5028 
  5029     if (__isStringLike(aPathName)) {
  5029     if (__isStringLike(aPathName)) {
  5030         char nameBuffer[MAXPATHLEN + 1 + MAXPATHLEN + 1];
  5030 	char nameBuffer[MAXPATHLEN + 1 + MAXPATHLEN + 1];
  5031         char *pFinal;
  5031 	char *pFinal;
  5032         int rslt;
  5032 	int rslt;
  5033 
  5033 
  5034 #ifdef DO_WRAP_CALLS
  5034 #ifdef DO_WRAP_CALLS
  5035         char _aPathName[MAXPATHLEN];
  5035 	char _aPathName[MAXPATHLEN];
  5036 
  5036 
  5037         strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  5037 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  5038         do {
  5038 	do {
  5039             __threadErrno = 0;
  5039 	    __threadErrno = 0;
  5040             rslt = STX_API_CALL4( "GetFullPathName", GetFullPathName, _aPathName, sizeof(nameBuffer), nameBuffer, &pFinal);
  5040 	    rslt = STX_API_CALL4( "GetFullPathName", GetFullPathName, _aPathName, sizeof(nameBuffer), nameBuffer, &pFinal);
  5041         } while ((rslt < 0) && (__threadErrno == EINTR));
  5041 	} while ((rslt < 0) && (__threadErrno == EINTR));
  5042 #else
  5042 #else
  5043         rslt = GetFullPathName(__stringVal(aPathName), sizeof(nameBuffer), nameBuffer, &pFinal);
  5043 	rslt = GetFullPathName(__stringVal(aPathName), sizeof(nameBuffer), nameBuffer, &pFinal);
  5044 #endif
  5044 #endif
  5045 
  5045 
  5046         if (rslt > 0) {
  5046 	if (rslt > 0) {
  5047             /*
  5047 	    /*
  5048              * Attention: GetLongPathName is not available on old NT4.0/W95/W98
  5048 	     * Attention: GetLongPathName is not available on old NT4.0/W95/W98
  5049              */
  5049 	     */
  5050             static FARPROC entry = NULL;
  5050 	    static FARPROC entry = NULL;
  5051 #ifdef NO_NT4_0_COMPATIBILITY
  5051 #ifdef NO_NT4_0_COMPATIBILITY
  5052             entry = (FARPROC) GetLongPathName;
  5052 	    entry = (FARPROC) GetLongPathName;
  5053 #else
  5053 #else
  5054             if (entry == NULL) {
  5054 	    if (entry == NULL) {
  5055                 entry = __get_KERNEL32_functionAddress("GetLongPathNameA");
  5055 		entry = __get_KERNEL32_functionAddress("GetLongPathNameA");
  5056             }
  5056 	    }
  5057 #endif /* NO_NT4_0_COMPATIBILITY */
  5057 #endif /* NO_NT4_0_COMPATIBILITY */
  5058 
  5058 
  5059             if (entry) {
  5059 	    if (entry) {
  5060 #ifdef DO_WRAP_CALLS
  5060 #ifdef DO_WRAP_CALLS
  5061                 do {
  5061 		do {
  5062                     __threadErrno = 0;
  5062 		    __threadErrno = 0;
  5063                     rslt = STX_API_CALL3( "GetLongPathName", entry, nameBuffer, nameBuffer, sizeof(nameBuffer));
  5063 		    rslt = STX_API_CALL3( "GetLongPathName", entry, nameBuffer, nameBuffer, sizeof(nameBuffer));
  5064                 } while ((rslt < 0) && (__threadErrno == EINTR));
  5064 		} while ((rslt < 0) && (__threadErrno == EINTR));
  5065 #else
  5065 #else
  5066                 rslt = (*entry)(nameBuffer, nameBuffer, sizeof(nameBuffer));
  5066 		rslt = (*entry)(nameBuffer, nameBuffer, sizeof(nameBuffer));
  5067 #endif
  5067 #endif
  5068             }
  5068 	    }
  5069         }
  5069 	}
  5070         if (rslt > 0) {
  5070 	if (rslt > 0) {
  5071             RETURN ( __MKSTRING(nameBuffer) );
  5071 	    RETURN ( __MKSTRING(nameBuffer) );
  5072         }
  5072 	}
  5073         __threadErrno = __WIN32_ERR(GetLastError());
  5073 	__threadErrno = __WIN32_ERR(GetLastError());
  5074     }
  5074     }
  5075 %}.
  5075 %}.
  5076     ^ nil
  5076     ^ nil
  5077 "
  5077 "
  5078 self primPathNameOf:'.'
  5078 self primPathNameOf:'.'
  5084 
  5084 
  5085 %{
  5085 %{
  5086     int ret;
  5086     int ret;
  5087 
  5087 
  5088     if (__isString(aPathName)) {
  5088     if (__isString(aPathName)) {
  5089         char _aPathName[MAXPATHLEN];
  5089 	char _aPathName[MAXPATHLEN];
  5090 
  5090 
  5091         strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  5091 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  5092         ret = STX_API_CALL2( "SetFileAttributes", SetFileAttributes, _aPathName, FILE_ATTRIBUTE_HIDDEN );
  5092 	ret = STX_API_CALL2( "SetFileAttributes", SetFileAttributes, _aPathName, FILE_ATTRIBUTE_HIDDEN );
  5093 
  5093 
  5094         if (ret != 0) {
  5094 	if (ret != 0) {
  5095             __threadErrno = __WIN32_ERR(GetLastError());
  5095 	    __threadErrno = __WIN32_ERR(GetLastError());
  5096         }
  5096 	}
  5097 
  5097 
  5098         RETURN (true);
  5098 	RETURN (true);
  5099     }
  5099     }
  5100 %}.
  5100 %}.
  5101     ^ self primitiveFailed
  5101     ^ self primitiveFailed
  5102 !
  5102 !
  5103 
  5103 
  5110 
  5110 
  5111 %{
  5111 %{
  5112     int ret;
  5112     int ret;
  5113 
  5113 
  5114     if (__isString(aPathName)) {
  5114     if (__isString(aPathName)) {
  5115         char _aPathName[MAXPATHLEN];
  5115 	char _aPathName[MAXPATHLEN];
  5116 
  5116 
  5117         strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  5117 	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
  5118         ret = STX_API_CALL2( "SetFileAttributes", SetFileAttributes, _aPathName, FILE_ATTRIBUTE_NORMAL );
  5118 	ret = STX_API_CALL2( "SetFileAttributes", SetFileAttributes, _aPathName, FILE_ATTRIBUTE_NORMAL );
  5119 
  5119 
  5120         if (ret != 0) {
  5120 	if (ret != 0) {
  5121             __threadErrno = __WIN32_ERR(GetLastError());
  5121 	    __threadErrno = __WIN32_ERR(GetLastError());
  5122         }
  5122 	}
  5123 
  5123 
  5124         RETURN (true);
  5124 	RETURN (true);
  5125     }
  5125     }
  5126 %}.
  5126 %}.
  5127     ^ self primitiveFailed
  5127     ^ self primitiveFailed
  5128 !
  5128 !
  5129 
  5129 
  5130 timeOfLastAccess:aPathName
  5130 timeOfLastAccess:aPathName
  5131     "return the time, when the file was last accessed.
  5131     "return the time, when the file was last accessed.
  5132      For nonexistent files, nil is returned."
  5132      For nonexistent files, nil is returned."
  5133 
  5133 
  5134     "could be implemented as:
  5134     "could be implemented as:
  5135         (self infoOf:aPathName) accessed
  5135 	(self infoOf:aPathName) accessed
  5136     "
  5136     "
  5137     | i|
  5137     | i|
  5138 
  5138 
  5139     i := self infoOf:aPathName.
  5139     i := self infoOf:aPathName.
  5140     i notNil ifTrue:[^ i accessTime].
  5140     i notNil ifTrue:[^ i accessTime].
  5148 timeOfLastChange:aPathName
  5148 timeOfLastChange:aPathName
  5149     "return the time, when the file was last changed.
  5149     "return the time, when the file was last changed.
  5150      For nonexistent files, nil is returned."
  5150      For nonexistent files, nil is returned."
  5151 
  5151 
  5152     "could be implemented as:
  5152     "could be implemented as:
  5153         (self infoOf:aPathName) modified
  5153 	(self infoOf:aPathName) modified
  5154     "
  5154     "
  5155 
  5155 
  5156     | i|
  5156     | i|
  5157 
  5157 
  5158     i := self infoOf:aPathName.
  5158     i := self infoOf:aPathName.
  5171 
  5171 
  5172     |i|
  5172     |i|
  5173 
  5173 
  5174     "
  5174     "
  5175      this could have been implemented as:
  5175      this could have been implemented as:
  5176         (self infoOf:aPathName) type
  5176 	(self infoOf:aPathName) type
  5177     "
  5177     "
  5178 
  5178 
  5179     i := self infoOf:aPathName.
  5179     i := self infoOf:aPathName.
  5180     i notNil ifTrue:[^ i type].
  5180     i notNil ifTrue:[^ i type].
  5181     ^ nil.
  5181     ^ nil.
  5194      Not all OperatingSystem support/use volumes; on unix,
  5194      Not all OperatingSystem support/use volumes; on unix,
  5195      this always returns an empty string."
  5195      this always returns an empty string."
  5196 
  5196 
  5197     aPathString size < 2 ifTrue:[^ ''].
  5197     aPathString size < 2 ifTrue:[^ ''].
  5198     (aPathString at:2) == $: ifTrue:[
  5198     (aPathString at:2) == $: ifTrue:[
  5199         ^ (aPathString at:1) asString.
  5199 	^ (aPathString at:1) asString.
  5200     ].
  5200     ].
  5201     ^ ''
  5201     ^ ''
  5202 ! !
  5202 ! !
  5203 
  5203 
  5204 !Win32OperatingSystem class methodsFor:'help support'!
  5204 !Win32OperatingSystem class methodsFor:'help support'!
  5209      html documents, pdf documents etc."
  5209      html documents, pdf documents etc."
  5210 
  5210 
  5211     |result|
  5211     |result|
  5212 
  5212 
  5213     Error
  5213     Error
  5214         handle:[:ex |
  5214 	handle:[:ex |
  5215             self halt
  5215 	    self halt
  5216         ] do:[
  5216 	] do:[
  5217             |filename|
  5217 	    |filename|
  5218 
  5218 
  5219             filename := aFilenameOrString asFilename.
  5219 	    filename := aFilenameOrString asFilename.
  5220             result := self
  5220 	    result := self
  5221                 shellExecute:nil
  5221 		shellExecute:nil
  5222                 lpOperation:'open'
  5222 		lpOperation:'open'
  5223                 lpFile:filename pathName
  5223 		lpFile:filename pathName
  5224                 lpParameters:nil
  5224 		lpParameters:nil
  5225                 lpDirectory:filename directory pathName
  5225 		lpDirectory:filename directory pathName
  5226                 nShowCmd:#SW_SHOWNORMAL.
  5226 		nShowCmd:#SW_SHOWNORMAL.
  5227             ^ self.
  5227 	    ^ self.
  5228         ]
  5228 	]
  5229 
  5229 
  5230     "
  5230     "
  5231      self openDocumentationFilename: 'C:\WINDOWS\Help\clipbrd.chm' asFilename
  5231      self openDocumentationFilename: 'C:\WINDOWS\Help\clipbrd.chm' asFilename
  5232      self openDocumentationFilename: Filename currentDirectory
  5232      self openDocumentationFilename: Filename currentDirectory
  5233     "
  5233     "
  5280     "this is a test method;
  5280     "this is a test method;
  5281      For testing double CTRL-C in blocking primitives"
  5281      For testing double CTRL-C in blocking primitives"
  5282 
  5282 
  5283 %{
  5283 %{
  5284     while(1) {
  5284     while(1) {
  5285         console_printf("blocking...");
  5285 	console_printf("blocking...");
  5286         Sleep(50);
  5286 	Sleep(50);
  5287     }
  5287     }
  5288 %}.
  5288 %}.
  5289     "
  5289     "
  5290      OperatingSystem blockingTest
  5290      OperatingSystem blockingTest
  5291     "
  5291     "
  5295     "this is a test method;
  5295     "this is a test method;
  5296      For testing double CTRL-C in blocking primitives"
  5296      For testing double CTRL-C in blocking primitives"
  5297 
  5297 
  5298 %{
  5298 %{
  5299     while(1) {
  5299     while(1) {
  5300         console_printf("blocking...");
  5300 	console_printf("blocking...");
  5301         STX_API_CALL1("Sleep", Sleep, 50);
  5301 	STX_API_CALL1("Sleep", Sleep, 50);
  5302     }
  5302     }
  5303 %}.
  5303 %}.
  5304     "
  5304     "
  5305      OperatingSystem blockingTest2
  5305      OperatingSystem blockingTest2
  5306     "
  5306     "
  5318 
  5318 
  5319 %{  /* NOCONTEXT */
  5319 %{  /* NOCONTEXT */
  5320 
  5320 
  5321     if (__isSmallInteger(signalNumber)) {
  5321     if (__isSmallInteger(signalNumber)) {
  5322 #ifdef SIG_DFL
  5322 #ifdef SIG_DFL
  5323         signal(__intVal(signalNumber), SIG_DFL);
  5323 	signal(__intVal(signalNumber), SIG_DFL);
  5324         RETURN (self);
  5324 	RETURN (self);
  5325 #endif
  5325 #endif
  5326     }
  5326     }
  5327 %}.
  5327 %}.
  5328     "
  5328     "
  5329      this error is triggered on non-integer argument
  5329      this error is triggered on non-integer argument
  5362      Use only for fully debugged stand alone applications."
  5362      Use only for fully debugged stand alone applications."
  5363 
  5363 
  5364 %{  /* NOCONTEXT */
  5364 %{  /* NOCONTEXT */
  5365 
  5365 
  5366     if (__isSmallInteger(signalNumber)) {
  5366     if (__isSmallInteger(signalNumber)) {
  5367         int sigNo = __intVal(signalNumber);
  5367 	int sigNo = __intVal(signalNumber);
  5368 
  5368 
  5369         if (sigNo == 0) {
  5369 	if (sigNo == 0) {
  5370             RETURN (self);
  5370 	    RETURN (self);
  5371         }
  5371 	}
  5372 #ifdef SIG_IGN
  5372 #ifdef SIG_IGN
  5373         signal(sigNo, SIG_IGN);
  5373 	signal(sigNo, SIG_IGN);
  5374         RETURN (self);
  5374 	RETURN (self);
  5375 #endif
  5375 #endif
  5376     }
  5376     }
  5377 %}.
  5377 %}.
  5378     "
  5378     "
  5379      this error is triggered on non-integer argument
  5379      this error is triggered on non-integer argument
  5390 !
  5390 !
  5391 
  5391 
  5392 disableTimer
  5392 disableTimer
  5393     "disable timer interrupts.
  5393     "disable timer interrupts.
  5394      WARNING:
  5394      WARNING:
  5395         the system will not operate correctly with timer interrupts
  5395 	the system will not operate correctly with timer interrupts
  5396         disabled, because no scheduling or timeouts are possible."
  5396 	disabled, because no scheduling or timeouts are possible."
  5397 
  5397 
  5398 %{  /* NOCONTEXT */
  5398 %{  /* NOCONTEXT */
  5399 
  5399 
  5400     extern void __win32ClearTimer();
  5400     extern void __win32ClearTimer();
  5401 
  5401 
  5527      && ((sigNr = __intVal(signalNumber)) >= 0)
  5527      && ((sigNr = __intVal(signalNumber)) >= 0)
  5528 #ifdef SIG_LIMIT
  5528 #ifdef SIG_LIMIT
  5529      &&  (sigNr <= SIG_LIMIT)
  5529      &&  (sigNr <= SIG_LIMIT)
  5530 #endif
  5530 #endif
  5531     ) {
  5531     ) {
  5532         /*
  5532 	/*
  5533          * standard signals are forced into standard handlers
  5533 	 * standard signals are forced into standard handlers
  5534          * - all others go into general signalInterrupt
  5534 	 * - all others go into general signalInterrupt
  5535          */
  5535 	 */
  5536 #if defined(SIGPOLL) && defined(SIGIO)
  5536 #if defined(SIGPOLL) && defined(SIGIO)
  5537         if (sigNr == SIGPOLL)
  5537 	if (sigNr == SIGPOLL)
  5538             sigNr = SIGIO;
  5538 	    sigNr = SIGIO;
  5539 #endif
  5539 #endif
  5540         switch (sigNr) {
  5540 	switch (sigNr) {
  5541             case 0:
  5541 	    case 0:
  5542                 /* enabling a non-supported signal */
  5542 		/* enabling a non-supported signal */
  5543                 RETURN (self);
  5543 		RETURN (self);
  5544 
  5544 
  5545 #ifdef SIGBREAK
  5545 #ifdef SIGBREAK
  5546             case SIGBREAK:
  5546 	    case SIGBREAK:
  5547 #endif
  5547 #endif
  5548 #ifdef SIGINT
  5548 #ifdef SIGINT
  5549             case SIGINT:
  5549 	    case SIGINT:
  5550 #endif
  5550 #endif
  5551 #ifdef SIGQUIT
  5551 #ifdef SIGQUIT
  5552             case SIGQUIT:
  5552 	    case SIGQUIT:
  5553 #endif
  5553 #endif
  5554 #ifdef SIGNALDEBUGWIN32
  5554 #ifdef SIGNALDEBUGWIN32
  5555                 console_printf("ConsoleSignal %d\n",sigNr);
  5555 		console_printf("ConsoleSignal %d\n",sigNr);
  5556 #endif
  5556 #endif
  5557                 SetConsoleCtrlHandler((PHANDLER_ROUTINE)__signalUserInterruptWIN32,TRUE);
  5557 		SetConsoleCtrlHandler((PHANDLER_ROUTINE)__signalUserInterruptWIN32,TRUE);
  5558                 RETURN (self);
  5558 		RETURN (self);
  5559 #ifdef SIGFPE
  5559 #ifdef SIGFPE
  5560             case SIGFPE:
  5560 	    case SIGFPE:
  5561                 handler = __signalFpExceptionInterrupt;
  5561 		handler = __signalFpExceptionInterrupt;
  5562                 break;
  5562 		break;
  5563 #endif
  5563 #endif
  5564 
  5564 
  5565 #ifdef SIGPIPE
  5565 #ifdef SIGPIPE
  5566             case SIGPIPE:
  5566 	    case SIGPIPE:
  5567                 handler = __signalPIPEInterrupt;
  5567 		handler = __signalPIPEInterrupt;
  5568                 break;
  5568 		break;
  5569 #endif
  5569 #endif
  5570 #ifdef SIGBUS
  5570 #ifdef SIGBUS
  5571             case SIGBUS:
  5571 	    case SIGBUS:
  5572                 handler = __signalBUSInterrupt;
  5572 		handler = __signalBUSInterrupt;
  5573                 break;
  5573 		break;
  5574 #endif
  5574 #endif
  5575 #ifdef SIGSEGV
  5575 #ifdef SIGSEGV
  5576             case SIGSEGV:
  5576 	    case SIGSEGV:
  5577                 handler = __signalSEGVInterrupt;
  5577 		handler = __signalSEGVInterrupt;
  5578                 break;
  5578 		break;
  5579 #endif
  5579 #endif
  5580 #ifdef SIGILL
  5580 #ifdef SIGILL
  5581             case SIGILL:
  5581 	    case SIGILL:
  5582                 handler = __signalTrapInterrupt;
  5582 		handler = __signalTrapInterrupt;
  5583                 break;
  5583 		break;
  5584 #endif
  5584 #endif
  5585 #ifdef SIGEMT
  5585 #ifdef SIGEMT
  5586             case SIGEMT:
  5586 	    case SIGEMT:
  5587                 handler = __signalTrapInterrupt;
  5587 		handler = __signalTrapInterrupt;
  5588                 break;
  5588 		break;
  5589 #endif
  5589 #endif
  5590 #ifdef SIGIO
  5590 #ifdef SIGIO
  5591             case SIGIO:
  5591 	    case SIGIO:
  5592                 handler = __signalIoInterrupt;
  5592 		handler = __signalIoInterrupt;
  5593                 break;
  5593 		break;
  5594 #endif
  5594 #endif
  5595 
  5595 
  5596 #ifdef CHILD_SIGNAL
  5596 #ifdef CHILD_SIGNAL
  5597             case CHILD_SIGNAL:
  5597 	    case CHILD_SIGNAL:
  5598                 handler = __signalChildInterrupt;
  5598 		handler = __signalChildInterrupt;
  5599                 break;
  5599 		break;
  5600 #endif
  5600 #endif
  5601 
  5601 
  5602             default:
  5602 	    default:
  5603                 handler = __signalInterrupt;
  5603 		handler = __signalInterrupt;
  5604                 break;
  5604 		break;
  5605         }
  5605 	}
  5606 
  5606 
  5607         {
  5607 	{
  5608 #ifdef HAS_SIGACTION
  5608 #ifdef HAS_SIGACTION
  5609             struct sigaction act;
  5609 	    struct sigaction act;
  5610 
  5610 
  5611             /*
  5611 	    /*
  5612              * Do not add SA_RESTART here. A signal can cause a
  5612 	     * Do not add SA_RESTART here. A signal can cause a
  5613              * thread switch, another thread can do a garbage collect
  5613 	     * thread switch, another thread can do a garbage collect
  5614              * and restarted system calls may write into old
  5614 	     * and restarted system calls may write into old
  5615              * (collected) addresses.
  5615 	     * (collected) addresses.
  5616              */
  5616 	     */
  5617 
  5617 
  5618             act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
  5618 	    act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
  5619             sigemptyset(&act.sa_mask);
  5619 	    sigemptyset(&act.sa_mask);
  5620             act.sa_handler = handler;
  5620 	    act.sa_handler = handler;
  5621             sigaction(sigNr, &act, 0);
  5621 	    sigaction(sigNr, &act, 0);
  5622 #else
  5622 #else
  5623 # ifdef HAS_SIGVEC
  5623 # ifdef HAS_SIGVEC
  5624             struct sigvec vec;
  5624 	    struct sigvec vec;
  5625 
  5625 
  5626             vec.sv_flags = SV_INTERRUPT;
  5626 	    vec.sv_flags = SV_INTERRUPT;
  5627             sigemptyset(&vec.sv_mask);
  5627 	    sigemptyset(&vec.sv_mask);
  5628             vec.sv_handler = handler;
  5628 	    vec.sv_handler = handler;
  5629             sigvec(sigNr, &vec, NULL);
  5629 	    sigvec(sigNr, &vec, NULL);
  5630 # else
  5630 # else
  5631 #  ifdef WIN32
  5631 #  ifdef WIN32
  5632 #   ifdef SIGNALDEBUGWIN32
  5632 #   ifdef SIGNALDEBUGWIN32
  5633             console_printf("signal %d can't change handler\n",sigNr);
  5633 	    console_printf("signal %d can't change handler\n",sigNr);
  5634 #   endif
  5634 #   endif
  5635 #  else
  5635 #  else
  5636             (void) signal(sigNr, handler);
  5636 	    (void) signal(sigNr, handler);
  5637 #  endif
  5637 #  endif
  5638 # endif
  5638 # endif
  5639 #endif
  5639 #endif
  5640         }
  5640 	}
  5641 
  5641 
  5642         /*
  5642 	/*
  5643          * maybe, we should Return the old enable-status
  5643 	 * maybe, we should Return the old enable-status
  5644          * as boolean here ...
  5644 	 * as boolean here ...
  5645          */
  5645 	 */
  5646         RETURN (self);
  5646 	RETURN (self);
  5647     }
  5647     }
  5648 %}.
  5648 %}.
  5649 
  5649 
  5650     "
  5650     "
  5651      this error is triggered on non-integer argument, or
  5651      this error is triggered on non-integer argument, or
  5659 
  5659 
  5660 %{  /* NOCONTEXT */
  5660 %{  /* NOCONTEXT */
  5661     extern void __win32SetTimer();
  5661     extern void __win32SetTimer();
  5662 
  5662 
  5663     if (__isSmallInteger(milliSeconds)) {
  5663     if (__isSmallInteger(milliSeconds)) {
  5664         __win32SetTimer( __intVal(milliSeconds) );
  5664 	__win32SetTimer( __intVal(milliSeconds) );
  5665         RETURN (true);
  5665 	RETURN (true);
  5666     }
  5666     }
  5667 %}.
  5667 %}.
  5668     ^ false
  5668     ^ false
  5669 !
  5669 !
  5670 
  5670 
  5680 killProcess:processId
  5680 killProcess:processId
  5681     "kill a process.
  5681     "kill a process.
  5682      The process terminates immediately and has no chance to perform any cleanup actions.
  5682      The process terminates immediately and has no chance to perform any cleanup actions.
  5683 
  5683 
  5684      WARNING: in order to avoid zombie processes (on unix),
  5684      WARNING: in order to avoid zombie processes (on unix),
  5685               you have to fetch the processes exitstatus with
  5685 	      you have to fetch the processes exitstatus with
  5686               OperatingSystem>>getStatusOfProcess:aProcessId."
  5686 	      OperatingSystem>>getStatusOfProcess:aProcessId."
  5687 
  5687 
  5688     self terminateProcess:processId
  5688     self terminateProcess:processId
  5689 !
  5689 !
  5690 
  5690 
  5691 sendSignal:signalNumber to:processId
  5691 sendSignal:signalNumber to:processId
  5693      Returns false if any error occurred, true otherwise.
  5693      Returns false if any error occurred, true otherwise.
  5694 
  5694 
  5695      Do not confuse UNIX signals with Smalltalk-Signals.
  5695      Do not confuse UNIX signals with Smalltalk-Signals.
  5696 
  5696 
  5697      WARNING: in order to avoid zombie processes (on unix),
  5697      WARNING: in order to avoid zombie processes (on unix),
  5698               you may have to fetch the processes exitstatus with
  5698 	      you may have to fetch the processes exitstatus with
  5699               OperatingSystem>>getStatusOfProcess:aProcessId
  5699 	      OperatingSystem>>getStatusOfProcess:aProcessId
  5700               if the signal terminates that process."
  5700 	      if the signal terminates that process."
  5701 
  5701 
  5702     "/
  5702     "/
  5703     "/ either invalid argument (non-integers)
  5703     "/ either invalid argument (non-integers)
  5704     "/ or not supported by OS
  5704     "/ or not supported by OS
  5705     "/
  5705     "/
  5708 
  5708 
  5709 terminateProcess:processHandle
  5709 terminateProcess:processHandle
  5710     "terminate a process.
  5710     "terminate a process.
  5711      The process has a chance to do some cleanup.
  5711      The process has a chance to do some cleanup.
  5712      WIN32:
  5712      WIN32:
  5713          Under unix, we have terminateProcess, which does a soft
  5713 	 Under unix, we have terminateProcess, which does a soft
  5714          terminate (giving the process a chance to cleanup) and
  5714 	 terminate (giving the process a chance to cleanup) and
  5715          killProcess, which does a hard terminate.
  5715 	 killProcess, which does a hard terminate.
  5716          Under WIN32, both (currently) use the TerminateProcess
  5716 	 Under WIN32, both (currently) use the TerminateProcess
  5717          function, which unconditionally causes a process to exit.
  5717 	 function, which unconditionally causes a process to exit.
  5718          I.e. under WIN32, the process has no chance to perform cleanup.
  5718 	 I.e. under WIN32, the process has no chance to perform cleanup.
  5719          Use it only in extreme circumstances. The state of
  5719 	 Use it only in extreme circumstances. The state of
  5720          global data maintained by dynamic-link libraries (DLLs)
  5720 	 global data maintained by dynamic-link libraries (DLLs)
  5721          may be compromised if TerminateProcess is used.
  5721 	 may be compromised if TerminateProcess is used.
  5722      TODO: send it a WM_QUIT instead, to allow for proper shutdown."
  5722      TODO: send it a WM_QUIT instead, to allow for proper shutdown."
  5723 
  5723 
  5724     self terminateProcess:processHandle exitCode:0
  5724     self terminateProcess:processHandle exitCode:0
  5725 !
  5725 !
  5726 
  5726 
  5727 terminateProcess:processHandle exitCode:exitCode
  5727 terminateProcess:processHandle exitCode:exitCode
  5728     "terminate a process.
  5728     "terminate a process.
  5729      The process should have a chance to do some cleanup.
  5729      The process should have a chance to do some cleanup.
  5730      WIN32:
  5730      WIN32:
  5731          Under unix, we have terminateProcess, which does a soft
  5731 	 Under unix, we have terminateProcess, which does a soft
  5732          terminate (giving the process a chance to cleanup) and
  5732 	 terminate (giving the process a chance to cleanup) and
  5733          killProcess, which does a hard terminate.
  5733 	 killProcess, which does a hard terminate.
  5734          Under WIN32, both (currently) use the TerminateProcess
  5734 	 Under WIN32, both (currently) use the TerminateProcess
  5735          function, which unconditionally causes a process to exit.
  5735 	 function, which unconditionally causes a process to exit.
  5736          I.e. under WIN32, the process has no chance to perform cleanup.
  5736 	 I.e. under WIN32, the process has no chance to perform cleanup.
  5737          Use it only in extreme circumstances. The state of
  5737 	 Use it only in extreme circumstances. The state of
  5738          global data maintained by dynamic-link libraries (DLLs)
  5738 	 global data maintained by dynamic-link libraries (DLLs)
  5739          may be compromised if TerminateProcess is used.
  5739 	 may be compromised if TerminateProcess is used.
  5740      TODO: send it a WM_QUIT instead, to allow for proper shutdown."
  5740      TODO: send it a WM_QUIT instead, to allow for proper shutdown."
  5741 
  5741 
  5742 %{
  5742 %{
  5743     if (__isExternalAddressLike(processHandle) ) {
  5743     if (__isExternalAddressLike(processHandle) ) {
  5744         HANDLE hProcess = _HANDLEVal(processHandle);
  5744 	HANDLE hProcess = _HANDLEVal(processHandle);
  5745 
  5745 
  5746 #ifdef PROCESS1DEBUGWIN32
  5746 #ifdef PROCESS1DEBUGWIN32
  5747         console_printf("TerminateProcess handle: %x\n", hProcess);
  5747 	console_printf("TerminateProcess handle: %x\n", hProcess);
  5748 #endif
  5748 #endif
  5749         if (hProcess != 0) {
  5749 	if (hProcess != 0) {
  5750             TerminateProcess(hProcess, __intVal(exitCode));
  5750 	    TerminateProcess(hProcess, __intVal(exitCode));
  5751         } else {
  5751 	} else {
  5752             console_fprintf(stderr, "Win32OS [warning]: wrong hProcess in TerminateProcess\n");
  5752 	    console_fprintf(stderr, "Win32OS [warning]: wrong hProcess in TerminateProcess\n");
  5753         }
  5753 	}
  5754     } else {
  5754     } else {
  5755         console_fprintf(stderr, "Win32OS [warning]: wrong processHandle in TerminateProcess\n");
  5755 	console_fprintf(stderr, "Win32OS [warning]: wrong processHandle in TerminateProcess\n");
  5756     }
  5756     }
  5757 %}
  5757 %}
  5758 
  5758 
  5759     "Modified: / 28.12.1995 / 15:05:37 / stefan"
  5759     "Modified: / 28.12.1995 / 15:05:37 / stefan"
  5760     "Modified: / 27.1.1998 / 20:05:47 / cg"
  5760     "Modified: / 27.1.1998 / 20:05:47 / cg"
  5762 
  5762 
  5763 terminateProcessGroup:processGroupHandle
  5763 terminateProcessGroup:processGroupHandle
  5764     "terminate a process group.
  5764     "terminate a process group.
  5765      The processes should have a chance to do some cleanup.
  5765      The processes should have a chance to do some cleanup.
  5766      WIN32:
  5766      WIN32:
  5767          The processGroup is terminated by sending it a CTRL-C
  5767 	 The processGroup is terminated by sending it a CTRL-C
  5768          using GenerateConsoleCtrlEvent."
  5768 	 using GenerateConsoleCtrlEvent."
  5769 
  5769 
  5770 %{
  5770 %{
  5771     if (__isExternalAddressLike(processGroupHandle) ) {
  5771     if (__isExternalAddressLike(processGroupHandle) ) {
  5772         HANDLE hProcessGroup = _HANDLEVal(processGroupHandle);
  5772 	HANDLE hProcessGroup = _HANDLEVal(processGroupHandle);
  5773         DWORD processGroupId;
  5773 	DWORD processGroupId;
  5774 
  5774 
  5775         if (hProcessGroup != (HANDLE)0) {
  5775 	if (hProcessGroup != (HANDLE)0) {
  5776             processGroupId = __intVal( ((struct __Win32OperatingSystem__Win32ProcessHandle_struct *)(processGroupHandle))->pid );
  5776 	    processGroupId = __intVal( ((struct __Win32OperatingSystem__Win32ProcessHandle_struct *)(processGroupHandle))->pid );
  5777 
  5777 
  5778 #ifdef PROCESS1DEBUGWIN32
  5778 #ifdef PROCESS1DEBUGWIN32
  5779             console_printf("TerminateProcessGroup processGroupHandle: %x (%d)\n", hProcessGroup, processGroupId);
  5779 	    console_printf("TerminateProcessGroup processGroupHandle: %x (%d)\n", hProcessGroup, processGroupId);
  5780 #endif
  5780 #endif
  5781             GenerateConsoleCtrlEvent(CTRL_C_EVENT, processGroupId);
  5781 	    GenerateConsoleCtrlEvent(CTRL_C_EVENT, processGroupId);
  5782         } else {
  5782 	} else {
  5783             console_fprintf(stderr, "Win32OS [warning]: wrong hProcessGroup in TerminateProcessGroup \n");
  5783 	    console_fprintf(stderr, "Win32OS [warning]: wrong hProcessGroup in TerminateProcessGroup \n");
  5784         }
  5784 	}
  5785     } else {
  5785     } else {
  5786         console_fprintf(stderr, "Win32OS [warning]: wrong processGroupHandle in TerminateProcessGroup \n");
  5786 	console_fprintf(stderr, "Win32OS [warning]: wrong processGroupHandle in TerminateProcessGroup \n");
  5787     }
  5787     }
  5788 %}
  5788 %}
  5789 ! !
  5789 ! !
  5790 
  5790 
  5791 !Win32OperatingSystem class methodsFor:'ipc support'!
  5791 !Win32OperatingSystem class methodsFor:'ipc support'!
  5808     sa.nLength = sizeof(SECURITY_ATTRIBUTES);
  5808     sa.nLength = sizeof(SECURITY_ATTRIBUTES);
  5809     sa.lpSecurityDescriptor = NULL;
  5809     sa.lpSecurityDescriptor = NULL;
  5810     sa.bInheritHandle = TRUE;
  5810     sa.bInheritHandle = TRUE;
  5811 
  5811 
  5812     if( ! CreatePipe( &pipeRead, &pipeWrite, &sa, 0 ) ) {
  5812     if( ! CreatePipe( &pipeRead, &pipeWrite, &sa, 0 ) ) {
  5813         @global(LastErrorNumber) = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
  5813 	@global(LastErrorNumber) = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
  5814         RETURN ( nil );
  5814 	RETURN ( nil );
  5815     }
  5815     }
  5816 
  5816 
  5817 #ifdef USE_HANDLES
  5817 #ifdef USE_HANDLES
  5818     fd1 = __MKEXTERNALADDRESS(pipeRead);
  5818     fd1 = __MKEXTERNALADDRESS(pipeRead);
  5819     fd2 = __MKEXTERNALADDRESS(pipeWrite);
  5819     fd2 = __MKEXTERNALADDRESS(pipeWrite);
  5827 # endif
  5827 # endif
  5828     fd1 = __mkSmallInteger(_open_osfhandle(pipeRead, O_BINARY));
  5828     fd1 = __mkSmallInteger(_open_osfhandle(pipeRead, O_BINARY));
  5829     fd2 = __mkSmallInteger(_open_osfhandle(pipeWrite, O_BINARY));
  5829     fd2 = __mkSmallInteger(_open_osfhandle(pipeWrite, O_BINARY));
  5830 #endif
  5830 #endif
  5831 %}.
  5831 %}.
  5832     fd1 notNil ifTrue:[
  5832     (fd1 notNil and:[fd2 notNil]) ifTrue:[
  5833         ^ Array with:fd1 with:fd2.
  5833 	(fd1 ~~ -1 and:[fd2 ~~ -1]) ifTrue:[
       
  5834 	    ^ Array with:fd1 with:fd2.
       
  5835 	].
  5834     ].
  5836     ].
  5835     ^ nil
  5837     ^ nil
  5836 ! !
  5838 ! !
  5837 
  5839 
  5838 !Win32OperatingSystem class methodsFor:'misc'!
  5840 !Win32OperatingSystem class methodsFor:'misc'!
  5839 
  5841 
  5840 closePid:pid
  5842 closePid:pid
  5841     "free pid resource"
  5843     "free pid resource"
  5842 %{
  5844 %{
  5843     if (__isExternalAddressLike(pid) ) {
  5845     if (__isExternalAddressLike(pid) ) {
  5844         HANDLE __pid = _HANDLEVal(pid);
  5846 	HANDLE __pid = _HANDLEVal(pid);
  5845 
  5847 
  5846         if (__pid != 0) {
  5848 	if (__pid != 0) {
  5847 #ifdef PROCESSDEBUGWIN32
  5849 #ifdef PROCESSDEBUGWIN32
  5848             console_printf("Close ProcessHandle %x\n", __pid);
  5850 	    console_printf("Close ProcessHandle %x\n", __pid);
  5849 #endif
  5851 #endif
  5850             CloseHandle(__pid);
  5852 	    CloseHandle(__pid);
  5851             _HANDLEVal(pid) = 0;
  5853 	    _HANDLEVal(pid) = 0;
  5852         }
  5854 	}
  5853     }
  5855     }
  5854 %}.
  5856 %}.
  5855     ^ true.
  5857     ^ true.
  5856 
  5858 
  5857     "Created: 28.1.1998 / 14:23:04 / md"
  5859     "Created: 28.1.1998 / 14:23:04 / md"
  5858     "Modified: 28.1.1998 / 14:27:18 / md"
  5860     "Modified: 28.1.1998 / 14:27:18 / md"
  5859 !
  5861 !
  5860 
  5862 
  5861 getPrivateProfileString:appNameString key:keyNameString default:defaultString fileName:fileName
  5863 getPrivateProfileString:appNameString key:keyNameString default:defaultString fileName:fileName
  5862     ^ self
  5864     ^ self
  5863         getProfileString:appNameString key:keyNameString default:defaultString
  5865 	getProfileString:appNameString key:keyNameString default:defaultString
  5864         fileName:fileName private:true
  5866 	fileName:fileName private:true
  5865 
  5867 
  5866     "Modified: / 27-07-2006 / 11:57:03 / fm"
  5868     "Modified: / 27-07-2006 / 11:57:03 / fm"
  5867 !
  5869 !
  5868 
  5870 
  5869 getProfileString:appNameString key:keyNameString default:defaultString
  5871 getProfileString:appNameString key:keyNameString default:defaultString
  5877     int bufferSize = sizeof(quickBuffer);
  5879     int bufferSize = sizeof(quickBuffer);
  5878     int nChars;
  5880     int nChars;
  5879     OBJ retVal;
  5881     OBJ retVal;
  5880 
  5882 
  5881     if (__isString(appNameString)) {
  5883     if (__isString(appNameString)) {
  5882         __appNameString = __stringVal(appNameString);
  5884 	__appNameString = __stringVal(appNameString);
  5883     } else if (appNameString != nil)
  5885     } else if (appNameString != nil)
  5884         goto primitiveFail;
  5886 	goto primitiveFail;
  5885 
  5887 
  5886     if (__isString(keyNameString)) {
  5888     if (__isString(keyNameString)) {
  5887         __keyNameString = __stringVal(keyNameString);
  5889 	__keyNameString = __stringVal(keyNameString);
  5888     } else if (keyNameString != nil)
  5890     } else if (keyNameString != nil)
  5889         goto primitiveFail;
  5891 	goto primitiveFail;
  5890 
  5892 
  5891     if (__isString(defaultString)) {
  5893     if (__isString(defaultString)) {
  5892         __defaultString = __stringVal(defaultString);
  5894 	__defaultString = __stringVal(defaultString);
  5893     } else if (defaultString != nil)
  5895     } else if (defaultString != nil)
  5894         goto primitiveFail;
  5896 	goto primitiveFail;
  5895 
  5897 
  5896     do {
  5898     do {
  5897         nChars = GetProfileString(__appNameString, __keyNameString, __defaultString, usedBuffer, bufferSize);
  5899 	nChars = GetProfileString(__appNameString, __keyNameString, __defaultString, usedBuffer, bufferSize);
  5898         if (nChars >= 0) {
  5900 	if (nChars >= 0) {
  5899             if (nChars != bufferSize-1) {
  5901 	    if (nChars != bufferSize-1) {
  5900                 retVal = __MKSTRING_L(usedBuffer, nChars);
  5902 		retVal = __MKSTRING_L(usedBuffer, nChars);
  5901                 if (usedBuffer != quickBuffer) free(usedBuffer);
  5903 		if (usedBuffer != quickBuffer) free(usedBuffer);
  5902                 RETURN (retVal);
  5904 		RETURN (retVal);
  5903             }
  5905 	    }
  5904 
  5906 
  5905             {
  5907 	    {
  5906                 /* use a bigger buffer */
  5908 		/* use a bigger buffer */
  5907                 char *newBuffer;
  5909 		char *newBuffer;
  5908                 int newBufferSize = bufferSize * 2;
  5910 		int newBufferSize = bufferSize * 2;
  5909 
  5911 
  5910                 newBuffer = (char *)malloc( newBufferSize );
  5912 		newBuffer = (char *)malloc( newBufferSize );
  5911                 if (usedBuffer != quickBuffer) free(usedBuffer);
  5913 		if (usedBuffer != quickBuffer) free(usedBuffer);
  5912                 usedBuffer = newBuffer;
  5914 		usedBuffer = newBuffer;
  5913                 bufferSize = newBufferSize;
  5915 		bufferSize = newBufferSize;
  5914             }
  5916 	    }
  5915         }
  5917 	}
  5916 
  5918 
  5917     } while (nChars > 0);
  5919     } while (nChars > 0);
  5918     RETURN (nil);
  5920     RETURN (nil);
  5919   primitiveFail: ;
  5921   primitiveFail: ;
  5920 %}.
  5922 %}.
  5935     int bufferSize = sizeof(quickBuffer);
  5937     int bufferSize = sizeof(quickBuffer);
  5936     int nChars;
  5938     int nChars;
  5937     OBJ retVal;
  5939     OBJ retVal;
  5938 
  5940 
  5939     if (__isString(appNameString)) {
  5941     if (__isString(appNameString)) {
  5940         __appNameString = __stringVal(appNameString);
  5942 	__appNameString = __stringVal(appNameString);
  5941     } else if (appNameString != nil)
  5943     } else if (appNameString != nil)
  5942         goto primitiveFail;
  5944 	goto primitiveFail;
  5943 
  5945 
  5944     if (__isString(keyNameString)) {
  5946     if (__isString(keyNameString)) {
  5945         __keyNameString = __stringVal(keyNameString);
  5947 	__keyNameString = __stringVal(keyNameString);
  5946     } else if (keyNameString != nil)
  5948     } else if (keyNameString != nil)
  5947         goto primitiveFail;
  5949 	goto primitiveFail;
  5948 
  5950 
  5949     if (__isString(defaultString)) {
  5951     if (__isString(defaultString)) {
  5950         __defaultString = __stringVal(defaultString);
  5952 	__defaultString = __stringVal(defaultString);
  5951     } else if (defaultString != nil)
  5953     } else if (defaultString != nil)
  5952         goto primitiveFail;
  5954 	goto primitiveFail;
  5953 
  5955 
  5954     if (private == true) {
  5956     if (private == true) {
  5955         if (! __isString(fileName)) goto primitiveFail;
  5957 	if (! __isString(fileName)) goto primitiveFail;
  5956         __fileName = __stringVal(fileName);
  5958 	__fileName = __stringVal(fileName);
  5957     }
  5959     }
  5958 
  5960 
  5959     do {
  5961     do {
  5960         if (private == true) {
  5962 	if (private == true) {
  5961             nChars = GetPrivateProfileString(__appNameString, __keyNameString, __defaultString, usedBuffer, bufferSize, __fileName);
  5963 	    nChars = GetPrivateProfileString(__appNameString, __keyNameString, __defaultString, usedBuffer, bufferSize, __fileName);
  5962         } else {
  5964 	} else {
  5963             nChars = GetProfileString(__appNameString, __keyNameString, __defaultString, usedBuffer, bufferSize);
  5965 	    nChars = GetProfileString(__appNameString, __keyNameString, __defaultString, usedBuffer, bufferSize);
  5964         }
  5966 	}
  5965         if (nChars >= 0) {
  5967 	if (nChars >= 0) {
  5966             if (nChars != bufferSize-1) {
  5968 	    if (nChars != bufferSize-1) {
  5967                 retVal = __MKSTRING_L(usedBuffer, nChars);
  5969 		retVal = __MKSTRING_L(usedBuffer, nChars);
  5968                 if (usedBuffer != quickBuffer) free(usedBuffer);
  5970 		if (usedBuffer != quickBuffer) free(usedBuffer);
  5969                 RETURN (retVal);
  5971 		RETURN (retVal);
  5970             }
  5972 	    }
  5971 
  5973 
  5972             {
  5974 	    {
  5973                 /* use a bigger buffer */
  5975 		/* use a bigger buffer */
  5974                 char *newBuffer;
  5976 		char *newBuffer;
  5975                 int newBufferSize = bufferSize * 2;
  5977 		int newBufferSize = bufferSize * 2;
  5976 
  5978 
  5977                 newBuffer = (char *)malloc( newBufferSize );
  5979 		newBuffer = (char *)malloc( newBufferSize );
  5978                 if (usedBuffer != quickBuffer) free(usedBuffer);
  5980 		if (usedBuffer != quickBuffer) free(usedBuffer);
  5979                 usedBuffer = newBuffer;
  5981 		usedBuffer = newBuffer;
  5980                 bufferSize = newBufferSize;
  5982 		bufferSize = newBufferSize;
  5981             }
  5983 	    }
  5982         }
  5984 	}
  5983 
  5985 
  5984     } while (nChars > 0);
  5986     } while (nChars > 0);
  5985     RETURN (nil);
  5987     RETURN (nil);
  5986   primitiveFail: ;
  5988   primitiveFail: ;
  5987 %}.
  5989 %}.
  6006 
  6008 
  6007 writePrivateProfileString: appName keyName: keyName profileString: profString fileName: aString
  6009 writePrivateProfileString: appName keyName: keyName profileString: profString fileName: aString
  6008 
  6010 
  6009    ^self primWritePrivateProfileString: appName keyName: keyName profileString: profString fileName: aString
  6011    ^self primWritePrivateProfileString: appName keyName: keyName profileString: profString fileName: aString
  6010 
  6012 
  6011 "   
  6013 "
  6012     |profileStringToWrite recoveredProfileString|
  6014     |profileStringToWrite recoveredProfileString|
  6013     profileStringToWrite :=  'c:\vsw311'.
  6015     profileStringToWrite :=  'c:\vsw311'.
  6014     self writePrivateProfileString: 'PAV-Editor' keyName: 'ExportPath' profileString: profileStringToWrite fileName: 'C:\vsw311\dapas.ini'.
  6016     self writePrivateProfileString: 'PAV-Editor' keyName: 'ExportPath' profileString: profileStringToWrite fileName: 'C:\vsw311\dapas.ini'.
  6015     recoveredProfileString := self getProfileString:'PAV-Editor' key:'ExportPath' default:'@@@nil@@@' fileName:'C:\vsw311\dapas.ini' private:true.
  6017     recoveredProfileString := self getProfileString:'PAV-Editor' key:'ExportPath' default:'@@@nil@@@' fileName:'C:\vsw311\dapas.ini' private:true.
  6016     self assert: (profileStringToWrite = recoveredProfileString).
  6018     self assert: (profileStringToWrite = recoveredProfileString).
  6031 !
  6033 !
  6032 
  6034 
  6033 getDomainName
  6035 getDomainName
  6034     "return the domain this host is in.
  6036     "return the domain this host is in.
  6035      Notice:
  6037      Notice:
  6036         not all systems support this; on some, 'unknown' is returned."
  6038 	not all systems support this; on some, 'unknown' is returned."
  6037 
  6039 
  6038     |name idx hostName k|
  6040     |name idx hostName k|
  6039 
  6041 
  6040     DomainName notNil ifTrue:[
  6042     DomainName notNil ifTrue:[
  6041         ^ DomainName
  6043 	^ DomainName
  6042     ].
  6044     ].
  6043 
  6045 
  6044     name := self getEnvironment:'DOMAIN'.
  6046     name := self getEnvironment:'DOMAIN'.
  6045     name isNil ifTrue:[
  6047     name isNil ifTrue:[
  6046         name := self getEnvironment:'DOMAINNAME'.
  6048 	name := self getEnvironment:'DOMAINNAME'.
  6047     ].
  6049     ].
  6048 
  6050 
  6049     name isNil ifTrue:[
  6051     name isNil ifTrue:[
  6050         "/ sometimes, we can extract the domainName from the hostName ...
  6052 	"/ sometimes, we can extract the domainName from the hostName ...
  6051         hostName := self primGetHostName.
  6053 	hostName := self primGetHostName.
  6052         hostName notNil ifTrue:[
  6054 	hostName notNil ifTrue:[
  6053             idx := hostName indexOf:$..
  6055 	    idx := hostName indexOf:$..
  6054             idx ~~ 0 ifTrue:[
  6056 	    idx ~~ 0 ifTrue:[
  6055                 name := hostName copyFrom:idx+1.
  6057 		name := hostName copyFrom:idx+1.
  6056             ]
  6058 	    ]
  6057         ].
  6059 	].
  6058         name isNil ifTrue:[
  6060 	name isNil ifTrue:[
  6059             "/ ok, search the registry ...
  6061 	    "/ ok, search the registry ...
  6060 
  6062 
  6061             "/ under NT, it is found there ...
  6063 	    "/ under NT, it is found there ...
  6062             k := RegistryEntry key:'HKEY_LOCAL_MACHINE\System'.
  6064 	    k := RegistryEntry key:'HKEY_LOCAL_MACHINE\System'.
  6063             k notNil ifTrue:[
  6065 	    k notNil ifTrue:[
  6064                 k subKeysDo:[:subKey |
  6066 		k subKeysDo:[:subKey |
  6065                     subKey subKeysDo:[:subSubKey |
  6067 		    subKey subKeysDo:[:subSubKey |
  6066                         |tcp params|
  6068 			|tcp params|
  6067 
  6069 
  6068                         (subSubKey path asLowercase endsWith:'services') ifTrue:[
  6070 			(subSubKey path asLowercase endsWith:'services') ifTrue:[
  6069                             tcp := subSubKey subKeyNamed:'tcpip'.
  6071 			    tcp := subSubKey subKeyNamed:'tcpip'.
  6070                             tcp notNil ifTrue:[
  6072 			    tcp notNil ifTrue:[
  6071                                 params := tcp subKeyNamed:'parameters'.
  6073 				params := tcp subKeyNamed:'parameters'.
  6072                                 params notNil ifTrue:[
  6074 				params notNil ifTrue:[
  6073                                     name := params valueNamed:'Domain'.
  6075 				    name := params valueNamed:'Domain'.
  6074                                     params close.
  6076 				    params close.
  6075                                 ].
  6077 				].
  6076                                 tcp close.
  6078 				tcp close.
  6077                             ]
  6079 			    ]
  6078                         ]
  6080 			]
  6079                     ]
  6081 		    ]
  6080                 ]
  6082 		]
  6081             ].
  6083 	    ].
  6082         ].
  6084 	].
  6083         name isNil ifTrue:[
  6085 	name isNil ifTrue:[
  6084             "/ under Win95/Win98, it is found there ...
  6086 	    "/ under Win95/Win98, it is found there ...
  6085             k := RegistryEntry key:'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\MSTCP'.
  6087 	    k := RegistryEntry key:'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\MSTCP'.
  6086             k notNil ifTrue:[
  6088 	    k notNil ifTrue:[
  6087                 name := k valueNamed:'Domain'.
  6089 		name := k valueNamed:'Domain'.
  6088                 k close.
  6090 		k close.
  6089             ]
  6091 	    ]
  6090         ].
  6092 	].
  6091 
  6093 
  6092         name isNil ifTrue:[
  6094 	name isNil ifTrue:[
  6093             'Win32OperatingSystem [warning]: cannot find out domainname' errorPrintCR.
  6095 	    'Win32OperatingSystem [warning]: cannot find out domainname' errorPrintCR.
  6094             name := 'unknown'.
  6096 	    name := 'unknown'.
  6095         ]
  6097 	]
  6096     ].
  6098     ].
  6097     DomainName := name.
  6099     DomainName := name.
  6098     ^ name
  6100     ^ name
  6099 
  6101 
  6100     "
  6102     "
  6111 
  6113 
  6112 %{  /* NOCONTEXT */
  6114 %{  /* NOCONTEXT */
  6113     char *env;
  6115     char *env;
  6114 
  6116 
  6115     if (__isString(aStringOrSymbol) || __isSymbol(aStringOrSymbol)) {
  6117     if (__isString(aStringOrSymbol) || __isSymbol(aStringOrSymbol)) {
  6116         char buff[1024];
  6118 	char buff[1024];
  6117         int nNeeded;
  6119 	int nNeeded;
  6118         OBJ ret = nil;
  6120 	OBJ ret = nil;
  6119 
  6121 
  6120         nNeeded = GetEnvironmentVariable(__stringVal(aStringOrSymbol),
  6122 	nNeeded = GetEnvironmentVariable(__stringVal(aStringOrSymbol),
  6121                                    buff,
  6123 				   buff,
  6122                                    sizeof(buff));
  6124 				   sizeof(buff));
  6123         if (nNeeded > sizeof(buff)) {
  6125 	if (nNeeded > sizeof(buff)) {
  6124             char *buff2;
  6126 	    char *buff2;
  6125 
  6127 
  6126             buff2 = (char *)malloc(nNeeded);
  6128 	    buff2 = (char *)malloc(nNeeded);
  6127             GetEnvironmentVariable(__stringVal(aStringOrSymbol),
  6129 	    GetEnvironmentVariable(__stringVal(aStringOrSymbol),
  6128                                    buff2,
  6130 				   buff2,
  6129                                    nNeeded);
  6131 				   nNeeded);
  6130             ret = __MKSTRING(buff2);
  6132 	    ret = __MKSTRING(buff2);
  6131             free(buff2);
  6133 	    free(buff2);
  6132         } else {
  6134 	} else {
  6133             if (nNeeded > 0) {
  6135 	    if (nNeeded > 0) {
  6134                 ret = __MKSTRING(buff);
  6136 		ret = __MKSTRING(buff);
  6135             }
  6137 	    }
  6136         }
  6138 	}
  6137         RETURN (ret);
  6139 	RETURN (ret);
  6138     }
  6140     }
  6139 %}
  6141 %}
  6140 .
  6142 .
  6141     ^ nil
  6143     ^ nil
  6142 
  6144 
  6154 
  6156 
  6155 getHostName
  6157 getHostName
  6156     "return the hostname we are running on - if there is
  6158     "return the hostname we are running on - if there is
  6157      a HOST environment variable, we are much faster here ...
  6159      a HOST environment variable, we are much faster here ...
  6158      Notice:
  6160      Notice:
  6159         not all systems support this; on some, 'unknown' is returned."
  6161 	not all systems support this; on some, 'unknown' is returned."
  6160 
  6162 
  6161     |name idx|
  6163     |name idx|
  6162 
  6164 
  6163     HostName notNil ifTrue:[
  6165     HostName notNil ifTrue:[
  6164         ^ HostName
  6166 	^ HostName
  6165     ].
  6167     ].
  6166 
  6168 
  6167     name := self primGetHostName.
  6169     name := self primGetHostName.
  6168 
  6170 
  6169     "/ on some systems, the hostname already contains the domain.
  6171     "/ on some systems, the hostname already contains the domain.
  6170     "/ decompose it here.
  6172     "/ decompose it here.
  6171     idx := name indexOf:$..
  6173     idx := name indexOf:$..
  6172     idx ~~ 0 ifTrue:[
  6174     idx ~~ 0 ifTrue:[
  6173         DomainName := name copyFrom:(idx+1).
  6175 	DomainName := name copyFrom:(idx+1).
  6174         name := name copyTo:(idx-1).
  6176 	name := name copyTo:(idx-1).
  6175     ].
  6177     ].
  6176     HostName := name.
  6178     HostName := name.
  6177     ^ name
  6179     ^ name
  6178 
  6180 
  6179     "
  6181     "
  6187 
  6189 
  6188     |lang|
  6190     |lang|
  6189 
  6191 
  6190     lang := self getEnvironment:'LANG'.
  6192     lang := self getEnvironment:'LANG'.
  6191     (lang isNil or:[lang = 'default']) ifTrue:[
  6193     (lang isNil or:[lang = 'default']) ifTrue:[
  6192         "/ ok, search the registry ...
  6194 	"/ ok, search the registry ...
  6193         "/ under XP, it is found there ...
  6195 	"/ under XP, it is found there ...
  6194         lang := RegistryEntry
  6196 	lang := RegistryEntry
  6195                     stringValueFor:'sLanguage'
  6197 		    stringValueFor:'sLanguage'
  6196                     atKey:'HKEY_CURRENT_USER\Control Panel\International'.
  6198 		    atKey:'HKEY_CURRENT_USER\Control Panel\International'.
  6197         lang notNil ifTrue:[
  6199 	lang notNil ifTrue:[
  6198             lang := self mapLanguage:lang.
  6200 	    lang := self mapLanguage:lang.
  6199         ].
  6201 	].
  6200     ].
  6202     ].
  6201     ^ lang
  6203     ^ lang
  6202 
  6204 
  6203     "
  6205     "
  6204      OperatingSystem getLanguage
  6206      OperatingSystem getLanguage
  6208 
  6210 
  6209 getLocaleInfo
  6211 getLocaleInfo
  6210     "return a dictionary filled with values from the locale information;
  6212     "return a dictionary filled with values from the locale information;
  6211      Not all fields may be present, depending on the OS's setup and capabilities.
  6213      Not all fields may be present, depending on the OS's setup and capabilities.
  6212      Possible fields are:
  6214      Possible fields are:
  6213         decimalPoint                    <String>
  6215 	decimalPoint                    <String>
  6214 
  6216 
  6215         thousandsSep                    <String>
  6217 	thousandsSep                    <String>
  6216 
  6218 
  6217         internationalCurrencySymbol     <String>
  6219 	internationalCurrencySymbol     <String>
  6218 
  6220 
  6219         currencySymbol                  <String>
  6221 	currencySymbol                  <String>
  6220 
  6222 
  6221         monetaryDecimalPoint            <String>
  6223 	monetaryDecimalPoint            <String>
  6222 
  6224 
  6223         monetaryThousandsSeparator      <String>
  6225 	monetaryThousandsSeparator      <String>
  6224 
  6226 
  6225         positiveSign                    <String>
  6227 	positiveSign                    <String>
  6226 
  6228 
  6227         negativeSign                    <String>
  6229 	negativeSign                    <String>
  6228 
  6230 
  6229         internationalFractionalDigits   <Integer>
  6231 	internationalFractionalDigits   <Integer>
  6230 
  6232 
  6231         fractionalDigits                <Integer>
  6233 	fractionalDigits                <Integer>
  6232 
  6234 
  6233         positiveSignPrecedesCurrencySymbol      <Boolean>
  6235 	positiveSignPrecedesCurrencySymbol      <Boolean>
  6234 
  6236 
  6235         negativeSignPrecedesCurrencySymbol      <Boolean>
  6237 	negativeSignPrecedesCurrencySymbol      <Boolean>
  6236 
  6238 
  6237         positiveSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
  6239 	positiveSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
  6238 
  6240 
  6239         negativeSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
  6241 	negativeSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
  6240 
  6242 
  6241         positiveSignPosition                            <Symbol>
  6243 	positiveSignPosition                            <Symbol>
  6242                                                         one of: #parenthesesAround,
  6244 							one of: #parenthesesAround,
  6243                                                                 #signPrecedes,
  6245 								#signPrecedes,
  6244                                                                 #signSuceeds,
  6246 								#signSuceeds,
  6245                                                                 #signPrecedesCurrencySymbol,
  6247 								#signPrecedesCurrencySymbol,
  6246                                                                 #signSuceedsCurrencySymbol
  6248 								#signSuceedsCurrencySymbol
  6247 
  6249 
  6248         negativeSignPosition                            <like above>
  6250 	negativeSignPosition                            <like above>
  6249 
  6251 
  6250      it is up to the application to deal with undefined values.
  6252      it is up to the application to deal with undefined values.
  6251 
  6253 
  6252      Notice, that (for now), the system does not use this information;
  6254      Notice, that (for now), the system does not use this information;
  6253      it should be used by applications as required.
  6255      it should be used by applications as required.
  6254     "
  6256     "
  6255 
  6257 
  6256     |info val|
  6258     |info val|
  6257 
  6259 
  6258     LocaleInfo notNil ifTrue:[
  6260     LocaleInfo notNil ifTrue:[
  6259         "/ return the internal info; useful on systems which do not
  6261 	"/ return the internal info; useful on systems which do not
  6260         "/ support this.
  6262 	"/ support this.
  6261         ^ LocaleInfo
  6263 	^ LocaleInfo
  6262     ].
  6264     ].
  6263 
  6265 
  6264     info := IdentityDictionary new.
  6266     info := IdentityDictionary new.
  6265 %{
  6267 %{
  6266     char *decimalPoint;         /* something like "." (US) or "," (german) */
  6268     char *decimalPoint;         /* something like "." (US) or "," (german) */
  6277     int   csNegPrecedes;        /* money: 1 if currency symbol precedes a negative value; 0 if it sceeds */
  6279     int   csNegPrecedes;        /* money: 1 if currency symbol precedes a negative value; 0 if it sceeds */
  6278     int   csPosSepBySpace;      /* money: 1 if currency symbol should be separated by a space from a positive value; 0 if no space */
  6280     int   csPosSepBySpace;      /* money: 1 if currency symbol should be separated by a space from a positive value; 0 if no space */
  6279     int   csNegSepBySpace;      /* money: 1 if currency symbol should be separated by a space from a negative value; 0 if no space */
  6281     int   csNegSepBySpace;      /* money: 1 if currency symbol should be separated by a space from a negative value; 0 if no space */
  6280     int   csPosSignPosition;    /* money: 0: ()'s around the value & currency symbol */
  6282     int   csPosSignPosition;    /* money: 0: ()'s around the value & currency symbol */
  6281     int   csNegSignPosition;    /*        1: sign precedes the value & currency symbol */
  6283     int   csNegSignPosition;    /*        1: sign precedes the value & currency symbol */
  6282                                 /*        2: sign succeeds the value & currency symbol */
  6284 				/*        2: sign succeeds the value & currency symbol */
  6283                                 /*        3: sign immediately precedes the currency symbol */
  6285 				/*        3: sign immediately precedes the currency symbol */
  6284                                 /*        4: sign immediately suceeds the currency symbol */
  6286 				/*        4: sign immediately suceeds the currency symbol */
  6285 
  6287 
  6286 #if defined(HAS_LOCALECONV)
  6288 #if defined(HAS_LOCALECONV)
  6287     struct lconv *conf;
  6289     struct lconv *conf;
  6288 
  6290 
  6289     conf = localeconv();
  6291     conf = localeconv();
  6290     if (conf) {
  6292     if (conf) {
  6291         decimalPoint = conf->decimal_point;
  6293 	decimalPoint = conf->decimal_point;
  6292         thousandsSep = conf->thousands_sep;
  6294 	thousandsSep = conf->thousands_sep;
  6293         intCurrencySymbol = conf->int_curr_symbol;
  6295 	intCurrencySymbol = conf->int_curr_symbol;
  6294         currencySymbol = conf->currency_symbol;
  6296 	currencySymbol = conf->currency_symbol;
  6295         monDecimalPoint = conf->mon_decimal_point;
  6297 	monDecimalPoint = conf->mon_decimal_point;
  6296         monThousandsSep = conf->mon_thousands_sep;
  6298 	monThousandsSep = conf->mon_thousands_sep;
  6297         positiveSign = conf->positive_sign;
  6299 	positiveSign = conf->positive_sign;
  6298         negativeSign = conf->negative_sign;
  6300 	negativeSign = conf->negative_sign;
  6299         intFractDigits = conf->int_frac_digits;
  6301 	intFractDigits = conf->int_frac_digits;
  6300         fractDigits = conf->frac_digits;
  6302 	fractDigits = conf->frac_digits;
  6301         csPosPrecedes = conf->p_cs_precedes;
  6303 	csPosPrecedes = conf->p_cs_precedes;
  6302         csNegPrecedes = conf->n_cs_precedes;
  6304 	csNegPrecedes = conf->n_cs_precedes;
  6303         csPosSepBySpace = conf->p_sep_by_space;
  6305 	csPosSepBySpace = conf->p_sep_by_space;
  6304         csNegSepBySpace = conf->n_sep_by_space;
  6306 	csNegSepBySpace = conf->n_sep_by_space;
  6305         csPosSignPosition = conf->p_sign_posn;
  6307 	csPosSignPosition = conf->p_sign_posn;
  6306         csNegSignPosition = conf->n_sign_posn;
  6308 	csNegSignPosition = conf->n_sign_posn;
  6307     }
  6309     }
  6308 #else
  6310 #else
  6309     decimalPoint = (char *)0;
  6311     decimalPoint = (char *)0;
  6310     thousandsSep = (char *)0;
  6312     thousandsSep = (char *)0;
  6311     intCurrencySymbol = (char *)0;
  6313     intCurrencySymbol = (char *)0;
  6322     csNegSepBySpace = -1;
  6324     csNegSepBySpace = -1;
  6323     csPosSignPosition = -1;
  6325     csPosSignPosition = -1;
  6324     csNegSignPosition = -1;
  6326     csNegSignPosition = -1;
  6325 #endif
  6327 #endif
  6326     if (decimalPoint) {
  6328     if (decimalPoint) {
  6327         val = __MKSTRING(decimalPoint);
  6329 	val = __MKSTRING(decimalPoint);
  6328         __AT_PUT_(info, @symbol(decimalPoint), val);
  6330 	__AT_PUT_(info, @symbol(decimalPoint), val);
  6329     }
  6331     }
  6330     if (thousandsSep) {
  6332     if (thousandsSep) {
  6331         val = __MKSTRING(thousandsSep);
  6333 	val = __MKSTRING(thousandsSep);
  6332         __AT_PUT_(info, @symbol(thousandsSeparator), val);
  6334 	__AT_PUT_(info, @symbol(thousandsSeparator), val);
  6333     }
  6335     }
  6334     if (intCurrencySymbol) {
  6336     if (intCurrencySymbol) {
  6335         val = __MKSTRING(intCurrencySymbol);
  6337 	val = __MKSTRING(intCurrencySymbol);
  6336         __AT_PUT_(info, @symbol(internationCurrencySymbol), val);
  6338 	__AT_PUT_(info, @symbol(internationCurrencySymbol), val);
  6337     }
  6339     }
  6338     if (currencySymbol) {
  6340     if (currencySymbol) {
  6339         val = __MKSTRING(currencySymbol);
  6341 	val = __MKSTRING(currencySymbol);
  6340         __AT_PUT_(info, @symbol(currencySymbol), val);
  6342 	__AT_PUT_(info, @symbol(currencySymbol), val);
  6341     }
  6343     }
  6342     if (monDecimalPoint) {
  6344     if (monDecimalPoint) {
  6343         val = __MKSTRING(monDecimalPoint);
  6345 	val = __MKSTRING(monDecimalPoint);
  6344         __AT_PUT_(info, @symbol(monetaryDecimalPoint), val);
  6346 	__AT_PUT_(info, @symbol(monetaryDecimalPoint), val);
  6345     }
  6347     }
  6346     if (monThousandsSep) {
  6348     if (monThousandsSep) {
  6347         val = __MKSTRING(monThousandsSep);
  6349 	val = __MKSTRING(monThousandsSep);
  6348         __AT_PUT_(info, @symbol(monetaryThousandsSeparator), val);
  6350 	__AT_PUT_(info, @symbol(monetaryThousandsSeparator), val);
  6349     }
  6351     }
  6350     if (positiveSign) {
  6352     if (positiveSign) {
  6351         val = __MKSTRING(positiveSign);
  6353 	val = __MKSTRING(positiveSign);
  6352         __AT_PUT_(info, @symbol(positiveSign), val);
  6354 	__AT_PUT_(info, @symbol(positiveSign), val);
  6353     }
  6355     }
  6354     if (negativeSign) {
  6356     if (negativeSign) {
  6355         val = __MKSTRING(negativeSign);
  6357 	val = __MKSTRING(negativeSign);
  6356         __AT_PUT_(info, @symbol(negativeSign), val);
  6358 	__AT_PUT_(info, @symbol(negativeSign), val);
  6357     }
  6359     }
  6358     if (intFractDigits >= 0) {
  6360     if (intFractDigits >= 0) {
  6359         __AT_PUT_(info, @symbol(internationalFractionalDigits),  __mkSmallInteger(intFractDigits));
  6361 	__AT_PUT_(info, @symbol(internationalFractionalDigits),  __mkSmallInteger(intFractDigits));
  6360     }
  6362     }
  6361     if (fractDigits >= 0) {
  6363     if (fractDigits >= 0) {
  6362         __AT_PUT_(info, @symbol(fractionalDigits),  __mkSmallInteger(fractDigits));
  6364 	__AT_PUT_(info, @symbol(fractionalDigits),  __mkSmallInteger(fractDigits));
  6363     }
  6365     }
  6364     if (csPosPrecedes >= 0) {
  6366     if (csPosPrecedes >= 0) {
  6365         if (csPosPrecedes == 0) {
  6367 	if (csPosPrecedes == 0) {
  6366             val = false;
  6368 	    val = false;
  6367         } else {
  6369 	} else {
  6368             val = true;
  6370 	    val = true;
  6369         }
  6371 	}
  6370         __AT_PUT_(info, @symbol(positiveSignPrecedesCurrencySymbol), val );
  6372 	__AT_PUT_(info, @symbol(positiveSignPrecedesCurrencySymbol), val );
  6371     }
  6373     }
  6372     if (csNegPrecedes >= 0) {
  6374     if (csNegPrecedes >= 0) {
  6373         if (csNegPrecedes == 0) {
  6375 	if (csNegPrecedes == 0) {
  6374             val = false;
  6376 	    val = false;
  6375         } else {
  6377 	} else {
  6376             val = true;
  6378 	    val = true;
  6377         }
  6379 	}
  6378         __AT_PUT_(info, @symbol(negativeSignPrecedesCurrencySymbol), val );
  6380 	__AT_PUT_(info, @symbol(negativeSignPrecedesCurrencySymbol), val );
  6379     }
  6381     }
  6380     if (csPosSepBySpace >= 0) {
  6382     if (csPosSepBySpace >= 0) {
  6381         if (csPosSepBySpace == 0) {
  6383 	if (csPosSepBySpace == 0) {
  6382             val = false;
  6384 	    val = false;
  6383         } else {
  6385 	} else {
  6384             val = true;
  6386 	    val = true;
  6385         }
  6387 	}
  6386         __AT_PUT_(info, @symbol(positiveSignSeparatedBySpaceFromCurrencySymbol), val);
  6388 	__AT_PUT_(info, @symbol(positiveSignSeparatedBySpaceFromCurrencySymbol), val);
  6387     }
  6389     }
  6388     if (csNegSepBySpace >= 0) {
  6390     if (csNegSepBySpace >= 0) {
  6389         if (csNegSepBySpace == 0) {
  6391 	if (csNegSepBySpace == 0) {
  6390             val = false;
  6392 	    val = false;
  6391         } else {
  6393 	} else {
  6392             val = true;
  6394 	    val = true;
  6393         }
  6395 	}
  6394         __AT_PUT_(info, @symbol(negativeSignSeparatedBySpaceFromCurrencySymbol), val);
  6396 	__AT_PUT_(info, @symbol(negativeSignSeparatedBySpaceFromCurrencySymbol), val);
  6395     }
  6397     }
  6396     switch (csPosSignPosition) {
  6398     switch (csPosSignPosition) {
  6397         case 0:
  6399 	case 0:
  6398             val = @symbol(parenthesesAround);
  6400 	    val = @symbol(parenthesesAround);
  6399             break;
  6401 	    break;
  6400 
  6402 
  6401         case 1:
  6403 	case 1:
  6402             val = @symbol(signPrecedes);
  6404 	    val = @symbol(signPrecedes);
  6403             break;
  6405 	    break;
  6404 
  6406 
  6405         case 2:
  6407 	case 2:
  6406             val = @symbol(signSuceeds);
  6408 	    val = @symbol(signSuceeds);
  6407             break;
  6409 	    break;
  6408 
  6410 
  6409         case 3:
  6411 	case 3:
  6410             val = @symbol(signPrecedesCurrencySymbol);
  6412 	    val = @symbol(signPrecedesCurrencySymbol);
  6411             break;
  6413 	    break;
  6412 
  6414 
  6413         case 4:
  6415 	case 4:
  6414             val = @symbol(signSuceedsCurrencySymbol);
  6416 	    val = @symbol(signSuceedsCurrencySymbol);
  6415             break;
  6417 	    break;
  6416 
  6418 
  6417         default:
  6419 	default:
  6418             val = nil;
  6420 	    val = nil;
  6419     }
  6421     }
  6420     if (val != nil) {
  6422     if (val != nil) {
  6421         __AT_PUT_(info, @symbol(positiveSignPosition), val);
  6423 	__AT_PUT_(info, @symbol(positiveSignPosition), val);
  6422     }
  6424     }
  6423 
  6425 
  6424     switch (csNegSignPosition) {
  6426     switch (csNegSignPosition) {
  6425         case 0:
  6427 	case 0:
  6426             val = @symbol(parenthesesAround);
  6428 	    val = @symbol(parenthesesAround);
  6427             break;
  6429 	    break;
  6428 
  6430 
  6429         case 1:
  6431 	case 1:
  6430             val = @symbol(signPrecedes);
  6432 	    val = @symbol(signPrecedes);
  6431             break;
  6433 	    break;
  6432 
  6434 
  6433         case 2:
  6435 	case 2:
  6434             val = @symbol(signSuceeds);
  6436 	    val = @symbol(signSuceeds);
  6435             break;
  6437 	    break;
  6436 
  6438 
  6437         case 3:
  6439 	case 3:
  6438             val = @symbol(signPrecedesCurrencySymbol);
  6440 	    val = @symbol(signPrecedesCurrencySymbol);
  6439             break;
  6441 	    break;
  6440 
  6442 
  6441         case 4:
  6443 	case 4:
  6442             val = @symbol(signSuceedsCurrencySymbol);
  6444 	    val = @symbol(signSuceedsCurrencySymbol);
  6443             break;
  6445 	    break;
  6444 
  6446 
  6445         default:
  6447 	default:
  6446             val = nil;
  6448 	    val = nil;
  6447     }
  6449     }
  6448     if (val != nil) {
  6450     if (val != nil) {
  6449         __AT_PUT_(info, @symbol(negativeSignPosition), val);
  6451 	__AT_PUT_(info, @symbol(negativeSignPosition), val);
  6450     }
  6452     }
  6451 %}.
  6453 %}.
  6452     ^ info
  6454     ^ info
  6453 
  6455 
  6454     "
  6456     "
  6458     "Created: 23.12.1995 / 14:19:20 / cg"
  6460     "Created: 23.12.1995 / 14:19:20 / cg"
  6459 !
  6461 !
  6460 
  6462 
  6461 getNetworkMACAddresses
  6463 getNetworkMACAddresses
  6462     "return a dictionary filled with
  6464     "return a dictionary filled with
  6463         key -> name of interface
  6465 	key -> name of interface
  6464         value -> the MAC adress (as ByteArray)
  6466 	value -> the MAC adress (as ByteArray)
  6465      for each interface
  6467      for each interface
  6466     "
  6468     "
  6467 
  6469 
  6468     |info nAdapters rawData entry
  6470     |info nAdapters rawData entry
  6469      name description macAddress ipAddress ipAddressMask|
  6471      name description macAddress ipAddress ipAddressMask|
  6488      */
  6490      */
  6489 #ifdef NO_NT4_0_COMPATIBILITY
  6491 #ifdef NO_NT4_0_COMPATIBILITY
  6490     entry2 = (FARPROC) GetAdaptersInfo;
  6492     entry2 = (FARPROC) GetAdaptersInfo;
  6491 #else
  6493 #else
  6492     if (entry2 == NULL) {
  6494     if (entry2 == NULL) {
  6493         entry2 = __get_iphlpapi_functionAddress("GetAdaptersInfo");
  6495 	entry2 = __get_iphlpapi_functionAddress("GetAdaptersInfo");
  6494     }
  6496     }
  6495 #endif /* NO_NT4_0_COMPATIBILITY */
  6497 #endif /* NO_NT4_0_COMPATIBILITY */
  6496 
  6498 
  6497     if (entry2) {
  6499     if (entry2) {
  6498         dwStatus = (*entry2)(
  6500 	dwStatus = (*entry2)(
  6499                                 AdapterInfo,                 // [out] buffer to receive data
  6501 				AdapterInfo,                 // [out] buffer to receive data
  6500                                 &dwBufLen);                  // [in] size of receive data buffer
  6502 				&dwBufLen);                  // [in] size of receive data buffer
  6501         if (dwStatus == ERROR_SUCCESS) {
  6503 	if (dwStatus == ERROR_SUCCESS) {
  6502             PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo;
  6504 	    PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo;
  6503             unsigned char *bP;
  6505 	    unsigned char *bP;
  6504             int nA = 0;
  6506 	    int nA = 0;
  6505 
  6507 
  6506             bP = __byteArrayVal(rawData);
  6508 	    bP = __byteArrayVal(rawData);
  6507             do {
  6509 	    do {
  6508                 name = __MKSTRING(pAdapterInfo->AdapterName);
  6510 		name = __MKSTRING(pAdapterInfo->AdapterName);
  6509                 description = __MKSTRING(pAdapterInfo->Description);
  6511 		description = __MKSTRING(pAdapterInfo->Description);
  6510                 macAddress = __MKBYTEARRAY(pAdapterInfo->Address, 6);
  6512 		macAddress = __MKBYTEARRAY(pAdapterInfo->Address, 6);
  6511                 ipAddress = __MKSTRING(pAdapterInfo->IpAddressList.IpAddress.String);
  6513 		ipAddress = __MKSTRING(pAdapterInfo->IpAddressList.IpAddress.String);
  6512                 ipAddressMask = __MKSTRING(pAdapterInfo->IpAddressList.IpMask.String);
  6514 		ipAddressMask = __MKSTRING(pAdapterInfo->IpAddressList.IpMask.String);
  6513                 entry = __ARRAY_NEW_INT(5);
  6515 		entry = __ARRAY_NEW_INT(5);
  6514 /*
  6516 /*
  6515  * back to ST/X's String definition
  6517  * back to ST/X's String definition
  6516  */
  6518  */
  6517 # ifdef __DEF_String
  6519 # ifdef __DEF_String
  6518 #  define String __DEF_String
  6520 #  define String __DEF_String
  6519 # endif
  6521 # endif
  6520 # ifdef __DEF_String
  6522 # ifdef __DEF_String
  6521 #  define Context __DEF_Context
  6523 #  define Context __DEF_Context
  6522 # endif
  6524 # endif
  6523                 __ArrayInstPtr(entry)->a_element[0] = name; __STORE(entry, name);
  6525 		__ArrayInstPtr(entry)->a_element[0] = name; __STORE(entry, name);
  6524                 __ArrayInstPtr(entry)->a_element[1] = description; __STORE(entry, description);
  6526 		__ArrayInstPtr(entry)->a_element[1] = description; __STORE(entry, description);
  6525                 __ArrayInstPtr(entry)->a_element[2] = macAddress; __STORE(entry, macAddress);
  6527 		__ArrayInstPtr(entry)->a_element[2] = macAddress; __STORE(entry, macAddress);
  6526                 __ArrayInstPtr(entry)->a_element[3] = ipAddress; __STORE(entry, ipAddress);
  6528 		__ArrayInstPtr(entry)->a_element[3] = ipAddress; __STORE(entry, ipAddress);
  6527                 __ArrayInstPtr(entry)->a_element[4] = ipAddressMask; __STORE(entry, ipAddressMask);
  6529 		__ArrayInstPtr(entry)->a_element[4] = ipAddressMask; __STORE(entry, ipAddressMask);
  6528 
  6530 
  6529                 __ArrayInstPtr(rawData)->a_element[nA] = entry; __STORE(rawData, entry);
  6531 		__ArrayInstPtr(rawData)->a_element[nA] = entry; __STORE(rawData, entry);
  6530                 nA++;
  6532 		nA++;
  6531                 pAdapterInfo = pAdapterInfo->Next;
  6533 		pAdapterInfo = pAdapterInfo->Next;
  6532             } while(pAdapterInfo);
  6534 	    } while(pAdapterInfo);
  6533             nAdapters = __mkSmallInteger(nA);
  6535 	    nAdapters = __mkSmallInteger(nA);
  6534         }
  6536 	}
  6535     }
  6537     }
  6536 #endif /* NO_GETADAPTERSINFO */
  6538 #endif /* NO_GETADAPTERSINFO */
  6537 %}.
  6539 %}.
  6538     info := Dictionary new.
  6540     info := Dictionary new.
  6539     nAdapters notNil ifTrue:[
  6541     nAdapters notNil ifTrue:[
  6540         1 to:nAdapters do:[:i |
  6542 	1 to:nAdapters do:[:i |
  6541             |entry name description macAddr ipAddr|
  6543 	    |entry name description macAddr ipAddr|
  6542 
  6544 
  6543             entry := rawData at:i.
  6545 	    entry := rawData at:i.
  6544             name := entry at:1.
  6546 	    name := entry at:1.
  6545             "/ description := entry at:2.
  6547 	    "/ description := entry at:2.
  6546             macAddr := entry at:3.
  6548 	    macAddr := entry at:3.
  6547             "/ ipAddr := entry at:4.
  6549 	    "/ ipAddr := entry at:4.
  6548             info at:name put:macAddr.
  6550 	    info at:name put:macAddr.
  6549         ].
  6551 	].
  6550     ].
  6552     ].
  6551     ^ info
  6553     ^ info
  6552 
  6554 
  6553     "
  6555     "
  6554      OperatingSystem getNetworkMACAddresses
  6556      OperatingSystem getNetworkMACAddresses
  6572 
  6574 
  6573 getSystemID
  6575 getSystemID
  6574     "if supported by the OS, return the systemID;
  6576     "if supported by the OS, return the systemID;
  6575      a unique per machine identification.
  6577      a unique per machine identification.
  6576      WARNING:
  6578      WARNING:
  6577         not all systems support this; on some, 'unknown' is returned."
  6579 	not all systems support this; on some, 'unknown' is returned."
  6578 
  6580 
  6579 %{  /* NO_CONTEXT */
  6581 %{  /* NO_CONTEXT */
  6580 #if defined(HAS_GETHOSTID)
  6582 #if defined(HAS_GETHOSTID)
  6581     int runningId;
  6583     int runningId;
  6582     OBJ arr;
  6584     OBJ arr;
  6586     *(int *)(__ByteArrayInstPtr(arr)->ba_element) = runningId;
  6588     *(int *)(__ByteArrayInstPtr(arr)->ba_element) = runningId;
  6587     RETURN (arr);
  6589     RETURN (arr);
  6588 #endif
  6590 #endif
  6589 #if defined(HAS_SYSINFO) && defined(SI_HW_SERIAL)
  6591 #if defined(HAS_SYSINFO) && defined(SI_HW_SERIAL)
  6590     {
  6592     {
  6591         char buffer[128];
  6593 	char buffer[128];
  6592 
  6594 
  6593         buffer[0] = 0;
  6595 	buffer[0] = 0;
  6594         if (sysinfo(SI_HW_SERIAL, buffer, sizeof(buffer))) {
  6596 	if (sysinfo(SI_HW_SERIAL, buffer, sizeof(buffer))) {
  6595             buffer[127] = 0;
  6597 	    buffer[127] = 0;
  6596             if (strlen(buffer) > 0) {
  6598 	    if (strlen(buffer) > 0) {
  6597                 RETURN(__MKSTRING(buffer));
  6599 		RETURN(__MKSTRING(buffer));
  6598             }
  6600 	    }
  6599         }
  6601 	}
  6600     }
  6602     }
  6601 #endif
  6603 #endif
  6602 %}.
  6604 %}.
  6603     ^ 'unknown'
  6605     ^ 'unknown'
  6604 
  6606 
  6618        OS, for example, linux returns 'ix86', while WIN32 returns 'x86'.
  6620        OS, for example, linux returns 'ix86', while WIN32 returns 'x86'.
  6619 
  6621 
  6620        This method is mainly provided to augment error reports with some system
  6622        This method is mainly provided to augment error reports with some system
  6621        information.
  6623        information.
  6622        (in case of system/version specific OS errors, conditional workarounds and patches
  6624        (in case of system/version specific OS errors, conditional workarounds and patches
  6623         may be based upon this info).
  6625 	may be based upon this info).
  6624        Your application should NOT depend upon this in any way.
  6626        Your application should NOT depend upon this in any way.
  6625 
  6627 
  6626      The returned info may (or may not) contain:
  6628      The returned info may (or may not) contain:
  6627         #system -> some operating system identification (irix, Linux, nt, win32s ...)
  6629 	#system -> some operating system identification (irix, Linux, nt, win32s ...)
  6628         #version -> OS version (some os version identification)
  6630 	#version -> OS version (some os version identification)
  6629         #release -> OS release (3.5, 1.2.1 ...)
  6631 	#release -> OS release (3.5, 1.2.1 ...)
  6630         #node   -> some host identification (hostname)
  6632 	#node   -> some host identification (hostname)
  6631         #domain  -> domain name (hosts domain)
  6633 	#domain  -> domain name (hosts domain)
  6632         #machine -> type of machine (i586, mips ...)
  6634 	#machine -> type of machine (i586, mips ...)
  6633 
  6635 
  6634      win32:
  6636      win32:
  6635         #physicalRam -> total amount of physical memory
  6637 	#physicalRam -> total amount of physical memory
  6636         #freeRam -> amount of free memory
  6638 	#freeRam -> amount of free memory
  6637         #swapSize -> size of swapSpace (page file)
  6639 	#swapSize -> size of swapSpace (page file)
  6638         #freeSwap -> free bytes in swapSpace
  6640 	#freeSwap -> free bytes in swapSpace
  6639         #virtualRam -> total amount of virtual memory
  6641 	#virtualRam -> total amount of virtual memory
  6640         #freeVirtual -> amount of free virtual memory
  6642 	#freeVirtual -> amount of free virtual memory
  6641         #memoryLoad -> percentage of memory usage (useless)
  6643 	#memoryLoad -> percentage of memory usage (useless)
  6642     "
  6644     "
  6643 
  6645 
  6644     |sys node rel ver mach dom info arch
  6646     |sys node rel ver mach dom info arch
  6645      physicalRam freeRam swapSize freeSwap
  6647      physicalRam freeRam swapSize freeSwap
  6646      virtualRam freeVirtual memoryLoad numberOfCPUs|
  6648      virtualRam freeVirtual memoryLoad numberOfCPUs|
  6659     winVer = LOWORD(vsn);
  6661     winVer = LOWORD(vsn);
  6660     verMinor = HIBYTE(winVer);
  6662     verMinor = HIBYTE(winVer);
  6661     verMajor = LOBYTE(winVer);
  6663     verMajor = LOBYTE(winVer);
  6662 
  6664 
  6663     if (HIWORD(vsn) & 0x8000) {
  6665     if (HIWORD(vsn) & 0x8000) {
  6664         s = "win95";
  6666 	s = "win95";
  6665     } else {
  6667     } else {
  6666         if ((verMajor > 5)
  6668 	if ((verMajor > 5)
  6667          || ((verMajor == 5) && (verMinor >= 1))) {
  6669 	 || ((verMajor == 5) && (verMinor >= 1))) {
  6668             s = "xp";
  6670 	    s = "xp";
  6669         } else {
  6671 	} else {
  6670             s = "nt";
  6672 	    s = "nt";
  6671         }
  6673 	}
  6672     }
  6674     }
  6673     sys = __MKSTRING(s);
  6675     sys = __MKSTRING(s);
  6674     len = snprintf(vsnBuffer, sizeof(vsnBuffer), "%d.%d", verMajor, verMinor);
  6676     len = snprintf(vsnBuffer, sizeof(vsnBuffer), "%d.%d", verMajor, verMinor);
  6675     rel = __MKSTRING_L(vsnBuffer, len);
  6677     rel = __MKSTRING_L(vsnBuffer, len);
  6676 
  6678 
  6693     /* MSC, BorlandC4 ... */
  6695     /* MSC, BorlandC4 ... */
  6694     switch (sysInfo.wProcessorArchitecture)
  6696     switch (sysInfo.wProcessorArchitecture)
  6695 #endif
  6697 #endif
  6696     {
  6698     {
  6697 #ifdef PROCESSOR_ARCHITECTURE_INTEL
  6699 #ifdef PROCESSOR_ARCHITECTURE_INTEL
  6698         case PROCESSOR_ARCHITECTURE_INTEL:
  6700 	case PROCESSOR_ARCHITECTURE_INTEL:
  6699             s = "intel";
  6701 	    s = "intel";
  6700             break;
  6702 	    break;
  6701 #endif
  6703 #endif
  6702 #ifdef PROCESSOR_ARCHITECTURE_MIPS
  6704 #ifdef PROCESSOR_ARCHITECTURE_MIPS
  6703         case PROCESSOR_ARCHITECTURE_MIPS:
  6705 	case PROCESSOR_ARCHITECTURE_MIPS:
  6704             s = "mips";
  6706 	    s = "mips";
  6705             break;
  6707 	    break;
  6706 #endif
  6708 #endif
  6707 #ifdef PROCESSOR_ARCHITECTURE_ALPHA
  6709 #ifdef PROCESSOR_ARCHITECTURE_ALPHA
  6708         case PROCESSOR_ARCHITECTURE_ALPHA:
  6710 	case PROCESSOR_ARCHITECTURE_ALPHA:
  6709             s = "alpha";
  6711 	    s = "alpha";
  6710             break;
  6712 	    break;
  6711 #endif
  6713 #endif
  6712 #ifdef PROCESSOR_ARCHITECTURE_ALPHA64
  6714 #ifdef PROCESSOR_ARCHITECTURE_ALPHA64
  6713         case PROCESSOR_ARCHITECTURE_ALPHA64:
  6715 	case PROCESSOR_ARCHITECTURE_ALPHA64:
  6714             s = "alpha64";
  6716 	    s = "alpha64";
  6715             break;
  6717 	    break;
  6716 #endif
  6718 #endif
  6717 #ifdef PROCESSOR_ARCHITECTURE_PPC
  6719 #ifdef PROCESSOR_ARCHITECTURE_PPC
  6718         case PROCESSOR_ARCHITECTURE_PPC:
  6720 	case PROCESSOR_ARCHITECTURE_PPC:
  6719             s = "ppc";
  6721 	    s = "ppc";
  6720             break;
  6722 	    break;
  6721 #endif
  6723 #endif
  6722 #ifdef PROCESSOR_ARCHITECTURE_ARM
  6724 #ifdef PROCESSOR_ARCHITECTURE_ARM
  6723         case PROCESSOR_ARCHITECTURE_ARM:
  6725 	case PROCESSOR_ARCHITECTURE_ARM:
  6724             s = "arm";
  6726 	    s = "arm";
  6725             break;
  6727 	    break;
  6726 #endif
  6728 #endif
  6727 #ifdef PROCESSOR_ARCHITECTURE_SHX
  6729 #ifdef PROCESSOR_ARCHITECTURE_SHX
  6728         case PROCESSOR_ARCHITECTURE_SHX:
  6730 	case PROCESSOR_ARCHITECTURE_SHX:
  6729             s = "shx";
  6731 	    s = "shx";
  6730             break;
  6732 	    break;
  6731 #endif
  6733 #endif
  6732 #ifdef PROCESSOR_ARCHITECTURE_IA64
  6734 #ifdef PROCESSOR_ARCHITECTURE_IA64
  6733         case PROCESSOR_ARCHITECTURE_IA64:
  6735 	case PROCESSOR_ARCHITECTURE_IA64:
  6734             s = "ia64";
  6736 	    s = "ia64";
  6735             break;
  6737 	    break;
  6736 #endif
  6738 #endif
  6737 #ifdef PROCESSOR_ARCHITECTURE_MSIL
  6739 #ifdef PROCESSOR_ARCHITECTURE_MSIL
  6738         case PROCESSOR_ARCHITECTURE_MSIL:
  6740 	case PROCESSOR_ARCHITECTURE_MSIL:
  6739             s = "msil";
  6741 	    s = "msil";
  6740             break;
  6742 	    break;
  6741 #endif
  6743 #endif
  6742         default:
  6744 	default:
  6743             s = "unknown";
  6745 	    s = "unknown";
  6744             break;
  6746 	    break;
  6745     }
  6747     }
  6746     arch = __MKSTRING(s);
  6748     arch = __MKSTRING(s);
  6747 
  6749 
  6748     switch (sysInfo.dwProcessorType) {
  6750     switch (sysInfo.dwProcessorType) {
  6749 #ifdef PROCESSOR_INTEL_386
  6751 #ifdef PROCESSOR_INTEL_386
  6750         case PROCESSOR_INTEL_386:
  6752 	case PROCESSOR_INTEL_386:
  6751             s = "i386";
  6753 	    s = "i386";
  6752             break;
  6754 	    break;
  6753 #endif
  6755 #endif
  6754 #ifdef PROCESSOR_INTEL_486
  6756 #ifdef PROCESSOR_INTEL_486
  6755         case PROCESSOR_INTEL_486:
  6757 	case PROCESSOR_INTEL_486:
  6756             s = "i486";
  6758 	    s = "i486";
  6757             break;
  6759 	    break;
  6758 #endif
  6760 #endif
  6759 #ifdef PROCESSOR_INTEL_PENTIUM
  6761 #ifdef PROCESSOR_INTEL_PENTIUM
  6760         case PROCESSOR_INTEL_PENTIUM:
  6762 	case PROCESSOR_INTEL_PENTIUM:
  6761             s = "i586";
  6763 	    s = "i586";
  6762             break;
  6764 	    break;
  6763 #endif
  6765 #endif
  6764 #ifdef PROCESSOR_INTEL_860
  6766 #ifdef PROCESSOR_INTEL_860
  6765         case PROCESSOR_INTEL_860:
  6767 	case PROCESSOR_INTEL_860:
  6766             s = "i860";
  6768 	    s = "i860";
  6767             break;
  6769 	    break;
  6768 #endif
  6770 #endif
  6769 #ifdef PROCESSOR_INTEL_IA64
  6771 #ifdef PROCESSOR_INTEL_IA64
  6770         case PROCESSOR_INTEL_IA64:
  6772 	case PROCESSOR_INTEL_IA64:
  6771             s = "ia64";
  6773 	    s = "ia64";
  6772             break;
  6774 	    break;
  6773 #endif
  6775 #endif
  6774 #ifdef PROCESSOR_MIPS_R2000
  6776 #ifdef PROCESSOR_MIPS_R2000
  6775         case PROCESSOR_MIPS_R2000:
  6777 	case PROCESSOR_MIPS_R2000:
  6776             s = "r2000";
  6778 	    s = "r2000";
  6777             break;
  6779 	    break;
  6778 #endif
  6780 #endif
  6779 #ifdef PROCESSOR_MIPS_R3000
  6781 #ifdef PROCESSOR_MIPS_R3000
  6780         case PROCESSOR_MIPS_R3000:
  6782 	case PROCESSOR_MIPS_R3000:
  6781             s = "r3000";
  6783 	    s = "r3000";
  6782             break;
  6784 	    break;
  6783 #endif
  6785 #endif
  6784 #ifdef PROCESSOR_MIPS_R4000
  6786 #ifdef PROCESSOR_MIPS_R4000
  6785         case PROCESSOR_MIPS_R4000:
  6787 	case PROCESSOR_MIPS_R4000:
  6786             s = "r4000";
  6788 	    s = "r4000";
  6787             break;
  6789 	    break;
  6788 #endif
  6790 #endif
  6789 #ifdef PROCESSOR_ALPHA_21064
  6791 #ifdef PROCESSOR_ALPHA_21064
  6790         case PROCESSOR_ALPHA_21064:
  6792 	case PROCESSOR_ALPHA_21064:
  6791             s = "alpha21064";
  6793 	    s = "alpha21064";
  6792             break;
  6794 	    break;
  6793 #endif
  6795 #endif
  6794 #ifdef PROCESSOR_ARM720
  6796 #ifdef PROCESSOR_ARM720
  6795         case PROCESSOR_ARM720:
  6797 	case PROCESSOR_ARM720:
  6796             s = "arm720";
  6798 	    s = "arm720";
  6797             break;
  6799 	    break;
  6798 #endif
  6800 #endif
  6799 #ifdef PROCESSOR_ARM820
  6801 #ifdef PROCESSOR_ARM820
  6800         case PROCESSOR_ARM820:
  6802 	case PROCESSOR_ARM820:
  6801             s = "arm820";
  6803 	    s = "arm820";
  6802             break;
  6804 	    break;
  6803 #endif
  6805 #endif
  6804 #ifdef PROCESSOR_ARM920
  6806 #ifdef PROCESSOR_ARM920
  6805         case PROCESSOR_ARM920:
  6807 	case PROCESSOR_ARM920:
  6806             s = "arm920";
  6808 	    s = "arm920";
  6807             break;
  6809 	    break;
  6808 #endif
  6810 #endif
  6809 #ifdef PROCESSOR_ARM_7TDMI
  6811 #ifdef PROCESSOR_ARM_7TDMI
  6810         case PROCESSOR_ARM_7TDMI:
  6812 	case PROCESSOR_ARM_7TDMI:
  6811             s = "arm70001";
  6813 	    s = "arm70001";
  6812             break;
  6814 	    break;
  6813 #endif
  6815 #endif
  6814 #ifdef PROCESSOR_PPC_601
  6816 #ifdef PROCESSOR_PPC_601
  6815         case PROCESSOR_PPC_601:
  6817 	case PROCESSOR_PPC_601:
  6816             s = "ppc601";
  6818 	    s = "ppc601";
  6817             break;
  6819 	    break;
  6818 #endif
  6820 #endif
  6819 #ifdef PROCESSOR_PPC_603
  6821 #ifdef PROCESSOR_PPC_603
  6820         case PROCESSOR_PPC_603:
  6822 	case PROCESSOR_PPC_603:
  6821             s = "ppc603";
  6823 	    s = "ppc603";
  6822             break;
  6824 	    break;
  6823 #endif
  6825 #endif
  6824 #ifdef PROCESSOR_PPC_604
  6826 #ifdef PROCESSOR_PPC_604
  6825         case PROCESSOR_PPC_604:
  6827 	case PROCESSOR_PPC_604:
  6826             s = "ppc604";
  6828 	    s = "ppc604";
  6827             break;
  6829 	    break;
  6828 #endif
  6830 #endif
  6829 #ifdef PROCESSOR_PPC_620
  6831 #ifdef PROCESSOR_PPC_620
  6830         case PROCESSOR_PPC_620:
  6832 	case PROCESSOR_PPC_620:
  6831             s = "ppc620";
  6833 	    s = "ppc620";
  6832             break;
  6834 	    break;
  6833 #endif
  6835 #endif
  6834 
  6836 
  6835         default:
  6837 	default:
  6836             sprintf(vsnBuffer, "%d", sysInfo.dwProcessorType);
  6838 	    sprintf(vsnBuffer, "%d", sysInfo.dwProcessorType);
  6837             s = vsnBuffer;
  6839 	    s = vsnBuffer;
  6838             break;
  6840 	    break;
  6839     }
  6841     }
  6840     mach = __MKSTRING(s);
  6842     mach = __MKSTRING(s);
  6841 
  6843 
  6842     numberOfCPUs = __MKUINT(sysInfo.dwNumberOfProcessors);
  6844     numberOfCPUs = __MKUINT(sysInfo.dwNumberOfProcessors);
  6843 %}.
  6845 %}.
  6844     sys isNil ifTrue:[
  6846     sys isNil ifTrue:[
  6845         sys := self getSystemType.
  6847 	sys := self getSystemType.
  6846     ].
  6848     ].
  6847     node isNil ifTrue:[
  6849     node isNil ifTrue:[
  6848         node := self getHostName.
  6850 	node := self getHostName.
  6849     ].
  6851     ].
  6850     dom isNil ifTrue:[
  6852     dom isNil ifTrue:[
  6851         dom := self getDomainName.
  6853 	dom := self getDomainName.
  6852     ].
  6854     ].
  6853     mach isNil ifTrue:[
  6855     mach isNil ifTrue:[
  6854         mach := self getCPUType.
  6856 	mach := self getCPUType.
  6855     ].
  6857     ].
  6856     arch isNil ifTrue:[
  6858     arch isNil ifTrue:[
  6857         arch := 'unknown'.
  6859 	arch := 'unknown'.
  6858     ].
  6860     ].
  6859 
  6861 
  6860     info := IdentityDictionary new.
  6862     info := IdentityDictionary new.
  6861     info at:#system put:sys.
  6863     info at:#system put:sys.
  6862     info at:#node put:node.
  6864     info at:#node put:node.
  6906 
  6908 
  6907 %{
  6909 %{
  6908     char buffer[MAXPATHLEN];
  6910     char buffer[MAXPATHLEN];
  6909 
  6911 
  6910     if (GetWindowsDirectory(buffer, MAXPATHLEN)) {
  6912     if (GetWindowsDirectory(buffer, MAXPATHLEN)) {
  6911         RETURN (__MKSTRING(buffer));
  6913 	RETURN (__MKSTRING(buffer));
  6912     }
  6914     }
  6913 %}.
  6915 %}.
  6914     ^ nil
  6916     ^ nil
  6915 
  6917 
  6916     "
  6918     "
  6927 
  6929 
  6928 %{
  6930 %{
  6929     char buffer[MAXPATHLEN];
  6931     char buffer[MAXPATHLEN];
  6930 
  6932 
  6931     if (GetSystemDirectory(buffer, MAXPATHLEN)) {
  6933     if (GetSystemDirectory(buffer, MAXPATHLEN)) {
  6932         RETURN (__MKSTRING(buffer));
  6934 	RETURN (__MKSTRING(buffer));
  6933     }
  6935     }
  6934 %}.
  6936 %}.
  6935     ^ nil
  6937     ^ nil
  6936 
  6938 
  6937     "
  6939     "
  6965 isMSWINDOWSNTlike
  6967 isMSWINDOWSNTlike
  6966     "This returns true if running in a Windows-NT system."
  6968     "This returns true if running in a Windows-NT system."
  6967 
  6969 
  6968 %{   /* NOCONTEXT */
  6970 %{   /* NOCONTEXT */
  6969      if (__isWinNT)
  6971      if (__isWinNT)
  6970         RETURN(true);
  6972 	RETURN(true);
  6971 %}.
  6973 %}.
  6972      ^ false.
  6974      ^ false.
  6973 !
  6975 !
  6974 
  6976 
  6975 isMSWINDOWSlike
  6977 isMSWINDOWSlike
  6980 !
  6982 !
  6981 
  6983 
  6982 maxFileNameLength
  6984 maxFileNameLength
  6983     "return the max number of characters in a filename.
  6985     "return the max number of characters in a filename.
  6984      CAVEAT:
  6986      CAVEAT:
  6985          Actually, the following is somewhat wrong - some systems
  6987 	 Actually, the following is somewhat wrong - some systems
  6986          support different sizes, depending on the volume.
  6988 	 support different sizes, depending on the volume.
  6987          We return a somewhat conservative number here.
  6989 	 We return a somewhat conservative number here.
  6988          Another entry, to query for volume specific max
  6990 	 Another entry, to query for volume specific max
  6989          will be added in the future."
  6991 	 will be added in the future."
  6990 
  6992 
  6991 %{  /* NOCONTEXT */
  6993 %{  /* NOCONTEXT */
  6992 
  6994 
  6993     /*
  6995     /*
  6994      * TODO: newer systems provide a query function for this ... use it
  6996      * TODO: newer systems provide a query function for this ... use it
  7043     HINSTANCE hNetApi32 = LoadLibrary("netapi32.dll");
  7045     HINSTANCE hNetApi32 = LoadLibrary("netapi32.dll");
  7044     DWORD (__stdcall *pfnNetApiBufferFree)(LPVOID Buffer);
  7046     DWORD (__stdcall *pfnNetApiBufferFree)(LPVOID Buffer);
  7045     DWORD (__stdcall *pfnNetWkstaGetInfo)(LPWSTR servername, DWORD level, void *bufptr);
  7047     DWORD (__stdcall *pfnNetWkstaGetInfo)(LPWSTR servername, DWORD level, void *bufptr);
  7046 
  7048 
  7047     if (hNetApi32) {
  7049     if (hNetApi32) {
  7048         pfnNetApiBufferFree = (DWORD (__stdcall *)(void *)) GetProcAddress(hNetApi32, "NetApiBufferFree");
  7050 	pfnNetApiBufferFree = (DWORD (__stdcall *)(void *)) GetProcAddress(hNetApi32, "NetApiBufferFree");
  7049         pfnNetWkstaGetInfo = (DWORD (__stdcall *)(LPWSTR, DWORD, void *)) GetProcAddress(hNetApi32, "NetWkstaGetInfo");
  7051 	pfnNetWkstaGetInfo = (DWORD (__stdcall *)(LPWSTR, DWORD, void *)) GetProcAddress(hNetApi32, "NetWkstaGetInfo");
  7050     }
  7052     }
  7051 
  7053 
  7052     if (hNetApi32 && pfnNetWkstaGetInfo && pfnNetApiBufferFree) {
  7054     if (hNetApi32 && pfnNetWkstaGetInfo && pfnNetApiBufferFree) {
  7053         /* this way is more reliable, in case user has a local account. */
  7055 	/* this way is more reliable, in case user has a local account. */
  7054         char dname[256];
  7056 	char dname[256];
  7055         DWORD dnamelen = sizeof(dname);
  7057 	DWORD dnamelen = sizeof(dname);
  7056         struct {
  7058 	struct {
  7057             DWORD   wki100_platform_id;
  7059 	    DWORD   wki100_platform_id;
  7058             LPWSTR  wki100_computername;
  7060 	    LPWSTR  wki100_computername;
  7059             LPWSTR  wki100_langroup;
  7061 	    LPWSTR  wki100_langroup;
  7060             DWORD   wki100_ver_major;
  7062 	    DWORD   wki100_ver_major;
  7061             DWORD   wki100_ver_minor;
  7063 	    DWORD   wki100_ver_minor;
  7062         } *pwi;
  7064 	} *pwi;
  7063 
  7065 
  7064         /* NERR_Success *is* 0*/
  7066 	/* NERR_Success *is* 0*/
  7065         if (0 == pfnNetWkstaGetInfo(NULL, 100, &pwi)) {
  7067 	if (0 == pfnNetWkstaGetInfo(NULL, 100, &pwi)) {
  7066             if (pwi->wki100_langroup && *(pwi->wki100_langroup)) {
  7068 	    if (pwi->wki100_langroup && *(pwi->wki100_langroup)) {
  7067                 WideCharToMultiByte(CP_ACP, NULL, pwi->wki100_langroup,
  7069 		WideCharToMultiByte(CP_ACP, NULL, pwi->wki100_langroup,
  7068                                     -1, (LPSTR)dname, dnamelen, NULL, NULL);
  7070 				    -1, (LPSTR)dname, dnamelen, NULL, NULL);
  7069             }
  7071 	    }
  7070             else {
  7072 	    else {
  7071                 WideCharToMultiByte(CP_ACP, NULL, pwi->wki100_computername,
  7073 		WideCharToMultiByte(CP_ACP, NULL, pwi->wki100_computername,
  7072                                     -1, (LPSTR)dname, dnamelen, NULL, NULL);
  7074 				    -1, (LPSTR)dname, dnamelen, NULL, NULL);
  7073             }
  7075 	    }
  7074             pfnNetApiBufferFree(pwi);
  7076 	    pfnNetApiBufferFree(pwi);
  7075             FreeLibrary(hNetApi32);
  7077 	    FreeLibrary(hNetApi32);
  7076             RETURN (__MKSTRING(dname));
  7078 	    RETURN (__MKSTRING(dname));
  7077         }
  7079 	}
  7078         FreeLibrary(hNetApi32);
  7080 	FreeLibrary(hNetApi32);
  7079     } else {
  7081     } else {
  7080         /* Win95 doesn't have NetWksta*(), so do it the old way */
  7082 	/* Win95 doesn't have NetWksta*(), so do it the old way */
  7081         char name[256];
  7083 	char name[256];
  7082         DWORD size = sizeof(name);
  7084 	DWORD size = sizeof(name);
  7083         if (hNetApi32)
  7085 	if (hNetApi32)
  7084             FreeLibrary(hNetApi32);
  7086 	    FreeLibrary(hNetApi32);
  7085         if (GetUserName(name,&size)) {
  7087 	if (GetUserName(name,&size)) {
  7086             char sid[1024];
  7088 	    char sid[1024];
  7087             DWORD sidlen = sizeof(sid);
  7089 	    DWORD sidlen = sizeof(sid);
  7088             char dname[256];
  7090 	    char dname[256];
  7089             DWORD dnamelen = sizeof(dname);
  7091 	    DWORD dnamelen = sizeof(dname);
  7090             SID_NAME_USE snu;
  7092 	    SID_NAME_USE snu;
  7091             if (LookupAccountName(NULL, name, (PSID)&sid, &sidlen,
  7093 	    if (LookupAccountName(NULL, name, (PSID)&sid, &sidlen,
  7092                                   dname, &dnamelen, &snu)) {
  7094 				  dname, &dnamelen, &snu)) {
  7093                 RETURN (__MKSTRING(dname));             /* all that for this */
  7095 		RETURN (__MKSTRING(dname));             /* all that for this */
  7094             }
  7096 	    }
  7095         }
  7097 	}
  7096     }
  7098     }
  7097 #endif /* not needed */
  7099 #endif /* not needed */
  7098 %}.
  7100 %}.
  7099     ^ nil
  7101     ^ nil
  7100 !
  7102 !
  7101 
  7103 
  7102 primGetHostName
  7104 primGetHostName
  7103     "return the hostname we are running on - if there is
  7105     "return the hostname we are running on - if there is
  7104      a HOST environment variable, we are much faster here ...
  7106      a HOST environment variable, we are much faster here ...
  7105      Notice:
  7107      Notice:
  7106         not all systems support this; on some, 'unknown' is returned."
  7108 	not all systems support this; on some, 'unknown' is returned."
  7107 
  7109 
  7108     |name|
  7110     |name|
  7109 
  7111 
  7110 %{  /* STACK: 2048 */
  7112 %{  /* STACK: 2048 */
  7111 #if defined(HAS_GETHOSTNAME)
  7113 #if defined(HAS_GETHOSTNAME)
  7112     char buffer[256];
  7114     char buffer[256];
  7113 
  7115 
  7114     if (gethostname(buffer, sizeof(buffer)) == 0) {
  7116     if (gethostname(buffer, sizeof(buffer)) == 0) {
  7115         name = __MKSTRING(buffer);
  7117 	name = __MKSTRING(buffer);
  7116     }
  7118     }
  7117 #else
  7119 #else
  7118     char buffer[128];
  7120     char buffer[128];
  7119     DWORD buffSize = sizeof(buffer);
  7121     DWORD buffSize = sizeof(buffer);
  7120 
  7122 
  7121     if (GetComputerName(buffer, &buffSize) == TRUE) {
  7123     if (GetComputerName(buffer, &buffSize) == TRUE) {
  7122         name = __MKSTRING(buffer);
  7124 	name = __MKSTRING(buffer);
  7123     }
  7125     }
  7124 #endif
  7126 #endif
  7125 %}.
  7127 %}.
  7126     name isNil ifTrue:[
  7128     name isNil ifTrue:[
  7127         name := self getEnvironment:'HOST'.
  7129 	name := self getEnvironment:'HOST'.
  7128         name isNil ifTrue:[
  7130 	name isNil ifTrue:[
  7129             name := self getEnvironment:'HOSTNAME'.
  7131 	    name := self getEnvironment:'HOSTNAME'.
  7130             name isNil ifTrue:[
  7132 	    name isNil ifTrue:[
  7131                 name := self getEnvironment:'COMPUTERNAME'.
  7133 		name := self getEnvironment:'COMPUTERNAME'.
  7132                 name isNil ifTrue:[
  7134 		name isNil ifTrue:[
  7133                     'Win32OperatingSystem [warning]: cannot find out hostname' errorPrintCR.
  7135 		    'Win32OperatingSystem [warning]: cannot find out hostname' errorPrintCR.
  7134                     name := 'unknown'.
  7136 		    name := 'unknown'.
  7135                 ]
  7137 		]
  7136             ]
  7138 	    ]
  7137         ]
  7139 	]
  7138     ].
  7140     ].
  7139     ^ name
  7141     ^ name
  7140 
  7142 
  7141     "
  7143     "
  7142      OperatingSystem primGetHostName
  7144      OperatingSystem primGetHostName
  7294     |pPath pkgDirPath dirs p|
  7296     |pPath pkgDirPath dirs p|
  7295 
  7297 
  7296     pPath := super defaultPackagePath.
  7298     pPath := super defaultPackagePath.
  7297     pkgDirPath := self stxPackageDirPath.
  7299     pkgDirPath := self stxPackageDirPath.
  7298     pkgDirPath notNil ifTrue:[
  7300     pkgDirPath notNil ifTrue:[
  7299         "/ and also add the packageDirPath from the registry ...
  7301 	"/ and also add the packageDirPath from the registry ...
  7300         dirs := pkgDirPath asCollectionOfSubstringsSeparatedBy:$;.
  7302 	dirs := pkgDirPath asCollectionOfSubstringsSeparatedBy:$;.
  7301         dirs do:[:aDir |
  7303 	dirs do:[:aDir |
  7302             (pPath includes:aDir) ifFalse:[
  7304 	    (pPath includes:aDir) ifFalse:[
  7303                 pPath add:aDir.
  7305 		pPath add:aDir.
  7304             ]
  7306 	    ]
  7305         ]
  7307 	]
  7306     ] ifFalse:[
  7308     ] ifFalse:[
  7307         #(
  7309 	#(
  7308             '\smalltalk'
  7310 	    '\smalltalk'
  7309             '\programme\smalltalk'
  7311 	    '\programme\smalltalk'
  7310             '\programme\eXept\smalltalk'
  7312 	    '\programme\eXept\smalltalk'
  7311             '\programs\smalltalk'
  7313 	    '\programs\smalltalk'
  7312             '\programs\eXept\smalltalk'
  7314 	    '\programs\eXept\smalltalk'
  7313         ) do:[:d | |dd|
  7315 	) do:[:d | |dd|
  7314             dd := d asFilename constructString:'packages'.
  7316 	    dd := d asFilename constructString:'packages'.
  7315             (pPath includes:dd) ifFalse:[
  7317 	    (pPath includes:dd) ifFalse:[
  7316                 pPath add:dd.
  7318 		pPath add:dd.
  7317             ].
  7319 	    ].
  7318             dd := (d asFilename construct:Smalltalk versionString) constructString:'packages'.
  7320 	    dd := (d asFilename construct:Smalltalk versionString) constructString:'packages'.
  7319             (pPath includes:dd) ifFalse:[
  7321 	    (pPath includes:dd) ifFalse:[
  7320                 pPath add:dd.
  7322 		pPath add:dd.
  7321             ].
  7323 	    ].
  7322         ].
  7324 	].
  7323     ].
  7325     ].
  7324 
  7326 
  7325     "/ under windows, the commandName includes the path - good.
  7327     "/ under windows, the commandName includes the path - good.
  7326     p := Smalltalk commandName.
  7328     p := Smalltalk commandName.
  7327     p notNil ifTrue:[
  7329     p notNil ifTrue:[
  7328         p := p asFilename directory constructString:'packages'.
  7330 	p := p asFilename directory constructString:'packages'.
  7329         (pPath includes:p) ifFalse:[
  7331 	(pPath includes:p) ifFalse:[
  7330             pPath add:p.
  7332 	    pPath add:p.
  7331         ]
  7333 	]
  7332     ].
  7334     ].
  7333     pPath := pPath select:[:p | p asFilename exists].
  7335     pPath := pPath select:[:p | p asFilename exists].
  7334     ^ pPath
  7336     ^ pPath
  7335 
  7337 
  7336     "
  7338     "
  7346 
  7348 
  7347     sysPath := super defaultSystemPath.
  7349     sysPath := super defaultSystemPath.
  7348 
  7350 
  7349     libDirPath := self stxLibDirPath.
  7351     libDirPath := self stxLibDirPath.
  7350     libDirPath notNil ifTrue:[
  7352     libDirPath notNil ifTrue:[
  7351         "/ and also add the libDirPath from the registry ...
  7353 	"/ and also add the libDirPath from the registry ...
  7352         (sysPath includes:libDirPath) ifFalse:[
  7354 	(sysPath includes:libDirPath) ifFalse:[
  7353             sysPath add:libDirPath
  7355 	    sysPath add:libDirPath
  7354         ].
  7356 	].
  7355     ].
  7357     ].
  7356     #(
  7358     #(
  7357         '\programs\eXept\smalltalk'
  7359 	'\programs\eXept\smalltalk'
  7358         '\programme\eXept\smalltalk'
  7360 	'\programme\eXept\smalltalk'
  7359         '\programs\smalltalk'
  7361 	'\programs\smalltalk'
  7360         '\programme\smalltalk'
  7362 	'\programme\smalltalk'
  7361         '\smalltalk'
  7363 	'\smalltalk'
  7362     ) do:[:dir |
  7364     ) do:[:dir |
  7363         |vsnDir|
  7365 	|vsnDir|
  7364 
  7366 
  7365         (dir asFilename isDirectory) ifTrue:[
  7367 	(dir asFilename isDirectory) ifTrue:[
  7366             vsnDir := dir , '\' , Smalltalk versionString.
  7368 	    vsnDir := dir , '\' , Smalltalk versionString.
  7367             (vsnDir asFilename isDirectory) ifTrue:[
  7369 	    (vsnDir asFilename isDirectory) ifTrue:[
  7368                 (sysPath includes:vsnDir) ifFalse:[
  7370 		(sysPath includes:vsnDir) ifFalse:[
  7369                     sysPath add:vsnDir.
  7371 		    sysPath add:vsnDir.
  7370                 ]
  7372 		]
  7371             ].
  7373 	    ].
  7372             (sysPath includes:dir) ifFalse:[
  7374 	    (sysPath includes:dir) ifFalse:[
  7373                 sysPath add:dir.
  7375 		sysPath add:dir.
  7374             ].
  7376 	    ].
  7375         ]
  7377 	]
  7376     ].
  7378     ].
  7377 
  7379 
  7378     ^ sysPath
  7380     ^ sysPath
  7379 
  7381 
  7380     "Modified: / 24.12.1999 / 00:29:18 / cg"
  7382     "Modified: / 24.12.1999 / 00:29:18 / cg"
  7385 
  7387 
  7386     |k p|
  7388     |k p|
  7387 
  7389 
  7388     k := RegistryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X\' , Smalltalk versionString.
  7390     k := RegistryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X\' , Smalltalk versionString.
  7389     k notNil ifTrue:[
  7391     k notNil ifTrue:[
  7390         p := k valueNamed:'BinDir'.
  7392 	p := k valueNamed:'BinDir'.
  7391     ].
  7393     ].
  7392     ^ p
  7394     ^ p
  7393 
  7395 
  7394     "
  7396     "
  7395      OperatingSystem stxBinDirPath
  7397      OperatingSystem stxBinDirPath
  7398 
  7400 
  7399 stxLibDirPath
  7401 stxLibDirPath
  7400     "ask the registry for the lib directory"
  7402     "ask the registry for the lib directory"
  7401 
  7403 
  7402     (Array
  7404     (Array
  7403         with:('HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X\' , Smalltalk versionString)
  7405 	with:('HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X\' , Smalltalk versionString)
  7404         with:('HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'))
  7406 	with:('HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'))
  7405     do:[:eachKeyToTry |
  7407     do:[:eachKeyToTry |
  7406         |k p|
  7408 	|k p|
  7407 
  7409 
  7408         k := RegistryEntry key:eachKeyToTry.
  7410 	k := RegistryEntry key:eachKeyToTry.
  7409         k notNil ifTrue:[
  7411 	k notNil ifTrue:[
  7410             p := k valueNamed:'LibDir'.
  7412 	    p := k valueNamed:'LibDir'.
  7411             k closeKey.
  7413 	    k closeKey.
  7412             ^ p
  7414 	    ^ p
  7413         ].
  7415 	].
  7414     ].
  7416     ].
  7415     ^ nil
  7417     ^ nil
  7416 
  7418 
  7417     "
  7419     "
  7418      OperatingSystem stxLibDirPath
  7420      OperatingSystem stxLibDirPath
  7424 
  7426 
  7425     |k p|
  7427     |k p|
  7426 
  7428 
  7427     k := RegistryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X\' , Smalltalk versionString.
  7429     k := RegistryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X\' , Smalltalk versionString.
  7428     k notNil ifTrue:[
  7430     k notNil ifTrue:[
  7429         p := k valueNamed:'PackageDirPath'.
  7431 	p := k valueNamed:'PackageDirPath'.
  7430     ].
  7432     ].
  7431     ^ p
  7433     ^ p
  7432 
  7434 
  7433     "
  7435     "
  7434      OperatingSystem stxPackageDirPath
  7436      OperatingSystem stxPackageDirPath
  7502 #define DM_IN_PROMPT        DM_PROMPT
  7504 #define DM_IN_PROMPT        DM_PROMPT
  7503 #define DM_OUT_BUFFER       DM_COPY
  7505 #define DM_OUT_BUFFER       DM_COPY
  7504 #define DM_OUT_DEFAULT      DM_UPDATE
  7506 #define DM_OUT_DEFAULT      DM_UPDATE
  7505 "
  7507 "
  7506     nBytesNeeded := self
  7508     nBytesNeeded := self
  7507            primDocumentProperties:nil
  7509 	   primDocumentProperties:nil
  7508            hPrinter:hPrinter
  7510 	   hPrinter:hPrinter
  7509            pDeviceName: deviceName
  7511 	   pDeviceName: deviceName
  7510            pDevModeOutput:nil
  7512 	   pDevModeOutput:nil
  7511            pDevModeInput:nil
  7513 	   pDevModeInput:nil
  7512            fMode:0.
  7514 	   fMode:0.
  7513 
  7515 
  7514     devModeOutput := DevModeStructure new:(nBytesNeeded * 2 "never trust MS !!").
  7516     devModeOutput := DevModeStructure new:(nBytesNeeded * 2 "never trust MS !!").
  7515 
  7517 
  7516     rslt := self
  7518     rslt := self
  7517            primDocumentProperties:nil
  7519 	   primDocumentProperties:nil
  7518            hPrinter:hPrinter
  7520 	   hPrinter:hPrinter
  7519            pDeviceName: deviceName
  7521 	   pDeviceName: deviceName
  7520            pDevModeOutput:devModeOutput
  7522 	   pDevModeOutput:devModeOutput
  7521            pDevModeInput:pDevModeInputOrNil
  7523 	   pDevModeInput:pDevModeInputOrNil
  7522            fMode:4+2.
  7524 	   fMode:4+2.
  7523 
  7525 
  7524     ^ devModeOutput
  7526     ^ devModeOutput
  7525 
  7527 
  7526     "
  7528     "
  7527      |h|
  7529      |h|
  7582 #define DM_IN_PROMPT        DM_PROMPT
  7584 #define DM_IN_PROMPT        DM_PROMPT
  7583 #define DM_OUT_BUFFER       DM_COPY
  7585 #define DM_OUT_BUFFER       DM_COPY
  7584 #define DM_OUT_DEFAULT      DM_UPDATE
  7586 #define DM_OUT_DEFAULT      DM_UPDATE
  7585 "
  7587 "
  7586     nBytesNeeded := self
  7588     nBytesNeeded := self
  7587            primDocumentProperties:nil
  7589 	   primDocumentProperties:nil
  7588            hPrinter:hPrinter
  7590 	   hPrinter:hPrinter
  7589            pDeviceName: deviceName
  7591 	   pDeviceName: deviceName
  7590            pDevModeOutput:nil
  7592 	   pDevModeOutput:nil
  7591            pDevModeInput:nil
  7593 	   pDevModeInput:nil
  7592            fMode:0.
  7594 	   fMode:0.
  7593 
  7595 
  7594     nBytesNeeded < 0 ifTrue:[^nil].
  7596     nBytesNeeded < 0 ifTrue:[^nil].
  7595     devModeOutput := DevModeStructure new:(nBytesNeeded * 2 "never trust MS !!").
  7597     devModeOutput := DevModeStructure new:(nBytesNeeded * 2 "never trust MS !!").
  7596 
  7598 
  7597     rslt := self
  7599     rslt := self
  7598            primDocumentProperties:nil
  7600 	   primDocumentProperties:nil
  7599            hPrinter:hPrinter
  7601 	   hPrinter:hPrinter
  7600            pDeviceName: deviceName
  7602 	   pDeviceName: deviceName
  7601            pDevModeOutput:devModeOutput
  7603 	   pDevModeOutput:devModeOutput
  7602            pDevModeInput:nil
  7604 	   pDevModeInput:nil
  7603            fMode:2.
  7605 	   fMode:2.
  7604 
  7606 
  7605      ^ devModeOutput
  7607      ^ devModeOutput
  7606 
  7608 
  7607     "
  7609     "
  7608      |h|
  7610      |h|
  7621 
  7623 
  7622      hPrinter := self openPrinter: printerName .
  7624      hPrinter := self openPrinter: printerName .
  7623      sizeBytesArray := ByteArray new:4.
  7625      sizeBytesArray := ByteArray new:4.
  7624 
  7626 
  7625      bytesNeeded := self
  7627      bytesNeeded := self
  7626                 primGetPrinter:hPrinter
  7628 		primGetPrinter:hPrinter
  7627                 level:2
  7629 		level:2
  7628                 informationBuffer: nil
  7630 		informationBuffer: nil
  7629                 bufferSize: 0
  7631 		bufferSize: 0
  7630                 bufferNeededSize:sizeBytesArray.
  7632 		bufferNeededSize:sizeBytesArray.
  7631      bytesNeeded := sizeBytesArray longAt:1.
  7633      bytesNeeded := sizeBytesArray longAt:1.
  7632      informationBuffer := PrinterInfo2Structure new: bytesNeeded.
  7634      informationBuffer := PrinterInfo2Structure new: bytesNeeded.
  7633      rslt := self
  7635      rslt := self
  7634                 primGetPrinter:hPrinter
  7636 		primGetPrinter:hPrinter
  7635                 level:2
  7637 		level:2
  7636                 informationBuffer:informationBuffer
  7638 		informationBuffer:informationBuffer
  7637                 bufferSize: bytesNeeded
  7639 		bufferSize: bytesNeeded
  7638                 bufferNeededSize:sizeBytesArray.
  7640 		bufferNeededSize:sizeBytesArray.
  7639      self closePrinter: printerName.
  7641      self closePrinter: printerName.
  7640      ^informationBuffer
  7642      ^informationBuffer
  7641 
  7643 
  7642     "
  7644     "
  7643      OperatingSystem getPrinterInfo2:(OperatingSystem getDefaultPrinterName)
  7645      OperatingSystem getPrinterInfo2:(OperatingSystem getDefaultPrinterName)
  7653     |printerNames collectedInfo|
  7655     |printerNames collectedInfo|
  7654 
  7656 
  7655     printerNames := self getPrintersNames.
  7657     printerNames := self getPrintersNames.
  7656     collectedInfo := OrderedCollection new.
  7658     collectedInfo := OrderedCollection new.
  7657     printerNames do:[:eachName |
  7659     printerNames do:[:eachName |
  7658         |fn vol attributes nm deviceInfo infoFields driverName|
  7660 	|fn vol attributes nm deviceInfo infoFields driverName|
  7659 
  7661 
  7660         attributes := Dictionary new.
  7662 	attributes := Dictionary new.
  7661 
  7663 
  7662         fn := eachName asFilename.
  7664 	fn := eachName asFilename.
  7663         vol := fn volume.
  7665 	vol := fn volume.
  7664         vol notEmptyOrNil ifTrue:[
  7666 	vol notEmptyOrNil ifTrue:[
  7665             (vol startsWith:'\\') ifTrue:[
  7667 	    (vol startsWith:'\\') ifTrue:[
  7666                 "/ a remote printer
  7668 		"/ a remote printer
  7667                 attributes at:#isRemotePrinter put:true.
  7669 		attributes at:#isRemotePrinter put:true.
  7668                 attributes at:#remotePrinterName put:(fn baseName).
  7670 		attributes at:#remotePrinterName put:(fn baseName).
  7669                 attributes at:#remotePrinterHost put:(fn directoryName copyFrom:3).
  7671 		attributes at:#remotePrinterHost put:(fn directoryName copyFrom:3).
  7670             ] ifFalse:[
  7672 	    ] ifFalse:[
  7671                 "/ some other printer
  7673 		"/ some other printer
  7672             ].
  7674 	    ].
  7673         ] ifFalse:[
  7675 	] ifFalse:[
  7674             "/ some other printer
  7676 	    "/ some other printer
  7675         ].
  7677 	].
  7676 
  7678 
  7677         deviceInfo := self getProfileString:'PrinterPorts' key:eachName default:''.
  7679 	deviceInfo := self getProfileString:'PrinterPorts' key:eachName default:''.
  7678         "gives us smething like 'winspool,Ne00:,15,45',
  7680 	"gives us smething like 'winspool,Ne00:,15,45',
  7679          which is: driverName, deviceName, ? , ?"
  7681 	 which is: driverName, deviceName, ? , ?"
  7680 
  7682 
  7681         infoFields := deviceInfo asCollectionOfSubstringsSeparatedBy:$,.
  7683 	infoFields := deviceInfo asCollectionOfSubstringsSeparatedBy:$,.
  7682         driverName := infoFields at:1.
  7684 	driverName := infoFields at:1.
  7683         2 to: infoFields size by:3 do:[:i |
  7685 	2 to: infoFields size by:3 do:[:i |
  7684             |medium longName|
  7686 	    |medium longName|
  7685 
  7687 
  7686             medium := infoFields at:i.
  7688 	    medium := infoFields at:i.
  7687             longName := eachName ,',' , driverName , ',' , medium.
  7689 	    longName := eachName ,',' , driverName , ',' , medium.
  7688             attributes at:#driverName put:driverName.
  7690 	    attributes at:#driverName put:driverName.
  7689             attributes at:#longName put:longName.
  7691 	    attributes at:#longName put:longName.
  7690             attributes at:#medium put:medium.
  7692 	    attributes at:#medium put:medium.
  7691 
  7693 
  7692             collectedInfo add:
  7694 	    collectedInfo add:
  7693                 (AbstractOperatingSystem::PrinterInfo new
  7695 		(AbstractOperatingSystem::PrinterInfo new
  7694                     printerName:eachName
  7696 		    printerName:eachName
  7695                     attributes:attributes;
  7697 		    attributes:attributes;
  7696                     setDocumentProperties;
  7698 		    setDocumentProperties;
  7697                     yourself)
  7699 		    yourself)
  7698         ].
  7700 	].
  7699     ].
  7701     ].
  7700     ^ collectedInfo
  7702     ^ collectedInfo
  7701 
  7703 
  7702     "
  7704     "
  7703      OperatingSystem getPrinters
  7705      OperatingSystem getPrinters
  7711     "return a collection of Printer names"
  7713     "return a collection of Printer names"
  7712 
  7714 
  7713     |printerNames|
  7715     |printerNames|
  7714 
  7716 
  7715     printerNames := (self getProfileString:'PrinterPorts' key:nil default:'')
  7717     printerNames := (self getProfileString:'PrinterPorts' key:nil default:'')
  7716                        asCollectionOfSubstringsSeparatedBy:(Character value:0).
  7718 		       asCollectionOfSubstringsSeparatedBy:(Character value:0).
  7717     printerNames := printerNames reject:[:nm | nm isEmpty].
  7719     printerNames := printerNames reject:[:nm | nm isEmpty].
  7718     ^printerNames
  7720     ^printerNames
  7719 
  7721 
  7720     "
  7722     "
  7721      OperatingSystem getPrintersNames
  7723      OperatingSystem getPrintersNames
  7800     "
  7802     "
  7801      |hPrinter rslt|
  7803      |hPrinter rslt|
  7802 
  7804 
  7803      hPrinter := self openPrinter:'\\http://exept.exept.de:631\lj4' .
  7805      hPrinter := self openPrinter:'\\http://exept.exept.de:631\lj4' .
  7804      rslt := self
  7806      rslt := self
  7805             primDocumentProperties:nil
  7807 	    primDocumentProperties:nil
  7806             hPrinter:hPrinter
  7808 	    hPrinter:hPrinter
  7807             pDeviceName: '\\http://exept.exept.de:631\lj4'
  7809 	    pDeviceName: '\\http://exept.exept.de:631\lj4'
  7808             pDevModeOutput:nil
  7810 	    pDevModeOutput:nil
  7809             pDevModeInput:nil
  7811 	    pDevModeInput:nil
  7810             fMode:0.
  7812 	    fMode:0.
  7811 
  7813 
  7812      self halt.
  7814      self halt.
  7813     "
  7815     "
  7814 
  7816 
  7815     "Created: / 27-07-2006 / 15:02:14 / fm"
  7817     "Created: / 27-07-2006 / 15:02:14 / fm"
  7822     "
  7824     "
  7823      |hPrinter rslt|
  7825      |hPrinter rslt|
  7824 
  7826 
  7825      hPrinter := self openPrinter:'\\http://exept.exept.de:631\lj4' .
  7827      hPrinter := self openPrinter:'\\http://exept.exept.de:631\lj4' .
  7826      rslt := self
  7828      rslt := self
  7827             primDocumentProperties:nil
  7829 	    primDocumentProperties:nil
  7828             hPrinter:hPrinter
  7830 	    hPrinter:hPrinter
  7829             pDeviceName: '\\http://exept.exept.de:631\lj4'
  7831 	    pDeviceName: '\\http://exept.exept.de:631\lj4'
  7830             pDevModeOutput:nil
  7832 	    pDevModeOutput:nil
  7831             pDevModeInput:nil
  7833 	    pDevModeInput:nil
  7832             fMode:0.
  7834 	    fMode:0.
  7833 
  7835 
  7834      self halt.
  7836      self halt.
  7835     "
  7837     "
  7836 
  7838 
  7837     "Created: / 27-07-2006 / 19:31:31 / fm"
  7839     "Created: / 27-07-2006 / 19:31:31 / fm"
  7844     "
  7846     "
  7845      |hPrinter rslt|
  7847      |hPrinter rslt|
  7846 
  7848 
  7847      hPrinter := self openPrinter:'\\http://exept.exept.de:631\lj4' .
  7849      hPrinter := self openPrinter:'\\http://exept.exept.de:631\lj4' .
  7848      rslt := self
  7850      rslt := self
  7849             primDocumentProperties:nil
  7851 	    primDocumentProperties:nil
  7850             hPrinter:hPrinter
  7852 	    hPrinter:hPrinter
  7851             pDeviceName: '\\http://exept.exept.de:631\lj4'
  7853 	    pDeviceName: '\\http://exept.exept.de:631\lj4'
  7852             pDevModeOutput:nil
  7854 	    pDevModeOutput:nil
  7853             pDevModeInput:nil
  7855 	    pDevModeInput:nil
  7854             fMode:0.
  7856 	    fMode:0.
  7855 
  7857 
  7856      self halt.
  7858      self halt.
  7857     "
  7859     "
  7858 
  7860 
  7859     "Created: / 27-07-2006 / 19:30:50 / fm"
  7861     "Created: / 27-07-2006 / 19:30:50 / fm"
  7878      printerName := '\\http://exept.exept.de:631\lj4'.
  7880      printerName := '\\http://exept.exept.de:631\lj4'.
  7879      hPrinter := self openPrinter: printerName .
  7881      hPrinter := self openPrinter: printerName .
  7880 
  7882 
  7881      sizeBytesArray := ByteArray new:4.
  7883      sizeBytesArray := ByteArray new:4.
  7882      ok := self
  7884      ok := self
  7883                 primGetPrinter:hPrinter
  7885 		primGetPrinter:hPrinter
  7884                 level:2
  7886 		level:2
  7885                 informationBuffer: nil
  7887 		informationBuffer: nil
  7886                 bufferSize: 0
  7888 		bufferSize: 0
  7887                 bufferNeededSize:sizeBytesArray.
  7889 		bufferNeededSize:sizeBytesArray.
  7888      bytesNeeded := sizeBytesArray longAt:1.
  7890      bytesNeeded := sizeBytesArray longAt:1.
  7889 
  7891 
  7890      informationBuffer := PrinterInfo2Structure new: bytesNeeded.
  7892      informationBuffer := PrinterInfo2Structure new: bytesNeeded.
  7891      rslt := self
  7893      rslt := self
  7892                 primGetPrinter:hPrinter
  7894 		primGetPrinter:hPrinter
  7893                 level:2
  7895 		level:2
  7894                 informationBuffer:informationBuffer
  7896 		informationBuffer:informationBuffer
  7895                 bufferSize: bytesNeeded
  7897 		bufferSize: bytesNeeded
  7896                 bufferNeededSize:sizeBytesArray.
  7898 		bufferNeededSize:sizeBytesArray.
  7897      self assert: rslt.
  7899      self assert: rslt.
  7898      informationBuffer inspect.
  7900      informationBuffer inspect.
  7899      self closePrinter: printerName.
  7901      self closePrinter: printerName.
  7900 "
  7902 "
  7901 
  7903 
  8021       'CSY'     'cs_CS'
  8023       'CSY'     'cs_CS'
  8022       'ELL'     'el_EL'
  8024       'ELL'     'el_EL'
  8023       'NON'     'no_NO'
  8025       'NON'     'no_NO'
  8024       'NOR'     'no_NO'
  8026       'NOR'     'no_NO'
  8025      ) pairWiseDo:[:key :mappedValue|
  8027      ) pairWiseDo:[:key :mappedValue|
  8026         key = windowsLanguageString ifTrue:[
  8028 	key = windowsLanguageString ifTrue:[
  8027             ^ mappedValue
  8029 	    ^ mappedValue
  8028         ]
  8030 	]
  8029     ].
  8031     ].
  8030 
  8032 
  8031     "no mapping"
  8033     "no mapping"
  8032     ^ windowsLanguageString.
  8034     ^ windowsLanguageString.
  8033 
  8035 
  8067 
  8069 
  8068     |errorNumber|
  8070     |errorNumber|
  8069 
  8071 
  8070     "
  8072     "
  8071      HINSTANCE ShellExecute(
  8073      HINSTANCE ShellExecute(
  8072              HWND hwnd,                      // handle to parent window
  8074 	     HWND hwnd,                      // handle to parent window
  8073              LPCTSTR lpOperation,    // pointer to string that specifies operation to perform
  8075 	     LPCTSTR lpOperation,    // pointer to string that specifies operation to perform
  8074              LPCTSTR lpFile,         // pointer to filename or folder name string
  8076 	     LPCTSTR lpFile,         // pointer to filename or folder name string
  8075              LPCTSTR lpParameters,   // pointer to string that specifies executable-file parameters
  8077 	     LPCTSTR lpParameters,   // pointer to string that specifies executable-file parameters
  8076              LPCTSTR lpDirectory,    // pointer to string that specifies default directory
  8078 	     LPCTSTR lpDirectory,    // pointer to string that specifies default directory
  8077              INT nShowCmd                    // whether file is shown when opened
  8079 	     INT nShowCmd                    // whether file is shown when opened
  8078      );
  8080      );
  8079     "
  8081     "
  8080 "/  <apicall: long 'ShellExecuteA' (long char* char* char* char* ulong) module:'shell32.dll'>
  8082 "/  <apicall: long 'ShellExecuteA' (long char* char* char* char* ulong) module:'shell32.dll'>
  8081 %{
  8083 %{
  8082     unsigned long __nShowCmd = 0;
  8084     unsigned long __nShowCmd = 0;
  8083 
  8085 
  8084     if (__isSmallInteger(nShowCmd)) {
  8086     if (__isSmallInteger(nShowCmd)) {
  8085         __nShowCmd = __intVal(nShowCmd);
  8087 	__nShowCmd = __intVal(nShowCmd);
  8086     } else {
  8088     } else {
  8087         if (nShowCmd == @symbol(SW_SHOW)) {
  8089 	if (nShowCmd == @symbol(SW_SHOW)) {
  8088             __nShowCmd = SW_SHOW;
  8090 	    __nShowCmd = SW_SHOW;
  8089         } else if (nShowCmd == @symbol(SW_SHOWNORMAL)) {
  8091 	} else if (nShowCmd == @symbol(SW_SHOWNORMAL)) {
  8090             __nShowCmd = SW_SHOWNORMAL;
  8092 	    __nShowCmd = SW_SHOWNORMAL;
  8091         } else if (nShowCmd == @symbol(SW_SHOWDEFAULT)) {
  8093 	} else if (nShowCmd == @symbol(SW_SHOWDEFAULT)) {
  8092             __nShowCmd = SW_SHOWDEFAULT;
  8094 	    __nShowCmd = SW_SHOWDEFAULT;
  8093         } else if (nShowCmd == @symbol(SW_SHOWMAXIMIZED)) {
  8095 	} else if (nShowCmd == @symbol(SW_SHOWMAXIMIZED)) {
  8094             __nShowCmd = SW_SHOWMAXIMIZED;
  8096 	    __nShowCmd = SW_SHOWMAXIMIZED;
  8095         } else if (nShowCmd == @symbol(SW_SHOWMINIMIZED)) {
  8097 	} else if (nShowCmd == @symbol(SW_SHOWMINIMIZED)) {
  8096             __nShowCmd = SW_SHOWMINIMIZED;
  8098 	    __nShowCmd = SW_SHOWMINIMIZED;
  8097         } else if (nShowCmd == @symbol(SW_SHOWMINNOACTIVE)) {
  8099 	} else if (nShowCmd == @symbol(SW_SHOWMINNOACTIVE)) {
  8098             __nShowCmd = SW_SHOWMINNOACTIVE;
  8100 	    __nShowCmd = SW_SHOWMINNOACTIVE;
  8099         } else if (nShowCmd == @symbol(SW_SHOWNA)) {
  8101 	} else if (nShowCmd == @symbol(SW_SHOWNA)) {
  8100             __nShowCmd = SW_SHOWNA;
  8102 	    __nShowCmd = SW_SHOWNA;
  8101         } else if (nShowCmd == @symbol(SW_SHOWNOACTIVATE)) {
  8103 	} else if (nShowCmd == @symbol(SW_SHOWNOACTIVATE)) {
  8102             __nShowCmd = SW_SHOWNOACTIVATE;
  8104 	    __nShowCmd = SW_SHOWNOACTIVATE;
  8103         } else if (nShowCmd == @symbol(SW_MAXIMIZE)) {
  8105 	} else if (nShowCmd == @symbol(SW_MAXIMIZE)) {
  8104             __nShowCmd = SW_MAXIMIZE;
  8106 	    __nShowCmd = SW_MAXIMIZE;
  8105         } else if (nShowCmd == @symbol(SW_RESTORE)) {
  8107 	} else if (nShowCmd == @symbol(SW_RESTORE)) {
  8106             __nShowCmd = SW_RESTORE;
  8108 	    __nShowCmd = SW_RESTORE;
  8107         } else {
  8109 	} else {
  8108             goto badArgument;
  8110 	    goto badArgument;
  8109         }
  8111 	}
  8110     }
  8112     }
  8111 
  8113 
  8112     if (((lpOperation == nil) || __isString(lpOperation))
  8114     if (((lpOperation == nil) || __isString(lpOperation))
  8113      && ((lpFile == nil) || __isString(lpFile))
  8115      && ((lpFile == nil) || __isString(lpFile))
  8114      && ((lpParameters == nil) || __isString(lpParameters))
  8116      && ((lpParameters == nil) || __isString(lpParameters))
  8115      && ((lpDirectory == nil) || __isString(lpDirectory))
  8117      && ((lpDirectory == nil) || __isString(lpDirectory))
  8116     ) {
  8118     ) {
  8117         HANDLE __hwnd = 0;
  8119 	HANDLE __hwnd = 0;
  8118         char *__lpOperation   = (lpOperation != nil) ? __stringVal(lpOperation) : NULL;
  8120 	char *__lpOperation   = (lpOperation != nil) ? __stringVal(lpOperation) : NULL;
  8119         char *__lpFile        = (lpFile != nil) ? __stringVal(lpFile) : NULL;
  8121 	char *__lpFile        = (lpFile != nil) ? __stringVal(lpFile) : NULL;
  8120         char *__lpParameters  = (lpParameters != nil) ? __stringVal(lpParameters) : NULL;
  8122 	char *__lpParameters  = (lpParameters != nil) ? __stringVal(lpParameters) : NULL;
  8121         char *__lpDirectory   = (lpDirectory != nil) ? __stringVal(lpDirectory) : NULL;
  8123 	char *__lpDirectory   = (lpDirectory != nil) ? __stringVal(lpDirectory) : NULL;
  8122         long result;
  8124 	long result;
  8123 
  8125 
  8124         if (hwnd != nil) {
  8126 	if (hwnd != nil) {
  8125             if (__isExternalAddressLike(hwnd)) {
  8127 	    if (__isExternalAddressLike(hwnd)) {
  8126                 __hwnd = (HANDLE)(__externalAddressVal(hwnd));
  8128 		__hwnd = (HANDLE)(__externalAddressVal(hwnd));
  8127             } else
  8129 	    } else
  8128                 goto badArgument;
  8130 		goto badArgument;
  8129         }
  8131 	}
  8130         result = ShellExecuteA(__hwnd, __lpOperation, __lpFile, __lpParameters, __lpDirectory, __nShowCmd);
  8132 	result = ShellExecuteA(__hwnd, __lpOperation, __lpFile, __lpParameters, __lpDirectory, __nShowCmd);
  8131 
  8133 
  8132         /* MS programmers are brain damaged - here's the proof... */
  8134 	/* MS programmers are brain damaged - here's the proof... */
  8133         if (result > 32) {
  8135 	if (result > 32) {
  8134             RETURN ( self ); /* OK */
  8136 	    RETURN ( self ); /* OK */
  8135         }
  8137 	}
  8136 
  8138 
  8137         switch (result) {
  8139 	switch (result) {
  8138             case 0:
  8140 	    case 0:
  8139             case SE_ERR_OOM:
  8141 	    case SE_ERR_OOM:
  8140                 result = ERROR_NOT_ENOUGH_MEMORY;
  8142 		result = ERROR_NOT_ENOUGH_MEMORY;
  8141                 break;
  8143 		break;
  8142 
  8144 
  8143             case SE_ERR_ACCESSDENIED:
  8145 	    case SE_ERR_ACCESSDENIED:
  8144                 result = ERROR_ACCESS_DENIED;
  8146 		result = ERROR_ACCESS_DENIED;
  8145                 break;
  8147 		break;
  8146 
  8148 
  8147             case SE_ERR_FNF:
  8149 	    case SE_ERR_FNF:
  8148                 result = ERROR_FILE_NOT_FOUND;
  8150 		result = ERROR_FILE_NOT_FOUND;
  8149                 break;
  8151 		break;
  8150 
  8152 
  8151             case SE_ERR_PNF:
  8153 	    case SE_ERR_PNF:
  8152                 result = ERROR_PATH_NOT_FOUND;
  8154 		result = ERROR_PATH_NOT_FOUND;
  8153                 break;
  8155 		break;
  8154 
  8156 
  8155             default:
  8157 	    default:
  8156                 result = ERROR_INVALID_FUNCTION;
  8158 		result = ERROR_INVALID_FUNCTION;
  8157                 break;
  8159 		break;
  8158         }
  8160 	}
  8159         errorNumber = __MKUINT( result );
  8161 	errorNumber = __MKUINT( result );
  8160     }
  8162     }
  8161 badArgument: ;
  8163 badArgument: ;
  8162 %}.
  8164 %}.
  8163     errorNumber isNil ifTrue:[
  8165     errorNumber isNil ifTrue:[
  8164         self error:'invalid argument(s)'.
  8166 	self error:'invalid argument(s)'.
  8165     ] ifFalse:[
  8167     ] ifFalse:[
  8166         (OperatingSystem errorHolderForNumber:errorNumber) reportError
  8168 	(OperatingSystem errorHolderForNumber:errorNumber) reportError
  8167     ].
  8169     ].
  8168 
  8170 
  8169     "
  8171     "
  8170      self
  8172      self
  8171         shellExecute:nil
  8173 	shellExecute:nil
  8172         lpOperation:'open'
  8174 	lpOperation:'open'
  8173         lpFile:(Filename currentDirectory pathName)
  8175 	lpFile:(Filename currentDirectory pathName)
  8174         lpParameters:nil
  8176 	lpParameters:nil
  8175         lpDirectory:(Filename currentDirectory pathName)
  8177 	lpDirectory:(Filename currentDirectory pathName)
  8176         nShowCmd:#SW_SHOWNORMAL
  8178 	nShowCmd:#SW_SHOWNORMAL
  8177 
  8179 
  8178     self
  8180     self
  8179         shellExecute:nil
  8181 	shellExecute:nil
  8180         lpOperation:'explore'
  8182 	lpOperation:'explore'
  8181         lpFile:(Filename currentDirectory pathName)
  8183 	lpFile:(Filename currentDirectory pathName)
  8182         lpParameters:nil
  8184 	lpParameters:nil
  8183         lpDirectory:(Filename currentDirectory pathName)
  8185 	lpDirectory:(Filename currentDirectory pathName)
  8184         nShowCmd:#SW_SHOWNORMAL
  8186 	nShowCmd:#SW_SHOWNORMAL
  8185     "
  8187     "
  8186 
  8188 
  8187     "Modified: / 26-01-2007 / 14:29:21 / cg"
  8189     "Modified: / 26-01-2007 / 14:29:21 / cg"
  8188 ! !
  8190 ! !
  8189 
  8191 
  8208      since my windows system menu crashes so often
  8210      since my windows system menu crashes so often
  8209      (even CTRL-ALT-DEL does no longer function, but ST/X is still alive),
  8211      (even CTRL-ALT-DEL does no longer function, but ST/X is still alive),
  8210      I added this in order to be able to shutdown w95 cleanly"
  8212      I added this in order to be able to shutdown w95 cleanly"
  8211 
  8213 
  8212     confirmationMessageOrNil notNil ifTrue:[
  8214     confirmationMessageOrNil notNil ifTrue:[
  8213         (Dialog confirm:confirmationMessageOrNil) ifFalse:[
  8215 	(Dialog confirm:confirmationMessageOrNil) ifFalse:[
  8214             ^ false
  8216 	    ^ false
  8215         ].
  8217 	].
  8216     ].
  8218     ].
  8217 %{
  8219 %{
  8218     int flag;
  8220     int flag;
  8219 
  8221 
  8220     if (how == @symbol(shutdown)) {
  8222     if (how == @symbol(shutdown)) {
  8221         flag = EWX_SHUTDOWN;
  8223 	flag = EWX_SHUTDOWN;
  8222     } else if (how == @symbol(reboot)) {
  8224     } else if (how == @symbol(reboot)) {
  8223         flag = EWX_REBOOT;
  8225 	flag = EWX_REBOOT;
  8224     } else if (how == @symbol(logoff)) {
  8226     } else if (how == @symbol(logoff)) {
  8225         flag = EWX_LOGOFF;
  8227 	flag = EWX_LOGOFF;
  8226     } else if (how == @symbol(forceShutdown)) {
  8228     } else if (how == @symbol(forceShutdown)) {
  8227         flag = EWX_SHUTDOWN | EWX_FORCE;
  8229 	flag = EWX_SHUTDOWN | EWX_FORCE;
  8228     } else if (how == @symbol(forceReboot)) {
  8230     } else if (how == @symbol(forceReboot)) {
  8229         flag = EWX_REBOOT | EWX_FORCE;
  8231 	flag = EWX_REBOOT | EWX_FORCE;
  8230     } else if (how == @symbol(forceLogoff)) {
  8232     } else if (how == @symbol(forceLogoff)) {
  8231         flag = EWX_LOGOFF | EWX_FORCE;
  8233 	flag = EWX_LOGOFF | EWX_FORCE;
  8232     } else {
  8234     } else {
  8233         RETURN (false);
  8235 	RETURN (false);
  8234     }
  8236     }
  8235     RETURN ((ExitWindowsEx(flag, 0) == TRUE) ? true : false);
  8237     RETURN ((ExitWindowsEx(flag, 0) == TRUE) ? true : false);
  8236 %}
  8238 %}
  8237 ! !
  8239 ! !
  8238 
  8240 
  8258 #ifdef __BORLANDC__
  8260 #ifdef __BORLANDC__
  8259     tmPtr = localtime(&tt);
  8261     tmPtr = localtime(&tt);
  8260 #else
  8262 #else
  8261     /* be thread safe */
  8263     /* be thread safe */
  8262     if (localtime_s(&tmValue, &tt) == 0)
  8264     if (localtime_s(&tmValue, &tt) == 0)
  8263         tmPtr = &tmValue;
  8265 	tmPtr = &tmValue;
  8264     else
  8266     else
  8265         tmPtr = NULL;
  8267 	tmPtr = NULL;
  8266 #endif
  8268 #endif
  8267 
  8269 
  8268     if (tmPtr != NULL) {
  8270     if (tmPtr != NULL) {
  8269         year = __mkSmallInteger(tmPtr->tm_year + 1900);
  8271 	year = __mkSmallInteger(tmPtr->tm_year + 1900);
  8270         month = __mkSmallInteger(tmPtr->tm_mon + 1);
  8272 	month = __mkSmallInteger(tmPtr->tm_mon + 1);
  8271         day = __mkSmallInteger(tmPtr->tm_mday);
  8273 	day = __mkSmallInteger(tmPtr->tm_mday);
  8272     }
  8274     }
  8273 %}.
  8275 %}.
  8274     year isNil ifTrue:[
  8276     year isNil ifTrue:[
  8275         self primitiveFailed
  8277 	self primitiveFailed
  8276     ].
  8278     ].
  8277     aBlock value:year value:month value:day
  8279     aBlock value:year value:month value:day
  8278 
  8280 
  8279     "
  8281     "
  8280      OperatingSystem computeDatePartsOf:0 for:[:y :m :d |
  8282      OperatingSystem computeDatePartsOf:0 for:[:y :m :d |
  8281         y printCR. m printCR. d printCR
  8283 	y printCR. m printCR. d printCR
  8282      ]
  8284      ]
  8283     "
  8285     "
  8284 
  8286 
  8285     "Modified: / 06-07-2006 / 18:18:04 / cg"
  8287     "Modified: / 06-07-2006 / 18:18:04 / cg"
  8286 !
  8288 !
  8295     struct tm tm;
  8297     struct tm tm;
  8296 
  8298 
  8297     if (__bothSmallInteger(y, m)
  8299     if (__bothSmallInteger(y, m)
  8298      && __bothSmallInteger(d, h)
  8300      && __bothSmallInteger(d, h)
  8299      && __bothSmallInteger(min, s)) {
  8301      && __bothSmallInteger(min, s)) {
  8300         time_t t;
  8302 	time_t t;
  8301         TIME_ZONE_INFORMATION tzInfo;
  8303 	TIME_ZONE_INFORMATION tzInfo;
  8302         int gmtoffMinutes;
  8304 	int gmtoffMinutes;
  8303 
  8305 
  8304         if (GetTimeZoneInformation(&tzInfo) < 0) goto error;
  8306 	if (GetTimeZoneInformation(&tzInfo) < 0) goto error;
  8305 
  8307 
  8306         tm.tm_hour = __intVal(h);
  8308 	tm.tm_hour = __intVal(h);
  8307         tm.tm_min = __intVal(min);
  8309 	tm.tm_min = __intVal(min);
  8308         tm.tm_sec = __intVal(s);
  8310 	tm.tm_sec = __intVal(s);
  8309 
  8311 
  8310         tm.tm_year = __intVal(y) - 1900;
  8312 	tm.tm_year = __intVal(y) - 1900;
  8311         tm.tm_mon = __intVal(m) - 1;
  8313 	tm.tm_mon = __intVal(m) - 1;
  8312         tm.tm_mday = __intVal(d);
  8314 	tm.tm_mday = __intVal(d);
  8313         tm.tm_isdst = -1;
  8315 	tm.tm_isdst = -1;
  8314 
  8316 
  8315         t = mktime(&tm);
  8317 	t = mktime(&tm);
  8316 
  8318 
  8317         gmtoffMinutes = tzInfo.Bias;
  8319 	gmtoffMinutes = tzInfo.Bias;
  8318         if (tm.tm_isdst) {
  8320 	if (tm.tm_isdst) {
  8319             gmtoffMinutes += tzInfo.DaylightBias;
  8321 	    gmtoffMinutes += tzInfo.DaylightBias;
  8320         } else {
  8322 	} else {
  8321             gmtoffMinutes += tzInfo.StandardBias;
  8323 	    gmtoffMinutes += tzInfo.StandardBias;
  8322         }
  8324 	}
  8323         t = t - gmtoffMinutes*60;
  8325 	t = t - gmtoffMinutes*60;
  8324         osSeconds = __MKUINT((INT)t);
  8326 	osSeconds = __MKUINT((INT)t);
  8325     }
  8327     }
  8326 error:;
  8328 error:;
  8327 %}.
  8329 %}.
  8328     osSeconds notNil ifTrue:[
  8330     osSeconds notNil ifTrue:[
  8329         ^ osSeconds * 1000 + millis
  8331 	^ osSeconds * 1000 + millis
  8330     ].
  8332     ].
  8331     ^ self primitiveFailed
  8333     ^ self primitiveFailed
  8332 
  8334 
  8333     "
  8335     "
  8334      OperatingSystem computeOSTimeFromUTCYear:1970 month:1 day:1 hour:0 minute:0 second:0 millisecond:0
  8336      OperatingSystem computeOSTimeFromUTCYear:1970 month:1 day:1 hour:0 minute:0 second:0 millisecond:0
  8347     time_t t;
  8349     time_t t;
  8348 
  8350 
  8349     if (__bothSmallInteger(y, m)
  8351     if (__bothSmallInteger(y, m)
  8350      && __bothSmallInteger(d, h)
  8352      && __bothSmallInteger(d, h)
  8351      && __bothSmallInteger(min, s)) {
  8353      && __bothSmallInteger(min, s)) {
  8352         tm.tm_hour = __intVal(h);
  8354 	tm.tm_hour = __intVal(h);
  8353         tm.tm_min = __intVal(min);
  8355 	tm.tm_min = __intVal(min);
  8354         tm.tm_sec = __intVal(s);
  8356 	tm.tm_sec = __intVal(s);
  8355 
  8357 
  8356         tm.tm_year = __intVal(y) - 1900;
  8358 	tm.tm_year = __intVal(y) - 1900;
  8357         tm.tm_mon = __intVal(m) - 1;
  8359 	tm.tm_mon = __intVal(m) - 1;
  8358         tm.tm_mday = __intVal(d);
  8360 	tm.tm_mday = __intVal(d);
  8359         tm.tm_isdst = -1;
  8361 	tm.tm_isdst = -1;
  8360 
  8362 
  8361         t = mktime(&tm);
  8363 	t = mktime(&tm);
  8362         osSeconds = __MKUINT((INT)t);
  8364 	osSeconds = __MKUINT((INT)t);
  8363     }
  8365     }
  8364 %}.
  8366 %}.
  8365     osSeconds notNil ifTrue:[
  8367     osSeconds notNil ifTrue:[
  8366         ^ osSeconds * 1000 + millis
  8368 	^ osSeconds * 1000 + millis
  8367     ].
  8369     ].
  8368     ^ self primitiveFailed
  8370     ^ self primitiveFailed
  8369 
  8371 
  8370     "
  8372     "
  8371      OperatingSystem computeOSTimeFromYear:1970 month:1 day:1 hour:0 minute:0 seconds:0 millis:0
  8373      OperatingSystem computeOSTimeFromYear:1970 month:1 day:1 hour:0 minute:0 seconds:0 millis:0
  8394 #ifdef __BORLANDC__
  8396 #ifdef __BORLANDC__
  8395     tmPtr = localtime(&tt);
  8397     tmPtr = localtime(&tt);
  8396 #else
  8398 #else
  8397     /* be thread safe */
  8399     /* be thread safe */
  8398     if (localtime_s(&tmValue, &tt) == 0)
  8400     if (localtime_s(&tmValue, &tt) == 0)
  8399         tmPtr = &tmValue;
  8401 	tmPtr = &tmValue;
  8400     else
  8402     else
  8401         tmPtr = NULL;
  8403 	tmPtr = NULL;
  8402 #endif
  8404 #endif
  8403 
  8405 
  8404     if (tmPtr != NULL) {
  8406     if (tmPtr != NULL) {
  8405         hours = __mkSmallInteger(tmPtr->tm_hour);
  8407 	hours = __mkSmallInteger(tmPtr->tm_hour);
  8406         minutes = __mkSmallInteger(tmPtr->tm_min);
  8408 	minutes = __mkSmallInteger(tmPtr->tm_min);
  8407         seconds = __mkSmallInteger(tmPtr->tm_sec);
  8409 	seconds = __mkSmallInteger(tmPtr->tm_sec);
  8408     }
  8410     }
  8409 %}.
  8411 %}.
  8410     hours isNil ifTrue:[
  8412     hours isNil ifTrue:[
  8411         self primitiveFailed
  8413 	self primitiveFailed
  8412     ].
  8414     ].
  8413     aBlock value:hours value:minutes value:seconds value:millis
  8415     aBlock value:hours value:minutes value:seconds value:millis
  8414 
  8416 
  8415     "
  8417     "
  8416      OperatingSystem computeTimePartsOf:100 for:[:h :m :s :milli |
  8418      OperatingSystem computeTimePartsOf:100 for:[:h :m :s :milli |
  8417         h printCR. m printCR. s printCR. millis printCR
  8419 	h printCR. m printCR. s printCR. millis printCR
  8418      ]
  8420      ]
  8419     "
  8421     "
  8420 
  8422 
  8421     "Modified: / 06-07-2006 / 18:18:39 / cg"
  8423     "Modified: / 06-07-2006 / 18:18:39 / cg"
  8422 !
  8424 !
  8455 
  8457 
  8456 #ifdef WINDOWS_IS_POSIX_CONFORM_WHICH_IT_IS_NOT
  8458 #ifdef WINDOWS_IS_POSIX_CONFORM_WHICH_IT_IS_NOT
  8457     utcOffset = __MKINT(tmPtr->tm_gmtoff);
  8459     utcOffset = __MKINT(tmPtr->tm_gmtoff);
  8458 #else
  8460 #else
  8459     {
  8461     {
  8460         TIME_ZONE_INFORMATION tzInfo;
  8462 	TIME_ZONE_INFORMATION tzInfo;
  8461         int gmtoffMinutes = 0;
  8463 	int gmtoffMinutes = 0;
  8462 
  8464 
  8463         if (GetTimeZoneInformation(&tzInfo) < 0) goto error;
  8465 	if (GetTimeZoneInformation(&tzInfo) < 0) goto error;
  8464         gmtoffMinutes = tzInfo.Bias;
  8466 	gmtoffMinutes = tzInfo.Bias;
  8465         if (tmPtr->tm_isdst) {
  8467 	if (tmPtr->tm_isdst) {
  8466             gmtoffMinutes += tzInfo.DaylightBias;
  8468 	    gmtoffMinutes += tzInfo.DaylightBias;
  8467         } else {
  8469 	} else {
  8468             gmtoffMinutes += tzInfo.StandardBias;
  8470 	    gmtoffMinutes += tzInfo.StandardBias;
  8469         }
  8471 	}
  8470 
  8472 
  8471         utcOffset = __MKINT(gmtoffMinutes*60);
  8473 	utcOffset = __MKINT(gmtoffMinutes*60);
  8472     }
  8474     }
  8473 #endif
  8475 #endif
  8474 error:;
  8476 error:;
  8475 %}.
  8477 %}.
  8476     "I would love to have SELF-like inline objects ..."
  8478     "I would love to have SELF-like inline objects ..."
  8501      Since this value is wrapping around in regular intervals, this can only be used for
  8503      Since this value is wrapping around in regular intervals, this can only be used for
  8502      short relative time deltas.
  8504      short relative time deltas.
  8503      Use the millisecondTimeXXX:-methods to compare and add time deltas - these know about the wrap.
  8505      Use the millisecondTimeXXX:-methods to compare and add time deltas - these know about the wrap.
  8504 
  8506 
  8505      BAD DESIGN:
  8507      BAD DESIGN:
  8506         This should be changed to return some instance of RelativeTime,
  8508 	This should be changed to return some instance of RelativeTime,
  8507         and these computations moved there.
  8509 	and these computations moved there.
  8508 
  8510 
  8509      Dont use this method in application code since it is an internal (private)
  8511      Dont use this method in application code since it is an internal (private)
  8510      interface. For compatibility with ST-80, use Time millisecondClockValue.
  8512      interface. For compatibility with ST-80, use Time millisecondClockValue.
  8511     "
  8513     "
  8512 
  8514 
  8652      only the calling thread sleep)."
  8654      only the calling thread sleep)."
  8653 
  8655 
  8654 %{  /* NOCONTEXT */
  8656 %{  /* NOCONTEXT */
  8655 
  8657 
  8656     if (__isSmallInteger(numberOfSeconds)) {
  8658     if (__isSmallInteger(numberOfSeconds)) {
  8657         sleep(__intVal(numberOfSeconds));
  8659 	sleep(__intVal(numberOfSeconds));
  8658         RETURN ( self );
  8660 	RETURN ( self );
  8659     }
  8661     }
  8660 %}.
  8662 %}.
  8661     "
  8663     "
  8662      argument not integer
  8664      argument not integer
  8663     "
  8665     "
  8684 
  8686 
  8685     t = __longIntVal(osSeconds);
  8687     t = __longIntVal(osSeconds);
  8686 
  8688 
  8687     /* try cache */
  8689     /* try cache */
  8688     {
  8690     {
  8689         OBJ lastSeconds, lastTimeInfo;
  8691 	OBJ lastSeconds, lastTimeInfo;
  8690 
  8692 
  8691         lastSeconds = @global(LastTimeInfoSeconds);
  8693 	lastSeconds = @global(LastTimeInfoSeconds);
  8692         if (lastSeconds
  8694 	if (lastSeconds
  8693          && (__longIntVal(lastSeconds) == t)
  8695 	 && (__longIntVal(lastSeconds) == t)
  8694          && (@global(LastTimeInfoMilliseconds) == osMilliseconds)
  8696 	 && (@global(LastTimeInfoMilliseconds) == osMilliseconds)
  8695          && (@global(LastTimeInfoIsLocal) == isLocalTime)
  8697 	 && (@global(LastTimeInfoIsLocal) == isLocalTime)
  8696         ) {
  8698 	) {
  8697             lastTimeInfo = @global(LastTimeInfo);
  8699 	    lastTimeInfo = @global(LastTimeInfo);
  8698             if (lastTimeInfo != nil) {
  8700 	    if (lastTimeInfo != nil) {
  8699                 RETURN (lastTimeInfo);
  8701 		RETURN (lastTimeInfo);
  8700             }
  8702 	    }
  8701         }
  8703 	}
  8702     }
  8704     }
  8703 
  8705 
  8704     tt = (time_t)t;
  8706     tt = (time_t)t;
  8705 
  8707 
  8706     if (isLocalTime == true) {
  8708     if (isLocalTime == true) {
  8707 #ifdef __BORLANDC__
  8709 #ifdef __BORLANDC__
  8708         tmPtr = localtime(&tt);
  8710 	tmPtr = localtime(&tt);
  8709 #else
  8711 #else
  8710         /* be thread safe */
  8712 	/* be thread safe */
  8711         if (localtime_s(&tmValue, &tt) == 0)
  8713 	if (localtime_s(&tmValue, &tt) == 0)
  8712             tmPtr = &tmValue;
  8714 	    tmPtr = &tmValue;
  8713         else
  8715 	else
  8714             tmPtr = NULL;
  8716 	    tmPtr = NULL;
  8715 #endif
  8717 #endif
  8716         if (tmPtr == NULL) goto error;
  8718 	if (tmPtr == NULL) goto error;
  8717 
  8719 
  8718 #ifdef WINDOWS_IS_POSIX_CONFORM_WHICH_IT_IS_NOT
  8720 #ifdef WINDOWS_IS_POSIX_CONFORM_WHICH_IT_IS_NOT
  8719         utcOffset = __MKINT(tmPtr->tm_gmtoff);
  8721 	utcOffset = __MKINT(tmPtr->tm_gmtoff);
  8720 #else
  8722 #else
  8721         {
  8723 	{
  8722             TIME_ZONE_INFORMATION tzInfo;
  8724 	    TIME_ZONE_INFORMATION tzInfo;
  8723             int gmtoffMinutes = 0;
  8725 	    int gmtoffMinutes = 0;
  8724 
  8726 
  8725             if (GetTimeZoneInformation(&tzInfo) < 0) goto error;
  8727 	    if (GetTimeZoneInformation(&tzInfo) < 0) goto error;
  8726             gmtoffMinutes = tzInfo.Bias;
  8728 	    gmtoffMinutes = tzInfo.Bias;
  8727             if (tmPtr->tm_isdst) {
  8729 	    if (tmPtr->tm_isdst) {
  8728                 gmtoffMinutes += tzInfo.DaylightBias;
  8730 		gmtoffMinutes += tzInfo.DaylightBias;
  8729             } else {
  8731 	    } else {
  8730                 gmtoffMinutes += tzInfo.StandardBias;
  8732 		gmtoffMinutes += tzInfo.StandardBias;
  8731             }
  8733 	    }
  8732             utcOffset = __MKINT(gmtoffMinutes*60);
  8734 	    utcOffset = __MKINT(gmtoffMinutes*60);
  8733         }
  8735 	}
  8734 #endif
  8736 #endif
  8735     } else {
  8737     } else {
  8736 #ifdef __BORLANDC__
  8738 #ifdef __BORLANDC__
  8737         tmPtr = gmtime(&tt);
  8739 	tmPtr = gmtime(&tt);
  8738 #else
  8740 #else
  8739         /* be thread safe */
  8741 	/* be thread safe */
  8740         if (gmtime_s(&tmValue, &tt) == 0)
  8742 	if (gmtime_s(&tmValue, &tt) == 0)
  8741             tmPtr = &tmValue;
  8743 	    tmPtr = &tmValue;
  8742         else
  8744 	else
  8743             tmPtr = NULL;
  8745 	    tmPtr = NULL;
  8744 #endif
  8746 #endif
  8745         if (tmPtr == NULL) goto error;
  8747 	if (tmPtr == NULL) goto error;
  8746         utcOffset = __mkSmallInteger(0);
  8748 	utcOffset = __mkSmallInteger(0);
  8747     }
  8749     }
  8748 
  8750 
  8749     hours = __mkSmallInteger(tmPtr->tm_hour);
  8751     hours = __mkSmallInteger(tmPtr->tm_hour);
  8750     minutes = __mkSmallInteger(tmPtr->tm_min);
  8752     minutes = __mkSmallInteger(tmPtr->tm_min);
  8751     seconds = __mkSmallInteger(tmPtr->tm_sec);
  8753     seconds = __mkSmallInteger(tmPtr->tm_sec);
  8759 
  8761 
  8760     dst = (tmPtr->tm_isdst == 0) ? false : true;
  8762     dst = (tmPtr->tm_isdst == 0) ? false : true;
  8761 error:;
  8763 error:;
  8762 %}.
  8764 %}.
  8763     dst isNil ifTrue:[
  8765     dst isNil ifTrue:[
  8764         ^ self primitiveFailed
  8766 	^ self primitiveFailed
  8765     ].
  8767     ].
  8766 
  8768 
  8767     info := self timeInfoClass new.
  8769     info := self timeInfoClass new.
  8768     info
  8770     info
  8769         year:year
  8771 	year:year
  8770         month:month
  8772 	month:month
  8771         day:day
  8773 	day:day
  8772         hours:hours
  8774 	hours:hours
  8773         minutes:minutes
  8775 	minutes:minutes
  8774         seconds:seconds
  8776 	seconds:seconds
  8775         milliseconds:osMilliseconds
  8777 	milliseconds:osMilliseconds
  8776         utcOffset:utcOffset
  8778 	utcOffset:utcOffset
  8777         dst:dst
  8779 	dst:dst
  8778         dayInYear:yDay
  8780 	dayInYear:yDay
  8779         dayInWeek:wDay.
  8781 	dayInWeek:wDay.
  8780 
  8782 
  8781     LastTimeInfo := info.
  8783     LastTimeInfo := info.
  8782     LastTimeInfoSeconds := osSeconds.
  8784     LastTimeInfoSeconds := osSeconds.
  8783     LastTimeInfoMilliseconds := osMilliseconds.
  8785     LastTimeInfoMilliseconds := osMilliseconds.
  8784     LastTimeInfoIsLocal := isLocalTime.
  8786     LastTimeInfoIsLocal := isLocalTime.
  8806 
  8808 
  8807     dir := self getHomeDirectory.
  8809     dir := self getHomeDirectory.
  8808     dir isNil ifTrue:[ ^ nil ].
  8810     dir isNil ifTrue:[ ^ nil ].
  8809 
  8811 
  8810     path := dir , '\Desktop'.
  8812     path := dir , '\Desktop'.
  8811     (self isValidPath:path) ifFalse:[ ^ nil ]. 
  8813     (self isValidPath:path) ifFalse:[ ^ nil ].
  8812     ^ path
  8814     ^ path
  8813 
  8815 
  8814     "
  8816     "
  8815      OperatingSystem getDesktopDirectory
  8817      OperatingSystem getDesktopDirectory
  8816     "
  8818     "
  8855     |info gecos|
  8857     |info gecos|
  8856 
  8858 
  8857     info := self userInfoOf:userID.
  8859     info := self userInfoOf:userID.
  8858     (info notNil
  8860     (info notNil
  8859     and:[info includesKey:#gecos]) ifTrue:[
  8861     and:[info includesKey:#gecos]) ifTrue:[
  8860         gecos := info at:#gecos.
  8862 	gecos := info at:#gecos.
  8861         (gecos includes:$,) ifTrue:[
  8863 	(gecos includes:$,) ifTrue:[
  8862             ^ gecos copyTo:(gecos indexOf:$,) - 1
  8864 	    ^ gecos copyTo:(gecos indexOf:$,) - 1
  8863         ].
  8865 	].
  8864         ^ gecos
  8866 	^ gecos
  8865     ].
  8867     ].
  8866     ^ self getUserNameFromID:userID
  8868     ^ self getUserNameFromID:userID
  8867 
  8869 
  8868     "
  8870     "
  8869      OperatingSystem getFullUserNameFromID:0
  8871      OperatingSystem getFullUserNameFromID:0
  8910 
  8912 
  8911     |dir drv path|
  8913     |dir drv path|
  8912 
  8914 
  8913     dir := self getEnvironment:'HOME'.
  8915     dir := self getEnvironment:'HOME'.
  8914     dir isNil ifTrue:[
  8916     dir isNil ifTrue:[
  8915         "for NT/WIN2K/XP users:
  8917 	"for NT/WIN2K/XP users:
  8916          if HOME is nil, try first HOMEHSARE and then HOMEDRIVE and HOMEPATH"
  8918 	 if HOME is nil, try first HOMEHSARE and then HOMEDRIVE and HOMEPATH"
  8917 
  8919 
  8918         dir := self getEnvironment:'HOMESHARE'.
  8920 	dir := self getEnvironment:'HOMESHARE'.
  8919         dir isNil ifTrue:[
  8921 	dir isNil ifTrue:[
  8920             ((drv := self getEnvironment:'HOMEDRIVE') notNil
  8922 	    ((drv := self getEnvironment:'HOMEDRIVE') notNil
  8921              and:[(path := self getEnvironment:'HOMEPATH') notNil]) ifTrue:[
  8923 	     and:[(path := self getEnvironment:'HOMEPATH') notNil]) ifTrue:[
  8922                 dir := drv , path
  8924 		dir := drv , path
  8923             ] ifFalse:[
  8925 	    ] ifFalse:[
  8924                 dir := '.'.
  8926 		dir := '.'.
  8925             ].
  8927 	    ].
  8926         ].
  8928 	].
  8927     ].
  8929     ].
  8928     ^ dir
  8930     ^ dir
  8929 
  8931 
  8930     "
  8932     "
  8931      OperatingSystem getHomeDirectory
  8933      OperatingSystem getHomeDirectory
  8946     extern char *getenv();
  8948     extern char *getenv();
  8947 #endif
  8949 #endif
  8948     char *name = (char *)0;
  8950     char *name = (char *)0;
  8949 
  8951 
  8950     if (firstCall) {
  8952     if (firstCall) {
  8951         DWORD nameSize = sizeof(cachedName);
  8953 	DWORD nameSize = sizeof(cachedName);
  8952 
  8954 
  8953         if (GetUserName(cachedName, &nameSize) == TRUE) {
  8955 	if (GetUserName(cachedName, &nameSize) == TRUE) {
  8954             name = cachedName;
  8956 	    name = cachedName;
  8955             firstCall = 0;
  8957 	    firstCall = 0;
  8956         }
  8958 	}
  8957     } else {
  8959     } else {
  8958         name = cachedName;
  8960 	name = cachedName;
  8959     }
  8961     }
  8960 
  8962 
  8961     /*
  8963     /*
  8962      * try a few common environment variables ...
  8964      * try a few common environment variables ...
  8963      */
  8965      */
  8964     if (! name || (name[0] == 0) ) {
  8966     if (! name || (name[0] == 0) ) {
  8965         name = getenv("LOGIN");
  8967 	name = getenv("LOGIN");
  8966         if (! name || (name[0] == 0) ) {
  8968 	if (! name || (name[0] == 0) ) {
  8967             name = getenv("LOGNAME");
  8969 	    name = getenv("LOGNAME");
  8968             if (! name || (name[0] == 0) ) {
  8970 	    if (! name || (name[0] == 0) ) {
  8969                 name = getenv("USER");
  8971 		name = getenv("USER");
  8970             }
  8972 	    }
  8971         }
  8973 	}
  8972     }
  8974     }
  8973     /*
  8975     /*
  8974      * nope - I really font know who you are.
  8976      * nope - I really font know who you are.
  8975      */
  8977      */
  8976     if (! name || (name[0] == 0) ) {
  8978     if (! name || (name[0] == 0) ) {
  8977         name = "you";
  8979 	name = "you";
  8978     }
  8980     }
  8979 
  8981 
  8980     RETURN ( __MKSTRING(name) );
  8982     RETURN ( __MKSTRING(name) );
  8981 %}.
  8983 %}.
  8982     "
  8984     "
  9001 
  9003 
  9002     "return the user-name-string for a given numeric user-id.
  9004     "return the user-name-string for a given numeric user-id.
  9003      This is the login name, not the fullName."
  9005      This is the login name, not the fullName."
  9004 
  9006 
  9005     aNumber == self getUserID ifTrue:[
  9007     aNumber == self getUserID ifTrue:[
  9006         ^ self getLoginName
  9008 	^ self getLoginName
  9007     ].
  9009     ].
  9008 
  9010 
  9009     ^ '? (' , aNumber printString , ')'
  9011     ^ '? (' , aNumber printString , ')'
  9010 
  9012 
  9011     "
  9013     "
  9026 
  9028 
  9027     |info name "uid gid" dir|
  9029     |info name "uid gid" dir|
  9028 
  9030 
  9029     info := IdentityDictionary new.
  9031     info := IdentityDictionary new.
  9030     name isNil ifTrue:[
  9032     name isNil ifTrue:[
  9031         aNameOrID == self getUserID ifTrue:[
  9033 	aNameOrID == self getUserID ifTrue:[
  9032             name := self getLoginName
  9034 	    name := self getLoginName
  9033         ].
  9035 	].
  9034     ].
  9036     ].
  9035     name notNil ifTrue:[
  9037     name notNil ifTrue:[
  9036         info at:#name put:name.
  9038 	info at:#name put:name.
  9037     ] ifFalse:[
  9039     ] ifFalse:[
  9038         info at:#name put:'unknown'
  9040 	info at:#name put:'unknown'
  9039     ].
  9041     ].
  9040     dir isNil ifTrue:[
  9042     dir isNil ifTrue:[
  9041         aNameOrID == self getUserID ifTrue:[
  9043 	aNameOrID == self getUserID ifTrue:[
  9042             dir := self getHomeDirectory
  9044 	    dir := self getHomeDirectory
  9043         ]
  9045 	]
  9044     ].
  9046     ].
  9045     dir notNil ifTrue:[info at:#dir put:dir].
  9047     dir notNil ifTrue:[info at:#dir put:dir].
  9046     "/ uid notNil ifTrue:[info at:#uid put:uid].
  9048     "/ uid notNil ifTrue:[info at:#uid put:uid].
  9047     "/ gid  notNil ifTrue:[info at:#gid put:gid].
  9049     "/ gid  notNil ifTrue:[info at:#gid put:gid].
  9048     ^ info
  9050     ^ info
  9079     |pid status code core|
  9081     |pid status code core|
  9080 %{
  9082 %{
  9081     DWORD endStatus;
  9083     DWORD endStatus;
  9082 
  9084 
  9083     if (__isExternalAddressLike(pidToWait) ) {
  9085     if (__isExternalAddressLike(pidToWait) ) {
  9084         HANDLE __pidToWait = _HANDLEVal(pidToWait);
  9086 	HANDLE __pidToWait = _HANDLEVal(pidToWait);
  9085         int t;
  9087 	int t;
  9086 
  9088 
  9087 #ifdef PROCESSDEBUG_CHILDPROCESSWAIT
  9089 #ifdef PROCESSDEBUG_CHILDPROCESSWAIT
  9088         console_printf("childProcessWait %x b %d\n",__pidToWait,blocking==true);
  9090 	console_printf("childProcessWait %x b %d\n",__pidToWait,blocking==true);
  9089 #endif
  9091 #endif
  9090         t = blocking==true ? INFINITE : 0;
  9092 	t = blocking==true ? INFINITE : 0;
  9091 
  9093 
  9092 #ifdef DO_WRAP_CALLS
  9094 #ifdef DO_WRAP_CALLS
  9093         do {
  9095 	do {
  9094             __threadErrno = 0;
  9096 	    __threadErrno = 0;
  9095             endStatus = STX_API_CALL2( "WaitForSingleObject", WaitForSingleObject, __pidToWait, t);
  9097 	    endStatus = STX_API_CALL2( "WaitForSingleObject", WaitForSingleObject, __pidToWait, t);
  9096         } while ((endStatus < 0) && (__threadErrno == EINTR));
  9098 	} while ((endStatus < 0) && (__threadErrno == EINTR));
  9097 #else
  9099 #else
  9098         endStatus = WaitForSingleObject(__pidToWait, t);
  9100 	endStatus = WaitForSingleObject(__pidToWait, t);
  9099         if (endStatus < 0) {
  9101 	if (endStatus < 0) {
  9100             __threadErrno = __WIN32_ERR(GetLastError());
  9102 	    __threadErrno = __WIN32_ERR(GetLastError());
  9101         }
  9103 	}
  9102 #endif
  9104 #endif
  9103         if ( endStatus == WAIT_TIMEOUT ) {
  9105 	if ( endStatus == WAIT_TIMEOUT ) {
  9104             if (blocking==true)
  9106 	    if (blocking==true)
  9105                 status = @symbol(timeout);
  9107 		status = @symbol(timeout);
  9106             else {
  9108 	    else {
  9107                 status = @symbol(continue);
  9109 		status = @symbol(continue);
  9108 #ifdef PROCESSDEBUG_CHILDPROCESSWAIT
  9110 #ifdef PROCESSDEBUG_CHILDPROCESSWAIT
  9109                 console_printf("ret nil\n");
  9111 		console_printf("ret nil\n");
  9110 #endif
  9112 #endif
  9111                 RETURN(nil);
  9113 		RETURN(nil);
  9112             }
  9114 	    }
  9113         } else {
  9115 	} else {
  9114             status = @symbol(exit);
  9116 	    status = @symbol(exit);
  9115 #ifdef PROCESSDEBUG_CHILDPROCESSWAIT
  9117 #ifdef PROCESSDEBUG_CHILDPROCESSWAIT
  9116             console_printf("exit\n");
  9118 	    console_printf("exit\n");
  9117 #endif
  9119 #endif
  9118             if (endStatus == WAIT_OBJECT_0) {
  9120 	    if (endStatus == WAIT_OBJECT_0) {
  9119                 if (GetExitCodeProcess(__pidToWait, &endStatus)) {
  9121 		if (GetExitCodeProcess(__pidToWait, &endStatus)) {
  9120                     if (endStatus == STILL_ACTIVE) {
  9122 		    if (endStatus == STILL_ACTIVE) {
  9121                         RETURN(nil);
  9123 			RETURN(nil);
  9122                     }
  9124 		    }
  9123 #ifdef PROCESSDEBUG_CHILDPROCESSWAIT
  9125 #ifdef PROCESSDEBUG_CHILDPROCESSWAIT
  9124                     console_printf("exit %d\n",endStatus);
  9126 		    console_printf("exit %d\n",endStatus);
  9125 #endif
  9127 #endif
  9126                     code = __mkSmallInteger(endStatus);
  9128 		    code = __mkSmallInteger(endStatus);
  9127                 } else {
  9129 		} else {
  9128                     code = __mkSmallInteger(GetLastError());
  9130 		    code = __mkSmallInteger(GetLastError());
  9129                 }
  9131 		}
  9130             } else {
  9132 	    } else {
  9131                 code = __mkSmallInteger(-1);
  9133 		code = __mkSmallInteger(-1);
  9132             }
  9134 	    }
  9133         }
  9135 	}
  9134         core = false;
  9136 	core = false;
  9135         pid = pidToWait;
  9137 	pid = pidToWait;
  9136     }
  9138     }
  9137 %}.
  9139 %}.
  9138 
  9140 
  9139     (status isNil or:[pid isNil]) ifTrue:[
  9141     (status isNil or:[pid isNil]) ifTrue:[
  9140         ^ self primitiveFailed
  9142 	^ self primitiveFailed
  9141     ].
  9143     ].
  9142 
  9144 
  9143 "/ Transcript show:'pid: '; show:pid; show:' status: '; show:status;
  9145 "/ Transcript show:'pid: '; show:pid; show:' status: '; show:status;
  9144 "/ show:' code: '; show:code; show:' core:'; showCR:core.
  9146 "/ show:' code: '; show:code; show:' core:'; showCR:core.
  9145 
  9147 
  9189     int    readCount;
  9191     int    readCount;
  9190     int    writeCount;
  9192     int    writeCount;
  9191     int    exceptCount;
  9193     int    exceptCount;
  9192 
  9194 
  9193     if (__isNonNilObject(readFdArray)) {
  9195     if (__isNonNilObject(readFdArray)) {
  9194         if (! __isArrayLike(readFdArray)) goto fail;
  9196 	if (! __isArrayLike(readFdArray)) goto fail;
  9195         readCount = __arraySize(readFdArray);
  9197 	readCount = __arraySize(readFdArray);
  9196     } else {
  9198     } else {
  9197         readCount = 0;
  9199 	readCount = 0;
  9198     }
  9200     }
  9199 
  9201 
  9200     if (__isNonNilObject(writeFdArray)) {
  9202     if (__isNonNilObject(writeFdArray)) {
  9201         if (! __isArrayLike(writeFdArray)) goto fail;
  9203 	if (! __isArrayLike(writeFdArray)) goto fail;
  9202         writeCount = __arraySize(writeFdArray);
  9204 	writeCount = __arraySize(writeFdArray);
  9203     } else {
  9205     } else {
  9204         writeCount = 0;
  9206 	writeCount = 0;
  9205     }
  9207     }
  9206 
  9208 
  9207     if (__isNonNilObject(exceptFdArray)) {
  9209     if (__isNonNilObject(exceptFdArray)) {
  9208         if (! __isArrayLike(exceptFdArray)) goto fail;
  9210 	if (! __isArrayLike(exceptFdArray)) goto fail;
  9209         exceptCount = __arraySize(exceptFdArray);
  9211 	exceptCount = __arraySize(exceptFdArray);
  9210     } else {
  9212     } else {
  9211         exceptCount = 0;
  9213 	exceptCount = 0;
  9212     }
  9214     }
  9213 
  9215 
  9214     for (i = 0; (i < readCount) && (numHandles < MAXHANDLE);i++) {
  9216     for (i = 0; (i < readCount) && (numHandles < MAXHANDLE);i++) {
  9215         fd = __ArrayInstPtr(readFdArray)->a_element[i];
  9217 	fd = __ArrayInstPtr(readFdArray)->a_element[i];
  9216 
  9218 
  9217         if (fd != nil) {
  9219 	if (fd != nil) {
  9218             if (__isExternalAddressLike(fd)) {
  9220 	    if (__isExternalAddressLike(fd)) {
  9219                 hArray  [numHandles] = _HANDLEVal(fd);
  9221 		hArray  [numHandles] = _HANDLEVal(fd);
  9220                 retArray[numHandles] = i;
  9222 		retArray[numHandles] = i;
  9221                 ++numHandles;
  9223 		++numHandles;
  9222             } else {
  9224 	    } else {
  9223                 int canRead = _canReadWithoutBlocking (__intVal(fd) );
  9225 		int canRead = _canReadWithoutBlocking (__intVal(fd) );
  9224 
  9226 
  9225                 if (canRead > 0 ) {
  9227 		if (canRead > 0 ) {
  9226                     RETURN (fd);
  9228 		    RETURN (fd);
  9227                 } else {
  9229 		} else {
  9228                     if (canRead < 0 ) {
  9230 		    if (canRead < 0 ) {
  9229                         @global(LastErrorNumber) = __mkSmallInteger(EBADF);
  9231 			@global(LastErrorNumber) = __mkSmallInteger(EBADF);
  9230                         RETURN (nil);
  9232 			RETURN (nil);
  9231                     }
  9233 		    }
  9232                 }
  9234 		}
  9233             }
  9235 	    }
  9234         }
  9236 	}
  9235     }
  9237     }
  9236 
  9238 
  9237     for (i = 0; (i < writeCount) && (numHandles < MAXHANDLE);i++) {
  9239     for (i = 0; (i < writeCount) && (numHandles < MAXHANDLE);i++) {
  9238         fd = __ArrayInstPtr(writeFdArray)->a_element[i];
  9240 	fd = __ArrayInstPtr(writeFdArray)->a_element[i];
  9239 
  9241 
  9240         if (fd != nil) {
  9242 	if (fd != nil) {
  9241             if (__isExternalAddressLike(fd)) {
  9243 	    if (__isExternalAddressLike(fd)) {
  9242                 hArray  [numHandles] = _HANDLEVal(fd);
  9244 		hArray  [numHandles] = _HANDLEVal(fd);
  9243                 retArray[numHandles] = i + 10000;
  9245 		retArray[numHandles] = i + 10000;
  9244                 ++numHandles;
  9246 		++numHandles;
  9245             } else {
  9247 	    } else {
  9246                 int canWrite = _canWriteWithoutBlocking (__intVal(fd) );
  9248 		int canWrite = _canWriteWithoutBlocking (__intVal(fd) );
  9247 
  9249 
  9248                 if (canWrite > 0 ) {
  9250 		if (canWrite > 0 ) {
  9249                     RETURN (fd);
  9251 		    RETURN (fd);
  9250                 } else {
  9252 		} else {
  9251                     if (canWrite < 0 ) {
  9253 		    if (canWrite < 0 ) {
  9252                         @global(LastErrorNumber) = __mkSmallInteger(EBADF);
  9254 			@global(LastErrorNumber) = __mkSmallInteger(EBADF);
  9253                         RETURN (nil);
  9255 			RETURN (nil);
  9254                     }
  9256 		    }
  9255                 }
  9257 		}
  9256             }
  9258 	    }
  9257         }
  9259 	}
  9258     }
  9260     }
  9259 
  9261 
  9260     for (i = 0; (i < exceptCount) && (numHandles < MAXHANDLE);i++) {
  9262     for (i = 0; (i < exceptCount) && (numHandles < MAXHANDLE);i++) {
  9261         fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
  9263 	fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
  9262 
  9264 
  9263         if (fd != nil) {
  9265 	if (fd != nil) {
  9264             if (__isExternalAddressLike(fd)) {
  9266 	    if (__isExternalAddressLike(fd)) {
  9265                 hArray  [numHandles] = _HANDLEVal(fd);
  9267 		hArray  [numHandles] = _HANDLEVal(fd);
  9266                 retArray[numHandles] = i + 20000;
  9268 		retArray[numHandles] = i + 20000;
  9267                 ++numHandles;
  9269 		++numHandles;
  9268             }
  9270 	    }
  9269         }
  9271 	}
  9270     }
  9272     }
  9271 
  9273 
  9272     if (__isSmallInteger(millis)) {
  9274     if (__isSmallInteger(millis)) {
  9273         t = __intVal(millis);
  9275 	t = __intVal(millis);
  9274 
  9276 
  9275         if (t <= 0 && numHandles == 0) {
  9277 	if (t <= 0 && numHandles == 0) {
  9276             RETURN (nil);
  9278 	    RETURN (nil);
  9277         }
  9279 	}
  9278     } else {
  9280     } else {
  9279         t = INFINITE;
  9281 	t = INFINITE;
  9280     }
  9282     }
  9281 
  9283 
  9282 #ifdef SELECT3DEBUGWIN32
  9284 #ifdef SELECT3DEBUGWIN32
  9283     console_printf("wait Handles = %d timeout = %d\n",numHandles, t);
  9285     console_printf("wait Handles = %d timeout = %d\n",numHandles, t);
  9284 #endif
  9286 #endif
  9285 
  9287 
  9286     res = __vmWait (numHandles, hArray, MAXHANDLE, t);
  9288     res = __vmWait (numHandles, hArray, MAXHANDLE, t);
  9287 
  9289 
  9288     if (numHandles) {
  9290     if (numHandles) {
  9289         if (res == WAIT_FAILED) {
  9291 	if (res == WAIT_FAILED) {
  9290 #ifdef SELECT2DEBUGWIN32
  9292 #ifdef SELECT2DEBUGWIN32
  9291             console_printf("- error %d; ret nil\n",GetLastError());
  9293 	    console_printf("- error %d; ret nil\n",GetLastError());
  9292 #endif
  9294 #endif
  9293             if (__threadErrno == EINTR) {
  9295 	    if (__threadErrno == EINTR) {
  9294                 __threadErrno = 0;
  9296 		__threadErrno = 0;
  9295                 @global(LastErrorNumber) = nil;
  9297 		@global(LastErrorNumber) = nil;
  9296             } else {
  9298 	    } else {
  9297                 __threadErrno = EBADF;
  9299 		__threadErrno = EBADF;
  9298                 if (@global(InfoPrinting) == true) {
  9300 		if (@global(InfoPrinting) == true) {
  9299                     console_fprintf(stderr, "Win32OS [info]: select errno = %d\n", __threadErrno);
  9301 		    console_fprintf(stderr, "Win32OS [info]: select errno = %d\n", __threadErrno);
  9300                 }
  9302 		}
  9301                 @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  9303 		@global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
  9302             }
  9304 	    }
  9303             RETURN ( nil );
  9305 	    RETURN ( nil );
  9304         }
  9306 	}
  9305 
  9307 
  9306         if (res == WAIT_TIMEOUT) {
  9308 	if (res == WAIT_TIMEOUT) {
  9307 #ifdef SELECT3DEBUGWIN32
  9309 #ifdef SELECT3DEBUGWIN32
  9308             console_printf("- timeOut; ret nil\n" );
  9310 	    console_printf("- timeOut; ret nil\n" );
  9309 #endif
  9311 #endif
  9310             goto polling;
  9312 	    goto polling;
  9311         }
  9313 	}
  9312 
  9314 
  9313         if (res == numHandles) {
  9315 	if (res == numHandles) {
  9314             if (1 /* @global(InfoPrinting) == true */) {
  9316 	    if (1 /* @global(InfoPrinting) == true */) {
  9315                 console_fprintf(stderr, "Win32OS [info]: plugIn event has been handled\n");
  9317 		console_fprintf(stderr, "Win32OS [info]: plugIn event has been handled\n");
  9316             }
  9318 	    }
  9317             __threadErrno = 0;
  9319 	    __threadErrno = 0;
  9318             @global(LastErrorNumber) = nil;
  9320 	    @global(LastErrorNumber) = nil;
  9319             RETURN ( nil );
  9321 	    RETURN ( nil );
  9320         }
  9322 	}
  9321         if ((res < 0) || (res > numHandles)) {
  9323 	if ((res < 0) || (res > numHandles)) {
  9322 #ifdef SELECTDEBUGWIN32
  9324 #ifdef SELECTDEBUGWIN32
  9323             console_printf("- res=%d error1 %d\n", res, GetLastError());
  9325 	    console_printf("- res=%d error1 %d\n", res, GetLastError());
  9324 #endif
  9326 #endif
  9325             __threadErrno = 0;
  9327 	    __threadErrno = 0;
  9326             @global(LastErrorNumber) = nil;
  9328 	    @global(LastErrorNumber) = nil;
  9327             RETURN ( nil );
  9329 	    RETURN ( nil );
  9328         }
  9330 	}
  9329 
  9331 
  9330         ret = res;
  9332 	ret = res;
  9331 
  9333 
  9332         if (ret < numHandles) {
  9334 	if (ret < numHandles) {
  9333             int fd = retArray[ret];
  9335 	    int fd = retArray[ret];
  9334 
  9336 
  9335             @global(LastErrorNumber) = nil;
  9337 	    @global(LastErrorNumber) = nil;
  9336 
  9338 
  9337 #ifdef SELECTDEBUGWIN32
  9339 #ifdef SELECTDEBUGWIN32
  9338             if (ret) console_printf("wait Handles %d %d ret\n", ret, fd);
  9340 	    if (ret) console_printf("wait Handles %d %d ret\n", ret, fd);
  9339 #endif
  9341 #endif
  9340             if (fd < 10000) {
  9342 	    if (fd < 10000) {
  9341                 RETURN ( __ArrayInstPtr(readFdArray)->a_element[fd] );
  9343 		RETURN ( __ArrayInstPtr(readFdArray)->a_element[fd] );
  9342             }
  9344 	    }
  9343             if (fd < 20000) {
  9345 	    if (fd < 20000) {
  9344                 RETURN ( __ArrayInstPtr(writeFdArray)->a_element[fd-10000] );
  9346 		RETURN ( __ArrayInstPtr(writeFdArray)->a_element[fd-10000] );
  9345             }
  9347 	    }
  9346             RETURN ( __ArrayInstPtr(exceptFdArray)->a_element[fd-20000] );
  9348 	    RETURN ( __ArrayInstPtr(exceptFdArray)->a_element[fd-20000] );
  9347         }
  9349 	}
  9348         console_fprintf(stderr, "Win32OS [info]: wait Handles ret = %d error2 %d\n", ret, GetLastError());
  9350 	console_fprintf(stderr, "Win32OS [info]: wait Handles ret = %d error2 %d\n", ret, GetLastError());
  9349         goto fail;
  9351 	goto fail;
  9350     } else {
  9352     } else {
  9351 
  9353 
  9352 polling:
  9354 polling:
  9353 
  9355 
  9354         for (i=0; i < readCount;i++) {
  9356 	for (i=0; i < readCount;i++) {
  9355             fd = __ArrayInstPtr(readFdArray)->a_element[i];
  9357 	    fd = __ArrayInstPtr(readFdArray)->a_element[i];
  9356 
  9358 
  9357             if (fd != nil) {
  9359 	    if (fd != nil) {
  9358                 if (! __isExternalAddressLike(fd)) {
  9360 		if (! __isExternalAddressLike(fd)) {
  9359                     int canRead = _canReadWithoutBlocking (__intVal(fd));
  9361 		    int canRead = _canReadWithoutBlocking (__intVal(fd));
  9360 
  9362 
  9361                     if (canRead > 0 ) {
  9363 		    if (canRead > 0 ) {
  9362                         RETURN (fd);
  9364 			RETURN (fd);
  9363                     } else {
  9365 		    } else {
  9364                         if (canRead < 0 ) {
  9366 			if (canRead < 0 ) {
  9365                             @global(LastErrorNumber) = __mkSmallInteger(EBADF);
  9367 			    @global(LastErrorNumber) = __mkSmallInteger(EBADF);
  9366                             RETURN (nil);
  9368 			    RETURN (nil);
  9367                         }
  9369 			}
  9368                     }
  9370 		    }
  9369                 }
  9371 		}
  9370             }
  9372 	    }
  9371         }
  9373 	}
  9372 
  9374 
  9373         for (i=0; i < writeCount;i++) {
  9375 	for (i=0; i < writeCount;i++) {
  9374             fd = __ArrayInstPtr(writeFdArray)->a_element[i];
  9376 	    fd = __ArrayInstPtr(writeFdArray)->a_element[i];
  9375 
  9377 
  9376             if (fd != nil) {
  9378 	    if (fd != nil) {
  9377                 if (! __isExternalAddressLike(fd)) {
  9379 		if (! __isExternalAddressLike(fd)) {
  9378                     int canWrite = _canWriteWithoutBlocking (__intVal(fd));
  9380 		    int canWrite = _canWriteWithoutBlocking (__intVal(fd));
  9379 
  9381 
  9380                     if (canWrite > 0 ) {
  9382 		    if (canWrite > 0 ) {
  9381                         RETURN (fd);
  9383 			RETURN (fd);
  9382                     } else {
  9384 		    } else {
  9383                         if (canWrite < 0 ) {
  9385 			if (canWrite < 0 ) {
  9384                             @global(LastErrorNumber) = __mkSmallInteger(EBADF);
  9386 			    @global(LastErrorNumber) = __mkSmallInteger(EBADF);
  9385                             RETURN (nil);
  9387 			    RETURN (nil);
  9386                         }
  9388 			}
  9387                     }
  9389 		    }
  9388                 }
  9390 		}
  9389             }
  9391 	    }
  9390         }
  9392 	}
  9391 
  9393 
  9392         @global(LastErrorNumber) = nil;
  9394 	@global(LastErrorNumber) = nil;
  9393         RETURN ( nil );
  9395 	RETURN ( nil );
  9394     }
  9396     }
  9395 
  9397 
  9396 fail: ;
  9398 fail: ;
  9397 %}.
  9399 %}.
  9398     "
  9400     "
  9429     DWORD res;
  9431     DWORD res;
  9430     HANDLE hArray[MAXHANDLE];
  9432     HANDLE hArray[MAXHANDLE];
  9431     INT i, count;
  9433     INT i, count;
  9432 
  9434 
  9433     if (! __isArrayLike(fdOrHandleArray)) {
  9435     if (! __isArrayLike(fdOrHandleArray)) {
  9434         goto fail;
  9436 	goto fail;
  9435     }
  9437     }
  9436     count = __arraySize(fdOrHandleArray);
  9438     count = __arraySize(fdOrHandleArray);
  9437 
  9439 
  9438     for (i=0; i<count; i++) {
  9440     for (i=0; i<count; i++) {
  9439         OBJ fdOrHandle = __ArrayInstPtr(fdOrHandleArray)->a_element[i];
  9441 	OBJ fdOrHandle = __ArrayInstPtr(fdOrHandleArray)->a_element[i];
  9440         HANDLE h;
  9442 	HANDLE h;
  9441 
  9443 
  9442         if (__isExternalAddressLike(fdOrHandle)) {
  9444 	if (__isExternalAddressLike(fdOrHandle)) {
  9443             h = _HANDLEVal(fdOrHandle);
  9445 	    h = _HANDLEVal(fdOrHandle);
  9444         } else {
  9446 	} else {
  9445             if (__isSmallInteger(fdOrHandle)) {
  9447 	    if (__isSmallInteger(fdOrHandle)) {
  9446                 h = (HANDLE) _get_osfhandle (__intVal(fdOrHandle));
  9448 		h = (HANDLE) _get_osfhandle (__intVal(fdOrHandle));
  9447             } else {
  9449 	    } else {
  9448                 goto fail;
  9450 		goto fail;
  9449             }
  9451 	    }
  9450         }
  9452 	}
  9451         hArray[i] = h;
  9453 	hArray[i] = h;
  9452     }
  9454     }
  9453 
  9455 
  9454     if (__isSmallInteger(millis)) {
  9456     if (__isSmallInteger(millis)) {
  9455         t = __intVal(millis);
  9457 	t = __intVal(millis);
  9456     } else {
  9458     } else {
  9457         t = INFINITE;
  9459 	t = INFINITE;
  9458     }
  9460     }
  9459 
  9461 
  9460 #ifdef DO_WRAP_CALLS
  9462 #ifdef DO_WRAP_CALLS
  9461     do {
  9463     do {
  9462         __threadErrno = 0;
  9464 	__threadErrno = 0;
  9463         res = STX_API_CALL4( "WaitForMultipleObjects", WaitForMultipleObjects, count, hArray, FALSE, t);
  9465 	res = STX_API_CALL4( "WaitForMultipleObjects", WaitForMultipleObjects, count, hArray, FALSE, t);
  9464     } while ((res < 0) && (__threadErrno == EINTR));
  9466     } while ((res < 0) && (__threadErrno == EINTR));
  9465 #else
  9467 #else
  9466     res = WaitForMultipleObjects(count, hArray, FALSE, t);
  9468     res = WaitForMultipleObjects(count, hArray, FALSE, t);
  9467     if (res < 0) {
  9469     if (res < 0) {
  9468         __threadErrno = __WIN32_ERR(GetLastError());
  9470 	__threadErrno = __WIN32_ERR(GetLastError());
  9469     }
  9471     }
  9470 #endif
  9472 #endif
  9471     if (res == WAIT_FAILED) {
  9473     if (res == WAIT_FAILED) {
  9472         RETURN (nil);
  9474 	RETURN (nil);
  9473     }
  9475     }
  9474     if (res == WAIT_TIMEOUT) {
  9476     if (res == WAIT_TIMEOUT) {
  9475         RETURN (nil);
  9477 	RETURN (nil);
  9476     }
  9478     }
  9477     if ((res >= WAIT_OBJECT_0) && (res < (WAIT_OBJECT_0+count))) {
  9479     if ((res >= WAIT_OBJECT_0) && (res < (WAIT_OBJECT_0+count))) {
  9478         RETURN (__ArrayInstPtr(fdOrHandleArray)->a_element[res-WAIT_OBJECT_0]);
  9480 	RETURN (__ArrayInstPtr(fdOrHandleArray)->a_element[res-WAIT_OBJECT_0]);
  9479     }
  9481     }
  9480 
  9482 
  9481     RETURN (nil);
  9483     RETURN (nil);
  9482 fail: ;
  9484 fail: ;
  9483 %}.
  9485 %}.
  9498     INT t;
  9500     INT t;
  9499     DWORD res;
  9501     DWORD res;
  9500     HANDLE h = NULL;
  9502     HANDLE h = NULL;
  9501 
  9503 
  9502     if (__isExternalAddressLike(fdOrHandle)) {
  9504     if (__isExternalAddressLike(fdOrHandle)) {
  9503         h = _HANDLEVal(fdOrHandle);
  9505 	h = _HANDLEVal(fdOrHandle);
  9504     } else {
  9506     } else {
  9505         if (__isSmallInteger(fdOrHandle)) {
  9507 	if (__isSmallInteger(fdOrHandle)) {
  9506             h = (HANDLE) _get_osfhandle (__intVal(fdOrHandle));
  9508 	    h = (HANDLE) _get_osfhandle (__intVal(fdOrHandle));
  9507         } else {
  9509 	} else {
  9508             goto fail;
  9510 	    goto fail;
  9509         }
  9511 	}
  9510     }
  9512     }
  9511 
  9513 
  9512     if (__isSmallInteger(millis)) {
  9514     if (__isSmallInteger(millis)) {
  9513         t = __intVal(millis);
  9515 	t = __intVal(millis);
  9514     } else {
  9516     } else {
  9515         t = INFINITE;
  9517 	t = INFINITE;
  9516     }
  9518     }
  9517 
  9519 
  9518 #ifdef DO_WRAP_CALLS
  9520 #ifdef DO_WRAP_CALLS
  9519     do {
  9521     do {
  9520         __threadErrno = 0;
  9522 	__threadErrno = 0;
  9521         res = STX_API_CALL2( "WaitForSingleObject", WaitForSingleObject, h,  t);
  9523 	res = STX_API_CALL2( "WaitForSingleObject", WaitForSingleObject, h,  t);
  9522     } while ((res < 0) && (__threadErrno == EINTR));
  9524     } while ((res < 0) && (__threadErrno == EINTR));
  9523 #else
  9525 #else
  9524     res = WaitForSingleObject(h, t);
  9526     res = WaitForSingleObject(h, t);
  9525     if (res < 0) {
  9527     if (res < 0) {
  9526         __threadErrno = __WIN32_ERR(GetLastError());
  9528 	__threadErrno = __WIN32_ERR(GetLastError());
  9527     }
  9529     }
  9528 #endif
  9530 #endif
  9529     if (res == WAIT_FAILED) {
  9531     if (res == WAIT_FAILED) {
  9530         RETURN (nil);
  9532 	RETURN (nil);
  9531     }
  9533     }
  9532     if (res == WAIT_TIMEOUT) {
  9534     if (res == WAIT_TIMEOUT) {
  9533         RETURN (nil);
  9535 	RETURN (nil);
  9534     }
  9536     }
  9535 
  9537 
  9536     RETURN (fdOrHandle);
  9538     RETURN (fdOrHandle);
  9537 fail: ;
  9539 fail: ;
  9538 %}.
  9540 %}.
  9723 
  9725 
  9724 !Win32OperatingSystem::FileStatusInfo class methodsFor:'instance creation'!
  9726 !Win32OperatingSystem::FileStatusInfo class methodsFor:'instance creation'!
  9725 
  9727 
  9726 type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT created:cT path:lP alternativeName:name2
  9728 type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT created:cT path:lP alternativeName:name2
  9727     ^ self basicNew
  9729     ^ self basicNew
  9728         type:t mode:m uid:u gid:g size:s
  9730 	type:t mode:m uid:u gid:g size:s
  9729         id:i accessed:aT modified:mT created:cT
  9731 	id:i accessed:aT modified:mT created:cT
  9730         path:lP alternativeName:name2
  9732 	path:lP alternativeName:name2
  9731 !
  9733 !
  9732 
  9734 
  9733 type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT created:cT path:lP fullName:fullName alternativeName:name2
  9735 type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT created:cT path:lP fullName:fullName alternativeName:name2
  9734     ^ self basicNew
  9736     ^ self basicNew
  9735         type:t mode:m uid:u gid:g size:s
  9737 	type:t mode:m uid:u gid:g size:s
  9736         id:i accessed:aT modified:mT created:cT
  9738 	id:i accessed:aT modified:mT created:cT
  9737         path:lP
  9739 	path:lP
  9738         fullName:fullName
  9740 	fullName:fullName
  9739         alternativeName:name2
  9741 	alternativeName:name2
  9740 ! !
  9742 ! !
  9741 
  9743 
  9742 !Win32OperatingSystem::FileStatusInfo methodsFor:'accessing'!
  9744 !Win32OperatingSystem::FileStatusInfo methodsFor:'accessing'!
  9743 
  9745 
  9744 accessTime
  9746 accessTime
  9812 path
  9814 path
  9813     "for symbolic links only: return the path where the symbolic link points to"
  9815     "for symbolic links only: return the path where the symbolic link points to"
  9814 
  9816 
  9815     "/ access lazily...
  9817     "/ access lazily...
  9816     path isNil ifTrue:[
  9818     path isNil ifTrue:[
  9817         type == #symbolicLink ifTrue:[
  9819 	type == #symbolicLink ifTrue:[
  9818             path := OperatingSystem getLinkTarget:fullName.
  9820 	    path := OperatingSystem getLinkTarget:fullName.
  9819         ]
  9821 	]
  9820     ].
  9822     ].
  9821 
  9823 
  9822     ^ path
  9824     ^ path
  9823 
  9825 
  9824     "Modified: / 07-02-2007 / 10:31:56 / cg"
  9826     "Modified: / 07-02-2007 / 10:31:56 / cg"
 10061     This is an auxillary class, that holds information about status changes of
 10063     This is an auxillary class, that holds information about status changes of
 10062     operating system processes (these are no smalltalk processes!!).
 10064     operating system processes (these are no smalltalk processes!!).
 10063 
 10065 
 10064     [Instance variables:]
 10066     [Instance variables:]
 10065 
 10067 
 10066         pid     <Integer>       OS-Process identifier
 10068 	pid     <Integer>       OS-Process identifier
 10067 
 10069 
 10068         status  <Symbol>        either #exit #signal #stop #continue
 10070 	status  <Symbol>        either #exit #signal #stop #continue
 10069 
 10071 
 10070         code    <Integer>       either exitcode or signalnumber
 10072 	code    <Integer>       either exitcode or signalnumber
 10071 
 10073 
 10072         core    <Boolean>       true if core has been dumped
 10074 	core    <Boolean>       true if core has been dumped
 10073 
 10075 
 10074 
 10076 
 10075     [author:]
 10077     [author:]
 10076         Stefan Vogel
 10078 	Stefan Vogel
 10077 
 10079 
 10078     [see also:]
 10080     [see also:]
 10079         OperatingSystem
 10081 	OperatingSystem
 10080 "
 10082 "
 10081 ! !
 10083 ! !
 10082 
 10084 
 10083 !Win32OperatingSystem::OSProcessStatus class methodsFor:'instance creation'!
 10085 !Win32OperatingSystem::OSProcessStatus class methodsFor:'instance creation'!
 10084 
 10086 
 10223 
 10225 
 10224 pComment
 10226 pComment
 10225     |pComment|
 10227     |pComment|
 10226 
 10228 
 10227     pComment := self unsignedLongAt:(20 + 1).
 10229     pComment := self unsignedLongAt:(20 + 1).
 10228     ^ pComment == 0 
 10230     ^ pComment == 0
 10229         ifTrue:''
 10231 	ifTrue:''
 10230         ifFalse:[ (ExternalBytes address:pComment) stringAt:1 ]
 10232 	ifFalse:[ (ExternalBytes address:pComment) stringAt:1 ]
 10231 
 10233 
 10232     "Created: / 01-08-2006 / 14:02:55 / fm"
 10234     "Created: / 01-08-2006 / 14:02:55 / fm"
 10233     "Modified: / 16-04-2007 / 13:08:39 / cg"
 10235     "Modified: / 16-04-2007 / 13:08:39 / cg"
 10234 !
 10236 !
 10235 
 10237 
 10250     pLocation := self unsignedLongAt:(24 + 1).
 10252     pLocation := self unsignedLongAt:(24 + 1).
 10251     pLocation == 0 ifTrue:[^ nil].
 10253     pLocation == 0 ifTrue:[^ nil].
 10252 
 10254 
 10253     externalBytes := ExternalBytes address:pLocation.
 10255     externalBytes := ExternalBytes address:pLocation.
 10254     ^ externalBytes isEmpty
 10256     ^ externalBytes isEmpty
 10255         ifTrue:[ nil ]
 10257 	ifTrue:[ nil ]
 10256         ifFalse:[ externalBytes stringAt:1 ]
 10258 	ifFalse:[ externalBytes stringAt:1 ]
 10257 
 10259 
 10258     "Created: / 01-08-2006 / 14:03:21 / fm"
 10260     "Created: / 01-08-2006 / 14:03:21 / fm"
 10259     "Modified: / 18-10-2006 / 12:06:45 / User"
 10261     "Modified: / 18-10-2006 / 12:06:45 / User"
 10260     "Modified: / 16-04-2007 / 13:08:27 / cg"
 10262     "Modified: / 16-04-2007 / 13:08:27 / cg"
 10261 !
 10263 !
 10278 
 10280 
 10279 rootKeyNames
 10281 rootKeyNames
 10280     "returns a collection of root keyNames"
 10282     "returns a collection of root keyNames"
 10281 
 10283 
 10282     ^ #(
 10284     ^ #(
 10283         'HKEY_CLASSES_ROOT'
 10285 	'HKEY_CLASSES_ROOT'
 10284         'HKEY_CURRENT_USER'
 10286 	'HKEY_CURRENT_USER'
 10285         'HKEY_LOCAL_MACHINE'
 10287 	'HKEY_LOCAL_MACHINE'
 10286         'HKEY_USERS'
 10288 	'HKEY_USERS'
 10287         'HKEY_PERFORMANCE_DATA'
 10289 	'HKEY_PERFORMANCE_DATA'
 10288         'HKEY_CURRENT_CONFIG'
 10290 	'HKEY_CURRENT_CONFIG'
 10289         'HKEY_DYN_DATA'
 10291 	'HKEY_DYN_DATA'
 10290       )
 10292       )
 10291 !
 10293 !
 10292 
 10294 
 10293 separator
 10295 separator
 10294     "returns the registry-key-path separator character"
 10296     "returns the registry-key-path separator character"
 10301 documentation
 10303 documentation
 10302 "
 10304 "
 10303     Interface to a WIN32 registry.
 10305     Interface to a WIN32 registry.
 10304 
 10306 
 10305     As this is a private class, access it via
 10307     As this is a private class, access it via
 10306         Win32OperatingSystem registryEntry
 10308 	Win32OperatingSystem registryEntry
 10307 
 10309 
 10308     [author:]
 10310     [author:]
 10309         Claus Gittinger (initial version & cleanup)
 10311 	Claus Gittinger (initial version & cleanup)
 10310 "
 10312 "
 10311 !
 10313 !
 10312 
 10314 
 10313 examples
 10315 examples
 10314 "
 10316 "
 10315     retrieve an existing entry by key:
 10317     retrieve an existing entry by key:
 10316                                                                         [exBegin]
 10318 									[exBegin]
 10317         |k|
 10319 	|k|
 10318 
 10320 
 10319         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X'
 10321 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X'
 10320                                                                         [exEnd]
 10322 									[exEnd]
 10321 
 10323 
 10322 
 10324 
 10323     retrieve a non-existing entry by key:
 10325     retrieve a non-existing entry by key:
 10324                                                                         [exBegin]
 10326 									[exBegin]
 10325         |k|
 10327 	|k|
 10326 
 10328 
 10327         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\xxx'
 10329 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\xxx'
 10328                                                                         [exEnd]
 10330 									[exEnd]
 10329 
 10331 
 10330 
 10332 
 10331     ask a keys value:
 10333     ask a keys value:
 10332                                                                         [exBegin]
 10334 									[exBegin]
 10333         |k|
 10335 	|k|
 10334 
 10336 
 10335         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion'.
 10337 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion'.
 10336         Transcript show:'Windows serial NR:'; showCR:(k valueNamed:'ProductId').
 10338 	Transcript show:'Windows serial NR:'; showCR:(k valueNamed:'ProductId').
 10337 
 10339 
 10338         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X'.
 10340 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X'.
 10339         Transcript showCR:(k valueNamed:'CurrentVersion').
 10341 	Transcript showCR:(k valueNamed:'CurrentVersion').
 10340                                                                         [exEnd]
 10342 									[exEnd]
 10341 
 10343 
 10342 
 10344 
 10343     create a sub-key (if not already present):
 10345     create a sub-key (if not already present):
 10344                                                                         [exBegin]
 10346 									[exBegin]
 10345         |k subKey|
 10347 	|k subKey|
 10346 
 10348 
 10347         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X'.
 10349 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X'.
 10348         subKey := k createSubKeyNamed:'RegistryDemo'
 10350 	subKey := k createSubKeyNamed:'RegistryDemo'
 10349                                                                         [exEnd]
 10351 									[exEnd]
 10350 
 10352 
 10351 
 10353 
 10352     change a keys value:
 10354     change a keys value:
 10353                                                                         [exBegin]
 10355 									[exBegin]
 10354         |k|
 10356 	|k|
 10355 
 10357 
 10356         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X\RegistryDemo'.
 10358 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X\RegistryDemo'.
 10357         k valueNamed:'FooBarBaz' put:'a foo bar baz string'.
 10359 	k valueNamed:'FooBarBaz' put:'a foo bar baz string'.
 10358                                                                         [exEnd]
 10360 									[exEnd]
 10359 
 10361 
 10360     delete a value:
 10362     delete a value:
 10361                                                                         [exBegin]
 10363 									[exBegin]
 10362         |k|
 10364 	|k|
 10363 
 10365 
 10364         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X\RegistryDemo'.
 10366 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X\RegistryDemo'.
 10365         k deleteValueNamed:'FooBarBaz'.
 10367 	k deleteValueNamed:'FooBarBaz'.
 10366                                                                         [exEnd]
 10368 									[exEnd]
 10367 
 10369 
 10368     delete a key:
 10370     delete a key:
 10369                                                                         [exBegin]
 10371 									[exBegin]
 10370         |k|
 10372 	|k|
 10371 
 10373 
 10372         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X'.
 10374 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X'.
 10373         k deleteSubKeyNamed:'RegistryDemo'.
 10375 	k deleteSubKeyNamed:'RegistryDemo'.
 10374                                                                         [exEnd]
 10376 									[exEnd]
 10375 
 10377 
 10376     enumerate keys:
 10378     enumerate keys:
 10377                                                                         [exBegin]
 10379 									[exBegin]
 10378         |k|
 10380 	|k|
 10379 
 10381 
 10380         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software'.
 10382 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software'.
 10381         k subKeysDo:[:subKey |
 10383 	k subKeysDo:[:subKey |
 10382             Transcript showCR:subKey path
 10384 	    Transcript showCR:subKey path
 10383         ]
 10385 	]
 10384                                                                         [exEnd]
 10386 									[exEnd]
 10385 
 10387 
 10386     enumerate all keys (recursive):
 10388     enumerate all keys (recursive):
 10387                                                                         [exBegin]
 10389 									[exBegin]
 10388         |k|
 10390 	|k|
 10389 
 10391 
 10390         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software'.
 10392 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\Software'.
 10391         k allSubKeysDo:[:subKey |
 10393 	k allSubKeysDo:[:subKey |
 10392             Transcript showCR:subKey path
 10394 	    Transcript showCR:subKey path
 10393         ]
 10395 	]
 10394                                                                         [exEnd]
 10396 									[exEnd]
 10395 
 10397 
 10396     fetch value by index:
 10398     fetch value by index:
 10397                                                                         [exBegin]
 10399 									[exBegin]
 10398         |k|
 10400 	|k|
 10399 
 10401 
 10400         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'.
 10402 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'.
 10401         Transcript showCR:(k valueNameAtIndex:0)
 10403 	Transcript showCR:(k valueNameAtIndex:0)
 10402                                                                         [exEnd]
 10404 									[exEnd]
 10403 
 10405 
 10404 
 10406 
 10405     enumerate value names:
 10407     enumerate value names:
 10406                                                                         [exBegin]
 10408 									[exBegin]
 10407         |k|
 10409 	|k|
 10408 
 10410 
 10409         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'.
 10411 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'.
 10410         k valueNamesDo:[:nm  |
 10412 	k valueNamesDo:[:nm  |
 10411            Transcript showCR:nm.
 10413 	   Transcript showCR:nm.
 10412         ]
 10414 	]
 10413                                                                         [exEnd]
 10415 									[exEnd]
 10414 
 10416 
 10415     enumerate values:
 10417     enumerate values:
 10416                                                                         [exBegin]
 10418 									[exBegin]
 10417         |k|
 10419 	|k|
 10418 
 10420 
 10419         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'.
 10421 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'.
 10420         k valueNamesAndValuesDo:[:nm :val |
 10422 	k valueNamesAndValuesDo:[:nm :val |
 10421             Transcript showCR:(nm , ' -> ' , val storeString).
 10423 	    Transcript showCR:(nm , ' -> ' , val storeString).
 10422         ]
 10424 	]
 10423                                                                         [exEnd]
 10425 									[exEnd]
 10424 
 10426 
 10425     search for a value (where does NT store the domain ?):
 10427     search for a value (where does NT store the domain ?):
 10426                                                                         [exBegin]
 10428 									[exBegin]
 10427         |k|
 10429 	|k|
 10428 
 10430 
 10429         k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\System'.
 10431 	k := Win32OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\System'.
 10430         k subKeysDo:[:subKey |
 10432 	k subKeysDo:[:subKey |
 10431             subKey subKeysDo:[:subSubKey |
 10433 	    subKey subKeysDo:[:subSubKey |
 10432                 |tcp params|
 10434 		|tcp params|
 10433 
 10435 
 10434                 (subSubKey path asLowercase endsWith:'services') ifTrue:[
 10436 		(subSubKey path asLowercase endsWith:'services') ifTrue:[
 10435                     tcp := subSubKey subKeyNamed:'tcpip'.
 10437 		    tcp := subSubKey subKeyNamed:'tcpip'.
 10436                     tcp notNil ifTrue:[
 10438 		    tcp notNil ifTrue:[
 10437                         params := tcp subKeyNamed:'parameters'.
 10439 			params := tcp subKeyNamed:'parameters'.
 10438                         params notNil ifTrue:[
 10440 			params notNil ifTrue:[
 10439                             Transcript showCR:'Domain is found in ' , params path ,
 10441 			    Transcript showCR:'Domain is found in ' , params path ,
 10440                                         ' value: ' , (params valueNamed:'Domain').
 10442 					' value: ' , (params valueNamed:'Domain').
 10441                             params close.
 10443 			    params close.
 10442                         ].
 10444 			].
 10443                         tcp close.
 10445 			tcp close.
 10444                     ]
 10446 		    ]
 10445                 ]
 10447 		]
 10446             ]
 10448 	    ]
 10447         ]
 10449 	]
 10448                                                                         [exEnd]
 10450 									[exEnd]
 10449 
 10451 
 10450 
 10452 
 10451 "
 10453 "
 10452 ! !
 10454 ! !
 10453 
 10455 
 10464     HKEY_PERFORMANCE_DATA := %{ __MKEXTERNALADDRESS(HKEY_PERFORMANCE_DATA) %}.
 10466     HKEY_PERFORMANCE_DATA := %{ __MKEXTERNALADDRESS(HKEY_PERFORMANCE_DATA) %}.
 10465     HKEY_CURRENT_CONFIG   := %{ __MKEXTERNALADDRESS(HKEY_CURRENT_CONFIG) %}.
 10467     HKEY_CURRENT_CONFIG   := %{ __MKEXTERNALADDRESS(HKEY_CURRENT_CONFIG) %}.
 10466     HKEY_DYN_DATA         := %{ __MKEXTERNALADDRESS(HKEY_DYN_DATA) %}.
 10468     HKEY_DYN_DATA         := %{ __MKEXTERNALADDRESS(HKEY_DYN_DATA) %}.
 10467 
 10469 
 10468     "
 10470     "
 10469         self initialize
 10471 	self initialize
 10470     "
 10472     "
 10471 
 10473 
 10472     "Created: / 19.5.1999 / 21:39:57 / cg"
 10474     "Created: / 19.5.1999 / 21:39:57 / cg"
 10473     "Modified: / 19.5.1999 / 22:45:31 / cg"
 10475     "Modified: / 19.5.1999 / 22:45:31 / cg"
 10474 !
 10476 !
 10478      (these are shared and not finalized, as opposed to all other keys)"
 10480      (these are shared and not finalized, as opposed to all other keys)"
 10479 
 10481 
 10480     HKEY_CLASSES_ROOT isNil ifTrue:[self initialize].
 10482     HKEY_CLASSES_ROOT isNil ifTrue:[self initialize].
 10481 
 10483 
 10482     specialKeyStringOrSymbol = #'HKEY_CLASSES_ROOT' ifTrue:[
 10484     specialKeyStringOrSymbol = #'HKEY_CLASSES_ROOT' ifTrue:[
 10483         ^ HKEY_CLASSES_ROOT.
 10485 	^ HKEY_CLASSES_ROOT.
 10484     ].
 10486     ].
 10485     specialKeyStringOrSymbol = #'HKEY_CURRENT_USER' ifTrue:[
 10487     specialKeyStringOrSymbol = #'HKEY_CURRENT_USER' ifTrue:[
 10486         ^ HKEY_CURRENT_USER.
 10488 	^ HKEY_CURRENT_USER.
 10487     ].
 10489     ].
 10488     specialKeyStringOrSymbol = #'HKEY_LOCAL_MACHINE' ifTrue:[
 10490     specialKeyStringOrSymbol = #'HKEY_LOCAL_MACHINE' ifTrue:[
 10489         ^ HKEY_LOCAL_MACHINE.
 10491 	^ HKEY_LOCAL_MACHINE.
 10490     ].
 10492     ].
 10491     specialKeyStringOrSymbol = #'HKEY_USERS' ifTrue:[
 10493     specialKeyStringOrSymbol = #'HKEY_USERS' ifTrue:[
 10492         ^ HKEY_USERS.
 10494 	^ HKEY_USERS.
 10493     ].
 10495     ].
 10494     specialKeyStringOrSymbol = #'HKEY_PERFORMANCE_DATA' ifTrue:[
 10496     specialKeyStringOrSymbol = #'HKEY_PERFORMANCE_DATA' ifTrue:[
 10495         ^ HKEY_PERFORMANCE_DATA.
 10497 	^ HKEY_PERFORMANCE_DATA.
 10496     ].
 10498     ].
 10497     specialKeyStringOrSymbol = #'HKEY_CURRENT_CONFIG' ifTrue:[
 10499     specialKeyStringOrSymbol = #'HKEY_CURRENT_CONFIG' ifTrue:[
 10498         ^ HKEY_CURRENT_CONFIG.
 10500 	^ HKEY_CURRENT_CONFIG.
 10499     ].
 10501     ].
 10500     specialKeyStringOrSymbol = #'HKEY_DYN_DATA' ifTrue:[
 10502     specialKeyStringOrSymbol = #'HKEY_DYN_DATA' ifTrue:[
 10501         ^ HKEY_DYN_DATA.
 10503 	^ HKEY_DYN_DATA.
 10502     ].
 10504     ].
 10503 
 10505 
 10504     ^ nil
 10506     ^ nil
 10505 
 10507 
 10506     "Created: / 19.5.1999 / 21:40:30 / cg"
 10508     "Created: / 19.5.1999 / 21:40:30 / cg"
 10509 
 10511 
 10510 update:something with:aParameter from:changedObject
 10512 update:something with:aParameter from:changedObject
 10511     "handle image restarts and refetch registry handles"
 10513     "handle image restarts and refetch registry handles"
 10512 
 10514 
 10513     (something == #returnFromSnapshot) ifTrue:[
 10515     (something == #returnFromSnapshot) ifTrue:[
 10514         self initialize
 10516 	self initialize
 10515     ]
 10517     ]
 10516 
 10518 
 10517     "Created: 15.6.1996 / 15:14:03 / cg"
 10519     "Created: 15.6.1996 / 15:14:03 / cg"
 10518     "Modified: 24.2.1997 / 22:08:05 / cg"
 10520     "Modified: 24.2.1997 / 22:08:05 / cg"
 10519 ! !
 10521 ! !
 10522 
 10524 
 10523 immediateHandle:aHandleValue
 10525 immediateHandle:aHandleValue
 10524     |h newEntry|
 10526     |h newEntry|
 10525 
 10527 
 10526     aHandleValue isInteger ifTrue:[
 10528     aHandleValue isInteger ifTrue:[
 10527         h := ExternalAddress newAddress:aHandleValue
 10529 	h := ExternalAddress newAddress:aHandleValue
 10528     ] ifFalse:[
 10530     ] ifFalse:[
 10529         h := aHandleValue
 10531 	h := aHandleValue
 10530     ].
 10532     ].
 10531 
 10533 
 10532     "/ rootKeys are not registered for RegClose ...
 10534     "/ rootKeys are not registered for RegClose ...
 10533     newEntry := self basicNew setHandle:h path:nil.
 10535     newEntry := self basicNew setHandle:h path:nil.
 10534     newEntry registerForFinalization.
 10536     newEntry registerForFinalization.
 10546 
 10548 
 10547     HKEY_CLASSES_ROOT isNil ifTrue:[self initialize].
 10549     HKEY_CLASSES_ROOT isNil ifTrue:[self initialize].
 10548 
 10550 
 10549     idx := aKeyNamePath indexOf:(self separator).
 10551     idx := aKeyNamePath indexOf:(self separator).
 10550     idx == 0 ifTrue:[
 10552     idx == 0 ifTrue:[
 10551         first := aKeyNamePath.
 10553 	first := aKeyNamePath.
 10552         rest := nil.
 10554 	rest := nil.
 10553     ] ifFalse:[
 10555     ] ifFalse:[
 10554         first := aKeyNamePath copyTo:idx-1.
 10556 	first := aKeyNamePath copyTo:idx-1.
 10555         rest := aKeyNamePath copyFrom:idx+1
 10557 	rest := aKeyNamePath copyFrom:idx+1
 10556     ].
 10558     ].
 10557 
 10559 
 10558     first := first asUppercase.
 10560     first := first asUppercase.
 10559 
 10561 
 10560     "/ the first is a pseudo name
 10562     "/ the first is a pseudo name
 10561     root := self rootKey:first.
 10563     root := self rootKey:first.
 10562     root isNil ifTrue:[
 10564     root isNil ifTrue:[
 10563         ^ nil
 10565 	^ nil
 10564     ].
 10566     ].
 10565 
 10567 
 10566     rest size == 0 ifTrue:[
 10568     rest size == 0 ifTrue:[
 10567         ^ root
 10569 	^ root
 10568     ].
 10570     ].
 10569 
 10571 
 10570     ^ root subKeyNamed:rest.
 10572     ^ root subKeyNamed:rest.
 10571 
 10573 
 10572     "
 10574     "
 10701 
 10703 
 10702     |k suffix|
 10704     |k suffix|
 10703 
 10705 
 10704     k := self key:'HKEY_CLASSES_ROOT\MIME\Database\Content Type\',mimeType.
 10706     k := self key:'HKEY_CLASSES_ROOT\MIME\Database\Content Type\',mimeType.
 10705     k notNil ifTrue:[
 10707     k notNil ifTrue:[
 10706         suffix := k valueNamed:'extension'.
 10708 	suffix := k valueNamed:'extension'.
 10707     ].
 10709     ].
 10708     ^ suffix
 10710     ^ suffix
 10709 !
 10711 !
 10710 
 10712 
 10711 shellCommandTemplateFor:operation onSuffix:suffixArg
 10713 shellCommandTemplateFor:operation onSuffix:suffixArg
 10715 
 10717 
 10716     suffix := suffixArg.
 10718     suffix := suffixArg.
 10717     suffix isNil ifTrue:[^ nil].
 10719     suffix isNil ifTrue:[^ nil].
 10718 
 10720 
 10719     (suffix startsWith:'.') ifTrue:[
 10721     (suffix startsWith:'.') ifTrue:[
 10720         suffix := suffix copyFrom:2
 10722 	suffix := suffix copyFrom:2
 10721     ].
 10723     ].
 10722     k := self key:'HKEY_CLASSES_ROOT\.',suffix.
 10724     k := self key:'HKEY_CLASSES_ROOT\.',suffix.
 10723 
 10725 
 10724     k notNil ifTrue:[
 10726     k notNil ifTrue:[
 10725         fkey := (k valueNamed:'').
 10727 	fkey := (k valueNamed:'').
 10726     ].
 10728     ].
 10727     fkey isNil ifTrue:[
 10729     fkey isNil ifTrue:[
 10728         fkey := suffix,'_auto_file'
 10730 	fkey := suffix,'_auto_file'
 10729     ].
 10731     ].
 10730 
 10732 
 10731     fkey notEmptyOrNil ifTrue:[
 10733     fkey notEmptyOrNil ifTrue:[
 10732 
 10734 
 10733         redirect := nil.
 10735 	redirect := nil.
 10734 
 10736 
 10735         k := Win32OperatingSystem::RegistryEntry key:('HKEY_CLASSES_ROOT\' , fkey , '\CurVer').
 10737 	k := Win32OperatingSystem::RegistryEntry key:('HKEY_CLASSES_ROOT\' , fkey , '\CurVer').
 10736         k notNil ifTrue:[
 10738 	k notNil ifTrue:[
 10737             redirect := k defaultValue
 10739 	    redirect := k defaultValue
 10738         ].
 10740 	].
 10739 
 10741 
 10740         redirect isNil ifTrue:[
 10742 	redirect isNil ifTrue:[
 10741              k := Win32OperatingSystem::RegistryEntry key:('HKEY_CLASSES_ROOT\' , (fkey) , '\shell\',operation,'\command').
 10743 	     k := Win32OperatingSystem::RegistryEntry key:('HKEY_CLASSES_ROOT\' , (fkey) , '\shell\',operation,'\command').
 10742         ] ifFalse:[
 10744 	] ifFalse:[
 10743              k := Win32OperatingSystem::RegistryEntry key:('HKEY_CLASSES_ROOT\' , (redirect) , '\shell\',operation,'\command').
 10745 	     k := Win32OperatingSystem::RegistryEntry key:('HKEY_CLASSES_ROOT\' , (redirect) , '\shell\',operation,'\command').
 10744         ].
 10746 	].
 10745 
 10747 
 10746         k notNil ifTrue:[
 10748 	k notNil ifTrue:[
 10747             cmd := k defaultValue
 10749 	    cmd := k defaultValue
 10748         ].
 10750 	].
 10749     ].
 10751     ].
 10750 
 10752 
 10751 
 10753 
 10752     ^ cmd
 10754     ^ cmd
 10753 ! !
 10755 ! !
 10768     v isString ifFalse:[^ nil].
 10770     v isString ifFalse:[^ nil].
 10769     ^ v
 10771     ^ v
 10770 
 10772 
 10771     "
 10773     "
 10772      self
 10774      self
 10773         stringValueFor:'Content Type'
 10775 	stringValueFor:'Content Type'
 10774         atKey:'HKEY_CLASSES_ROOT\.au'
 10776 	atKey:'HKEY_CLASSES_ROOT\.au'
 10775     "
 10777     "
 10776 ! !
 10778 ! !
 10777 
 10779 
 10778 !Win32OperatingSystem::RegistryEntry methodsFor:'accessing'!
 10780 !Win32OperatingSystem::RegistryEntry methodsFor:'accessing'!
 10779 
 10781 
 10810 %{
 10812 %{
 10811     HKEY myKey, subKey = 0;
 10813     HKEY myKey, subKey = 0;
 10812 
 10814 
 10813     if (__isExternalAddressLike(__INST(handle))
 10815     if (__isExternalAddressLike(__INST(handle))
 10814      && (__isString(subKeyString) || __isSymbol(subKeyString))) {
 10816      && (__isString(subKeyString) || __isSymbol(subKeyString))) {
 10815         myKey = (HKEY)__externalAddressVal(__INST(handle));
 10817 	myKey = (HKEY)__externalAddressVal(__INST(handle));
 10816         if (RegCreateKey(myKey, __stringVal(subKeyString), &subKey) == ERROR_SUCCESS) {
 10818 	if (RegCreateKey(myKey, __stringVal(subKeyString), &subKey) == ERROR_SUCCESS) {
 10817             subHandle = __MKEXTERNALADDRESS(subKey);
 10819 	    subHandle = __MKEXTERNALADDRESS(subKey);
 10818         }
 10820 	}
 10819     }
 10821     }
 10820 %}.
 10822 %}.
 10821     subHandle notNil ifTrue:[
 10823     subHandle notNil ifTrue:[
 10822         newEntry := self class basicNew
 10824 	newEntry := self class basicNew
 10823                         setHandle:subHandle
 10825 			setHandle:subHandle
 10824                         path:(path , self class separator asString , subKeyString).
 10826 			path:(path , self class separator asString , subKeyString).
 10825         newEntry registerForFinalization.
 10827 	newEntry registerForFinalization.
 10826         ^ newEntry.
 10828 	^ newEntry.
 10827     ].
 10829     ].
 10828     ^ nil
 10830     ^ nil
 10829 
 10831 
 10830     "
 10832     "
 10831      |top sub|
 10833      |top sub|
 10842 %{
 10844 %{
 10843     HKEY myKey;
 10845     HKEY myKey;
 10844 
 10846 
 10845     if (__isExternalAddressLike(__INST(handle))
 10847     if (__isExternalAddressLike(__INST(handle))
 10846      && (__isString(subKeyString) || __isSymbol(subKeyString))) {
 10848      && (__isString(subKeyString) || __isSymbol(subKeyString))) {
 10847         myKey = (HKEY)__externalAddressVal(__INST(handle));
 10849 	myKey = (HKEY)__externalAddressVal(__INST(handle));
 10848         if (RegDeleteKey(myKey, __stringVal(subKeyString)) == ERROR_SUCCESS) {
 10850 	if (RegDeleteKey(myKey, __stringVal(subKeyString)) == ERROR_SUCCESS) {
 10849             RETURN (true);
 10851 	    RETURN (true);
 10850         }
 10852 	}
 10851     }
 10853     }
 10852 %}.
 10854 %}.
 10853     ^ false
 10855     ^ false
 10854 
 10856 
 10855     "
 10857     "
 10869 
 10871 
 10870 %{
 10872 %{
 10871     HKEY myKey, remoteKey = 0;
 10873     HKEY myKey, remoteKey = 0;
 10872 
 10874 
 10873     if (__isExternalAddressLike(__INST(handle)) && __isString(hostName)) {
 10875     if (__isExternalAddressLike(__INST(handle)) && __isString(hostName)) {
 10874         myKey = (HKEY)__externalAddressVal(__INST(handle));
 10876 	myKey = (HKEY)__externalAddressVal(__INST(handle));
 10875         if (RegConnectRegistry(__stringVal(hostName), myKey, &remoteKey) == ERROR_SUCCESS) {
 10877 	if (RegConnectRegistry(__stringVal(hostName), myKey, &remoteKey) == ERROR_SUCCESS) {
 10876             remoteHandle = __MKEXTERNALADDRESS(remoteKey);
 10878 	    remoteHandle = __MKEXTERNALADDRESS(remoteKey);
 10877         }
 10879 	}
 10878     }
 10880     }
 10879 %}.
 10881 %}.
 10880     remoteHandle notNil ifTrue:[
 10882     remoteHandle notNil ifTrue:[
 10881         newEntry := self class basicNew setHandle:remoteHandle path:path.
 10883 	newEntry := self class basicNew setHandle:remoteHandle path:path.
 10882         newEntry registerForFinalization.
 10884 	newEntry registerForFinalization.
 10883         ^ newEntry.
 10885 	^ newEntry.
 10884     ].
 10886     ].
 10885     ^ nil
 10887     ^ nil
 10886 
 10888 
 10887     "
 10889     "
 10888      |top remote|
 10890      |top remote|
 10924     DWORD classNameSize = sizeof(classNameBuffer) - 1;
 10926     DWORD classNameSize = sizeof(classNameBuffer) - 1;
 10925     FILETIME modificationTime;
 10927     FILETIME modificationTime;
 10926 
 10928 
 10927     if (__isExternalAddressLike(__INST(handle))
 10929     if (__isExternalAddressLike(__INST(handle))
 10928      && __isSmallInteger(subKeyIndex)) {
 10930      && __isSmallInteger(subKeyIndex)) {
 10929         myKey = (HKEY)__externalAddressVal(__INST(handle));
 10931 	myKey = (HKEY)__externalAddressVal(__INST(handle));
 10930         if (RegEnumKeyEx(myKey, __intVal(subKeyIndex),
 10932 	if (RegEnumKeyEx(myKey, __intVal(subKeyIndex),
 10931                          nameBuffer, &nameSize,
 10933 			 nameBuffer, &nameSize,
 10932                          NULL,
 10934 			 NULL,
 10933                          classNameBuffer, &classNameSize,
 10935 			 classNameBuffer, &classNameSize,
 10934                          &modificationTime) == ERROR_SUCCESS) {
 10936 			 &modificationTime) == ERROR_SUCCESS) {
 10935             nameBuffer[nameSize] = '\0';
 10937 	    nameBuffer[nameSize] = '\0';
 10936             classNameBuffer[classNameSize] = '\0';
 10938 	    classNameBuffer[classNameSize] = '\0';
 10937             subKeyName = __MKSTRING(nameBuffer);
 10939 	    subKeyName = __MKSTRING(nameBuffer);
 10938             subKeyClassName = __MKSTRING(classNameBuffer);
 10940 	    subKeyClassName = __MKSTRING(classNameBuffer);
 10939         } else {
 10941 	} else {
 10940         }
 10942 	}
 10941     }
 10943     }
 10942 %}.
 10944 %}.
 10943     subKeyName isNil ifTrue:[^ nil].
 10945     subKeyName isNil ifTrue:[^ nil].
 10944     ^ self subKeyNamed:subKeyName.
 10946     ^ self subKeyNamed:subKeyName.
 10945 
 10947 
 10960 %{
 10962 %{
 10961     HKEY myKey, subKey = 0;
 10963     HKEY myKey, subKey = 0;
 10962 
 10964 
 10963     if (__isExternalAddressLike(__INST(handle))
 10965     if (__isExternalAddressLike(__INST(handle))
 10964      && (__isString(subKeyString) || __isSymbol(subKeyString))) {
 10966      && (__isString(subKeyString) || __isSymbol(subKeyString))) {
 10965         myKey = (HKEY)__externalAddressVal(__INST(handle));
 10967 	myKey = (HKEY)__externalAddressVal(__INST(handle));
 10966         if (RegOpenKey(myKey, __stringVal(subKeyString), &subKey) == ERROR_SUCCESS) {
 10968 	if (RegOpenKey(myKey, __stringVal(subKeyString), &subKey) == ERROR_SUCCESS) {
 10967             subHandle = __MKEXTERNALADDRESS(subKey);
 10969 	    subHandle = __MKEXTERNALADDRESS(subKey);
 10968         }
 10970 	}
 10969     }
 10971     }
 10970 %}.
 10972 %}.
 10971     subHandle notNil ifTrue:[
 10973     subHandle notNil ifTrue:[
 10972         newEntry := self class basicNew
 10974 	newEntry := self class basicNew
 10973                         setHandle:subHandle
 10975 			setHandle:subHandle
 10974                         path:((path ? '?') , self class separator asString , subKeyString).
 10976 			path:((path ? '?') , self class separator asString , subKeyString).
 10975 
 10977 
 10976         newEntry registerForFinalization.
 10978 	newEntry registerForFinalization.
 10977         ^ newEntry.
 10979 	^ newEntry.
 10978     ].
 10980     ].
 10979     ^ nil
 10981     ^ nil
 10980 
 10982 
 10981     "
 10983     "
 10982      |top sub|
 10984      |top sub|
 11003 %{
 11005 %{
 11004     HKEY myKey;
 11006     HKEY myKey;
 11005 
 11007 
 11006     if (__isExternalAddressLike(__INST(handle))
 11008     if (__isExternalAddressLike(__INST(handle))
 11007      && (__isString(aValueName) || __isSymbol(aValueName))) {
 11009      && (__isString(aValueName) || __isSymbol(aValueName))) {
 11008         myKey = (HKEY)__externalAddressVal(__INST(handle));
 11010 	myKey = (HKEY)__externalAddressVal(__INST(handle));
 11009         if (RegDeleteValue(myKey, __stringVal(aValueName)) == ERROR_SUCCESS) {
 11011 	if (RegDeleteValue(myKey, __stringVal(aValueName)) == ERROR_SUCCESS) {
 11010             RETURN (true);
 11012 	    RETURN (true);
 11011         }
 11013 	}
 11012     }
 11014     }
 11013 %}.
 11015 %}.
 11014     ^ false
 11016     ^ false
 11015 !
 11017 !
 11016 
 11018 
 11026     DWORD nameSize = sizeof(nameBuffer) - 1;
 11028     DWORD nameSize = sizeof(nameBuffer) - 1;
 11027     DWORD valueType;
 11029     DWORD valueType;
 11028 
 11030 
 11029     if (__isExternalAddressLike(__INST(handle))
 11031     if (__isExternalAddressLike(__INST(handle))
 11030      && __isSmallInteger(valueIndex)) {
 11032      && __isSmallInteger(valueIndex)) {
 11031         myKey = (HKEY)__externalAddressVal(__INST(handle));
 11033 	myKey = (HKEY)__externalAddressVal(__INST(handle));
 11032         if (RegEnumValue(myKey, __intVal(valueIndex),
 11034 	if (RegEnumValue(myKey, __intVal(valueIndex),
 11033                          nameBuffer, &nameSize,
 11035 			 nameBuffer, &nameSize,
 11034                          NULL,
 11036 			 NULL,
 11035                          &valueType,
 11037 			 &valueType,
 11036                          NULL, NULL) == ERROR_SUCCESS) {
 11038 			 NULL, NULL) == ERROR_SUCCESS) {
 11037             nameBuffer[nameSize] = '\0';
 11039 	    nameBuffer[nameSize] = '\0';
 11038             valueName = __MKSTRING(nameBuffer);
 11040 	    valueName = __MKSTRING(nameBuffer);
 11039         }
 11041 	}
 11040     }
 11042     }
 11041 %}.
 11043 %}.
 11042     ^ valueName
 11044     ^ valueName
 11043 
 11045 
 11044     "
 11046     "
 11049     "
 11051     "
 11050 !
 11052 !
 11051 
 11053 
 11052 valueNamed:aValueName
 11054 valueNamed:aValueName
 11053     "retrieve a value; the returned object depends upon the type:
 11055     "retrieve a value; the returned object depends upon the type:
 11054         REG_BINARY      -> ByteArray
 11056 	REG_BINARY      -> ByteArray
 11055         REG_SZ          -> String
 11057 	REG_SZ          -> String
 11056         REG_MULTI_SZ    -> Array of strings
 11058 	REG_MULTI_SZ    -> Array of strings
 11057         REG_DWORD       -> Integer
 11059 	REG_DWORD       -> Integer
 11058         REG_NONE        -> nil
 11060 	REG_NONE        -> nil
 11059     "
 11061     "
 11060 
 11062 
 11061     |data stringArray|
 11063     |data stringArray|
 11062 %{
 11064 %{
 11063     HKEY myKey;
 11065     HKEY myKey;
 11064     DWORD valueType;
 11066     DWORD valueType;
 11065     union {
 11067     union {
 11066         DWORD dWord;
 11068 	DWORD dWord;
 11067         unsigned char dWordBytes[4];
 11069 	unsigned char dWordBytes[4];
 11068         unsigned char smallDataBuffer[256];
 11070 	unsigned char smallDataBuffer[256];
 11069     } quickData;
 11071     } quickData;
 11070     int val;
 11072     int val;
 11071     DWORD dataSize = sizeof(quickData);
 11073     DWORD dataSize = sizeof(quickData);
 11072     unsigned char *dataBuffer = NULL;
 11074     unsigned char *dataBuffer = NULL;
 11073 
 11075 
 11074     if (__isExternalAddressLike(__INST(handle))
 11076     if (__isExternalAddressLike(__INST(handle))
 11075      && (__isString(aValueName) || __isSymbol(aValueName))) {
 11077      && (__isString(aValueName) || __isSymbol(aValueName))) {
 11076         int ret;
 11078 	int ret;
 11077 
 11079 
 11078         myKey = (HKEY)__externalAddressVal(__INST(handle));
 11080 	myKey = (HKEY)__externalAddressVal(__INST(handle));
 11079 
 11081 
 11080         /*
 11082 	/*
 11081          * try to get it with one call ...
 11083 	 * try to get it with one call ...
 11082          */
 11084 	 */
 11083         ret = RegQueryValueEx(myKey, __stringVal(aValueName),
 11085 	ret = RegQueryValueEx(myKey, __stringVal(aValueName),
 11084                          NULL,
 11086 			 NULL,
 11085                          &valueType,
 11087 			 &valueType,
 11086                          (char *)&quickData,
 11088 			 (char *)&quickData,
 11087                          &dataSize);
 11089 			 &dataSize);
 11088 
 11090 
 11089         if (ret == ERROR_MORE_DATA) {
 11091 	if (ret == ERROR_MORE_DATA) {
 11090             /*
 11092 	    /*
 11091              * nope - need another one ...
 11093 	     * nope - need another one ...
 11092              */
 11094 	     */
 11093             switch (valueType) {
 11095 	    switch (valueType) {
 11094                 case REG_BINARY:
 11096 		case REG_BINARY:
 11095                 case REG_MULTI_SZ:
 11097 		case REG_MULTI_SZ:
 11096                     data = __BYTEARRAY_UNINITIALIZED_NEW_INT(dataSize);
 11098 		    data = __BYTEARRAY_UNINITIALIZED_NEW_INT(dataSize);
 11097                     dataBuffer = __ByteArrayInstPtr(data)->ba_element;
 11099 		    dataBuffer = __ByteArrayInstPtr(data)->ba_element;
 11098                     break;
 11100 		    break;
 11099                 case REG_SZ:
 11101 		case REG_SZ:
 11100                     data = __MKEMPTYSTRING(dataSize-1);
 11102 		    data = __MKEMPTYSTRING(dataSize-1);
 11101                     dataBuffer = __stringVal(data);
 11103 		    dataBuffer = __stringVal(data);
 11102                     break;
 11104 		    break;
 11103             }
 11105 	    }
 11104             if (dataBuffer) {
 11106 	    if (dataBuffer) {
 11105                 ret = RegQueryValueEx(myKey, __stringVal(aValueName),
 11107 		ret = RegQueryValueEx(myKey, __stringVal(aValueName),
 11106                                  NULL,
 11108 				 NULL,
 11107                                  &valueType,
 11109 				 &valueType,
 11108                                  dataBuffer, &dataSize);
 11110 				 dataBuffer, &dataSize);
 11109             }
 11111 	    }
 11110         }
 11112 	}
 11111 
 11113 
 11112         if (ret == ERROR_SUCCESS) {
 11114 	if (ret == ERROR_SUCCESS) {
 11113             switch (valueType) {
 11115 	    switch (valueType) {
 11114                 case REG_NONE:
 11116 		case REG_NONE:
 11115                     /* RETURN (@symbol(none));  */
 11117 		    /* RETURN (@symbol(none));  */
 11116                     RETURN (nil);
 11118 		    RETURN (nil);
 11117 
 11119 
 11118                 case REG_BINARY:
 11120 		case REG_BINARY:
 11119                     /*
 11121 		    /*
 11120                      * did we get it with the first call ?
 11122 		     * did we get it with the first call ?
 11121                      */
 11123 		     */
 11122                     if (! dataBuffer) {
 11124 		    if (! dataBuffer) {
 11123                         data = __MKBYTEARRAY(quickData.smallDataBuffer, dataSize);
 11125 			data = __MKBYTEARRAY(quickData.smallDataBuffer, dataSize);
 11124                     }
 11126 		    }
 11125                     RETURN (data);
 11127 		    RETURN (data);
 11126 
 11128 
 11127                 case REG_SZ:
 11129 		case REG_SZ:
 11128                 case REG_EXPAND_SZ:
 11130 		case REG_EXPAND_SZ:
 11129                     /*
 11131 		    /*
 11130                      * did we get it with the first call ?
 11132 		     * did we get it with the first call ?
 11131                      */
 11133 		     */
 11132                     if (! dataBuffer) {
 11134 		    if (! dataBuffer) {
 11133                         data = __MKSTRING_L(quickData.smallDataBuffer, dataSize-1);
 11135 			data = __MKSTRING_L(quickData.smallDataBuffer, dataSize-1);
 11134                     }
 11136 		    }
 11135                     RETURN (data);
 11137 		    RETURN (data);
 11136 
 11138 
 11137 #if 0
 11139 #if 0
 11138                 case REG_DWORD:
 11140 		case REG_DWORD:
 11139                     /* int in native format */
 11141 		    /* int in native format */
 11140                     RETURN (__MKUINT(quickData.dWord));
 11142 		    RETURN (__MKUINT(quickData.dWord));
 11141 #endif
 11143 #endif
 11142                 case REG_DWORD_LITTLE_ENDIAN:
 11144 		case REG_DWORD_LITTLE_ENDIAN:
 11143                     val = quickData.dWordBytes[3];
 11145 		    val = quickData.dWordBytes[3];
 11144                     val = (val << 8) | quickData.dWordBytes[2];
 11146 		    val = (val << 8) | quickData.dWordBytes[2];
 11145                     val = (val << 8) | quickData.dWordBytes[1];
 11147 		    val = (val << 8) | quickData.dWordBytes[1];
 11146                     val = (val << 8) | quickData.dWordBytes[0];
 11148 		    val = (val << 8) | quickData.dWordBytes[0];
 11147                     RETURN (__MKUINT(val));
 11149 		    RETURN (__MKUINT(val));
 11148 
 11150 
 11149                 case REG_DWORD_BIG_ENDIAN:
 11151 		case REG_DWORD_BIG_ENDIAN:
 11150                     val = quickData.dWordBytes[0];
 11152 		    val = quickData.dWordBytes[0];
 11151                     val = (val << 8) | quickData.dWordBytes[1];
 11153 		    val = (val << 8) | quickData.dWordBytes[1];
 11152                     val = (val << 8) | quickData.dWordBytes[2];
 11154 		    val = (val << 8) | quickData.dWordBytes[2];
 11153                     val = (val << 8) | quickData.dWordBytes[3];
 11155 		    val = (val << 8) | quickData.dWordBytes[3];
 11154                     RETURN (__MKUINT(val));
 11156 		    RETURN (__MKUINT(val));
 11155 
 11157 
 11156                 case REG_MULTI_SZ:
 11158 		case REG_MULTI_SZ:
 11157                     {
 11159 		    {
 11158                         char *cp, *cp0;
 11160 			char *cp, *cp0;
 11159                         int ns = 0, i;
 11161 			int ns = 0, i;
 11160 
 11162 
 11161                         cp0 = dataBuffer ? dataBuffer : quickData.smallDataBuffer;
 11163 			cp0 = dataBuffer ? dataBuffer : quickData.smallDataBuffer;
 11162                         cp = cp0;
 11164 			cp = cp0;
 11163                         while (*cp) {
 11165 			while (*cp) {
 11164                             while (*cp++) ;;
 11166 			    while (*cp++) ;;
 11165                             ns++;
 11167 			    ns++;
 11166                             cp++;
 11168 			    cp++;
 11167                         }
 11169 			}
 11168                         stringArray = __ARRAY_NEW_INT(ns);
 11170 			stringArray = __ARRAY_NEW_INT(ns);
 11169 
 11171 
 11170                         i = 0;
 11172 			i = 0;
 11171                         while (*cp0) {
 11173 			while (*cp0) {
 11172                             OBJ s;
 11174 			    OBJ s;
 11173 
 11175 
 11174                             cp = cp0;
 11176 			    cp = cp0;
 11175                             while (*cp++) ;;
 11177 			    while (*cp++) ;;
 11176                             s = __MKSTRING(cp0); __ArrayInstPtr(stringArray)->a_element[i] = s; __STORE(stringArray, s);
 11178 			    s = __MKSTRING(cp0); __ArrayInstPtr(stringArray)->a_element[i] = s; __STORE(stringArray, s);
 11177                             cp++;
 11179 			    cp++;
 11178                             cp0 = cp;
 11180 			    cp0 = cp;
 11179                             i++;
 11181 			    i++;
 11180                         }
 11182 			}
 11181                         RETURN (stringArray);
 11183 			RETURN (stringArray);
 11182                     }
 11184 		    }
 11183             }
 11185 	    }
 11184         }
 11186 	}
 11185     }
 11187     }
 11186 %}.
 11188 %}.
 11187     ^ nil
 11189     ^ nil
 11188 
 11190 
 11189     "
 11191     "
 11194     "
 11196     "
 11195 !
 11197 !
 11196 
 11198 
 11197 valueNamed:aValueName put:datum
 11199 valueNamed:aValueName put:datum
 11198     "store a value; the value type depends upon the stored value:
 11200     "store a value; the value type depends upon the stored value:
 11199         ByteArray       -> REG_BINARY
 11201 	ByteArray       -> REG_BINARY
 11200         String          -> REG_SZ
 11202 	String          -> REG_SZ
 11201         Array of string -> REG_MULTI_SZ
 11203 	Array of string -> REG_MULTI_SZ
 11202         Integer         -> REG_DWORD
 11204 	Integer         -> REG_DWORD
 11203         nil             -> REG_NONE
 11205 	nil             -> REG_NONE
 11204     "
 11206     "
 11205 
 11207 
 11206     |data stringArray|
 11208     |data stringArray|
 11207 %{
 11209 %{
 11208     HKEY myKey;
 11210     HKEY myKey;
 11212     unsigned char *dataPointer = NULL;
 11214     unsigned char *dataPointer = NULL;
 11213     int datumOk = 1, mustFreeData = 0;
 11215     int datumOk = 1, mustFreeData = 0;
 11214 
 11216 
 11215     if (__isExternalAddressLike(__INST(handle))
 11217     if (__isExternalAddressLike(__INST(handle))
 11216      && (__isString(aValueName) || __isSymbol(aValueName))) {
 11218      && (__isString(aValueName) || __isSymbol(aValueName))) {
 11217         int ret;
 11219 	int ret;
 11218         OBJ cls;
 11220 	OBJ cls;
 11219 
 11221 
 11220         myKey = (HKEY)__externalAddressVal(__INST(handle));
 11222 	myKey = (HKEY)__externalAddressVal(__INST(handle));
 11221 
 11223 
 11222         if (datum == nil) {
 11224 	if (datum == nil) {
 11223             valueType = REG_NONE;
 11225 	    valueType = REG_NONE;
 11224             dataSize = 0;
 11226 	    dataSize = 0;
 11225         } else if (__isSmallInteger(datum)) {
 11227 	} else if (__isSmallInteger(datum)) {
 11226             valueType = REG_DWORD;
 11228 	    valueType = REG_DWORD;
 11227             val = __intVal(datum);
 11229 	    val = __intVal(datum);
 11228             dataPointer = (unsigned char *)(&val);
 11230 	    dataPointer = (unsigned char *)(&val);
 11229             dataSize = sizeof(val);
 11231 	    dataSize = sizeof(val);
 11230         } else if (__isString(datum) || __isSymbol(datum)) {
 11232 	} else if (__isString(datum) || __isSymbol(datum)) {
 11231             valueType = REG_SZ;
 11233 	    valueType = REG_SZ;
 11232             dataPointer = __stringVal(datum);
 11234 	    dataPointer = __stringVal(datum);
 11233             dataSize = __stringSize(datum) + 1;
 11235 	    dataSize = __stringSize(datum) + 1;
 11234         } else if (__Class(datum) == ByteArray) {
 11236 	} else if (__Class(datum) == ByteArray) {
 11235             valueType = REG_BINARY;
 11237 	    valueType = REG_BINARY;
 11236             dataPointer = __ByteArrayInstPtr(datum)->ba_element;
 11238 	    dataPointer = __ByteArrayInstPtr(datum)->ba_element;
 11237             dataSize = __byteArraySize(datum);
 11239 	    dataSize = __byteArraySize(datum);
 11238         } else if (__Class(datum) == LargeInteger) {
 11240 	} else if (__Class(datum) == LargeInteger) {
 11239             valueType = REG_DWORD;
 11241 	    valueType = REG_DWORD;
 11240             val = __longIntVal(datum);
 11242 	    val = __longIntVal(datum);
 11241             if (val) {
 11243 	    if (val) {
 11242                 dataPointer = (unsigned char *)(&val);
 11244 		dataPointer = (unsigned char *)(&val);
 11243                 dataSize = sizeof(val);
 11245 		dataSize = sizeof(val);
 11244             } else {
 11246 	    } else {
 11245                 datumOk = 0;
 11247 		datumOk = 0;
 11246             }
 11248 	    }
 11247         } else if (__Class(datum) == Array) {
 11249 	} else if (__Class(datum) == Array) {
 11248             int i = 0, ns = 0, totalSize = 0;
 11250 	    int i = 0, ns = 0, totalSize = 0;
 11249 
 11251 
 11250             valueType = REG_MULTI_SZ;
 11252 	    valueType = REG_MULTI_SZ;
 11251 
 11253 
 11252             /*
 11254 	    /*
 11253              * must allocate a local buffer
 11255 	     * must allocate a local buffer
 11254              * find size ...
 11256 	     * find size ...
 11255              */
 11257 	     */
 11256             for (i=0; i<__arraySize(datum); i++) {
 11258 	    for (i=0; i<__arraySize(datum); i++) {
 11257                 OBJ s = __ArrayInstPtr(datum)->a_element[i];
 11259 		OBJ s = __ArrayInstPtr(datum)->a_element[i];
 11258 
 11260 
 11259                 if (__isString(datum) || __isSymbol(datum)) {
 11261 		if (__isString(datum) || __isSymbol(datum)) {
 11260                     totalSize += __stringSize(datum) + 1;
 11262 		    totalSize += __stringSize(datum) + 1;
 11261                 } else {
 11263 		} else {
 11262                     datumOk = 0;
 11264 		    datumOk = 0;
 11263                     break;
 11265 		    break;
 11264                 }
 11266 		}
 11265                 ns++;
 11267 		ns++;
 11266             }
 11268 	    }
 11267             if (datumOk) {
 11269 	    if (datumOk) {
 11268                 char *cp;
 11270 		char *cp;
 11269 
 11271 
 11270                 /*
 11272 		/*
 11271                  * allocate and fill...
 11273 		 * allocate and fill...
 11272                  */
 11274 		 */
 11273                 totalSize ++;
 11275 		totalSize ++;
 11274                 dataPointer = (char *)(malloc(totalSize));
 11276 		dataPointer = (char *)(malloc(totalSize));
 11275                 mustFreeData = 1;
 11277 		mustFreeData = 1;
 11276                 cp = dataPointer;
 11278 		cp = dataPointer;
 11277                 for (i=0; i<__arraySize(datum); i++) {
 11279 		for (i=0; i<__arraySize(datum); i++) {
 11278                     OBJ s = __ArrayInstPtr(datum)->a_element[i];
 11280 		    OBJ s = __ArrayInstPtr(datum)->a_element[i];
 11279 
 11281 
 11280                     strcpy(cp, __stringVal(s));
 11282 		    strcpy(cp, __stringVal(s));
 11281                     cp += __stringSize(datum);
 11283 		    cp += __stringSize(datum);
 11282                     *cp++ = '\0';
 11284 		    *cp++ = '\0';
 11283                 }
 11285 		}
 11284                 *cp++ = '\0';
 11286 		*cp++ = '\0';
 11285                 dataSize = totalSize;
 11287 		dataSize = totalSize;
 11286             }
 11288 	    }
 11287         } else {
 11289 	} else {
 11288             datumOk = 0;
 11290 	    datumOk = 0;
 11289         }
 11291 	}
 11290 
 11292 
 11291         if (datumOk) {
 11293 	if (datumOk) {
 11292             ret = RegSetValueEx(myKey, __stringVal(aValueName),
 11294 	    ret = RegSetValueEx(myKey, __stringVal(aValueName),
 11293                                 0, valueType,
 11295 				0, valueType,
 11294                                 dataPointer, dataSize);
 11296 				dataPointer, dataSize);
 11295             if (mustFreeData) {
 11297 	    if (mustFreeData) {
 11296                 free(dataPointer);
 11298 		free(dataPointer);
 11297             }
 11299 	    }
 11298             RETURN ((ret == ERROR_SUCCESS) ? true : false);
 11300 	    RETURN ((ret == ERROR_SUCCESS) ? true : false);
 11299         }
 11301 	}
 11300     }
 11302     }
 11301 %}.
 11303 %}.
 11302     ^ false
 11304     ^ false
 11303 
 11305 
 11304     "
 11306     "
 11316 
 11318 
 11317     |idx subEntry|
 11319     |idx subEntry|
 11318 
 11320 
 11319     idx := 0.
 11321     idx := 0.
 11320     [true] whileTrue:[
 11322     [true] whileTrue:[
 11321         subEntry := self subKeyAtIndex:idx.
 11323 	subEntry := self subKeyAtIndex:idx.
 11322         subEntry isNil ifTrue:[
 11324 	subEntry isNil ifTrue:[
 11323             ^self
 11325 	    ^self
 11324         ].
 11326 	].
 11325         aBlock value:subEntry.
 11327 	aBlock value:subEntry.
 11326         subEntry allSubKeysDo:aBlock.
 11328 	subEntry allSubKeysDo:aBlock.
 11327         subEntry close.
 11329 	subEntry close.
 11328         idx := idx + 1.
 11330 	idx := idx + 1.
 11329     ]
 11331     ]
 11330 
 11332 
 11331     "
 11333     "
 11332      |top sub|
 11334      |top sub|
 11333 
 11335 
 11334      top := self key:'HKEY_LOCAL_MACHINE'.
 11336      top := self key:'HKEY_LOCAL_MACHINE'.
 11335      top allSubKeysDo:[:subEntry |
 11337      top allSubKeysDo:[:subEntry |
 11336         Transcript showCR:subEntry path
 11338 	Transcript showCR:subEntry path
 11337      ]
 11339      ]
 11338     "
 11340     "
 11339 !
 11341 !
 11340 
 11342 
 11341 subKeys
 11343 subKeys
 11363 
 11365 
 11364     |idx subEntry|
 11366     |idx subEntry|
 11365 
 11367 
 11366     idx := 0.
 11368     idx := 0.
 11367     [true] whileTrue:[
 11369     [true] whileTrue:[
 11368         subEntry := self subKeyAtIndex:idx.
 11370 	subEntry := self subKeyAtIndex:idx.
 11369         subEntry isNil ifTrue:[
 11371 	subEntry isNil ifTrue:[
 11370             ^self
 11372 	    ^self
 11371         ].
 11373 	].
 11372         aBlock value:subEntry.
 11374 	aBlock value:subEntry.
 11373         subEntry close.
 11375 	subEntry close.
 11374         idx := idx + 1.
 11376 	idx := idx + 1.
 11375     ]
 11377     ]
 11376 
 11378 
 11377     "
 11379     "
 11378      |top sub|
 11380      |top sub|
 11379 
 11381 
 11380      top := self key:'HKEY_LOCAL_MACHINE'.
 11382      top := self key:'HKEY_LOCAL_MACHINE'.
 11381      top subKeysDo:[:subEntry |
 11383      top subKeysDo:[:subEntry |
 11382         Transcript showCR:subEntry path
 11384 	Transcript showCR:subEntry path
 11383      ]
 11385      ]
 11384     "
 11386     "
 11385 !
 11387 !
 11386 
 11388 
 11387 valueNamesAndValuesDo:aBlock
 11389 valueNamesAndValuesDo:aBlock
 11388     "evaluate aBlock for all value names"
 11390     "evaluate aBlock for all value names"
 11389 
 11391 
 11390     self valueNamesDo:[:nm |
 11392     self valueNamesDo:[:nm |
 11391         aBlock value:nm value:(self valueNamed:nm)
 11393 	aBlock value:nm value:(self valueNamed:nm)
 11392     ]
 11394     ]
 11393 
 11395 
 11394     "
 11396     "
 11395      |key|
 11397      |key|
 11396 
 11398 
 11397      key := self key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'.
 11399      key := self key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'.
 11398      key valueNamesAndValuesDo:[:nm :val |
 11400      key valueNamesAndValuesDo:[:nm :val |
 11399         Transcript showCR:(nm , ' -> ' , val storeString).
 11401 	Transcript showCR:(nm , ' -> ' , val storeString).
 11400      ]
 11402      ]
 11401     "
 11403     "
 11402 !
 11404 !
 11403 
 11405 
 11404 valueNamesDo:aBlock
 11406 valueNamesDo:aBlock
 11406 
 11408 
 11407     |idx valueName|
 11409     |idx valueName|
 11408 
 11410 
 11409     idx := 0.
 11411     idx := 0.
 11410     [true] whileTrue:[
 11412     [true] whileTrue:[
 11411         valueName := self valueNameAtIndex:idx.
 11413 	valueName := self valueNameAtIndex:idx.
 11412         valueName isNil ifTrue:[
 11414 	valueName isNil ifTrue:[
 11413             ^self
 11415 	    ^self
 11414         ].
 11416 	].
 11415         aBlock value:valueName.
 11417 	aBlock value:valueName.
 11416         idx := idx + 1.
 11418 	idx := idx + 1.
 11417     ]
 11419     ]
 11418 ! !
 11420 ! !
 11419 
 11421 
 11420 !Win32OperatingSystem::RegistryEntry methodsFor:'instance release'!
 11422 !Win32OperatingSystem::RegistryEntry methodsFor:'instance release'!
 11421 
 11423 
 11431 
 11433 
 11432 %{
 11434 %{
 11433     HKEY myKey;
 11435     HKEY myKey;
 11434 
 11436 
 11435     if (__isExternalAddressLike(__INST(handle))) {
 11437     if (__isExternalAddressLike(__INST(handle))) {
 11436         myKey = (HKEY)(__externalAddressVal(__INST(handle)));
 11438 	myKey = (HKEY)(__externalAddressVal(__INST(handle)));
 11437         __INST(handle) = nil;
 11439 	__INST(handle) = nil;
 11438         RegCloseKey(myKey);
 11440 	RegCloseKey(myKey);
 11439     }
 11441     }
 11440 %}
 11442 %}
 11441 !
 11443 !
 11442 
 11444 
 11443 finalizationLobby
 11445 finalizationLobby
 11446 
 11448 
 11447 finalize
 11449 finalize
 11448     "some entry has been collected - close it"
 11450     "some entry has been collected - close it"
 11449 
 11451 
 11450     handle notNil ifTrue:[
 11452     handle notNil ifTrue:[
 11451         self closeKey.
 11453 	self closeKey.
 11452     ]
 11454     ]
 11453 
 11455 
 11454     "Created: / 19.5.1999 / 22:39:52 / cg"
 11456     "Created: / 19.5.1999 / 22:39:52 / cg"
 11455     "Modified: / 19.5.1999 / 22:44:50 / cg"
 11457     "Modified: / 19.5.1999 / 22:44:50 / cg"
 11456 ! !
 11458 ! !
 11473     HKEY key;
 11475     HKEY key;
 11474     OBJ t;
 11476     OBJ t;
 11475 
 11477 
 11476     key = __longIntVal(integerHandleValue);
 11478     key = __longIntVal(integerHandleValue);
 11477     if (! key) {
 11479     if (! key) {
 11478         RETURN (nil);
 11480 	RETURN (nil);
 11479     }
 11481     }
 11480 
 11482 
 11481     t = __MKEXTERNALADDRESS(key); __INST(handle) = t; __STORE(self, t);
 11483     t = __MKEXTERNALADDRESS(key); __INST(handle) = t; __STORE(self, t);
 11482 %}.
 11484 %}.
 11483 
 11485 
 11555     int bufferSize;
 11557     int bufferSize;
 11556     char miniBuffer[32];
 11558     char miniBuffer[32];
 11557     BOOL ok;
 11559     BOOL ok;
 11558 
 11560 
 11559     if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) {
 11561     if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) {
 11560         errSym = @symbol(errorNotOpen);
 11562 	errSym = @symbol(errorNotOpen);
 11561         goto bad;
 11563 	goto bad;
 11562     }
 11564     }
 11563     if (! __bothSmallInteger(count, firstIndex)) {
 11565     if (! __bothSmallInteger(count, firstIndex)) {
 11564         errSym = @symbol(badArgument);
 11566 	errSym = @symbol(badArgument);
 11565         goto bad;
 11567 	goto bad;
 11566     }
 11568     }
 11567     cntWanted = __smallIntegerVal(count);
 11569     cntWanted = __smallIntegerVal(count);
 11568     if (cntWanted <= 0) {
 11570     if (cntWanted <= 0) {
 11569         errSym = @symbol(badCount);
 11571 	errSym = @symbol(badCount);
 11570         goto bad;
 11572 	goto bad;
 11571     }
 11573     }
 11572     offs = __smallIntegerVal(firstIndex) - 1;
 11574     offs = __smallIntegerVal(firstIndex) - 1;
 11573     if (offs < 0) {
 11575     if (offs < 0) {
 11574         errSym = @symbol(badOffset);
 11576 	errSym = @symbol(badOffset);
 11575         goto bad;
 11577 	goto bad;
 11576     }
 11578     }
 11577 
 11579 
 11578     bufferIsExternalBytes = __isExternalBytesLike(aByteBuffer);
 11580     bufferIsExternalBytes = __isExternalBytesLike(aByteBuffer);
 11579     if (! bufferIsExternalBytes) {
 11581     if (! bufferIsExternalBytes) {
 11580         if (__isByteArray(aByteBuffer)) {
 11582 	if (__isByteArray(aByteBuffer)) {
 11581             bufferSize = __byteArraySize(aByteBuffer);
 11583 	    bufferSize = __byteArraySize(aByteBuffer);
 11582         } else if (__isString(aByteBuffer)) {
 11584 	} else if (__isString(aByteBuffer)) {
 11583             bufferSize = __stringSize(aByteBuffer);
 11585 	    bufferSize = __stringSize(aByteBuffer);
 11584         } else {
 11586 	} else {
 11585             errSym = @symbol(badBuffer);
 11587 	    errSym = @symbol(badBuffer);
 11586             goto bad;
 11588 	    goto bad;
 11587         }
 11589 	}
 11588         if (bufferSize < (cntWanted + offs)) {
 11590 	if (bufferSize < (cntWanted + offs)) {
 11589             errSym = @symbol(badBufferSize);
 11591 	    errSym = @symbol(badBufferSize);
 11590             goto bad;
 11592 	    goto bad;
 11591         }
 11593 	}
 11592         if (cntWanted <= sizeof(miniBuffer)) {
 11594 	if (cntWanted <= sizeof(miniBuffer)) {
 11593             extPtr = miniBuffer;
 11595 	    extPtr = miniBuffer;
 11594         } else {
 11596 	} else {
 11595             extPtr = malloc(cntWanted);
 11597 	    extPtr = malloc(cntWanted);
 11596             mustFreeBuffer = 1;
 11598 	    mustFreeBuffer = 1;
 11597         }
 11599 	}
 11598     } else {
 11600     } else {
 11599         OBJ sz;
 11601 	OBJ sz;
 11600 
 11602 
 11601         extPtr = (char *)(__externalBytesAddress(aByteBuffer));
 11603 	extPtr = (char *)(__externalBytesAddress(aByteBuffer));
 11602         sz = __externalBytesSize(aByteBuffer);
 11604 	sz = __externalBytesSize(aByteBuffer);
 11603         if (! __isSmallInteger(sz)) {
 11605 	if (! __isSmallInteger(sz)) {
 11604             errSym = @symbol(badBufferSize);
 11606 	    errSym = @symbol(badBufferSize);
 11605             goto bad;
 11607 	    goto bad;
 11606         }
 11608 	}
 11607         bufferSize = __smallIntegerVal(sz);
 11609 	bufferSize = __smallIntegerVal(sz);
 11608         if (bufferSize < (cntWanted + offs)) {
 11610 	if (bufferSize < (cntWanted + offs)) {
 11609             errSym = @symbol(badBufferSize);
 11611 	    errSym = @symbol(badBufferSize);
 11610             goto bad;
 11612 	    goto bad;
 11611         }
 11613 	}
 11612         extPtr = extPtr + offs;
 11614 	extPtr = extPtr + offs;
 11613     }
 11615     }
 11614 
 11616 
 11615     do {
 11617     do {
 11616         __threadErrno = 0;
 11618 	__threadErrno = 0;
 11617         ok = STX_API_CALL5( "ReadFile", ReadFile, hFile, extPtr, cntWanted, &cntRead, 0 /* lpOverlapped */);
 11619 	ok = STX_API_CALL5( "ReadFile", ReadFile, hFile, extPtr, cntWanted, &cntRead, 0 /* lpOverlapped */);
 11618     } while(__threadErrno == EINTR);
 11620     } while(__threadErrno == EINTR);
 11619 
 11621 
 11620     if (ok == TRUE) {
 11622     if (ok == TRUE) {
 11621         if (! bufferIsExternalBytes) {
 11623 	if (! bufferIsExternalBytes) {
 11622             /* copy over */
 11624 	    /* copy over */
 11623             memcpy(__byteArrayVal(aByteBuffer)+offs, extPtr, cntRead);
 11625 	    memcpy(__byteArrayVal(aByteBuffer)+offs, extPtr, cntRead);
 11624             if (mustFreeBuffer) {
 11626 	    if (mustFreeBuffer) {
 11625                 free(extPtr);
 11627 		free(extPtr);
 11626             }
 11628 	    }
 11627         }
 11629 	}
 11628         RETURN (__mkSmallInteger(cntRead));
 11630 	RETURN (__mkSmallInteger(cntRead));
 11629     }
 11631     }
 11630     errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
 11632     errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
 11631 
 11633 
 11632 bad: ;
 11634 bad: ;
 11633     if (mustFreeBuffer) {
 11635     if (mustFreeBuffer) {
 11634         free(extPtr);
 11636 	free(extPtr);
 11635     }
 11637     }
 11636 %}.
 11638 %}.
 11637 
 11639 
 11638     errorNumber isNil ifTrue:[
 11640     errorNumber isNil ifTrue:[
 11639         self error:'invalid argument(s): ', errSym.
 11641 	self error:'invalid argument(s): ', errSym.
 11640     ] ifFalse:[
 11642     ] ifFalse:[
 11641         (OperatingSystem errorHolderForNumber:errorNumber) reportError
 11643 	(OperatingSystem errorHolderForNumber:errorNumber) reportError
 11642     ].
 11644     ].
 11643 
 11645 
 11644     "
 11646     "
 11645      |h buff n|
 11647      |h buff n|
 11646 
 11648 
 11660     HANDLE hFile = (HANDLE)(__externalAddressVal(self));
 11662     HANDLE hFile = (HANDLE)(__externalAddressVal(self));
 11661     DWORD res;
 11663     DWORD res;
 11662     INT t;
 11664     INT t;
 11663 
 11665 
 11664     if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) {
 11666     if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) {
 11665         errSym = @symbol(errorNotOpen);
 11667 	errSym = @symbol(errorNotOpen);
 11666         goto bad;
 11668 	goto bad;
 11667     }
 11669     }
 11668 
 11670 
 11669 #if 0
 11671 #if 0
 11670     if (ioctlsocket((SOCKET)hFile, FIONREAD, &res)==0) {
 11672     if (ioctlsocket((SOCKET)hFile, FIONREAD, &res)==0) {
 11671         /* its a socket */
 11673 	/* its a socket */
 11672         if (res > 0) {
 11674 	if (res > 0) {
 11673             RETURN ( false );
 11675 	    RETURN ( false );
 11674         }
 11676 	}
 11675     }
 11677     }
 11676     if (PeekNamedPipe(hFile, 0, 0, 0, &res, 0)) {
 11678     if (PeekNamedPipe(hFile, 0, 0, 0, &res, 0)) {
 11677         /* its a namedPipe */
 11679 	/* its a namedPipe */
 11678         if (res > 0) {
 11680 	if (res > 0) {
 11679             RETURN ( false );
 11681 	    RETURN ( false );
 11680         }
 11682 	}
 11681     }
 11683     }
 11682 #endif
 11684 #endif
 11683     if (__isSmallInteger(millis)) {
 11685     if (__isSmallInteger(millis)) {
 11684         t = __intVal(millis);
 11686 	t = __intVal(millis);
 11685     } else {
 11687     } else {
 11686         t = INFINITE;
 11688 	t = INFINITE;
 11687     }
 11689     }
 11688 
 11690 
 11689     do {
 11691     do {
 11690         __threadErrno = 0;
 11692 	__threadErrno = 0;
 11691         res = WaitForSingleObject(hFile, t);
 11693 	res = WaitForSingleObject(hFile, t);
 11692     } while (__threadErrno == EINTR);
 11694     } while (__threadErrno == EINTR);
 11693 
 11695 
 11694     switch (res) {
 11696     switch (res) {
 11695         case WAIT_OBJECT_0:
 11697 	case WAIT_OBJECT_0:
 11696             /* signalled */
 11698 	    /* signalled */
 11697             RETURN ( false );
 11699 	    RETURN ( false );
 11698 
 11700 
 11699         case WAIT_TIMEOUT:
 11701 	case WAIT_TIMEOUT:
 11700             /* signalled */
 11702 	    /* signalled */
 11701             RETURN ( true );
 11703 	    RETURN ( true );
 11702 
 11704 
 11703         default:
 11705 	default:
 11704         case WAIT_ABANDONED:
 11706 	case WAIT_ABANDONED:
 11705             errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
 11707 	    errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
 11706             goto bad;
 11708 	    goto bad;
 11707     }
 11709     }
 11708 
 11710 
 11709 bad: ;
 11711 bad: ;
 11710 %}.
 11712 %}.
 11711     "
 11713     "
 11716     ^ self primitiveFailed
 11718     ^ self primitiveFailed
 11717 !
 11719 !
 11718 
 11720 
 11719 seekTo:newPosition from:whence
 11721 seekTo:newPosition from:whence
 11720     "whence is one of:
 11722     "whence is one of:
 11721         #begin
 11723 	#begin
 11722         #current
 11724 	#current
 11723         #end
 11725 	#end
 11724     "
 11726     "
 11725 
 11727 
 11726     |errSym errorNumber|
 11728     |errSym errorNumber|
 11727 
 11729 
 11728 %{
 11730 %{
 11730     DWORD moveHow;
 11732     DWORD moveHow;
 11731     LONG posLo, posHi = 0;
 11733     LONG posLo, posHi = 0;
 11732     __uint64__ pos64, newPos64;
 11734     __uint64__ pos64, newPos64;
 11733 
 11735 
 11734     if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) {
 11736     if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) {
 11735         errSym = @symbol(errorNotOpen);
 11737 	errSym = @symbol(errorNotOpen);
 11736         goto bad;
 11738 	goto bad;
 11737     }
 11739     }
 11738 
 11740 
 11739     if (whence == @symbol(begin)) {
 11741     if (whence == @symbol(begin)) {
 11740         moveHow = FILE_BEGIN;
 11742 	moveHow = FILE_BEGIN;
 11741     } else if (whence == @symbol(current)) {
 11743     } else if (whence == @symbol(current)) {
 11742         moveHow = FILE_CURRENT;
 11744 	moveHow = FILE_CURRENT;
 11743     } else if (whence == @symbol(end)) {
 11745     } else if (whence == @symbol(end)) {
 11744         moveHow = FILE_END;
 11746 	moveHow = FILE_END;
 11745     } else {
 11747     } else {
 11746         errSym = @symbol(badArgument2);
 11748 	errSym = @symbol(badArgument2);
 11747         goto bad;
 11749 	goto bad;
 11748     }
 11750     }
 11749 
 11751 
 11750     if (__signedLong64IntVal(newPosition, &pos64) == 0) {
 11752     if (__signedLong64IntVal(newPosition, &pos64) == 0) {
 11751         errSym = @symbol(badArgument);
 11753 	errSym = @symbol(badArgument);
 11752         goto bad;
 11754 	goto bad;
 11753     }
 11755     }
 11754     posLo = pos64.lo;
 11756     posLo = pos64.lo;
 11755     posHi = pos64.hi;
 11757     posHi = pos64.hi;
 11756 
 11758 
 11757     posLo = SetFilePointer(hFile, posLo, &posHi, moveHow);
 11759     posLo = SetFilePointer(hFile, posLo, &posHi, moveHow);
 11758     if (posLo == 0xFFFFFFFF) {
 11760     if (posLo == 0xFFFFFFFF) {
 11759         int lastError;
 11761 	int lastError;
 11760 
 11762 
 11761         /* can be either an error, or a valid low-word */
 11763 	/* can be either an error, or a valid low-word */
 11762         lastError = GetLastError();
 11764 	lastError = GetLastError();
 11763         if (lastError != NO_ERROR) {
 11765 	if (lastError != NO_ERROR) {
 11764             errorNumber = __mkSmallInteger( __WIN32_ERR(lastError) );
 11766 	    errorNumber = __mkSmallInteger( __WIN32_ERR(lastError) );
 11765             goto bad;
 11767 	    goto bad;
 11766         }
 11768 	}
 11767     }
 11769     }
 11768 
 11770 
 11769     if (posHi == 0) {
 11771     if (posHi == 0) {
 11770         RETURN (__MKUINT( posLo ));
 11772 	RETURN (__MKUINT( posLo ));
 11771     }
 11773     }
 11772     newPos64.lo = posLo;
 11774     newPos64.lo = posLo;
 11773     newPos64.hi = posHi;
 11775     newPos64.hi = posHi;
 11774 
 11776 
 11775     RETURN ( __MKUINT64(&newPos64) );
 11777     RETURN ( __MKUINT64(&newPos64) );
 11776 
 11778 
 11777 bad: ;
 11779 bad: ;
 11778 %}.
 11780 %}.
 11779 
 11781 
 11780     errorNumber isNil ifTrue:[
 11782     errorNumber isNil ifTrue:[
 11781         self error:'invalid argument(s): ', errSym.
 11783 	self error:'invalid argument(s): ', errSym.
 11782     ] ifFalse:[
 11784     ] ifFalse:[
 11783         (OperatingSystem errorHolderForNumber:errorNumber) reportError
 11785 	(OperatingSystem errorHolderForNumber:errorNumber) reportError
 11784     ].
 11786     ].
 11785 !
 11787 !
 11786 
 11788 
 11787 writeBytes:count from:aByteBuffer startingAt:firstIndex
 11789 writeBytes:count from:aByteBuffer startingAt:firstIndex
 11788     "write count bytes from a byte-buffer;
 11790     "write count bytes from a byte-buffer;
 11799     int bufferSize;
 11801     int bufferSize;
 11800     char miniBuffer[32];
 11802     char miniBuffer[32];
 11801     BOOL ok;
 11803     BOOL ok;
 11802 
 11804 
 11803     if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) {
 11805     if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) {
 11804         errSym = @symbol(errorNotOpen);
 11806 	errSym = @symbol(errorNotOpen);
 11805         goto bad;
 11807 	goto bad;
 11806     }
 11808     }
 11807     if (! __bothSmallInteger(count, firstIndex)) {
 11809     if (! __bothSmallInteger(count, firstIndex)) {
 11808         errSym = @symbol(badArgument);
 11810 	errSym = @symbol(badArgument);
 11809         goto bad;
 11811 	goto bad;
 11810     }
 11812     }
 11811     cntWanted = __smallIntegerVal(count);
 11813     cntWanted = __smallIntegerVal(count);
 11812     if (cntWanted <= 0) {
 11814     if (cntWanted <= 0) {
 11813         errSym = @symbol(badCount);
 11815 	errSym = @symbol(badCount);
 11814         goto bad;
 11816 	goto bad;
 11815     }
 11817     }
 11816     offs = __smallIntegerVal(firstIndex) - 1;
 11818     offs = __smallIntegerVal(firstIndex) - 1;
 11817     if (offs < 0) {
 11819     if (offs < 0) {
 11818         errSym = @symbol(badOffset);
 11820 	errSym = @symbol(badOffset);
 11819         goto bad;
 11821 	goto bad;
 11820     }
 11822     }
 11821 
 11823 
 11822     bufferIsExternalBytes = __isExternalBytesLike(aByteBuffer);
 11824     bufferIsExternalBytes = __isExternalBytesLike(aByteBuffer);
 11823     if (! bufferIsExternalBytes) {
 11825     if (! bufferIsExternalBytes) {
 11824         if (__isByteArray(aByteBuffer)) {
 11826 	if (__isByteArray(aByteBuffer)) {
 11825             bufferSize = __byteArraySize(aByteBuffer);
 11827 	    bufferSize = __byteArraySize(aByteBuffer);
 11826         } else if (__isString(aByteBuffer)) {
 11828 	} else if (__isString(aByteBuffer)) {
 11827             bufferSize = __stringSize(aByteBuffer);
 11829 	    bufferSize = __stringSize(aByteBuffer);
 11828         } else {
 11830 	} else {
 11829             errSym = @symbol(badBuffer);
 11831 	    errSym = @symbol(badBuffer);
 11830             goto bad;
 11832 	    goto bad;
 11831         }
 11833 	}
 11832         if (bufferSize < (cntWanted + offs)) {
 11834 	if (bufferSize < (cntWanted + offs)) {
 11833             errSym = @symbol(badBufferSize);
 11835 	    errSym = @symbol(badBufferSize);
 11834             goto bad;
 11836 	    goto bad;
 11835         }
 11837 	}
 11836         if (cntWanted <= sizeof(miniBuffer)) {
 11838 	if (cntWanted <= sizeof(miniBuffer)) {
 11837             extPtr = miniBuffer;
 11839 	    extPtr = miniBuffer;
 11838         } else {
 11840 	} else {
 11839             extPtr = malloc(cntWanted);
 11841 	    extPtr = malloc(cntWanted);
 11840             mustFreeBuffer = 1;
 11842 	    mustFreeBuffer = 1;
 11841         }
 11843 	}
 11842         memcpy(extPtr, __byteArrayVal(aByteBuffer)+offs, cntWanted);
 11844 	memcpy(extPtr, __byteArrayVal(aByteBuffer)+offs, cntWanted);
 11843     } else {
 11845     } else {
 11844         extPtr = (char *)(__externalBytesAddress(aByteBuffer));
 11846 	extPtr = (char *)(__externalBytesAddress(aByteBuffer));
 11845         bufferSize = __externalBytesSize(aByteBuffer);
 11847 	bufferSize = __externalBytesSize(aByteBuffer);
 11846         if (! __isSmallInteger(bufferSize)) {
 11848 	if (! __isSmallInteger(bufferSize)) {
 11847             errSym = @symbol(badBufferSize);
 11849 	    errSym = @symbol(badBufferSize);
 11848             goto bad;
 11850 	    goto bad;
 11849         }
 11851 	}
 11850         bufferSize = __smallIntegerVal(bufferSize);
 11852 	bufferSize = __smallIntegerVal(bufferSize);
 11851         if (bufferSize < (cntWanted + offs)) {
 11853 	if (bufferSize < (cntWanted + offs)) {
 11852             errSym = @symbol(badBufferSize);
 11854 	    errSym = @symbol(badBufferSize);
 11853             goto bad;
 11855 	    goto bad;
 11854         }
 11856 	}
 11855         extPtr = extPtr + offs;
 11857 	extPtr = extPtr + offs;
 11856     }
 11858     }
 11857 
 11859 
 11858     do {
 11860     do {
 11859         __threadErrno = 0;
 11861 	__threadErrno = 0;
 11860         ok = STX_API_CALL5( "WriteFile", WriteFile, hFile, extPtr, cntWanted, &cntWritten, 0 /* lpOverlapped */);
 11862 	ok = STX_API_CALL5( "WriteFile", WriteFile, hFile, extPtr, cntWanted, &cntWritten, 0 /* lpOverlapped */);
 11861     } while(__threadErrno == EINTR);
 11863     } while(__threadErrno == EINTR);
 11862 
 11864 
 11863     if (ok == TRUE) {
 11865     if (ok == TRUE) {
 11864         if (mustFreeBuffer) {
 11866 	if (mustFreeBuffer) {
 11865             free(extPtr);
 11867 	    free(extPtr);
 11866         }
 11868 	}
 11867         RETURN (__mkSmallInteger(cntWritten));
 11869 	RETURN (__mkSmallInteger(cntWritten));
 11868     }
 11870     }
 11869     errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
 11871     errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
 11870 
 11872 
 11871 bad: ;
 11873 bad: ;
 11872     if (mustFreeBuffer) {
 11874     if (mustFreeBuffer) {
 11873         free(extPtr);
 11875 	free(extPtr);
 11874     }
 11876     }
 11875 %}.
 11877 %}.
 11876     errorNumber isNil ifTrue:[
 11878     errorNumber isNil ifTrue:[
 11877         self error:'invalid argument(s): ', errSym.
 11879 	self error:'invalid argument(s): ', errSym.
 11878     ] ifFalse:[
 11880     ] ifFalse:[
 11879         (OperatingSystem errorHolderForNumber:errorNumber) reportError
 11881 	(OperatingSystem errorHolderForNumber:errorNumber) reportError
 11880     ].
 11882     ].
 11881 
 11883 
 11882     "
 11884     "
 11883      |h buff n|
 11885      |h buff n|
 11884 
 11886 
 11903 
 11905 
 11904 %{
 11906 %{
 11905     HANDLE h = (HANDLE)(__externalAddressVal(self));
 11907     HANDLE h = (HANDLE)(__externalAddressVal(self));
 11906 
 11908 
 11907     if (h) {
 11909     if (h) {
 11908         __externalAddressVal(self) = (HANDLE)0;
 11910 	__externalAddressVal(self) = (HANDLE)0;
 11909         CloseHandle(h);
 11911 	CloseHandle(h);
 11910     }
 11912     }
 11911 %}.
 11913 %}.
 11912 ! !
 11914 ! !
 11913 
 11915 
 11914 !Win32OperatingSystem::Win32PrinterHandle methodsFor:'release'!
 11916 !Win32OperatingSystem::Win32PrinterHandle methodsFor:'release'!
 11915 
 11917 
 11916 closeHandle
 11918 closeHandle
 11917     self address ~~ 0 ifTrue:[
 11919     self address ~~ 0 ifTrue:[
 11918         OperatingSystem primClosePrinter:self.
 11920 	OperatingSystem primClosePrinter:self.
 11919     ]
 11921     ]
 11920 
 11922 
 11921     "Created: / 27-07-2006 / 14:48:37 / fm"
 11923     "Created: / 27-07-2006 / 14:48:37 / fm"
 11922 ! !
 11924 ! !
 11923 
 11925 
 11928 ! !
 11930 ! !
 11929 
 11931 
 11930 !Win32OperatingSystem::Win32SerialPortHandle methodsFor:'opening'!
 11932 !Win32OperatingSystem::Win32SerialPortHandle methodsFor:'opening'!
 11931 
 11933 
 11932 open:portName baudRate:baudRate stopBitsType:stopBitsType
 11934 open:portName baudRate:baudRate stopBitsType:stopBitsType
 11933                     parityType:parityType dataBits:dataBits
 11935 		    parityType:parityType dataBits:dataBits
 11934                     inFlowCtrl:inFlowCtrlType outFlowCtrl:outFlowCtrlType
 11936 		    inFlowCtrl:inFlowCtrlType outFlowCtrl:outFlowCtrlType
 11935                     xOnChar:xOnChar xOffChar:xOffChar
 11937 		    xOnChar:xOnChar xOffChar:xOffChar
 11936     "portName: COM%d
 11938     "portName: COM%d
 11937      baudRate: Integer
 11939      baudRate: Integer
 11938      stopBitsType: #stop1, #stop2 or #stop1_5
 11940      stopBitsType: #stop1, #stop2 or #stop1_5
 11939      parityType: #odd, #even or #none
 11941      parityType: #odd, #even or #none
 11940      dataBits: #integer
 11942      dataBits: #integer
 11949     HANDLE port;
 11951     HANDLE port;
 11950     COMMTIMEOUTS timeouts;
 11952     COMMTIMEOUTS timeouts;
 11951     DCB dcb;
 11953     DCB dcb;
 11952     char *__portName;
 11954     char *__portName;
 11953     int __setBaudRate = 1,
 11955     int __setBaudRate = 1,
 11954         __setDataBits = 1,
 11956 	__setDataBits = 1,
 11955         __setXOnChar = 1,
 11957 	__setXOnChar = 1,
 11956         __setXOffChar = 1,
 11958 	__setXOffChar = 1,
 11957         __setInFlowCtrl = 1,
 11959 	__setInFlowCtrl = 1,
 11958         __setOutFlowCtrl = 1,
 11960 	__setOutFlowCtrl = 1,
 11959         __setStopBits = 1,
 11961 	__setStopBits = 1,
 11960         __setParityType = 1;
 11962 	__setParityType = 1;
 11961     int __baudRate, __dataBits;
 11963     int __baudRate, __dataBits;
 11962     int __xOnChar, __xOffChar;
 11964     int __xOnChar, __xOffChar;
 11963     int __inFlowCtrl, __outFlowCtrl;
 11965     int __inFlowCtrl, __outFlowCtrl;
 11964     int __stopBits, __parityType;
 11966     int __stopBits, __parityType;
 11965 #   define XONOFF       1
 11967 #   define XONOFF       1
 11970 #   define ODD       1
 11972 #   define ODD       1
 11971 #   define EVEN      2
 11973 #   define EVEN      2
 11972 #   define NONE      3
 11974 #   define NONE      3
 11973 
 11975 
 11974     if (__isString(portName)) {
 11976     if (__isString(portName)) {
 11975         __portName = __stringVal(portName);
 11977 	__portName = __stringVal(portName);
 11976     } else {
 11978     } else {
 11977         goto failure;
 11979 	goto failure;
 11978     }
 11980     }
 11979     if (__isSmallInteger(baudRate)) {
 11981     if (__isSmallInteger(baudRate)) {
 11980         __baudRate = __intVal(baudRate);
 11982 	__baudRate = __intVal(baudRate);
 11981     } else if (baudRate == nil) {
 11983     } else if (baudRate == nil) {
 11982         __setBaudRate = 0;
 11984 	__setBaudRate = 0;
 11983     } else {
 11985     } else {
 11984         goto failure;
 11986 	goto failure;
 11985     }
 11987     }
 11986 
 11988 
 11987     if (__isSmallInteger(dataBits)) {
 11989     if (__isSmallInteger(dataBits)) {
 11988         __dataBits = __intVal(dataBits);
 11990 	__dataBits = __intVal(dataBits);
 11989     } else if (dataBits == nil) {
 11991     } else if (dataBits == nil) {
 11990         __setDataBits = 0;
 11992 	__setDataBits = 0;
 11991     } else {
 11993     } else {
 11992         goto failure;
 11994 	goto failure;
 11993     }
 11995     }
 11994 
 11996 
 11995     if (__isSmallInteger(xOnChar)) {
 11997     if (__isSmallInteger(xOnChar)) {
 11996         __xOnChar = __intVal(xOnChar);
 11998 	__xOnChar = __intVal(xOnChar);
 11997     } else if (__isCharacter(xOnChar)) {
 11999     } else if (__isCharacter(xOnChar)) {
 11998         __xOnChar = __intVal(_characterVal(xOnChar));
 12000 	__xOnChar = __intVal(_characterVal(xOnChar));
 11999     } else if (xOnChar == nil) {
 12001     } else if (xOnChar == nil) {
 12000         __setXOnChar = 0;
 12002 	__setXOnChar = 0;
 12001     } else {
 12003     } else {
 12002         goto failure;
 12004 	goto failure;
 12003     }
 12005     }
 12004 
 12006 
 12005     if (__isSmallInteger(xOffChar)) {
 12007     if (__isSmallInteger(xOffChar)) {
 12006         __xOffChar = __intVal(xOffChar);
 12008 	__xOffChar = __intVal(xOffChar);
 12007     } else if (__isCharacter(xOffChar)) {
 12009     } else if (__isCharacter(xOffChar)) {
 12008         __xOffChar = __intVal(_characterVal(xOffChar));
 12010 	__xOffChar = __intVal(_characterVal(xOffChar));
 12009     } else if (xOffChar == nil) {
 12011     } else if (xOffChar == nil) {
 12010         __setXOffChar = 0;
 12012 	__setXOffChar = 0;
 12011     } else {
 12013     } else {
 12012         goto failure;
 12014 	goto failure;
 12013     }
 12015     }
 12014 
 12016 
 12015     if (inFlowCtrlType == @symbol(xOnOff)) {
 12017     if (inFlowCtrlType == @symbol(xOnOff)) {
 12016         __inFlowCtrl = XONOFF;
 12018 	__inFlowCtrl = XONOFF;
 12017     } else if (inFlowCtrlType == @symbol(hardware)) {
 12019     } else if (inFlowCtrlType == @symbol(hardware)) {
 12018         __inFlowCtrl = HARDWARE;
 12020 	__inFlowCtrl = HARDWARE;
 12019     } else if (inFlowCtrlType == nil) {
 12021     } else if (inFlowCtrlType == nil) {
 12020         __setInFlowCtrl = 0;
 12022 	__setInFlowCtrl = 0;
 12021     } else {
 12023     } else {
 12022         goto failure;
 12024 	goto failure;
 12023     }
 12025     }
 12024 
 12026 
 12025     if (outFlowCtrlType == @symbol(xOnOff)) {
 12027     if (outFlowCtrlType == @symbol(xOnOff)) {
 12026         __outFlowCtrl = XONOFF;
 12028 	__outFlowCtrl = XONOFF;
 12027     } else if (outFlowCtrlType == @symbol(hardware)) {
 12029     } else if (outFlowCtrlType == @symbol(hardware)) {
 12028         __outFlowCtrl = HARDWARE;
 12030 	__outFlowCtrl = HARDWARE;
 12029     } else if (outFlowCtrlType == nil) {
 12031     } else if (outFlowCtrlType == nil) {
 12030         __setOutFlowCtrl = 0;
 12032 	__setOutFlowCtrl = 0;
 12031     } else {
 12033     } else {
 12032         goto failure;
 12034 	goto failure;
 12033     }
 12035     }
 12034 
 12036 
 12035     if (stopBitsType == @symbol(stop1)) {
 12037     if (stopBitsType == @symbol(stop1)) {
 12036         __stopBits = STOP1;
 12038 	__stopBits = STOP1;
 12037     } else if (stopBitsType == @symbol(stop2)) {
 12039     } else if (stopBitsType == @symbol(stop2)) {
 12038         __stopBits = STOP2;
 12040 	__stopBits = STOP2;
 12039     } else if (stopBitsType == @symbol(stop1_5)) {
 12041     } else if (stopBitsType == @symbol(stop1_5)) {
 12040         __stopBits = STOP1_5;
 12042 	__stopBits = STOP1_5;
 12041     } else if (stopBitsType == nil) {
 12043     } else if (stopBitsType == nil) {
 12042         __setStopBits = 0;
 12044 	__setStopBits = 0;
 12043     } else {
 12045     } else {
 12044         goto failure;
 12046 	goto failure;
 12045     }
 12047     }
 12046 
 12048 
 12047     port = CreateFile(__portName,
 12049     port = CreateFile(__portName,
 12048               GENERIC_READ | GENERIC_WRITE,
 12050 	      GENERIC_READ | GENERIC_WRITE,
 12049               0,             /* comm devices must be opened with exclusive access */
 12051 	      0,             /* comm devices must be opened with exclusive access */
 12050               NULL,          /* no security attrs */
 12052 	      NULL,          /* no security attrs */
 12051               OPEN_EXISTING, /* comm devices must use OPEN_EXISTING */
 12053 	      OPEN_EXISTING, /* comm devices must use OPEN_EXISTING */
 12052               0,             /* no overlapped I/O */
 12054 	      0,             /* no overlapped I/O */
 12053               NULL           /* hTemplate must be NULL for comm devices */
 12055 	      NULL           /* hTemplate must be NULL for comm devices */
 12054            );
 12056 	   );
 12055     if (port == INVALID_HANDLE_VALUE) {
 12057     if (port == INVALID_HANDLE_VALUE) {
 12056         console_fprintf(stderr, "Win32OS [info]: serial port open failed\n");
 12058 	console_fprintf(stderr, "Win32OS [info]: serial port open failed\n");
 12057         errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
 12059 	errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
 12058         goto failure;
 12060 	goto failure;
 12059     }
 12061     }
 12060     /* Flush the driver */
 12062     /* Flush the driver */
 12061     PurgeComm( port, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR );
 12063     PurgeComm( port, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR );
 12062 
 12064 
 12063     /* Set driver buffer sizes */
 12065     /* Set driver buffer sizes */
 12080     if (__setDataBits) dcb.ByteSize = __dataBits;
 12082     if (__setDataBits) dcb.ByteSize = __dataBits;
 12081     if (__setXOnChar)  dcb.XonChar = __xOnChar;
 12083     if (__setXOnChar)  dcb.XonChar = __xOnChar;
 12082     if (__setXOffChar) dcb.XoffChar = __xOffChar;
 12084     if (__setXOffChar) dcb.XoffChar = __xOffChar;
 12083 
 12085 
 12084     if (__setStopBits) {
 12086     if (__setStopBits) {
 12085         /* set stop bits */
 12087 	/* set stop bits */
 12086         switch(__stopBits) {
 12088 	switch(__stopBits) {
 12087             case STOP1_5: dcb.StopBits = 1; break; /* 1.5 stop bits */
 12089 	    case STOP1_5: dcb.StopBits = 1; break; /* 1.5 stop bits */
 12088             case STOP1: dcb.StopBits = 0; break; /* 1 stop bit */
 12090 	    case STOP1: dcb.StopBits = 0; break; /* 1 stop bit */
 12089             case STOP2: dcb.StopBits = 2; break; /* 2 stop bits */
 12091 	    case STOP2: dcb.StopBits = 2; break; /* 2 stop bits */
 12090             default: goto errExit;
 12092 	    default: goto errExit;
 12091         }
 12093 	}
 12092     }
 12094     }
 12093 
 12095 
 12094     if (__setParityType) {
 12096     if (__setParityType) {
 12095         /* set parity */
 12097 	/* set parity */
 12096         switch(__parityType) {
 12098 	switch(__parityType) {
 12097             case NONE: dcb.Parity = NOPARITY; break;
 12099 	    case NONE: dcb.Parity = NOPARITY; break;
 12098             case ODD: dcb.Parity = ODDPARITY; break;
 12100 	    case ODD: dcb.Parity = ODDPARITY; break;
 12099             case EVEN: dcb.Parity = EVENPARITY; break;
 12101 	    case EVEN: dcb.Parity = EVENPARITY; break;
 12100             default: goto errExit;
 12102 	    default: goto errExit;
 12101         }
 12103 	}
 12102     }
 12104     }
 12103 
 12105 
 12104     if (__setInFlowCtrl) {
 12106     if (__setInFlowCtrl) {
 12105         /* set control flow */
 12107 	/* set control flow */
 12106         dcb.fInX = FALSE;
 12108 	dcb.fInX = FALSE;
 12107         dcb.fDtrControl = FALSE;
 12109 	dcb.fDtrControl = FALSE;
 12108         if (__inFlowCtrl == XONOFF) dcb.fInX = TRUE;  /* XOn/XOff handshaking */
 12110 	if (__inFlowCtrl == XONOFF) dcb.fInX = TRUE;  /* XOn/XOff handshaking */
 12109         if (__inFlowCtrl == HARDWARE) dcb.fDtrControl = TRUE;  /* hardware handshaking */
 12111 	if (__inFlowCtrl == HARDWARE) dcb.fDtrControl = TRUE;  /* hardware handshaking */
 12110     }
 12112     }
 12111     if (__setOutFlowCtrl) {
 12113     if (__setOutFlowCtrl) {
 12112         dcb.fOutX = FALSE;
 12114 	dcb.fOutX = FALSE;
 12113         dcb.fOutxCtsFlow = FALSE;
 12115 	dcb.fOutxCtsFlow = FALSE;
 12114 
 12116 
 12115         if (__outFlowCtrl == XONOFF) dcb.fOutX = TRUE;  /* XOn/XOff handshaking */
 12117 	if (__outFlowCtrl == XONOFF) dcb.fOutX = TRUE;  /* XOn/XOff handshaking */
 12116         if (__outFlowCtrl == HARDWARE) dcb.fOutxCtsFlow = TRUE;  /* hardware handshaking */
 12118 	if (__outFlowCtrl == HARDWARE) dcb.fOutxCtsFlow = TRUE;  /* hardware handshaking */
 12117     }
 12119     }
 12118 
 12120 
 12119     if (SetCommState(port, &dcb)) {
 12121     if (SetCommState(port, &dcb)) {
 12120         RETURN( true );
 12122 	RETURN( true );
 12121     }
 12123     }
 12122 
 12124 
 12123     console_fprintf(stderr, "Win32OS [info]: serial port comm-setup failed\n");
 12125     console_fprintf(stderr, "Win32OS [info]: serial port comm-setup failed\n");
 12124     errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
 12126     errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
 12125     /* fall into */
 12127     /* fall into */
 12135 #   undef ODD
 12137 #   undef ODD
 12136 #   undef EVEN
 12138 #   undef EVEN
 12137 #   undef NONE
 12139 #   undef NONE
 12138 %}.
 12140 %}.
 12139     errorNumber isNil ifTrue:[
 12141     errorNumber isNil ifTrue:[
 12140         self error:'invalid argument(s)'.
 12142 	self error:'invalid argument(s)'.
 12141     ] ifFalse:[
 12143     ] ifFalse:[
 12142         (OperatingSystem errorHolderForNumber:errorNumber) reportError
 12144 	(OperatingSystem errorHolderForNumber:errorNumber) reportError
 12143     ].
 12145     ].
 12144 ! !
 12146 ! !
 12145 
 12147 
 12146 !Win32OperatingSystem::Win32SerialPortHandle methodsFor:'release'!
 12148 !Win32OperatingSystem::Win32SerialPortHandle methodsFor:'release'!
 12147 
 12149 
 12150 
 12152 
 12151 %{
 12153 %{
 12152     HANDLE port = (HANDLE)(__externalAddressVal(self));
 12154     HANDLE port = (HANDLE)(__externalAddressVal(self));
 12153 
 12155 
 12154     if (port) {
 12156     if (port) {
 12155         __externalAddressVal(self) = (HANDLE)0;
 12157 	__externalAddressVal(self) = (HANDLE)0;
 12156         PurgeComm( port, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR );
 12158 	PurgeComm( port, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR );
 12157         CloseHandle(port);
 12159 	CloseHandle(port);
 12158     }
 12160     }
 12159 %}.
 12161 %}.
 12160 ! !
 12162 ! !
 12161 
 12163 
 12162 !Win32OperatingSystem::Win32SerialPortHandle methodsFor:'setup'!
 12164 !Win32OperatingSystem::Win32SerialPortHandle methodsFor:'setup'!
 12165 %{
 12167 %{
 12166     HANDLE port = (HANDLE)(__externalAddressVal(self));
 12168     HANDLE port = (HANDLE)(__externalAddressVal(self));
 12167 
 12169 
 12168     if (port
 12170     if (port
 12169      && __isSmallInteger(newRate)) {
 12171      && __isSmallInteger(newRate)) {
 12170         DCB dcb;
 12172 	DCB dcb;
 12171 
 12173 
 12172         ZeroMemory(&dcb, sizeof(dcb));
 12174 	ZeroMemory(&dcb, sizeof(dcb));
 12173         dcb.DCBlength = sizeof(dcb);
 12175 	dcb.DCBlength = sizeof(dcb);
 12174         GetCommState(port, &dcb);
 12176 	GetCommState(port, &dcb);
 12175 
 12177 
 12176         dcb.BaudRate = __intVal(newRate);
 12178 	dcb.BaudRate = __intVal(newRate);
 12177 
 12179 
 12178         if (! SetCommState(port, &dcb)) {
 12180 	if (! SetCommState(port, &dcb)) {
 12179             RETURN(false);
 12181 	    RETURN(false);
 12180         }
 12182 	}
 12181         RETURN(true);
 12183 	RETURN(true);
 12182     }
 12184     }
 12183 %}.
 12185 %}.
 12184     self primitiveFailed.
 12186     self primitiveFailed.
 12185 !
 12187 !
 12186 
 12188 
 12188 %{
 12190 %{
 12189     HANDLE port = (HANDLE)(__externalAddressVal(self));
 12191     HANDLE port = (HANDLE)(__externalAddressVal(self));
 12190 
 12192 
 12191     if (port
 12193     if (port
 12192      && __isSmallInteger(newNumberOfBits)) {
 12194      && __isSmallInteger(newNumberOfBits)) {
 12193         DCB dcb;
 12195 	DCB dcb;
 12194 
 12196 
 12195         ZeroMemory(&dcb, sizeof(dcb));
 12197 	ZeroMemory(&dcb, sizeof(dcb));
 12196         dcb.DCBlength = sizeof(dcb);
 12198 	dcb.DCBlength = sizeof(dcb);
 12197         GetCommState(port, &dcb);
 12199 	GetCommState(port, &dcb);
 12198 
 12200 
 12199         dcb.ByteSize = __intVal(newNumberOfBits);
 12201 	dcb.ByteSize = __intVal(newNumberOfBits);
 12200 
 12202 
 12201         if (! SetCommState(port, &dcb)) {
 12203 	if (! SetCommState(port, &dcb)) {
 12202             RETURN(false);
 12204 	    RETURN(false);
 12203         }
 12205 	}
 12204         RETURN(true);
 12206 	RETURN(true);
 12205     }
 12207     }
 12206 %}.
 12208 %}.
 12207     self primitiveFailed.
 12209     self primitiveFailed.
 12208 !
 12210 !
 12209 
 12211 
 12212 
 12214 
 12213 %{
 12215 %{
 12214     HANDLE port = (HANDLE)(__externalAddressVal(self));
 12216     HANDLE port = (HANDLE)(__externalAddressVal(self));
 12215 
 12217 
 12216     if (port) {
 12218     if (port) {
 12217         DCB dcb;
 12219 	DCB dcb;
 12218 
 12220 
 12219         ZeroMemory(&dcb, sizeof(dcb));
 12221 	ZeroMemory(&dcb, sizeof(dcb));
 12220         dcb.DCBlength = sizeof(dcb);
 12222 	dcb.DCBlength = sizeof(dcb);
 12221         GetCommState(port, &dcb);
 12223 	GetCommState(port, &dcb);
 12222 
 12224 
 12223 
 12225 
 12224         if ((newParityTypeSymbol == nil) || (newParityTypeSymbol == @symbol(none))) {
 12226 	if ((newParityTypeSymbol == nil) || (newParityTypeSymbol == @symbol(none))) {
 12225             dcb.Parity = NOPARITY;
 12227 	    dcb.Parity = NOPARITY;
 12226         } else if (newParityTypeSymbol == @symbol(odd)) {
 12228 	} else if (newParityTypeSymbol == @symbol(odd)) {
 12227             dcb.Parity = ODDPARITY;
 12229 	    dcb.Parity = ODDPARITY;
 12228         } else if (newParityTypeSymbol == @symbol(even)) {
 12230 	} else if (newParityTypeSymbol == @symbol(even)) {
 12229             dcb.Parity = EVENPARITY;
 12231 	    dcb.Parity = EVENPARITY;
 12230         } else {
 12232 	} else {
 12231             goto failure;
 12233 	    goto failure;
 12232         }
 12234 	}
 12233 
 12235 
 12234         if (! SetCommState(port, &dcb)) {
 12236 	if (! SetCommState(port, &dcb)) {
 12235             RETURN(false);
 12237 	    RETURN(false);
 12236         }
 12238 	}
 12237         RETURN(true);
 12239 	RETURN(true);
 12238     }
 12240     }
 12239   failure: ;
 12241   failure: ;
 12240 %}.
 12242 %}.
 12241     self primitiveFailed.
 12243     self primitiveFailed.
 12242 !
 12244 !
 12245     "newParityTypeSymbol must be one of #stop1, #stop2 or #stop1_5"
 12247     "newParityTypeSymbol must be one of #stop1, #stop2 or #stop1_5"
 12246 %{
 12248 %{
 12247     HANDLE port = (HANDLE)(__externalAddressVal(self));
 12249     HANDLE port = (HANDLE)(__externalAddressVal(self));
 12248 
 12250 
 12249     if (port) {
 12251     if (port) {
 12250         DCB dcb;
 12252 	DCB dcb;
 12251 
 12253 
 12252         ZeroMemory(&dcb, sizeof(dcb));
 12254 	ZeroMemory(&dcb, sizeof(dcb));
 12253         dcb.DCBlength = sizeof(dcb);
 12255 	dcb.DCBlength = sizeof(dcb);
 12254         GetCommState(port, &dcb);
 12256 	GetCommState(port, &dcb);
 12255 
 12257 
 12256         if (newStopBitsSymbol == @symbol(stop1)) {
 12258 	if (newStopBitsSymbol == @symbol(stop1)) {
 12257             dcb.Parity = 0 /* STOP1 */;
 12259 	    dcb.Parity = 0 /* STOP1 */;
 12258         } else if (newStopBitsSymbol == @symbol(stop2)) {
 12260 	} else if (newStopBitsSymbol == @symbol(stop2)) {
 12259             dcb.Parity = 2 /* STOP2 */;
 12261 	    dcb.Parity = 2 /* STOP2 */;
 12260         } else if (newStopBitsSymbol == @symbol(stop1_5)) {
 12262 	} else if (newStopBitsSymbol == @symbol(stop1_5)) {
 12261             dcb.Parity = 1 /* STOP1_5 */;
 12263 	    dcb.Parity = 1 /* STOP1_5 */;
 12262         } else {
 12264 	} else {
 12263             goto failure;
 12265 	    goto failure;
 12264         }
 12266 	}
 12265 
 12267 
 12266         if (! SetCommState(port, &dcb)) {
 12268 	if (! SetCommState(port, &dcb)) {
 12267             RETURN(false);
 12269 	    RETURN(false);
 12268         }
 12270 	}
 12269         RETURN(true);
 12271 	RETURN(true);
 12270     }
 12272     }
 12271   failure: ;
 12273   failure: ;
 12272 %}.
 12274 %}.
 12273     self primitiveFailed.
 12275     self primitiveFailed.
 12274 ! !
 12276 ! !
 12328 #if !defined(NO_SOCKET)
 12330 #if !defined(NO_SOCKET)
 12329     char *__hostName, *__serviceName;
 12331     char *__hostName, *__serviceName;
 12330     int ret, cnt = 0;
 12332     int ret, cnt = 0;
 12331 
 12333 
 12332     if (hostName == nil) {
 12334     if (hostName == nil) {
 12333         __hostName = 0;
 12335 	__hostName = 0;
 12334     } else if (__isString(hostName) || __isSymbol(hostName)) {
 12336     } else if (__isString(hostName) || __isSymbol(hostName)) {
 12335         __hostName = __stringVal(hostName);
 12337 	__hostName = __stringVal(hostName);
 12336     } else {
 12338     } else {
 12337         error = @symbol(badArgument1);
 12339 	error = @symbol(badArgument1);
 12338         goto err;
 12340 	goto err;
 12339     }
 12341     }
 12340     if (serviceName == nil) {
 12342     if (serviceName == nil) {
 12341         __serviceName = 0;
 12343 	__serviceName = 0;
 12342     } else if (__isString(serviceName) || __isSymbol(serviceName)) {
 12344     } else if (__isString(serviceName) || __isSymbol(serviceName)) {
 12343         __serviceName = __stringVal(serviceName);
 12345 	__serviceName = __stringVal(serviceName);
 12344     } else {
 12346     } else {
 12345         error = @symbol(badArgument2);
 12347 	error = @symbol(badArgument2);
 12346         goto err;
 12348 	goto err;
 12347     }
 12349     }
 12348     if (__hostName == 0 && __serviceName == 0) {
 12350     if (__hostName == 0 && __serviceName == 0) {
 12349         error = @symbol(badArgument);
 12351 	error = @symbol(badArgument);
 12350         goto err;
 12352 	goto err;
 12351     }
 12353     }
 12352 
 12354 
 12353 {
 12355 {
 12354 # if defined(AI_NUMERICHOST)
 12356 # if defined(AI_NUMERICHOST)
 12355     /*
 12357     /*
 12358     struct addrinfo hints;
 12360     struct addrinfo hints;
 12359     struct addrinfo *info = NULL, *infop;
 12361     struct addrinfo *info = NULL, *infop;
 12360 
 12362 
 12361     memset(&hints, 0, sizeof(hints));
 12363     memset(&hints, 0, sizeof(hints));
 12362     if (__isSmallInteger(domain))
 12364     if (__isSmallInteger(domain))
 12363         hints.ai_family = __intVal(domain);
 12365 	hints.ai_family = __intVal(domain);
 12364     if (__isSmallInteger(type))
 12366     if (__isSmallInteger(type))
 12365         hints.ai_socktype = __intVal(type);
 12367 	hints.ai_socktype = __intVal(type);
 12366     if (__isSmallInteger(proto))
 12368     if (__isSmallInteger(proto))
 12367         hints.ai_protocol = __intVal(proto);
 12369 	hints.ai_protocol = __intVal(proto);
 12368 
 12370 
 12369     do {
 12371     do {
 12370         /* must refetch in loop */
 12372 	/* must refetch in loop */
 12371         if (hostName == nil) {
 12373 	if (hostName == nil) {
 12372             __hostName = 0;
 12374 	    __hostName = 0;
 12373         } else if (__isString(hostName) || __isSymbol(hostName)) {
 12375 	} else if (__isString(hostName) || __isSymbol(hostName)) {
 12374             __hostName = __stringVal(hostName);
 12376 	    __hostName = __stringVal(hostName);
 12375         }
 12377 	}
 12376         if (serviceName == nil) {
 12378 	if (serviceName == nil) {
 12377             __serviceName = 0;
 12379 	    __serviceName = 0;
 12378         } else if (__isString(serviceName) || __isSymbol(serviceName)) {
 12380 	} else if (__isString(serviceName) || __isSymbol(serviceName)) {
 12379             __serviceName = __stringVal(serviceName);
 12381 	    __serviceName = __stringVal(serviceName);
 12380         }
 12382 	}
 12381 
 12383 
 12382 # ifdef DO_WRAP_CALLS
 12384 # ifdef DO_WRAP_CALLS
 12383         do {
 12385 	do {
 12384             __threadErrno = 0;
 12386 	    __threadErrno = 0;
 12385             res = STX_WSA_CALL4( "getaddrinfo", getaddrinfo, __hostName, __serviceName, &hints, &info);
 12387 	    res = STX_WSA_CALL4( "getaddrinfo", getaddrinfo, __hostName, __serviceName, &hints, &info);
 12386         } while ((res < 0) && (__threadErrno == EINTR));
 12388 	} while ((res < 0) && (__threadErrno == EINTR));
 12387 # else
 12389 # else
 12388         __BEGIN_INTERRUPTABLE__
 12390 	__BEGIN_INTERRUPTABLE__
 12389         ret = getaddrinfo(__hostName, __serviceName, &hints, &info);
 12391 	ret = getaddrinfo(__hostName, __serviceName, &hints, &info);
 12390         __END_INTERRUPTABLE__
 12392 	__END_INTERRUPTABLE__
 12391 # endif
 12393 # endif
 12392     } while (ret == EAI_SYSTEM && errno == EINTR);
 12394     } while (ret == EAI_SYSTEM && errno == EINTR);
 12393     if (ret != 0) {
 12395     if (ret != 0) {
 12394         switch (ret) {
 12396 	switch (ret) {
 12395         case EAI_FAMILY:
 12397 	case EAI_FAMILY:
 12396             error = @symbol(badProtocol);
 12398 	    error = @symbol(badProtocol);
 12397             break;
 12399 	    break;
 12398         case EAI_SOCKTYPE:
 12400 	case EAI_SOCKTYPE:
 12399             error = @symbol(badSocketType);
 12401 	    error = @symbol(badSocketType);
 12400             break;
 12402 	    break;
 12401         case EAI_BADFLAGS:
 12403 	case EAI_BADFLAGS:
 12402             error = @symbol(badFlags);
 12404 	    error = @symbol(badFlags);
 12403             break;
 12405 	    break;
 12404         case EAI_NONAME:
 12406 	case EAI_NONAME:
 12405             error = @symbol(unknownHost);
 12407 	    error = @symbol(unknownHost);
 12406             break;
 12408 	    break;
 12407         case EAI_SERVICE:
 12409 	case EAI_SERVICE:
 12408             error = @symbol(unknownService);
 12410 	    error = @symbol(unknownService);
 12409             break;
 12411 	    break;
 12410         case EAI_ADDRFAMILY :
 12412 	case EAI_ADDRFAMILY :
 12411             error = @symbol(unknownHostForProtocol);
 12413 	    error = @symbol(unknownHostForProtocol);
 12412             break;
 12414 	    break;
 12413         case EAI_NODATA:
 12415 	case EAI_NODATA:
 12414             error = @symbol(noAddress);
 12416 	    error = @symbol(noAddress);
 12415             break;
 12417 	    break;
 12416         case EAI_MEMORY:
 12418 	case EAI_MEMORY:
 12417             error = @symbol(allocationFailure);
 12419 	    error = @symbol(allocationFailure);
 12418             break;
 12420 	    break;
 12419         case EAI_FAIL:
 12421 	case EAI_FAIL:
 12420             error = @symbol(permanentFailure);
 12422 	    error = @symbol(permanentFailure);
 12421             break;
 12423 	    break;
 12422         case EAI_AGAIN:
 12424 	case EAI_AGAIN:
 12423             error = @symbol(tryAgain);
 12425 	    error = @symbol(tryAgain);
 12424             break;
 12426 	    break;
 12425         case EAI_SYSTEM:
 12427 	case EAI_SYSTEM:
 12426             error = @symbol(systemError);
 12428 	    error = @symbol(systemError);
 12427             break;
 12429 	    break;
 12428         default:
 12430 	default:
 12429             error = @symbol(unknownError);
 12431 	    error = @symbol(unknownError);
 12430         }
 12432 	}
 12431         errorString = __MKSTRING(gai_strerror(ret));
 12433 	errorString = __MKSTRING(gai_strerror(ret));
 12432         goto err;
 12434 	goto err;
 12433     }
 12435     }
 12434     for (cnt=0, infop=info; infop; infop=infop->ai_next)
 12436     for (cnt=0, infop=info; infop; infop=infop->ai_next)
 12435         cnt++;
 12437 	cnt++;
 12436 
 12438 
 12437     result = __ARRAY_NEW_INT(cnt);
 12439     result = __ARRAY_NEW_INT(cnt);
 12438     if (result == nil) {
 12440     if (result == nil) {
 12439         error = @symbol(allocationFailure);
 12441 	error = @symbol(allocationFailure);
 12440         goto err;
 12442 	goto err;
 12441     }
 12443     }
 12442     for (infop=info, cnt=0; infop; infop=infop->ai_next, cnt++) {
 12444     for (infop=info, cnt=0; infop; infop=infop->ai_next, cnt++) {
 12443         OBJ o, resp;
 12445 	OBJ o, resp;
 12444 
 12446 
 12445         resp = __ARRAY_NEW_INT(6);
 12447 	resp = __ARRAY_NEW_INT(6);
 12446         if (resp == nil) {
 12448 	if (resp == nil) {
 12447             error = @symbol(allocationFailure);
 12449 	    error = @symbol(allocationFailure);
 12448             goto err;
 12450 	    goto err;
 12449         }
 12451 	}
 12450 
 12452 
 12451         __ArrayInstPtr(result)->a_element[cnt] = resp; __STORE(result, resp);
 12453 	__ArrayInstPtr(result)->a_element[cnt] = resp; __STORE(result, resp);
 12452 
 12454 
 12453         __ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(infop->ai_flags);
 12455 	__ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(infop->ai_flags);
 12454         __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(infop->ai_family);
 12456 	__ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(infop->ai_family);
 12455         __ArrayInstPtr(resp)->a_element[2] = __mkSmallInteger(infop->ai_socktype);
 12457 	__ArrayInstPtr(resp)->a_element[2] = __mkSmallInteger(infop->ai_socktype);
 12456         __ArrayInstPtr(resp)->a_element[3] = __mkSmallInteger(infop->ai_protocol);
 12458 	__ArrayInstPtr(resp)->a_element[3] = __mkSmallInteger(infop->ai_protocol);
 12457 
 12459 
 12458         __PROTECT__(resp);
 12460 	__PROTECT__(resp);
 12459         o = __BYTEARRAY_NEW_INT(infop->ai_addrlen);
 12461 	o = __BYTEARRAY_NEW_INT(infop->ai_addrlen);
 12460         __UNPROTECT__(resp);
 12462 	__UNPROTECT__(resp);
 12461         if (o == nil) {
 12463 	if (o == nil) {
 12462             error = @symbol(allocationFailure);
 12464 	    error = @symbol(allocationFailure);
 12463             goto err;
 12465 	    goto err;
 12464         }
 12466 	}
 12465         memcpy(__byteArrayVal(o), infop->ai_addr, infop->ai_addrlen);
 12467 	memcpy(__byteArrayVal(o), infop->ai_addr, infop->ai_addrlen);
 12466        __ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
 12468        __ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
 12467 
 12469 
 12468         if (infop->ai_canonname) {
 12470 	if (infop->ai_canonname) {
 12469             __PROTECT__(resp);
 12471 	    __PROTECT__(resp);
 12470             o = __MKSTRING(infop->ai_canonname);
 12472 	    o = __MKSTRING(infop->ai_canonname);
 12471             __UNPROTECT__(resp);
 12473 	    __UNPROTECT__(resp);
 12472             if (o == nil) {
 12474 	    if (o == nil) {
 12473                 error = @symbol(allocationFailure);
 12475 		error = @symbol(allocationFailure);
 12474                 goto err;
 12476 		goto err;
 12475             }
 12477 	    }
 12476             __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
 12478 	    __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
 12477         }
 12479 	}
 12478     }
 12480     }
 12479 
 12481 
 12480 err:
 12482 err:
 12481     if (info) freeaddrinfo(info);
 12483     if (info) freeaddrinfo(info);
 12482 
 12484 
 12489     char **addrpp;
 12491     char **addrpp;
 12490     int port = 0;
 12492     int port = 0;
 12491     int i;
 12493     int i;
 12492 
 12494 
 12493     if (__serviceName) {
 12495     if (__serviceName) {
 12494         struct servent *sp;
 12496 	struct servent *sp;
 12495         char *__proto = 0;
 12497 	char *__proto = 0;
 12496 
 12498 
 12497         if (__isString(protoArg) || __isSymbol(protoArg))
 12499 	if (__isString(protoArg) || __isSymbol(protoArg))
 12498             __proto = __stringVal(protoArg);
 12500 	    __proto = __stringVal(protoArg);
 12499 
 12501 
 12500         sp = getservbyname(__serviceName, __proto);
 12502 	sp = getservbyname(__serviceName, __proto);
 12501         if (sp == NULL) {
 12503 	if (sp == NULL) {
 12502             errorString = @symbol(unknownService);
 12504 	    errorString = @symbol(unknownService);
 12503             error = __mkSmallInteger(-3);
 12505 	    error = __mkSmallInteger(-3);
 12504             goto err;
 12506 	    goto err;
 12505         }
 12507 	}
 12506         port = sp->s_port;
 12508 	port = sp->s_port;
 12507     }
 12509     }
 12508 
 12510 
 12509     if (__hostName) {
 12511     if (__hostName) {
 12510 #  ifdef USE_H_ERRNO
 12512 #  ifdef USE_H_ERRNO
 12511         do {
 12513 	do {
 12512             /* must refetch in loop */
 12514 	    /* must refetch in loop */
 12513             if (hostName == nil) {
 12515 	    if (hostName == nil) {
 12514                 __hostName = 0;
 12516 		__hostName = 0;
 12515             } else if (__isString(hostName) || __isSymbol(hostName)) {
 12517 	    } else if (__isString(hostName) || __isSymbol(hostName)) {
 12516                 __hostName = __stringVal(hostName);
 12518 		__hostName = __stringVal(hostName);
 12517             }
 12519 	    }
 12518 # ifdef DO_WRAP_CALLS
 12520 # ifdef DO_WRAP_CALLS
 12519             hp = STX_WSA_CALL1("gethostbyname", gethostbyname, __hostName);
 12521 	    hp = STX_WSA_CALL1("gethostbyname", gethostbyname, __hostName);
 12520             if ((INT)hp < 0) hp = NULL;
 12522 	    if ((INT)hp < 0) hp = NULL;
 12521 # else
 12523 # else
 12522             /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname
 12524 	    /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname
 12523              * uses a static data area
 12525 	     * uses a static data area
 12524              */
 12526 	     */
 12525             __BEGIN_INTERRUPTABLE__
 12527 	    __BEGIN_INTERRUPTABLE__
 12526             hp = gethostbyname(__hostName);
 12528 	    hp = gethostbyname(__hostName);
 12527             __END_INTERRUPTABLE__
 12529 	    __END_INTERRUPTABLE__
 12528 #endif
 12530 #endif
 12529         } while ((hp == NULL)
 12531 	} while ((hp == NULL)
 12530                   && (
 12532 		  && (
 12531                         (h_errno == TRY_AGAIN)
 12533 			(h_errno == TRY_AGAIN)
 12532                       || errno == EINTR
 12534 		      || errno == EINTR
 12533 #   ifdef IRIX5_3
 12535 #   ifdef IRIX5_3
 12534                       || (errno == ECONNREFUSED)
 12536 		      || (errno == ECONNREFUSED)
 12535 #   endif
 12537 #   endif
 12536                      )
 12538 		     )
 12537         );
 12539 	);
 12538         if (hp == 0) {
 12540 	if (hp == 0) {
 12539             switch (h_errno) {
 12541 	    switch (h_errno) {
 12540             case HOST_NOT_FOUND:
 12542 	    case HOST_NOT_FOUND:
 12541                 errorString = @symbol(unknownHost);
 12543 		errorString = @symbol(unknownHost);
 12542                 break;
 12544 		break;
 12543             case NO_ADDRESS:
 12545 	    case NO_ADDRESS:
 12544                 errorString = @symbol(noAddress);
 12546 		errorString = @symbol(noAddress);
 12545                 break;
 12547 		break;
 12546             case NO_RECOVERY:
 12548 	    case NO_RECOVERY:
 12547                 errorString = @symbol(permanentFailure);
 12549 		errorString = @symbol(permanentFailure);
 12548                 break;
 12550 		break;
 12549             case TRY_AGAIN:
 12551 	    case TRY_AGAIN:
 12550                 errorString = @symbol(tryAgain);
 12552 		errorString = @symbol(tryAgain);
 12551                 break;
 12553 		break;
 12552             default:
 12554 	    default:
 12553                 errorString = @symbol(unknownError);
 12555 		errorString = @symbol(unknownError);
 12554                 break;
 12556 		break;
 12555             }
 12557 	    }
 12556             error = __mkSmallInteger(h_errno);
 12558 	    error = __mkSmallInteger(h_errno);
 12557             goto err;
 12559 	    goto err;
 12558         }
 12560 	}
 12559 #  else /* !USE_H_ERRNO */
 12561 #  else /* !USE_H_ERRNO */
 12560         hp = gethostbyname(__hostName);
 12562 	hp = gethostbyname(__hostName);
 12561         if (hp == 0) {
 12563 	if (hp == 0) {
 12562             errorString = @symbol(unknownHost);
 12564 	    errorString = @symbol(unknownHost);
 12563             error = __mkSmallInteger(-1);
 12565 	    error = __mkSmallInteger(-1);
 12564             goto err;
 12566 	    goto err;
 12565         }
 12567 	}
 12566 #  endif /* !USE_H_ERRNO*/
 12568 #  endif /* !USE_H_ERRNO*/
 12567 
 12569 
 12568         if (__isSmallInteger(domain) && hp->h_addrtype != __smallIntegerVal(domain)) {
 12570 	if (__isSmallInteger(domain) && hp->h_addrtype != __smallIntegerVal(domain)) {
 12569             errorString = @symbol(unknownHost);
 12571 	    errorString = @symbol(unknownHost);
 12570             error = __mkSmallInteger(-2);
 12572 	    error = __mkSmallInteger(-2);
 12571             goto err;
 12573 	    goto err;
 12572         }
 12574 	}
 12573 
 12575 
 12574         for (cnt = 0, addrpp = hp->h_addr_list; *addrpp; addrpp++)
 12576 	for (cnt = 0, addrpp = hp->h_addr_list; *addrpp; addrpp++)
 12575             cnt++;
 12577 	    cnt++;
 12576         addrpp = hp->h_addr_list;
 12578 	addrpp = hp->h_addr_list;
 12577     } else {
 12579     } else {
 12578         cnt = 1;
 12580 	cnt = 1;
 12579     }
 12581     }
 12580 
 12582 
 12581     result = __ARRAY_NEW_INT(cnt);
 12583     result = __ARRAY_NEW_INT(cnt);
 12582     if (result == nil) {
 12584     if (result == nil) {
 12583         error = @symbol(allocationFailure);
 12585 	error = @symbol(allocationFailure);
 12584         goto err;
 12586 	goto err;
 12585     }
 12587     }
 12586 
 12588 
 12587     for (i = 0; i < cnt; i++) {
 12589     for (i = 0; i < cnt; i++) {
 12588         OBJ o, resp;
 12590 	OBJ o, resp;
 12589         struct sockaddr_in *sa;
 12591 	struct sockaddr_in *sa;
 12590 
 12592 
 12591         resp = __ARRAY_NEW_INT(6);
 12593 	resp = __ARRAY_NEW_INT(6);
 12592         if (resp == nil) {
 12594 	if (resp == nil) {
 12593             error = @symbol(allocationFailure);
 12595 	    error = @symbol(allocationFailure);
 12594             goto err;
 12596 	    goto err;
 12595         }
 12597 	}
 12596 
 12598 
 12597         __ArrayInstPtr(result)->a_element[i] = resp; __STORE(result, resp);
 12599 	__ArrayInstPtr(result)->a_element[i] = resp; __STORE(result, resp);
 12598         __ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(0);
 12600 	__ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(0);
 12599         __ArrayInstPtr(resp)->a_element[2] = type; __STORE(result, type);
 12601 	__ArrayInstPtr(resp)->a_element[2] = type; __STORE(result, type);
 12600         __ArrayInstPtr(resp)->a_element[3] = proto; __STORE(result, proto);
 12602 	__ArrayInstPtr(resp)->a_element[3] = proto; __STORE(result, proto);
 12601         __PROTECT__(resp);
 12603 	__PROTECT__(resp);
 12602         o = __BYTEARRAY_NEW_INT(sizeof(*sa));
 12604 	o = __BYTEARRAY_NEW_INT(sizeof(*sa));
 12603         __UNPROTECT__(resp);
 12605 	__UNPROTECT__(resp);
 12604         if (o == nil) {
 12606 	if (o == nil) {
 12605             error = @symbol(allocationFailure);
 12607 	    error = @symbol(allocationFailure);
 12606             goto err;
 12608 	    goto err;
 12607         }
 12609 	}
 12608         __ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
 12610 	__ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
 12609         sa = (struct sockaddr_in *)__byteArrayVal(o);
 12611 	sa = (struct sockaddr_in *)__byteArrayVal(o);
 12610         sa->sin_port = port;
 12612 	sa->sin_port = port;
 12611 
 12613 
 12612         if (__hostName) {
 12614 	if (__hostName) {
 12613             sa->sin_family = hp->h_addrtype;
 12615 	    sa->sin_family = hp->h_addrtype;
 12614             memcpy(&sa->sin_addr, *addrpp, hp->h_length);
 12616 	    memcpy(&sa->sin_addr, *addrpp, hp->h_length);
 12615             __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(hp->h_addrtype);
 12617 	    __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(hp->h_addrtype);
 12616             if (hp->h_name) {
 12618 	    if (hp->h_name) {
 12617                 __PROTECT__(resp);
 12619 		__PROTECT__(resp);
 12618                 o = __MKSTRING(hp->h_name);
 12620 		o = __MKSTRING(hp->h_name);
 12619                 __UNPROTECT__(resp);
 12621 		__UNPROTECT__(resp);
 12620                 if (o == nil) {
 12622 		if (o == nil) {
 12621                     error = @symbol(allocationFailure);
 12623 		    error = @symbol(allocationFailure);
 12622                     goto err;
 12624 		    goto err;
 12623                 }
 12625 		}
 12624                 __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
 12626 		__ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
 12625             }
 12627 	    }
 12626             addrpp++;
 12628 	    addrpp++;
 12627         } else{
 12629 	} else{
 12628             __ArrayInstPtr(resp)->a_element[1] = domain; __STORE(resp, domain);
 12630 	    __ArrayInstPtr(resp)->a_element[1] = domain; __STORE(resp, domain);
 12629         }
 12631 	}
 12630     }
 12632     }
 12631 
 12633 
 12632 err:;
 12634 err:;
 12633 # endif /* ! AI_NUMERICHOST */
 12635 # endif /* ! AI_NUMERICHOST */
 12634 }
 12636 }
 12635 #else /* ! HAS_SOCKET */
 12637 #else /* ! HAS_SOCKET */
 12636     error = @symbol(notImplemented);
 12638     error = @symbol(notImplemented);
 12637 #endif
 12639 #endif
 12638 %}.
 12640 %}.
 12639     error notNil ifTrue:[
 12641     error notNil ifTrue:[
 12640         |request|
 12642 	|request|
 12641         request := SocketAddressInfo new
 12643 	request := SocketAddressInfo new
 12642             domain:domainArg;
 12644 	    domain:domainArg;
 12643             type:typeArg;
 12645 	    type:typeArg;
 12644             protocol:protoArg;
 12646 	    protocol:protoArg;
 12645             canonicalName:hostName;
 12647 	    canonicalName:hostName;
 12646             serviceName:serviceName.
 12648 	    serviceName:serviceName.
 12647         ^ (HostNameLookupError new
 12649 	^ (HostNameLookupError new
 12648                 parameter:error;
 12650 		parameter:error;
 12649                 messageText:' - ', errorString;
 12651 		messageText:' - ', errorString;
 12650                 request:request) raiseRequest.
 12652 		request:request) raiseRequest.
 12651     ].
 12653     ].
 12652     1 to:result size do:[:i |
 12654     1 to:result size do:[:i |
 12653         |entry dom info|
 12655 	|entry dom info|
 12654 
 12656 
 12655         info := SocketAddressInfo new.
 12657 	info := SocketAddressInfo new.
 12656         entry := result at:i.
 12658 	entry := result at:i.
 12657         info flags:(entry at:1).
 12659 	info flags:(entry at:1).
 12658         info domain:(dom := OperatingSystem domainSymbolOf:(entry at:2)).
 12660 	info domain:(dom := OperatingSystem domainSymbolOf:(entry at:2)).
 12659         info type:(OperatingSystem socketTypeSymbolOf:(entry at:3)).
 12661 	info type:(OperatingSystem socketTypeSymbolOf:(entry at:3)).
 12660         info protocol:(self protocolSymbolOf:(entry at:4)).
 12662 	info protocol:(self protocolSymbolOf:(entry at:4)).
 12661         info socketAddress:((SocketAddress newDomain:dom) fromBytes:(entry at:5)).
 12663 	info socketAddress:((SocketAddress newDomain:dom) fromBytes:(entry at:5)).
 12662         info canonicalName:(entry at:6).
 12664 	info canonicalName:(entry at:6).
 12663         result at:i put:info
 12665 	result at:i put:info
 12664     ].
 12666     ].
 12665     ^ result
 12667     ^ result
 12666 
 12668 
 12667     "
 12669     "
 12668      self getAddressInfo:'localhost' serviceName:nil
 12670      self getAddressInfo:'localhost' serviceName:nil
 12669             domain:nil type:nil protocol:nil flags:nil
 12671 	    domain:nil type:nil protocol:nil flags:nil
 12670      self getAddressInfo:'localhost' serviceName:nil
 12672      self getAddressInfo:'localhost' serviceName:nil
 12671             domain:#inet type:#stream protocol:nil flags:nil
 12673 	    domain:#inet type:#stream protocol:nil flags:nil
 12672      self getAddressInfo:'localhost' serviceName:nil
 12674      self getAddressInfo:'localhost' serviceName:nil
 12673             domain:#inet type:#stream protocol:#tcp flags:nil
 12675 	    domain:#inet type:#stream protocol:#tcp flags:nil
 12674      self getAddressInfo:'blurb.exept.de' serviceName:nil
 12676      self getAddressInfo:'blurb.exept.de' serviceName:nil
 12675             domain:#inet type:nil protocol:nil flags:nil
 12677 	    domain:#inet type:nil protocol:nil flags:nil
 12676      self getAddressInfo:'1.2.3.4' serviceName:'bla'
 12678      self getAddressInfo:'1.2.3.4' serviceName:'bla'
 12677             domain:#inet type:nil protocol:nil flags:nil
 12679 	    domain:#inet type:nil protocol:nil flags:nil
 12678      self getAddressInfo:'localhost' serviceName:'echo'
 12680      self getAddressInfo:'localhost' serviceName:'echo'
 12679             domain:#inet type:nil protocol:nil flags:nil
 12681 	    domain:#inet type:nil protocol:nil flags:nil
 12680      self getAddressInfo:nil serviceName:'echo'
 12682      self getAddressInfo:nil serviceName:'echo'
 12681             domain:#inet type:nil protocol:nil flags:nil
 12683 	    domain:#inet type:nil protocol:nil flags:nil
 12682      self getAddressInfo:nil serviceName:nil
 12684      self getAddressInfo:nil serviceName:nil
 12683             domain:#inet type:nil protocol:nil flags:nil
 12685 	    domain:#inet type:nil protocol:nil flags:nil
 12684      self getAddressInfo:'www.google.de' serviceName:nil
 12686      self getAddressInfo:'www.google.de' serviceName:nil
 12685             domain:nil type:nil protocol:nil flags:nil
 12687 	    domain:nil type:nil protocol:nil flags:nil
 12686      self getAddressInfo:'smc1' serviceName:nil
 12688      self getAddressInfo:'smc1' serviceName:nil
 12687             domain:nil type:nil protocol:nil flags:nil
 12689 	    domain:nil type:nil protocol:nil flags:nil
 12688     "
 12690     "
 12689 !
 12691 !
 12690 
 12692 
 12691 getNameInfo:socketAddress wantHostName:wantHostName wantServiceName:wantServiceName datagram:useDatagram flags:flags
 12693 getNameInfo:socketAddress wantHostName:wantHostName wantServiceName:wantServiceName datagram:useDatagram flags:flags
 12692     "answer an Array containing the hostName and serviceName
 12694     "answer an Array containing the hostName and serviceName
 12712     int ret, __flags;
 12714     int ret, __flags;
 12713     char *bp;
 12715     char *bp;
 12714     int nInstBytes, sockAddrSize;
 12716     int nInstBytes, sockAddrSize;
 12715 
 12717 
 12716     if (wantHostName == true) {
 12718     if (wantHostName == true) {
 12717         hp = host;
 12719 	hp = host;
 12718         hsz = sizeof(host);
 12720 	hsz = sizeof(host);
 12719     }
 12721     }
 12720     if (wantServiceName == true) {
 12722     if (wantServiceName == true) {
 12721         sp = service;
 12723 	sp = service;
 12722         ssz = sizeof(service);
 12724 	ssz = sizeof(service);
 12723     }
 12725     }
 12724     if (hp == 0 && sp == 0) {
 12726     if (hp == 0 && sp == 0) {
 12725         error = @symbol(badArgument);
 12727 	error = @symbol(badArgument);
 12726         goto err;
 12728 	goto err;
 12727     }
 12729     }
 12728     if (!__isBytes(socketAddress)) {
 12730     if (!__isBytes(socketAddress)) {
 12729         error = @symbol(badArgument1);
 12731 	error = @symbol(badArgument1);
 12730         goto err;
 12732 	goto err;
 12731     }
 12733     }
 12732 
 12734 
 12733     nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_ninstvars));
 12735     nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_ninstvars));
 12734     sockAddrSize = __byteArraySize(socketAddress);
 12736     sockAddrSize = __byteArraySize(socketAddress);
 12735     sockAddrSize -= nInstBytes;
 12737     sockAddrSize -= nInstBytes;
 12736 
 12738 
 12737     if (!__isSmallInteger(flags)) {
 12739     if (!__isSmallInteger(flags)) {
 12738         error = @symbol(badArgument5);
 12740 	error = @symbol(badArgument5);
 12739         goto err;
 12741 	goto err;
 12740     }
 12742     }
 12741     __flags = __intVal(flags);
 12743     __flags = __intVal(flags);
 12742 
 12744 
 12743 #if defined(NI_NUMERICHOST)
 12745 #if defined(NI_NUMERICHOST)
 12744     if (useDatagram == true) {
 12746     if (useDatagram == true) {
 12745         __flags |= NI_DGRAM;
 12747 	__flags |= NI_DGRAM;
 12746     }
 12748     }
 12747 
 12749 
 12748     {
 12750     {
 12749         bp = (char *)(__byteArrayVal(socketAddress));
 12751 	bp = (char *)(__byteArrayVal(socketAddress));
 12750         bp += nInstBytes;
 12752 	bp += nInstBytes;
 12751         __BEGIN_INTERRUPTABLE__
 12753 	__BEGIN_INTERRUPTABLE__
 12752         ret = getnameinfo((struct sockaddr *)bp, sockAddrSize,
 12754 	ret = getnameinfo((struct sockaddr *)bp, sockAddrSize,
 12753                           hp, hsz, sp, ssz, __flags);
 12755 			  hp, hsz, sp, ssz, __flags);
 12754         __END_INTERRUPTABLE__
 12756 	__END_INTERRUPTABLE__
 12755     } while (ret == EAI_SYSTEM && errno == EINTR);
 12757     } while (ret == EAI_SYSTEM && errno == EINTR);
 12756     if (ret != 0) {
 12758     if (ret != 0) {
 12757         switch (ret) {
 12759 	switch (ret) {
 12758         case EAI_FAMILY:
 12760 	case EAI_FAMILY:
 12759             error = @symbol(badProtocol);
 12761 	    error = @symbol(badProtocol);
 12760             break;
 12762 	    break;
 12761         case EAI_SOCKTYPE:
 12763 	case EAI_SOCKTYPE:
 12762             error = @symbol(badSocketType);
 12764 	    error = @symbol(badSocketType);
 12763             break;
 12765 	    break;
 12764         case EAI_BADFLAGS:
 12766 	case EAI_BADFLAGS:
 12765             error = @symbol(badFlags);
 12767 	    error = @symbol(badFlags);
 12766             break;
 12768 	    break;
 12767         case EAI_NONAME:
 12769 	case EAI_NONAME:
 12768             error = @symbol(unknownHost);
 12770 	    error = @symbol(unknownHost);
 12769             break;
 12771 	    break;
 12770         case EAI_SERVICE:
 12772 	case EAI_SERVICE:
 12771             error = @symbol(unknownService);
 12773 	    error = @symbol(unknownService);
 12772             break;
 12774 	    break;
 12773         case EAI_ADDRFAMILY :
 12775 	case EAI_ADDRFAMILY :
 12774             error = @symbol(unknownHostForProtocol);
 12776 	    error = @symbol(unknownHostForProtocol);
 12775             break;
 12777 	    break;
 12776         case EAI_NODATA:
 12778 	case EAI_NODATA:
 12777             error = @symbol(noAddress);
 12779 	    error = @symbol(noAddress);
 12778             break;
 12780 	    break;
 12779         case EAI_MEMORY:
 12781 	case EAI_MEMORY:
 12780             error = @symbol(allocationFailure);
 12782 	    error = @symbol(allocationFailure);
 12781             break;
 12783 	    break;
 12782         case EAI_FAIL:
 12784 	case EAI_FAIL:
 12783             error = @symbol(permanentFailure);
 12785 	    error = @symbol(permanentFailure);
 12784             break;
 12786 	    break;
 12785         case EAI_AGAIN:
 12787 	case EAI_AGAIN:
 12786             error = @symbol(tryAgain);
 12788 	    error = @symbol(tryAgain);
 12787             break;
 12789 	    break;
 12788         case EAI_SYSTEM:
 12790 	case EAI_SYSTEM:
 12789             error = @symbol(systemError);
 12791 	    error = @symbol(systemError);
 12790             break;
 12792 	    break;
 12791         default:
 12793 	default:
 12792             error = @symbol(unknownError);
 12794 	    error = @symbol(unknownError);
 12793         }
 12795 	}
 12794         errorString = __MKSTRING(gai_strerror(ret));
 12796 	errorString = __MKSTRING(gai_strerror(ret));
 12795         goto err;
 12797 	goto err;
 12796     }
 12798     }
 12797 # else /* ! NI_NUMERICHOST */
 12799 # else /* ! NI_NUMERICHOST */
 12798     {
 12800     {
 12799         /*
 12801 	/*
 12800          * Do it using gethostbyaddr()
 12802 	 * Do it using gethostbyaddr()
 12801          */
 12803 	 */
 12802         struct sockaddr_in *sa;
 12804 	struct sockaddr_in *sa;
 12803 
 12805 
 12804         if (sockAddrSize < sizeof(*sa)) {
 12806 	if (sockAddrSize < sizeof(*sa)) {
 12805             error = @symbol(badArgument1);
 12807 	    error = @symbol(badArgument1);
 12806             goto err;
 12808 	    goto err;
 12807         }
 12809 	}
 12808         bp = (char *)(__byteArrayVal(socketAddress));
 12810 	bp = (char *)(__byteArrayVal(socketAddress));
 12809         bp += nInstBytes;
 12811 	bp += nInstBytes;
 12810         sa = (struct sockaddr_in *)bp;
 12812 	sa = (struct sockaddr_in *)bp;
 12811 
 12813 
 12812         if (sp) {
 12814 	if (sp) {
 12813             struct servent *servp;
 12815 	    struct servent *servp;
 12814             char *__proto = 0;
 12816 	    char *__proto = 0;
 12815 
 12817 
 12816             __proto = (useDatagram == true ? "udp" : "tcp");
 12818 	    __proto = (useDatagram == true ? "udp" : "tcp");
 12817 
 12819 
 12818             servp = getservbyport(sa->sin_port, __proto);
 12820 	    servp = getservbyport(sa->sin_port, __proto);
 12819             if (servp) {
 12821 	    if (servp) {
 12820                 sp = servp->s_name;
 12822 		sp = servp->s_name;
 12821             }
 12823 	    }
 12822         }
 12824 	}
 12823         if (hp) {
 12825 	if (hp) {
 12824             struct hostent *hostp;
 12826 	    struct hostent *hostp;
 12825 #  ifdef USE_H_ERRNO
 12827 #  ifdef USE_H_ERRNO
 12826             do {
 12828 	    do {
 12827                 /* must refetch in loop */
 12829 		/* must refetch in loop */
 12828                 bp = (char *)(__byteArrayVal(socketAddress));
 12830 		bp = (char *)(__byteArrayVal(socketAddress));
 12829                 bp += nInstBytes;
 12831 		bp += nInstBytes;
 12830                 sa = (struct sockaddr_in *)bp;
 12832 		sa = (struct sockaddr_in *)bp;
 12831                 /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname uses a static data area
 12833 		/* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname uses a static data area
 12832                  */
 12834 		 */
 12833                 hostp = gethostbyaddr((char *)&sa->sin_addr, sockAddrSize, sa->sin_family);
 12835 		hostp = gethostbyaddr((char *)&sa->sin_addr, sockAddrSize, sa->sin_family);
 12834                 /* __END_INTERRUPTABLE__ */
 12836 		/* __END_INTERRUPTABLE__ */
 12835             } while ((hostp == NULL)
 12837 	    } while ((hostp == NULL)
 12836                       && ((h_errno == TRY_AGAIN)
 12838 		      && ((h_errno == TRY_AGAIN)
 12837                           || errno == EINTR
 12839 			  || errno == EINTR
 12838 #   ifdef IRIX5_3
 12840 #   ifdef IRIX5_3
 12839                           || (errno == ECONNREFUSED)
 12841 			  || (errno == ECONNREFUSED)
 12840 #   endif
 12842 #   endif
 12841                          )
 12843 			 )
 12842             );
 12844 	    );
 12843             if (hostp == 0) {
 12845 	    if (hostp == 0) {
 12844                 switch (h_errno) {
 12846 		switch (h_errno) {
 12845                 case HOST_NOT_FOUND:
 12847 		case HOST_NOT_FOUND:
 12846                     errorString = @symbol(unknownHost);
 12848 		    errorString = @symbol(unknownHost);
 12847                     break;
 12849 		    break;
 12848                 case NO_ADDRESS:
 12850 		case NO_ADDRESS:
 12849                     errorString = @symbol(noAddress);
 12851 		    errorString = @symbol(noAddress);
 12850                     break;
 12852 		    break;
 12851                 case NO_RECOVERY:
 12853 		case NO_RECOVERY:
 12852                     errorString = @symbol(permanentFailure);
 12854 		    errorString = @symbol(permanentFailure);
 12853                     break;
 12855 		    break;
 12854                 case TRY_AGAIN:
 12856 		case TRY_AGAIN:
 12855                     errorString = @symbol(tryAgain);
 12857 		    errorString = @symbol(tryAgain);
 12856                     break;
 12858 		    break;
 12857                 default:
 12859 		default:
 12858                     errorString = @symbol(unknownError);
 12860 		    errorString = @symbol(unknownError);
 12859                     break;
 12861 		    break;
 12860                 }
 12862 		}
 12861                 error = __mkSmallInteger(h_errno);
 12863 		error = __mkSmallInteger(h_errno);
 12862                 goto err;
 12864 		goto err;
 12863             }
 12865 	    }
 12864 #  else /* !USE_H_ERRNO */
 12866 #  else /* !USE_H_ERRNO */
 12865             hostp = gethostbyaddr((char *)&sa->sin_addr, sockAddrSize, sa->sin_family);
 12867 	    hostp = gethostbyaddr((char *)&sa->sin_addr, sockAddrSize, sa->sin_family);
 12866             if (hostp == 0) {
 12868 	    if (hostp == 0) {
 12867                 errorString = @symbol(unknownHost);
 12869 		errorString = @symbol(unknownHost);
 12868                 error = __mkSmallInteger(-1);
 12870 		error = __mkSmallInteger(-1);
 12869                 goto err;
 12871 		goto err;
 12870             }
 12872 	    }
 12871 #  endif /* !USE_H_ERRNO*/
 12873 #  endif /* !USE_H_ERRNO*/
 12872             hp = hostp->h_name;
 12874 	    hp = hostp->h_name;
 12873         }
 12875 	}
 12874     }
 12876     }
 12875 # endif /* ! NI_NUMERICHOST */
 12877 # endif /* ! NI_NUMERICHOST */
 12876 
 12878 
 12877     if (hp)
 12879     if (hp)
 12878         hostName = __MKSTRING(hp);
 12880 	hostName = __MKSTRING(hp);
 12879     if (sp)
 12881     if (sp)
 12880         serviceName = __MKSTRING(sp);
 12882 	serviceName = __MKSTRING(sp);
 12881 err:;
 12883 err:;
 12882 #else
 12884 #else
 12883     error = @symbol(notImplemented);
 12885     error = @symbol(notImplemented);
 12884 #endif
 12886 #endif
 12885 %}.
 12887 %}.
 12886     error notNil ifTrue:[
 12888     error notNil ifTrue:[
 12887         ^ (HostAddressLookupError new
 12889 	^ (HostAddressLookupError new
 12888                 parameter:error;
 12890 		parameter:error;
 12889                 messageText:' - ', errorString;
 12891 		messageText:' - ', errorString;
 12890                 request:thisContext message) raiseRequest.
 12892 		request:thisContext message) raiseRequest.
 12891     ].
 12893     ].
 12892 
 12894 
 12893     ^ Array with:hostName with:serviceName
 12895     ^ Array with:hostName with:serviceName
 12894 
 12896 
 12895     "
 12897     "
 12896      self getNameInfo:
 12898      self getNameInfo:
 12897         (self getAddressInfo:'localhost' serviceName:'echo'
 12899 	(self getAddressInfo:'localhost' serviceName:'echo'
 12898                 domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
 12900 		domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
 12899          wantHostName:true wantServiceName:true datagram:false flags:0
 12901 	 wantHostName:true wantServiceName:true datagram:false flags:0
 12900 
 12902 
 12901      self getNameInfo:
 12903      self getNameInfo:
 12902         (self getAddressInfo:'exept.exept.de' serviceName:'echo'
 12904 	(self getAddressInfo:'exept.exept.de' serviceName:'echo'
 12903                 domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
 12905 		domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
 12904          wantHostName:true wantServiceName:true datagram:false flags:0
 12906 	 wantHostName:true wantServiceName:true datagram:false flags:0
 12905 
 12907 
 12906      self getNameInfo:#[1 2 3 4]
 12908      self getNameInfo:#[1 2 3 4]
 12907          wantHostName:true wantServiceName:true datagram:false flags:0
 12909 	 wantHostName:true wantServiceName:true datagram:false flags:0
 12908     "
 12910     "
 12909 ! !
 12911 ! !
 12910 
 12912 
 12911 !Win32OperatingSystem::WinPointStructure class methodsFor:'instance creation'!
 12913 !Win32OperatingSystem::WinPointStructure class methodsFor:'instance creation'!
 12912 
 12914 
 12925 ! !
 12927 ! !
 12926 
 12928 
 12927 !Win32OperatingSystem::WinPointStructure methodsFor:'accessing'!
 12929 !Win32OperatingSystem::WinPointStructure methodsFor:'accessing'!
 12928 
 12930 
 12929 asPoint
 12931 asPoint
 12930         "Private - Answer the receiver as a Point."
 12932 	"Private - Answer the receiver as a Point."
 12931     ^self x @ self y
 12933     ^self x @ self y
 12932 
 12934 
 12933     "Created: / 03-08-2006 / 10:45:55 / fm"
 12935     "Created: / 03-08-2006 / 10:45:55 / fm"
 12934 !
 12936 !
 12935 
 12937 
 12936 x
 12938 x
 12937         "Private - Answer the x coordinate of the point."
 12939 	"Private - Answer the x coordinate of the point."
 12938     ^self longAt: 0 + 1
 12940     ^self longAt: 0 + 1
 12939 
 12941 
 12940     "Created: / 03-08-2006 / 10:46:11 / fm"
 12942     "Created: / 03-08-2006 / 10:46:11 / fm"
 12941 !
 12943 !
 12942 
 12944 
 12943 x: anInteger
 12945 x: anInteger
 12944         "Private - Set the x coordinate of the point."
 12946 	"Private - Set the x coordinate of the point."
 12945     self longAt: 0 + 1 put: anInteger
 12947     self longAt: 0 + 1 put: anInteger
 12946 
 12948 
 12947     "Created: / 03-08-2006 / 10:46:41 / fm"
 12949     "Created: / 03-08-2006 / 10:46:41 / fm"
 12948 !
 12950 !
 12949 
 12951 
 12950 y
 12952 y
 12951         "Private - Answer the y coordinate of the point."
 12953 	"Private - Answer the y coordinate of the point."
 12952     ^self longAt: 4 + 1
 12954     ^self longAt: 4 + 1
 12953 
 12955 
 12954     "Created: / 03-08-2006 / 10:46:26 / fm"
 12956     "Created: / 03-08-2006 / 10:46:26 / fm"
 12955 !
 12957 !
 12956 
 12958 
 12957 y: anInteger
 12959 y: anInteger
 12958         "Private - Set the y coordinate of the point."
 12960 	"Private - Set the y coordinate of the point."
 12959     self longAt: 4 + 1 put: anInteger
 12961     self longAt: 4 + 1 put: anInteger
 12960 
 12962 
 12961     "Created: / 03-08-2006 / 10:46:56 / fm"
 12963     "Created: / 03-08-2006 / 10:46:56 / fm"
 12962 ! !
 12964 ! !
 12963 
 12965 
 12964 !Win32OperatingSystem::WinPointStructure methodsFor:'printing'!
 12966 !Win32OperatingSystem::WinPointStructure methodsFor:'printing'!
 12965 
 12967 
 12966 printOn: aStream
 12968 printOn: aStream
 12967         "Append a textual representation of the receiver to aStream."
 12969 	"Append a textual representation of the receiver to aStream."
 12968     aStream nextPutAll: self class name, ' { ', self asPoint printString, ' } '
 12970     aStream nextPutAll: self class name, ' { ', self asPoint printString, ' } '
 12969 
 12971 
 12970     "Created: / 03-08-2006 / 10:45:40 / fm"
 12972     "Created: / 03-08-2006 / 10:45:40 / fm"
 12971 ! !
 12973 ! !
 12972 
 12974 
 12973 !Win32OperatingSystem class methodsFor:'documentation'!
 12975 !Win32OperatingSystem class methodsFor:'documentation'!
 12974 
 12976 
 12975 version
 12977 version
 12976     ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.282 2007-06-27 12:05:00 sr Exp $'
 12978     ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.283 2007-07-04 15:07:44 cg Exp $'
 12977 ! !
 12979 ! !
 12978 
 12980 
 12979 Win32OperatingSystem initialize!
 12981 Win32OperatingSystem initialize!
 12980 Win32OperatingSystem::RegistryEntry initialize!
 12982 Win32OperatingSystem::RegistryEntry initialize!