2 * Generate .res format from a resource-tree
4 * Copyright 1998 Bertho A. Stultiens
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 * 05-May-2000 BS - Added code to support endian conversions. The
22 * extra functions also aid unaligned access, but
23 * this is not yet implemented.
24 * 25-May-1998 BS - Added simple unicode -> char conversion for resource
25 * names in .s and .h files.
44 #include "wine/unicode.h"
46 #define SetResSize(res, tag) set_dword((res), (tag), (res)->size - get_dword((res), (tag)))
51 r
= xmalloc(sizeof(res_t
));
52 r
->allocsize
= RES_BLOCKSIZE
;
55 r
->data
= xmalloc(RES_BLOCKSIZE
);
59 res_t
*grow_res(res_t
*r
, unsigned int add
)
62 r
->data
= xrealloc(r
->data
, r
->allocsize
);
67 *****************************************************************************
71 * Syntax : void put_byte(res_t *res, unsigned c)
72 * void put_word(res_t *res, unsigned w)
73 * void put_dword(res_t *res, unsigned d)
75 * res - Binary resource to put the data in
76 * c, w, d - Data to put
78 * Description : Put primitives that put an item in the binary resource.
79 * The data array grows automatically.
81 *****************************************************************************
83 void put_byte(res_t
*res
, unsigned c
)
85 if(res
->allocsize
- res
->size
< sizeof(char))
86 grow_res(res
, RES_BLOCKSIZE
);
87 res
->data
[res
->size
] = (char)c
;
88 res
->size
+= sizeof(char);
91 void put_word(res_t
*res
, unsigned w
)
93 if(res
->allocsize
- res
->size
< sizeof(WORD
))
94 grow_res(res
, RES_BLOCKSIZE
);
97 #ifdef WORDS_BIGENDIAN
101 res
->data
[res
->size
+0] = HIBYTE(w
);
102 res
->data
[res
->size
+1] = LOBYTE(w
);
105 #ifndef WORDS_BIGENDIAN
109 res
->data
[res
->size
+1] = HIBYTE(w
);
110 res
->data
[res
->size
+0] = LOBYTE(w
);
113 res
->size
+= sizeof(WORD
);
116 void put_dword(res_t
*res
, unsigned d
)
118 if(res
->allocsize
- res
->size
< sizeof(DWORD
))
119 grow_res(res
, RES_BLOCKSIZE
);
122 #ifdef WORDS_BIGENDIAN
126 res
->data
[res
->size
+0] = HIBYTE(HIWORD(d
));
127 res
->data
[res
->size
+1] = LOBYTE(HIWORD(d
));
128 res
->data
[res
->size
+2] = HIBYTE(LOWORD(d
));
129 res
->data
[res
->size
+3] = LOBYTE(LOWORD(d
));
132 #ifndef WORDS_BIGENDIAN
136 res
->data
[res
->size
+3] = HIBYTE(HIWORD(d
));
137 res
->data
[res
->size
+2] = LOBYTE(HIWORD(d
));
138 res
->data
[res
->size
+1] = HIBYTE(LOWORD(d
));
139 res
->data
[res
->size
+0] = LOBYTE(LOWORD(d
));
142 res
->size
+= sizeof(DWORD
);
145 static void put_pad(res_t
*res
)
147 while(res
->size
& 0x3)
152 *****************************************************************************
153 * Function : set_word
155 * Syntax : void set_word(res_t *res, int ofs, unsigned w)
156 * void set_dword(res_t *res, int ofs, unsigned d)
158 * res - Binary resource to put the data in
159 * ofs - Byte offset in data-array
162 * Description : Set the value of a binary resource data array to a
165 *****************************************************************************
167 static void set_word(res_t
*res
, int ofs
, unsigned w
)
171 #ifdef WORDS_BIGENDIAN
175 res
->data
[ofs
+0] = HIBYTE(w
);
176 res
->data
[ofs
+1] = LOBYTE(w
);
179 #ifndef WORDS_BIGENDIAN
183 res
->data
[ofs
+1] = HIBYTE(w
);
184 res
->data
[ofs
+0] = LOBYTE(w
);
189 static void set_dword(res_t
*res
, int ofs
, unsigned d
)
193 #ifdef WORDS_BIGENDIAN
197 res
->data
[ofs
+0] = HIBYTE(HIWORD(d
));
198 res
->data
[ofs
+1] = LOBYTE(HIWORD(d
));
199 res
->data
[ofs
+2] = HIBYTE(LOWORD(d
));
200 res
->data
[ofs
+3] = LOBYTE(LOWORD(d
));
203 #ifndef WORDS_BIGENDIAN
207 res
->data
[ofs
+3] = HIBYTE(HIWORD(d
));
208 res
->data
[ofs
+2] = LOBYTE(HIWORD(d
));
209 res
->data
[ofs
+1] = HIBYTE(LOWORD(d
));
210 res
->data
[ofs
+0] = LOBYTE(LOWORD(d
));
216 *****************************************************************************
217 * Function : get_dword
219 * res - Binary resource to put the data in
220 * ofs - Byte offset in data-array
221 * Output : The data in native endian
222 * Description : Get the value of a binary resource data array in native
225 *****************************************************************************
227 static DWORD
get_dword(res_t
*res
, int ofs
)
231 #ifdef WORDS_BIGENDIAN
235 return (res
->data
[ofs
+0] << 24)
236 | (res
->data
[ofs
+1] << 16)
237 | (res
->data
[ofs
+2] << 8)
240 #ifndef WORDS_BIGENDIAN
244 return (res
->data
[ofs
+3] << 24)
245 | (res
->data
[ofs
+2] << 16)
246 | (res
->data
[ofs
+1] << 8)
252 *****************************************************************************
253 * Function : string_to_upper
254 * Syntax : void string_to_upper(string_t *str)
258 * Remarks : FIXME: codepages...
259 *****************************************************************************
261 static void string_to_upper(string_t
*str
)
265 if(str
->type
== str_char
)
267 for (i
= 0; i
< str
->size
; i
++) str
->str
.cstr
[i
] = toupper((unsigned char)str
->str
.cstr
[i
]);
269 else if(str
->type
== str_unicode
)
271 for (i
= 0; i
< str
->size
; i
++) str
->str
.wstr
[i
] = toupperW(str
->str
.wstr
[i
]);
275 internal_error(__FILE__
, __LINE__
, "Invalid string type %d\n", str
->type
);
280 *****************************************************************************
281 * Function : put_string
282 * Syntax : void put_string(res_t *res, string_t *str, enum str_e type,
283 * int isterm, const language_t *lang)
285 * res - Binary resource to put the data in
286 * str - String to put
287 * type - Data has to be written in either str_char or str_unicode
288 * isterm - The string is '\0' terminated (disregard the string's
293 *****************************************************************************
295 static void put_string(res_t
*res
, const string_t
*str
, enum str_e type
, int isterm
,
296 const language_t
*lang
)
304 if (lang
) codepage
= get_language_codepage( lang
->id
, lang
->sub
);
305 else codepage
= get_language_codepage( 0, 0 );
307 assert( codepage
!= -1 );
309 newstr
= convert_string(str
, type
, codepage
);
310 if (type
== str_unicode
)
312 if (str
->type
== str_char
)
314 if (!check_unicode_conversion( str
, newstr
, codepage
))
315 error( "String %s does not convert identically to Unicode and back in codepage %d. "
316 "Try using a Unicode string instead\n", str
->str
.cstr
, codepage
);
317 if (check_valid_utf8( str
, codepage
))
318 warning( "string \"%s\" seems to be UTF-8 but codepage %u is in use.\n",
319 str
->str
.cstr
, codepage
);
321 if (!isterm
) put_word(res
, newstr
->size
);
322 for(cnt
= 0; cnt
< newstr
->size
; cnt
++)
324 WCHAR c
= newstr
->str
.wstr
[cnt
];
325 if (isterm
&& !c
) break;
328 if (isterm
) put_word(res
, 0);
332 if (!isterm
) put_byte(res
, newstr
->size
);
333 for(cnt
= 0; cnt
< newstr
->size
; cnt
++)
335 char c
= newstr
->str
.cstr
[cnt
];
336 if (isterm
&& !c
) break;
339 if (isterm
) put_byte(res
, 0);
345 *****************************************************************************
346 * Function : put_name_id
347 * Syntax : void put_name_id(res_t *res, name_id_t *nid, int upcase, const language_t *lang)
352 *****************************************************************************
354 static void put_name_id(res_t
*res
, name_id_t
*nid
, int upcase
, const language_t
*lang
)
356 if(nid
->type
== name_ord
)
359 put_word(res
, 0xffff);
362 put_word(res
, (WORD
)nid
->name
.i_name
);
364 else if(nid
->type
== name_str
)
367 string_to_upper(nid
->name
.s_name
);
368 put_string(res
, nid
->name
.s_name
, win32
? str_unicode
: str_char
, TRUE
, lang
);
372 internal_error(__FILE__
, __LINE__
, "Invalid name_id type %d\n", nid
->type
);
377 *****************************************************************************
379 * Syntax : void put_lvc(res_t *res, lvc_t *lvc)
384 *****************************************************************************
386 static void put_lvc(res_t
*res
, lvc_t
*lvc
)
388 if(lvc
&& lvc
->language
)
389 put_word(res
, MAKELANGID(lvc
->language
->id
, lvc
->language
->sub
));
391 put_word(res
, 0); /* Neutral */
392 if(lvc
&& lvc
->version
)
393 put_dword(res
, *(lvc
->version
));
396 if(lvc
&& lvc
->characts
)
397 put_dword(res
, *(lvc
->characts
));
403 *****************************************************************************
404 * Function : put_raw_data
405 * Syntax : void put_raw_data(res_t *res, raw_data_t *raw, int offset)
410 *****************************************************************************
412 static void put_raw_data(res_t
*res
, raw_data_t
*raw
, int offset
)
414 unsigned int wsize
= raw
->size
- offset
;
415 if(res
->allocsize
- res
->size
< wsize
)
416 grow_res(res
, wsize
);
417 memcpy(&(res
->data
[res
->size
]), raw
->data
+ offset
, wsize
);
422 *****************************************************************************
423 * Function : put_res_header
424 * Syntax : input_res_header(res_t *res, int type, name_id_t *ntype,
425 * name_id_t *name, DWORD memopt, lvc_t *lvc)
428 * res - Binary resource descriptor to write to
429 * type - Resource identifier (if ntype == NULL)
430 * ntype - Name id of type
431 * name - Resource's name
432 * memopt - Resource's memory options to write
433 * lvc - Language, version and characteristics (win32 only)
434 * Output : An index to the resource size field. The resource size field
435 * contains the header size upon exit.
438 *****************************************************************************
440 static int put_res_header(res_t
*res
, int type
, name_id_t
*ntype
, name_id_t
*name
,
441 DWORD memopt
, lvc_t
*lvc
)
445 put_dword(res
, 0); /* We will overwrite these later */
449 put_word(res
, 0xffff); /* ResType */
453 put_name_id(res
, ntype
, TRUE
, lvc
->language
);
454 put_name_id(res
, name
, TRUE
, lvc
->language
); /* ResName */
456 put_dword(res
, 0); /* DataVersion */
457 put_word(res
, memopt
); /* Memory options */
458 put_lvc(res
, lvc
); /* Language, version and characts */
459 set_dword(res
, 0*sizeof(DWORD
), res
->size
); /* Set preliminary resource */
460 set_dword(res
, 1*sizeof(DWORD
), res
->size
); /* Set HeaderSize */
461 res
->dataidx
= res
->size
;
469 put_byte(res
, 0xff); /* ResType */
473 put_name_id(res
, ntype
, TRUE
, NULL
);
474 put_name_id(res
, name
, TRUE
, NULL
); /* ResName */
475 put_word(res
, memopt
); /* Memory options */
477 put_dword(res
, 0); /* ResSize overwritten later*/
478 set_dword(res
, tag
, res
->size
);
479 res
->dataidx
= res
->size
;
485 *****************************************************************************
486 * Function : accelerator2res
487 * Syntax : res_t *accelerator2res(name_id_t *name, accelerator_t *acc)
489 * name - Name/ordinal of the resource
490 * acc - The accelerator descriptor
491 * Output : New .res format structure
494 *****************************************************************************
496 static res_t
*accelerator2res(name_id_t
*name
, accelerator_t
*acc
)
501 assert(name
!= NULL
);
508 restag
= put_res_header(res
, WRC_RT_ACCELERATOR
, NULL
, name
, acc
->memopt
, &(acc
->lvc
));
511 put_word(res
, ev
->flags
| (ev
->next
? 0 : 0x80));
512 put_word(res
, ev
->key
);
513 put_word(res
, ev
->id
);
514 put_word(res
, 0); /* Padding */
521 restag
= put_res_header(res
, WRC_RT_ACCELERATOR
, NULL
, name
, acc
->memopt
, NULL
);
524 put_byte(res
, ev
->flags
| (ev
->next
? 0 : 0x80));
525 put_word(res
, ev
->key
);
526 put_word(res
, ev
->id
);
530 /* Set ResourceSize */
531 SetResSize(res
, restag
);
536 *****************************************************************************
537 * Function : dialog2res
538 * Syntax : res_t *dialog2res(name_id_t *name, dialog_t *dlg)
540 * name - Name/ordinal of the resource
541 * dlg - The dialog descriptor
542 * Output : New .res format structure
545 *****************************************************************************
547 static res_t
*dialog2res(name_id_t
*name
, dialog_t
*dlg
)
554 assert(name
!= NULL
);
557 ctrl
= dlg
->controls
;
561 restag
= put_res_header(res
, WRC_RT_DIALOG
, NULL
, name
, dlg
->memopt
, &(dlg
->lvc
));
565 /* FIXME: MS doc says that the first word must contain 0xffff
566 * and the second 0x0001 to signal a DLGTEMPLATEEX. Borland's
567 * compiler reverses the two words.
568 * I don't know which one to choose, but I write it as Mr. B
571 put_word(res
, 1); /* Signature */
572 put_word(res
, 0xffff); /* DlgVer */
573 put_dword(res
, dlg
->gothelpid
? dlg
->helpid
: 0);
574 put_dword(res
, dlg
->gotexstyle
? dlg
->exstyle
->or_mask
: 0);
575 put_dword(res
, dlg
->gotstyle
? dlg
->style
->or_mask
: WS_POPUPWINDOW
);
579 put_dword(res
, dlg
->style
->or_mask
);
580 put_dword(res
, dlg
->gotexstyle
? dlg
->exstyle
->or_mask
: 0);
582 tag_nctrl
= res
->size
;
583 put_word(res
, 0); /* Number of controls */
584 put_word(res
, dlg
->x
);
585 put_word(res
, dlg
->y
);
586 put_word(res
, dlg
->width
);
587 put_word(res
, dlg
->height
);
589 put_name_id(res
, dlg
->menu
, TRUE
, dlg
->lvc
.language
);
593 put_name_id(res
, dlg
->dlgclass
, TRUE
, dlg
->lvc
.language
);
597 put_string(res
, dlg
->title
, str_unicode
, TRUE
, dlg
->lvc
.language
);
602 put_word(res
, dlg
->font
->size
);
605 put_word(res
, dlg
->font
->weight
);
606 /* FIXME: ? TRUE should be sufficient to say that it's
607 * italic, but Borland's compiler says it's 0x0101.
608 * I just copy it here, and hope for the best.
610 put_word(res
, dlg
->font
->italic
? 0x0101 : 0);
612 put_string(res
, dlg
->font
->name
, str_unicode
, TRUE
, dlg
->lvc
.language
);
620 put_dword(res
, ctrl
->gothelpid
? ctrl
->helpid
: 0);
621 put_dword(res
, ctrl
->gotexstyle
? ctrl
->exstyle
->or_mask
: 0);
622 /* FIXME: what is default control style? */
623 put_dword(res
, ctrl
->gotstyle
? ctrl
->style
->or_mask
: WS_CHILD
| WS_VISIBLE
);
627 /* FIXME: what is default control style? */
628 put_dword(res
, ctrl
->gotstyle
? ctrl
->style
->or_mask
: WS_CHILD
);
629 put_dword(res
, ctrl
->gotexstyle
? ctrl
->exstyle
->or_mask
: 0);
631 put_word(res
, ctrl
->x
);
632 put_word(res
, ctrl
->y
);
633 put_word(res
, ctrl
->width
);
634 put_word(res
, ctrl
->height
);
636 put_dword(res
, ctrl
->id
);
638 put_word(res
, ctrl
->id
);
640 put_name_id(res
, ctrl
->ctlclass
, TRUE
, dlg
->lvc
.language
);
642 internal_error(__FILE__
, __LINE__
, "Control has no control-class\n");
644 put_name_id(res
, ctrl
->title
, FALSE
, dlg
->lvc
.language
);
649 put_word(res
, ctrl
->extra
->size
+2);
651 put_raw_data(res
, ctrl
->extra
, 0);
661 /* Set number of controls */
662 set_word(res
, tag_nctrl
, (WORD
)nctrl
);
666 restag
= put_res_header(res
, WRC_RT_DIALOG
, NULL
, name
, dlg
->memopt
, NULL
);
668 put_dword(res
, dlg
->gotstyle
? dlg
->style
->or_mask
: WS_POPUPWINDOW
);
669 tag_nctrl
= res
->size
;
670 put_byte(res
, 0); /* Number of controls */
671 put_word(res
, dlg
->x
);
672 put_word(res
, dlg
->y
);
673 put_word(res
, dlg
->width
);
674 put_word(res
, dlg
->height
);
676 put_name_id(res
, dlg
->menu
, TRUE
, NULL
);
680 put_name_id(res
, dlg
->dlgclass
, TRUE
, NULL
);
684 put_string(res
, dlg
->title
, str_char
, TRUE
, NULL
);
689 put_word(res
, dlg
->font
->size
);
690 put_string(res
, dlg
->font
->name
, str_char
, TRUE
, NULL
);
695 put_word(res
, ctrl
->x
);
696 put_word(res
, ctrl
->y
);
697 put_word(res
, ctrl
->width
);
698 put_word(res
, ctrl
->height
);
699 put_word(res
, ctrl
->id
);
700 put_dword(res
, ctrl
->gotstyle
? ctrl
->style
->or_mask
: WS_CHILD
);
703 if(ctrl
->ctlclass
->type
== name_ord
704 && ctrl
->ctlclass
->name
.i_name
>= 0x80
705 && ctrl
->ctlclass
->name
.i_name
<= 0x85)
706 put_byte(res
, ctrl
->ctlclass
->name
.i_name
);
707 else if(ctrl
->ctlclass
->type
== name_str
)
708 put_name_id(res
, ctrl
->ctlclass
, FALSE
, NULL
);
710 error("Unknown control-class %04x\n", ctrl
->ctlclass
->name
.i_name
);
713 internal_error(__FILE__
, __LINE__
, "Control has no control-class\n");
715 put_name_id(res
, ctrl
->title
, FALSE
, NULL
);
719 /* FIXME: What is this extra byte doing here? */
725 /* Set number of controls */
726 ((char *)res
->data
)[tag_nctrl
] = (char)nctrl
;
728 /* Set ResourceSize */
729 SetResSize(res
, restag
);
734 *****************************************************************************
735 * Function : menuitem2res
736 * Syntax : void menuitem2res(res_t *res, menu_item_t *item)
740 * Remarks : Self recursive
741 *****************************************************************************
743 static void menuitem2res(res_t
*res
, menu_item_t
*menitem
, const language_t
*lang
)
745 menu_item_t
*itm
= menitem
;
750 put_word(res
, itm
->state
| (itm
->popup
? MF_POPUP
: 0) | (!itm
->next
? MF_END
: 0));
752 put_word(res
, itm
->id
);
754 put_string(res
, itm
->name
, str_unicode
, TRUE
, lang
);
758 menuitem2res(res
, itm
->popup
, lang
);
766 put_word(res
, itm
->state
| (itm
->popup
? MF_POPUP
: 0) | (!itm
->next
? MF_END
: 0));
768 put_word(res
, itm
->id
);
770 put_string(res
, itm
->name
, str_char
, TRUE
, lang
);
774 menuitem2res(res
, itm
->popup
, lang
);
782 *****************************************************************************
783 * Function : menuexitem2res
784 * Syntax : void menuexitem2res(res_t *res, menuex_item_t *item)
788 * Remarks : Self recursive
789 *****************************************************************************
791 static void menuexitem2res(res_t
*res
, menu_item_t
*menitem
, const language_t
*lang
)
793 menu_item_t
*itm
= menitem
;
797 put_dword(res
, itm
->gottype
? itm
->type
: 0);
798 put_dword(res
, itm
->gotstate
? itm
->state
: 0);
799 put_dword(res
, itm
->gotid
? itm
->id
: 0); /* FIXME: Docu. says word */
800 put_word(res
, (itm
->popup
? 0x01 : 0) | (!itm
->next
? MF_END
: 0));
802 put_string(res
, itm
->name
, str_unicode
, TRUE
, lang
);
808 put_dword(res
, itm
->gothelpid
? itm
->helpid
: 0);
809 menuexitem2res(res
, itm
->popup
, lang
);
817 *****************************************************************************
818 * Function : menu2res
819 * Syntax : res_t *menu2res(name_id_t *name, menu_t *men)
821 * name - Name/ordinal of the resource
822 * menex - The menuex descriptor
823 * Output : New .res format structure
826 *****************************************************************************
828 static res_t
*menu2res(name_id_t
*name
, menu_t
*men
)
832 assert(name
!= NULL
);
838 restag
= put_res_header(res
, WRC_RT_MENU
, NULL
, name
, men
->memopt
, &(men
->lvc
));
842 put_word(res
, 1); /* Menuheader: Version */
843 put_word(res
, 4); /* Offset */
844 put_dword(res
, 0); /* HelpId */
846 menuexitem2res(res
, men
->items
, men
->lvc
.language
);
850 put_dword(res
, 0); /* Menuheader: Version and HeaderSize */
851 menuitem2res(res
, men
->items
, men
->lvc
.language
);
853 /* Set ResourceSize */
854 SetResSize(res
, restag
);
859 restag
= put_res_header(res
, WRC_RT_MENU
, NULL
, name
, men
->memopt
, NULL
);
861 put_dword(res
, 0); /* Menuheader: Version and HeaderSize */
862 menuitem2res(res
, men
->items
, NULL
);
863 /* Set ResourceSize */
864 SetResSize(res
, restag
);
870 *****************************************************************************
871 * Function : cursorgroup2res
872 * Syntax : res_t *cursorgroup2res(name_id_t *name, cursor_group_t *curg)
874 * name - Name/ordinal of the resource
875 * curg - The cursor descriptor
876 * Output : New .res format structure
879 *****************************************************************************
881 static res_t
*cursorgroup2res(name_id_t
*name
, cursor_group_t
*curg
)
886 assert(name
!= NULL
);
887 assert(curg
!= NULL
);
890 restag
= put_res_header(res
, WRC_RT_GROUP_CURSOR
, NULL
, name
, curg
->memopt
, &(curg
->lvc
));
893 put_word(res
, 0); /* Reserved */
894 /* FIXME: The ResType in the NEWHEADER structure should
895 * contain 14 according to the MS win32 doc. This is
896 * not the case with the BRC compiler and I really doubt
897 * the latter. Putting one here is compliant to win16 spec,
898 * but who knows the true value?
900 put_word(res
, 2); /* ResType */
901 put_word(res
, curg
->ncursor
);
903 for(cur
= curg
->cursorlist
; cur
; cur
= cur
->next
)
905 cur
= curg
->cursorlist
;
908 for(; cur
; cur
= cur
->prev
)
911 put_word(res
, cur
->width
);
912 /* FIXME: The height of a cursor is half the size of
913 * the bitmap's height. BRC puts the height from the
914 * BITMAPINFOHEADER here instead of the cursorfile's
915 * height. MS doesn't seem to care...
917 put_word(res
, cur
->height
);
918 /* FIXME: The next two are reversed in BRC and I don't
919 * know why. Probably a bug. But, we can safely ignore
920 * it because win16 does not support color cursors.
921 * A warning should have been generated by the parser.
923 put_word(res
, cur
->planes
);
924 put_word(res
, cur
->bits
);
925 /* FIXME: The +4 is the hotspot in the cursor resource.
926 * However, I could not find this in the documentation.
927 * The hotspot bytes must either be included or MS
930 put_dword(res
, cur
->data
->size
+4);
931 put_word(res
, cur
->id
);
936 put_word(res
, 0); /* Reserved */
937 put_word(res
, 2); /* ResType */
938 put_word(res
, curg
->ncursor
);
940 for(cur
= curg
->cursorlist
; cur
; cur
= cur
->next
)
942 cur
= curg
->cursorlist
;
945 for(; cur
; cur
= cur
->prev
)
948 put_word(res
, cur
->width
);
949 /* FIXME: The height of a cursor is half the size of
950 * the bitmap's height. BRC puts the height from the
951 * BITMAPINFOHEADER here instead of the cursorfile's
952 * height. MS doesn't seem to care...
954 put_word(res
, cur
->height
);
955 /* FIXME: The next two are reversed in BRC and I don't
956 * know why. Probably a bug. But, we can safely ignore
957 * it because win16 does not support color cursors.
958 * A warning should have been generated by the parser.
960 put_word(res
, cur
->planes
);
961 put_word(res
, cur
->bits
);
962 /* FIXME: The +4 is the hotspot in the cursor resource.
963 * However, I could not find this in the documentation.
964 * The hotspot bytes must either be included or MS
967 put_dword(res
, cur
->data
->size
+4);
968 put_word(res
, cur
->id
);
971 SetResSize(res
, restag
); /* Set ResourceSize */
979 *****************************************************************************
980 * Function : cursor2res
981 * Syntax : res_t *cursor2res(cursor_t *cur)
983 * cur - The cursor descriptor
984 * Output : New .res format structure
987 *****************************************************************************
989 static res_t
*cursor2res(cursor_t
*cur
)
998 name
.type
= name_ord
;
999 name
.name
.i_name
= cur
->id
;
1000 restag
= put_res_header(res
, WRC_RT_CURSOR
, NULL
, &name
, WRC_MO_MOVEABLE
| WRC_MO_DISCARDABLE
, &(cur
->lvc
));
1001 put_word(res
, cur
->xhot
);
1002 put_word(res
, cur
->yhot
);
1003 put_raw_data(res
, cur
->data
, 0);
1005 SetResSize(res
, restag
); /* Set ResourceSize */
1013 *****************************************************************************
1014 * Function : icongroup2res
1015 * Syntax : res_t *icongroup2res(name_id_t *name, icon_group_t *icog)
1017 * name - Name/ordinal of the resource
1018 * icog - The icon group descriptor
1019 * Output : New .res format structure
1022 *****************************************************************************
1024 static res_t
*icongroup2res(name_id_t
*name
, icon_group_t
*icog
)
1029 assert(name
!= NULL
);
1030 assert(icog
!= NULL
);
1033 restag
= put_res_header(res
, WRC_RT_GROUP_ICON
, NULL
, name
, icog
->memopt
, &(icog
->lvc
));
1036 put_word(res
, 0); /* Reserved */
1037 /* FIXME: The ResType in the NEWHEADER structure should
1038 * contain 14 according to the MS win32 doc. This is
1039 * not the case with the BRC compiler and I really doubt
1040 * the latter. Putting one here is compliant to win16 spec,
1041 * but who knows the true value?
1043 put_word(res
, 1); /* ResType */
1044 put_word(res
, icog
->nicon
);
1045 for(ico
= icog
->iconlist
; ico
; ico
= ico
->next
)
1047 put_byte(res
, ico
->width
);
1048 put_byte(res
, ico
->height
);
1049 put_byte(res
, ico
->nclr
);
1050 put_byte(res
, 0); /* Reserved */
1051 put_word(res
, ico
->planes
);
1052 put_word(res
, ico
->bits
);
1053 put_dword(res
, ico
->data
->size
);
1054 put_word(res
, ico
->id
);
1059 put_word(res
, 0); /* Reserved */
1060 put_word(res
, 1); /* ResType */
1061 put_word(res
, icog
->nicon
);
1062 for(ico
= icog
->iconlist
; ico
; ico
= ico
->next
)
1064 put_byte(res
, ico
->width
);
1065 put_byte(res
, ico
->height
);
1066 put_byte(res
, ico
->nclr
);
1067 put_byte(res
, 0); /* Reserved */
1068 put_word(res
, ico
->planes
);
1069 put_word(res
, ico
->bits
);
1070 put_dword(res
, ico
->data
->size
);
1071 put_word(res
, ico
->id
);
1074 SetResSize(res
, restag
); /* Set ResourceSize */
1082 *****************************************************************************
1083 * Function : icon2res
1084 * Syntax : res_t *icon2res(icon_t *ico)
1086 * ico - The icon descriptor
1087 * Output : New .res format structure
1090 *****************************************************************************
1092 static res_t
*icon2res(icon_t
*ico
)
1098 assert(ico
!= NULL
);
1101 name
.type
= name_ord
;
1102 name
.name
.i_name
= ico
->id
;
1103 restag
= put_res_header(res
, WRC_RT_ICON
, NULL
, &name
, WRC_MO_MOVEABLE
| WRC_MO_DISCARDABLE
, &(ico
->lvc
));
1104 put_raw_data(res
, ico
->data
, 0);
1106 SetResSize(res
, restag
); /* Set ResourceSize */
1114 *****************************************************************************
1115 * Function : anicurico2res
1116 * Syntax : res_t *anicurico2res(name_id_t *name, ani_curico_t *ani)
1118 * name - Name/ordinal of the resource
1119 * ani - The animated object descriptor
1120 * Output : New .res format structure
1122 * Remarks : The endian of the object's structures have been converted
1124 * There are rumors that win311 could handle animated stuff.
1125 * That is why they are generated for both win16 and win32
1127 *****************************************************************************
1129 static res_t
*anicurico2res(name_id_t
*name
, ani_curico_t
*ani
, enum res_e type
)
1133 assert(name
!= NULL
);
1134 assert(ani
!= NULL
);
1137 restag
= put_res_header(res
, type
== res_anicur
? WRC_RT_ANICURSOR
: WRC_RT_ANIICON
,
1138 NULL
, name
, ani
->memopt
, NULL
);
1139 put_raw_data(res
, ani
->data
, 0);
1140 /* Set ResourceSize */
1141 SetResSize(res
, restag
);
1148 *****************************************************************************
1149 * Function : bitmap2res
1150 * Syntax : res_t *bitmap2res(name_id_t *name, bitmap_t *bmp)
1152 * name - Name/ordinal of the resource
1153 * bmp - The bitmap descriptor
1154 * Output : New .res format structure
1156 * Remarks : The endian of the bitmap structures have been converted
1158 *****************************************************************************
1160 static res_t
*bitmap2res(name_id_t
*name
, bitmap_t
*bmp
)
1164 assert(name
!= NULL
);
1165 assert(bmp
!= NULL
);
1168 restag
= put_res_header(res
, WRC_RT_BITMAP
, NULL
, name
, bmp
->memopt
, &(bmp
->data
->lvc
));
1169 if(bmp
->data
->data
[0] == 'B'
1170 && bmp
->data
->data
[1] == 'M'
1171 && ((BITMAPFILEHEADER
*)bmp
->data
->data
)->bfSize
== bmp
->data
->size
1172 && bmp
->data
->size
>= sizeof(BITMAPFILEHEADER
))
1174 /* The File header is still attached, don't write it */
1175 put_raw_data(res
, bmp
->data
, sizeof(BITMAPFILEHEADER
));
1179 put_raw_data(res
, bmp
->data
, 0);
1181 /* Set ResourceSize */
1182 SetResSize(res
, restag
);
1189 *****************************************************************************
1190 * Function : font2res
1191 * Syntax : res_t *font2res(name_id_t *name, font_t *fnt)
1193 * name - Name/ordinal of the resource
1194 * fnt - The font descriptor
1195 * Output : New .res format structure
1197 * Remarks : The data has been prepared just after parsing.
1198 *****************************************************************************
1200 static res_t
*font2res(name_id_t
*name
, font_t
*fnt
)
1204 assert(name
!= NULL
);
1205 assert(fnt
!= NULL
);
1208 restag
= put_res_header(res
, WRC_RT_FONT
, NULL
, name
, fnt
->memopt
, &(fnt
->data
->lvc
));
1209 put_raw_data(res
, fnt
->data
, 0);
1210 /* Set ResourceSize */
1211 SetResSize(res
, restag
);
1218 *****************************************************************************
1219 * Function : fontdir2res
1220 * Syntax : res_t *fontdir2res(name_id_t *name, fontdir_t *fnd)
1222 * name - Name/ordinal of the resource
1223 * fntdir - The fontdir descriptor
1224 * Output : New .res format structure
1226 * Remarks : The data has been prepared just after parsing.
1227 *****************************************************************************
1229 static res_t
*fontdir2res(name_id_t
*name
, fontdir_t
*fnd
)
1233 assert(name
!= NULL
);
1234 assert(fnd
!= NULL
);
1237 restag
= put_res_header(res
, WRC_RT_FONTDIR
, NULL
, name
, fnd
->memopt
, &(fnd
->data
->lvc
));
1238 put_raw_data(res
, fnd
->data
, 0);
1239 /* Set ResourceSize */
1240 SetResSize(res
, restag
);
1247 *****************************************************************************
1248 * Function : html2res
1249 * Syntax : res_t *html2res(name_id_t *name, html_t *html)
1251 * name - Name/ordinal of the resource
1252 * rdt - The html descriptor
1253 * Output : New .res format structure
1256 *****************************************************************************
1258 static res_t
*html2res(name_id_t
*name
, html_t
*html
)
1262 assert(name
!= NULL
);
1263 assert(html
!= NULL
);
1266 restag
= put_res_header(res
, WRC_RT_HTML
, NULL
, name
, html
->memopt
, &(html
->data
->lvc
));
1267 put_raw_data(res
, html
->data
, 0);
1268 /* Set ResourceSize */
1269 SetResSize(res
, restag
);
1276 *****************************************************************************
1277 * Function : rcdata2res
1278 * Syntax : res_t *rcdata2res(name_id_t *name, rcdata_t *rdt)
1280 * name - Name/ordinal of the resource
1281 * rdt - The rcdata descriptor
1282 * Output : New .res format structure
1285 *****************************************************************************
1287 static res_t
*rcdata2res(name_id_t
*name
, rcdata_t
*rdt
)
1291 assert(name
!= NULL
);
1292 assert(rdt
!= NULL
);
1295 restag
= put_res_header(res
, WRC_RT_RCDATA
, NULL
, name
, rdt
->memopt
, &(rdt
->data
->lvc
));
1296 put_raw_data(res
, rdt
->data
, 0);
1297 /* Set ResourceSize */
1298 SetResSize(res
, restag
);
1305 *****************************************************************************
1306 * Function : messagetable2res
1307 * Syntax : res_t *messagetable2res(name_id_t *name, messagetable_t *msg)
1309 * name - Name/ordinal of the resource
1310 * msg - The messagetable descriptor
1311 * Output : New .res format structure
1313 * Remarks : The data has been converted to the appropriate endian
1314 * after it was parsed.
1315 *****************************************************************************
1317 static res_t
*messagetable2res(name_id_t
*name
, messagetable_t
*msg
)
1321 assert(name
!= NULL
);
1322 assert(msg
!= NULL
);
1325 restag
= put_res_header(res
, WRC_RT_MESSAGETABLE
, NULL
, name
, msg
->memopt
, &(msg
->data
->lvc
));
1326 put_raw_data(res
, msg
->data
, 0);
1327 /* Set ResourceSize */
1328 SetResSize(res
, restag
);
1335 *****************************************************************************
1336 * Function : stringtable2res
1337 * Syntax : res_t *stringtable2res(stringtable_t *stt)
1339 * stt - The stringtable descriptor
1340 * Output : New .res format structure
1343 *****************************************************************************
1345 static res_t
*stringtable2res(stringtable_t
*stt
)
1353 assert(stt
!= NULL
);
1356 for(; stt
; stt
= stt
->next
)
1360 warning("Empty internal stringtable\n");
1363 name
.type
= name_ord
;
1364 name
.name
.i_name
= (stt
->idbase
>> 4) + 1;
1365 restag
= put_res_header(res
, WRC_RT_STRING
, NULL
, &name
, stt
->memopt
, win32
? &(stt
->lvc
) : NULL
);
1366 for(i
= 0; i
< stt
->nentries
; i
++)
1368 if(stt
->entries
[i
].str
&& stt
->entries
[i
].str
->size
)
1370 put_string(res
, stt
->entries
[i
].str
, win32
? str_unicode
: str_char
,
1371 FALSE
, win32
? stt
->lvc
.language
: NULL
);
1381 /* Set ResourceSize */
1382 SetResSize(res
, restag
- lastsize
);
1385 lastsize
= res
->size
;
1391 *****************************************************************************
1392 * Function : user2res
1393 * Syntax : res_t *user2res(name_id_t *name, user_t *usr)
1395 * name - Name/ordinal of the resource
1396 * usr - The userresource descriptor
1397 * Output : New .res format structure
1400 *****************************************************************************
1402 static res_t
*user2res(name_id_t
*name
, user_t
*usr
)
1406 assert(name
!= NULL
);
1407 assert(usr
!= NULL
);
1410 restag
= put_res_header(res
, 0, usr
->type
, name
, usr
->memopt
, &(usr
->data
->lvc
));
1411 put_raw_data(res
, usr
->data
, 0);
1412 /* Set ResourceSize */
1413 SetResSize(res
, restag
);
1420 *****************************************************************************
1421 * Function : versionblock2res
1422 * Syntax : void versionblock2res(res_t *res, ver_block_t *blk)
1424 * res - Binary resource to write to
1425 * blk - The version block to be written
1428 * Remarks : Self recursive
1429 *****************************************************************************
1431 static void versionblock2res(res_t
*res
, ver_block_t
*blk
, int level
, const language_t
*lang
)
1440 blksizetag
= res
->size
;
1441 put_word(res
, 0); /* Will be overwritten later */
1444 put_word(res
, 0); /* level ? */
1445 put_string(res
, blk
->name
, win32
? str_unicode
: str_char
, TRUE
, lang
);
1447 for(val
= blk
->values
; val
; val
= val
->next
)
1449 if(val
->type
== val_str
)
1451 valblksizetag
= res
->size
;
1452 put_word(res
, 0); /* Will be overwritten later */
1453 valvalsizetag
= res
->size
;
1454 put_word(res
, 0); /* Will be overwritten later */
1457 put_word(res
, level
);
1459 put_string(res
, val
->key
, win32
? str_unicode
: str_char
, TRUE
, lang
);
1462 put_string(res
, val
->value
.str
, win32
? str_unicode
: str_char
, TRUE
, lang
);
1464 set_word(res
, valvalsizetag
, (WORD
)((res
->size
- tag
) >> 1));
1466 set_word(res
, valvalsizetag
, (WORD
)(res
->size
- tag
));
1467 set_word(res
, valblksizetag
, (WORD
)(res
->size
- valblksizetag
));
1470 else if(val
->type
== val_words
)
1472 valblksizetag
= res
->size
;
1473 put_word(res
, 0); /* Will be overwritten later */
1474 valvalsizetag
= res
->size
;
1475 put_word(res
, 0); /* Will be overwritten later */
1478 put_word(res
, level
);
1480 put_string(res
, val
->key
, win32
? str_unicode
: str_char
, TRUE
, lang
);
1483 for(i
= 0; i
< val
->value
.words
->nwords
; i
++)
1485 put_word(res
, val
->value
.words
->words
[i
]);
1487 set_word(res
, valvalsizetag
, (WORD
)(res
->size
- tag
));
1488 set_word(res
, valblksizetag
, (WORD
)(res
->size
- valblksizetag
));
1491 else if(val
->type
== val_block
)
1493 versionblock2res(res
, val
->value
.block
, level
+1, lang
);
1497 internal_error(__FILE__
, __LINE__
, "Invalid value indicator %d in VERSIONINFO\n", val
->type
);
1502 set_word(res
, blksizetag
, (WORD
)(res
->size
- blksizetag
));
1506 *****************************************************************************
1507 * Function : versioninfo2res
1508 * Syntax : res_t *versioninfo2res(name_id_t *name, versioninfo_t *ver)
1510 * name - Name/ordinal of the resource
1511 * ver - The versioninfo descriptor
1512 * Output : New .res format structure
1515 *****************************************************************************
1517 static res_t
*versioninfo2res(name_id_t
*name
, versioninfo_t
*ver
)
1520 int rootblocksizetag
;
1527 assert(name
!= NULL
);
1528 assert(ver
!= NULL
);
1530 vsvi
.type
= str_char
;
1531 vsvi
.str
.cstr
= xstrdup("VS_VERSION_INFO");
1532 vsvi
.size
= 15; /* Excl. termination */
1535 restag
= put_res_header(res
, WRC_RT_VERSION
, NULL
, name
, ver
->memopt
, &(ver
->lvc
));
1536 rootblocksizetag
= res
->size
;
1537 put_word(res
, 0); /* BlockSize filled in later */
1538 valsizetag
= res
->size
;
1539 put_word(res
, 0); /* ValueSize filled in later*/
1541 put_word(res
, 0); /* Tree-level ? */
1542 put_string(res
, &vsvi
, win32
? str_unicode
: str_char
,
1543 TRUE
, win32
? ver
->lvc
.language
: NULL
);
1547 put_dword(res
, VS_FFI_SIGNATURE
);
1548 put_dword(res
, VS_FFI_STRUCVERSION
);
1549 put_dword(res
, (ver
->filever_maj1
<< 16) + (ver
->filever_maj2
& 0xffff));
1550 put_dword(res
, (ver
->filever_min1
<< 16) + (ver
->filever_min2
& 0xffff));
1551 put_dword(res
, (ver
->prodver_maj1
<< 16) + (ver
->prodver_maj2
& 0xffff));
1552 put_dword(res
, (ver
->prodver_min1
<< 16) + (ver
->prodver_min2
& 0xffff));
1553 put_dword(res
, ver
->fileflagsmask
);
1554 put_dword(res
, ver
->fileflags
);
1555 put_dword(res
, ver
->fileos
);
1556 put_dword(res
, ver
->filetype
);
1557 put_dword(res
, ver
->filesubtype
);
1558 put_dword(res
, 0); /* FileDateMS */
1559 put_dword(res
, 0); /* FileDateLS */
1561 set_word(res
, valsizetag
, (WORD
)(res
->size
- tag
));
1562 /* Descend into the blocks */
1563 for(blk
= ver
->blocks
; blk
; blk
= blk
->next
)
1564 versionblock2res(res
, blk
, 0, win32
? ver
->lvc
.language
: NULL
);
1565 /* Set root block's size */
1566 set_word(res
, rootblocksizetag
, (WORD
)(res
->size
- rootblocksizetag
));
1568 SetResSize(res
, restag
);
1572 free(vsvi
.str
.cstr
);
1577 *****************************************************************************
1578 * Function : toolbaritem2res
1579 * Syntax : void toolbaritem2res(res_t *res, toolbar_item_t *tbitem)
1583 * Remarks : Self recursive
1584 *****************************************************************************
1586 static void toolbaritem2res(res_t
*res
, toolbar_item_t
*tbitem
)
1588 toolbar_item_t
*itm
= tbitem
;
1592 put_word(res
, itm
->id
);
1599 *****************************************************************************
1600 * Function : toolbar2res
1601 * Syntax : res_t *toolbar2res(name_id_t *name, toolbar_t *toolbar)
1603 * name - Name/ordinal of the resource
1604 * toolbar - The toolbar descriptor
1605 * Output : New .res format structure
1608 *****************************************************************************
1610 static res_t
*toolbar2res(name_id_t
*name
, toolbar_t
*toolbar
)
1614 assert(name
!= NULL
);
1615 assert(toolbar
!= NULL
);
1620 restag
= put_res_header(res
, WRC_RT_TOOLBAR
, NULL
, name
, toolbar
->memopt
, &(toolbar
->lvc
));
1622 put_word(res
, 1); /* Menuheader: Version */
1623 put_word(res
, toolbar
->button_width
); /* (in pixels?) */
1624 put_word(res
, toolbar
->button_height
); /* (in pixels?) */
1625 put_word(res
, toolbar
->nitems
);
1627 toolbaritem2res(res
, toolbar
->items
);
1628 /* Set ResourceSize */
1629 SetResSize(res
, restag
);
1634 /* Do not generate anything in 16-bit mode */
1643 *****************************************************************************
1644 * Function : dlginit2res
1645 * Syntax : res_t *dlginit2res(name_id_t *name, dlginit_t *dit)
1647 * name - Name/ordinal of the resource
1648 * rdt - The dlginit descriptor
1649 * Output : New .res format structure
1652 *****************************************************************************
1654 static res_t
*dlginit2res(name_id_t
*name
, dlginit_t
*dit
)
1658 assert(name
!= NULL
);
1659 assert(dit
!= NULL
);
1662 restag
= put_res_header(res
, WRC_RT_DLGINIT
, NULL
, name
, dit
->memopt
, &(dit
->data
->lvc
));
1663 put_raw_data(res
, dit
->data
, 0);
1664 /* Set ResourceSize */
1665 SetResSize(res
, restag
);
1672 *****************************************************************************
1673 * Function : prep_nid_for_label
1674 * Syntax : char *prep_nid_for_label(const name_id_t *nid)
1677 * Description : Converts a resource name into the first 32 (or less)
1678 * characters of the name with conversions.
1680 *****************************************************************************
1682 #define MAXNAMELEN 32
1683 char *prep_nid_for_label(const name_id_t
*nid
)
1685 static char buf
[MAXNAMELEN
+1];
1687 assert(nid
!= NULL
);
1689 if(nid
->type
== name_str
&& nid
->name
.s_name
->type
== str_unicode
)
1693 sptr
= nid
->name
.s_name
->str
.wstr
;
1695 for(i
= 0; *sptr
&& i
< MAXNAMELEN
; i
++)
1697 if((unsigned)*sptr
< 0x80 && isprint(*sptr
& 0xff))
1700 warning("Resourcename (str_unicode) contain unprintable characters or invalid translation, ignored\n");
1704 else if(nid
->type
== name_str
&& nid
->name
.s_name
->type
== str_char
)
1708 cptr
= nid
->name
.s_name
->str
.cstr
;
1710 for(i
= 0; *cptr
&& i
< MAXNAMELEN
; i
++)
1712 if((unsigned)*cptr
< 0x80 && isprint(*cptr
& 0xff))
1715 warning("Resourcename (str_char) contain unprintable characters, ignored\n");
1719 else if(nid
->type
== name_ord
)
1721 sprintf(buf
, "%u", nid
->name
.i_name
);
1725 internal_error(__FILE__
, __LINE__
, "Resource name_id with invalid type %d\n", nid
->type
);
1732 *****************************************************************************
1733 * Function : make_c_name
1734 * Syntax : char *make_c_name(const char *base, const name_id_t *nid, const language_t *lan)
1737 * Description : Converts a resource name into a valid c-identifier in the
1740 *****************************************************************************
1742 char *make_c_name(const char *base
, const name_id_t
*nid
, const language_t
*lan
)
1749 sprintf(lanbuf
, "%d", lan
? MAKELANGID(lan
->id
, lan
->sub
) : 0);
1750 buf
= prep_nid_for_label(nid
);
1751 nlen
= strlen(buf
) + strlen(lanbuf
);
1752 nlen
+= strlen(base
) + 4; /* three time '_' and '\0' */
1753 ret
= xmalloc(nlen
);
1759 strcat(ret
, lanbuf
);
1764 *****************************************************************************
1765 * Function : get_c_typename
1766 * Syntax : const char *get_c_typename(enum res_e type)
1769 * Description : Convert resource enum to char string to be used in c-name
1772 *****************************************************************************
1774 const char *get_c_typename(enum res_e type
)
1778 case res_acc
: return "Acc";
1779 case res_anicur
:return "AniCur";
1780 case res_aniico
:return "AniIco";
1781 case res_bmp
: return "Bmp";
1782 case res_cur
: return "Cur";
1783 case res_curg
: return "CurGrp";
1784 case res_dlg
: return "Dlg";
1785 case res_fnt
: return "Fnt";
1786 case res_fntdir
:return "FntDir";
1787 case res_ico
: return "Ico";
1788 case res_icog
: return "IcoGrp";
1789 case res_men
: return "Men";
1790 case res_rdt
: return "RCDat";
1791 case res_stt
: return "StrTab";
1792 case res_usr
: return "Usr";
1793 case res_msg
: return "MsgTab";
1794 case res_ver
: return "VerInf";
1795 case res_toolbar
: return "TlBr";
1796 case res_dlginit
: return "DlgInit";
1797 default: return "Oops";
1802 *****************************************************************************
1803 * Function : resources2res
1804 * Syntax : void resources2res(resource_t *top)
1806 * top - The resource-tree to convert
1808 * Description : Convert logical resource descriptors into binary data
1810 *****************************************************************************
1812 void resources2res(resource_t
*top
)
1820 top
->binres
= accelerator2res(top
->name
, top
->res
.acc
);
1824 top
->binres
= bitmap2res(top
->name
, top
->res
.bmp
);
1828 top
->binres
= cursor2res(top
->res
.cur
);
1832 top
->binres
= cursorgroup2res(top
->name
, top
->res
.curg
);
1836 top
->binres
= dialog2res(top
->name
, top
->res
.dlg
);
1840 top
->binres
= font2res(top
->name
, top
->res
.fnt
);
1844 top
->binres
= fontdir2res(top
->name
, top
->res
.fnd
);
1848 top
->binres
= icon2res(top
->res
.ico
);
1852 top
->binres
= icongroup2res(top
->name
, top
->res
.icog
);
1856 top
->binres
= menu2res(top
->name
, top
->res
.men
);
1860 top
->binres
= html2res(top
->name
, top
->res
.html
);
1864 top
->binres
= rcdata2res(top
->name
, top
->res
.rdt
);
1868 top
->binres
= stringtable2res(top
->res
.stt
);
1872 top
->binres
= user2res(top
->name
, top
->res
.usr
);
1876 top
->binres
= messagetable2res(top
->name
, top
->res
.msg
);
1880 top
->binres
= versioninfo2res(top
->name
, top
->res
.ver
);
1884 top
->binres
= toolbar2res(top
->name
, top
->res
.tbt
);
1888 top
->binres
= dlginit2res(top
->name
, top
->res
.dlgi
);
1893 top
->binres
= anicurico2res(top
->name
, top
->res
.ani
, top
->type
);
1896 internal_error(__FILE__
, __LINE__
, "Unknown resource type encountered %d in binary res generation\n", top
->type
);
1898 top
->c_name
= make_c_name(get_c_typename(top
->type
), top
->name
, top
->lan
);