OSSP CVS Repository

ossp - Difference in ossp-pkg/sa/sa.c versions 1.58 and 1.59
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/sa/sa.c 1.58 -> 1.59

--- sa.c 2002/03/15 10:47:36     1.58
+++ sa.c 2002/10/11 15:27:39     1.59
@@ -240,10 +240,17 @@
     struct in_addr in_val;
 
     if (family == AF_INET) {
+#if defined(HAVE_INET_ATON)
         /* at least for IPv4 we can rely on the old inet_aton(3)
            and for IPv6 inet_pton(3) would exist anyway */
         if (inet_aton(strptr, &in_val) == 0)
             return 0;
+#elif defined(HAVE_INET_ADDR)
+        /* at least for IPv4 try to rely on the even older inet_addr(3) */
+        memset(&in_val, '\0', sizeof(in_val));
+        if ((in_val.s_addr = inet_addr(strptr)) == ((in_addr_t)-1))
+            return 0;
+#endif
         memcpy(addrptr, &in_val, sizeof(struct in_addr));
         return 1;
     }
@@ -258,14 +265,14 @@
 #ifdef HAVE_INET_NTOP
     return inet_ntop(family, src, dst, size);
 #else
-    struct in_addr in_val;
     char *cp;
     int n;
 
     if (family == AF_INET) {
+#ifdef HAVE_INET_NTOA
         /* at least for IPv4 we can rely on the old inet_ntoa(3)
            and for IPv6 inet_ntop(3) would exist anyway */
-        if ((cp = inet_ntoa(src)) == NULL) 
+        if ((cp = inet_ntoa(*((struct in_addr *)src))) == NULL) 
             return NULL;
         n = strlen(cp);
         if (n > size-1)
@@ -273,6 +280,7 @@
         memcpy(dst, cp, n);
         dst[n] = '\0';
         return dst;
+#endif
     }
     errno = EAFNOSUPPORT;
     return NULL;
@@ -814,8 +822,8 @@
         ucp1 = (const unsigned char *)&(((struct sockaddr_in6 *)saa1->saBuf)->sin6_addr);
         ucp2 = (const unsigned char *)&(((struct sockaddr_in6 *)saa2->saBuf)->sin6_addr);
         nBits = 128;
-#endif
     }
+#endif
     else
         return SA_RC(SA_ERR_INT);
 
@@ -862,14 +870,14 @@
     if (sa->fdSocket != -1) {
         if (SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_READ])) {
             if (setsockopt(sa->fdSocket, SOL_SOCKET, SO_RCVTIMEO,
-                           &sa->tvTimeout[SA_TIMEOUT_READ],
-                           sizeof(sa->tvTimeout[SA_TIMEOUT_READ])) < 0)
+                           (const void *)(&sa->tvTimeout[SA_TIMEOUT_READ]),
+                           (socklen_t)(sizeof(sa->tvTimeout[SA_TIMEOUT_READ]))) < 0)
                 return SA_RC(SA_ERR_SYS);
         }
         if (SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_WRITE])) {
             if (setsockopt(sa->fdSocket, SOL_SOCKET, SO_SNDTIMEO,
-                           &sa->tvTimeout[SA_TIMEOUT_WRITE],
-                           sizeof(sa->tvTimeout[SA_TIMEOUT_WRITE])) < 0)
+                           (const void *)(&sa->tvTimeout[SA_TIMEOUT_WRITE]),
+                           (socklen_t)(sizeof(sa->tvTimeout[SA_TIMEOUT_WRITE]))) < 0)
                 return SA_RC(SA_ERR_SYS);
         }
     }
@@ -1150,7 +1158,7 @@
                 break;
             }
             if (setsockopt(sa->fdSocket, IPPROTO_TCP, TCP_NODELAY, 
-                           (void *)&mode, sizeof(mode)) < 0)
+                           (const void *)&mode, (socklen_t)sizeof(mode)) < 0)
                 rv = SA_ERR_SYS;
 #else
             rv = SA_ERR_IMP;
@@ -1165,7 +1173,7 @@
                 break;
             }
             if (setsockopt(sa->fdSocket, SOL_SOCKET, SO_LINGER, 
-                           linger, sizeof(struct linger)) < 0)
+                           (const void *)linger, (socklen_t)sizeof(struct linger)) < 0)
                 rv = SA_ERR_SYS;
 #else
             rv = SA_ERR_IMP;
@@ -1192,7 +1200,7 @@
                 default: flag = 0; break;
             }
             if (setsockopt(sa->fdSocket, SOL_SOCKET, flag, 
-                           (void *)&mode, sizeof(mode)) < 0)
+                           (const void *)&mode, (socklen_t)sizeof(mode)) < 0)
                 rv = SA_ERR_SYS;
             break;
         }
@@ -1349,7 +1357,7 @@
 
         /* fetch pending error */
         len = sizeof(error);
-        if (getsockopt(sa->fdSocket, SOL_SOCKET, SO_ERROR, &error, &len) < 0)
+        if (getsockopt(sa->fdSocket, SOL_SOCKET, SO_ERROR, (void *)&error, &len) < 0)
             error = errno;
 
         done:

CVSTrac 2.0.1