OSSP CVS Repository

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

ossp-pkg/sa/sa.c 1.27 -> 1.28

--- sa.c 2001/10/10 09:05:18     1.27
+++ sa.c 2001/10/10 09:21:27     1.28
@@ -170,9 +170,6 @@
     int              nWriteLen;        /* write buffer current length */
     int              nWriteSize;       /* write buffer current size */
     char            *cpWriteBuf;       /* write buffer memory chunk */
-    char             szError[256];     /* error temporary buffer */
-    char             szErrorInfo[128]; /* error additional information text */
-    sa_rc_t          rvErrorInfo;      /* error additional information code */
     sa_syscall_tab_t scSysCall;        /* table of system calls */
 };
 
@@ -375,88 +372,6 @@
     return chars;
 }
 
-/* remember extra error information */
-static sa_rc_t sa_errorinfo(sa_t *sa, sa_rc_t rv, const char *fmt, ...)
-{
-    va_list ap;
-
-    /* argument sanity check */
-    if (sa == NULL)
-        return SA_ERR_ARG;
-
-    if (rv == SA_OK && fmt == NULL) {
-        /* reset error information */
-        sa->szErrorInfo[0] = '\0';
-        sa->rvErrorInfo = SA_OK;
-    }
-    else {
-        /* remember error information */
-        va_start(ap, fmt);
-        sa_mvsnprintf(sa->szErrorInfo, sizeof(sa->szErrorInfo), fmt, ap);
-        sa->rvErrorInfo = rv;
-        va_end(ap);
-    }
-    return SA_OK;
-}
-
-/* return error string */
-sa_rc_t sa_error(sa_t *sa, sa_rc_t rv, char **str)
-{
-    char *sz;
-    char *cpBuf;
-    int nBuf;
-    int n;
-
-    /* argument sanity check */
-    if (str == NULL)
-        return SA_ERR_ARG;
-
-    /* translate result value into corresponding string */
-    if      (rv == SA_OK)      sz = "everything ok";
-    else if (rv == SA_ERR_ARG) sz = "invalid argument";
-    else if (rv == SA_ERR_USE) sz = "invalid use or context";
-    else if (rv == SA_ERR_MEM) sz = "not enough memory available";
-    else if (rv == SA_ERR_MTC) sz = "matching operation failed";
-    else if (rv == SA_ERR_EOF) sz = "communication end";
-    else if (rv == SA_ERR_TMT) sz = "communication timeout";
-    else if (rv == SA_ERR_SYS) sz = "operating system error";
-    else if (rv == SA_ERR_INT) sz = "internal error";
-    else
-        return SA_ERR_ARG;
-
-    /* if no context is available we have to stop */
-    if (sa == NULL) {
-        *str = sz;
-        return SA_OK;
-    }
-
-    /* start at begin of buffer */
-    cpBuf = sa->szError;
-    nBuf  = sizeof(sa->szError);
-    n = sa_msnprintf(cpBuf, nBuf, "%s", sz);
-    cpBuf += n;
-    nBuf  -= n;
-
-    /* optionally annotate with error information */
-    if (rv == sa->rvErrorInfo && sa->szErrorInfo[0] != '\0') {
-        n = sa_msnprintf(cpBuf, nBuf, "; %s", sa->szErrorInfo);
-        cpBuf += n;
-        nBuf  -= n;
-        sa_errorinfo(sa, SA_OK, NULL);
-    }
-
-    /* optionally annotate with operating system error information */
-    if (rv == SA_ERR_SYS) {
-        n = sa_msnprintf(cpBuf, nBuf, "; %s (%d)", strerror(errno), errno);
-        cpBuf += n;
-        nBuf  -= n;
-    }
-
-    /* return pointer to internal buffer */
-    *str = sa->szError;
-    return SA_OK;
-}
-
 /* create address object */
 sa_rc_t sa_addr_create(sa_addr_t **saap)
 {
@@ -639,12 +554,14 @@
                 sf = AF_INET6;
             }
 #endif
+            else
+                return SA_ERR_ARG;
         }
+        else
+            return SA_ERR_ARG;
     }
-
-    /* make sure result variables are set */
-    if (sa == NULL || sl == 0 || sf == 0)
-        return SA_ERR_INT;
+    else
+        return SA_ERR_ARG;
 
     /* fill-in result address structure */
     if (saa->saBuf != NULL)
@@ -965,9 +882,6 @@
     sa->nWriteLen      = 0;
     sa->nWriteSize     = 0;
     sa->cpWriteBuf     = NULL;
-    sa->szError[0]     = '\0';
-    sa->szErrorInfo[0] = '\0';
-    sa->rvErrorInfo    = SA_OK;
 
     /* init timeval object attributes */
     for (i = 0; i < (sizeof(sa->tvTimeout)/sizeof(sa->tvTimeout[0])); i++) {
@@ -1952,3 +1866,22 @@
     return SA_OK;
 }
 
+/* return error string */
+char *sa_error(sa_rc_t rv)
+{
+    char *sz;
+
+    /* translate result value into corresponding string */
+    if      (rv == SA_OK)      sz = "Everything Ok";
+    else if (rv == SA_ERR_ARG) sz = "Invalid Argument";
+    else if (rv == SA_ERR_USE) sz = "Invalid Use Or Context";
+    else if (rv == SA_ERR_MEM) sz = "Not Enough Memory";
+    else if (rv == SA_ERR_MTC) sz = "Matching Failed";
+    else if (rv == SA_ERR_EOF) sz = "End Of Communication";
+    else if (rv == SA_ERR_TMT) sz = "Communication Timeout";
+    else if (rv == SA_ERR_SYS) sz = "Operating System Error";
+    else if (rv == SA_ERR_INT) sz = "Internal Error";
+    else                       sz = "Invalid Result Code";
+    return sz;
+}
+

CVSTrac 2.0.1