Merge jv
authorMerge Script
Wed, 19 Aug 2015 06:41:26 +0200
branchjv
changeset 18698 17c1b3a8e36f
parent 18693 22ba9e374cbf (current diff)
parent 18697 0d51908c9cef (diff)
child 18705 843770030c5f
Merge
UnixOperatingSystem.st
--- a/UnixOperatingSystem.st	Mon Aug 17 16:09:05 2015 +0100
+++ b/UnixOperatingSystem.st	Wed Aug 19 06:41:26 2015 +0200
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
  COPYRIGHT (c) 1988 by Claus Gittinger
 	      All Rights Reserved
@@ -7542,15 +7540,15 @@
 
 getNetworkAddressInfo
     "return a Dictionary of network interface information.
-	key -> name of interface
-	value -> a Set of network address
-		information for the interface - a dictionaries containing the
-		information about the configuration of each interface in the system.
-		The dictionary keys are:
-		    #address
-		    #netmask
-		    #flags
-		    #destAddress"
+        key -> name of interface
+        value -> a Set of network address
+                information for the interface - a dictionaries containing the
+                information about the configuration of each interface in the system.
+                The dictionary keys are:
+                    #address
+                    #netmask
+                    #flags
+                    #destAddress"
 
     |returnArray addressArray nameArray noOfIf retDictionary error retIndex|
 
@@ -7570,176 +7568,108 @@
     OBJ t;
 
     if (getifaddrs(&ifap) < 0) {
-	error = __MKSTRING("getifaddrs() failed");
-	goto out;
+        error = __MKSTRING("getifaddrs() failed");
+        goto out;
     }
 
     for (ifaLoop = ifap; ifaLoop != 0; ifaLoop = ifaLoop->ifa_next) n_ifa++;
-
-    returnArray = __ARRAY_NEW_INT(n_ifa*5);
+    noOfIf = __mkSmallInteger(n_ifa);
+
+    returnArray = __ARRAY_NEW_INT(n_ifa*6);
 
     if (returnArray == nil) {
-	/* Creating a string wouldn't work here */
-	error = @symbol(allocationFailure);
-	goto bad;
+        /* Creating a string wouldn't work here */
+        error = @symbol(allocationFailure);
+        goto bad;
     }
 
     for (ifaLoop = ifap; ifaLoop != 0; ifaLoop = ifaLoop->ifa_next) {
-	int family, len;
-
-	if (ifaLoop->ifa_addr == 0)
-	       continue;
-	family = ifaLoop->ifa_addr->sa_family;
-	switch (family) {
-	case AF_INET:
-	    len = sizeof(struct sockaddr_in);
-	    break;
-	case AF_INET6:
-	    len = sizeof(struct sockaddr_in6);
-	    break;
+        int family, len;
+
+        if (ifaLoop->ifa_addr == 0)
+               continue;
+        family = ifaLoop->ifa_addr->sa_family;
+        switch (family) {
+        case AF_INET:
+            len = sizeof(struct sockaddr_in);
+            break;
+        case AF_INET6:
+            len = sizeof(struct sockaddr_in6);
+            break;
 #if 0
-	case AF_PACKET:
-	    len = sizeof(sockaddr_ll);
-	    break;
-#endif
-	default:
-	    /* skip */
-	    continue;
-	};
-	t = __MKSTRING(ifaLoop->ifa_name);
-	__arrayVal(returnArray)[retI++] = t; __STORE(returnArray, t);
-	t = __MKUINT(ifaLoop->ifa_flags);
-	__arrayVal(returnArray)[retI++] = t; __STORE(returnArray, t);
-	t = __MKBYTEARRAY((char *)ifaLoop->ifa_addr, len);
-	__arrayVal(returnArray)[retI++] = t; __STORE(returnArray, t);
-	if (ifaLoop->ifa_netmask != 0) {
-	    t = __MKBYTEARRAY((char *)ifaLoop->ifa_netmask, len);
-	    __arrayVal(returnArray)[retI] = t; __STORE(returnArray, t);
-	}
-	retI++;
-	if (ifaLoop->ifa_dstaddr != 0) {
-	    t = __MKBYTEARRAY((char *)ifaLoop->ifa_dstaddr, len);
-	    __arrayVal(returnArray)[retI] = t; __STORE(returnArray, t);
-	}
-	retI++;
-    }
-
-    noOfIf = __mkSmallInteger(n_ifa);
+        case AF_PACKET:
+            len = sizeof(sockaddr_ll);
+            break;
+#endif
+        default:
+            /* skip */
+            continue;
+        };
+        t = __MKSTRING(ifaLoop->ifa_name);
+        __arrayVal(returnArray)[retI++] = t; __STORE(returnArray, t);
+        t = __MKUINT(ifaLoop->ifa_flags);
+        __arrayVal(returnArray)[retI++] = t; __STORE(returnArray, t);
+        t = __MKBYTEARRAY((char *)ifaLoop->ifa_addr, len);
+        __arrayVal(returnArray)[retI++] = t; __STORE(returnArray, t);
+        if (ifaLoop->ifa_netmask != 0) {
+            t = __MKBYTEARRAY((char *)ifaLoop->ifa_netmask, len);
+            __arrayVal(returnArray)[retI] = t; __STORE(returnArray, t);
+        }
+        retI++;
+        if ((ifaLoop->ifa_flags&IFF_POINTOPOINT) && ifaLoop->ifa_dstaddr != 0) {
+            t = __MKBYTEARRAY((char *)ifaLoop->ifa_dstaddr, len);
+            __arrayVal(returnArray)[retI++] = t; __STORE(returnArray, t);
+        } else if (retI++, ifaLoop->ifa_broadaddr != 0) {
+            t = __MKBYTEARRAY((char *)ifaLoop->ifa_broadaddr, len);
+            __arrayVal(returnArray)[retI] = t; __STORE(returnArray, t);
+        }
+        retI++;
+    }
 
 bad:
     freeifaddrs(ifap);
 
