2005-10-05 Paolo Bonzini <bonzini@gnu.org>
[deliverable/binutils-gdb.git] / binutils / resrc.c
index 2613b396d5ec8c028e68a341b6be641f5b474d01..73b482cd04ab6ffe8210a68bbe0ae5845327b104 100644 (file)
@@ -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.
@@ -16,8 +17,8 @@
 
    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.  */
@@ -251,7 +252,7 @@ run_cmd (char *cmd, const char *redir)
   /* Restore stdout to its previous setting.  */
   dup2 (stdout_save, STDOUT_FILENO);
 
-  /* Close reponse file.  */
+  /* Close response file.  */
   close (redir_handle);
 
   if (pid == -1)
@@ -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);
@@ -1040,10 +1041,20 @@ define_icon (struct res_id id, const struct res_res_info *resinfo,
       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;
@@ -1239,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
@@ -1258,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);
This page took 0.027618 seconds and 4 git commands to generate.