UnixOperatingSystem.st
changeset 8762 2fe7d8c44ccf
parent 8735 531252ebbbe3
child 8788 562f4f8bb3ed
--- a/UnixOperatingSystem.st	Tue Mar 01 14:54:13 2005 +0100
+++ b/UnixOperatingSystem.st	Tue Mar 01 16:19:34 2005 +0100
@@ -3392,13 +3392,13 @@
       && __isSmallInteger(outFd)
       && __isSmallInteger(startIdx)
       && __isSmallInteger(count)) {
-        int nWritten;
-
-        nWritten = sendfile(__intVal(outFd), __intVal(inFd), __intVal(startIdx), __intVal(count));
-        if (nWritten < 0) {
-            @global(LastErrorNumber) = __MKSMALLINT(errno);
-        }
-        RETURN (__MKSMALLINT(nWritten));
+	int nWritten;
+
+	nWritten = sendfile(__intVal(outFd), __intVal(inFd), __intVal(startIdx), __intVal(count));
+	if (nWritten < 0) {
+	    @global(LastErrorNumber) = __MKSMALLINT(errno);
+	}
+	RETURN (__MKSMALLINT(nWritten));
      }
 #endif
 %}.
@@ -4733,21 +4733,21 @@
 
      The info (for which corresponding access methods are understood by
      the returned object) is:
-         type            - a symbol giving the files type
-         mode            - numeric access mode
-         uid             - owners user id
-         gid             - owners group id
-         size            - files size
-         id              - files number (i.e. inode number)
-         accessed        - last access time (as Timestamp)
-         modified        - last modification time (as Timestamp)
-         statusChanged   - last status change time (as Timestamp)
-         alternativeName     - (windows only:) the MSDOS name of the file
-         recordFormatNumeric - (VMS only:) numeric value of the recordFormat
-         recordFormat        - (VMS only:) symbolic value of the recordFormat
-         recordAttributes    - (VMS only:) recordAttributes
-         fixedHeaderSize     - (VMS only:) fixed header size in a variable record format
-         recordSize          - (VMS only:) record size.
+	 type            - a symbol giving the files type
+	 mode            - numeric access mode
+	 uid             - owners user id
+	 gid             - owners group id
+	 size            - files size
+	 id              - files number (i.e. inode number)
+	 accessed        - last access time (as Timestamp)
+	 modified        - last modification time (as Timestamp)
+	 statusChanged   - last status change time (as Timestamp)
+	 alternativeName     - (windows only:) the MSDOS name of the file
+	 recordFormatNumeric - (VMS only:) numeric value of the recordFormat
+	 recordFormat        - (VMS only:) symbolic value of the recordFormat
+	 recordAttributes    - (VMS only:) recordAttributes
+	 fixedHeaderSize     - (VMS only:) fixed header size in a variable record format
+	 recordSize          - (VMS only:) record size.
 
      Some of the fields may be returned as nil on systems which do not provide
      all of the information.
