Lines Matching refs:fp
11 ctf_dict_t *fp;
28 if ((fp = ctf_dict_open (ctf, NULL, &err)) == NULL)
34 if (ctf_add_integer (fp, CTF_ADD_ROOT, "int", &en) == 0)
37 if (ctf_errno (fp) != ECTF_RDONLY)
38 fprintf (stderr, "unexpected error %s attempting to add integer in readonly portion\n", ctf_errmsg (ctf_errno (fp)));
40 if (ctf_add_typedef (fp, CTF_ADD_ROOT, "a_typedef", 0) == 0)
43 if (ctf_errno (fp) != ECTF_RDONLY)
44 fprintf (stderr, "unexpected error %s attempting to add typedef in readonly portion\n", ctf_errmsg (ctf_errno (fp)));
46 if (ctf_add_struct (fp, CTF_ADD_ROOT, "a_struct") == 0)
49 if (ctf_errno (fp) != ECTF_RDONLY)
50 fprintf (stderr, "unexpected error %s attempting to add struct in readonly portion\n", ctf_errmsg (ctf_errno (fp)));
52 if (ctf_add_union (fp, CTF_ADD_ROOT, "a_union") == 0)
55 if (ctf_errno (fp) != ECTF_RDONLY)
56 fprintf (stderr, "unexpected error %s attempting to add union in readonly portion\n", ctf_errmsg (ctf_errno (fp)));
58 if (ctf_add_enum (fp, CTF_ADD_ROOT, "an_enum") == 0)
61 if (ctf_errno (fp) != ECTF_RDONLY)
62 fprintf (stderr, "unexpected error %s attempting to add enum in readonly portion\n", ctf_errmsg (ctf_errno (fp)));
64 if (ctf_add_struct (fp, CTF_ADD_ROOT, "struct_forward") == 0)
67 if (ctf_errno (fp) != ECTF_RDONLY)
68 fprintf (stderr, "unexpected error %s attempting to promote struct forward in readonly portion\n", ctf_errmsg (ctf_errno (fp)));
70 if (ctf_add_union (fp, CTF_ADD_ROOT, "union_forward") == 0)
73 if (ctf_errno (fp) != ECTF_RDONLY)
74 fprintf (stderr, "unexpected error %s attempting to promote union forward in readonly portion\n", ctf_errmsg (ctf_errno (fp)));
76 if (ctf_add_enum (fp, CTF_ADD_ROOT, "enum_forward") == 0)
79 if (ctf_errno (fp) != ECTF_RDONLY)
80 fprintf (stderr, "unexpected error %s attempting to promote enum forward in readonly portion\n", ctf_errmsg (ctf_errno (fp)));
82 if ((type = ctf_lookup_by_name (fp, "struct a_struct")) == CTF_ERR)
83 fprintf (stderr, "Lookup of struct a_struct failed: %s\n", ctf_errmsg (ctf_errno (fp)));
85 if (ctf_add_member (fp, type, "wombat", 0) == 0)
88 if (ctf_errno (fp) != ECTF_RDONLY)
89 fprintf (stderr, "unexpected error %s attempting to add member to struct in readonly portion\n", ctf_errmsg (ctf_errno (fp)));
91 if ((type = ctf_lookup_by_name (fp, "union a_union")) == CTF_ERR)
92 fprintf (stderr, "Lookup of union a_union failed: %s\n", ctf_errmsg (ctf_errno (fp)));
94 if (ctf_add_member (fp, type, "wombat", 0) == 0)
97 if (ctf_errno (fp) != ECTF_RDONLY)
98 fprintf (stderr, "unexpected error %s attempting to add member to union in readonly portion\n", ctf_errmsg (ctf_errno (fp)));
100 if ((type = ctf_lookup_by_name (fp, "enum an_enum")) == CTF_ERR)
101 fprintf (stderr, "Lookup of enum an_enum failed: %s\n", ctf_errmsg (ctf_errno (fp)));
103 if (ctf_add_enumerator (fp, type, "wombat", 0) == 0)
106 if (ctf_errno (fp) != ECTF_RDONLY)
107 fprintf (stderr, "unexpected error %s attempting to add enumerator to enum in readonly portion\n", ctf_errmsg (ctf_errno (fp)));
109 if ((type = ctf_lookup_by_name (fp, "an_array")) == CTF_ERR)
110 fprintf (stderr, "Lookup of an_array failed: %s\n", ctf_errmsg (ctf_errno (fp)));
112 if ((type = ctf_type_reference (fp, type)) == CTF_ERR)
113 fprintf (stderr, "Lookup of type reffed by an_array failed: %s\n", ctf_errmsg (ctf_errno (fp)));
115 if (ctf_set_array (fp, type, &ar) == 0)
118 if (ctf_errno (fp) != ECTF_RDONLY)
119 fprintf (stderr, "unexpected error %s attempting to set array in readonly portion\n", ctf_errmsg (ctf_errno (fp)));
121 if ((ctf_written = ctf_write_mem (fp, &size, 4096)) == NULL)
122 fprintf (stderr, "Re-writeout unexpectedly failed: %s\n", ctf_errmsg (ctf_errno (fp)));
127 if ((type = ctf_lookup_by_name (fp, "struct a_struct")) == CTF_ERR)
128 fprintf (stderr, "Lookup of struct a_struct failed: %s\n", ctf_errmsg (ctf_errno (fp)));
130 if ((ptrtype = ctf_add_pointer (fp, CTF_ADD_ROOT, type)) == CTF_ERR)
131 fprintf (stderr, "Cannot add pointer to ctf_opened dict: %s\n", ctf_errmsg (ctf_errno (fp)));
133 if (ctf_type_reference (fp, ptrtype) == CTF_ERR)
134 fprintf (stderr, "Lookup of pointer preserved across writeout failed: %s\n", ctf_errmsg (ctf_errno (fp)));
136 if (ctf_type_reference (fp, ptrtype) != type)
137 fprintf (stderr, "Look up of newly-added type in serialized dict yields ID %lx, expected %lx\n", ctf_type_reference (fp, ptrtype), type);
139 ctf_dict_close (fp);