OSSP CVS Repository

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

ossp-pkg/sa/sa.c 1.61 -> 1.62

--- sa.c 2002/10/26 11:11:05     1.61
+++ sa.c 2002/10/26 15:45:32     1.62
@@ -205,7 +205,7 @@
     SA_SC_DECLARE_6(ssize_t, recvfrom, int, void *, size_t, int, struct sockaddr *, socklen_t *)
     SA_SC_DECLARE_6(ssize_t, sendto,   int, const void *, size_t, int, const struct sockaddr *, socklen_t)
 } sa_syscall_tab_t;
- 
+
 /* socket abstraction object */
 struct sa_st {
     sa_type_t        eType;            /* socket type (stream or datagram) */
@@ -272,7 +272,7 @@
 #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(*((struct in_addr *)src))) == NULL) 
+        if ((cp = inet_ntoa(*((struct in_addr *)src))) == NULL)
             return NULL;
         n = strlen(cp);
         if (n > size-1)
@@ -291,7 +291,7 @@
 static int sa_mvxprintf(int (*output)(void *ctx, const char *buffer, size_t bufsize), void *ctx, const char *format, va_list ap)
 {
     /* sufficient integer buffer: <available-bits> x log_10(2) + safety */
-    char ibuf[((sizeof(int)*8)/3)+10]; 
+    char ibuf[((sizeof(int)*8)/3)+10];
     char *cp;
     char c;
     int d;
@@ -384,7 +384,7 @@
         return -1;
     if (buffer != NULL && bufsize == 0)
         return -1;
-    if (buffer == NULL) 
+    if (buffer == NULL)
         /* just determine output length */
         n = sa_mvxprintf(NULL, NULL, format, ap);
     else {
@@ -491,7 +491,7 @@
     sl = 0;
     sf = 0;
 
-    /* parse URI and resolve contents. 
+    /* parse URI and resolve contents.
        The following syntax is recognized:
        - unix:<path>
        - inet://<host>:<port>[#(tcp|udp)] */
@@ -611,7 +611,7 @@
             else if (he->h_addrtype == AF_INET6) {
                 sa6.sin6_family = AF_INET6;
                 sa6.sin6_port = htons(nPort);
-                memcpy(&sa6.sin6_addr.s6_addr, he->h_addr_list[0], 
+                memcpy(&sa6.sin6_addr.s6_addr, he->h_addr_list[0],
                        sizeof(sa6.sin6_addr.s6_addr));
                 sa = (struct sockaddr *)&sa6;
                 sl = sizeof(sa6);
@@ -693,7 +693,7 @@
             || saa->slBuf < sizeof(struct sockaddr_un))
             /* in case the remote side of a Unix Domain socket was not
                bound, a "struct sockaddr_un" can occur with a length less
-               than the expected one. Then there is actually no path at all. 
+               than the expected one. Then there is actually no path at all.
                This has been verified under FreeBSD, Linux and Solaris. */
             sa_msnprintf(uribuf, sizeof(uribuf), "unix:/NOT-BOUND");
         else
@@ -782,7 +782,7 @@
 #ifdef AF_INET6
     else if (   (saa1->nFamily == AF_INET  && saa2->nFamily == AF_INET6)
              || (saa1->nFamily == AF_INET6 && saa2->nFamily == AF_INET )) {
-        /* special case of comparing a regular IPv4 address (1.2.3.4) with an 
+        /* special case of comparing a regular IPv4 address (1.2.3.4) with an
            "IPv4-mapped IPv6 address" (::ffff:1.2.3.4). For details see RFC 2373. */
         if (saa1->nFamily == AF_INET6) {
             np1  = (unsigned int)(((struct sockaddr_in6 *)saa1->saBuf)->sin6_port);
@@ -839,7 +839,7 @@
         prefixlen = nBits;
     }
 
-    /* perform address representation comparison 
+    /* perform address representation comparison
        (assumption guaranteed by API: network byte order is used) */
     nBytes = (prefixlen / 8);
     nBits  = (prefixlen % 8);
@@ -911,7 +911,7 @@
         return SA_RC(SA_ERR_INT);
 
     /* determine socket protocol */
-    if (nFamily == AF_LOCAL) 
+    if (nFamily == AF_LOCAL)
         nProto = 0;
 #ifdef AF_INET6
     else if (nFamily == AF_INET || nFamily == AF_INET6) {
@@ -1157,7 +1157,7 @@
                 rv = SA_ERR_USE;
                 break;
             }
-            if (setsockopt(sa->fdSocket, IPPROTO_TCP, TCP_NODELAY, 
+            if (setsockopt(sa->fdSocket, IPPROTO_TCP, TCP_NODELAY,
                            (const void *)&mode, (socklen_t)sizeof(mode)) < 0)
                 rv = SA_ERR_SYS;
 #else
@@ -1172,7 +1172,7 @@
                 rv = SA_ERR_USE;
                 break;
             }
-            if (setsockopt(sa->fdSocket, SOL_SOCKET, SO_LINGER, 
+            if (setsockopt(sa->fdSocket, SOL_SOCKET, SO_LINGER,
                            (const void *)linger, (socklen_t)sizeof(struct linger)) < 0)
                 rv = SA_ERR_SYS;
 #else
@@ -1182,7 +1182,7 @@
         }
         case SA_OPTION_REUSEADDR:
 #ifdef SA_OPTION_REUSEPORT
-        case SA_OPTION_REUSEPORT: 
+        case SA_OPTION_REUSEPORT:
 #endif
         {
             /* enable/disable reusability of binding to address or port */
@@ -1199,7 +1199,7 @@
 #endif
                 default: flag = 0; break;
             }
-            if (setsockopt(sa->fdSocket, SOL_SOCKET, flag, 
+            if (setsockopt(sa->fdSocket, SOL_SOCKET, flag,
                            (const void *)&mode, (socklen_t)sizeof(mode)) < 0)
                 rv = SA_ERR_SYS;
             break;
@@ -1252,7 +1252,7 @@
         case SA_SYSCALL_WRITE:    SA_SC_ASSIGN(sa, write,    fptr, fctx); break;
         case SA_SYSCALL_RECVFROM: SA_SC_ASSIGN(sa, recvfrom, fptr, fctx); break;
         case SA_SYSCALL_SENDTO:   SA_SC_ASSIGN(sa, sendto,   fptr, fctx); break;
-        default: rv = SA_ERR_ARG; 
+        default: rv = SA_ERR_ARG;
     }
 
     return SA_RC(rv);
@@ -1298,7 +1298,7 @@
     if (sa == NULL || raddr == NULL)
         return SA_RC(SA_ERR_ARG);
 
-    /* connecting is only possible for stream communication */ 
+    /* connecting is only possible for stream communication */
     if (sa->eType != SA_TYPE_STREAM)
         return SA_RC(SA_ERR_USE);
 
@@ -1331,7 +1331,7 @@
 
         /* ok if connect completed immediately */
         if (n == 0)
-            goto done; 
+            goto done;
 
         /* wait for read or write possibility */
         FD_ZERO(&rset);
@@ -1383,7 +1383,7 @@
     if (sa == NULL)
         return SA_RC(SA_ERR_ARG);
 
-    /* listening is only possible for stream communication */ 
+    /* listening is only possible for stream communication */
     if (sa->eType != SA_TYPE_STREAM)
         return SA_RC(SA_ERR_USE);
 
@@ -1419,7 +1419,7 @@
     if (sa == NULL || caddr == NULL || csa == NULL)
         return SA_RC(SA_ERR_ARG);
 
-    /* accepting connections is only possible for stream communication */ 
+    /* accepting connections is only possible for stream communication */
     if (sa->eType != SA_TYPE_STREAM)
         return SA_RC(SA_ERR_USE);
 
@@ -1435,7 +1435,7 @@
             n = SA_SC_CALL_5(sa, select, sa->fdSocket+1, &fds, NULL, NULL,
                              &sa->tvTimeout[SA_TIMEOUT_ACCEPT]);
         } while (n == -1 && errno == EINTR);
-        if (n == 0) 
+        if (n == 0)
             return SA_RC(SA_ERR_TMT);
         if (n <= 0)
             return SA_RC(SA_ERR_SYS);
@@ -1497,7 +1497,7 @@
     if (sa == NULL || raddr == NULL)
         return SA_RC(SA_ERR_ARG);
 
-    /* peers exist only for stream communication */ 
+    /* peers exist only for stream communication */
     if (sa->eType != SA_TYPE_STREAM)
         return SA_RC(SA_ERR_USE);
 
@@ -1582,14 +1582,14 @@
     fd_set fds;
 #endif
 
-    /* if timeout is enabled, perform explicit/smart blocking instead 
+    /* if timeout is enabled, perform explicit/smart blocking instead
        of implicitly/hard blocking in the read(2) system call */
 #if !(defined(SO_RCVTIMEO) && defined(SO_SNDTIMEO))
     if (!SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_READ])) {
         FD_ZERO(&fds);
         FD_SET(sa->fdSocket, &fds);
         do {
-            rv = SA_SC_CALL_5(sa, select, sa->fdSocket+1, &fds, NULL, NULL, 
+            rv = SA_SC_CALL_5(sa, select, sa->fdSocket+1, &fds, NULL, NULL,
                               &sa->tvTimeout[SA_TIMEOUT_READ]);
         } while (rv == -1 && errno == EINTR);
         if (rv == 0) {
@@ -1623,7 +1623,7 @@
     if (sa == NULL || cpBuf == NULL || nBufReq == 0)
         return SA_RC(SA_ERR_ARG);
 
-    /* reading is only possible for stream communication */ 
+    /* reading is only possible for stream communication */
     if (sa->eType != SA_TYPE_STREAM)
         return SA_RC(SA_ERR_USE);
 
@@ -1701,7 +1701,7 @@
         }
     }
 
-    /* pass number of actually read bytes to caller */ 
+    /* pass number of actually read bytes to caller */
     if (nBufRes != NULL)
         *nBufRes = (size_t)res;
 
@@ -1720,7 +1720,7 @@
     if (sa == NULL || cpBuf == NULL || nBufReq == 0)
         return SA_RC(SA_ERR_ARG);
 
-    /* reading is only possible for stream communication */ 
+    /* reading is only possible for stream communication */
     if (sa->eType != SA_TYPE_STREAM)
         return SA_RC(SA_ERR_USE);
 
@@ -1761,14 +1761,14 @@
     fd_set fds;
 #endif
 
-    /* if timeout is enabled, perform explicit/smart blocking instead 
+    /* if timeout is enabled, perform explicit/smart blocking instead
        of implicitly/hard blocking in the write(2) system call */
 #if !(defined(SO_RCVTIMEO) && defined(SO_SNDTIMEO))
     if (!SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_WRITE])) {
         FD_ZERO(&fds);
         FD_SET(sa->fdSocket, &fds);
         do {
-            rv = SA_SC_CALL_5(sa, select, sa->fdSocket+1, NULL, &fds, NULL, 
+            rv = SA_SC_CALL_5(sa, select, sa->fdSocket+1, NULL, &fds, NULL,
                               &sa->tvTimeout[SA_TIMEOUT_WRITE]);
         } while (rv == -1 && errno == EINTR);
         if (rv == 0) {
@@ -1802,7 +1802,7 @@
     if (sa == NULL || cpBuf == NULL || nBufReq == 0)
         return SA_RC(SA_ERR_ARG);
 
-    /* writing is only possible for stream communication */ 
+    /* writing is only possible for stream communication */
     if (sa->eType != SA_TYPE_STREAM)
         return SA_RC(SA_ERR_USE);
 
@@ -1884,7 +1884,7 @@
     if (sa == NULL || cpFmt == NULL)
         return SA_RC(SA_ERR_ARG);
 
-    /* writing is only possible for stream communication */ 
+    /* writing is only possible for stream communication */
     if (sa->eType != SA_TYPE_STREAM)
         return SA_RC(SA_ERR_USE);
 
@@ -1912,7 +1912,7 @@
     if (sa == NULL)
         return SA_RC(SA_ERR_ARG);
 
-    /* flushing is only possible for stream communication */ 
+    /* flushing is only possible for stream communication */
     if (sa->eType != SA_TYPE_STREAM)
         return SA_RC(SA_ERR_USE);
 
@@ -1948,7 +1948,7 @@
     if (sa == NULL || flags == NULL)
         return SA_RC(SA_ERR_ARG);
 
-    /* shutdown is only possible for stream communication */ 
+    /* shutdown is only possible for stream communication */
     if (sa->eType != SA_TYPE_STREAM)
         return SA_RC(SA_ERR_USE);
 
@@ -1992,7 +1992,7 @@
     if (sa == NULL || buf == NULL || buflen == 0 || raddr == NULL)
         return SA_RC(SA_ERR_ARG);
 
-    /* receiving is only possible for datagram communication */ 
+    /* receiving is only possible for datagram communication */
     if (sa->eType != SA_TYPE_DATAGRAM)
         return SA_RC(SA_ERR_USE);
 
@@ -2000,16 +2000,16 @@
     if (sa->fdSocket == -1)
         return SA_RC(SA_ERR_USE);
 
-    /* if timeout is enabled, perform explicit/smart blocking instead 
+    /* if timeout is enabled, perform explicit/smart blocking instead
        of implicitly/hard blocking in the recvfrom(2) system call */
     if (!SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_READ])) {
         FD_ZERO(&fds);
         FD_SET(sa->fdSocket, &fds);
         do {
-            n = SA_SC_CALL_5(sa, select, sa->fdSocket+1, &fds, NULL, NULL, 
+            n = SA_SC_CALL_5(sa, select, sa->fdSocket+1, &fds, NULL, NULL,
                              &sa->tvTimeout[SA_TIMEOUT_READ]);
         } while (n == -1 && errno == EINTR);
-        if (n == 0) 
+        if (n == 0)
             errno = ETIMEDOUT;
         if (n <= 0)
             return SA_RC(SA_ERR_SYS);
@@ -2017,7 +2017,7 @@
 
     /* perform receive operation on underlying socket */
     sa_len = sizeof(sa_buf);
-    if ((n = SA_SC_CALL_6(sa, recvfrom, sa->fdSocket, buf, buflen, 0, 
+    if ((n = SA_SC_CALL_6(sa, recvfrom, sa->fdSocket, buf, buflen, 0,
                           (struct sockaddr *)&sa_buf, &sa_len)) == -1)
         return SA_RC(SA_ERR_SYS);
 
@@ -2047,7 +2047,7 @@
     if (sa == NULL || buf == NULL || buflen == 0 || raddr == NULL)
         return SA_RC(SA_ERR_ARG);
 
-    /* sending is only possible for datagram communication */ 
+    /* sending is only possible for datagram communication */
     if (sa->eType != SA_TYPE_DATAGRAM)
         return SA_RC(SA_ERR_USE);
 
@@ -2056,16 +2056,16 @@
         if ((rv = sa_socket_init(sa, raddr->nFamily)) != SA_OK)
             return rv;
 
-    /* if timeout is enabled, perform explicit/smart blocking instead 
+    /* if timeout is enabled, perform explicit/smart blocking instead
        of implicitly/hard blocking in the sendto(2) system call */
     if (!SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_WRITE])) {
         FD_ZERO(&fds);
         FD_SET(sa->fdSocket, &fds);
         do {
-            n = SA_SC_CALL_5(sa, select, sa->fdSocket+1, NULL, &fds, NULL, 
+            n = SA_SC_CALL_5(sa, select, sa->fdSocket+1, NULL, &fds, NULL,
                              &sa->tvTimeout[SA_TIMEOUT_WRITE]);
         } while (n == -1 && errno == EINTR);
-        if (n == 0) 
+        if (n == 0)
             errno = ETIMEDOUT;
         if (n <= 0)
             return SA_RC(SA_ERR_SYS);

CVSTrac 2.0.1