@@ -4768,105 +4768,105 @@
     char pathBuffer[1024];
 
     if (__isStringLike(aPathName)) {
-        __BEGIN_INTERRUPTABLE__
-        do {
-            ret = lstat((char *) __stringVal(aPathName), &buf);
-        } while ((ret < 0) && (errno == EINTR));
-        __END_INTERRUPTABLE__
-
-        if (ret < 0) {
-            @global(LastErrorNumber) = __MKSMALLINT(errno);
-            RETURN ( nil );
-        }
-        switch (buf.st_mode & S_IFMT) {
+	__BEGIN_INTERRUPTABLE__
+	do {
+	    ret = lstat((char *) __stringVal(aPathName), &buf);
+	} while ((ret < 0) && (errno == EINTR));
+	__END_INTERRUPTABLE__
+
+	if (ret < 0) {
+	    @global(LastErrorNumber) = __MKSMALLINT(errno);
+	    RETURN ( nil );
+	}
+	switch (buf.st_mode & S_IFMT) {
     # ifdef S_IFLNK
-            case S_IFLNK:
-                type = @symbol(symbolicLink);
-                if ((ret = readlink((char *) __stringVal(aPathName), pathBuffer, sizeof(pathBuffer))) < 0) {
-                    @global(LastErrorNumber) = __MKSMALLINT(errno);
-                    RETURN ( nil );
-                }
-                pathBuffer[ret] = '\0';  /* readlink does not 0-terminate */
-                path = __MKSTRING(pathBuffer);
-                break;
+	    case S_IFLNK:
+		type = @symbol(symbolicLink);
+		if ((ret = readlink((char *) __stringVal(aPathName), pathBuffer, sizeof(pathBuffer))) < 0) {
+		    @global(LastErrorNumber) = __MKSMALLINT(errno);
+		    RETURN ( nil );
+		}
+		pathBuffer[ret] = '\0';  /* readlink does not 0-terminate */
+		path = __MKSTRING(pathBuffer);
+		break;
     # endif
-            case S_IFDIR:
-                type = @symbol(directory);
-                break;
-
-            case S_IFREG:
-                type = @symbol(regular);
-                break;
+	    case S_IFDIR:
+		type = @symbol(directory);
+		break;
+
+	    case S_IFREG:
+		type = @symbol(regular);
+		break;
     # ifdef S_IFCHR
-            case S_IFCHR:
-                type = @symbol(characterSpecial);
-                break;
+	    case S_IFCHR:
+		type = @symbol(characterSpecial);
+		break;
     # endif
     # ifdef S_IFBLK
-            case S_IFBLK:
-                type = @symbol(blockSpecial);
-                break;
+	    case S_IFBLK:
+		type = @symbol(blockSpecial);
+		break;
     # endif
     # ifdef S_IFMPC
-            case S_IFMPC:
-                type = @symbol(multiplexedCharacterSpecial);
-                break;
+	    case S_IFMPC:
+		type = @symbol(multiplexedCharacterSpecial);
+		break;
     # endif
     # ifdef S_IFMPB
-            case S_IFMPB:
-                type = @symbol(multiplexedBlockSpecial);
-                break;
+	    case S_IFMPB:
+		type = @symbol(multiplexedBlockSpecial);
+		break;
     # endif
     # ifdef S_IFSOCK
-            case S_IFSOCK:
-                type = @symbol(socket);
-                break;
+	    case S_IFSOCK:
+		type = @symbol(socket);
+		break;
     # endif
     # ifdef S_IFIFO
-            case S_IFIFO:
-                type = @symbol(fifo);
-                break;
+	    case S_IFIFO:
+		type = @symbol(fifo);
+		break;
     # endif
-            default:
-                type = @symbol(unknown);
-                break;
-        }
-
-        if (sizeof(buf.st_ino) == 8) {
-            id = __MKUINT64(&buf.st_ino);
-        } else {
-            id = __MKUINT(buf.st_ino);
-        }
-        mode = __MKSMALLINT(buf.st_mode & 0777);
-        uid = __MKSMALLINT(buf.st_uid);
-        gid = __MKSMALLINT(buf.st_gid);
-        nLink = __MKSMALLINT(buf.st_nlink);
-        if (sizeof(buf.st_size) == 8) {
-            size = __MKINT64(&buf.st_size);
-        } else {
-            size = __MKINT(buf.st_size);
-        }
-        aOStime = __MKUINT(buf.st_atime);
-        mOStime = __MKUINT(buf.st_mtime);
-        cOStime = __MKUINT(buf.st_ctime);
+	    default:
+		type = @symbol(unknown);
+		break;
+	}
+
+	if (sizeof(buf.st_ino) == 8) {
+	    id = __MKUINT64(&buf.st_ino);
+	} else {
+	    id = __MKUINT(buf.st_ino);
+	}
+	mode = __MKSMALLINT(buf.st_mode & 0777);
+	uid = __MKSMALLINT(buf.st_uid);
+	gid = __MKSMALLINT(buf.st_gid);
+	nLink = __MKSMALLINT(buf.st_nlink);
+	if (sizeof(buf.st_size) == 8) {
+	    size = __MKINT64(&buf.st_size);
+	} else {
+	    size = __MKINT(buf.st_size);
+	}
+	aOStime = __MKUINT(buf.st_atime);
+	mOStime = __MKUINT(buf.st_mtime);
+	cOStime = __MKUINT(buf.st_ctime);
     }
 #else
     RETURN ( nil );
 #endif
 %}.
     mode notNil ifTrue:[
-        ^ FileStatusInfo
-            type:type
-            mode:mode
-            uid:uid
-            gid:gid
-            size:size
-            id:id
-            accessed:aOStime
-            modified:mOStime
-            statusChanged:cOStime
-            path:path
-            numLinks:nLink.
+	^ FileStatusInfo
+	    type:type
+	    mode:mode
+	    uid:uid
+	    gid:gid
+	    size:size
+	    id:id
+	    accessed:aOStime
+	    modified:mOStime
+	    statusChanged:cOStime
+	    path:path
+	    numLinks:nLink.
    ].
    ^ self primitiveFailed
 
@@ -4883,15 +4883,15 @@
      the info is cached for some time (5 minutes)"
 
     CacheMountPointsTimeStamp notNil ifTrue:[
-        Timestamp now < (CacheMountPointsTimeStamp addSeconds:5*60) ifTrue:[
-            ^ CachedMountPoints 
-        ].
+	Timestamp now < (CacheMountPointsTimeStamp addSeconds:5*60) ifTrue:[
+	    ^ CachedMountPoints
+	].
     ].
 
     '/proc/mounts' asFilename exists ifTrue:[
-        CachedMountPoints := self mountPointsFromProcFS.
-        CacheMountPointsTimeStamp := Timestamp now.
-        ^ CachedMountPoints
+	CachedMountPoints := self mountPointsFromProcFS.
+	CacheMountPointsTimeStamp := Timestamp now.
+	^ CachedMountPoints
     ].
 
     "/ TODO: add fallback code for other OS's (i.e. reading /etc/mtab)
@@ -6193,36 +6193,36 @@
 closeLeftOverFiles
     "a bad bad kludge and workaround for a big bug in the linux
      getAddrInfo implementation:
-        if it gets interrupted (via a timer, for example), its domain-name
-        socket remains open and is NEVER closed.
-        These open files collect up and lead to no-more-files eventually.
+	if it gets interrupted (via a timer, for example), its domain-name
+	socket remains open and is NEVER closed.
+	These open files collect up and lead to no-more-files eventually.
      Invoking this method helps in this situation."
 
     |p|
 
     p := PipeStream
-            readingFrom:('lsof -p ' , (OperatingSystem getProcessId printString)).
+	    readingFrom:('lsof -p ' , (OperatingSystem getProcessId printString)).
 
     p linesDo:[:line |
-        |words fd|
-
-        words := line asCollectionOfWords.
-        "/ COMMAND PID USER   FD   TYPE     DEVICE    SIZE    NODE NAME
-        words first = 'stx' ifTrue:[
-            words second = (OperatingSystem getProcessId printString) ifTrue:[
-                (words fourth endsWith:'u') ifTrue:[
-                    (words fifth = 'IPv4') ifTrue:[
-                        (words seventh = 'UDP') ifTrue:[
-                            (words last endsWith:'domain') ifTrue:[
-                                fd := Number readFrom:(words fourth copyWithoutLast:1).
+	|words fd|
+
+	words := line asCollectionOfWords.
+	"/ COMMAND PID USER   FD   TYPE     DEVICE    SIZE    NODE NAME
+	words first = 'stx' ifTrue:[
+	    words second = (OperatingSystem getProcessId printString) ifTrue:[
+		(words fourth endsWith:'u') ifTrue:[
+		    (words fifth = 'IPv4') ifTrue:[
+			(words seventh = 'UDP') ifTrue:[
+			    (words last endsWith:'domain') ifTrue:[
+				fd := Number readFrom:(words fourth copyWithoutLast:1).
 Transcript showCR:line.
-                                OperatingSystem closeFd:fd.
-                            ]
-                        ]
-                    ]
-                ]
-            ]
-        ]
+				OperatingSystem closeFd:fd.
+			    ]
+			]
+		    ]
+		]
+	    ]
+	]
     ].
     p close.
 
