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
++)
267 if (str
->str
.cstr
[i
] >= 'a' && str
->str
.cstr
[i
] <= 'z') str
->str
.cstr
[i
] -= 32;
269 else if(str
->type
== str_unicode
)
271 for (i
= 0; i
< str
->size
; i
++)
272 if (str
->str
.wstr
[i
] >= 'a' && str
->str
.wstr
[i
] <= 'z') str
->str
.wstr
[i
] -= 32;
276 internal_error(__FILE__
, __LINE__
, "Invalid string type %d\n", str
->type
);
280 static int parse_accel_string( const string_t
*key
, int flags
)
284 if(key
->type
== str_char
)
286 if (key
->str
.cstr
[0] == '#') return 0; /* ignore message contexts */
287 if((flags
& WRC_AF_VIRTKEY
) &&
288 !((key
->str
.cstr
[0] >= 'A' && key
->str
.cstr
[0] <= 'Z') ||
289 (key
->str
.cstr
[0] >= '0' && key
->str
.cstr
[0] <= '9')))
291 print_location( &key
->loc
);
292 error("VIRTKEY code is not equal to ascii value\n");
295 if(key
->str
.cstr
[0] == '^' && (flags
& WRC_AF_CONTROL
) != 0)
297 print_location( &key
->loc
);
298 error("Cannot use both '^' and CONTROL modifier\n");
300 else if(key
->str
.cstr
[0] == '^')
302 if (key
->str
.cstr
[1] >= 'a' && key
->str
.cstr
[1] <= 'z')
303 keycode
= key
->str
.cstr
[1] - 'a' + 1;
304 else if (key
->str
.cstr
[1] >= 'A' && key
->str
.cstr
[1] <= 'Z')
305 keycode
= key
->str
.cstr
[1] - 'A' + 1;
308 print_location( &key
->loc
);
309 error("Control-code out of range\n");
313 keycode
= key
->str
.cstr
[0];
317 if (key
->str
.wstr
[0] == '#') return 0; /* ignore message contexts */
318 if((flags
& WRC_AF_VIRTKEY
) &&
319 !((key
->str
.wstr
[0] >= 'A' && key
->str
.wstr
[0] <= 'Z') ||
320 (key
->str
.wstr
[0] >= '0' && key
->str
.wstr
[0] <= '9')))
322 print_location( &key
->loc
);
323 error("VIRTKEY code is not equal to ascii value\n");
325 if(key
->str
.wstr
[0] == '^' && (flags
& WRC_AF_CONTROL
) != 0)
327 print_location( &key
->loc
);
328 error("Cannot use both '^' and CONTROL modifier\n");
330 else if(key
->str
.wstr
[0] == '^')
332 if (key
->str
.wstr
[1] >= 'a' && key
->str
.wstr
[1] <= 'z')
333 keycode
= key
->str
.wstr
[1] - 'a' + 1;
334 else if (key
->str
.wstr
[1] >= 'A' && key
->str
.wstr
[1] <= 'Z')
335 keycode
= key
->str
.wstr
[1] - 'A' + 1;
338 print_location( &key
->loc
);
339 error("Control-code out of range\n");
343 keycode
= key
->str
.wstr
[0];
349 *****************************************************************************
350 * Function : put_string
351 * Syntax : void put_string(res_t *res, string_t *str, enum str_e type,
352 * int isterm, const language_t *lang)
354 * res - Binary resource to put the data in
355 * str - String to put
356 * type - Data has to be written in either str_char or str_unicode
357 * isterm - The string is '\0' terminated (disregard the string's
362 *****************************************************************************
364 static void put_string(res_t
*res
, const string_t
*str
, enum str_e type
, int isterm
,
365 const language_t
*lang
)
373 if (lang
) codepage
= get_language_codepage( lang
->id
, lang
->sub
);
374 else codepage
= get_language_codepage( 0, 0 );
376 assert( codepage
!= -1 );
378 newstr
= convert_string(str
, type
, codepage
);
379 if (type
== str_unicode
)
381 if (str
->type
== str_char
)
383 if (!check_unicode_conversion( str
, newstr
, codepage
))
385 print_location( &str
->loc
);
386 error( "String %s does not convert identically to Unicode and back in codepage %d. "
387 "Try using a Unicode string instead\n", str
->str
.cstr
, codepage
);
389 if (check_valid_utf8( str
, codepage
))
391 print_location( &str
->loc
);
392 warning( "string \"%s\" seems to be UTF-8 but codepage %u is in use.\n",
393 str
->str
.cstr
, codepage
);
396 if (!isterm
) put_word(res
, newstr
->size
);
397 for(cnt
= 0; cnt
< newstr
->size
; cnt
++)
399 WCHAR c
= newstr
->str
.wstr
[cnt
];
400 if (isterm
&& !c
) break;
403 if (isterm
) put_word(res
, 0);
407 if (!isterm
) put_byte(res
, newstr
->size
);
408 for(cnt
= 0; cnt
< newstr
->size
; cnt
++)
410 char c
= newstr
->str
.cstr
[cnt
];
411 if (isterm
&& !c
) break;
414 if (isterm
) put_byte(res
, 0);
420 *****************************************************************************
421 * Function : put_name_id
422 * Syntax : void put_name_id(res_t *res, name_id_t *nid, int upcase, const language_t *lang)
427 *****************************************************************************
429 static void put_name_id(res_t
*res
, name_id_t
*nid
, int upcase
, const language_t
*lang
)
431 if(nid
->type
== name_ord
)
434 put_word(res
, 0xffff);
437 put_word(res
, (WORD
)nid
->name
.i_name
);
439 else if(nid
->type
== name_str
)
442 string_to_upper(nid
->name
.s_name
);
443 put_string(res
, nid
->name
.s_name
, win32
? str_unicode
: str_char
, TRUE
, lang
);
447 internal_error(__FILE__
, __LINE__
, "Invalid name_id type %d\n", nid
->type
);
452 *****************************************************************************
454 * Syntax : void put_lvc(res_t *res, lvc_t *lvc)
459 *****************************************************************************
461 static void put_lvc(res_t
*res
, lvc_t
*lvc
)
463 if(lvc
&& lvc
->language
)
464 put_word(res
, MAKELANGID(lvc
->language
->id
, lvc
->language
->sub
));
466 put_word(res
, 0); /* Neutral */
467 if(lvc
&& lvc
->version
)
468 put_dword(res
, *(lvc
->version
));
471 if(lvc
&& lvc
->characts
)
472 put_dword(res
, *(lvc
->characts
));
478 *****************************************************************************
479 * Function : put_raw_data
480 * Syntax : void put_raw_data(res_t *res, raw_data_t *raw, int offset)
485 *****************************************************************************
487 static void put_raw_data(res_t
*res
, raw_data_t
*raw
, int offset
)
489 unsigned int wsize
= raw
->size
- offset
;
490 if(res
->allocsize
- res
->size
< wsize
)
491 grow_res(res
, wsize
);
492 memcpy(&(res
->data
[res
->size
]), raw
->data
+ offset
, wsize
);
497 *****************************************************************************
498 * Function : put_res_header
499 * Syntax : input_res_header(res_t *res, int type, name_id_t *ntype,
500 * name_id_t *name, DWORD memopt, lvc_t *lvc)
503 * res - Binary resource descriptor to write to
504 * type - Resource identifier (if ntype == NULL)
505 * ntype - Name id of type
506 * name - Resource's name
507 * memopt - Resource's memory options to write
508 * lvc - Language, version and characteristics (win32 only)
509 * Output : An index to the resource size field. The resource size field
510 * contains the header size upon exit.
513 *****************************************************************************
515 static int put_res_header(res_t
*res
, int type
, name_id_t
*ntype
, name_id_t
*name
,
516 DWORD memopt
, lvc_t
*lvc
)
520 put_dword(res
, 0); /* We will overwrite these later */
524 put_word(res
, 0xffff); /* ResType */
528 put_name_id(res
, ntype
, TRUE
, lvc
->language
);
529 put_name_id(res
, name
, TRUE
, lvc
->language
); /* ResName */
531 put_dword(res
, 0); /* DataVersion */
532 put_word(res
, memopt
); /* Memory options */
533 put_lvc(res
, lvc
); /* Language, version and characts */
534 set_dword(res
, 0*sizeof(DWORD
), res
->size
); /* Set preliminary resource */
535 set_dword(res
, 1*sizeof(DWORD
), res
->size
); /* Set HeaderSize */
536 res
->dataidx
= res
->size
;
544 put_byte(res
, 0xff); /* ResType */
548 put_name_id(res
, ntype
, TRUE
, NULL
);
549 put_name_id(res
, name
, TRUE
, NULL
); /* ResName */
550 put_word(res
, memopt
); /* Memory options */
552 put_dword(res
, 0); /* ResSize overwritten later*/
553 set_dword(res
, tag
, res
->size
);
554 res
->dataidx
= res
->size
;
560 *****************************************************************************
561 * Function : accelerator2res
562 * Syntax : res_t *accelerator2res(name_id_t *name, accelerator_t *acc)
564 * name - Name/ordinal of the resource
565 * acc - The accelerator descriptor
566 * Output : New .res format structure
569 *****************************************************************************
571 static res_t
*accelerator2res(name_id_t
*name
, accelerator_t
*acc
)
576 assert(name
!= NULL
);
583 restag
= put_res_header(res
, WRC_RT_ACCELERATOR
, NULL
, name
, acc
->memopt
, &(acc
->lvc
));
587 if (ev
->str
) key
= parse_accel_string( ev
->str
, ev
->flags
);
588 put_word(res
, ev
->flags
| (ev
->next
? 0 : 0x80));
590 put_word(res
, ev
->id
);
591 put_word(res
, 0); /* Padding */
598 restag
= put_res_header(res
, WRC_RT_ACCELERATOR
, NULL
, name
, acc
->memopt
, NULL
);
602 if (ev
->str
) key
= parse_accel_string( ev
->str
, ev
->flags
);
603 put_byte(res
, ev
->flags
| (ev
->next
? 0 : 0x80));
605 put_word(res
, ev
->id
);
609 /* Set ResourceSize */
610 SetResSize(res
, restag
);
615 *****************************************************************************
616 * Function : dialog2res
617 * Syntax : res_t *dialog2res(name_id_t *name, dialog_t *dlg)
619 * name - Name/ordinal of the resource
620 * dlg - The dialog descriptor
621 * Output : New .res format structure
624 *****************************************************************************
626 static res_t
*dialog2res(name_id_t
*name
, dialog_t
*dlg
)
633 assert(name
!= NULL
);
636 ctrl
= dlg
->controls
;
640 restag
= put_res_header(res
, WRC_RT_DIALOG
, NULL
, name
, dlg
->memopt
, &(dlg
->lvc
));
644 /* FIXME: MS doc says that the first word must contain 0xffff
645 * and the second 0x0001 to signal a DLGTEMPLATEEX. Borland's
646 * compiler reverses the two words.
647 * I don't know which one to choose, but I write it as Mr. B
650 put_word(res
, 1); /* Signature */
651 put_word(res
, 0xffff); /* DlgVer */
652 put_dword(res
, dlg
->gothelpid
? dlg
->helpid
: 0);
653 put_dword(res
, dlg
->gotexstyle
? dlg
->exstyle
->or_mask
: 0);
654 put_dword(res
, dlg
->gotstyle
? dlg
->style
->or_mask
: WS_POPUPWINDOW
);
658 put_dword(res
, dlg
->style
->or_mask
);
659 put_dword(res
, dlg
->gotexstyle
? dlg
->exstyle
->or_mask
: 0);
661 tag_nctrl
= res
->size
;
662 put_word(res
, 0); /* Number of controls */
663 put_word(res
, dlg
->x
);
664 put_word(res
, dlg
->y
);
665 put_word(res
, dlg
->width
);
666 put_word(res
, dlg
->height
);
668 put_name_id(res
, dlg
->menu
, FALSE
, dlg
->lvc
.language
);
672 put_name_id(res
, dlg
->dlgclass
, FALSE
, dlg
->lvc
.language
);
676 put_string(res
, dlg
->title
, str_unicode
, TRUE
, dlg
->lvc
.language
);
681 put_word(res
, dlg
->font
->size
);
684 put_word(res
, dlg
->font
->weight
);
685 /* FIXME: ? TRUE should be sufficient to say that it's
686 * italic, but Borland's compiler says it's 0x0101.
687 * I just copy it here, and hope for the best.
689 put_word(res
, dlg
->font
->italic
? 0x0101 : 0);
691 put_string(res
, dlg
->font
->name
, str_unicode
, TRUE
, dlg
->lvc
.language
);
693 else if (dlg
->style
->or_mask
& DS_SETFONT
) put_word( res
, 0x7fff );
700 put_dword(res
, ctrl
->gothelpid
? ctrl
->helpid
: 0);
701 put_dword(res
, ctrl
->gotexstyle
? ctrl
->exstyle
->or_mask
: 0);
702 /* FIXME: what is default control style? */
703 put_dword(res
, ctrl
->gotstyle
? ctrl
->style
->or_mask
: WS_CHILD
| WS_VISIBLE
);
707 /* FIXME: what is default control style? */
708 put_dword(res
, ctrl
->gotstyle
? ctrl
->style
->or_mask
: WS_CHILD
);
709 put_dword(res
, ctrl
->gotexstyle
? ctrl
->exstyle
->or_mask
: 0);
711 put_word(res
, ctrl
->x
);
712 put_word(res
, ctrl
->y
);
713 put_word(res
, ctrl
->width
);
714 put_word(res
, ctrl
->height
);
716 put_dword(res
, ctrl
->id
);
718 put_word(res
, ctrl
->id
);
720 put_name_id(res
, ctrl
->ctlclass
, FALSE
, dlg
->lvc
.language
);
722 internal_error(__FILE__
, __LINE__
, "Control has no control-class\n");
724 put_name_id(res
, ctrl
->title
, FALSE
, dlg
->lvc
.language
);
729 put_word(res
, ctrl
->extra
->size
);
730 put_raw_data(res
, ctrl
->extra
, 0);
740 /* Set number of controls */
741 set_word(res
, tag_nctrl
, (WORD
)nctrl
);
745 restag
= put_res_header(res
, WRC_RT_DIALOG
, NULL
, name
, dlg
->memopt
, NULL
);
747 put_dword(res
, dlg
->gotstyle
? dlg
->style
->or_mask
: WS_POPUPWINDOW
);
748 tag_nctrl
= res
->size
;
749 put_byte(res
, 0); /* Number of controls */
750 put_word(res
, dlg
->x
);
751 put_word(res
, dlg
->y
);
752 put_word(res
, dlg
->width
);
753 put_word(res
, dlg
->height
);
755 put_name_id(res
, dlg
->menu
, TRUE
, NULL
);
759 put_name_id(res
, dlg
->dlgclass
, TRUE
, NULL
);
763 put_string(res
, dlg
->title
, str_char
, TRUE
, NULL
);
768 put_word(res
, dlg
->font
->size
);
769 put_string(res
, dlg
->font
->name
, str_char
, TRUE
, NULL
);
774 put_word(res
, ctrl
->x
);
775 put_word(res
, ctrl
->y
);
776 put_word(res
, ctrl
->width
);
777 put_word(res
, ctrl
->height
);
778 put_word(res
, ctrl
->id
);
779 put_dword(res
, ctrl
->gotstyle
? ctrl
->style
->or_mask
: WS_CHILD
);
782 if(ctrl
->ctlclass
->type
== name_ord
783 && ctrl
->ctlclass
->name
.i_name
>= 0x80
784 && ctrl
->ctlclass
->name
.i_name
<= 0x85)
785 put_byte(res
, ctrl
->ctlclass
->name
.i_name
);
786 else if(ctrl
->ctlclass
->type
== name_str
)
787 put_name_id(res
, ctrl
->ctlclass
, FALSE
, NULL
);
789 error("Unknown control-class %04x\n", ctrl
->ctlclass
->name
.i_name
);
792 internal_error(__FILE__
, __LINE__
, "Control has no control-class\n");
794 put_name_id(res
, ctrl
->title
, FALSE
, NULL
);
798 /* FIXME: What is this extra byte doing here? */
804 /* Set number of controls */
805 ((char *)res
->data
)[tag_nctrl
] = (char)nctrl
;
807 /* Set ResourceSize */
808 SetResSize(res
, restag
);
813 *****************************************************************************
814 * Function : menuitem2res
815 * Syntax : void menuitem2res(res_t *res, menu_item_t *item)
819 * Remarks : Self recursive
820 *****************************************************************************
822 static void menuitem2res(res_t
*res
, menu_item_t
*menitem
, const language_t
*lang
)
824 menu_item_t
*itm
= menitem
;
829 put_word(res
, itm
->state
| (itm
->popup
? MF_POPUP
: 0) | (!itm
->next
? MF_END
: 0));
831 put_word(res
, itm
->id
);
833 put_string(res
, itm
->name
, str_unicode
, TRUE
, lang
);
837 menuitem2res(res
, itm
->popup
, lang
);
845 put_word(res
, itm
->state
| (itm
->popup
? MF_POPUP
: 0) | (!itm
->next
? MF_END
: 0));
847 put_word(res
, itm
->id
);
849 put_string(res
, itm
->name
, str_char
, TRUE
, lang
);
853 menuitem2res(res
, itm
->popup
, lang
);
861 *****************************************************************************
862 * Function : menuexitem2res
863 * Syntax : void menuexitem2res(res_t *res, menuex_item_t *item)
867 * Remarks : Self recursive
868 *****************************************************************************
870 static void menuexitem2res(res_t
*res
, menu_item_t
*menitem
, const language_t
*lang
)
872 menu_item_t
*itm
= menitem
;
876 put_dword(res
, itm
->gottype
? itm
->type
: 0);
877 put_dword(res
, itm
->gotstate
? itm
->state
: 0);
878 put_dword(res
, itm
->gotid
? itm
->id
: 0);
879 put_word(res
, (itm
->popup
? 0x01 : 0) | (!itm
->next
? MF_END
: 0));
881 put_string(res
, itm
->name
, str_unicode
, TRUE
, lang
);
887 put_dword(res
, itm
->gothelpid
? itm
->helpid
: 0);
888 menuexitem2res(res
, itm
->popup
, lang
);
896 *****************************************************************************
897 * Function : menu2res
898 * Syntax : res_t *menu2res(name_id_t *name, menu_t *men)
900 * name - Name/ordinal of the resource
901 * menex - The menuex descriptor
902 * Output : New .res format structure
905 *****************************************************************************
907 static res_t
*menu2res(name_id_t
*name
, menu_t
*men
)
911 assert(name
!= NULL
);
917 restag
= put_res_header(res
, WRC_RT_MENU
, NULL
, name
, men
->memopt
, &(men
->lvc
));
921 put_word(res
, 1); /* Menuheader: Version */
922 put_word(res
, 4); /* Offset */
923 put_dword(res
, 0); /* HelpId */
925 menuexitem2res(res
, men
->items
, men
->lvc
.language
);
929 put_dword(res
, 0); /* Menuheader: Version and HeaderSize */
930 menuitem2res(res
, men
->items
, men
->lvc
.language
);
932 /* Set ResourceSize */
933 SetResSize(res
, restag
);
938 restag
= put_res_header(res
, WRC_RT_MENU
, NULL
, name
, men
->memopt
, NULL
);
940 put_dword(res
, 0); /* Menuheader: Version and HeaderSize */
941 menuitem2res(res
, men
->items
, NULL
);
942 /* Set ResourceSize */
943 SetResSize(res
, restag
);
949 *****************************************************************************
950 * Function : cursorgroup2res
951 * Syntax : res_t *cursorgroup2res(name_id_t *name, cursor_group_t *curg)
953 * name - Name/ordinal of the resource
954 * curg - The cursor descriptor
955 * Output : New .res format structure
958 *****************************************************************************
960 static res_t
*cursorgroup2res(name_id_t
*name
, cursor_group_t
*curg
)
965 assert(name
!= NULL
);
966 assert(curg
!= NULL
);
969 restag
= put_res_header(res
, WRC_RT_GROUP_CURSOR
, NULL
, name
, curg
->memopt
, &(curg
->lvc
));
971 put_word(res
, 0); /* Reserved */
972 /* FIXME: The ResType in the NEWHEADER structure should
973 * contain 14 according to the MS win32 doc. This is
974 * not the case with the BRC compiler and I really doubt
975 * the latter. Putting one here is compliant to win16 spec,
976 * but who knows the true value?
978 put_word(res
, 2); /* ResType */
979 put_word(res
, curg
->ncursor
);
981 for(cur
= curg
->cursorlist
; cur
; cur
= cur
->next
)
983 cur
= curg
->cursorlist
;
986 for(; cur
; cur
= cur
->prev
)
989 put_word(res
, cur
->width
);
990 /* FIXME: The height of a cursor is half the size of
991 * the bitmap's height. BRC puts the height from the
992 * BITMAPINFOHEADER here instead of the cursorfile's
993 * height. MS doesn't seem to care...
995 put_word(res
, cur
->height
);
996 /* FIXME: The next two are reversed in BRC and I don't
997 * know why. Probably a bug. But, we can safely ignore
998 * it because win16 does not support color cursors.
999 * A warning should have been generated by the parser.
1001 put_word(res
, cur
->planes
);
1002 put_word(res
, cur
->bits
);
1003 /* FIXME: The +4 is the hotspot in the cursor resource.
1004 * However, I could not find this in the documentation.
1005 * The hotspot bytes must either be included or MS
1008 put_dword(res
, cur
->data
->size
+4);
1009 put_word(res
, cur
->id
);
1012 SetResSize(res
, restag
); /* Set ResourceSize */
1020 *****************************************************************************
1021 * Function : cursor2res
1022 * Syntax : res_t *cursor2res(cursor_t *cur)
1024 * cur - The cursor descriptor
1025 * Output : New .res format structure
1028 *****************************************************************************
1030 static res_t
*cursor2res(cursor_t
*cur
)
1036 assert(cur
!= NULL
);
1039 name
.type
= name_ord
;
1040 name
.name
.i_name
= cur
->id
;
1041 restag
= put_res_header(res
, WRC_RT_CURSOR
, NULL
, &name
, WRC_MO_MOVEABLE
| WRC_MO_DISCARDABLE
, &(cur
->lvc
));
1042 put_word(res
, cur
->xhot
);
1043 put_word(res
, cur
->yhot
);
1044 put_raw_data(res
, cur
->data
, 0);
1046 SetResSize(res
, restag
); /* Set ResourceSize */
1054 *****************************************************************************
1055 * Function : icongroup2res
1056 * Syntax : res_t *icongroup2res(name_id_t *name, icon_group_t *icog)
1058 * name - Name/ordinal of the resource
1059 * icog - The icon group descriptor
1060 * Output : New .res format structure
1063 *****************************************************************************
1065 static res_t
*icongroup2res(name_id_t
*name
, icon_group_t
*icog
)
1070 assert(name
!= NULL
);
1071 assert(icog
!= NULL
);
1074 restag
= put_res_header(res
, WRC_RT_GROUP_ICON
, NULL
, name
, icog
->memopt
, &(icog
->lvc
));
1076 put_word(res
, 0); /* Reserved */
1077 /* FIXME: The ResType in the NEWHEADER structure should
1078 * contain 14 according to the MS win32 doc. This is
1079 * not the case with the BRC compiler and I really doubt
1080 * the latter. Putting one here is compliant to win16 spec,
1081 * but who knows the true value?
1083 put_word(res
, 1); /* ResType */
1084 put_word(res
, icog
->nicon
);
1085 for(ico
= icog
->iconlist
; ico
; ico
= ico
->next
)
1087 put_byte(res
, ico
->width
);
1088 put_byte(res
, ico
->height
);
1089 put_byte(res
, ico
->nclr
);
1090 put_byte(res
, 0); /* Reserved */
1091 put_word(res
, ico
->planes
);
1092 put_word(res
, ico
->bits
);
1093 put_dword(res
, ico
->data
->size
);
1094 put_word(res
, ico
->id
);
1097 SetResSize(res
, restag
); /* Set ResourceSize */
1105 *****************************************************************************
1106 * Function : icon2res
1107 * Syntax : res_t *icon2res(icon_t *ico)
1109 * ico - The icon descriptor
1110 * Output : New .res format structure
1113 *****************************************************************************
1115 static res_t
*icon2res(icon_t
*ico
)
1121 assert(ico
!= NULL
);
1124 name
.type
= name_ord
;
1125 name
.name
.i_name
= ico
->id
;
1126 restag
= put_res_header(res
, WRC_RT_ICON
, NULL
, &name
, WRC_MO_MOVEABLE
| WRC_MO_DISCARDABLE
, &(ico
->lvc
));
1127 put_raw_data(res
, ico
->data
, 0);
1129 SetResSize(res
, restag
); /* Set ResourceSize */
1137 *****************************************************************************
1138 * Function : anicurico2res
1139 * Syntax : res_t *anicurico2res(name_id_t *name, ani_curico_t *ani)
1141 * name - Name/ordinal of the resource
1142 * ani - The animated object descriptor
1143 * Output : New .res format structure
1145 * Remarks : The endian of the object's structures have been converted
1147 * There are rumors that win311 could handle animated stuff.
1148 * That is why they are generated for both win16 and win32
1150 *****************************************************************************
1152 static res_t
*anicurico2res(name_id_t
*name
, ani_curico_t
*ani
, enum res_e type
)
1156 assert(name
!= NULL
);
1157 assert(ani
!= NULL
);
1160 restag
= put_res_header(res
, type
== res_anicur
? WRC_RT_ANICURSOR
: WRC_RT_ANIICON
,
1161 NULL
, name
, ani
->memopt
, NULL
);
1162 put_raw_data(res
, ani
->data
, 0);
1163 /* Set ResourceSize */
1164 SetResSize(res
, restag
);
1171 *****************************************************************************
1172 * Function : bitmap2res
1173 * Syntax : res_t *bitmap2res(name_id_t *name, bitmap_t *bmp)
1175 * name - Name/ordinal of the resource
1176 * bmp - The bitmap descriptor
1177 * Output : New .res format structure
1179 * Remarks : The endian of the bitmap structures have been converted
1181 *****************************************************************************
1183 static res_t
*bitmap2res(name_id_t
*name
, bitmap_t
*bmp
)
1187 assert(name
!= NULL
);
1188 assert(bmp
!= NULL
);
1191 restag
= put_res_header(res
, WRC_RT_BITMAP
, NULL
, name
, bmp
->memopt
, &(bmp
->data
->lvc
));
1192 if(bmp
->data
->data
[0] == 'B'
1193 && bmp
->data
->data
[1] == 'M'
1194 && ((BITMAPFILEHEADER
*)bmp
->data
->data
)->bfSize
== bmp
->data
->size
1195 && bmp
->data
->size
>= sizeof(BITMAPFILEHEADER
))
1197 /* The File header is still attached, don't write it */
1198 put_raw_data(res
, bmp
->data
, sizeof(BITMAPFILEHEADER
));
1202 put_raw_data(res
, bmp
->data
, 0);
1204 /* Set ResourceSize */
1205 SetResSize(res
, restag
);
1212 *****************************************************************************
1213 * Function : font2res
1214 * Syntax : res_t *font2res(name_id_t *name, font_t *fnt)
1216 * name - Name/ordinal of the resource
1217 * fnt - The font descriptor
1218 * Output : New .res format structure
1220 * Remarks : The data has been prepared just after parsing.
1221 *****************************************************************************
1223 static res_t
*font2res(name_id_t
*name
, font_t
*fnt
)
1227 assert(name
!= NULL
);
1228 assert(fnt
!= NULL
);
1231 restag
= put_res_header(res
, WRC_RT_FONT
, NULL
, name
, fnt
->memopt
, &(fnt
->data
->lvc
));
1232 put_raw_data(res
, fnt
->data
, 0);
1233 /* Set ResourceSize */
1234 SetResSize(res
, restag
);
1241 *****************************************************************************
1242 * Function : fontdir2res
1243 * Syntax : res_t *fontdir2res(name_id_t *name, fontdir_t *fnd)
1245 * name - Name/ordinal of the resource
1246 * fntdir - The fontdir descriptor
1247 * Output : New .res format structure
1249 * Remarks : The data has been prepared just after parsing.
1250 *****************************************************************************
1252 static res_t
*fontdir2res(name_id_t
*name
, fontdir_t
*fnd
)
1256 assert(name
!= NULL
);
1257 assert(fnd
!= NULL
);
1260 restag
= put_res_header(res
, WRC_RT_FONTDIR
, NULL
, name
, fnd
->memopt
, &(fnd
->data
->lvc
));
1261 put_raw_data(res
, fnd
->data
, 0);
1262 /* Set ResourceSize */
1263 SetResSize(res
, restag
);
1270 *****************************************************************************
1271 * Function : html2res
1272 * Syntax : res_t *html2res(name_id_t *name, html_t *html)
1274 * name - Name/ordinal of the resource
1275 * rdt - The html descriptor
1276 * Output : New .res format structure
1279 *****************************************************************************
1281 static res_t
*html2res(name_id_t
*name
, html_t
*html
)
1285 assert(name
!= NULL
);
1286 assert(html
!= NULL
);
1289 restag
= put_res_header(res
, WRC_RT_HTML
, NULL
, name
, html
->memopt
, &(html
->data
->lvc
));
1290 put_raw_data(res
, html
->data
, 0);
1291 /* Set ResourceSize */
1292 SetResSize(res
, restag
);
1299 *****************************************************************************
1300 * Function : rcdata2res
1301 * Syntax : res_t *rcdata2res(name_id_t *name, rcdata_t *rdt)
1303 * name - Name/ordinal of the resource
1304 * rdt - The rcdata descriptor
1305 * Output : New .res format structure
1308 *****************************************************************************
1310 static res_t
*rcdata2res(name_id_t
*name
, rcdata_t
*rdt
)
1314 assert(name
!= NULL
);
1315 assert(rdt
!= NULL
);
1318 restag
= put_res_header(res
, WRC_RT_RCDATA
, NULL
, name
, rdt
->memopt
, &(rdt
->data
->lvc
));
1319 put_raw_data(res
, rdt
->data
, 0);
1320 /* Set ResourceSize */
1321 SetResSize(res
, restag
);
1328 *****************************************************************************
1329 * Function : messagetable2res
1330 * Syntax : res_t *messagetable2res(name_id_t *name, messagetable_t *msg)
1332 * name - Name/ordinal of the resource
1333 * msg - The messagetable descriptor
1334 * Output : New .res format structure
1336 * Remarks : The data has been converted to the appropriate endian
1337 * after it was parsed.
1338 *****************************************************************************
1340 static res_t
*messagetable2res(name_id_t
*name
, messagetable_t
*msg
)
1344 assert(name
!= NULL
);
1345 assert(msg
!= NULL
);
1348 restag
= put_res_header(res
, WRC_RT_MESSAGETABLE
, NULL
, name
, msg
->memopt
, &(msg
->data
->lvc
));
1349 put_raw_data(res
, msg
->data
, 0);
1350 /* Set ResourceSize */
1351 SetResSize(res
, restag
);
1358 *****************************************************************************
1359 * Function : stringtable2res
1360 * Syntax : res_t *stringtable2res(stringtable_t *stt)
1362 * stt - The stringtable descriptor
1363 * Output : New .res format structure
1366 *****************************************************************************
1368 static res_t
*stringtable2res(stringtable_t
*stt
)
1376 assert(stt
!= NULL
);
1379 for(; stt
; stt
= stt
->next
)
1383 warning("Empty internal stringtable\n");
1386 name
.type
= name_ord
;
1387 name
.name
.i_name
= (stt
->idbase
>> 4) + 1;
1388 restag
= put_res_header(res
, WRC_RT_STRING
, NULL
, &name
, stt
->memopt
, win32
? &(stt
->lvc
) : NULL
);
1389 for(i
= 0; i
< stt
->nentries
; i
++)
1391 if(stt
->entries
[i
].str
&& stt
->entries
[i
].str
->size
)
1393 put_string(res
, stt
->entries
[i
].str
, win32
? str_unicode
: str_char
,
1394 FALSE
, win32
? stt
->lvc
.language
: NULL
);
1404 /* Set ResourceSize */
1405 SetResSize(res
, restag
- lastsize
);
1408 lastsize
= res
->size
;
1414 *****************************************************************************
1415 * Function : user2res
1416 * Syntax : res_t *user2res(name_id_t *name, user_t *usr)
1418 * name - Name/ordinal of the resource
1419 * usr - The userresource descriptor
1420 * Output : New .res format structure
1423 *****************************************************************************
1425 static res_t
*user2res(name_id_t
*name
, user_t
*usr
)
1429 assert(name
!= NULL
);
1430 assert(usr
!= NULL
);
1433 restag
= put_res_header(res
, 0, usr
->type
, name
, usr
->memopt
, &(usr
->data
->lvc
));
1434 put_raw_data(res
, usr
->data
, 0);
1435 /* Set ResourceSize */
1436 SetResSize(res
, restag
);
1443 *****************************************************************************
1444 * Function : versionblock2res
1445 * Syntax : void versionblock2res(res_t *res, ver_block_t *blk)
1447 * res - Binary resource to write to
1448 * blk - The version block to be written
1451 * Remarks : Self recursive
1452 *****************************************************************************
1454 static void versionblock2res(res_t
*res
, ver_block_t
*blk
, int level
, const language_t
*lang
)
1463 blksizetag
= res
->size
;
1464 put_word(res
, 0); /* Will be overwritten later */
1467 put_word(res
, 0); /* level ? */
1468 put_string(res
, blk
->name
, win32
? str_unicode
: str_char
, TRUE
, lang
);
1470 for(val
= blk
->values
; val
; val
= val
->next
)
1472 if(val
->type
== val_str
)
1474 valblksizetag
= res
->size
;
1475 put_word(res
, 0); /* Will be overwritten later */
1476 valvalsizetag
= res
->size
;
1477 put_word(res
, 0); /* Will be overwritten later */
1480 put_word(res
, level
);
1482 put_string(res
, val
->key
, win32
? str_unicode
: str_char
, TRUE
, lang
);
1485 put_string(res
, val
->value
.str
, win32
? str_unicode
: str_char
, TRUE
, lang
);
1487 set_word(res
, valvalsizetag
, (WORD
)((res
->size
- tag
) >> 1));
1489 set_word(res
, valvalsizetag
, (WORD
)(res
->size
- tag
));
1490 set_word(res
, valblksizetag
, (WORD
)(res
->size
- valblksizetag
));
1493 else if(val
->type
== val_words
)
1495 valblksizetag
= res
->size
;
1496 put_word(res
, 0); /* Will be overwritten later */
1497 valvalsizetag
= res
->size
;
1498 put_word(res
, 0); /* Will be overwritten later */
1501 put_word(res
, level
);
1503 put_string(res
, val
->key
, win32
? str_unicode
: str_char
, TRUE
, lang
);
1506 for(i
= 0; i
< val
->value
.words
->nwords
; i
++)
1508 put_word(res
, val
->value
.words
->words
[i
]);
1510 set_word(res
, valvalsizetag
, (WORD
)(res
->size
- tag
));
1511 set_word(res
, valblksizetag
, (WORD
)(res
->size
- valblksizetag
));
1514 else if(val
->type
== val_block
)
1516 versionblock2res(res
, val
->value
.block
, level
+1, lang
);
1520 internal_error(__FILE__
, __LINE__
, "Invalid value indicator %d in VERSIONINFO\n", val
->type
);
1525 set_word(res
, blksizetag
, (WORD
)(res
->size
- blksizetag
));
1529 *****************************************************************************
1530 * Function : versioninfo2res
1531 * Syntax : res_t *versioninfo2res(name_id_t *name, versioninfo_t *ver)
1533 * name - Name/ordinal of the resource
1534 * ver - The versioninfo descriptor
1535 * Output : New .res format structure
1538 *****************************************************************************
1540 static res_t
*versioninfo2res(name_id_t
*name
, versioninfo_t
*ver
)
1543 int rootblocksizetag
;
1550 assert(name
!= NULL
);
1551 assert(ver
!= NULL
);
1553 vsvi
.type
= str_char
;
1554 vsvi
.str
.cstr
= xstrdup("VS_VERSION_INFO");
1555 vsvi
.size
= 15; /* Excl. termination */
1558 restag
= put_res_header(res
, WRC_RT_VERSION
, NULL
, name
, ver
->memopt
, &(ver
->lvc
));
1559 rootblocksizetag
= res
->size
;
1560 put_word(res
, 0); /* BlockSize filled in later */
1561 valsizetag
= res
->size
;
1562 put_word(res
, 0); /* ValueSize filled in later*/
1564 put_word(res
, 0); /* Tree-level ? */
1565 put_string(res
, &vsvi
, win32
? str_unicode
: str_char
,
1566 TRUE
, win32
? ver
->lvc
.language
: NULL
);
1570 put_dword(res
, VS_FFI_SIGNATURE
);
1571 put_dword(res
, VS_FFI_STRUCVERSION
);
1572 put_dword(res
, (ver
->filever_maj1
<< 16) + (ver
->filever_maj2
& 0xffff));
1573 put_dword(res
, (ver
->filever_min1
<< 16) + (ver
->filever_min2
& 0xffff));
1574 put_dword(res
, (ver
->prodver_maj1
<< 16) + (ver
->prodver_maj2
& 0xffff));
1575 put_dword(res
, (ver
->prodver_min1
<< 16) + (ver
->prodver_min2
& 0xffff));
1576 put_dword(res
, ver
->fileflagsmask
);
1577 put_dword(res
, ver
->fileflags
);
1578 put_dword(res
, ver
->fileos
);
1579 put_dword(res
, ver
->filetype
);
1580 put_dword(res
, ver
->filesubtype
);
1581 put_dword(res
, 0); /* FileDateMS */
1582 put_dword(res
, 0); /* FileDateLS */
1584 set_word(res
, valsizetag
, (WORD
)(res
->size
- tag
));
1585 /* Descend into the blocks */
1586 for(blk
= ver
->blocks
; blk
; blk
= blk
->next
)
1587 versionblock2res(res
, blk
, 0, win32
? ver
->lvc
.language
: NULL
);
1588 /* Set root block's size */
1589 set_word(res
, rootblocksizetag
, (WORD
)(res
->size
- rootblocksizetag
));
1591 SetResSize(res
, restag
);
1595 free(vsvi
.str
.cstr
);
1600 *****************************************************************************
1601 * Function : toolbaritem2res
1602 * Syntax : void toolbaritem2res(res_t *res, toolbar_item_t *tbitem)
1606 * Remarks : Self recursive
1607 *****************************************************************************
1609 static void toolbaritem2res(res_t
*res
, toolbar_item_t
*tbitem
)
1611 toolbar_item_t
*itm
= tbitem
;
1615 put_word(res
, itm
->id
);
1622 *****************************************************************************
1623 * Function : toolbar2res
1624 * Syntax : res_t *toolbar2res(name_id_t *name, toolbar_t *toolbar)
1626 * name - Name/ordinal of the resource
1627 * toolbar - The toolbar descriptor
1628 * Output : New .res format structure
1631 *****************************************************************************
1633 static res_t
*toolbar2res(name_id_t
*name
, toolbar_t
*toolbar
)
1637 assert(name
!= NULL
);
1638 assert(toolbar
!= NULL
);
1643 restag
= put_res_header(res
, WRC_RT_TOOLBAR
, NULL
, name
, toolbar
->memopt
, &(toolbar
->lvc
));
1645 put_word(res
, 1); /* Menuheader: Version */
1646 put_word(res
, toolbar
->button_width
); /* (in pixels?) */
1647 put_word(res
, toolbar
->button_height
); /* (in pixels?) */
1648 put_word(res
, toolbar
->nitems
);
1650 toolbaritem2res(res
, toolbar
->items
);
1651 /* Set ResourceSize */
1652 SetResSize(res
, restag
);
1657 /* Do not generate anything in 16-bit mode */
1666 *****************************************************************************
1667 * Function : dlginit2res
1668 * Syntax : res_t *dlginit2res(name_id_t *name, dlginit_t *dit)
1670 * name - Name/ordinal of the resource
1671 * rdt - The dlginit descriptor
1672 * Output : New .res format structure
1675 *****************************************************************************
1677 static res_t
*dlginit2res(name_id_t
*name
, dlginit_t
*dit
)
1681 assert(name
!= NULL
);
1682 assert(dit
!= NULL
);
1685 restag
= put_res_header(res
, WRC_RT_DLGINIT
, NULL
, name
, dit
->memopt
, &(dit
->data
->lvc
));
1686 put_raw_data(res
, dit
->data
, 0);
1687 /* Set ResourceSize */
1688 SetResSize(res
, restag
);
1695 *****************************************************************************
1696 * Function : prep_nid_for_label
1697 * Syntax : char *prep_nid_for_label(const name_id_t *nid)
1700 * Description : Converts a resource name into the first 32 (or less)
1701 * characters of the name with conversions.
1703 *****************************************************************************
1705 #define MAXNAMELEN 32
1706 char *prep_nid_for_label(const name_id_t
*nid
)
1708 static char buf
[MAXNAMELEN
+1];
1710 assert(nid
!= NULL
);
1712 if(nid
->type
== name_str
&& nid
->name
.s_name
->type
== str_unicode
)
1716 sptr
= nid
->name
.s_name
->str
.wstr
;
1718 for(i
= 0; *sptr
&& i
< MAXNAMELEN
; i
++)
1720 if((unsigned)*sptr
< 0x80 && isprint(*sptr
& 0xff))
1723 warning("Resourcename (str_unicode) contain unprintable characters or invalid translation, ignored\n");
1727 else if(nid
->type
== name_str
&& nid
->name
.s_name
->type
== str_char
)
1731 cptr
= nid
->name
.s_name
->str
.cstr
;
1733 for(i
= 0; *cptr
&& i
< MAXNAMELEN
; i
++)
1735 if((unsigned)*cptr
< 0x80 && isprint(*cptr
& 0xff))
1738 warning("Resourcename (str_char) contain unprintable characters, ignored\n");
1742 else if(nid
->type
== name_ord
)
1744 sprintf(buf
, "%u", nid
->name
.i_name
);
1748 internal_error(__FILE__
, __LINE__
, "Resource name_id with invalid type %d\n", nid
->type
);
1755 *****************************************************************************
1756 * Function : make_c_name
1757 * Syntax : char *make_c_name(const char *base, const name_id_t *nid, const language_t *lan)
1760 * Description : Converts a resource name into a valid c-identifier in the
1763 *****************************************************************************
1765 char *make_c_name(const char *base
, const name_id_t
*nid
, const language_t
*lan
)
1767 char *buf
= prep_nid_for_label(nid
);
1768 return strmake( "_%s_%s_%d", base
, buf
, lan
? MAKELANGID(lan
->id
, lan
->sub
) : 0);
1772 *****************************************************************************
1773 * Function : get_c_typename
1774 * Syntax : const char *get_c_typename(enum res_e type)
1777 * Description : Convert resource enum to char string to be used in c-name
1780 *****************************************************************************
1782 const char *get_c_typename(enum res_e type
)
1786 case res_acc
: return "Acc";
1787 case res_anicur
:return "AniCur";
1788 case res_aniico
:return "AniIco";
1789 case res_bmp
: return "Bmp";
1790 case res_cur
: return "Cur";
1791 case res_curg
: return "CurGrp";
1792 case res_dlg
: return "Dlg";
1793 case res_fnt
: return "Fnt";
1794 case res_fntdir
:return "FntDir";
1795 case res_ico
: return "Ico";
1796 case res_icog
: return "IcoGrp";
1797 case res_men
: return "Men";
1798 case res_rdt
: return "RCDat";
1799 case res_stt
: return "StrTab";
1800 case res_usr
: return "Usr";
1801 case res_msg
: return "MsgTab";
1802 case res_ver
: return "VerInf";
1803 case res_toolbar
: return "TlBr";
1804 case res_dlginit
: return "DlgInit";
1805 default: return "Oops";
1810 *****************************************************************************
1811 * Function : resources2res
1812 * Syntax : void resources2res(resource_t *top)
1814 * top - The resource-tree to convert
1816 * Description : Convert logical resource descriptors into binary data
1818 *****************************************************************************
1820 void resources2res(resource_t
*top
)
1828 top
->binres
= accelerator2res(top
->name
, top
->res
.acc
);
1832 top
->binres
= bitmap2res(top
->name
, top
->res
.bmp
);
1836 top
->binres
= cursor2res(top
->res
.cur
);
1840 top
->binres
= cursorgroup2res(top
->name
, top
->res
.curg
);
1844 top
->binres
= dialog2res(top
->name
, top
->res
.dlg
);
1848 top
->binres
= font2res(top
->name
, top
->res
.fnt
);
1852 top
->binres
= fontdir2res(top
->name
, top
->res
.fnd
);
1856 top
->binres
= icon2res(top
->res
.ico
);
1860 top
->binres
= icongroup2res(top
->name
, top
->res
.icog
);
1864 top
->binres
= menu2res(top
->name
, top
->res
.men
);
1868 top
->binres
= html2res(top
->name
, top
->res
.html
);
1872 top
->binres
= rcdata2res(top
->name
, top
->res
.rdt
);
1876 top
->binres
= stringtable2res(top
->res
.stt
);
1880 top
->binres
= user2res(top
->name
, top
->res
.usr
);
1884 top
->binres
= messagetable2res(top
->name
, top
->res
.msg
);
1888 top
->binres
= versioninfo2res(top
->name
, top
->res
.ver
);
1892 top
->binres
= toolbar2res(top
->name
, top
->res
.tbt
);
1896 top
->binres
= dlginit2res(top
->name
, top
->res
.dlgi
);
1901 top
->binres
= anicurico2res(top
->name
, top
->res
.ani
, top
->type
);
1904 internal_error(__FILE__
, __LINE__
, "Unknown resource type encountered %d in binary res generation\n", top
->type
);
1906 top
->c_name
= make_c_name(get_c_typename(top
->type
), top
->name
, top
->lan
);