OSSP CVS Repository

ossp - Difference in ossp-pkg/xds/init.c versions 1.1 and 1.2
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/xds/init.c 1.1 -> 1.2

--- init.c       2001/07/04 15:58:51     1.1
+++ init.c       2001/07/04 16:21:26     1.2
@@ -26,10 +26,34 @@
 */
 
 #include <stdlib.h>
+#include <errno.h>
+#include <assert.h>
 #include "internal.h"
 
 xds_t* xds_init(xds_mode_t mode)
     {
-    xds_t* ctx = calloc(1, sizeof(struct xds_context));
-    return NULL;
+    xds_t* ctx;
+
+    /* Sanity check parameter. */
+
+    assert(mode == XDS_ENCODE || mode == XDS_DECODE);
+    if (mode != XDS_ENCODE && mode != XDS_DECODE)
+        {
+        errno = EINVAL;
+        return NULL;
+        }
+
+    /* Allocate context structure. */
+
+    ctx = calloc(1, sizeof(struct xds_context));
+    if (ctx == NULL)
+        return NULL;            /* errno is set by calloc() */
+
+    /* Set mode of operation in context. */
+
+    ctx->mode = mode;
+
+    /* We are initialized. */
+
+    return ctx;
     }

CVSTrac 2.0.1