@@ -8106,17 +8106,17 @@
     static int has_clock_gettime = 1;
 
     if (has_clock_gettime) {
-        if (clock_gettime(CLOCK_MONOTONIC, &ts) != -1) {
-            seconds = __MKUINT(ts.tv_sec);
-            micros  = __MKUINT(ts.tv_nsec / 1000);
-            goto out;
-        } else {
-            /* 
-             * clock_gettime is not implemented in the kernel
-             * fall through to alternative implementation
-             */
-            has_clock_gettime = 0;
-        }
+	if (clock_gettime(CLOCK_MONOTONIC, &ts) != -1) {
+	    seconds = __MKUINT(ts.tv_sec);
+	    micros  = __MKUINT(ts.tv_nsec / 1000);
+	    goto out;
+	} else {
+	    /*
+	     * clock_gettime is not implemented in the kernel
+	     * fall through to alternative implementation
+	     */
+	    has_clock_gettime = 0;
+	}
     }
 #endif
 
@@ -8125,7 +8125,7 @@
 
     gettimeofday(&tb, NULL /* &tzb */);
     if (tb.tv_usec >= (1000*1000)) {
-        error = @symbol(bad);
+	error = @symbol(bad);
     }
 
     seconds = __MKUINT(tb.tv_sec);
@@ -8136,10 +8136,10 @@
 %}.
 
     seconds notNil ifTrue:[
-        ^ (seconds * 1000000) + micros
+	^ (seconds * 1000000) + micros
     ].
     error isNil ifTrue:[
-        ^ self getMillisecondTime * 1000
+	^ self getMillisecondTime * 1000
     ].
     self primitiveFailed:error.
 
@@ -8158,8 +8158,8 @@
      Use the XXXmillisecondTime:-methods to compare and add time deltas - these know about the wrap.
 
      BAD DESIGN:
-        This should be changed to return some instance of RelativeTime,
-        and these computations moved there.
+	This should be changed to return some instance of RelativeTime,
+	and these computations moved there.
 
      Don't use this method in application code since it is an internal (private)
      interface. For compatibility with ST-80, use Time millisecondClockValue.
@@ -8174,16 +8174,16 @@
     struct timespec ts;
 
     if (has_clock_gettime) {
-        if (clock_gettime(CLOCK_MONOTONIC, &ts) != -1) {
-            t = ts.tv_sec*1000 + ts.tv_nsec/1000000;
-            goto out;
-        } else {
-            /* 
-             * clock_gettime is not implemented in the kernel
-             * fall through to alternative implementation
-             */
-            has_clock_gettime = 0;
-        }
+	if (clock_gettime(CLOCK_MONOTONIC, &ts) != -1) {
+	    t = ts.tv_sec*1000 + ts.tv_nsec/1000000;
+	    goto out;
+	} else {
+	    /*
+	     * clock_gettime is not implemented in the kernel
+	     * fall through to alternative implementation
+	     */
+	    has_clock_gettime = 0;
+	}
     }
 #endif /*  _POSIX_MONOTONIC_CLOCK */
 
