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.
45 #define SetResSize(res, tag) set_dword((res), (tag), (res)->size - get_dword((res), (tag)))
50 r
= xmalloc(sizeof(res_t
));
51 r
->allocsize
= RES_BLOCKSIZE
;
54 r
->data
= xmalloc(RES_BLOCKSIZE
);
58 res_t
*grow_res(res_t
*r
, unsigned int add
)
61 r
->data
= xrealloc(r
->data
, r
->allocsize
);
66 *****************************************************************************
70 * Syntax : void put_byte(res_t *res, unsigned c)
71 * void put_word(res_t *res, unsigned w)
72 * void put_dword(res_t *res, unsigned d)
74 * res - Binary resource to put the data in
75 * c, w, d - Data to put
77 * Description : Put primitives that put an item in the binary resource.
78 * The data array grows automatically.
80 *****************************************************************************
82 void put_byte(res_t
*res
, unsigned c
)
84 if(res
->allocsize
- res
->size
< sizeof(char))
85 grow_res(res
, RES_BLOCKSIZE
);
86 res
->data
[res
->size
] = (char)c
;
87 res
->size
+= sizeof(char);
90 void put_word(res_t
*res
, unsigned w
)
92 if(res
->allocsize
- res
->size
< sizeof(WORD
))
93 grow_res(res
, RES_BLOCKSIZE
);
96 #ifdef WORDS_BIGENDIAN
100 res
->data
[res
->size
+0] = HIBYTE(w
);
101 res
->data
[res
->size
+1] = LOBYTE(w
);
104 #ifndef WORDS_BIGENDIAN
108 res
->data
[res
->size
+1] = HIBYTE(w
);
109 res
->data
[res
->size
+0] = LOBYTE(w
);
112 res
->size
+= sizeof(WORD
);
115 void put_dword(res_t
*res
, unsigned d
)
117 if(res
->allocsize
- res
->size
< sizeof(DWORD
))
118 grow_res(res
, RES_BLOCKSIZE
);
121 #ifdef WORDS_BIGENDIAN
125 res
->data
[res
->size
+0] = HIBYTE(HIWORD(d
));
126 res
->data
[res
->size
+1] = LOBYTE(HIWORD(d
));
127 res
->data
[res
->size
+2] = HIBYTE(LOWORD(d
));
128 res
->data
[res
->size
+3] = LOBYTE(LOWORD(d
));
131 #ifndef WORDS_BIGENDIAN
135 res
->data
[res
->size
+3] = HIBYTE(HIWORD(d
));
136 res
->data
[res
->size
+2] = LOBYTE(HIWORD(d
));
137 res
->data
[res
->size
+1] = HIBYTE(LOWORD(d
));
138 res
->data
[res
->size
+0] = LOBYTE(LOWORD(d
));
141 res
->size
+= sizeof(DWORD
);
144 static void put_pad(res_t
*res
)
146 while(res
->size
& 0x3)
151 *****************************************************************************
152 * Function : set_word
154 * Syntax : void set_word(res_t *res, int ofs, unsigned w)
155 * void set_dword(res_t *res, int ofs, unsigned d)
157 * res - Binary resource to put the data in
158 * ofs - Byte offset in data-array
161 * Description : Set the value of a binary resource data array to a
164 *****************************************************************************
166 static void set_word(res_t
*res
, int ofs
, unsigned w
)
170 #ifdef WORDS_BIGENDIAN
174 res
->data
[ofs
+0] = HIBYTE(w
);
175 res
->data
[ofs
+1] = LOBYTE(w
);
178 #ifndef WORDS_BIGENDIAN
182 res
->data
[ofs
+1] = HIBYTE(w
);
183 res
->data
[ofs
+0] = LOBYTE(w
);
188 static void set_dword(res_t
*res
, int ofs
, unsigned d
)
192 #ifdef WORDS_BIGENDIAN
196 res
->data
[ofs
+0] = HIBYTE(HIWORD(d
));
197 res
->data
[ofs
+1] = LOBYTE(HIWORD(d
));
198 res
->data
[ofs
+2] = HIBYTE(LOWORD(d
));
199 res
->data
[ofs
+3] = LOBYTE(LOWORD(d
));
202 #ifndef WORDS_BIGENDIAN
206 res
->data
[ofs
+3] = HIBYTE(HIWORD(d
));
207 res
->data
[ofs
+2] = LOBYTE(HIWORD(d
));
208 res
->data
[ofs
+1] = HIBYTE(LOWORD(d
));
209 res
->data
[ofs
+0] = LOBYTE(LOWORD(d
));
215 *****************************************************************************
216 * Function : get_dword
218 * res - Binary resource to put the data in
219 * ofs - Byte offset in data-array
220 * Output : The data in native endian
221 * Description : Get the value of a binary resource data array in native
224 *****************************************************************************
226 static DWORD
get_dword(res_t
*res
, int ofs
)
230 #ifdef WORDS_BIGENDIAN
234 return (res
->data
[ofs
+0] << 24)
235 | (res
->data
[ofs
+1] << 16)
236 | (res
->data
[ofs
+2] << 8)
239 #ifndef WORDS_BIGENDIAN
243 return (res
->data
[ofs
+3] << 24)
244 | (res
->data
[ofs
+2] << 16)
245 | (res
->data
[ofs
+1] << 8)
251 *****************************************************************************
252 * Function : string_to_upper
253 * Syntax : void string_to_upper(string_t *str)
257 * Remarks : FIXME: codepages...
258 *****************************************************************************
260 static void string_to_upper(string_t
*str
)
264 if(str
->type
== str_char
)
266 for (i
= 0; i
< str
->size
; i
++) str
->str
.cstr
[i
] = toupper((unsigned char)str
->str
.cstr
[i
]);
268 else if(str
->type
== str_unicode
)
270 for (i
= 0; i
< str
->size
; i
++) str
->str
.wstr
[i
] = toupperW(str
->str
.wstr
[i
]);
274 internal_error(__FILE__
, __LINE__
, "Invalid string type %d\n", str
->type
);
278 static int parse_accel_string( const string_t
*key
, int flags
)
282 if(key
->type
== str_char
)
284 if (key
->str
.cstr
[0] == '#') return 0; /* ignore message contexts */
285 if((flags
& WRC_AF_VIRTKEY
) &&
286 !((key
->str
.cstr
[0] >= 'A' && key
->str
.cstr
[0] <= 'Z') ||
287 (key
->str
.cstr
[0] >= '0' && key
->str
.cstr
[0] <= '9')))
289 print_location( &key
->loc
);
290 error("VIRTKEY code is not equal to ascii value\n");
293 if(key
->str
.cstr
[0] == '^' && (flags
& WRC_AF_CONTROL
) != 0)
295 print_location( &key
->loc
);
296 error("Cannot use both '^' and CONTROL modifier\n");
298 else if(key
->str
.cstr
[0] == '^')
300 keycode
= toupper((unsigned char)key
->str
.cstr
[1]) - '@';
303 print_location( &key
->loc
);
304 error("Control-code out of range\n");
308 keycode
= key
->str
.cstr
[0];
312 if (key
->str
.wstr
[0] == '#') return 0; /* ignore message contexts */
313 if((flags
& WRC_AF_VIRTKEY
) &&
314 !((key
->str
.wstr
[0] >= 'A' && key
->str
.wstr
[0] <= 'Z') ||
315 (key
->str
.wstr
[0] >= '0' && key
->str
.wstr
[0] <= '9')))
317 print_location( &key
->loc
);
318 error("VIRTKEY code is not equal to ascii value\n");
320 if(key
->str
.wstr
[0] == '^' && (flags
& WRC_AF_CONTROL
) != 0)
322 print_location( &key
->loc
);
323 error("Cannot use both '^' and CONTROL modifier\n");
325 else if(key
->str
.wstr
[0] == '^')
327 keycode
= toupperW(key
->str
.wstr
[1]) - '@';
330 print_location( &key
->loc
);
331 error("Control-code out of range\n");
335 keycode
= key
->str
.wstr
[0];
341 *****************************************************************************
342 * Function : put_string
343 * Syntax : void put_string(res_t *res, string_t *str, enum str_e type,
344 * int isterm, const language_t *lang)
346 * res - Binary resource to put the data in
347 * str - String to put
348 * type - Data has to be written in either str_char or str_unicode
349 * isterm - The string is '\0' terminated (disregard the string's
354 *****************************************************************************
356 static void put_string(res_t
*res
, const string_t
*str
, enum str_e type
, int isterm
,
357 const language_t
*lang
)
365 if (lang
) codepage
= get_language_codepage( lang
->id
, lang
->sub
);
366 else codepage
= get_language_codepage( 0, 0 );
368 assert( codepage
!= -1 );
370 newstr
= convert_string(str
, type
, codepage
);
371 if (type
== str_unicode
)
373 if (str
->type
== str_char
)
375 if (!check_unicode_conversion( str
, newstr
, codepage
))
377 print_location( &str
->loc
);
378 error( "String %s does not convert identically to Unicode and back in codepage %d. "
379 "Try using a Unicode string instead\n", str
->str
.cstr
, codepage
);
381 if (check_valid_utf8( str
, codepage
))
383 print_location( &str
->loc
);
384 warning( "string \"%s\" seems to be UTF-8 but codepage %u is in use.\n",
385 str
->str
.cstr
, codepage
);
388 if (!isterm
) put_word(res
, newstr
->size
);
389 for(cnt
= 0; cnt
< newstr
->size
; cnt
++)
391 WCHAR c
= newstr
->str
.wstr
[cnt
];
392 if (isterm
&& !c
) break;
395 if (isterm
) put_word(res
, 0);
399 if (!isterm
) put_byte(res
, newstr
->size
);
400 for(cnt
= 0; cnt
< newstr
->size
; cnt
++)
402 char c
= newstr
->str
.cstr
[cnt
];
403 if (isterm
&& !c
) break;
406 if (isterm
) put_byte(res
, 0);
412 *****************************************************************************
413 * Function : put_name_id
414 * Syntax : void put_name_id(res_t *res, name_id_t *nid, int upcase, const language_t *lang)
419 *****************************************************************************
421 static void put_name_id(res_t
*res
, name_id_t
*nid
, int upcase
, const language_t
*lang
)
423 if(nid
->type
== name_ord
)
426 put_word(res
, 0xffff);
429 put_word(res
, (WORD
)nid
->name
.i_name
);
431 else if(nid
->type
== name_str
)
434 string_to_upper(nid
->name
.s_name
);
435 put_string(res
, nid
->name
.s_name
, win32
? str_unicode
: str_char
, TRUE
, lang
);
439 internal_error(__FILE__
, __LINE__
, "Invalid name_id type %d\n", nid
->type
);
444 *****************************************************************************
446 * Syntax : void put_lvc(res_t *res, lvc_t *lvc)
451 *****************************************************************************
453 static void put_lvc(res_t
*res
, lvc_t
*lvc
)
455 if(lvc
&& lvc
->language
)
456 put_word(res
, MAKELANGID(lvc
->language
->id
, lvc
->language
->sub
));
458 put_word(res
, 0); /* Neutral */
459 if(lvc
&& lvc
->version
)
460 put_dword(res
, *(lvc
->version
));
463 if(lvc
&& lvc
->characts
)
464 put_dword(res
, *(lvc
->characts
));
470 *****************************************************************************
471 * Function : put_raw_data
472 * Syntax : void put_raw_data(res_t *res, raw_data_t *raw, int offset)
477 *****************************************************************************
479 static void put_raw_data(res_t
*res
, raw_data_t
*raw
, int offset
)
481 unsigned int wsize
= raw
->size
- offset
;
482 if(res
->allocsize
- res
->size
< wsize
)
483 grow_res(res
, wsize
);
484 memcpy(&(res
->data
[res
->size
]), raw
->data
+ offset
, wsize
);
489 *****************************************************************************
490 * Function : put_res_header
491 * Syntax : input_res_header(res_t *res, int type, name_id_t *ntype,
492 * name_id_t *name, DWORD memopt, lvc_t *lvc)
495 * res - Binary resource descriptor to write to
496 * type - Resource identifier (if ntype == NULL)
497 * ntype - Name id of type
498 * name - Resource's name
499 * memopt - Resource's memory options to write
500 * lvc - Language, version and characteristics (win32 only)
501 * Output : An index to the resource size field. The resource size field
502 * contains the header size upon exit.
505 *****************************************************************************
507 static int put_res_header(res_t
*res
, int type
, name_id_t
*ntype
, name_id_t
*name
,
508 DWORD memopt
, lvc_t
*lvc
)
512 put_dword(res
, 0); /* We will overwrite these later */
516 put_word(res
, 0xffff); /* ResType */
520 put_name_id(res
, ntype
, TRUE
, lvc
->language
);
521 put_name_id(res
, name
, TRUE
, lvc
->language
); /* ResName */
523 put_dword(res
, 0); /* DataVersion */
524 put_word(res
, memopt
); /* Memory options */
525 put_lvc(res
, lvc
); /* Language, version and characts */
526 set_dword(res
, 0*sizeof(DWORD
), res
->size
); /* Set preliminary resource */
527 set_dword(res
, 1*sizeof(DWORD
), res
->size
); /* Set HeaderSize */
528 res
->dataidx
= res
->size
;
536 put_byte(res
, 0xff); /* ResType */
540 put_name_id(res
, ntype
, TRUE
, NULL
);
541 put_name_id(res
, name
, TRUE
, NULL
); /* ResName */
542 put_word(res
, memopt
); /* Memory options */
544 put_dword(res
, 0); /* ResSize overwritten later*/
545 set_dword(res
, tag
, res
->size
);
546 res
->dataidx
= res
->size
;
552 *****************************************************************************
553 * Function : accelerator2res
554 * Syntax : res_t *accelerator2res(name_id_t *name, accelerator_t *acc)
556 * name - Name/ordinal of the resource
557 * acc - The accelerator descriptor
558 * Output : New .res format structure
561 *****************************************************************************
563 static res_t
*accelerator2res(name_id_t
*name
, accelerator_t
*acc
)
568 assert(name
!= NULL
);
575 restag
= put_res_header(res
, WRC_RT_ACCELERATOR
, NULL
, name
, acc
->memopt
, &(acc
->lvc
));
579 if (ev
->str
) key
= parse_accel_string( ev
->str
, ev
->flags
);
580 put_word(res
, ev
->flags
| (ev
->next
? 0 : 0x80));
582 put_word(res
, ev
->id
);
583 put_word(res
, 0); /* Padding */
590 restag
= put_res_header(res
, WRC_RT_ACCELERATOR
, NULL
, name
, acc
->memopt
, NULL
);
594 if (ev
->str
) key
= parse_accel_string( ev
->str
, ev
->flags
);
595 put_byte(res
, ev
->flags
| (ev
->next
? 0 : 0x80));
597 put_word(res
, ev
->id
);
601 /* Set ResourceSize */
602 SetResSize(res
, restag
);
607 *****************************************************************************
608 * Function : dialog2res
609 * Syntax : res_t *dialog2res(name_id_t *name, dialog_t *dlg)
611 * name - Name/ordinal of the resource
612 * dlg - The dialog descriptor
613 * Output : New .res format structure
616 *****************************************************************************
618 static res_t
*dialog2res(name_id_t
*name
, dialog_t
*dlg
)
625 assert(name
!= NULL
);
628 ctrl
= dlg
->controls
;
632 restag
= put_res_header(res
, WRC_RT_DIALOG
, NULL
, name
, dlg
->memopt
, &(dlg
->lvc
));
636 /* FIXME: MS doc says that the first word must contain 0xffff
637 * and the second 0x0001 to signal a DLGTEMPLATEEX. Borland's
638 * compiler reverses the two words.
639 * I don't know which one to choose, but I write it as Mr. B
642 put_word(res
, 1); /* Signature */
643 put_word(res
, 0xffff); /* DlgVer */
644 put_dword(res
, dlg
->gothelpid
? dlg
->helpid
: 0);
645 put_dword(res
, dlg
->gotexstyle
? dlg
->exstyle
->or_mask
: 0);
646 put_dword(res
, dlg
->gotstyle
? dlg
->style
->or_mask
: WS_POPUPWINDOW
);
650 put_dword(res
, dlg
->style
->or_mask
);
651 put_dword(res
, dlg
->gotexstyle
? dlg
->exstyle
->or_mask
: 0);
653 tag_nctrl
= res
->size
;
654 put_word(res
, 0); /* Number of controls */
655 put_word(res
, dlg
->x
);
656 put_word(res
, dlg
->y
);
657 put_word(res
, dlg
->width
);
658 put_word(res
, dlg
->height
);
660 put_name_id(res
, dlg
->menu
, TRUE
, dlg
->lvc
.language
);
664 put_name_id(res
, dlg
->dlgclass
, TRUE
, dlg
->lvc
.language
);
668 put_string(res
, dlg
->title
, str_unicode
, TRUE
, dlg
->lvc
.language
);
673 put_word(res
, dlg
->font
->size
);
676 put_word(res
, dlg
->font
->weight
);
677 /* FIXME: ? TRUE should be sufficient to say that it's
678 * italic, but Borland's compiler says it's 0x0101.
679 * I just copy it here, and hope for the best.
681 put_word(res
, dlg
->font
->italic
? 0x0101 : 0);
683 put_string(res
, dlg
->font
->name
, str_unicode
, TRUE
, dlg
->lvc
.language
);
685 else if (dlg
->style
->or_mask
& DS_SETFONT
) put_word( res
, 0x7fff );
692 put_dword(res
, ctrl
->gothelpid
? ctrl
->helpid
: 0);
693 put_dword(res
, ctrl
->gotexstyle
? ctrl
->exstyle
->or_mask
: 0);
694 /* FIXME: what is default control style? */
695 put_dword(res
, ctrl
->gotstyle
? ctrl
->style
->or_mask
: WS_CHILD
| WS_VISIBLE
);
699 /* FIXME: what is default control style? */
700 put_dword(res
, ctrl
->gotstyle
? ctrl
->style
->or_mask
: WS_CHILD
);
701 put_dword(res
, ctrl
->gotexstyle
? ctrl
->exstyle
->or_mask
: 0);
703 put_word(res
, ctrl
->x
);
704 put_word(res
, ctrl
->y
);
705 put_word(res
, ctrl
->width
);
706 put_word(res
, ctrl
->height
);
708 put_dword(res
, ctrl
->id
);
710 put_word(res
, ctrl
->id
);
712 put_name_id(res
, ctrl
->ctlclass
, TRUE
, dlg
->lvc
.language
);
714 internal_error(__FILE__
, __LINE__
, "Control has no control-class\n");
716 put_name_id(res
, ctrl
->title
, FALSE
, dlg
->lvc
.language
);
721 put_word(res
, ctrl
->extra
->size
+2);
723 put_raw_data(res
, ctrl
->extra
, 0);
733 /* Set number of controls */
734 set_word(res
, tag_nctrl
, (WORD
)nctrl
);
738 restag
= put_res_header(res
, WRC_RT_DIALOG
, NULL
, name
, dlg
->memopt
, NULL
);
740 put_dword(res
, dlg
->gotstyle
? dlg
->style
->or_mask
: WS_POPUPWINDOW
);
741 tag_nctrl
= res
->size
;
742 put_byte(res
, 0); /* Number of controls */
743 put_word(res
, dlg
->x
);
744 put_word(res
, dlg
->y
);
745 put_word(res
, dlg
->width
);
746 put_word(res
, dlg
->height
);
748 put_name_id(res
, dlg
->menu
, TRUE
, NULL
);
752 put_name_id(res
, dlg
->dlgclass
, TRUE
, NULL
);
756 put_string(res
, dlg
->title
, str_char
, TRUE
, NULL
);
761 put_word(res
, dlg
->font
->size
);
762 put_string(res
, dlg
->font
->name
, str_char
, TRUE
, NULL
);
767 put_word(res
, ctrl
->x
);
768 put_word(res
, ctrl
->y
);
769 put_word(res
, ctrl
->width
);
770 put_word(res
, ctrl
->height
);
771 put_word(res
, ctrl
->id
);
772 put_dword(res
, ctrl
->gotstyle
? ctrl
->style
->or_mask
: WS_CHILD
);
775 if(ctrl
->ctlclass
->type
== name_ord
776 && ctrl
->ctlclass
->name
.i_name
>= 0x80
777 && ctrl
->ctlclass
->name
.i_name
<= 0x85)
778 put_byte(res
, ctrl
->ctlclass
->name
.i_name
);
779 else if(ctrl
->ctlclass
->type
== name_str
)
780 put_name_id(res
, ctrl
->ctlclass
, FALSE
, NULL
);
782 error("Unknown control-class %04x\n", ctrl
->ctlclass
->name
.i_name
);
785 internal_error(__FILE__
, __LINE__
, "Control has no control-class\n");
787 put_name_id(res
, ctrl
->title
, FALSE
, NULL
);
791 /* FIXME: What is this extra byte doing here? */
797 /* Set number of controls */
798 ((char *)res
->data
)[tag_nctrl
] = (char)nctrl
;
800 /* Set ResourceSize */
801 SetResSize(res
, restag
);
806 *****************************************************************************
807 * Function : menuitem2res
808 * Syntax : void menuitem2res(res_t *res, menu_item_t *item)
812 * Remarks : Self recursive
813 *****************************************************************************
815 static void menuitem2res(res_t
*res
, menu_item_t
*menitem
, const language_t
*lang
)
817 menu_item_t
*itm
= menitem
;
822 put_word(res
, itm
->state
| (itm
->popup
? MF_POPUP
: 0) | (!itm
->next
? MF_END
: 0));
824 put_word(res
, itm
->id
);
826 put_string(res
, itm
->name
, str_unicode
, TRUE
, lang
);
830 menuitem2res(res
, itm
->popup
, lang
);
838 put_word(res
, itm
->state
| (itm
->popup
? MF_POPUP
: 0) | (!itm
->next
? MF_END
: 0));
840 put_word(res
, itm
->id
);
842 put_string(res
, itm
->name
, str_char
, TRUE
, lang
);
846 menuitem2res(res
, itm
->popup
, lang
);
854 *****************************************************************************
855 * Function : menuexitem2res
856 * Syntax : void menuexitem2res(res_t *res, menuex_item_t *item)
860 * Remarks : Self recursive
861 *****************************************************************************
863 static void menuexitem2res(res_t
*res
, menu_item_t
*menitem
, const language_t
*lang
)
865 menu_item_t
*itm
= menitem
;
869 put_dword(res
, itm
->gottype
? itm
->type
: 0);
870 put_dword(res
, itm
->gotstate
? itm
->state
: 0);
871 put_dword(res
, itm
->gotid
? itm
->id
: 0); /* FIXME: Docu. says word */
872 put_word(res
, (itm
->popup
? 0x01 : 0) | (!itm
->next
? MF_END
: 0));
874 put_string(res
, itm
->name
, str_unicode
, TRUE
, lang
);
880 put_dword(res
, itm
->gothelpid
? itm
->helpid
: 0);
881 menuexitem2res(res
, itm
->popup
, lang
);
889 *****************************************************************************
890 * Function : menu2res
891 * Syntax : res_t *menu2res(name_id_t *name, menu_t *men)
893 * name - Name/ordinal of the resource
894 * menex - The menuex descriptor
895 * Output : New .res format structure
898 *****************************************************************************
900 static res_t
*menu2res(name_id_t
*name
, menu_t
*men
)
904 assert(name
!= NULL
);
910 restag
= put_res_header(res
, WRC_RT_MENU
, NULL
, name
, men
->memopt
, &(men
->lvc
));
914 put_word(res
, 1); /* Menuheader: Version */
915 put_word(res
, 4); /* Offset */
916 put_dword(res
, 0); /* HelpId */
918 menuexitem2res(res
, men
->items
, men
->lvc
.language
);
922 put_dword(res
, 0); /* Menuheader: Version and HeaderSize */
923 menuitem2res(res
, men
->items
, men
->lvc
.language
);
925 /* Set ResourceSize */
926 SetResSize(res
, restag
);
931 restag
= put_res_header(res
, WRC_RT_MENU
, NULL
, name
, men
->memopt
, NULL
);
933 put_dword(res
, 0); /* Menuheader: Version and HeaderSize */
934 menuitem2res(res
, men
->items
, NULL
);
935 /* Set ResourceSize */
936 SetResSize(res
, restag
);
942 *****************************************************************************
943 * Function : cursorgroup2res
944 * Syntax : res_t *cursorgroup2res(name_id_t *name, cursor_group_t *curg)
946 * name - Name/ordinal of the resource
947 * curg - The cursor descriptor
948 * Output : New .res format structure
951 *****************************************************************************
953 static res_t
*cursorgroup2res(name_id_t
*name
, cursor_group_t
*curg
)
958 assert(name
!= NULL
);
959 assert(curg
!= NULL
);
962 restag
= put_res_header(res
, WRC_RT_GROUP_CURSOR
, NULL
, name
, curg
->memopt
, &(curg
->lvc
));
964 put_word(res
, 0); /* Reserved */
965 /* FIXME: The ResType in the NEWHEADER structure should
966 * contain 14 according to the MS win32 doc. This is
967 * not the case with the BRC compiler and I really doubt
968 * the latter. Putting one here is compliant to win16 spec,
969 * but who knows the true value?
971 put_word(res
, 2); /* ResType */
972 put_word(res
, curg
->ncursor
);
974 for(cur
= curg
->cursorlist
; cur
; cur
= cur
->next
)
976 cur
= curg
->cursorlist
;
979 for(; cur
; cur
= cur
->prev
)
982 put_word(res
, cur
->width
);
983 /* FIXME: The height of a cursor is half the size of
984 * the bitmap's height. BRC puts the height from the
985 * BITMAPINFOHEADER here instead of the cursorfile's
986 * height. MS doesn't seem to care...
988 put_word(res
, cur
->height
);
989 /* FIXME: The next two are reversed in BRC and I don't
990 * know why. Probably a bug. But, we can safely ignore
991 * it because win16 does not support color cursors.
992 * A warning should have been generated by the parser.
994 put_word(res
, cur
->planes
);
995 put_word(res
, cur
->bits
);
996 /* FIXME: The +4 is the hotspot in the cursor resource.
997 * However, I could not find this in the documentation.
998 * The hotspot bytes must either be included or MS
1001 put_dword(res
, cur
->data
->size
+4);
1002 put_word(res
, cur
->id
);
1005 SetResSize(res
, restag
); /* Set ResourceSize */
1013 *****************************************************************************
1014 * Function : cursor2res
1015 * Syntax : res_t *cursor2res(cursor_t *cur)
1017 * cur - The cursor descriptor
1018 * Output : New .res format structure
1021 *****************************************************************************
1023 static res_t
*cursor2res(cursor_t
*cur
)
1029 assert(cur
!= NULL
);
1032 name
.type
= name_ord
;
1033 name
.name
.i_name
= cur
->id
;
1034 restag
= put_res_header(res
, WRC_RT_CURSOR
, NULL
, &name
, WRC_MO_MOVEABLE
| WRC_MO_DISCARDABLE
, &(cur
->lvc
));
1035 put_word(res
, cur
->xhot
);
1036 put_word(res
, cur
->yhot
);
1037 put_raw_data(res
, cur
->data
, 0);
1039 SetResSize(res
, restag
); /* Set ResourceSize */
1047 *****************************************************************************
1048 * Function : icongroup2res
1049 * Syntax : res_t *icongroup2res(name_id_t *name, icon_group_t *icog)
1051 * name - Name/ordinal of the resource
1052 * icog - The icon group descriptor
1053 * Output : New .res format structure
1056 *****************************************************************************
1058 static res_t
*icongroup2res(name_id_t
*name
, icon_group_t
*icog
)
1063 assert(name
!= NULL
);
1064 assert(icog
!= NULL
);
1067 restag
= put_res_header(res
, WRC_RT_GROUP_ICON
, NULL
, name
, icog
->memopt
, &(icog
->lvc
));
1069 put_word(res
, 0); /* Reserved */
1070 /* FIXME: The ResType in the NEWHEADER structure should
1071 * contain 14 according to the MS win32 doc. This is
1072 * not the case with the BRC compiler and I really doubt
1073 * the latter. Putting one here is compliant to win16 spec,
1074 * but who knows the true value?
1076 put_word(res
, 1); /* ResType */
1077 put_word(res
, icog
->nicon
);
1078 for(ico
= icog
->iconlist
; ico
; ico
= ico
->next
)
1080 put_byte(res
, ico
->width
);
1081 put_byte(res
, ico
->height
);
1082 put_byte(res
, ico
->nclr
);
1083 put_byte(res
, 0); /* Reserved */
1084 put_word(res
, ico
->planes
);
1085 put_word(res
, ico
->bits
);
1086 put_dword(res
, ico
->data
->size
);
1087 put_word(res
, ico
->id
);
1090 SetResSize(res
, restag
); /* Set ResourceSize */
1098 *****************************************************************************
1099 * Function : icon2res
1100 * Syntax : res_t *icon2res(icon_t *ico)
1102 * ico - The icon descriptor
1103 * Output : New .res format structure
1106 *****************************************************************************
1108 static res_t
*icon2res(icon_t
*ico
)
1114 assert(ico
!= NULL
);
1117 name
.type
= name_ord
;
1118 name
.name
.i_name
= ico
->id
;
1119 restag
= put_res_header(res
, WRC_RT_ICON
, NULL
, &name
, WRC_MO_MOVEABLE
| WRC_MO_DISCARDABLE
, &(ico
->lvc
));
1120 put_raw_data(res
, ico
->data
, 0);
1122 SetResSize(res
, restag
); /* Set ResourceSize */
1130 *****************************************************************************
1131 * Function : anicurico2res
1132 * Syntax : res_t *anicurico2res(name_id_t *name, ani_curico_t *ani)
1134 * name - Name/ordinal of the resource
1135 * ani - The animated object descriptor
1136 * Output : New .res format structure
1138 * Remarks : The endian of the object's structures have been converted
1140 * There are rumors that win311 could handle animated stuff.
1141 * That is why they are generated for both win16 and win32
1143 *****************************************************************************
1145 static res_t
*anicurico2res(name_id_t
*name
, ani_curico_t
*ani
, enum res_e type
)
1149 assert(name
!= NULL
);
1150 assert(ani
!= NULL
);
1153 restag
= put_res_header(res
, type
== res_anicur
? WRC_RT_ANICURSOR
: WRC_RT_ANIICON
,
1154 NULL
, name
, ani
->memopt
, NULL
);
1155 put_raw_data(res
, ani
->data
, 0);
1156 /* Set ResourceSize */
1157 SetResSize(res
, restag
);
1164 *****************************************************************************
1165 * Function : bitmap2res
1166 * Syntax : res_t *bitmap2res(name_id_t *name, bitmap_t *bmp)
1168 * name - Name/ordinal of the resource
1169 * bmp - The bitmap descriptor
1170 * Output : New .res format structure
1172 * Remarks : The endian of the bitmap structures have been converted
1174 *****************************************************************************
1176 static res_t
*bitmap2res(name_id_t
*name
, bitmap_t
*bmp
)
1180 assert(name
!= NULL
);
1181 assert(bmp
!= NULL
);
1184 restag
= put_res_header(res
, WRC_RT_BITMAP
, NULL
, name
, bmp
->memopt
, &(bmp
->data
->lvc
));
1185 if(bmp
->data
->data
[0] == 'B'
1186 && bmp
->data
->data
[1] == 'M'
1187 && ((BITMAPFILEHEADER
*)bmp
->data
->data
)->bfSize
== bmp
->data
->size
1188 && bmp
->data
->size
>= sizeof(BITMAPFILEHEADER
))
1190 /* The File header is still attached, don't write it */
1191 put_raw_data(res
, bmp
->data
, sizeof(BITMAPFILEHEADER
));
1195 put_raw_data(res
, bmp
->data
, 0);
1197 /* Set ResourceSize */
1198 SetResSize(res
, restag
);
1205 *****************************************************************************
1206 * Function : font2res
1207 * Syntax : res_t *font2res(name_id_t *name, font_t *fnt)
1209 * name - Name/ordinal of the resource
1210 * fnt - The font descriptor
1211 * Output : New .res format structure
1213 * Remarks : The data has been prepared just after parsing.
1214 *****************************************************************************
1216 static res_t
*font2res(name_id_t
*name
, font_t
*fnt
)
1220 assert(name
!= NULL
);
1221 assert(fnt
!= NULL
);
1224 restag
= put_res_header(res
, WRC_RT_FONT
, NULL
, name
, fnt
->memopt
, &(fnt
->data
->lvc
));
1225 put_raw_data(res
, fnt
->data
, 0);
1226 /* Set ResourceSize */
1227 SetResSize(res
, restag
);
1234 *****************************************************************************
1235 * Function : fontdir2res
1236 * Syntax : res_t *fontdir2res(name_id_t *name, fontdir_t *fnd)
1238 * name - Name/ordinal of the resource
1239 * fntdir - The fontdir descriptor
1240 * Output : New .res format structure
1242 * Remarks : The data has been prepared just after parsing.
1243 *****************************************************************************
1245 static res_t
*fontdir2res(name_id_t
*name
, fontdir_t
*fnd
)
1249 assert(name
!= NULL
);
1250 assert(fnd
!= NULL
);
1253 restag
= put_res_header(res
, WRC_RT_FONTDIR
, NULL
, name
, fnd
->memopt
, &(fnd
->data
->lvc
));
1254 put_raw_data(res
, fnd
->data
, 0);
1255 /* Set ResourceSize */
1256 SetResSize(res
, restag
);
1263 *****************************************************************************
1264 * Function : html2res
1265 * Syntax : res_t *html2res(name_id_t *name, html_t *html)
1267 * name - Name/ordinal of the resource
1268 * rdt - The html descriptor
1269 * Output : New .res format structure
1272 *****************************************************************************
1274 static res_t
*html2res(name_id_t
*name
, html_t
*html
)
1278 assert(name
!= NULL
);
1279 assert(html
!= NULL
);
1282 restag
= put_res_header(res
, WRC_RT_HTML
, NULL
, name
, html
->memopt
, &(html
->data
->lvc
));
1283 put_raw_data(res
, html
->data
, 0);
1284 /* Set ResourceSize */
1285 SetResSize(res
, restag
);
1292 *****************************************************************************
1293 * Function : rcdata2res
1294 * Syntax : res_t *rcdata2res(name_id_t *name, rcdata_t *rdt)
1296 * name - Name/ordinal of the resource
1297 * rdt - The rcdata descriptor
1298 * Output : New .res format structure
1301 *****************************************************************************
1303 static res_t
*rcdata2res(name_id_t
*name
, rcdata_t
*rdt
)
1307 assert(name
!= NULL
);
1308 assert(rdt
!= NULL
);
1311 restag
= put_res_header(res
, WRC_RT_RCDATA
, NULL
, name
, rdt
->memopt
, &(rdt
->data
->lvc
));
1312 put_raw_data(res
, rdt
->data
, 0);
1313 /* Set ResourceSize */
1314 SetResSize(res
, restag
);
1321 *****************************************************************************
1322 * Function : messagetable2res
1323 * Syntax : res_t *messagetable2res(name_id_t *name, messagetable_t *msg)
1325 * name - Name/ordinal of the resource
1326 * msg - The messagetable descriptor
1327 * Output : New .res format structure
1329 * Remarks : The data has been converted to the appropriate endian
1330 * after it was parsed.
1331 *****************************************************************************
1333 static res_t
*messagetable2res(name_id_t
*name
, messagetable_t
*msg
)
1337 assert(name
!= NULL
);
1338 assert(msg
!= NULL
);
1341 restag
= put_res_header(res
, WRC_RT_MESSAGETABLE
, NULL
, name
, msg
->memopt
, &(msg
->data
->lvc
));
1342 put_raw_data(res
, msg
->data
, 0);
1343 /* Set ResourceSize */
1344 SetResSize(res
, restag
);
1351 *****************************************************************************
1352 * Function : stringtable2res
1353 * Syntax : res_t *stringtable2res(stringtable_t *stt)
1355 * stt - The stringtable descriptor
1356 * Output : New .res format structure
1359 *****************************************************************************
1361 static res_t
*stringtable2res(stringtable_t
*stt
)
1369 assert(stt
!= NULL
);
1372 for(; stt
; stt
= stt
->next
)
1376 warning("Empty internal stringtable\n");
1379 name
.type
= name_ord
;
1380 name
.name
.i_name
= (stt
->idbase
>> 4) + 1;
1381 restag
= put_res_header(res
, WRC_RT_STRING
, NULL
, &name
, stt
->memopt
, win32
? &(stt
->lvc
) : NULL
);
1382 for(i
= 0; i
< stt
->nentries
; i
++)
1384 if(stt
->entries
[i
].str
&& stt
->entries
[i
].str
->size
)
1386 put_string(res
, stt
->entries
[i
].str
, win32
? str_unicode
: str_char
,
1387 FALSE
, win32
? stt
->lvc
.language
: NULL
);
1397 /* Set ResourceSize */
1398 SetResSize(res
, restag
- lastsize
);
1401 lastsize
= res
->size
;
1407 *****************************************************************************
1408 * Function : user2res
1409 * Syntax : res_t *user2res(name_id_t *name, user_t *usr)
1411 * name - Name/ordinal of the resource
1412 * usr - The userresource descriptor
1413 * Output : New .res format structure
1416 *****************************************************************************
1418 static res_t
*user2res(name_id_t
*name
, user_t
*usr
)
1422 assert(name
!= NULL
);
1423 assert(usr
!= NULL
);
1426 restag
= put_res_header(res
, 0, usr
->type
, name
, usr
->memopt
, &(usr
->data
->lvc
));
1427 put_raw_data(res
, usr
->data
, 0);
1428 /* Set ResourceSize */
1429 SetResSize(res
, restag
);
1436 *****************************************************************************
1437 * Function : versionblock2res
1438 * Syntax : void versionblock2res(res_t *res, ver_block_t *blk)
1440 * res - Binary resource to write to
1441 * blk - The version block to be written
1444 * Remarks : Self recursive
1445 *****************************************************************************
1447 static void versionblock2res(res_t
*res
, ver_block_t
*blk
, int level
, const language_t
*lang
)
1456 blksizetag
= res
->size
;
1457 put_word(res
, 0); /* Will be overwritten later */
1460 put_word(res
, 0); /* level ? */
1461 put_string(res
, blk
->name
, win32
? str_unicode
: str_char
, TRUE
, lang
);
1463 for(val
= blk
->values
; val
; val
= val
->next
)
1465 if(val
->type
== val_str
)
1467 valblksizetag
= res
->size
;
1468 put_word(res
, 0); /* Will be overwritten later */
1469 valvalsizetag
= res
->size
;
1470 put_word(res
, 0); /* Will be overwritten later */
1473 put_word(res
, level
);
1475 put_string(res
, val
->key
, win32
? str_unicode
: str_char
, TRUE
, lang
);
1478 put_string(res
, val
->value
.str
, win32
? str_unicode
: str_char
, TRUE
, lang
);
1480 set_word(res
, valvalsizetag
, (WORD
)((res
->size
- tag
) >> 1));
1482 set_word(res
, valvalsizetag
, (WORD
)(res
->size
- tag
));
1483 set_word(res
, valblksizetag
, (WORD
)(res
->size
- valblksizetag
));
1486 else if(val
->type
== val_words
)
1488 valblksizetag
= res
->size
;
1489 put_word(res
, 0); /* Will be overwritten later */
1490 valvalsizetag
= res
->size
;
1491 put_word(res
, 0); /* Will be overwritten later */
1494 put_word(res
, level
);
1496 put_string(res
, val
->key
, win32
? str_unicode
: str_char
, TRUE
, lang
);
1499 for(i
= 0; i
< val
->value
.words
->nwords
; i
++)
1501 put_word(res
, val
->value
.words
->words
[i
]);
1503 set_word(res
, valvalsizetag
, (WORD
)(res
->size
- tag
));
1504 set_word(res
, valblksizetag
, (WORD
)(res
->size
- valblksizetag
));
1507 else if(val
->type
== val_block
)
1509 versionblock2res(res
, val
->value
.block
, level
+1, lang
);
1513 internal_error(__FILE__
, __LINE__
, "Invalid value indicator %d in VERSIONINFO\n", val
->type
);
1518 set_word(res
, blksizetag
, (WORD
)(res
->size
- blksizetag
));
1522 *****************************************************************************
1523 * Function : versioninfo2res
1524 * Syntax : res_t *versioninfo2res(name_id_t *name, versioninfo_t *ver)
1526 * name - Name/ordinal of the resource
1527 * ver - The versioninfo descriptor
1528 * Output : New .res format structure
1531 *****************************************************************************
1533 static res_t
*versioninfo2res(name_id_t
*name
, versioninfo_t
*ver
)
1536 int rootblocksizetag
;
1543 assert(name
!= NULL
);
1544 assert(ver
!= NULL
);
1546 vsvi
.type
= str_char
;
1547 vsvi
.str
.cstr
= xstrdup("VS_VERSION_INFO");
1548 vsvi
.size
= 15; /* Excl. termination */
1551 restag
= put_res_header(res
, WRC_RT_VERSION
, NULL
, name
, ver
->memopt
, &(ver
->lvc
));
1552 rootblocksizetag
= res
->size
;
1553 put_word(res
, 0); /* BlockSize filled in later */
1554 valsizetag
= res
->size
;
1555 put_word(res
, 0); /* ValueSize filled in later*/
1557 put_word(res
, 0); /* Tree-level ? */
1558 put_string(res
, &vsvi
, win32
? str_unicode
: str_char
,
1559 TRUE
, win32
? ver
->lvc
.language
: NULL
);
1563 put_dword(res
, VS_FFI_SIGNATURE
);
1564 put_dword(res
, VS_FFI_STRUCVERSION
);
1565 put_dword(res
, (ver
->filever_maj1
<< 16) + (ver
->filever_maj2
& 0xffff));
1566 put_dword(res
, (ver
->filever_min1
<< 16) + (ver
->filever_min2
& 0xffff));
1567 put_dword(res
, (ver
->prodver_maj1
<< 16) + (ver
->prodver_maj2
& 0xffff));
1568 put_dword(res
, (ver
->prodver_min1
<< 16) + (ver
->prodver_min2
& 0xffff));
1569 put_dword(res
, ver
->fileflagsmask
);
1570 put_dword(res
, ver
->fileflags
);
1571 put_dword(res
, ver
->fileos
);
1572 put_dword(res
, ver
->filetype
);
1573 put_dword(res
, ver
->filesubtype
);
1574 put_dword(res
, 0); /* FileDateMS */
1575 put_dword(res
, 0); /* FileDateLS */
1577 set_word(res
, valsizetag
, (WORD
)(res
->size
- tag
));
1578 /* Descend into the blocks */
1579 for(blk
= ver
->blocks
; blk
; blk
= blk
->next
)
1580 versionblock2res(res
, blk
, 0, win32
? ver
->lvc
.language
: NULL
);
1581 /* Set root block's size */
1582 set_word(res
, rootblocksizetag
, (WORD
)(res
->size
- rootblocksizetag
));
1584 SetResSize(res
, restag
);
1588 free(vsvi
.str
.cstr
);
1593 *****************************************************************************
1594 * Function : toolbaritem2res
1595 * Syntax : void toolbaritem2res(res_t *res, toolbar_item_t *tbitem)
1599 * Remarks : Self recursive
1600 *****************************************************************************
1602 static void toolbaritem2res(res_t
*res
, toolbar_item_t
*tbitem
)
1604 toolbar_item_t
*itm
= tbitem
;
1608 put_word(res
, itm
->id
);
1615 *****************************************************************************
1616 * Function : toolbar2res
1617 * Syntax : res_t *toolbar2res(name_id_t *name, toolbar_t *toolbar)
1619 * name - Name/ordinal of the resource
1620 * toolbar - The toolbar descriptor
1621 * Output : New .res format structure
1624 *****************************************************************************
1626 static res_t
*toolbar2res(name_id_t
*name
, toolbar_t
*toolbar
)
1630 assert(name
!= NULL
);
1631 assert(toolbar
!= NULL
);
1636 restag
= put_res_header(res
, WRC_RT_TOOLBAR
, NULL
, name
, toolbar
->memopt
, &(toolbar
->lvc
));
1638 put_word(res
, 1); /* Menuheader: Version */
1639 put_word(res
, toolbar
->button_width
); /* (in pixels?) */
1640 put_word(res
, toolbar
->button_height
); /* (in pixels?) */
1641 put_word(res
, toolbar
->nitems
);
1643 toolbaritem2res(res
, toolbar
->items
);
1644 /* Set ResourceSize */
1645 SetResSize(res
, restag
);
1650 /* Do not generate anything in 16-bit mode */
1659 *****************************************************************************
1660 * Function : dlginit2res
1661 * Syntax : res_t *dlginit2res(name_id_t *name, dlginit_t *dit)
1663 * name - Name/ordinal of the resource
1664 * rdt - The dlginit descriptor
1665 * Output : New .res format structure
1668 *****************************************************************************
1670 static res_t
*dlginit2res(name_id_t
*name
, dlginit_t
*dit
)
1674 assert(name
!= NULL
);
1675 assert(dit
!= NULL
);
1678 restag
= put_res_header(res
, WRC_RT_DLGINIT
, NULL
, name
, dit
->memopt
, &(dit
->data
->lvc
));
1679 put_raw_data(res
, dit
->data
, 0);
1680 /* Set ResourceSize */
1681 SetResSize(res
, restag
);
1688 *****************************************************************************
1689 * Function : prep_nid_for_label
1690 * Syntax : char *prep_nid_for_label(const name_id_t *nid)
1693 * Description : Converts a resource name into the first 32 (or less)
1694 * characters of the name with conversions.
1696 *****************************************************************************
1698 #define MAXNAMELEN 32
1699 char *prep_nid_for_label(const name_id_t
*nid
)
1701 static char buf
[MAXNAMELEN
+1];
1703 assert(nid
!= NULL
);
1705 if(nid
->type
== name_str
&& nid
->name
.s_name
->type
== str_unicode
)
1709 sptr
= nid
->name
.s_name
->str
.wstr
;
1711 for(i
= 0; *sptr
&& i
< MAXNAMELEN
; i
++)
1713 if((unsigned)*sptr
< 0x80 && isprint(*sptr
& 0xff))
1716 warning("Resourcename (str_unicode) contain unprintable characters or invalid translation, ignored\n");
1720 else if(nid
->type
== name_str
&& nid
->name
.s_name
->type
== str_char
)
1724 cptr
= nid
->name
.s_name
->str
.cstr
;
1726 for(i
= 0; *cptr
&& i
< MAXNAMELEN
; i
++)
1728 if((unsigned)*cptr
< 0x80 && isprint(*cptr
& 0xff))
1731 warning("Resourcename (str_char) contain unprintable characters, ignored\n");
1735 else if(nid
->type
== name_ord
)
1737 sprintf(buf
, "%u", nid
->name
.i_name
);
1741 internal_error(__FILE__
, __LINE__
, "Resource name_id with invalid type %d\n", nid
->type
);
1748 *****************************************************************************
1749 * Function : make_c_name
1750 * Syntax : char *make_c_name(const char *base, const name_id_t *nid, const language_t *lan)
1753 * Description : Converts a resource name into a valid c-identifier in the
1756 *****************************************************************************
1758 char *make_c_name(const char *base
, const name_id_t
*nid
, const language_t
*lan
)
1760 char *buf
= prep_nid_for_label(nid
);
1761 return strmake( "_%s_%s_%d", base
, buf
, lan
? MAKELANGID(lan
->id
, lan
->sub
) : 0);
1765 *****************************************************************************
1766 * Function : get_c_typename
1767 * Syntax : const char *get_c_typename(enum res_e type)
1770 * Description : Convert resource enum to char string to be used in c-name
1773 *****************************************************************************
1775 const char *get_c_typename(enum res_e type
)
1779 case res_acc
: return "Acc";
1780 case res_anicur
:return "AniCur";
1781 case res_aniico
:return "AniIco";
1782 case res_bmp
: return "Bmp";
1783 case res_cur
: return "Cur";
1784 case res_curg
: return "CurGrp";
1785 case res_dlg
: return "Dlg";
1786 case res_fnt
: return "Fnt";
1787 case res_fntdir
:return "FntDir";
1788 case res_ico
: return "Ico";
1789 case res_icog
: return "IcoGrp";
1790 case res_men
: return "Men";
1791 case res_rdt
: return "RCDat";
1792 case res_stt
: return "StrTab";
1793 case res_usr
: return "Usr";
1794 case res_msg
: return "MsgTab";
1795 case res_ver
: return "VerInf";
1796 case res_toolbar
: return "TlBr";
1797 case res_dlginit
: return "DlgInit";
1798 default: return "Oops";
1803 *****************************************************************************
1804 * Function : resources2res
1805 * Syntax : void resources2res(resource_t *top)
1807 * top - The resource-tree to convert
1809 * Description : Convert logical resource descriptors into binary data
1811 *****************************************************************************
1813 void resources2res(resource_t
*top
)
1821 top
->binres
= accelerator2res(top
->name
, top
->res
.acc
);
1825 top
->binres
= bitmap2res(top
->name
, top
->res
.bmp
);
1829 top
->binres
= cursor2res(top
->res
.cur
);
1833 top
->binres
= cursorgroup2res(top
->name
, top
->res
.curg
);
1837 top
->binres
= dialog2res(top
->name
, top
->res
.dlg
);
1841 top
->binres
= font2res(top
->name
, top
->res
.fnt
);
1845 top
->binres
= fontdir2res(top
->name
, top
->res
.fnd
);
1849 top
->binres
= icon2res(top
->res
.ico
);
1853 top
->binres
= icongroup2res(top
->name
, top
->res
.icog
);
1857 top
->binres
= menu2res(top
->name
, top
->res
.men
);
1861 top
->binres
= html2res(top
->name
, top
->res
.html
);
1865 top
->binres
= rcdata2res(top
->name
, top
->res
.rdt
);
1869 top
->binres
= stringtable2res(top
->res
.stt
);
1873 top
->binres
= user2res(top
->name
, top
->res
.usr
);
1877 top
->binres
= messagetable2res(top
->name
, top
->res
.msg
);
1881 top
->binres
= versioninfo2res(top
->name
, top
->res
.ver
);
1885 top
->binres
= toolbar2res(top
->name
, top
->res
.tbt
);
1889 top
->binres
= dlginit2res(top
->name
, top
->res
.dlgi
);
1894 top
->binres
= anicurico2res(top
->name
, top
->res
.ani
, top
->type
);
1897 internal_error(__FILE__
, __LINE__
, "Unknown resource type encountered %d in binary res generation\n", top
->type
);
1899 top
->c_name
= make_c_name(get_c_typename(top
->type
), top
->name
, top
->lan
);