6 main (int argc, char *argv[])
16 const char *membs[] = { "bar", "baz", NULL };
22 fprintf (stderr, "Syntax: %s PROGRAM\n", argv[0]);
26 if ((ctf = ctf_open (argv[1], NULL, &err)) == NULL)
29 if ((fp = ctf_dict_open (ctf, NULL, &err)) == NULL)
32 if ((dyn = ctf_create (&err)) == NULL)
35 /* Copy 'struct foo' into the dynamic dict, then make sure we can look up a
36 member situated inside an unnamed struct. */
38 if ((type = ctf_lookup_by_name (fp, "struct foo")) == CTF_ERR)
40 fprintf (stderr, "Cannot look up struct foo: %s\n", ctf_errmsg (ctf_errno (dyn)));
44 if ((newtype = ctf_add_type (dyn, fp, type)) == CTF_ERR)
47 for (walk = membs; *walk != NULL; walk++)
49 if (ctf_member_info (dyn, newtype, *walk, &mi) < 0)
51 printf ("Looked up %s, type %lx, offset %lx\n", *walk, (long) mi.ctm_type, mi.ctm_offset);
61 fprintf (stderr, "%s: cannot open: %s\n", argv[0], ctf_errmsg (err));
64 fprintf (stderr, "%s: cannot create: %s\n", argv[0], ctf_errmsg (err));
67 fprintf (stderr, "Type addition failed: %s\n", ctf_errmsg (ctf_errno (dyn)));
70 fprintf (stderr, "Cannot look up %s: %s\n", *walk, ctf_errmsg (ctf_errno (dyn)));