@@ -8199,12 +8199,12 @@
     struct tms tb;
 
     if (!millisecondsPerTick) {
-        int ticksPerSecond = sysconf(_SC_CLK_TCK);
-        if (ticksPerSecond <= 0)
-            goto err;
-        if (ticksPerSecond > 1000)
-            goto err;
-        millisecondsPerTick = 1000 / ticksPerSecond;
+	int ticksPerSecond = sysconf(_SC_CLK_TCK);
+	if (ticksPerSecond <= 0)
+	    goto err;
+	if (ticksPerSecond > 1000)
+	    goto err;
+	millisecondsPerTick = 1000 / ticksPerSecond;
 /*
 printf("milliSecondsPerTick: %d\n", millisecondsPerTick);
 */
@@ -8212,7 +8212,7 @@
 
     ticks = times(&tb);
     if (ticks == -1)
-        goto err;
+	goto err;
 
     t = ticks * millisecondsPerTick;
 
@@ -10885,24 +10885,24 @@
     int ret, cnt = 0;
 
     if (hostName == nil) {
-        __hostName = 0;
+	__hostName = 0;
     } else if (__isString(hostName) || __isSymbol(hostName)) {
-        __hostName = __stringVal(hostName);
+	__hostName = __stringVal(hostName);
     } else {
-        error = @symbol(badArgument1);
-        goto err;
+	error = @symbol(badArgument1);
+	goto err;
     }
     if (serviceName == nil) {
-        __serviceName = 0;
+	__serviceName = 0;
     } else if (__isString(serviceName) || __isSymbol(serviceName)) {
-        __serviceName = __stringVal(serviceName);
+	__serviceName = __stringVal(serviceName);
     } else {
-        error = @symbol(badArgument2);
-        goto err;
+	error = @symbol(badArgument2);
+	goto err;
     }
     if (__hostName == 0 && __serviceName == 0) {
-        error = @symbol(badArgument);
-        goto err;
+	error = @symbol(badArgument);
+	goto err;
     }
 
 {
@@ -10915,102 +10915,113 @@
 
     memset(&hints, 0, sizeof(hints));
     if (__isSmallInteger(domain))
-        hints.ai_family = __intVal(domain);
+	hints.ai_family = __intVal(domain);
     if (__isSmallInteger(type))
-        hints.ai_socktype = __intVal(type);
+	hints.ai_socktype = __intVal(type);
     if (__isSmallInteger(proto))
-        hints.ai_protocol = __intVal(proto);
+	hints.ai_protocol = __intVal(proto);
 
     do {
-        __BEGIN_INTERRUPTABLE__
-        ret = getaddrinfo(__hostName, __serviceName, &hints, &info);
-        __END_INTERRUPTABLE__
+	if (hostName == nil) {
+	    __hostName = 0;
+	} else if (__isString(hostName) || __isSymbol(hostName)) {
+	    __hostName = __stringVal(hostName);
+	}
+	if (serviceName == nil) {
+	    __serviceName = 0;
+	} else if (__isString(serviceName) || __isSymbol(serviceName)) {
+	    __serviceName = __stringVal(serviceName);
+	}
+
+	__BEGIN_INTERRUPTABLE__
+	ret = getaddrinfo(__hostName, __serviceName, &hints, &info);
+	__END_INTERRUPTABLE__
     } while (ret == EAI_SYSTEM && errno == EINTR);
     if (ret != 0) {
-        switch (ret) {
-        case EAI_FAMILY:
-            error = @symbol(badProtocol);
-            break;
-        case EAI_SOCKTYPE:
-            error = @symbol(badSocketType);
-            break;
-        case EAI_BADFLAGS:
-            error = @symbol(badFlags);
-            break;
-        case EAI_NONAME:
-            error = @symbol(unknownHost);
-            break;
-        case EAI_SERVICE:
-            error = @symbol(unknownService);
-            break;
-        case EAI_ADDRFAMILY :
-            error = @symbol(unknownHostForProtocol);
-            break;
-        case EAI_NODATA:
-            error = @symbol(noAddress);
-            break;
-        case EAI_MEMORY:
-            error = @symbol(allocationFailure);
-            break;
-        case EAI_FAIL:
-            error = @symbol(permanentFailure);
-            break;
-        case EAI_AGAIN:
-            error = @symbol(tryAgain);
-            break;
-        case EAI_SYSTEM:
-            error = @symbol(systemError);
-            break;
-        default:
-            error = @symbol(unknownError);
-        }
-        errorString = __MKSTRING(gai_strerror(ret));
-        goto err;
+	switch (ret) {
+	case EAI_FAMILY:
+	    error = @symbol(badProtocol);
+	    break;
+	case EAI_SOCKTYPE:
+	    error = @symbol(badSocketType);
+	    break;
+	case EAI_BADFLAGS:
+	    error = @symbol(badFlags);
+	    break;
+	case EAI_NONAME:
+	    error = @symbol(unknownHost);
+	    break;
+	case EAI_SERVICE:
+	    error = @symbol(unknownService);
+	    break;
+	case EAI_ADDRFAMILY :
+	    error = @symbol(unknownHostForProtocol);
+	    break;
+	case EAI_NODATA:
+	    error = @symbol(noAddress);
+	    break;
+	case EAI_MEMORY:
+	    error = @symbol(allocationFailure);
+	    break;
+	case EAI_FAIL:
+	    error = @symbol(permanentFailure);
+	    break;
+	case EAI_AGAIN:
+	    error = @symbol(tryAgain);
+	    break;
+	case EAI_SYSTEM:
+	    error = @symbol(systemError);
+	    break;
+	default:
+	    error = @symbol(unknownError);
+	}
+	errorString = __MKSTRING(gai_strerror(ret));
+	goto err;
     }
     for (cnt=0, infop=info; infop; infop=infop->ai_next)
-        cnt++;
+	cnt++;
 
     result = __ARRAY_NEW_INT(cnt);
     if (result == nil) {
-        error = @symbol(allocationFailure);
-        goto err;
+	error = @symbol(allocationFailure);
+	goto err;
     }
     for (infop=info, cnt=0; infop; infop=infop->ai_next, cnt++) {
-        OBJ o, resp;
-
-        resp = __ARRAY_NEW_INT(6);
-        if (resp == nil) {
-            error = @symbol(allocationFailure);
-            goto err;
-        }
-
-        __ArrayInstPtr(result)->a_element[cnt] = resp; __STORE(result, resp);
-
-        __ArrayInstPtr(resp)->a_element[0] = __MKSMALLINT(infop->ai_flags);
-        __ArrayInstPtr(resp)->a_element[1] = __MKSMALLINT(infop->ai_family);
-        __ArrayInstPtr(resp)->a_element[2] = __MKSMALLINT(infop->ai_socktype);
-        __ArrayInstPtr(resp)->a_element[3] = __MKSMALLINT(infop->ai_protocol);
-
-        __PROTECT__(resp);
-        o = __BYTEARRAY_NEW_INT(infop->ai_addrlen);
-        __UNPROTECT__(resp);
-        if (o == nil) {
-            error = @symbol(allocationFailure);
-            goto err;
-        }
-        memcpy(__byteArrayVal(o), infop->ai_addr, infop->ai_addrlen);
+	OBJ o, resp;
+
+	resp = __ARRAY_NEW_INT(6);
+	if (resp == nil) {
+	    error = @symbol(allocationFailure);
+	    goto err;
+	}
+
+	__ArrayInstPtr(result)->a_element[cnt] = resp; __STORE(result, resp);
+
+	__ArrayInstPtr(resp)->a_element[0] = __MKSMALLINT(infop->ai_flags);
+	__ArrayInstPtr(resp)->a_element[1] = __MKSMALLINT(infop->ai_family);
+	__ArrayInstPtr(resp)->a_element[2] = __MKSMALLINT(infop->ai_socktype);
+	__ArrayInstPtr(resp)->a_element[3] = __MKSMALLINT(infop->ai_protocol);
+
+	__PROTECT__(resp);
+	o = __BYTEARRAY_NEW_INT(infop->ai_addrlen);
+	__UNPROTECT__(resp);
+	if (o == nil) {
+	    error = @symbol(allocationFailure);
+	    goto err;
+	}
+	memcpy(__byteArrayVal(o), infop->ai_addr, infop->ai_addrlen);
        __ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
 
-        if (infop->ai_canonname) {
-            __PROTECT__(resp);
-            o = __MKSTRING(infop->ai_canonname);
-            __UNPROTECT__(resp);
-            if (o == nil) {
-                error = @symbol(allocationFailure);
-                goto err;
-            }
-            __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
-        }
+	if (infop->ai_canonname) {
+	    __PROTECT__(resp);
+	    o = __MKSTRING(infop->ai_canonname);
+	    __UNPROTECT__(resp);
+	    if (o == nil) {
+		error = @symbol(allocationFailure);
+		goto err;
+	    }
+	    __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
+	}
     }
 
 err:
@@ -11027,131 +11038,136 @@
     int i;
 
     if (__serviceName) {
-        struct servent *sp;
-        char *__proto = 0;
-
-        if (__isString(protoArg) || __isSymbol(protoArg))
-            __proto = __stringVal(protoArg);
-
-        sp = getservbyname(__serviceName, __proto);
-        if (sp == NULL) {
-            errorString = @symbol(unknownService);
-            error = __mkSmallInteger(-3);
-            goto err;
-        }
-        port = sp->s_port;
+	struct servent *sp;
+	char *__proto = 0;
+
+	if (__isString(protoArg) || __isSymbol(protoArg))
+	    __proto = __stringVal(protoArg);
+
+	sp = getservbyname(__serviceName, __proto);
+	if (sp == NULL) {
+	    errorString = @symbol(unknownService);
+	    error = __mkSmallInteger(-3);
+	    goto err;
+	}
+	port = sp->s_port;
     }
 
     if (__hostName) {
 #  ifdef USE_H_ERRNO
-        do {
-            /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname
-             * uses a static data area
-             */
-            __BEGIN_INTERRUPTABLE__
-            hp = gethostbyname(__hostName);
-            __END_INTERRUPTABLE__
-        } while ((hp == NULL)
-                  && (
-                        (h_errno == TRY_AGAIN)
-                      || errno == EINTR
+	do {
+	    if (hostName == nil) {
+		__hostName = 0;
+	    } else if (__isString(hostName) || __isSymbol(hostName)) {
+		__hostName = __stringVal(hostName);
+	    }
+	    /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname
+	     * uses a static data area
+	     */
+	    __BEGIN_INTERRUPTABLE__
+	    hp = gethostbyname(__hostName);
+	    __END_INTERRUPTABLE__
+	} while ((hp == NULL)
+		  && (
+			(h_errno == TRY_AGAIN)
+		      || errno == EINTR
 #   ifdef IRIX5_3
-                      || (errno == ECONNREFUSED)
+		      || (errno == ECONNREFUSED)
 #   endif
-                     )
-        );
-        if (hp == 0) {
-            switch (h_errno) {
-            case HOST_NOT_FOUND:
-                errorString = @symbol(unknownHost);
-                break;
-            case NO_ADDRESS:
-                errorString = @symbol(noAddress);
-                break;
-            case NO_RECOVERY:
-                errorString = @symbol(permanentFailure);
-                break;
-            case TRY_AGAIN:
-                errorString = @symbol(tryAgain);
-                break;
-            default:
-                errorString = @symbol(unknownError);
-                break;
-            }
-            error = __mkSmallInteger(h_errno);
-            goto err;
-        }
+		     )
+	);
+	if (hp == 0) {
+	    switch (h_errno) {
+	    case HOST_NOT_FOUND:
+		errorString = @symbol(unknownHost);
+		break;
+	    case NO_ADDRESS:
+		errorString = @symbol(noAddress);
+		break;
+	    case NO_RECOVERY:
+		errorString = @symbol(permanentFailure);
+		break;
+	    case TRY_AGAIN:
+		errorString = @symbol(tryAgain);
+		break;
+	    default:
+		errorString = @symbol(unknownError);
+		break;
+	    }
+	    error = __mkSmallInteger(h_errno);
+	    goto err;
+	}
 #  else /* !USE_H_ERRNO */
-        hp = gethostbyname(__hostName);
-        if (hp == 0) {
-            errorString = @symbol(unknownHost);
-            error = __mkSmallInteger(-1);
-            goto err;
-        }
+	hp = gethostbyname(__hostName);
+	if (hp == 0) {
+	    errorString = @symbol(unknownHost);
+	    error = __mkSmallInteger(-1);
+	    goto err;
+	}
 #  endif /* !USE_H_ERRNO*/
 
-        if (__isSmallInteger(domain) && hp->h_addrtype != __smallIntegerVal(domain)) {
-            errorString = @symbol(unknownHost);
-            error = __mkSmallInteger(-2);
-            goto err;
-        }
-
-        for (cnt = 0, addrpp = hp->h_addr_list; *addrpp; addrpp++)
-            cnt++;
-        addrpp = hp->h_addr_list;
+	if (__isSmallInteger(domain) && hp->h_addrtype != __smallIntegerVal(domain)) {
+	    errorString = @symbol(unknownHost);
+	    error = __mkSmallInteger(-2);
+	    goto err;
+	}
+
+	for (cnt = 0, addrpp = hp->h_addr_list; *addrpp; addrpp++)
+	    cnt++;
+	addrpp = hp->h_addr_list;
     } else {
-        cnt = 1;
+	cnt = 1;
     }
 
     result = __ARRAY_NEW_INT(cnt);
     if (result == nil) {
-        error = @symbol(allocationFailure);
-        goto err;
+	error = @symbol(allocationFailure);
+	goto err;
     }
 
     for (i = 0; i < cnt; i++) {
-        OBJ o, resp;
-        struct sockaddr_in *sa;
-
-        resp = __ARRAY_NEW_INT(6);
-        if (resp == nil) {
-            error = @symbol(allocationFailure);
-            goto err;
-        }
-
-        __ArrayInstPtr(result)->a_element[i] = resp; __STORE(result, resp);
-        __ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(0);
-        __ArrayInstPtr(resp)->a_element[2] = type; __STORE(result, type);
-        __ArrayInstPtr(resp)->a_element[3] = proto; __STORE(result, proto);
-        __PROTECT__(resp);
-        o = __BYTEARRAY_NEW_INT(sizeof(*sa));
-        __UNPROTECT__(resp);
-        if (o == nil) {
-            error = @symbol(allocationFailure);
-            goto err;
-        }
-        __ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
-        sa = (struct sockaddr_in *)__byteArrayVal(o);
-        sa->sin_port = port;
-
-        if (__hostName) {
-            sa->sin_family = hp->h_addrtype;
-            memcpy(&sa->sin_addr, *addrpp, hp->h_length);
-            __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(hp->h_addrtype);
-            if (hp->h_name) {
-                __PROTECT__(resp);
-                o = __MKSTRING(hp->h_name);
-                __UNPROTECT__(resp);
-                if (o == nil) {
-                    error = @symbol(allocationFailure);
-                    goto err;
-                }
-                __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
-            }
-            addrpp++;
-        } else{
-            __ArrayInstPtr(resp)->a_element[1] = domain; __STORE(resp, domain);
-        }
+	OBJ o, resp;
+	struct sockaddr_in *sa;
+
+	resp = __ARRAY_NEW_INT(6);
+	if (resp == nil) {
+	    error = @symbol(allocationFailure);
+	    goto err;
+	}
+
+	__ArrayInstPtr(result)->a_element[i] = resp; __STORE(result, resp);
+	__ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(0);
+	__ArrayInstPtr(resp)->a_element[2] = type; __STORE(result, type);
+	__ArrayInstPtr(resp)->a_element[3] = proto; __STORE(result, proto);
+	__PROTECT__(resp);
+	o = __BYTEARRAY_NEW_INT(sizeof(*sa));
+	__UNPROTECT__(resp);
+	if (o == nil) {
+	    error = @symbol(allocationFailure);
+	    goto err;
+	}
+	__ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
+	sa = (struct sockaddr_in *)__byteArrayVal(o);
+	sa->sin_port = port;
+
+	if (__hostName) {
+	    sa->sin_family = hp->h_addrtype;
+	    memcpy(&sa->sin_addr, *addrpp, hp->h_length);
+	    __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(hp->h_addrtype);
+	    if (hp->h_name) {
+		__PROTECT__(resp);
+		o = __MKSTRING(hp->h_name);
+		__UNPROTECT__(resp);
+		if (o == nil) {
+		    error = @symbol(allocationFailure);
+		    goto err;
+		}
+		__ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
+	    }
+	    addrpp++;
+	} else{
+	    __ArrayInstPtr(resp)->a_element[1] = domain; __STORE(resp, domain);
+	}
     }
 
 err:;
@@ -11162,54 +11178,54 @@
 #endif
 %}.
     error notNil ifTrue:[
-        |request|
-        request := SocketAddressInfo new
-            domain:domainArg;
-            type:typeArg;
-            protocol:protoArg;
-            canonicalName:hostName;
-            serviceName:serviceName.
-        ^ (HostNameLookupError new 
-                parameter:error; 
-                messageText:' - ', errorString; 
-                request:request) raiseRequest.
+	|request|
+	request := SocketAddressInfo new
+	    domain:domainArg;
+	    type:typeArg;
+	    protocol:protoArg;
+	    canonicalName:hostName;
+	    serviceName:serviceName.
+	^ (HostNameLookupError new
+		parameter:error;
+		messageText:' - ', errorString;
+		request:request) raiseRequest.
     ].
     1 to:result size do:[:i |
-        |entry dom info|
-
-        info := SocketAddressInfo new.
-        entry := result at:i.
-        info flags:(entry at:1).
-        info domain:(dom := OperatingSystem domainSymbolOf:(entry at:2)).
-        info type:(OperatingSystem socketTypeSymbolOf:(entry at:3)).
-        info protocol:(self protocolSymbolOf:(entry at:4)).
-        info socketAddress:((SocketAddress newDomain:dom) fromBytes:(entry at:5)).
-        info canonicalName:(entry at:6).
-        result at:i put:info
+	|entry dom info|
+
+	info := SocketAddressInfo new.
+	entry := result at:i.
+	info flags:(entry at:1).
+	info domain:(dom := OperatingSystem domainSymbolOf:(entry at:2)).
+	info type:(OperatingSystem socketTypeSymbolOf:(entry at:3)).
+	info protocol:(self protocolSymbolOf:(entry at:4)).
+	info socketAddress:((SocketAddress newDomain:dom) fromBytes:(entry at:5)).
+	info canonicalName:(entry at:6).
+	result at:i put:info
     ].
     ^ result
 
     "
      self getAddressInfo:'localhost' serviceName:nil
-            domain:nil type:nil protocol:nil flags:nil
+	    domain:nil type:nil protocol:nil flags:nil
      self getAddressInfo:'localhost' serviceName:nil
-            domain:#inet type:#stream protocol:nil flags:nil
+	    domain:#inet type:#stream protocol:nil flags:nil
      self getAddressInfo:'localhost' serviceName:nil
-            domain:#inet type:#stream protocol:#tcp flags:nil
+	    domain:#inet type:#stream protocol:#tcp flags:nil
      self getAddressInfo:'blurb.exept.de' serviceName:nil
-            domain:#inet type:nil protocol:nil flags:nil
+	    domain:#inet type:nil protocol:nil flags:nil
      self getAddressInfo:'1.2.3.4' serviceName:'bla'
-            domain:#inet type:nil protocol:nil flags:nil
+	    domain:#inet type:nil protocol:nil flags:nil
      self getAddressInfo:'localhost' serviceName:'echo'
-            domain:#inet type:nil protocol:nil flags:nil
+	    domain:#inet type:nil protocol:nil flags:nil
      self getAddressInfo:nil serviceName:'echo'
-            domain:#inet type:nil protocol:nil flags:nil
+	    domain:#inet type:nil protocol:nil flags:nil
      self getAddressInfo:nil serviceName:nil
-            domain:#inet type:nil protocol:nil flags:nil
+	    domain:#inet type:nil protocol:nil flags:nil
      self getAddressInfo:'www.google.de' serviceName:nil
-            domain:nil type:nil protocol:nil flags:nil
+	    domain:nil type:nil protocol:nil flags:nil
      self getAddressInfo:'smc1' serviceName:nil
-            domain:nil type:nil protocol:nil flags:nil
+	    domain:nil type:nil protocol:nil flags:nil
     "
 !
 
@@ -11241,20 +11257,20 @@
     int nInstBytes, sockAddrSize;
 
     if (wantHostName == true) {
-        hp = host;
-        hsz = sizeof(host);
+	hp = host;
+	hsz = sizeof(host);
     }
     if (wantServiceName == true) {
-        sp = service;
-        ssz = sizeof(service);
+	sp = service;
+	ssz = sizeof(service);
     }
     if (hp == 0 && sp == 0) {
-        error = @symbol(badArgument);
-        goto err;
+	error = @symbol(badArgument);
+	goto err;
     }
     if (!__isBytes(socketAddress)) {
-        error = @symbol(badArgument1);
-        goto err;
+	error = @symbol(badArgument1);
+	goto err;
     }
 
     nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_ninstvars));
