OSSP CVS Repository

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

Check-in Number: 4252
Date: 2001-Aug-01 13:26:16 (local)
2001-Aug-01 11:26:16 (UTC)
User:simons
Branch:callback-semantic-rewrite
Comment: Rewrote framework for new callback semantics: Callbacks now return an XDS_* code all the time. The length of the buffer used by the callback is returned via used_buffer_size. If the buffer is too small, XDS_ERR_OVERFLOW is returned.
Tickets:
Inspections:
Files:
ossp-pkg/xds/vdecode.c      1.4.2.1 -> 1.4.2.2     6 inserted, 3 deleted
ossp-pkg/xds/vencode.c      1.12.2.1 -> 1.12.2.2     20 inserted, 33 deleted

ossp-pkg/xds/vdecode.c 1.4.2.1 -> 1.4.2.2

--- vdecode.c    2001/08/01 09:55:58     1.4.2.1
+++ vdecode.c    2001/08/01 11:26:16     1.4.2.2
@@ -70,17 +70,20 @@
         if (strlen(name) > 0)
             {
             size_t pos;
+            size_t used_buffer_size;
             if (xds_find_engine(xds->engines, xds->engines_len, name, &pos))
                 {
                 rc = (*xds->engines[pos].engine)(xds,
                                                  xds->engines[pos].context,
                                                  xds->buffer + xds->buffer_len,
                                                  xds->buffer_capacity - xds->buffer_len,
+                                                 &used_buffer_size,
                                                  &args);
-                if (rc < 0)
-                    goto leave;
+                assert(rc <= 0);
+                if (rc == XDS_OK)
+                    xds->buffer_len += used_buffer_size;
                 else
-                    xds->buffer_len += rc;
+                    goto leave;
                 }
             else
                 {


ossp-pkg/xds/vencode.c 1.12.2.1 -> 1.12.2.2

--- vencode.c    2001/08/01 09:55:58     1.12.2.1
+++ vencode.c    2001/08/01 11:26:16     1.12.2.2
@@ -105,6 +105,7 @@
             if (xds_find_engine(xds->engines, xds->engines_len, name, &pos))
                 {
                 int restart_engine;
+                size_t used_buffer_size;
                 do
                     {
                     args_backup = args;
@@ -112,47 +113,33 @@
                                                      xds->engines[pos].context,
                                                      xds->buffer + xds->buffer_len,
                                                      xds->buffer_capacity - xds->buffer_len,
+                                                     &used_buffer_size,
                                                      &args);
-                    if (rc < 0)
-                        goto leave;
-                    else if (rc >= xds->buffer_capacity - xds->buffer_len)
+                    assert(rc <= 0);
+                    if (rc == XDS_OK)
+                        {
+                        restart_engine = XDS_FALSE;
+                        xds->buffer_len += used_buffer_size;
+                        }
+                    else if (rc == XDS_ERR_OVERFLOW)
                         {               /* enlarge buffer */
-                        int rc2;
-
-                        if (rc > xds->buffer_capacity - xds->buffer_len)
-                            {
-                            restart_engine = XDS_TRUE;
-                            args = args_backup;
-                            }
-                        else
-                            {
-                            restart_engine = XDS_FALSE;
-                            xds->buffer_len += rc;
-                            }
-
                         if (!xds->we_own_buffer)
-                            {
-                            rc = XDS_ERR_OVERFLOW;
                             goto leave;
-                            }
 
-                        rc2 = xds_set_capacity((void**)&xds->buffer,
-                                               &xds->buffer_capacity,
-                                               xds->buffer_capacity + rc,
-                                               sizeof(char),
-                                               XDS_INITIAL_BUFFER_CAPACITY);
-                        assert(rc2 == XDS_OK || rc2 == XDS_ERR_NO_MEM);
-                        if (rc2 != XDS_OK)
-                            {
-                            rc = rc2;
+                        restart_engine = XDS_TRUE;
+                        args = args_backup;
+
+                        rc = xds_set_capacity((void**)&xds->buffer,
+                                              &xds->buffer_capacity,
+                                              xds->buffer_capacity + 1,
+                                              sizeof(char),
+                                              XDS_INITIAL_BUFFER_CAPACITY);
+                        assert(rc == XDS_OK || rc == XDS_ERR_NO_MEM);
+                        if (rc != XDS_OK)
                             goto leave;
-                            }
                         }
                     else
-                        {
-                        restart_engine = XDS_FALSE;
-                        xds->buffer_len += rc;
-                        }
+                        goto leave;
                     }
                 while (restart_engine);
                 }

CVSTrac 2.0.1