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
+2);
731 put_raw_data(res
, ctrl
->extra
, 0);
741 /* Set number of controls */
742 set_word(res
, tag_nctrl
, (WORD
)nctrl
);
746 restag
= put_res_header(res
, WRC_RT_DIALOG
, NULL
, name
, dlg
->memopt
, NULL
);
748 put_dword(res
, dlg
->gotstyle
? dlg
->style
->or_mask
: WS_POPUPWINDOW
);
749 tag_nctrl
= res
->size
;
750 put_byte(res
, 0); /* Number of controls */
751 put_word(res
, dlg
->x
);
752 put_word(res
, dlg
->y
);
753 put_word(res
, dlg
->width
);
754 put_word(res
, dlg
->height
);
756 put_name_id(res
, dlg
->menu
, TRUE
, NULL
);
760 put_name_id(res
, dlg
->dlgclass
, TRUE
, NULL
);
764 put_string(res
, dlg
->title
, str_char
, TRUE
, NULL
);
769 put_word(res
, dlg
->font
->size
);
770 put_string(res
, dlg
->font
->name
, str_char
, TRUE
, NULL
);
775 put_word(res
, ctrl
->x
);
776 put_word(res
, ctrl
->y
);
777 put_word(res
, ctrl
->width
);
778 put_word(res
, ctrl
->height
);
779 put_word(res
, ctrl
->id
);
780 put_dword(res
, ctrl
->gotstyle
? ctrl
->style
->or_mask
: WS_CHILD
);
783 if(ctrl
->ctlclass
->type
== name_ord
784 && ctrl
->ctlclass
->name
.i_name
>= 0x80
785 && ctrl
->ctlclass
->name
.i_name
<= 0x85)
786 put_byte(res
, ctrl
->ctlclass
->name
.i_name
);
787 else if(ctrl
->ctlclass
->type
== name_str
)
788 put_name_id(res
, ctrl
->ctlclass
, FALSE
, NULL
);
790 error("Unknown control-class %04x\n", ctrl
->ctlclass
->name
.i_name
);
793 internal_error(__FILE__
, __LINE__
, "Control has no control-class\n");
795 put_name_id(res
, ctrl
->title
, FALSE
, NULL
);
799 /* FIXME: What is this extra byte doing here? */
805 /* Set number of controls */
806 ((char *)res
->data
)[tag_nctrl
] = (char)nctrl
;
808 /* Set ResourceSize */
809 SetResSize(res
, restag
);
814 *****************************************************************************
815 * Function : menuitem2res
816 * Syntax : void menuitem2res(res_t *res, menu_item_t *item)
820 * Remarks : Self recursive
821 *****************************************************************************
823 static void menuitem2res(res_t
*res
, menu_item_t
*menitem
, const language_t
*lang
)
825 menu_item_t
*itm
= menitem
;
830 put_word(res
, itm
->state
| (itm
->popup
? MF_POPUP
: 0) | (!itm
->next
? MF_END
: 0));
832 put_word(res
, itm
->id
);
834 put_string(res
, itm
->name
, str_unicode
, TRUE
, lang
);
838 menuitem2res(res
, itm
->popup
, lang
);
846 put_word(res
, itm
->state
| (itm
->popup
? MF_POPUP
: 0) | (!itm
->next
? MF_END
: 0));
848 put_word(res
, itm
->id
);
850 put_string(res
, itm
->name
, str_char
, TRUE
, lang
);
854 menuitem2res(res
, itm
->popup
, lang
);
862 *****************************************************************************
863 * Function : menuexitem2res
864 * Syntax : void menuexitem2res(res_t *res, menuex_item_t *item)
868 * Remarks : Self recursive
869 *****************************************************************************
871 static void menuexitem2res(res_t
*res
, menu_item_t
*menitem
, const language_t
*lang
)
873 menu_item_t
*itm
= menitem
;
877 put_dword(res
, itm
->gottype
? itm
->type
: 0);
878 put_dword(res
, itm
->gotstate
? itm
->state
: 0);
879 put_dword(res
, itm
->gotid
? itm
->id
: 0); /* FIXME: Docu. says word */
880 put_word(res
, (itm
->popup
? 0x01 : 0) | (!itm
->next
? MF_END
: 0));
882 put_string(res
, itm
->name
, str_unicode
, TRUE
, lang
);
888 put_dword(res
, itm
->gothelpid
? itm
->helpid
: 0);
889 menuexitem2res(res
, itm
->popup
, lang
);
897 *****************************************************************************
898 * Function : menu2res
899 * Syntax : res_t *menu2res(name_id_t *name, menu_t *men)
901 * name - Name/ordinal of the resource
902 * menex - The menuex descriptor
903 * Output : New .res format structure
906 *****************************************************************************
908 static res_t
*menu2res(name_id_t
*name
, menu_t
*men
)
912 assert(name
!= NULL
);
918 restag
= put_res_header(res
, WRC_RT_MENU
, NULL
, name
, men
->memopt
, &(men
->lvc
));
922 put_word(res
, 1); /* Menuheader: Version */
923 put_word(res
, 4); /* Offset */
924 put_dword(res
, 0); /* HelpId */
926 menuexitem2res(res
, men
->items
, men
->lvc
.language
);
930 put_dword(res
, 0); /* Menuheader: Version and HeaderSize */
931 menuitem2res(res
, men
->items
, men
->lvc
.language
);
933 /* Set ResourceSize */
934 SetResSize(res
, restag
);
939 restag
= put_res_header(res
, WRC_RT_MENU
, NULL
, name
, men
->memopt
, NULL
);
941 put_dword(res
, 0); /* Menuheader: Version and HeaderSize */
942 menuitem2res(res
, men
->items
, NULL
);
943 /* Set ResourceSize */
944 SetResSize(res
, restag
);
950 *****************************************************************************
951 * Function : cursorgroup2res
952 * Syntax : res_t *cursorgroup2res(name_id_t *name, cursor_group_t *curg)
954 * name - Name/ordinal of the resource
955 * curg - The cursor descriptor
956 * Output : New .res format structure
959 *****************************************************************************
961 static res_t
*cursorgroup2res(name_id_t
*name
, cursor_group_t
*curg
)
966 assert(name
!= NULL
);
967 assert(curg
!= NULL
);
970 restag
= put_res_header(res
, WRC_RT_GROUP_CURSOR
, NULL
, name
, curg
->memopt
, &(curg
->lvc
));
972 put_word(res
, 0); /* Reserved */
973 /* FIXME: The ResType in the NEWHEADER structure should
974 * contain 14 according to the MS win32 doc. This is
975 * not the case with the BRC compiler and I really doubt
976 * the latter. Putting one here is compliant to win16 spec,
977 * but who knows the true value?
979 put_word(res
, 2); /* ResType */
980 put_word(res
, curg
->ncursor
);
982 for(cur
= curg
->cursorlist
; cur
; cur
= cur
->next
)
984 cur
= curg
->cursorlist
;
987 for(; cur
; cur
= cur
->prev
)
990 put_word(res
, cur
->width
);
991 /* FIXME: The height of a cursor is half the size of
992 * the bitmap's height. BRC puts the height from the
993 * BITMAPINFOHEADER here instead of the cursorfile's
994 * height. MS doesn't seem to care...
996 put_word(res
, cur
->height
);
997 /* FIXME: The next two are reversed in BRC and I don't
998 * know why. Probably a bug. But, we can safely ignore
999 * it because win16 does not support color cursors.
1000 * A warning should have been generated by the parser.
1002 put_word(res
, cur
->planes
);
1003 put_word(res
, cur
->bits
);
1004 /* FIXME: The +4 is the hotspot in the cursor resource.
1005 * However, I could not find this in the documentation.
1006 * The hotspot bytes must either be included or MS
1009 put_dword(res
, cur
->data
->size
+4);
1010 put_word(res
, cur
->id
);
1013 SetResSize(res
, restag
); /* Set ResourceSize */
1021 *****************************************************************************
1022 * Function : cursor2res
1023 * Syntax : res_t *cursor2res(cursor_t *cur)
1025 * cur - The cursor descriptor
1026 * Output : New .res format structure
1029 *****************************************************************************
1031 static res_t
*cursor2res(cursor_t
*cur
)
1037 assert(cur
!= NULL
);
1040 name
.type
= name_ord
;
1041 name
.name
.i_name
= cur
->id
;
1042 restag
= put_res_header(res
, WRC_RT_CURSOR
, NULL
, &name
, WRC_MO_MOVEABLE
| WRC_MO_DISCARDABLE
, &(cur
->lvc
));
1043 put_word(res
, cur
->xhot
);
1044 put_word(res
, cur
->yhot
);
1045 put_raw_data(res
, cur
->data
, 0);
1047 SetResSize(res
, restag
); /* Set ResourceSize */
1055 *****************************************************************************
1056 * Function : icongroup2res
1057 * Syntax : res_t *icongroup2res(name_id_t *name, icon_group_t *icog)
1059 * name - Name/ordinal of the resource
1060 * icog - The icon group descriptor
1061 * Output : New .res format structure
1064 *****************************************************************************
1066 static res_t
*icongroup2res(name_id_t
*name
, icon_group_t
*icog
)
1071 assert(name
!= NULL
);
1072 assert(icog
!= NULL
);
1075 restag
= put_res_header(res
, WRC_RT_GROUP_ICON
, NULL
, name
, icog
->memopt
, &(icog
->lvc
));
1077 put_word(res
, 0); /* Reserved */
1078 /* FIXME: The ResType in the NEWHEADER structure should
1079 * contain 14 according to the MS win32 doc. This is
1080 * not the case with the BRC compiler and I really doubt
1081 * the latter. Putting one here is compliant to win16 spec,
1082 * but who knows the true value?
1084 put_word(res
, 1); /* ResType */
1085 put_word(res
, icog
->nicon
);
1086 for(ico
= icog
->iconlist
; ico
; ico
= ico
->next
)
1088 put_byte(res
, ico
->width
);
1089 put_byte(res
, ico
->height
);
1090 put_byte(res
, ico
->nclr
);
1091 put_byte(res
, 0); /* Reserved */
1092 put_word(res
, ico
->planes
);
1093 put_word(res
, ico
->bits
);
1094 put_dword(res
, ico
->data
->size
);
1095 put_word(res
, ico
->id
);
1098 SetResSize(res
, restag
); /* Set ResourceSize */
1106 *****************************************************************************
1107 * Function : icon2res
1108 * Syntax : res_t *icon2res(icon_t *ico)
1110 * ico - The icon descriptor
1111 * Output : New .res format structure
1114 *****************************************************************************
1116 static res_t
*icon2res(icon_t
*ico
)
1122 assert(ico
!= NULL
);
1125 name
.type
= name_ord
;
1126 name
.name
.i_name
= ico
->id
;
1127 restag
= put_res_header(res
, WRC_RT_ICON
, NULL
, &name
, WRC_MO_MOVEABLE
| WRC_MO_DISCARDABLE
, &(ico
->lvc
));
1128 put_raw_data(res
, ico
->data
, 0);
1130 SetResSize(res
, restag
); /* Set ResourceSize */
1138 *****************************************************************************
1139 * Function : anicurico2res
1140 * Syntax : res_t *anicurico2res(name_id_t *name, ani_curico_t *ani)
1142 * name - Name/ordinal of the resource
1143 * ani - The animated object descriptor
1144 * Output : New .res format structure
1146 * Remarks : The endian of the object's structures have been converted
1148 * There are rumors that win311 could handle animated stuff.
1149 * That is why they are generated for both win16 and win32
1151 *****************************************************************************
1153 static res_t
*anicurico2res(name_id_t
*name
, ani_curico_t
*ani
, enum res_e type
)
1157 assert(name
!= NULL
);
1158 assert(ani
!= NULL
);
1161 restag
= put_res_header(res
, type
== res_anicur
? WRC_RT_ANICURSOR
: WRC_RT_ANIICON
,
1162 NULL
, name
, ani
->memopt
, NULL
);
1163 put_raw_data(res
, ani
->data
, 0);
1164 /* Set ResourceSize */
1165 SetResSize(res
, restag
);
1172 *****************************************************************************
1173 * Function : bitmap2res
1174 * Syntax : res_t *bitmap2res(name_id_t *name, bitmap_t *bmp)
1176 * name - Name/ordinal of the resource
1177 * bmp - The bitmap descriptor
1178 * Output : New .res format structure
1180 * Remarks : The endian of the bitmap structures have been converted
1182 *****************************************************************************
1184 static res_t
*bitmap2res(name_id_t
*name
, bitmap_t
*bmp
)
1188 assert(name
!= NULL
);
1189 assert(bmp
!= NULL
);
1192 restag
= put_res_header(res
, WRC_RT_BITMAP
, NULL
, name
, bmp
->memopt
, &(bmp
->data
->lvc
));
1193 if(bmp
->data
->data
[0] == 'B'
1194 && bmp
->data
->data
[1] == 'M'
1195 && ((BITMAPFILEHEADER
*)bmp
->data
->data
)->bfSize
== bmp
->data
->size
1196 && bmp
->data
->size
>= sizeof(BITMAPFILEHEADER
))
1198 /* The File header is still attached, don't write it */
1199 put_raw_data(res
, bmp
->data
, sizeof(BITMAPFILEHEADER
));
1203 put_raw_data(res
, bmp
->data
, 0);
1205 /* Set ResourceSize */
1206 SetResSize(res
, restag
);
1213 *****************************************************************************
1214 * Function : font2res
1215 * Syntax : res_t *font2res(name_id_t *name, font_t *fnt)
1217 * name - Name/ordinal of the resource
1218 * fnt - The font descriptor
1219 * Output : New .res format structure
1221 * Remarks : The data has been prepared just after parsing.
1222 *****************************************************************************
1224 static res_t
*font2res(name_id_t
*name
, font_t
*fnt
)
1228 assert(name
!= NULL
);
1229 assert(fnt
!= NULL
);
1232 restag
= put_res_header(res
, WRC_RT_FONT
, NULL
, name
, fnt
->memopt
, &(fnt
->data
->lvc
));
1233 put_raw_data(res
, fnt
->data
, 0);
1234 /* Set ResourceSize */
1235 SetResSize(res
, restag
);
1242 *****************************************************************************
1243 * Function : fontdir2res
1244 * Syntax : res_t *fontdir2res(name_id_t *name, fontdir_t *fnd)
1246 * name - Name/ordinal of the resource
1247 * fntdir - The fontdir descriptor
1248 * Output : New .res format structure
1250 * Remarks : The data has been prepared just after parsing.
1251 *****************************************************************************
1253 static res_t
*fontdir2res(name_id_t
*name
, fontdir_t
*fnd
)
1257 assert(name
!= NULL
);
1258 assert(fnd
!= NULL
);
1261 restag
= put_res_header(res
, WRC_RT_FONTDIR
, NULL
, name
, fnd
->memopt
, &(fnd
->data
->lvc
));
1262 put_raw_data(res
, fnd
->data
, 0);
1263 /* Set ResourceSize */
1264 SetResSize(res
, restag
);
1271 *****************************************************************************
1272 * Function : html2res
1273 * Syntax : res_t *html2res(name_id_t *name, html_t *html)
1275 * name - Name/ordinal of the resource
1276 * rdt - The html descriptor
1277 * Output : New .res format structure
1280 *****************************************************************************
1282 static res_t
*html2res(name_id_t
*name
, html_t
*html
)
1286 assert(name
!= NULL
);
1287 assert(html
!= NULL
);
1290 restag
= put_res_header(res
, WRC_RT_HTML
, NULL
, name
, html
->memopt
, &(html
->data
->lvc
));
1291 put_raw_data(res
, html
->data
, 0);
1292 /* Set ResourceSize */
1293 SetResSize(res
, restag
);
1300 *****************************************************************************
1301 * Function : rcdata2res
1302 * Syntax : res_t *rcdata2res(name_id_t *name, rcdata_t *rdt)
1304 * name - Name/ordinal of the resource
1305 * rdt - The rcdata descriptor
1306 * Output : New .res format structure
1309 *****************************************************************************
1311 static res_t
*rcdata2res(name_id_t
*name
, rcdata_t
*rdt
)
1315 assert(name
!= NULL
);
1316 assert(rdt
!= NULL
);
1319 restag
= put_res_header(res
, WRC_RT_RCDATA
, NULL
, name
, rdt
->memopt
, &(rdt
->data
->lvc
));
1320 put_raw_data(res
, rdt
->data
, 0);
1321 /* Set ResourceSize */
1322 SetResSize(res
, restag
);
1329 *****************************************************************************
1330 * Function : messagetable2res
1331 * Syntax : res_t *messagetable2res(name_id_t *name, messagetable_t *msg)
1333 * name - Name/ordinal of the resource
1334 * msg - The messagetable descriptor
1335 * Output : New .res format structure
1337 * Remarks : The data has been converted to the appropriate endian
1338 * after it was parsed.
1339 *****************************************************************************
1341 static res_t
*messagetable2res(name_id_t
*name
, messagetable_t
*msg
)
1345 assert(name
!= NULL
);
1346 assert(msg
!= NULL
);
1349 restag
= put_res_header(res
, WRC_RT_MESSAGETABLE
, NULL
, name
, msg
->memopt
, &(msg
->data
->lvc
));
1350 put_raw_data(res
, msg
->data
, 0);
1351 /* Set ResourceSize */
1352 SetResSize(res
, restag
);
1359 *****************************************************************************
1360 * Function : stringtable2res
1361 * Syntax : res_t *stringtable2res(stringtable_t *stt)
1363 * stt - The stringtable descriptor
1364 * Output : New .res format structure
1367 *****************************************************************************
1369 static res_t
*stringtable2res(stringtable_t
*stt
)
1377 assert(stt
!= NULL
);
1380 for(; stt
; stt
= stt
->next
)
1384 warning("Empty internal stringtable\n");
1387 name
.type
= name_ord
;
1388 name
.name
.i_name
= (stt
->idbase
>> 4) + 1;
1389 restag
= put_res_header(res
, WRC_RT_STRING
, NULL
, &name
, stt
->memopt
, win32
? &(stt
->lvc
) : NULL
);
1390 for(i
= 0; i
< stt
->nentries
; i
++)
1392 if(stt
->entries
[i
].str
&& stt
->entries
[i
].str
->size
)
1394 put_string(res
, stt
->entries
[i
].str
, win32
? str_unicode
: str_char
,
1395 FALSE
, win32
? stt
->lvc
.language
: NULL
);
1405 /* Set ResourceSize */
1406 SetResSize(res
, restag
- lastsize
);
1409 lastsize
= res
->size
;
1415 *****************************************************************************
1416 * Function : user2res
1417 * Syntax : res_t *user2res(name_id_t *name, user_t *usr)
1419 * name - Name/ordinal of the resource
1420 * usr - The userresource descriptor
1421 * Output : New .res format structure
1424 *****************************************************************************
1426 static res_t
*user2res(name_id_t
*name
, user_t
*usr
)
1430 assert(name
!= NULL
);
1431 assert(usr
!= NULL
);
1434 restag
= put_res_header(res
, 0, usr
->type
, name
, usr
->memopt
, &(usr
->data
->lvc
));
1435 put_raw_data(res
, usr
->data
, 0);
1436 /* Set ResourceSize */
1437 SetResSize(res
, restag
);
1444 *****************************************************************************
1445 * Function : versionblock2res
1446 * Syntax : void versionblock2res(res_t *res, ver_block_t *blk)
1448 * res - Binary resource to write to
1449 * blk - The version block to be written
1452 * Remarks : Self recursive
1453 *****************************************************************************
1455 static void versionblock2res(res_t
*res
, ver_block_t
*blk
, int level
, const language_t
*lang
)
1464 blksizetag
= res
->size
;
1465 put_word(res
, 0); /* Will be overwritten later */
1468 put_word(res
, 0); /* level ? */
1469 put_string(res
, blk
->name
, win32
? str_unicode
: str_char
, TRUE
, lang
);
1471 for(val
= blk
->values
; val
; val
= val
->next
)
1473 if(val
->type
== val_str
)
1475 valblksizetag
= res
->size
;
1476 put_word(res
, 0); /* Will be overwritten later */
1477 valvalsizetag
= res
->size
;
1478 put_word(res
, 0); /* Will be overwritten later */
1481 put_word(res
, level
);
1483 put_string(res
, val
->key
, win32
? str_unicode
: str_char
, TRUE
, lang
);
1486 put_string(res
, val
->value
.str
, win32
? str_unicode
: str_char
, TRUE
, lang
);
1488 set_word(res
, valvalsizetag
, (WORD
)((res
->size
- tag
) >> 1));
1490 set_word(res
, valvalsizetag
, (WORD
)(res
->size
- tag
));
1491 set_word(res
, valblksizetag
, (WORD
)(res
->size
- valblksizetag
));
1494 else if(val
->type
== val_words
)
1496 valblksizetag
= res
->size
;
1497 put_word(res
, 0); /* Will be overwritten later */
1498 valvalsizetag
= res
->size
;
1499 put_word(res
, 0); /* Will be overwritten later */
1502 put_word(res
, level
);
1504 put_string(res
, val
->key
, win32
? str_unicode
: str_char
, TRUE
, lang
);
1507 for(i
= 0; i
< val
->value
.words
->nwords
; i
++)
1509 put_word(res
, val
->value
.words
->words
[i
]);
1511 set_word(res
, valvalsizetag
, (WORD
)(res
->size
- tag
));
1512 set_word(res
, valblksizetag
, (WORD
)(res
->size
- valblksizetag
));
1515 else if(val
->type
== val_block
)
1517 versionblock2res(res
, val
->value
.block
, level
+1, lang
);
1521 internal_error(__FILE__
, __LINE__
, "Invalid value indicator %d in VERSIONINFO\n", val
->type
);
1526 set_word(res
, blksizetag
, (WORD
)(res
->size
- blksizetag
));
1530 *****************************************************************************
1531 * Function : versioninfo2res
1532 * Syntax : res_t *versioninfo2res(name_id_t *name, versioninfo_t *ver)
1534 * name - Name/ordinal of the resource
1535 * ver - The versioninfo descriptor
1536 * Output : New .res format structure
1539 *****************************************************************************
1541 static res_t
*versioninfo2res(name_id_t
*name
, versioninfo_t
*ver
)
1544 int rootblocksizetag
;
1551 assert(name
!= NULL
);
1552 assert(ver
!= NULL
);
1554 vsvi
.type
= str_char
;
1555 vsvi
.str
.cstr
= xstrdup("VS_VERSION_INFO");
1556 vsvi
.size
= 15; /* Excl. termination */
1559 restag
= put_res_header(res
, WRC_RT_VERSION
, NULL
, name
, ver
->memopt
, &(ver
->lvc
));
1560 rootblocksizetag
= res
->size
;
1561 put_word(res
, 0); /* BlockSize filled in later */
1562 valsizetag
= res
->size
;
1563 put_word(res
, 0); /* ValueSize filled in later*/
1565 put_word(res
, 0); /* Tree-level ? */
1566 put_string(res
, &vsvi
, win32
? str_unicode
: str_char
,
1567 TRUE
, win32
? ver
->lvc
.language
: NULL
);
1571 put_dword(res
, VS_FFI_SIGNATURE
);
1572 put_dword(res
, VS_FFI_STRUCVERSION
);
1573 put_dword(res
, (ver
->filever_maj1
<< 16) + (ver
->filever_maj2
& 0xffff));
1574 put_dword(res
, (ver
->filever_min1
<< 16) + (ver
->filever_min2
& 0xffff));
1575 put_dword(res
, (ver
->prodver_maj1
<< 16) + (ver
->prodver_maj2
& 0xffff));
1576 put_dword(res
, (ver
->prodver_min1
<< 16) + (ver
->prodver_min2
& 0xffff));
1577 put_dword(res
, ver
->fileflagsmask
);
1578 put_dword(res
, ver
->fileflags
);
1579 put_dword(res
, ver
->fileos
);
1580 put_dword(res
, ver
->filetype
);
1581 put_dword(res
, ver
->filesubtype
);
1582 put_dword(res
, 0); /* FileDateMS */
1583 put_dword(res
, 0); /* FileDateLS */
1585 set_word(res
, valsizetag
, (WORD
)(res
->size
- tag
));
1586 /* Descend into the blocks */
1587 for(blk
= ver
->blocks
; blk
; blk
= blk
->next
)
1588 versionblock2res(res
, blk
, 0, win32
? ver
->lvc
.language
: NULL
);
1589 /* Set root block's size */
1590 set_word(res
, rootblocksizetag
, (WORD
)(res
->size
- rootblocksizetag
));
1592 SetResSize(res
, restag
);
1596 free(vsvi
.str
.cstr
);
1601 *****************************************************************************
1602 * Function : toolbaritem2res
1603 * Syntax : void toolbaritem2res(res_t *res, toolbar_item_t *tbitem)
1607 * Remarks : Self recursive
1608 *****************************************************************************
1610 static void toolbaritem2res(res_t
*res
, toolbar_item_t
*tbitem
)
1612 toolbar_item_t
*itm
= tbitem
;
1616 put_word(res
, itm
->id
);
1623 *****************************************************************************
1624 * Function : toolbar2res
1625 * Syntax : res_t *toolbar2res(name_id_t *name, toolbar_t *toolbar)
1627 * name - Name/ordinal of the resource
1628 * toolbar - The toolbar descriptor
1629 * Output : New .res format structure
1632 *****************************************************************************
1634 static res_t
*toolbar2res(name_id_t
*name
, toolbar_t
*toolbar
)
1638 assert(name
!= NULL
);
1639 assert(toolbar
!= NULL
);
1644 restag
= put_res_header(res
, WRC_RT_TOOLBAR
, NULL
, name
, toolbar
->memopt
, &(toolbar
->lvc
));
1646 put_word(res
, 1); /* Menuheader: Version */
1647 put_word(res
, toolbar
->button_width
); /* (in pixels?) */
1648 put_word(res
, toolbar
->button_height
); /* (in pixels?) */
1649 put_word(res
, toolbar
->nitems
);
1651 toolbaritem2res(res
, toolbar
->items
);
1652 /* Set ResourceSize */
1653 SetResSize(res
, restag
);
1658 /* Do not generate anything in 16-bit mode */
1667 *****************************************************************************
1668 * Function : dlginit2res
1669 * Syntax : res_t *dlginit2res(name_id_t *name, dlginit_t *dit)
1671 * name - Name/ordinal of the resource
1672 * rdt - The dlginit descriptor
1673 * Output : New .res format structure
1676 *****************************************************************************
1678 static res_t
*dlginit2res(name_id_t
*name
, dlginit_t
*dit
)
1682 assert(name
!= NULL
);
1683 assert(dit
!= NULL
);
1686 restag
= put_res_header(res
, WRC_RT_DLGINIT
, NULL
, name
, dit
->memopt
, &(dit
->data
->lvc
));
1687 put_raw_data(res
, dit
->data
, 0);
1688 /* Set ResourceSize */
1689 SetResSize(res
, restag
);
1696 *****************************************************************************
1697 * Function : prep_nid_for_label
1698 * Syntax : char *prep_nid_for_label(const name_id_t *nid)
1701 * Description : Converts a resource name into the first 32 (or less)
1702 * characters of the name with conversions.
1704 *****************************************************************************
1706 #define MAXNAMELEN 32
1707 char *prep_nid_for_label(const name_id_t
*nid
)
1709 static char buf
[MAXNAMELEN
+1];
1711 assert(nid
!= NULL
);
1713 if(nid
->type
== name_str
&& nid
->name
.s_name
->type
== str_unicode
)
1717 sptr
= nid
->name
.s_name
->str
.wstr
;
1719 for(i
= 0; *sptr
&& i
< MAXNAMELEN
; i
++)
1721 if((unsigned)*sptr
< 0x80 && isprint(*sptr
& 0xff))
1724 warning("Resourcename (str_unicode) contain unprintable characters or invalid translation, ignored\n");
1728 else if(nid
->type
== name_str
&& nid
->name
.s_name
->type
== str_char
)
1732 cptr
= nid
->name
.s_name
->str
.cstr
;
1734 for(i
= 0; *cptr
&& i
< MAXNAMELEN
; i
++)
1736 if((unsigned)*cptr
< 0x80 && isprint(*cptr
& 0xff))
1739 warning("Resourcename (str_char) contain unprintable characters, ignored\n");
1743 else if(nid
->type
== name_ord
)
1745 sprintf(buf
, "%u", nid
->name
.i_name
);
1749 internal_error(__FILE__
, __LINE__
, "Resource name_id with invalid type %d\n", nid
->type
);
1756 *****************************************************************************
1757 * Function : make_c_name
1758 * Syntax : char *make_c_name(const char *base, const name_id_t *nid, const language_t *lan)
1761 * Description : Converts a resource name into a valid c-identifier in the
1764 *****************************************************************************
1766 char *make_c_name(const char *base
, const name_id_t
*nid
, const language_t
*lan
)
1768 char *buf
= prep_nid_for_label(nid
);
1769 return strmake( "_%s_%s_%d", base
, buf
, lan
? MAKELANGID(lan
->id
, lan
->sub
) : 0);
1773 *****************************************************************************
1774 * Function : get_c_typename
1775 * Syntax : const char *get_c_typename(enum res_e type)
1778 * Description : Convert resource enum to char string to be used in c-name
1781 *****************************************************************************
1783 const char *get_c_typename(enum res_e type
)
1787 case res_acc
: return "Acc";
1788 case res_anicur
:return "AniCur";
1789 case res_aniico
:return "AniIco";
1790 case res_bmp
: return "Bmp";
1791 case res_cur
: return "Cur";
1792 case res_curg
: return "CurGrp";
1793 case res_dlg
: return "Dlg";
1794 case res_fnt
: return "Fnt";
1795 case res_fntdir
:return "FntDir";
1796 case res_ico
: return "Ico";
1797 case res_icog
: return "IcoGrp";
1798 case res_men
: return "Men";
1799 case res_rdt
: return "RCDat";
1800 case res_stt
: return "StrTab";
1801 case res_usr
: return "Usr";
1802 case res_msg
: return "MsgTab";
1803 case res_ver
: return "VerInf";
1804 case res_toolbar
: return "TlBr";
1805 case res_dlginit
: return "DlgInit";
1806 default: return "Oops";
1811 *****************************************************************************
1812 * Function : resources2res
1813 * Syntax : void resources2res(resource_t *top)
1815 * top - The resource-tree to convert
1817 * Description : Convert logical resource descriptors into binary data
1819 *****************************************************************************
1821 void resources2res(resource_t
*top
)
1829 top
->binres
= accelerator2res(top
->name
, top
->res
.acc
);
1833 top
->binres
= bitmap2res(top
->name
, top
->res
.bmp
);
1837 top
->binres
= cursor2res(top
->res
.cur
);
1841 top
->binres
= cursorgroup2res(top
->name
, top
->res
.curg
);
1845 top
->binres
= dialog2res(top
->name
, top
->res
.dlg
);
1849 top
->binres
= font2res(top
->name
, top
->res
.fnt
);
1853 top
->binres
= fontdir2res(top
->name
, top
->res
.fnd
);
1857 top
->binres
= icon2res(top
->res
.ico
);
1861 top
->binres
= icongroup2res(top
->name
, top
->res
.icog
);
1865 top
->binres
= menu2res(top
->name
, top
->res
.men
);
1869 top
->binres
= html2res(top
->name
, top
->res
.html
);
1873 top
->binres
= rcdata2res(top
->name
, top
->res
.rdt
);
1877 top
->binres
= stringtable2res(top
->res
.stt
);
1881 top
->binres
= user2res(top
->name
, top
->res
.usr
);
1885 top
->binres
= messagetable2res(top
->name
, top
->res
.msg
);
1889 top
->binres
= versioninfo2res(top
->name
, top
->res
.ver
);
1893 top
->binres
= toolbar2res(top
->name
, top
->res
.tbt
);
1897 top
->binres
= dlginit2res(top
->name
, top
->res
.dlgi
);
1902 top
->binres
= anicurico2res(top
->name
, top
->res
.ani
, top
->type
);
1905 internal_error(__FILE__
, __LINE__
, "Unknown resource type encountered %d in binary res generation\n", top
->type
);
1907 top
->c_name
= make_c_name(get_c_typename(top
->type
), top
->name
, top
->lan
);