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
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
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.
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.
45 #define NEEDS_DFUI_STRUCTURE_DEFINITIONS
47 #undef NEEDS_DFUI_STRUCTURE_DEFINITIONS
50 FILE *dfui_debug_file
;
55 #define __debug_only __unused
59 dfui_info_dump(const struct dfui_info
*info __debug_only
)
62 fprintf(dfui_debug_file
, "+ INFO:\n");
64 fprintf(dfui_debug_file
, " *NULL*");
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
);
74 dfui_option_dump(const struct dfui_option
*o __debug_only
)
77 fprintf(dfui_debug_file
, "+ OPTION:\n");
79 fprintf(dfui_debug_file
, " *NULL*");
82 fprintf(dfui_debug_file
, "value: %s\n", o
->value
);
87 dfui_field_dump(const struct dfui_field
*fi __debug_only
)
90 struct dfui_option
*o
;
92 fprintf(dfui_debug_file
, "+ FIELD:\n");
94 fprintf(dfui_debug_file
, " *NULL*");
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
) {
106 dfui_action_dump(const struct dfui_action
*a __debug_only
)
109 fprintf(dfui_debug_file
, "+ ACTION:\n");
111 fprintf(dfui_debug_file
, " *NULL*");
114 fprintf(dfui_debug_file
, "id: %s\n", a
->id
);
115 dfui_info_dump(a
->info
);
121 dfui_celldata_dump(const struct dfui_celldata
*c __debug_only
)
125 fprintf(dfui_debug_file
, "*NULL* ");
128 fprintf(dfui_debug_file
, "{%s = %s}", c
->field_id
, c
->value
);
133 dfui_dataset_dump(const struct dfui_dataset
*ds __debug_only
)
136 struct dfui_celldata
*c
;
138 fprintf(dfui_debug_file
, "+ DATASET:\n");
140 fprintf(dfui_debug_file
, " *NULL*");
144 for (c
= ds
->celldata_head
; c
!= NULL
; c
= c
->next
) {
145 dfui_celldata_dump(c
);
147 fprintf(dfui_debug_file
, "\n");
153 dfui_form_dump(const struct dfui_form
*f __debug_only
)
156 struct dfui_field
*fi
;
157 struct dfui_action
*a
;
158 struct dfui_dataset
*ds
;
160 fprintf(dfui_debug_file
, "FORM ------\n");
162 fprintf(dfui_debug_file
, "*NULL*");
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
) {
175 for (a
= f
->action_head
; a
!= NULL
; a
= a
->next
) {
178 for (ds
= f
->dataset_head
; ds
!= NULL
; ds
= ds
->next
) {
179 dfui_dataset_dump(ds
);
185 dfui_response_dump(const struct dfui_response
*r __debug_only
)
188 struct dfui_dataset
*ds
;
190 fprintf(dfui_debug_file
, "RESPONSE ------\n");
192 fprintf(dfui_debug_file
, "*NULL*");
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
);
205 dfui_progress_dump(const struct dfui_progress
*pr __debug_only
)
208 fprintf(dfui_debug_file
, "PROGRESS ------\n");
210 fprintf(dfui_debug_file
, "*NULL*");
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
);
222 dfui_debug(const char *fmt __debug_only
, ...)
228 vfprintf(dfui_debug_file
, fmt
, args
);