OSSP CVS Repository

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

Check-in Number: 1724
Date: 2002-Jan-30 19:55:23 (local)
2002-Jan-30 18:55:23 (UTC)
User:rse
Branch:
Comment: add optional OSSP ex based exception handling support
Tickets:
Inspections:
Files:
ossp-pkg/val/acconfig.h      added-> 1.1
ossp-pkg/val/aclocal.m4      1.3 -> 1.4     113 inserted, 0 deleted
ossp-pkg/val/configure.ac      1.1 -> 1.2     2 inserted, 0 deleted
ossp-pkg/val/val.c      1.8 -> 1.9     51 inserted, 38 deleted
ossp-pkg/val/val.h      1.5 -> 1.6     3 inserted, 0 deleted

ossp-pkg/val/acconfig.h -> 1.1

*** /dev/null    Fri Apr 19 07:15:32 2024
--- -    Fri Apr 19 07:21:27 2024
***************
*** 0 ****
--- 1,4 ----
+ 
+ /* whether to use OSSP ex */
+ #undef WITH_EX
+ 


ossp-pkg/val/aclocal.m4 1.3 -> 1.4

--- aclocal.m4   2002/01/16 14:09:18     1.3
+++ aclocal.m4   2002/01/30 18:55:23     1.4
@@ -115,3 +115,116 @@
 fi
 ])
 
+dnl ##
+dnl ##  Check for an external/extension library.
+dnl ##  - is aware of <libname>-config style scripts
+dnl ##  - searches under standard paths include, lib, etc.
+dnl ##  - searches under subareas like .libs, etc.
+dnl ##
+dnl ##  configure.in:
+dnl ##      AC_CHECK_EXTLIB(<realname>, <libname>, <func>, <header>,
+dnl ##                      [<success-action> [, <fail-action>]])
+dnl ##  Makefile.in:
+dnl ##      CFLAGS  = @CFLAGS@
+dnl ##      LDFLAGS = @LDFLAGS@
+dnl ##      LIBS    = @LIBS@
+dnl ##  shell:
+dnl ##      $ ./configure --with-<libname>[=DIR]
+dnl ##
+
+AC_DEFUN(AC_CHECK_EXTLIB,[dnl
+AC_ARG_WITH($2, [dnl
+[  --with-]m4_substr([$2[[=DIR]]                     ], 0, 19)[build with external $1 library (default=no)]], [dnl
+    if test ".$with_$2" = .yes; then
+        #   via config script in PATH
+        $2_version=`($2-config --version) 2>/dev/null`
+        if test ".$$2_version" != .; then
+            CPPFLAGS="$CPPFLAGS `$2-config --cflags`"
+            CFLAGS="$CFLAGS `$2-config --cflags`"
+            LDFLAGS="$LDFLAGS `$2-config --ldflags`"
+        fi
+    else
+        if test -d "$with_$2"; then
+            found=0
+            #   via config script
+            for dir in $with_$2/bin $with_$2; do
+                if test -f "$dir/$2-config" && test ! -f "$dir/$2-config.in"; then
+                    $2_version=`($dir/$2-config --version) 2>/dev/null`
+                    if test ".$$2_version" != .; then
+                        CPPFLAGS="$CPPFLAGS `$dir/$2-config --cflags`"
+                        CFLAGS="$CFLAGS `$dir/$2-config --cflags`"
+                        LDFLAGS="$LDFLAGS `$dir/$2-config --ldflags`"
+                        found=1
+                        break
+                    fi
+                fi
+            done
+            #   in standard sub-areas
+            if test ".$found" = .0; then
+                for dir in $with_$2/include/$2 $with_$2/include $with_$2; do
+                    if test -f "$dir/$4"; then
+                        CPPFLAGS="$CPPFLAGS -I$dir"
+                        CFLAGS="$CFLAGS -I$dir"
+                        found=1
+                        break
+                    fi
+                done
+                for dir in $with_$2/lib/$2 $with_$2/lib $with_$2; do
+                    if test -f "$dir/lib$2.la" && test -d "$dir/.libs"; then
+                        LDFLAGS="$LDFLAGS -L$dir -L$dir/.libs"
+                        found=1
+                        break
+                    elif test -f "$dir/lib$2.a" || test -f "$dir/lib$2.so"; then
+                        LDFLAGS="$LDFLAGS -L$dir"
+                        found=1
+                        break
+                    fi
+                done
+            fi
+            #   in any sub-area
+            if test ".$found" = .0; then
+changequote(, )dnl
+                for file in x `find $with_$2 -name "$4" -type f -print`; do
+                    test .$file = .x && continue
+                    dir=`echo $file | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;'`
+                    CPPFLAGS="$CPPFLAGS -I$dir"
+                    CFLAGS="$CFLAGS -I$dir"
+                done
+                for file in x `find $with_$2 -name "lib$2.[aso]" -type f -print`; do
+                    test .$file = .x && continue
+                    dir=`echo $file | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;'`
+                    LDFLAGS="$LDFLAGS -L$dir"
+                done
+changequote([, ])dnl
+            fi
+        fi
+    fi
+    AC_HAVE_HEADERS($4)
+    AC_CHECK_LIB($2, $3)
+    with_$2=yes
+    ac_var="ac_cv_header_`echo $4 | sed 'y%./+-%__p_%'`"
+    eval "ac_val=\$$ac_var"
+    if test ".$ac_val" != .yes; then
+        with_$2=no
+    fi
+    if test ".$ac_cv_lib_$2_$3" != .yes; then
+        with_$2=no
+    fi
+    if test ".$with_$2" = .no; then
+        AC_ERROR([Unable to find $1 library])
+    fi
+    ], [dnl
+if test ".$with_$2" = .; then
+    with_$2=no
+fi
+    ])dnl
+AC_MSG_CHECKING(whether to build against external $1 library)
+if test ".$with_$2" = .yes; then
+    ifelse([$5], , :, [$5])
+else
+    ifelse([$6], , :, [$6])
+fi
+AC_MSG_RESULT([$with_$2])
+])dnl
+
+


ossp-pkg/val/configure.ac 1.1 -> 1.2

--- configure.ac 2002/01/09 10:44:28     1.1
+++ configure.ac 2002/01/30 18:55:23     1.2
@@ -44,6 +44,8 @@
 sinclude(libtool.m4)
 AC_PROG_LIBTOOL
 
+AC_CHECK_EXTLIB([OSSP ex], ex, __ex_ctx, ex.h, [AC_DEFINE(WITH_EX)])
+
 AC_CONFIG_HEADERS(config.h)
 AC_CONFIG_FILES(Makefile val-config)
 AC_OUTPUT


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);


ossp-pkg/val/val.h 1.5 -> 1.6

--- val.h        2002/01/17 12:19:09     1.5
+++ val.h        2002/01/30 18:55:23     1.6
@@ -66,6 +66,9 @@
 /* function type for use with val_apply() */
 typedef val_rc_t (*val_cb_t)(void *, const char *, int, const char *, void *);
 
+/* unique library identifier */
+extern const char val_id[];
+
 /* set of API functions */
 val_rc_t val_create  (val_t **);
 val_rc_t val_destroy (val_t *);

CVSTrac 2.0.1