OSSP CVS Repository

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

Check-in Number: 1569
Date: 2002-Jan-17 12:50:06 (local)
2002-Jan-17 11:50:06 (UTC)
User:rse
Branch:
Comment: added two copy'n'past examples
Tickets:
Inspections:
Files:
ossp-pkg/val/val.pod      1.5 -> 1.6     50 inserted, 0 deleted

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

--- val.pod      2002/01/17 09:22:18     1.5
+++ val.pod      2002/01/17 11:50:06     1.6
@@ -232,6 +232,56 @@
 
 OSSP var.
 
+=head1 EXAMPLES
+
+=over 4
+
+=item simple create, reg, get, destroy
+
+    #include <stdio.h>
+    #include "val.h"
+
+    int main(void)
+    {
+        val_rc_t rc;
+        val_t *v;
+        int example;
+        int pullout;
+
+        if ((rc = val_create(&v)) != VAL_OK) exit(-1);
+        if ((rc = val_reg(v, "foo", VAL_TYPE_INT, "foo variable", (void *)&example)) != VAL_OK) exit(-1);
+        example = 123;
+        if ((rc = val_get(v, "foo", &pullout)) != VAL_OK) exit(-1);
+        printf("pulled example and got %d\n", pullout);
+        if ((rc = val_destroy(v)) != VAL_OK) exit(-1);
+        return 0;
+    }
+
+=item reg inline data, structured name, set
+
+    #include <stdio.h>
+    #include "val.h"
+
+    int main(void)
+    {
+        val_rc_t rc;
+        val_t *v1, *v2;
+        int pullout;
+
+        if ((rc = val_create(&v1)) != VAL_OK) exit(-1);
+        if ((rc = val_create(&v2)) != VAL_OK) exit(-1);
+        if ((rc = val_reg(v1, "bar", VAL_TYPE_VAL, "child", (void *)&v2)) != VAL_OK) exit(-1);
+        if ((rc = val_reg(v1, "bar.foo", VAL_TYPE_INT, "foo variable", NULL)) != VAL_OK) exit(-1);
+        if ((rc = val_set(v2, "foo", 456)) != VAL_OK) exit(-1);
+        if ((rc = val_get(v1, "bar.foo", &pullout)) != VAL_OK) exit(-1);
+        printf("pulled example and got %d\n", pullout);
+        if ((rc = val_destroy(v2)) != VAL_OK) exit(-1);
+        if ((rc = val_destroy(v1)) != VAL_OK) exit(-1);
+        return 0;
+    }
+
+=back
+
 =head1 HISTORY
 
 B<OSSP val> was invented in January 2002 by Thomas Lotterer and Ralf S.

CVSTrac 2.0.1