OSSP CVS Repository

ossp - Check-in [1138]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 1138
Date: 2001-Oct-10 09:42:26 (local)
2001-Oct-10 07:42:26 (UTC)
User:rse
Branch:
Comment: Change

   sa_rc_t sa_buffers      (sa_t *sa, size_t rsize, size_t wsize);

to sa_rc_t sa_buffer (sa_t *sa, sa_buffer_t id, size_t size);

in order to make this API function more flexible.

Tickets:
Inspections:
Files:
ossp-pkg/sa/TODO      1.18 -> 1.19     1 inserted, 5 deleted
ossp-pkg/sa/sa.c      1.25 -> 1.26     42 inserted, 38 deleted
ossp-pkg/sa/sa.h      1.20 -> 1.21     7 inserted, 1 deleted
ossp-pkg/sa/sa.pod      1.9 -> 1.10     2 inserted, 2 deleted

ossp-pkg/sa/TODO 1.18 -> 1.19

--- TODO 2001/10/09 18:55:47     1.18
+++ TODO 2001/10/10 07:42:26     1.19
@@ -1,12 +1,8 @@
 
 - support for writev(2)
 - perhaps move 1024-buffer of writef into sa_t and make adjustable
-- sa_buffer(sa, <which>, size)
-  SA_BUFFER_UREAD
-  SA_BUFFER_UWRITE
-  SA_BUFFER_KREAD
+- SA_BUFFER_KREAD
   SA_BUFFER_KWRITE
-  SA_BUFFER_WRITEF
 - full test suite for whole API
   - inet://0.0.0.0:0 -> inet://0.0.0.0:514
   - inet://127.0.0.1:514 -> inet://127.0.0.1:514


ossp-pkg/sa/sa.c 1.25 -> 1.26

--- sa.c 2001/10/09 20:19:58     1.25
+++ sa.c 2001/10/10 07:42:26     1.26
@@ -1005,7 +1005,7 @@
 }
 
 /* configure I/O buffers */
-sa_rc_t sa_buffers(sa_t *sa, size_t rsize, size_t wsize)
+sa_rc_t sa_buffer(sa_t *sa, sa_buffer_t id, size_t size)
 {
     char *cp;
 
@@ -1013,45 +1013,49 @@
     if (sa == NULL)
         return SA_ERR_ARG;
 
-    /* make sure buffered were already flushed sufficiently */
-    if (sa->nReadLen > rsize || sa->nWriteLen > wsize)
-        return SA_ERR_USE;
-
-    /* configure read/incoming buffer */
-    if (rsize > 0) {
-        if (sa->cpReadBuf == NULL)
-            cp = (char *)malloc(rsize);
-        else
-            cp = (char *)realloc(sa->cpReadBuf, rsize);
-        if (cp == NULL)
-            return SA_ERR_SYS;
-        sa->cpReadBuf = cp;
-        sa->nReadSize = rsize;
-    }
-    else {
-        if (sa->cpReadBuf != NULL)
-            free(sa->cpReadBuf);
-        sa->cpReadBuf = NULL;
-        sa->nReadSize = 0;
+    if (id == SA_BUFFER_READ) {
+        /* configure read/incoming buffer */
+        if (sa->nReadLen > size)
+            return SA_ERR_USE;
+        if (size > 0) {
+            if (sa->cpReadBuf == NULL)
+                cp = (char *)malloc(size);
+            else
+                cp = (char *)realloc(sa->cpReadBuf, size);
+            if (cp == NULL)
+                return SA_ERR_SYS;
+            sa->cpReadBuf = cp;
+            sa->nReadSize = size;
+        }
+        else {
+            if (sa->cpReadBuf != NULL)
+                free(sa->cpReadBuf);
+            sa->cpReadBuf = NULL;
+            sa->nReadSize = 0;
+        }
     }
-
-    /* configure write/outgoing buffer */
-    if (wsize > 0) {
-        if (sa->cpWriteBuf == NULL)
-            cp = (char *)malloc(wsize);
-        else
-            cp = (char *)realloc(sa->cpWriteBuf, wsize);
-        if (cp == NULL)
-            return SA_ERR_SYS;
-        sa->cpWriteBuf = cp;
-        sa->nWriteSize = wsize;
-    }
-    else {
-        if (sa->cpWriteBuf != NULL)
-            free(sa->cpWriteBuf);
-        sa->cpWriteBuf = NULL;
-        sa->nWriteSize = 0;
+    else if (id == SA_BUFFER_WRITE) {
+        /* configure write/outgoing buffer */
+        if (sa->nWriteLen > size)
+            return SA_ERR_USE;
+        if (size > 0) {
+            if (sa->cpWriteBuf == NULL)
+                cp = (char *)malloc(size);
+            else
+                cp = (char *)realloc(sa->cpWriteBuf, size);
+            if (cp == NULL)
+                return SA_ERR_SYS;
+            sa->cpWriteBuf = cp;
+            sa->nWriteSize = size;
+        }
+        else {
+            if (sa->cpWriteBuf != NULL)
+                free(sa->cpWriteBuf);
+            sa->cpWriteBuf = NULL;
+            sa->nWriteSize = 0;
+        }
     }
+        return SA_ERR_ARG;
 
     return SA_OK;
 }


ossp-pkg/sa/sa.h 1.20 -> 1.21

--- sa.h 2001/10/09 20:19:58     1.20
+++ sa.h 2001/10/10 07:42:26     1.21
@@ -124,6 +124,12 @@
     SA_TIMEOUT_WRITE    = 3
 } sa_timeout_t;
 
+/* list of buffers */
+typedef enum {
+    SA_BUFFER_READ,
+    SA_BUFFER_WRITE
+} sa_buffer_t;
+
 /* list of system calls */
 typedef enum {
     SA_SYSCALL_CONNECT,
@@ -153,7 +159,7 @@
 /* socket parameter operations */
 sa_rc_t sa_type         (sa_t *sa, sa_type_t type);
 sa_rc_t sa_timeout      (sa_t *sa, sa_timeout_t id, long sec, long usec);
-sa_rc_t sa_buffers      (sa_t *sa, size_t rsize, size_t wsize);
+sa_rc_t sa_buffer       (sa_t *sa, sa_buffer_t  id, size_t size);
 sa_rc_t sa_syscall      (sa_t *sa, sa_syscall_t id, void (*fptr)(), void *fctx);
 
 /* socket connection operations */


ossp-pkg/sa/sa.pod 1.9 -> 1.10

--- sa.pod       2001/10/09 13:19:25     1.9
+++ sa.pod       2001/10/10 07:42:26     1.10
@@ -65,7 +65,7 @@
 =item B<Socket Parameter Operations>:
 
 sa_timeout,
-sa_buffers. 
+sa_buffer. 
             
 =item B<Socket Connection Operations>:
 
@@ -220,7 +220,7 @@
 
 =item sa_rc_t B<sa_timeout>(sa_t *I<sa>, long I<sec>, long I<usec>);
 
-=item sa_rc_t B<sa_buffers>(sa_t *I<sa>, size_t I<rsize>, size_t I<wsize>);
+=item sa_rc_t B<sa_buffer>(sa_t *I<sa>, sa_buffer_t id, size_t I<size>);
 
 =item sa_rc_t B<sa_getoption>(sa_t *I<sa>, int I<optname>, void *I<optval>, socklen_t *I<optlen>);
 

CVSTrac 2.0.1