/* 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
+ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+ 02110-1301, USA. */
/* This file contains functions that read and write Windows rc files.
These are text files that represent resources. */
/* Restore stdout to its previous setting. */
dup2 (stdout_save, STDOUT_FILENO);
- /* Close reponse file. */
+ /* Close response file. */
close (redir_handle);
if (pid == -1)
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);
cg->height = icondirs[i].height;
cg->colors = icondirs[i].colorcount;
- cg->planes = 1;
- cg->bits = 0;
- while ((1 << cg->bits) < cg->colors)
- ++cg->bits;
+ if (icondirs[i].u.icon.planes)
+ cg->planes = icondirs[i].u.icon.planes;
+ else
+ cg->planes = 1;
+
+ if (icondirs[i].u.icon.bits)
+ cg->bits = icondirs[i].u.icon.bits;
+ else
+ {
+ cg->bits = 0;
+
+ while ((1L << cg->bits) < cg->colors)
+ ++cg->bits;
+ }
cg->bytes = icondirs[i].bytes;
cg->index = first_icon + i + 1;
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
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);