Initial release of the message compiler.
[wine] / tools / wrc / dumpres.c
1 /*
2  * Copyrignt 1998 Bertho A. Stultiens (BS)
3  *
4  * 16-Apr-1998 BS       - Yeah, dump it to stdout.
5  *
6  */
7
8 #include "config.h"
9
10 #include <assert.h>
11 #include <stdio.h>
12 #include <ctype.h>
13
14 #include "wrc.h"
15 #include "dumpres.h"
16
17 /*
18  *****************************************************************************
19  * Function     : get_typename
20  * Syntax       : char *get_typename(resource_t* r)
21  * Input        :
22  *      r       - Resource description
23  * Output       : A pointer to a string representing the resource type
24  * Description  :
25  * Remarks      :
26  *****************************************************************************
27 */
28 char *get_typename(resource_t* r)
29 {
30         switch(r->type){
31         case res_acc:   return "ACCELERATOR";
32         case res_bmp:   return "BITMAP";
33         case res_cur:   return "CURSOR";
34         case res_curg:  return "GROUP_CURSOR";
35         case res_dlg:   return "DIALOG";
36         case res_dlgex: return "DIALOGEX";
37         case res_fnt:   return "FONT";
38         case res_ico:   return "ICON";
39         case res_icog:  return "GROUP_ICON";
40         case res_men:   return "MENU";
41         case res_menex: return "MENUEX";
42         case res_rdt:   return "RCDATA";
43         case res_stt:   return "STRINGTABLE";
44         case res_usr:   return "UserResource";
45         case res_msg:   return "MESSAGETABLE";
46         case res_ver:   return "VERSIONINFO";
47         case res_dlginit: return "DLGINIT";
48         case res_toolbar: return "TOOLBAR";
49         case res_anicur:  return "CURSOR (animated)";
50         case res_aniico:  return "ICON (animated)";
51         default:        return "Unknown";
52         }
53 }
54
55 /*
56  *****************************************************************************
57  * Function     : strncpyWtoA
58  * Syntax       : char *strncpyWtoA(char *cs, short *ws, int maxlen)
59  * Input        :
60  *      cs      - Pointer to buffer to receive result
61  *      ws      - Source wide-string
62  *      maxlen  - Max chars to copy
63  * Output       : 'cs'
64  * Description  : Copy a unicode string to ascii. Copying stops after the
65  *                first occuring '\0' or when maxlen-1 chars are copied. The
66  *                String is always nul terminated.
67  * Remarks      : No codepage translation is done.
68  *****************************************************************************
69 */
70 char *strncpyWtoA(char *cs, short *ws, int maxlen)
71 {
72         char *cptr = cs;
73         short *wsMax = ws + maxlen;
74         while(ws < wsMax)
75         {
76                 if(*ws < -128 || *ws > 127)
77                         printf("***Warning: Unicode string contains non-printable chars***");
78                 *cptr++ = (char)*ws++;
79                 maxlen--;
80         }
81         *cptr = '\0';
82         return cs;
83 }
84
85 /*
86  *****************************************************************************
87  * Function     : print_string
88  * Syntax       : void print_string(string_t *str)
89  * Input        :
90  * Output       :
91  * Description  :
92  * Remarks      :
93  *****************************************************************************
94 */
95 void print_string(string_t *str)
96 {
97         char buffer[512];
98         if(!str)
99                 printf("<none>");
100         else if(str->type == str_char)
101                 printf("\"%s\"", str->str.cstr);
102         else
103         {
104                 strncpyWtoA(buffer, str->str.wstr, sizeof(buffer));
105                 printf("L\"%s\"", buffer);
106         }
107 }
108
109 /*
110  *****************************************************************************
111  * Function     : get_nameid_str
112  * Syntax       : char *get_nameid_str(name_id_t *n)
113  * Input        :
114  *      n       - nameid to convert to text
115  * Output       : A pointer to the name.
116  * Description  :
117  * Remarks      : Not reentrant because of static buffer
118  *****************************************************************************
119 */
120 char *get_nameid_str(name_id_t *n)
121 {
122         static char buffer[256];
123
124         if(!n)
125                 return "<none>";
126
127         if(n->type == name_ord)
128         {
129                 sprintf(buffer, "%d", n->name.i_name);
130                 return buffer;
131         }
132         else if(n->type == name_str)
133         {
134                 if(n->name.s_name->type == str_char)
135                         return n->name.s_name->str.cstr;
136                 else
137                 {
138                         strncpyWtoA(buffer, n->name.s_name->str.wstr, sizeof(buffer));
139                         return buffer;
140                 }
141         }
142         else
143                 return "Hoooo, report this: wrong type in nameid";
144 }
145
146 /*
147  *****************************************************************************
148  * Function     : dump_memopt
149  * Syntax       : void dump_memopt(DWORD memopt)
150  * Input        :
151  *      memopt  - flag bits of the options set
152  * Output       :
153  * Description  :
154  * Remarks      :
155  *****************************************************************************
156 */
157 static void dump_memopt(DWORD memopt)
158 {
159         printf("Memory/load options: ");
160         if(memopt & 0x0040)
161                 printf("PRELOAD ");
162         else
163                 printf("LOADONCALL ");
164         if(memopt & 0x0010)
165                 printf("MOVEABLE ");
166         else
167                 printf("FIXED ");
168         if(memopt & 0x0020)
169                 printf("PURE ");
170         else
171                 printf("IMPURE ");
172         if(memopt & 0x1000)
173                 printf("DISCARDABLE");
174         printf("\n");
175 }
176
177 /*
178  *****************************************************************************
179  * Function     : dump_lvc
180  * Syntax       : void dump_lvc(lvc_t *l)
181  * Input        :
182  *      l       - pointer to lvc structure
183  * Output       :
184  * Description  : Dump language, version and characteristics
185  * Remarks      :
186  *****************************************************************************
187 */
188 static void dump_lvc(lvc_t *l)
189 {
190         if(l->language)
191                 printf("LANGUAGE %04x, %04x\n", l->language->id, l->language->sub);
192         else
193                 printf("LANGUAGE <not set>\n");
194
195         if(l->version)
196                 printf("VERSION %08lx\n", *(l->version));
197         else
198                 printf("VERSION <not set>\n");
199
200         if(l->characts)
201                 printf("CHARACTERISTICS %08lx\n", *(l->characts));
202         else
203                 printf("CHARACTERISTICS <not set>\n");
204 }
205
206 /*
207  *****************************************************************************
208  * Function     : dump_raw_data
209  * Syntax       : void dump_raw_data(raw_data_t *d)
210  * Input        :
211  *      d       - Raw data descriptor
212  * Output       :
213  * Description  :
214  * Remarks      :
215  *****************************************************************************
216 */
217 static void dump_raw_data(raw_data_t *d)
218 {
219         int n;
220         int i;
221         int j;
222
223         if(!d)
224         {
225                 printf("<none>");
226                 return;
227         }
228         printf("Rawdata size: %d\n", d->size);
229         if(debuglevel < 2)
230                 return;
231
232         for(n = 0; n < d->size; n++)
233         {
234                 if((n % 16) == 0) 
235                 {
236                         if(n)
237                         {
238                                 printf("- ");
239                                 for(i = 0; i < 16; i++)
240                                         printf("%c", isprint(d->data[n-16+i] & 0xff) ? d->data[n-16+i] : '.');
241                                 printf("\n%08x: ", n);
242                         }
243                         else
244                                 printf("%08x: ", n);
245                 }
246                 printf("%02x ", d->data[n] & 0xff);
247         }
248         printf("- ");
249         j = d->size % 16;
250         if(!j)
251                 j = 16;
252         for(i = 0; i < j; i++)
253                 printf("%c", isprint(d->data[n-j+i] & 0xff) ? d->data[n-j+i] : '.');
254         printf("\n");
255 }
256
257 /*
258  *****************************************************************************
259  * Function     : dump_accelerator
260  * Syntax       : void dump_accelerator(resource_t *acc)
261  * Input        :
262  *      acc     - Accelerator resource descriptor
263  * Output       : nop
264  * Description  :
265  * Remarks      :
266  *****************************************************************************
267 */
268 static void dump_accelerator(accelerator_t *acc)
269 {
270         event_t *ev = acc->events;
271
272         dump_memopt(acc->memopt);
273         dump_lvc(&(acc->lvc));
274
275         printf("Events: %s\n", ev ? "" : "<none>");
276         while(ev)
277         {
278                 printf("Key=");
279                 if(isprint(ev->key))
280                         printf("\"%c\"", ev->key);
281                 else if(iscntrl(ev->key))
282                         printf("\"^%c\"", ev->key +'@');
283                 else
284                         printf("\\x%02x", ev->key & 0xff);
285
286                 printf(" Id=%d flags=%04x\n", ev->id, ev->flags);
287                 ev = ev->next;
288         }
289 }
290
291 /*
292  *****************************************************************************
293  * Function     : dump_cursor
294  * Syntax       : void dump_cursor(cursor_t *cur)
295  * Input        :
296  *      cur     - Cursor resource descriptor
297  * Output       : nop
298  * Description  :
299  * Remarks      :
300  *****************************************************************************
301 */
302 static void dump_cursor(cursor_t *cur)
303 {
304         printf("Id: %d\n", cur->id);
305         printf("Width: %d\n", cur->width);
306         printf("Height: %d\n", cur->height);
307         printf("X Hotspot: %d\n", cur->xhot);
308         printf("Y Hotspot: %d\n", cur->yhot);
309         dump_raw_data(cur->data);
310 }
311
312 /*
313  *****************************************************************************
314  * Function     : dump_cursor_group
315  * Syntax       : void dump_cursor_group(cursor_group_t *cur)
316  * Input        :
317  *      cur     - Cursor group resource descriptor
318  * Output       : nop
319  * Description  :
320  * Remarks      :
321  *****************************************************************************
322 */
323 static void dump_cursor_group(cursor_group_t *curg)
324 {
325         dump_memopt(curg->memopt);
326         printf("There are %d cursors in this group\n", curg->ncursor);
327 }
328
329 /*
330  *****************************************************************************
331  * Function     : dump_icon
332  * Syntax       : void dump_icon(icon_t *ico)
333  * Input        :
334  *      ico     - Icon resource descriptor
335  * Output       : nop
336  * Description  :
337  * Remarks      :
338  *****************************************************************************
339 */
340 static void dump_icon(icon_t *ico)
341 {
342         printf("Id: %d\n", ico->id);
343         printf("Width: %d\n", ico->width);
344         printf("Height: %d\n", ico->height);
345         printf("NColor: %d\n", ico->nclr);
346         printf("NPlanes: %d\n", ico->planes);
347         printf("NBits: %d\n", ico->bits);
348         dump_raw_data(ico->data);
349 }
350
351 /*
352  *****************************************************************************
353  * Function     : dump_icon_group
354  * Syntax       : void dump_icon_group(icon_group_t *ico)
355  * Input        :
356  *      ico     - Icon group resource descriptor
357  * Output       : nop
358  * Description  :
359  * Remarks      :
360  *****************************************************************************
361 */
362 static void dump_icon_group(icon_group_t *icog)
363 {
364         dump_memopt(icog->memopt);
365         printf("There are %d icons in this group\n", icog->nicon);
366 }
367
368 /*
369  *****************************************************************************
370  * Function     : dump_ani_curico
371  * Syntax       : void dump_ani_curico(ani_curico_t *ani)
372  * Input        :
373  *      ani     - Animated object resource descriptor
374  * Output       : nop
375  * Description  :
376  * Remarks      :
377  *****************************************************************************
378 */
379 static void dump_ani_curico(ani_curico_t *ani)
380 {
381         dump_memopt(ani->memopt);
382         dump_lvc(&ani->data->lvc);
383         dump_raw_data(ani->data);
384 }
385
386 /*
387  *****************************************************************************
388  * Function     : dump_font
389  * Syntax       : void dump_font(font_t *fnt)
390  * Input        :
391  *      fnt     - Font resource descriptor
392  * Output       : nop
393  * Description  :
394  * Remarks      :
395  *****************************************************************************
396 */
397 static void dump_font(font_t *fnt)
398 {
399         dump_memopt(fnt->memopt);
400         dump_lvc(&(fnt->data->lvc));
401         dump_raw_data(fnt->data);
402 }
403
404 /*
405  *****************************************************************************
406  * Function     : dump_bitmap
407  * Syntax       : void dump_bitmap(bitmap_t *bmp)
408  * Input        :
409  *      bmp     - Bitmap resource descriptor
410  * Output       : nop
411  * Description  :
412  * Remarks      :
413  *****************************************************************************
414 */
415 static void dump_bitmap(bitmap_t *bmp)
416 {
417         dump_memopt(bmp->memopt);
418         dump_lvc(&(bmp->data->lvc));
419         dump_raw_data(bmp->data);
420 }
421
422 /*
423  *****************************************************************************
424  * Function     : dump_rcdata
425  * Syntax       : void dump_rcdata(rcdata_t *rdt)
426  * Input        :
427  *      rdt     - RCData resource descriptor
428  * Output       : nop
429  * Description  :
430  * Remarks      :
431  *****************************************************************************
432 */
433 static void dump_rcdata(rcdata_t *rdt)
434 {
435         dump_memopt(rdt->memopt);
436         dump_lvc(&(rdt->data->lvc));
437         dump_raw_data(rdt->data);
438 }
439
440 /*
441  *****************************************************************************
442  * Function     : dump_user
443  * Syntax       : void dump_user(user_t *usr)
444  * Input        :
445  *      usr     - User resource descriptor
446  * Output       : nop
447  * Description  :
448  * Remarks      :
449  *****************************************************************************
450 */
451 static void dump_user(user_t *usr)
452 {
453         dump_memopt(usr->memopt);
454         dump_lvc(&(usr->data->lvc));
455         printf("Class %s\n", get_nameid_str(usr->type));
456         dump_raw_data(usr->data);
457 }
458
459 /*
460  *****************************************************************************
461  * Function     : dump_messagetable
462  * Syntax       : void dump_messagetable(messagetable_t *msg)
463  * Input        :
464  *      msg     - Messagetable resource descriptor
465  * Output       : nop
466  * Description  :
467  * Remarks      :
468  *****************************************************************************
469 */
470 static void dump_messagetable(messagetable_t *msg)
471 {
472         dump_memopt(msg->memopt);
473         dump_lvc(&(msg->data->lvc));
474         dump_raw_data(msg->data);
475 }
476
477 /*
478  *****************************************************************************
479  * Function     : dump_stringtable
480  * Syntax       : void dump_stringtable(stringtable_t *stt)
481  * Input        :
482  *      stt     - Stringtable resource descriptor
483  * Output       : nop
484  * Description  :
485  * Remarks      :
486  *****************************************************************************
487 */
488 static void dump_stringtable(stringtable_t *stt)
489 {
490         int i;
491         for(; stt; stt = stt->next)
492         {
493                 printf("{\n");
494                 dump_memopt(stt->memopt);
495                 dump_lvc(&(stt->lvc));
496                 for(i = 0; i < stt->nentries; i++)
497                 {
498                         printf("Id=%-5d (%d) ", stt->idbase+i, stt->entries[i].id);
499                         if(stt->entries[i].str)
500                                 print_string(stt->entries[i].str);
501                         else
502                                 printf("<none>");
503                         printf("\n");
504                 }
505                 printf("}\n");
506         }
507 }
508
509 /*
510  *****************************************************************************
511  * Function     : dump_control
512  * Syntax       : void dump_control(control_t *ctrl)
513  * Input        :
514  *      ctrl    - Control resource descriptor
515  * Output       :
516  * Description  :
517  * Remarks      :
518  *****************************************************************************
519 */
520 static void dump_control(control_t *ctrl)
521 {
522         printf("Control {\n\tClass: %s\n", get_nameid_str(ctrl->ctlclass));
523         printf("\tText: "); get_nameid_str(ctrl->title); printf("\n");
524         printf("\tId: %d\n", ctrl->id);
525         printf("\tx, y, w, h: %d, %d, %d, %d\n", ctrl->x, ctrl->y, ctrl->width, ctrl->height);
526         if(ctrl->gotstyle)
527         {
528                 assert(ctrl->style != NULL);
529                 assert(ctrl->style->and_mask == 0);
530                 printf("\tStyle: %08lx\n", ctrl->style->or_mask);
531         }
532         if(ctrl->gotexstyle)
533         {
534                 assert(ctrl->exstyle != NULL);
535                 assert(ctrl->exstyle->and_mask == 0);
536                 printf("\tExStyle: %08lx\n", ctrl->exstyle->or_mask);
537         }
538         if(ctrl->gothelpid)
539                 printf("\tHelpid: %ld\n", ctrl->helpid);
540         if(ctrl->extra)
541         {
542                 printf("\t");
543                 dump_raw_data(ctrl->extra);
544         }
545         printf("}\n");
546 }
547
548 /*
549  *****************************************************************************
550  * Function     : dump_dialog
551  * Syntax       : void dump_dialog(dialog_t *dlg)
552  * Input        :
553  *      dlg     - Dialog resource descriptor
554  * Output       :
555  * Description  :
556  * Remarks      :
557  *****************************************************************************
558 */
559 static void dump_dialog(dialog_t *dlg)
560 {
561         control_t *c = dlg->controls;
562
563         dump_memopt(dlg->memopt);
564         dump_lvc(&(dlg->lvc));
565         printf("x, y, w, h: %d, %d, %d, %d\n", dlg->x, dlg->y, dlg->width, dlg->height);
566         if(dlg->gotstyle)
567         {
568                 assert(dlg->style != NULL);
569                 assert(dlg->style->and_mask == 0);
570                 printf("Style: %08lx\n", dlg->style->or_mask);
571                 
572         }
573         if(dlg->gotexstyle)
574         {
575                 assert(dlg->exstyle != NULL);
576                 assert(dlg->exstyle->and_mask == 0);
577                 printf("ExStyle: %08lx\n", dlg->exstyle->or_mask);
578         }
579         printf("Menu: %s\n", get_nameid_str(dlg->menu));
580         printf("Class: %s\n", get_nameid_str(dlg->dlgclass));
581         printf("Title: "); print_string(dlg->title); printf("\n");
582         printf("Font: ");
583         if(!dlg->font)
584                 printf("<none>\n");
585         else
586         {
587                 printf("%d, ", dlg->font->size);
588                 print_string(dlg->font->name);
589                 printf("\n");
590         }
591         while(c)
592         {
593                 dump_control(c);
594                 c = c->next;
595         }
596 }
597
598 /*
599  *****************************************************************************
600  * Function     : dump_dialogex
601  * Syntax       : void dump_dialogex(dialogex_t *dlgex)
602  * Input        :
603  *      dlgex   - DialogEx resource descriptor
604  * Output       :
605  * Description  :
606  * Remarks      :
607  *****************************************************************************
608 */
609 static void dump_dialogex(dialogex_t *dlgex)
610 {
611         control_t *c = dlgex->controls;
612
613         dump_memopt(dlgex->memopt);
614         dump_lvc(&(dlgex->lvc));
615         printf("x, y, w, h: %d, %d, %d, %d\n", dlgex->x, dlgex->y, dlgex->width, dlgex->height);
616         if(dlgex->gotstyle)
617         {
618                 assert(dlgex->style != NULL);
619                 assert(dlgex->style->and_mask == 0);
620                 printf("Style: %08lx\n", dlgex->style->or_mask);
621         }
622         if(dlgex->gotexstyle)
623         {
624                 assert(dlgex->exstyle != NULL);
625                 assert(dlgex->exstyle->and_mask == 0);
626                 printf("ExStyle: %08lx\n", dlgex->exstyle->or_mask);
627         }
628         if(dlgex->gothelpid)
629                 printf("Helpid: %ld\n", dlgex->helpid);
630         printf("Menu: %s\n", get_nameid_str(dlgex->menu));
631         printf("Class: %s\n", get_nameid_str(dlgex->dlgclass));
632         printf("Title: "); print_string(dlgex->title); printf("\n");
633         printf("Font: ");
634         if(!dlgex->font)
635                 printf("<none>\n");
636         else
637         {
638                 printf("%d, ", dlgex->font->size);
639                 print_string(dlgex->font->name);
640                 printf(", %d, %d\n", dlgex->font->weight, dlgex->font->italic);
641         }
642         while(c)
643         {
644                 dump_control(c);
645                 c = c->next;
646         }
647 }
648
649 /*
650  *****************************************************************************
651  * Function     : dump_menu_item
652  * Syntax       : void dump_menu_item(menu_item_t *item)
653  * Input        :
654  * Output       :
655  * Description  :
656  * Remarks      :
657  *****************************************************************************
658 */
659 static void dump_menu_item(menu_item_t *item)
660 {
661         while(item)
662         {
663                 if(item->popup)
664                 {
665                         printf("POPUP ");
666                         print_string(item->name);
667                         printf("\n");
668                         dump_menu_item(item->popup);
669                 }
670                 else
671                 {
672                         printf("MENUITEM ");
673                         if(item->name)
674                         {
675                                 print_string(item->name);
676                                 printf(", %d, %08lx", item->id, item->state);
677                         }
678                         else
679                                 printf("SEPARATOR");
680                         printf("\n");
681                 }
682                 item = item->next;
683         }
684 }
685
686 /*
687  *****************************************************************************
688  * Function     : dump_menu
689  * Syntax       : void dump_menu(menu_t *men)
690  * Input        :
691  *      men     - Menu resource descriptor
692  * Output       :
693  * Description  :
694  * Remarks      :
695  *****************************************************************************
696 */
697 static void dump_menu(menu_t *men)
698 {
699         dump_memopt(men->memopt);
700         dump_lvc(&(men->lvc));
701         dump_menu_item(men->items);
702 }
703
704 /*
705  *****************************************************************************
706  * Function     : dump_menuex_item
707  * Syntax       : void dump_menuex_item(menuex_item_t *item)
708  * Input        :
709  * Output       :
710  * Description  :
711  * Remarks      :
712  *****************************************************************************
713 */
714 static void dump_menuex_item(menuex_item_t *item)
715 {
716         while(item)
717         {
718                 if(item->popup)
719                 {
720                         printf("POPUP ");
721                         print_string(item->name);
722                         if(item->gotid)
723                                 printf(", Id=%d", item->id);
724                         if(item->gottype)
725                                 printf(", Type=%ld", item->type);
726                         if(item->gotstate)
727                                 printf(", State=%08lx", item->state);
728                         if(item->gothelpid)
729                                 printf(", HelpId=%d", item->helpid);
730                         printf("\n");
731                         dump_menuex_item(item->popup);
732                 }
733                 else
734                 {
735                         printf("MENUITEM ");
736                         if(item->name)
737                         {
738                                 print_string(item->name);
739                                 if(item->gotid)
740                                         printf(", Id=%d", item->id);
741                                 if(item->gottype)
742                                         printf(", Type=%ld", item->type);
743                                 if(item->gotstate)
744                                         printf(", State=%08lx", item->state);
745                                 if(item->gothelpid)
746                                         printf(", HelpId=%d", item->helpid);
747                         }
748                         else
749                                 printf("SEPARATOR");
750                         printf("\n");
751                 }
752                 item = item->next;
753         }
754 }
755
756 /*
757  *****************************************************************************
758  * Function     : dump_menuex
759  * Syntax       : void dump_menuex(dialogex_t *menex)
760  * Input        :
761  *      menex   - MenuEx resource descriptor
762  * Output       :
763  * Description  :
764  * Remarks      :
765  *****************************************************************************
766 */
767 static void dump_menuex(menuex_t *menex)
768 {
769         dump_memopt(menex->memopt);
770         dump_lvc(&(menex->lvc));
771         dump_menuex_item(menex->items);
772 }
773
774 /*
775  *****************************************************************************
776  * Function     : dump_ver_value
777  * Syntax       : void dump_ver_value(ver_value_t *val)
778  * Input        :
779  * Output       :
780  * Description  :
781  * Remarks      :
782  *****************************************************************************
783 */
784 static void dump_ver_block(ver_block_t *);      /* Forward ref */
785
786 static void dump_ver_value(ver_value_t *val)
787 {
788         if(val->type == val_str)
789         {
790                 printf("VALUE ");
791                 print_string(val->key);
792                 printf(" ");
793                 print_string(val->value.str);
794                 printf("\n");
795         }
796         else if(val->type == val_words)
797         {
798                 int i;
799                 printf("VALUE");
800                 print_string(val->key);
801                 for(i = 0; i < val->value.words->nwords; i++)
802                         printf(" %04x", val->value.words->words[i]);
803                 printf("\n");
804         }
805         else if(val->type == val_block)
806         {
807                 dump_ver_block(val->value.block);
808         }
809 }
810
811 /*
812  *****************************************************************************
813  * Function     : dump_ver_block
814  * Syntax       : void dump_ver_block(ver_block_t *blk)
815  * Input        :
816  * Output       :
817  * Description  :
818  * Remarks      :
819  *****************************************************************************
820 */
821 static void dump_ver_block(ver_block_t *blk)
822 {
823         ver_value_t *val = blk->values;
824         printf("BLOCK ");
825         print_string(blk->name);
826         printf("\n{\n");
827         while(val)
828         {
829                 dump_ver_value(val);
830                 val = val->next;
831         }
832         printf("}\n");
833 }
834
835 /*
836  *****************************************************************************
837  * Function     : dump_versioninfo
838  * Syntax       : void dump_versioninfo(versioninfo_t *ver)
839  * Input        :
840  *      ver     - Versioninfo resource descriptor
841  * Output       :
842  * Description  :
843  * Remarks      :
844  *****************************************************************************
845 */
846 static void dump_versioninfo(versioninfo_t *ver)
847 {
848         ver_block_t *blk = ver->blocks;
849
850         dump_lvc(&(ver->lvc));
851
852         if(ver->gotit.fv)
853                 printf("FILEVERSION %04x, %04x, %04x, %04x\n",
854                         ver->filever_maj1,
855                         ver->filever_maj2,
856                         ver->filever_min1,
857                         ver->filever_min2);
858         if(ver->gotit.pv)
859                 printf("PRODUCTVERSION %04x, %04x, %04x, %04x\n",
860                         ver->prodver_maj1,
861                         ver->prodver_maj2,
862                         ver->prodver_min1,
863                         ver->prodver_min2);
864         if(ver->gotit.fo)
865                 printf("FILEOS %08x\n", ver->fileos);
866         if(ver->gotit.ff)
867                 printf("FILEFLAGS %08x\n", ver->fileflags);
868         if(ver->gotit.ffm)
869                 printf("FILEFLAGSMASK %08x\n", ver->fileflagsmask);
870         if(ver->gotit.ft)
871                 printf("FILETYPE %08x\n", ver->filetype);
872         if(ver->gotit.fst)
873                 printf("FILESUBTYPE %08x\n", ver->filesubtype);
874         while(blk)
875         {
876                 dump_ver_block(blk);
877                 blk = blk->next;
878         }
879 }
880
881 /*
882  *****************************************************************************
883  * Function     : dump_toolbar_item
884  * Syntax       : void dump_toolbar_item(toolbar_item_t *item)
885  * Input        :
886  * Output       :
887  * Description  :
888  * Remarks      :
889  *****************************************************************************
890 */
891 static void dump_toolbar_items(toolbar_item_t *items)
892 {
893         while(items)
894         {
895                 if(items->id)
896                         printf("   BUTTON %d", items->id );
897                 else
898                         printf("   SEPARATOR");
899
900                 printf("\n");
901               
902                 items = items->next;
903         }
904 }
905
906 /*
907  *****************************************************************************
908  * Function     : dump_toolbar
909  * Syntax       : void dump_toolbar(toolbar_t *toolbar)
910  * Input        :
911  *      toolbar - Toolbar resource descriptor
912  * Output       :
913  * Description  :
914  * Remarks      :
915  *****************************************************************************
916 */
917 static void dump_toolbar(toolbar_t *toolbar)
918 {
919         dump_memopt(toolbar->memopt);
920         dump_lvc(&(toolbar->lvc));
921         dump_toolbar_items(toolbar->items);
922 }
923
924 /*
925  *****************************************************************************
926  * Function     : dump_dlginit
927  * Syntax       : void dump_dlginit(dlginit_t *dit)
928  * Input        :
929  *      dit     - DlgInit resource descriptor
930  * Output       :
931  * Description  :
932  * Remarks      :
933  *****************************************************************************
934 */
935 static void dump_dlginit(dlginit_t *dit)
936 {
937         dump_memopt(dit->memopt);
938         dump_lvc(&(dit->data->lvc));
939         dump_raw_data(dit->data);
940 }
941
942 /*
943  *****************************************************************************
944  * Function     :
945  * Syntax       :
946  * Input        :
947  * Output       :
948  * Description  :
949  * Remarks      :
950  *****************************************************************************
951 */
952 /*
953  *****************************************************************************
954  * Function     : dump_resources
955  * Syntax       : void dump_resources(resource_t *top)
956  * Input        :
957  *      top     - Top of the resource tree
958  * Output       :
959  *      nop
960  * Description  : Dump the parsed resource-tree to stdout
961  * Remarks      :
962  *****************************************************************************
963 */
964 void dump_resources(resource_t *top)
965 {
966         printf("Internal resource-tree dump:\n");
967         while(top)
968         {
969                 printf("Resource: %s\nId: %s\n",
970                        get_typename(top),
971                        get_nameid_str(top->name));
972                 switch(top->type)
973                 {
974                 case res_acc:
975                         dump_accelerator(top->res.acc);
976                         break;
977                 case res_bmp:
978                         dump_bitmap(top->res.bmp);
979                         break;
980                 case res_cur:
981                         dump_cursor(top->res.cur);
982                         break;
983                 case res_curg:
984                         dump_cursor_group(top->res.curg);
985                         break;
986                 case res_dlg:
987                         dump_dialog(top->res.dlg);
988                         break;
989                 case res_dlgex:
990                         dump_dialogex(top->res.dlgex);
991                         break;
992                 case res_fnt:
993                         dump_font(top->res.fnt);
994                         break;
995                 case res_icog:
996                         dump_icon_group(top->res.icog);
997                         break;
998                 case res_ico:
999                         dump_icon(top->res.ico);
1000                         break;
1001                 case res_men:
1002                         dump_menu(top->res.men);
1003                         break;
1004                 case res_menex:
1005                         dump_menuex(top->res.menex);
1006                         break;
1007                 case res_rdt:
1008                         dump_rcdata(top->res.rdt);
1009                         break;
1010                 case res_stt:
1011                         dump_stringtable(top->res.stt);
1012                         break;
1013                 case res_usr:
1014                         dump_user(top->res.usr);
1015                         break;
1016                 case res_msg:
1017                         dump_messagetable(top->res.msg);
1018                         break;
1019                 case res_ver:
1020                         dump_versioninfo(top->res.ver);
1021                         break;
1022                 case res_dlginit:
1023                         dump_dlginit(top->res.dlgi);
1024                         break;
1025                 case res_toolbar:
1026                         dump_toolbar(top->res.tbt);
1027                         break;
1028                 case res_anicur:
1029                 case res_aniico:
1030                         dump_ani_curico(top->res.ani);
1031                         break;
1032                 default:
1033                         printf("Report this: Unknown resource type parsed %08x\n", top->type);
1034                 }
1035                 printf("\n");
1036                 top = top->next;
1037         }
1038 }
1039