nlookup.9 - document nlookup_init_root
[dragonfly.git] / usr.sbin / installer / libdfui / dump.c
blobfb938881e6312f14d3220e86258e343ad17cd6a1
1 /*
2 * Copyright (c)2004 Cat's Eye Technologies. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
8 * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
16 * Neither the name of Cat's Eye Technologies nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31 * OF THE POSSIBILITY OF SUCH DAMAGE.
35 * dump.c
36 * $Id: dump.c,v 1.5 2005/02/06 19:53:19 cpressey Exp $
37 * Debugging functions for libdfui.
38 * These functions are just stubs when libdfui is built without DEBUG.
41 #include <stdarg.h>
42 #include <stdio.h>
43 #include <stdlib.h>
45 #define NEEDS_DFUI_STRUCTURE_DEFINITIONS
46 #include "dfui.h"
47 #undef NEEDS_DFUI_STRUCTURE_DEFINITIONS
48 #include "dump.h"
50 FILE *dfui_debug_file;
52 #ifdef DEBUG
53 #define __debug_only
54 #else
55 #define __debug_only __unused
56 #endif
58 void
59 dfui_info_dump(const struct dfui_info *info __debug_only)
61 #ifdef DEBUG
62 fprintf(dfui_debug_file, "+ INFO:\n");
63 if (info == NULL) {
64 fprintf(dfui_debug_file, " *NULL*");
65 return;
67 fprintf(dfui_debug_file, " name: %s\n", info->name);
68 fprintf(dfui_debug_file, " short_desc: %s\n", info->short_desc);
69 fprintf(dfui_debug_file, " long_desc: %s\n", info->long_desc);
70 #endif
73 void
74 dfui_option_dump(const struct dfui_option *o __debug_only)
76 #ifdef DEBUG
77 fprintf(dfui_debug_file, "+ OPTION:\n");
78 if (o == NULL) {
79 fprintf(dfui_debug_file, " *NULL*");
80 return;
82 fprintf(dfui_debug_file, "value: %s\n", o->value);
83 #endif
86 void
87 dfui_field_dump(const struct dfui_field *fi __debug_only)
89 #ifdef DEBUG
90 struct dfui_option *o;
92 fprintf(dfui_debug_file, "+ FIELD:\n");
93 if (fi == NULL) {
94 fprintf(dfui_debug_file, " *NULL*");
95 return;
97 fprintf(dfui_debug_file, "id: %s\n", fi->id);
98 dfui_info_dump(fi->info);
99 for (o = fi->option_head; o != NULL; o = o->next) {
100 dfui_option_dump(o);
102 #endif
105 void
106 dfui_action_dump(const struct dfui_action *a __debug_only)
108 #ifdef DEBUG
109 fprintf(dfui_debug_file, "+ ACTION:\n");
110 if (a == NULL) {
111 fprintf(dfui_debug_file, " *NULL*");
112 return;
114 fprintf(dfui_debug_file, "id: %s\n", a->id);
115 dfui_info_dump(a->info);
116 /* parameters */
117 #endif
120 void
121 dfui_celldata_dump(const struct dfui_celldata *c __debug_only)
123 #ifdef DEBUG
124 if (c == NULL) {
125 fprintf(dfui_debug_file, "*NULL* ");
126 return;
128 fprintf(dfui_debug_file, "{%s = %s}", c->field_id, c->value);
129 #endif
132 void
133 dfui_dataset_dump(const struct dfui_dataset *ds __debug_only)
135 #ifdef DEBUG
136 struct dfui_celldata *c;
138 fprintf(dfui_debug_file, "+ DATASET:\n");
139 if (ds == NULL) {
140 fprintf(dfui_debug_file, " *NULL*");
141 return;
144 for (c = ds->celldata_head; c != NULL; c = c->next) {
145 dfui_celldata_dump(c);
147 fprintf(dfui_debug_file, "\n");
148 #endif
152 void
153 dfui_form_dump(const struct dfui_form *f __debug_only)
155 #ifdef DEBUG
156 struct dfui_field *fi;
157 struct dfui_action *a;
158 struct dfui_dataset *ds;
160 fprintf(dfui_debug_file, "FORM ------\n");
161 if (f == NULL) {
162 fprintf(dfui_debug_file, "*NULL*");
163 return;
166 fprintf(dfui_debug_file, "id: %s\n", f->id);
167 dfui_info_dump(f->info);
169 fprintf(dfui_debug_file, "multiple: %d\n", f->multiple);
170 fprintf(dfui_debug_file, "extensible: %d\n", f->extensible);
172 for (fi = f->field_head; fi != NULL; fi = fi->next) {
173 dfui_field_dump(fi);
175 for (a = f->action_head; a != NULL; a = a->next) {
176 dfui_action_dump(a);
178 for (ds = f->dataset_head; ds != NULL; ds = ds->next) {
179 dfui_dataset_dump(ds);
181 #endif
184 void
185 dfui_response_dump(const struct dfui_response *r __debug_only)
187 #ifdef DEBUG
188 struct dfui_dataset *ds;
190 fprintf(dfui_debug_file, "RESPONSE ------\n");
191 if (r == NULL) {
192 fprintf(dfui_debug_file, "*NULL*");
193 return;
195 fprintf(dfui_debug_file, "form id: %s\n", r->form_id);
196 fprintf(dfui_debug_file, "action id: %s\n", r->action_id);
198 for (ds = r->dataset_head; ds != NULL; ds = ds->next) {
199 dfui_dataset_dump(ds);
201 #endif
204 void
205 dfui_progress_dump(const struct dfui_progress *pr __debug_only)
207 #ifdef DEBUG
208 fprintf(dfui_debug_file, "PROGRESS ------\n");
209 if (pr == NULL) {
210 fprintf(dfui_debug_file, "*NULL*");
211 return;
214 /* fprintf(dfui_debug_file, "id: %s\n", pr->id); */
215 dfui_info_dump(pr->info);
217 fprintf(dfui_debug_file, "amount: %d\n", pr->amount);
218 #endif
221 void
222 dfui_debug(const char *fmt __debug_only, ...)
224 #ifdef DEBUG
225 va_list args;
227 va_start(args, fmt);
228 vfprintf(dfui_debug_file, fmt, args);
229 va_end(args);
230 #endif