@@ -11262,172 +11278,176 @@
     sockAddrSize -= nInstBytes;
 
     if (!__isSmallInteger(flags)) {
-        error = @symbol(badArgument5);
-        goto err;
+	error = @symbol(badArgument5);
+	goto err;
     }
     __flags = __intVal(flags);
 
 #if defined(NI_NUMERICHOST)
     if (useDatagram == true) {
-        __flags |= NI_DGRAM;
+	__flags |= NI_DGRAM;
     }
 
     {
-        bp = (char *)(__byteArrayVal(socketAddress));
-        bp += nInstBytes;
-        __BEGIN_INTERRUPTABLE__
-        ret = getnameinfo((struct sockaddr *)bp, sockAddrSize,
-                          hp, hsz, sp, ssz, __flags);
-        __END_INTERRUPTABLE__
+	bp = (char *)(__byteArrayVal(socketAddress));
+	bp += nInstBytes;
+	__BEGIN_INTERRUPTABLE__
+	ret = getnameinfo((struct sockaddr *)bp, sockAddrSize,
+			  hp, hsz, sp, ssz, __flags);
+	__END_INTERRUPTABLE__
     } while (ret == EAI_SYSTEM && errno == EINTR);
     if (ret != 0) {
-        switch (ret) {
-        case EAI_FAMILY:
-            error = @symbol(badProtocol);
-            break;
-        case EAI_SOCKTYPE:
-            error = @symbol(badSocketType);
-            break;
-        case EAI_BADFLAGS:
-            error = @symbol(badFlags);
-            break;
-        case EAI_NONAME:
-            error = @symbol(unknownHost);
-            break;
-        case EAI_SERVICE:
-            error = @symbol(unknownService);
-            break;
-        case EAI_ADDRFAMILY :
-            error = @symbol(unknownHostForProtocol);
-            break;
-        case EAI_NODATA:
-            error = @symbol(noAddress);
-            break;
-        case EAI_MEMORY:
-            error = @symbol(allocationFailure);
-            break;
-        case EAI_FAIL:
-            error = @symbol(permanentFailure);
-            break;
-        case EAI_AGAIN:
-            error = @symbol(tryAgain);
-            break;
-        case EAI_SYSTEM:
-            error = @symbol(systemError);
-            break;
-        default:
-            error = @symbol(unknownError);
-        }
-        errorString = __MKSTRING(gai_strerror(ret));
-        goto err;
+	switch (ret) {
+	case EAI_FAMILY:
+	    error = @symbol(badProtocol);
+	    break;
+	case EAI_SOCKTYPE:
+	    error = @symbol(badSocketType);
+	    break;
+	case EAI_BADFLAGS:
+	    error = @symbol(badFlags);
+	    break;
+	case EAI_NONAME:
+	    error = @symbol(unknownHost);
+	    break;
+	case EAI_SERVICE:
+	    error = @symbol(unknownService);
+	    break;
+	case EAI_ADDRFAMILY :
+	    error = @symbol(unknownHostForProtocol);
+	    break;
+	case EAI_NODATA:
+	    error = @symbol(noAddress);
+	    break;
+	case EAI_MEMORY:
+	    error = @symbol(allocationFailure);
+	    break;
+	case EAI_FAIL:
+	    error = @symbol(permanentFailure);
+	    break;
+	case EAI_AGAIN:
+	    error = @symbol(tryAgain);
+	    break;
+	case EAI_SYSTEM:
+	    error = @symbol(systemError);
+	    break;
+	default:
+	    error = @symbol(unknownError);
+	}
+	errorString = __MKSTRING(gai_strerror(ret));
+	goto err;
     }
 # else /* ! NI_NUMERICHOST */
     {
-        /*
-         * Do it using gethostbyaddr()
-         */
-        struct sockaddr_in *sa;
-
-        if (sockAddrSize < sizeof(*sa)) {
-            error = @symbol(badArgument1);
-            goto err;
-        }
-        bp = (char *)(__byteArrayVal(socketAddress));
-        bp += nInstBytes;
-        sa = (struct sockaddr_in *)bp;
-
-        if (sp) {
-            struct servent *servp;
-            char *__proto = 0;
-
-            __proto = (useDatagram == true ? "udp" : "tcp");
-
-            servp = getservbyport(sa->sin_port, __proto);
-            if (servp) {
-                sp = servp->s_name;
-            }
-        }
-        if (hp) {
-            struct hostent *hostp;
+	/*
+	 * Do it using gethostbyaddr()
+	 */
+	struct sockaddr_in *sa;
+
+	if (sockAddrSize < sizeof(*sa)) {
+	    error = @symbol(badArgument1);
+	    goto err;
+	}
+	bp = (char *)(__byteArrayVal(socketAddress));
+	bp += nInstBytes;
+	sa = (struct sockaddr_in *)bp;
+
+	if (sp) {
+	    struct servent *servp;
+	    char *__proto = 0;
+
+	    __proto = (useDatagram == true ? "udp" : "tcp");
+
+	    servp = getservbyport(sa->sin_port, __proto);
+	    if (servp) {
+		sp = servp->s_name;
+	    }
+	}
+	if (hp) {
+	    struct hostent *hostp;
 #  ifdef USE_H_ERRNO
-            do {
-                /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname uses a static data area
-                 */
-                hostp = gethostbyaddr((char *)&sa->sin_addr, sockAddrSize, sa->sin_family);
-                /* __END_INTERRUPTABLE__ */
-            } while ((hostp == NULL)
-                      && ((h_errno == TRY_AGAIN)
-                          || errno == EINTR
+	    do {
+		bp = (char *)(__byteArrayVal(socketAddress));
+		bp += nInstBytes;
+		sa = (struct sockaddr_in *)bp;
+
+		/* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname uses a static data area
+		 */
+		hostp = gethostbyaddr((char *)&sa->sin_addr, sockAddrSize, sa->sin_family);
+		/* __END_INTERRUPTABLE__ */
+	    } while ((hostp == NULL)
+		      && ((h_errno == TRY_AGAIN)
+			  || errno == EINTR
 #   ifdef IRIX5_3
-                          || (errno == ECONNREFUSED)
+			  || (errno == ECONNREFUSED)
 #   endif
-                         )
-            );
-            if (hostp == 0) {
-                switch (h_errno) {
-                case HOST_NOT_FOUND:
-                    errorString = @symbol(unknownHost);
-                    break;
-                case NO_ADDRESS:
-                    errorString = @symbol(noAddress);
-                    break;
-                case NO_RECOVERY:
-                    errorString = @symbol(permanentFailure);
-                    break;
-                case TRY_AGAIN:
-                    errorString = @symbol(tryAgain);
-                    break;
-                default:
-                    errorString = @symbol(unknownError);
-                    break;
-                }
-                error = __mkSmallInteger(h_errno);
-                goto err;
-            }
+			 )
+	    );
+	    if (hostp == 0) {
+		switch (h_errno) {
+		case HOST_NOT_FOUND:
+		    errorString = @symbol(unknownHost);
+		    break;
+		case NO_ADDRESS:
+		    errorString = @symbol(noAddress);
+		    break;
+		case NO_RECOVERY:
+		    errorString = @symbol(permanentFailure);
+		    break;
+		case TRY_AGAIN:
+		    errorString = @symbol(tryAgain);
+		    break;
+		default:
+		    errorString = @symbol(unknownError);
+		    break;
+		}
+		error = __mkSmallInteger(h_errno);
+		goto err;
+	    }
 #  else /* !USE_H_ERRNO */
-            hostp = gethostbyaddr(sa->sin_addr, sockAddrSize, sa->sin_family);
-            if (hostp == 0) {
-                errorString = @symbol(unknownHost);
-                error = __mkSmallInteger(-1);
-                goto err;
-            }
+	    hostp = gethostbyaddr(sa->sin_addr, sockAddrSize, sa->sin_family);
+	    if (hostp == 0) {
+		errorString = @symbol(unknownHost);
+		error = __mkSmallInteger(-1);
+		goto err;
+	    }
 #  endif /* !USE_H_ERRNO*/
-            hp = hostp->h_name;
-        }
+	    hp = hostp->h_name;
+	}
     }
 # endif /* ! NI_NUMERICHOST */
 
     if (hp)
