From 52788d1f1c74eb8faad9ff22bdccb982fc578507 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 30 Jun 2005 20:58:52 +0000 Subject: [PATCH] Added support for HTML resource type. --- tools/wrc/genres.c | 33 +++++++++++++++++++++++++++++++++ tools/wrc/newstruc.c | 14 ++++++++++++++ tools/wrc/newstruc.h | 2 +- tools/wrc/parser.l | 1 + tools/wrc/parser.y | 14 ++++++++++++-- tools/wrc/wrctypes.h | 6 ++++++ 6 files changed, 67 insertions(+), 3 deletions(-) diff --git a/tools/wrc/genres.c b/tools/wrc/genres.c index 620134c4455..722baea9369 100644 --- a/tools/wrc/genres.c +++ b/tools/wrc/genres.c @@ -1339,6 +1339,35 @@ static res_t *fontdir2res(name_id_t *name, fontdir_t *fnd) return res; } +/* + ***************************************************************************** + * Function : html2res + * Syntax : res_t *html2res(name_id_t *name, html_t *html) + * Input : + * name - Name/ordinal of the resource + * rdt - The html descriptor + * Output : New .res format structure + * Description : + * Remarks : + ***************************************************************************** +*/ +static res_t *html2res(name_id_t *name, html_t *html) +{ + int restag; + res_t *res; + assert(name != NULL); + assert(html != NULL); + + res = new_res(); + restag = put_res_header(res, WRC_RT_HTML, NULL, name, html->memopt, &(html->data->lvc)); + put_raw_data(res, html->data, 0); + /* Set ResourceSize */ + SetResSize(res, restag); + if(win32) + put_pad(res); + return res; +} + /* ***************************************************************************** * Function : rcdata2res @@ -1932,6 +1961,10 @@ void resources2res(resource_t *top) if(!top->binres) top->binres = menuex2res(top->name, top->res.menex); break; + case res_html: + if(!top->binres) + top->binres = html2res(top->name, top->res.html); + break; case res_rdt: if(!top->binres) top->binres = rcdata2res(top->name, top->res.rdt); diff --git a/tools/wrc/newstruc.c b/tools/wrc/newstruc.c index 46d0a6ce3e4..9129caa181a 100644 --- a/tools/wrc/newstruc.c +++ b/tools/wrc/newstruc.c @@ -123,6 +123,20 @@ characts_t *dup_characts(characts_t *c) return new_characts(*c); } +html_t *new_html(raw_data_t *rd, int *memopt) +{ + html_t *html = xmalloc(sizeof(html_t)); + html->data = rd; + if(memopt) + { + html->memopt = *memopt; + free(memopt); + } + else + html->memopt = WRC_MO_MOVEABLE | WRC_MO_PURE; + return html; +} + rcdata_t *new_rcdata(raw_data_t *rd, int *memopt) { rcdata_t *rc = (rcdata_t *)xmalloc(sizeof(rcdata_t)); diff --git a/tools/wrc/newstruc.h b/tools/wrc/newstruc.h index a0a624ddf3a..8f061ef2dbf 100644 --- a/tools/wrc/newstruc.h +++ b/tools/wrc/newstruc.h @@ -61,6 +61,7 @@ language_t *new_language(int id, int sub); language_t *dup_language(language_t *l); version_t *dup_version(version_t *v); characts_t *dup_characts(characts_t *c); +html_t *new_html(raw_data_t *rd, int *memopt); rcdata_t *new_rcdata(raw_data_t *rd, int *memopt); font_id_t *new_font_id(int size, string_t *face, int weight, int italic); user_t *new_user(name_id_t *type, raw_data_t *rd, int *memopt); @@ -82,4 +83,3 @@ style_pair_t *new_style_pair(style_t *style, style_t *exstyle); style_t *new_style(DWORD or_mask, DWORD and_mask); #endif - diff --git a/tools/wrc/parser.l b/tools/wrc/parser.l index 58487a750c5..9983d107cea 100644 --- a/tools/wrc/parser.l +++ b/tools/wrc/parser.l @@ -204,6 +204,7 @@ static struct keyword keywords[] = { { "GRAYED", tGRAYED, 0, 0, 0}, { "GROUPBOX", tGROUPBOX, 0, 0, 0}, { "HELP", tHELP, 0, 0, 0}, + { "HTML", tHTML, 0, 0, 0}, { "ICON", tICON, 0, 0, 0}, { "IMPURE", tIMPURE, 0, 0, 0}, { "INACTIVE", tINACTIVE, 0, 0, 0}, diff --git a/tools/wrc/parser.y b/tools/wrc/parser.y index b444540215c..e31869c8937 100644 --- a/tools/wrc/parser.y +++ b/tools/wrc/parser.y @@ -251,6 +251,7 @@ static int rsrcid_to_token(int lookahead); fontdir_t *fnd; menu_t *men; menuex_t *menex; + html_t *html; rcdata_t *rdt; stringtable_t *stt; stt_entry_t *stte; @@ -285,7 +286,7 @@ static int rsrcid_to_token(int lookahead); %token tSTRING tIDENT tFILENAME %token tRAWDATA %token tACCELERATORS tBITMAP tCURSOR tDIALOG tDIALOGEX tMENU tMENUEX tMESSAGETABLE -%token tRCDATA tVERSIONINFO tSTRINGTABLE tFONT tFONTDIR tICON +%token tRCDATA tVERSIONINFO tSTRINGTABLE tFONT tFONTDIR tICON tHTML %token tAUTO3STATE tAUTOCHECKBOX tAUTORADIOBUTTON tCHECKBOX tDEFPUSHBUTTON %token tPUSHBUTTON tRADIOBUTTON tSTATE3 /* PUSHBOX */ %token tGROUPBOX tCOMBOBOX tLISTBOX tSCROLLBAR @@ -323,6 +324,7 @@ static int rsrcid_to_token(int lookahead); %type helpid %type dialogex dlgex_attribs %type exctrls gen_exctrl lab_exctrl exctrl_desc +%type html %type rcdata %type raw_data raw_elements opt_data file_raw %type versioninfo fix_version @@ -644,6 +646,7 @@ resource_definition $$ = NULL; } | messagetable { $$ = new_resource(res_msg, $1, WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE, $1->data->lvc.language); } + | html { $$ = new_resource(res_html, $1, $1->memopt, $1->data->lvc.language); } | rcdata { $$ = new_resource(res_rdt, $1, $1->memopt, $1->data->lvc.language); } | toolbar { $$ = new_resource(res_toolbar, $1, $1->memopt, $1->lvc.language); } | userres { $$ = new_resource(res_usr, $1, $1->memopt, $1->data->lvc.language); } @@ -724,6 +727,10 @@ messagetable } ; +/* ------------------------------ HTML ------------------------------ */ +html : tHTML loadmemopts file_raw { $$ = new_html($3, $2); } + ; + /* ------------------------------ RCData ------------------------------ */ rcdata : tRCDATA loadmemopts file_raw { $$ = new_rcdata($3, $2); } ; @@ -3008,6 +3015,10 @@ static int rsrcid_to_token(int lookahead) type = "TOOLBAR"; token = tTOOLBAR; break; + case WRC_RT_HTML: + type = "HTML"; + token = tHTML; + break; case WRC_RT_STRING: type = "STRINGTABLE"; @@ -3023,7 +3034,6 @@ static int rsrcid_to_token(int lookahead) case WRC_RT_DLGINCLUDE: case WRC_RT_PLUGPLAY: case WRC_RT_VXD: - case WRC_RT_HTML: yywarning("Usertype uses reserved type ID %d, which is not supported by wrc yet", yylval.num); default: return lookahead; diff --git a/tools/wrc/wrctypes.h b/tools/wrc/wrctypes.h index eb5e907b7fb..f81e79367f4 100644 --- a/tools/wrc/wrctypes.h +++ b/tools/wrc/wrctypes.h @@ -441,6 +441,11 @@ typedef struct bitmap { raw_data_t *data; } bitmap_t; +typedef struct html { + DWORD memopt; + raw_data_t *data; +} html_t; + typedef struct rcdata { DWORD memopt; raw_data_t *data; @@ -615,6 +620,7 @@ typedef struct resource { menu_t *men; menuex_t *menex; messagetable_t *msg; + html_t *html; rcdata_t *rdt; stringtable_t *stt; toolbar_t *tbt;