6 main (int argc, char *argv[])
14 const char *membs[] = { "bar", "baz", "foo", NULL };
20 fprintf (stderr, "Syntax: %s PROGRAM\n", argv[0]);
24 if ((ctf = ctf_open (argv[1], NULL, &err)) == NULL)
27 if ((fp = ctf_dict_open (ctf, NULL, &err)) == NULL)
30 if ((dyn = ctf_create (&err)) == NULL)
33 /* Copy 'struct foo' into the dynamic dict, then make sure we can look up a
34 member situated inside an unnamed struct. */
36 if ((type = ctf_lookup_by_name (fp, "struct foo")) == CTF_ERR)
38 fprintf (stderr, "Cannot look up struct foo: %s\n", ctf_errmsg (ctf_errno (dyn)));
42 if ((newtype = ctf_add_type (dyn, fp, type)) == CTF_ERR)
45 for (walk = membs; *walk != NULL; walk++)
47 if (ctf_member_info (dyn, newtype, *walk, &mi) < 0)
49 printf ("Looked up %s, type %lx, offset %lx\n", *walk, (long) mi.ctm_type, mi.ctm_offset);
59 fprintf (stderr, "%s: cannot open: %s\n", argv[0], ctf_errmsg (err));
62 fprintf (stderr, "%s: cannot create: %s\n", argv[0], ctf_errmsg (err));
65 fprintf (stderr, "Type addition failed: %s\n", ctf_errmsg (ctf_errno (dyn)));
68 fprintf (stderr, "Cannot look up %s: %s\n", *walk, ctf_errmsg (ctf_errno (dyn)));