summaryrefslogtreecommitdiff
path: root/binutils/resrc.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2005-01-17 16:24:12 +0000
committerNick Clifton <nickc@redhat.com>2005-01-17 16:24:12 +0000
commitafcc49547b768355bd30c75f0ef22140418a8a6e (patch)
treee67665ef20a942ff189141d266539026b95ac78f /binutils/resrc.c
parent262b7f836e8be0c72de86cb7a7b8fc069fd01de6 (diff)
downloadbinutils-redhat-afcc49547b768355bd30c75f0ef22140418a8a6e.tar.gz
PR binutils/647
* rcparse.y (RCDATA): Allow a filename to be supplied as the parameter. Parse it with define_rcdata_file(). * resrc.c (define_rcdata_file): New function. * windres.h: Provide a prototype for the new function. * resrc.c (define_user_file): Fix typo by replacing "font file" with "file".
Diffstat (limited to 'binutils/resrc.c')
-rw-r--r--binutils/resrc.c44
1 files changed, 39 insertions, 5 deletions
diff --git a/binutils/resrc.c b/binutils/resrc.c
index c290a9d0c0..296bd69dd1 100644
--- a/binutils/resrc.c
+++ b/binutils/resrc.c
@@ -1,5 +1,6 @@
/* resrc.c -- read and write Windows rc files.
- Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005
+ Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support.
This file is part of GNU Binutils.
@@ -857,7 +858,7 @@ define_font (struct res_id id, const struct res_res_info *resinfo,
e = open_file_search (filename, FOPEN_RB, "font file", &real_filename);
if (stat (real_filename, &s) < 0)
- fatal (_("stat failed on bitmap file `%s': %s"), real_filename,
+ fatal (_("stat failed on font file `%s': %s"), real_filename,
strerror (errno));
data = (unsigned char *) res_alloc (s.st_size);
@@ -1249,12 +1250,45 @@ define_user_data (struct res_id id, struct res_id type,
ids[2].named = 0;
ids[2].u.id = resinfo->language;
- r = define_resource (&resources, 3, ids, 0);
+ r = define_resource (& resources, 3, ids, 0);
r->type = RES_TYPE_USERDATA;
r->u.userdata = data;
r->res_info = *resinfo;
}
+void
+define_rcdata_file (struct res_id id, const struct res_res_info *resinfo,
+ const char *filename)
+{
+ struct rcdata_item *ri;
+ FILE *e;
+ char *real_filename;
+ struct stat s;
+ unsigned char *data;
+
+ e = open_file_search (filename, FOPEN_RB, "file", &real_filename);
+
+
+ if (stat (real_filename, &s) < 0)
+ fatal (_("stat failed on file `%s': %s"), real_filename,
+ strerror (errno));
+
+ data = (unsigned char *) res_alloc (s.st_size);
+
+ get_data (e, data, s.st_size, real_filename);
+
+ fclose (e);
+ free (real_filename);
+
+ ri = (struct rcdata_item *) res_alloc (sizeof *ri);
+ ri->next = NULL;
+ ri->type = RCDATA_BUFFER;
+ ri->u.buffer.length = s.st_size;
+ ri->u.buffer.data = data;
+
+ define_rcdata (id, resinfo, ri);
+}
+
/* Define a user data resource where the data is in a file. */
void
@@ -1268,10 +1302,10 @@ define_user_file (struct res_id id, struct res_id type,
struct res_id ids[3];
struct res_resource *r;
- e = open_file_search (filename, FOPEN_RB, "font file", &real_filename);
+ e = open_file_search (filename, FOPEN_RB, "file", &real_filename);
if (stat (real_filename, &s) < 0)
- fatal (_("stat failed on bitmap file `%s': %s"), real_filename,
+ fatal (_("stat failed on file `%s': %s"), real_filename,
strerror (errno));
data = (unsigned char *) res_alloc (s.st_size);