-#elif defined(SIOCGIFADDR) && defined(SIOCGIFCONF)
-
-    int             afinet_socket = -1;
-
-    struct ifconf   ifc;
-    struct ifreq    *ifr;
-    struct ifreq    ifreq;
-    unsigned char   buf[1024];
-    int             n_ifs, i, countOfIf;
-    OBJ             t;
-
-    /*
-    ** Open an INET socket
-    */
-
-    afinet_socket = socket(AF_INET, SOCK_DGRAM, 0);
-    if (afinet_socket < 0) {
-	goto bad;
-    }
-
-    /*
-    ** Get the list of network interfaces
-    */
-
-    ifc.ifc_len = sizeof (buf);
-    ifc.ifc_buf = (caddr_t) buf;
-
-    if (ioctl (afinet_socket, SIOCGIFCONF, (caddr_t) &ifc) < 0) {
-	close(afinet_socket);
-	error = __MKSTRING("ioctl(SIOCGIFCONF) failed");
-	goto bad;
-    }
-
-    n_ifs = ifc.ifc_len / sizeof (struct ifreq);
-
-    nameArray    = __ARRAY_NEW_INT(n_ifs);
-    addressArray = __ARRAY_NEW_INT(n_ifs);
-
-    if (nameArray == nil || addressArray == nil) {
-	/* Creating a string wouldn/t work here */
-	error = @symbol(allocationFailure);
-	goto bad;
-    }
-
-    /*
-    ** Iterate of the list of the system's netif. Find all
-    ** active interfaces and their ethernet addresses
-    */
-    countOfIf = 0;
-
-    for (i=0, ifr = ifc.ifc_req; i < n_ifs; i++, ifr++) {
-	/*
-	** Get address for this interface
-	*/
-	memset (&ifreq, 0, sizeof(ifreq));
-	memcpy (ifreq.ifr_name, ifr->ifr_name, sizeof(ifr->ifr_name));
-	if (ioctl (afinet_socket, SIOCGIFADDR, &ifreq) >= 0) {
-	    t = __MKBYTEARRAY((char *)&ifreq.ifr_addr, sizeof(ifreq.ifr_addr));
-	    __arrayVal(addressArray)[countOfIf] = t; __STORE(addressArray, t);
-	    t = __MKSTRING(&ifreq.ifr_name);
-	    __arrayVal(nameArray)[countOfIf] = t; __STORE(nameArray, t);
-	    countOfIf++;
-	} else {
-	    if (@global(InfoPrinting) == true) {
-		fprintf(stderr, "OS [warning]: SIOCGIFADDR failed: %d\n", errno);
-	    }
-	}
-	error = __MKSTRING("ioctl(SIOCGIFCONF) failed");
-    }
-
-    noOfIf = __mkSmallInteger(countOfIf);
-bad:
-    if (afinet_socket >= 0)
-	close(afinet_socket);
 #else
     error = @symbol(notSupported);
-#endif /* defined(SIOCGIFADDR) */
+#endif
 out:;
 %}.
 
