OSSP CVS Repository

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

Check-in Number: 1571
Date: 2002-Jan-17 13:19:09 (local)
2002-Jan-17 12:19:09 (UTC)
User:rse
Branch:
Comment: add val_unreg() function
Tickets:
Inspections:
Files:
ossp-pkg/val/val.c      1.5 -> 1.6     35 inserted, 0 deleted
ossp-pkg/val/val.h      1.4 -> 1.5     1 inserted, 0 deleted
ossp-pkg/val/val.pod      1.6 -> 1.7     5 inserted, 0 deleted

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

--- val.c        2002/01/16 20:32:23     1.5
+++ val.c        2002/01/17 12:19:09     1.6
@@ -722,6 +722,41 @@
     return VAL_OK;
 }
 
+val_rc_t val_unreg(val_t *val, const char *name)
+{
+    val_object_t *obj;
+    const char *cp;
+    val_t *child;
+
+    /* argument consistency check */
+    if (val == NULL || name == NULL)
+        return 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;
+        if (!(obj->type & VAL_TYPE_VAL))
+            return 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;
+
+    /* destroy value object */
+    if (obj->desc != NULL)
+        free(obj->desc);
+
+    /* delete value from hash table */
+    if (!lh_delete(val->lh, name, strlen(name)))
+        return VAL_ERR_HSH;
+
+    return VAL_OK;
+}
+
 /* query information about a value */
 val_rc_t val_query(val_t *val, const char *name, 
                    int *ptype, char **pdesc, void **pstorage)


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

--- val.h        2002/01/16 20:32:23     1.4
+++ val.h        2002/01/17 12:19:09     1.5
@@ -70,6 +70,7 @@
 val_rc_t val_create  (val_t **);
 val_rc_t val_destroy (val_t *);
 val_rc_t val_reg     (val_t *, const char *, int, const char *, void *);
+val_rc_t val_unreg   (val_t *, const char *);
 val_rc_t val_query   (val_t *, const char *, int *, char **, void **);
 val_rc_t val_set     (val_t *, const char *, ...);
 val_rc_t val_get     (val_t *, const char *, ...);


ossp-pkg/val/val.pod 1.6 -> 1.7

--- val.pod      2002/01/17 11:50:06     1.6
+++ val.pod      2002/01/17 12:19:09     1.7
@@ -68,6 +68,7 @@
 C<val_create>,
 C<val_destroy>,
 C<val_reg>,
+C<val_unreg>,
 C<val_query>,
 C<val_set>,
 C<val_get>,
@@ -179,6 +180,10 @@
 can only be access through B<val_get>(), B<val_set>() or after the actual
 storage address was queried using B<val_query>().
 
+=item val_rc_t B<val_unreg>(val_t *I<val>, const char *I<name>);
+
+Unregisters a variable I<name> in I<val>.
+
 =item val_rc_t B<val_query>(val_t *I<val>, const char *I<name>, int *I<ptype>, char **I<pdesc>, void **I<pstorage>);
 
 Queries a variable I<name> in I<val> and returns it's type, description and

CVSTrac 2.0.1