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