+    error notNil ifTrue:[
+        self primitiveFailed:error.
+        "return empty dictionary if proceeding from error"
+        ^  Dictionary new.
+    ].
+
     retDictionary := Dictionary new:noOfIf.
-    error notNil ifTrue:[
-	self primitiveFailed:error.
-	"return empty dictionary if proceeding from error"
-	^  retDictionary.
-    ].
-
     retIndex := 1.
 
     1 to:noOfIf do:[:cnt|
-	|name addressBytes set dict|
-
-	name := returnArray at:retIndex.
-	addressBytes := returnArray at:retIndex+2.
-
-	addressBytes notNil ifTrue:[
-	    set := retDictionary at:name ifAbsentPut:[Set new].
-	    dict := Dictionary new:5.
-	    dict at:#flags put:(returnArray at:retIndex+1).
-	    dict at:#address put:(SocketAddress fromBytes:addressBytes).
-	    addressBytes := returnArray at:retIndex+3.
-	    addressBytes notNil ifTrue:[
-		dict at:#netMask put:(SocketAddress fromBytes:addressBytes).
-	    ].
-	    addressBytes := returnArray at:retIndex+4.
-	    addressBytes notNil ifTrue:[
-		dict at:#destAddress put:(SocketAddress fromBytes:addressBytes).
-	    ].
-	    set add:dict.
-	].
-	retIndex := retIndex + 5.
+        |name addressBytes set dict|
+
+        name := returnArray at:retIndex.
+        addressBytes := returnArray at:retIndex+2.
+
+        addressBytes notNil ifTrue:[
+            set := retDictionary at:name ifAbsentPut:[Set new].
+            dict := Dictionary new:5.
+            dict at:#flags put:(returnArray at:retIndex+1).
+            dict at:#address put:(SocketAddress fromBytes:addressBytes).
+            addressBytes := returnArray at:retIndex+3.
+            addressBytes notNil ifTrue:[
+                dict at:#netMask put:(SocketAddress fromBytes:addressBytes).
+            ].
+            addressBytes := returnArray at:retIndex+4.
+            addressBytes notNil ifTrue:[
+                dict at:#destAddress put:(SocketAddress fromBytes:addressBytes).
+            ].
+            addressBytes := returnArray at:retIndex+5.
+            addressBytes notNil ifTrue:[
+                dict at:#broadcastAddress put:(SocketAddress fromBytes:addressBytes).
+            ].
+            set add:dict.
+        ].
+        retIndex := retIndex + 6.
     ].
 
     ^ retDictionary
@@ -9585,7 +9515,7 @@
      Codeset := #'utf8-mac'.
      CodesetEncoder := nil.
      OperatingSystem getCodesetEncoder
-     OperatingSystem encodePath:'äöü'
+     OperatingSystem encodePath:'äöü'
     "
 
     "Modified: / 23-01-2013 / 10:00:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -10732,20 +10662,6 @@
     ^ self isChildProcessWaitBlocking
 !
 
-isChildProcessWaitBlocking
-     "return true, if childProcessWait: blocks, if no children are ready.
-      On those systems, we must be somewhat careful when looking out for
-      a subprocesses status (to avoid blocking)."
-
-%{ /*NOCONTEXT*/
-#if defined(HAS_WAITPID) || defined(HAS_WAIT3)
-    RETURN(false);
-#else
-    RETURN(true);
-#endif
-%}
-!
-
 childProcessWait:blocking pid:pidToWait
     "{ Pragma: +optSpace }"
 
@@ -10906,6 +10822,20 @@
     ^ self primitiveFailed
 !
 
+isChildProcessWaitBlocking
+     "return true, if childProcessWait: blocks, if no children are ready.
+      On those systems, we must be somewhat careful when looking out for
+      a subprocesses status (to avoid blocking)."
+
+%{ /*NOCONTEXT*/
+#if defined(HAS_WAITPID) || defined(HAS_WAIT3)
+    RETURN(false);
+#else
+    RETURN(true);
+#endif
+%}
+!
+
 numAvailableForReadOn:fd
     "return the number of bytes available for reading, without blocking."
 
@@ -13098,7 +13028,7 @@
 	    domain:#'AF_INET' type:nil protocol:nil flags:nil
      self getAddressInfo:'www.exept.de' serviceName:nil
 	    domain:#'AF_INET6' type:nil protocol:nil flags:nil
-     self getAddressInfo:'www.baden-württemberg.de' serviceName:nil
+     self getAddressInfo:'www.baden-württemberg.de' serviceName:nil
 	    domain:#'AF_INET' type:#stream protocol:nil flags:nil
     "
 !