-        hostName = __MKSTRING(hp);
+	hostName = __MKSTRING(hp);
     if (sp)
-        serviceName = __MKSTRING(sp);
+	serviceName = __MKSTRING(sp);
 err:;
 #else
     error = @symbol(notImplemented);
 #endif
 %}.
     error notNil ifTrue:[
-        ^ (HostAddressLookupError new 
-                parameter:error; 
-                messageText:' - ', errorString; 
-                request:thisContext message) raiseRequest.
+	^ (HostAddressLookupError new
+		parameter:error;
+		messageText:' - ', errorString;
+		request:thisContext message) raiseRequest.
     ].
 
     ^ Array with:hostName with:serviceName
 
     "
      self getNameInfo:
-        (self getAddressInfo:'localhost' serviceName:'echo'
-                domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
-         wantHostName:true wantServiceName:true datagram:false flags:0
+	(self getAddressInfo:'localhost' serviceName:'echo'
+		domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
+	 wantHostName:true wantServiceName:true datagram:false flags:0
 
      self getNameInfo:
-        (self getAddressInfo:'exept.exept.de' serviceName:'echo'
-                domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
-         wantHostName:true wantServiceName:true datagram:false flags:0
+	(self getAddressInfo:'exept.exept.de' serviceName:'echo'
+		domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
+	 wantHostName:true wantServiceName:true datagram:false flags:0
 
      self getNameInfo:#[1 2 3 4]
-         wantHostName:true wantServiceName:true datagram:false flags:0
+	 wantHostName:true wantServiceName:true datagram:false flags:0
     "
 ! !
 
@@ -12272,7 +12292,7 @@
 !UnixOperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.222 2005-02-09 11:13:02 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.223 2005-03-01 15:19:34 cg Exp $'
 ! !
 
 UnixOperatingSystem initialize!