Alexandre Julliard : wrc: Move write_resfile() into genres.c and remove writeres.c.
Alexandre Julliard
julliard at winehq.org
Fri Dec 10 15:07:51 CST 2021
Module: wine
Branch: master
Commit: 952d849e488bfc7be622ebb697df14b63e90f4ed
URL: https://source.winehq.org/git/wine.git/?a=commit;h=952d849e488bfc7be622ebb697df14b63e90f4ed
Author: Alexandre Julliard <julliard at winehq.org>
Date: Fri Dec 10 12:16:41 2021 +0100
wrc: Move write_resfile() into genres.c and remove writeres.c.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
tools/wrc/Makefile.in | 3 +-
tools/wrc/genres.c | 88 ++++++++++++++++++++++++++++++++++++++----
tools/wrc/genres.h | 33 ----------------
tools/wrc/po.c | 1 -
tools/wrc/wrc.c | 4 --
tools/wrc/writeres.c | 103 --------------------------------------------------
6 files changed, 82 insertions(+), 150 deletions(-)
diff --git a/tools/wrc/Makefile.in b/tools/wrc/Makefile.in
index 140240962e4..29529a2d71e 100644
--- a/tools/wrc/Makefile.in
+++ b/tools/wrc/Makefile.in
@@ -9,8 +9,7 @@ C_SRCS = \
translation.c \
utils.c \
wpp.c \
- wrc.c \
- writeres.c
+ wrc.c
LEX_SRCS = \
parser.l \
diff --git a/tools/wrc/genres.c b/tools/wrc/genres.c
index 4ce0821a730..ba848084ac9 100644
--- a/tools/wrc/genres.c
+++ b/tools/wrc/genres.c
@@ -36,14 +36,13 @@
#include "../tools.h"
#include "wrc.h"
-#include "genres.h"
#include "utils.h"
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
-res_t *new_res(void)
+static res_t *new_res(void)
{
res_t *r;
r = xmalloc(sizeof(res_t));
@@ -54,7 +53,7 @@ res_t *new_res(void)
return r;
}
-res_t *grow_res(res_t *r, unsigned int add)
+static res_t *grow_res(res_t *r, unsigned int add)
{
r->allocsize += add;
r->data = xrealloc(r->data, r->allocsize);
@@ -78,7 +77,7 @@ res_t *grow_res(res_t *r, unsigned int add)
* Remarks :
*****************************************************************************
*/
-void put_byte(res_t *res, unsigned c)
+static void put_byte(res_t *res, unsigned c)
{
if(res->allocsize - res->size < sizeof(char))
grow_res(res, RES_BLOCKSIZE);
@@ -86,7 +85,7 @@ void put_byte(res_t *res, unsigned c)
res->size += sizeof(char);
}
-void put_word(res_t *res, unsigned w)
+static void put_word(res_t *res, unsigned w)
{
if(res->allocsize - res->size < sizeof(WORD))
grow_res(res, RES_BLOCKSIZE);
@@ -95,7 +94,7 @@ void put_word(res_t *res, unsigned w)
res->size += sizeof(WORD);
}
-void put_dword(res_t *res, unsigned d)
+static void put_dword(res_t *res, unsigned d)
{
if(res->allocsize - res->size < sizeof(DWORD))
grow_res(res, RES_BLOCKSIZE);
@@ -1487,7 +1486,7 @@ static res_t *dlginit2res(name_id_t *name, dlginit_t *dit)
* Remarks :
*****************************************************************************
*/
-void resources2res(resource_t *top)
+static void resources2res(resource_t *top)
{
while(top)
{
@@ -1576,3 +1575,78 @@ void resources2res(resource_t *top)
top = top->next;
}
}
+
+/*
+ *****************************************************************************
+ * Function : write_resfile
+ * Syntax : void write_resfile(char *outname, resource_t *top)
+ * Input :
+ * outname - Filename to write to
+ * top - The resource-tree to convert
+ * Output :
+ * Description :
+ * Remarks :
+ *****************************************************************************
+*/
+void write_resfile(char *outname, resource_t *top)
+{
+ FILE *fo;
+ unsigned int ret;
+ char zeros[3] = {0, 0, 0};
+
+ /* Convert the internal lists to binary data */
+ resources2res(resource_top);
+
+ fo = fopen(outname, "wb");
+ if(!fo)
+ fatal_perror("Could not open %s", outname);
+
+ if(win32)
+ {
+ /* Put an empty resource first to signal win32 format */
+ res_t *res = new_res();
+ put_dword(res, 0); /* ResSize */
+ put_dword(res, 0x00000020); /* HeaderSize */
+ put_word(res, 0xffff); /* ResType */
+ put_word(res, 0);
+ put_word(res, 0xffff); /* ResName */
+ put_word(res, 0);
+ put_dword(res, 0); /* DataVersion */
+ put_word(res, 0); /* Memory options */
+ put_word(res, 0); /* Language */
+ put_dword(res, 0); /* Version */
+ put_dword(res, 0); /* Characteristics */
+ ret = fwrite(res->data, 1, res->size, fo);
+ if(ret != res->size)
+ {
+ fclose(fo);
+ error("Error writing %s\n", outname);
+ }
+ free(res);
+ }
+
+ for(; top; top = top->next)
+ {
+ if(!top->binres)
+ continue;
+
+ ret = fwrite(top->binres->data, 1, top->binres->size, fo);
+ if(ret != top->binres->size)
+ {
+ fclose(fo);
+ error("Error writing %s\n", outname);
+ }
+ if(win32 && (top->binres->size & 0x03))
+ {
+ /* Write padding */
+ ret = fwrite(zeros, 1, 4 - (top->binres->size & 0x03), fo);
+ if(ret != 4 - (top->binres->size & 0x03))
+ {
+ fclose(fo);
+ error("Error writing %s\n", outname);
+ }
+ }
+ }
+ if (fclose(fo))
+ fatal_perror("Error writing %s", outname);
+}
diff --git a/tools/wrc/genres.h b/tools/wrc/genres.h
deleted file mode 100644
index de24f8d1ff0..00000000000
--- a/tools/wrc/genres.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Generate resource prototypes
- *
- * Copyright 1998 Bertho A. Stultiens (BS)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#ifndef __WRC_GENRES_H
-#define __WRC_GENRES_H
-
-#include "wrctypes.h"
-
-res_t *new_res(void);
-res_t *grow_res(res_t *r, unsigned int add);
-void put_byte(res_t *res, unsigned c);
-void put_word(res_t *res, unsigned w);
-void put_dword(res_t *res, unsigned d);
-void resources2res(resource_t *top);
-
-#endif
diff --git a/tools/wrc/po.c b/tools/wrc/po.c
index 520c7de266b..42e06f93c10 100644
--- a/tools/wrc/po.c
+++ b/tools/wrc/po.c
@@ -32,7 +32,6 @@
#include "../tools.h"
#include "wrc.h"
-#include "genres.h"
#include "newstruc.h"
#include "utils.h"
#include "windef.h"
diff --git a/tools/wrc/wrc.c b/tools/wrc/wrc.c
index ca9361c3017..41207120237 100644
--- a/tools/wrc/wrc.c
+++ b/tools/wrc/wrc.c
@@ -37,7 +37,6 @@
#include "wrc.h"
#include "utils.h"
#include "dumpres.h"
-#include "genres.h"
#include "newstruc.h"
#include "parser.h"
#include "wpp_private.h"
@@ -528,9 +527,6 @@ int main(int argc,char *argv[])
}
if (win32) add_translations( po_dir );
- /* Convert the internal lists to binary data */
- resources2res(resource_top);
-
chat("Writing .res-file\n");
if (!output_name)
{
diff --git a/tools/wrc/writeres.c b/tools/wrc/writeres.c
deleted file mode 100644
index 7a75cb1e0d6..00000000000
--- a/tools/wrc/writeres.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Write .res file from a resource-tree
- *
- * Copyright 1998 Bertho A. Stultiens
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-#include "wrc.h"
-#include "genres.h"
-#include "newstruc.h"
-#include "utils.h"
-
-/*
- *****************************************************************************
- * Function : write_resfile
- * Syntax : void write_resfile(char *outname, resource_t *top)
- * Input :
- * outname - Filename to write to
- * top - The resource-tree to convert
- * Output :
- * Description :
- * Remarks :
- *****************************************************************************
-*/
-void write_resfile(char *outname, resource_t *top)
-{
- FILE *fo;
- unsigned int ret;
- char zeros[3] = {0, 0, 0};
-
- fo = fopen(outname, "wb");
- if(!fo)
- fatal_perror("Could not open %s", outname);
-
- if(win32)
- {
- /* Put an empty resource first to signal win32 format */
- res_t *res = new_res();
- put_dword(res, 0); /* ResSize */
- put_dword(res, 0x00000020); /* HeaderSize */
- put_word(res, 0xffff); /* ResType */
- put_word(res, 0);
- put_word(res, 0xffff); /* ResName */
- put_word(res, 0);
- put_dword(res, 0); /* DataVersion */
- put_word(res, 0); /* Memory options */
- put_word(res, 0); /* Language */
- put_dword(res, 0); /* Version */
- put_dword(res, 0); /* Characteristics */
- ret = fwrite(res->data, 1, res->size, fo);
- if(ret != res->size)
- {
- fclose(fo);
- error("Error writing %s\n", outname);
- }
- free(res);
- }
-
- for(; top; top = top->next)
- {
- if(!top->binres)
- continue;
-
- ret = fwrite(top->binres->data, 1, top->binres->size, fo);
- if(ret != top->binres->size)
- {
- fclose(fo);
- error("Error writing %s\n", outname);
- }
- if(win32 && (top->binres->size & 0x03))
- {
- /* Write padding */
- ret = fwrite(zeros, 1, 4 - (top->binres->size & 0x03), fo);
- if(ret != 4 - (top->binres->size & 0x03))
- {
- fclose(fo);
- error("Error writing %s\n", outname);
- }
- }
- }
- if (fclose(fo))
- fatal_perror("Error writing %s", outname);
-}
More information about the wine-cvs
mailing list