OSSP CVS Repository

ossp - Difference in ossp-pkg/val/val.c versions 1.8 and 1.9
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/val/val.c 1.8 -> 1.9

--- val.c        2002/01/24 15:30:58     1.8
+++ val.c        2002/01/30 18:55:23     1.9
@@ -50,6 +50,19 @@
 #define TRUE  (!FALSE)
 #endif
 
+/* unique library identifier */
+const char val_id[] = "OSSP sa";
+
+/* support for OSSP ex based exception throwing */
+#ifdef WITH_EX
+#include "ex.h"
+#define VAL_RC(rv) \
+    (  (rv) != VAL_OK && (ex_catching && !ex_shielding) \
+     ? (ex_throw(val_id, NULL, (rv)), (rv)) : (rv) )
+#else
+#define VAL_RC(rv) (rv)
+#endif /* WITH_EX */
+
 /*
 **  ____                            ____
 **  ____ LINEAR HASHING SUB-LIBRARY ____
@@ -629,16 +642,16 @@
 
     /* argument consistency check */
     if (pval == NULL)
-        return VAL_ERR_ARG;
+        return VAL_RC(VAL_ERR_ARG);
 
     /* create top-level structure */
     if ((val = (val_t *)malloc(sizeof(val_t))) == NULL)
-        return VAL_ERR_SYS;
+        return VAL_RC(VAL_ERR_SYS);
 
     /* create hash table */
     if ((val->lh = lh_create()) == NULL) {
         free(val);
-        return VAL_ERR_SYS;
+        return VAL_RC(VAL_ERR_SYS);
     }
 
     /* pass result to caller */
@@ -667,14 +680,14 @@
 {
     /* argument consistency check */
     if (val == NULL)
-        return VAL_ERR_ARG;
+        return VAL_RC(VAL_ERR_ARG);
 
     /* destroy all hash table elements */
     lh_apply(val->lh, val_destroy_cb, NULL);
 
     /* destroy hash table */
     if (!lh_destroy(val->lh))
-        return VAL_ERR_SYS;
+        return VAL_RC(VAL_ERR_SYS);
 
     /* destroy top-level structure */
     free(val);
@@ -692,14 +705,14 @@
 
     /* argument consistency check */
     if (val == NULL || name == NULL || type == 0)
-        return VAL_ERR_ARG;
+        return VAL_RC(VAL_ERR_ARG);
 
     /* recursive step-down on structured name */
     if ((cp = strchr(name, '.')) != NULL) {
         if (!lh_lookup(val->lh, name, cp-name, (void **)&obj, NULL))
-            return VAL_ERR_ARG;
+            return VAL_RC(VAL_ERR_ARG);
         if (!(obj->type & VAL_TYPE_VAL))
-            return VAL_ERR_USE;
+            return VAL_RC(VAL_ERR_USE);
         child = *(val_t **)(val_storage(obj));
         return val_reg(child, cp+1, type, desc, storage);
     }
@@ -720,7 +733,7 @@
 
     /* insert value into hash table */
     if (!lh_insert(val->lh, name, strlen(name), &newobj, sizeof(newobj), 1))
-        return VAL_ERR_HSH;
+        return VAL_RC(VAL_ERR_HSH);
 
     return VAL_OK;
 }
@@ -733,21 +746,21 @@
 
     /* argument consistency check */
     if (val == NULL || name == NULL)
-        return VAL_ERR_ARG;
+        return VAL_RC(VAL_ERR_ARG);
 
     /* recursive step-down on structured name */
     if ((cp = strchr(name, '.')) != NULL) {
         if (!lh_lookup(val->lh, name, cp-name, (void **)&obj, NULL))
-            return VAL_ERR_ARG;
+            return VAL_RC(VAL_ERR_ARG);
         if (!(obj->type & VAL_TYPE_VAL))
-            return VAL_ERR_USE;
+            return VAL_RC(VAL_ERR_USE);
         child = *(val_t **)(val_storage(obj));
         return val_unreg(child, cp+1);
     }
 
     /* try to lookup object in hash table */
     if (!lh_lookup(val->lh, name, strlen(name), (void **)&obj, NULL))
-        return VAL_ERR_ARG;
+        return VAL_RC(VAL_ERR_ARG);
 
     /* destroy value object */
     if (obj->desc != NULL)
@@ -755,7 +768,7 @@
 
     /* delete value from hash table */
     if (!lh_delete(val->lh, name, strlen(name)))
-        return VAL_ERR_HSH;
+        return VAL_RC(VAL_ERR_HSH);
 
     return VAL_OK;
 }
@@ -770,21 +783,21 @@
 
     /* argument consistency check */
     if (val == NULL || name == NULL)
-        return VAL_ERR_ARG;
+        return VAL_RC(VAL_ERR_ARG);
 
     /* recursive step-down on structured name */
     if ((cp = strchr(name, '.')) != NULL) {
         if (!lh_lookup(val->lh, name, cp-name, (void **)&obj, NULL))
-            return VAL_ERR_ARG;
+            return VAL_RC(VAL_ERR_ARG);
         if (!(obj->type & VAL_TYPE_VAL))
-            return VAL_ERR_USE;
+            return VAL_RC(VAL_ERR_USE);
         child = *(val_t **)(val_storage(obj));
         return val_query(child, cp+1, ptype, pdesc, pstorage);
     }
 
     /* try to lookup object in hash table */
     if (!lh_lookup(val->lh, name, strlen(name), (void **)&obj, NULL))
-        return VAL_ERR_ARG;
+        return VAL_RC(VAL_ERR_ARG);
 
     /* pass queried information to caller */
     if (ptype != NULL)
