OSSP CVS Repository

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

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

--- val.c        2002/01/16 20:24:09     1.4
+++ val.c        2002/01/16 20:32:23     1.5
@@ -722,6 +722,43 @@
     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)
+{
+    char *cp;
+    val_object_t *obj;
+    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_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;
+
+    /* pass queried information to caller */
+    if (ptype != NULL)
+        *ptype = (obj->type & ~VAL_INLINE);
+    if (pdesc != NULL)
+        *pdesc = obj->desc;
+    if (pstorage != NULL)
+        *pstorage = val_storage(obj);
+
+    return VAL_OK;
+}
+
 /* set a value (va_list variant) */
 val_rc_t val_vset(val_t *val, const char *name, va_list ap)
 {

CVSTrac 2.0.1