@@ -807,25 +820,25 @@
 
     /* argument consistency check */
     if (val == NULL || name == NULL || ap == NULL)
-        return VAL_ERR_ARG;
+        return VAL_RC(VAL_ERR_ARG);
 
     /* recursive step-down on structured name */
     if ((cp = strchr(name, '.')) != NULL) {
         if (!lh_lookup(val->lh, name, cp-name, (void **)&obj, NULL))
-            return VAL_ERR_ARG;
+            return VAL_RC(VAL_ERR_ARG);
         if (!(obj->type & VAL_TYPE_VAL))
-            return VAL_ERR_USE;
+            return VAL_RC(VAL_ERR_USE);
         child = *(val_t **)(val_storage(obj));
         return val_vset(child, cp+1, ap);
     }
 
     /* try to lookup object in hash table */
     if (!lh_lookup(val->lh, name, strlen(name), (void **)&obj, NULL))
-        return VAL_ERR_ARG;
+        return VAL_RC(VAL_ERR_ARG);
 
     /* determine value storage */
     if ((storage = val_storage(obj)) == NULL)
-        return VAL_ERR_INT;
+        return VAL_RC(VAL_ERR_INT);
 
     /* copy value from variable argument into storage location */
     switch (obj->type & ~VAL_INLINE) {
@@ -851,14 +864,14 @@
 
     /* argument consistency check */
     if (val == NULL || name == NULL)
-        return VAL_ERR_ARG;
+        return VAL_RC(VAL_ERR_ARG);
 
     /* just pass-through to va_list variant */
     va_start(ap, name);
     rc = val_vset(val, name, ap);
     va_end(ap);
 
-    return rc;
+    return VAL_RC(rc);
 }
 
 /* get a value (va_list variant) */
@@ -871,25 +884,25 @@
 
     /* argument consistency check */
     if (val == NULL || name == NULL || ap == NULL)
-        return VAL_ERR_ARG;
+        return VAL_RC(VAL_ERR_ARG);
     
     /* recursive step-down on structured name */
     if ((cp = strchr(name, '.')) != NULL) {
         if (!lh_lookup(val->lh, name, cp-name, (void **)&obj, NULL))
-            return VAL_ERR_ARG;
+            return VAL_RC(VAL_ERR_ARG);
         if (!(obj->type & VAL_TYPE_VAL))
-            return VAL_ERR_USE;
+            return VAL_RC(VAL_ERR_USE);
         child = *(val_t **)(val_storage(obj));
         return val_vget(child, cp+1, ap);
     }
 
     /* try to lookup object in hash table */
     if (!lh_lookup(val->lh, name, strlen(name), (void **)&obj, NULL))
-        return VAL_ERR_ARG;
+        return VAL_RC(VAL_ERR_ARG);
 
     /* determine value storage */
     if ((storage = val_storage(obj)) == NULL)
-        return VAL_ERR_INT;
+        return VAL_RC(VAL_ERR_INT);
 
     /* copy value from storage location into variable argument pointer location */
     switch (obj->type & ~VAL_INLINE) {
@@ -915,14 +928,14 @@
 
     /* argument consistency check */
     if (val == NULL || name == NULL)
-        return VAL_ERR_ARG;
+        return VAL_RC(VAL_ERR_ARG);
     
     /* just pass-through to va_list variant */
     va_start(ap, name);
     rc = val_vget(val, name, ap);
     va_end(ap);
 
-    return rc;
+    return VAL_RC(rc);
 }
 
 /* internal lh_apply() recursion callback context structure */
@@ -991,15 +1004,15 @@
         val_ctx.ctx       = ctx;
         val_ctx.rc        = VAL_OK;
         if (!lh_apply(val->lh, val_apply_cb, &val_ctx))
-            return VAL_ERR_SYS;
+            return VAL_RC(VAL_ERR_SYS);
     }
     else if ((cp = strchr(name+prefixlen, '.')) != NULL) {
         /* CASE 2: still stepping-down for structured name
            prefix="foo.bar.", remainder="quux.baz" */
         if (!lh_lookup(val->lh, name+prefixlen, cp-(name+prefixlen), (void **)&obj, NULL))
-            return VAL_ERR_ARG;
+            return VAL_RC(VAL_ERR_ARG);
         if (!(obj->type & VAL_TYPE_VAL))
-            return VAL_ERR_USE;
+            return VAL_RC(VAL_ERR_USE);
         child = *(val_t **)(val_storage(obj));
         if (depth == 0)
             return VAL_OK;
@@ -1008,10 +1021,10 @@
         /* CASE 3: reached last component of structured name
            prefix="foo.bar.quux.", remainder="baz" */
         if (!lh_lookup(val->lh, name+prefixlen, strlen(name+prefixlen), (void **)&obj, NULL))
-            return VAL_ERR_ARG;
+            return VAL_RC(VAL_ERR_ARG);
         if ((rc = cb(ctx, name, (obj->type & ~VAL_INLINE), 
                      obj->desc, val_storage(obj))) != VAL_OK)
-            return rc;
+            return VAL_RC(rc);
         if (obj->type & VAL_TYPE_VAL) {
             if (depth == 0)
                 return VAL_OK;
@@ -1027,7 +1040,7 @@
 {
     /* argument consistency check */
     if (val == NULL || name == NULL || depth < 0 || cb == NULL)
-        return VAL_ERR_ARG;
+        return VAL_RC(VAL_ERR_ARG);
 
     /* just pass-through to internal API-extended variant */
     return val_apply_internal(val, name, 0, depth, cb, ctx);

CVSTrac 2.0.1