public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* windres borland compatibility patch
@ 2004-09-07  0:32 Ryan Underwood
  2004-09-07  0:42 ` Ryan Underwood
  0 siblings, 1 reply; 6+ messages in thread
From: Ryan Underwood @ 2004-09-07  0:32 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 737 bytes --]


Hi,

I hacked up a little patch that parses the byte-blob format that Borland
resource files use.  With it, I was able to compile the resource file of
an application I am porting.  The form is like this:

ICON1 ICON
{
 'AE 09 08 64 ...

basically a string of hexadecimal bytes.  I saw it used in the icon,
cursor, and bitmap types, but it's possible that it is used in other
types.

All the patch does is parse this into an internal structure, and then
write out a temp file which is then passed to the other windres
functions like a normal filename was included.  This works fine for me,
but if anyone has a more elegant approach, I'm all ears.

applies against cvs.

-- 
Ryan Underwood, <nemesis@icequake.net>

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: windres borland compatibility patch
  2004-09-07  0:32 windres borland compatibility patch Ryan Underwood
@ 2004-09-07  0:42 ` Ryan Underwood
  2004-09-08  4:10   ` Ryan Underwood
  0 siblings, 1 reply; 6+ messages in thread
From: Ryan Underwood @ 2004-09-07  0:42 UTC (permalink / raw)
  To: binutils


[-- Attachment #1.1: Type: text/plain, Size: 806 bytes --]


> I hacked up a little patch that parses the byte-blob format that Borland
> resource files use.  With it, I was able to compile the resource file of
> an application I am porting.  The form is like this:
> 
> ICON1 ICON
> {
>  'AE 09 08 64 ...
> 
> basically a string of hexadecimal bytes.  I saw it used in the icon,
> cursor, and bitmap types, but it's possible that it is used in other
> types.
> 
> All the patch does is parse this into an internal structure, and then
> write out a temp file which is then passed to the other windres
> functions like a normal filename was included.  This works fine for me,
> but if anyone has a more elegant approach, I'm all ears.
> 
> applies against cvs.

Here's the patch for real this time.

-- 
Ryan Underwood, <nemesis@icequake.net>

[-- Attachment #1.2: windres.diff --]
[-- Type: text/plain, Size: 5149 bytes --]

Index: rclex.l
===================================================================
RCS file: /cvs/src/src/binutils/rclex.l,v
retrieving revision 1.10
diff -u -r1.10 rclex.l
--- rclex.l	14 Sep 2003 12:20:16 -0000	1.10
+++ rclex.l	7 Sep 2004 00:19:32 -0000
@@ -72,12 +72,16 @@
 
 %}
 
+%x QUOTE_STATE
+
 %%
 
 "BEGIN"			{ MAYBE_RETURN (BEG); }
 "{"			{ MAYBE_RETURN (BEG); }
 "END"			{ MAYBE_RETURN (END); }
 "}"			{ MAYBE_RETURN (END); }
+<QUOTE_STATE>"'"	{ BEGIN INITIAL; }
+"'"			{ BEGIN QUOTE_STATE; }
 "ACCELERATORS"		{ MAYBE_RETURN (ACCELERATORS); }
 "VIRTKEY"		{ MAYBE_RETURN (VIRTKEY); }
 "ASCII"			{ MAYBE_RETURN (ASCII); }
@@ -184,6 +188,12 @@
 			  cpp_line (yytext);
 			}
 
+<QUOTE_STATE>[0-9A-Fa-f]{2}/[[:space:]']	{
+			  yylval.i.val = strtoul (yytext, 0, 16);
+			  yylval.i.dword = 0;
+			  MAYBE_RETURN (BYTE);
+			}
+
 [0-9][x0-9A-Fa-f]*L	{
 			  yylval.i.val = strtoul (yytext, 0, 0);
 			  yylval.i.dword = 1;
@@ -229,8 +239,8 @@
 			  MAYBE_RETURN (STRING);
 			}
 
-[\n]			{ ++rc_lineno; }
-[ \t\r]+		{ /* ignore whitespace */ }
+<*>[\n]			{ ++rc_lineno; }
+<*>[ \t\r]+		{ /* ignore whitespace */ }
 .			{ MAYBE_RETURN (*yytext); }
 
 %%
Index: rcparse.y
===================================================================
RCS file: /cvs/src/src/binutils/rcparse.y,v
retrieving revision 1.19
diff -u -r1.19 rcparse.y
--- rcparse.y	14 Sep 2003 12:20:16 -0000	1.19
+++ rcparse.y	7 Sep 2004 00:19:33 -0000
@@ -58,6 +58,8 @@
    do not allow resource 'text' field in control definition. */
 static const struct res_id res_null_text = { 1, {{0, L""}}};
 
+int blob2file(struct bstring *blob, char *fname);
+
 %}
 
 %union
@@ -98,9 +100,11 @@
     unsigned long length;
     const char *s;
   } ss;
+  struct bstring bs;
+  unsigned char uc;
 };
 
-%token BEG END
+%token BEG END QUOTE
 %token ACCELERATORS VIRTKEY ASCII NOINVERT SHIFT CONTROL ALT
 %token BITMAP
 %token CURSOR
@@ -127,6 +131,7 @@
 %token <i> NUMBER
 %token <ss> SIZEDSTRING
 %token IGNORED_TOKEN
+%token <uc> BYTE
 
 %type <pacc> acc_entries
 %type <acc> acc_entry acc_event
@@ -146,6 +151,7 @@
 %type <is> acc_options acc_option menuitem_flags menuitem_flag
 %type <s> file_name resname
 %type <i> sizednumexpr sizedposnumexpr
+%type <bs> binary_blob
 
 %left '|'
 %left '^'
@@ -314,6 +320,38 @@
 	      YYERROR;
 	    rcparse_discard_strings ();
 	  }
+	| id BITMAP memflags_move BEG binary_blob END
+	  {
+	    char *fname;
+	    asprintf(&fname, ".temp.bmp");
+
+	    if (!blob2file(&$5, fname))
+	      YYERROR;
+
+	    define_bitmap ($1, &$3, fname);
+	    free($5.s);
+	    free(fname);
+	    unlink(".temp.bmp");
+	  }
+	;
+
+binary_blob:
+	  binary_blob BYTE 
+	  {
+	    if ($$.len == $$.alloc_len)
+	    {
+	      $$.s = xrealloc($$.s, $$.alloc_len + 256);
+	      $$.alloc_len += 256;
+	    }
+	    $$.s[$$.len++] = $2;
+	  }
+	| BYTE	
+	  {
+	    $$.s = (unsigned char *)xmalloc(256);
+	    $$.alloc_len = 256;
+	    $$.len = 0;
+	    $$.s[$$.len++] = $1;
+	  }
 	;
 
 /* Cursor resources.  */
@@ -326,6 +364,19 @@
 	      YYERROR;
 	    rcparse_discard_strings ();
 	  }
+	| id CURSOR memflags_move_discard BEG binary_blob END
+	  {
+	    char *fname;
+	    asprintf(&fname, ".temp.cur");
+
+	    if (!blob2file(&$5, fname))
+	      YYERROR;
+
+	    define_cursor ($1, &$3, fname);
+	    free($5.s);
+	    free(fname);
+	    unlink(".temp.cur");
+	  }
 	;
 
 /* Dialog resources.  */
@@ -959,6 +1010,19 @@
 	      YYERROR;
 	    rcparse_discard_strings ();
 	  }
+	| id ICON memflags_move_discard BEG binary_blob END
+	  {
+	    char *fname;
+	    asprintf(&fname, ".temp.ico");
+
+	    if (!blob2file(&$5, fname))
+	      YYERROR;
+
+	    define_icon ($1, &$3, fname);
+	    free($5.s);
+	    free(fname);
+	    unlink(".temp.ico");
+	  }
 	;
 
 /* Language command.  This changes the static variable language, which
@@ -1766,3 +1830,29 @@
 {
   language = lang;
 }
+
+int blob2file(struct bstring *blob, char *fname) {
+
+  FILE *newfile;
+  newfile = fopen(fname, "w+");
+
+  if (newfile == NULL)
+  {
+    printf("Couldn't create file %s for resource\n", fname);
+    return 0;
+  }
+  if (fwrite(blob->s, 1, blob->len, newfile) < blob->len)
+  {
+    printf("Couldn't write resource to file %s\n", fname);
+    return 0;
+  }
+  if (fclose(newfile) == -1)
+  {
+    printf("Couldn't close %s: %s\n", fname, strerror(errno));
+    return 0;
+  }
+
+  return 1;
+}
+
+
Index: windres.h
===================================================================
RCS file: /cvs/src/src/binutils/windres.h,v
retrieving revision 1.11
diff -u -r1.11 windres.h
--- windres.h	14 Sep 2003 12:20:17 -0000	1.11
+++ windres.h	7 Sep 2004 00:19:33 -0000
@@ -746,6 +746,16 @@
   unsigned char *data;
 };
 
+/* A structure to hold a binary blob as it is being parsed from the
+ * rc file. */
+
+struct bstring
+{
+  unsigned long len;
+  unsigned long alloc_len;
+  unsigned char *s;
+};
+
 extern int verbose;
 
 /* Function declarations.  */

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: windres borland compatibility patch
  2004-09-07  0:42 ` Ryan Underwood
@ 2004-09-08  4:10   ` Ryan Underwood
  2004-09-08 13:45     ` Ian Lance Taylor
  0 siblings, 1 reply; 6+ messages in thread
From: Ryan Underwood @ 2004-09-08  4:10 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 610 bytes --]


On Mon, Sep 06, 2004 at 07:42:41PM -0500, Ryan Underwood wrote:
> 
> > I hacked up a little patch that parses the byte-blob format that Borland
> > resource files use.  With it, I was able to compile the resource file of
> > an application I am porting.  The form is like this:

Here's a better patch.  I didn't realize I was using asprintf on a
constant string.  Originally I intended to derive the temporary file
name from the resource name, but then I realized the resource name was
in Unicode and I didn't know of a clean way to do a conversion.  Anyone
know?


-- 
Ryan Underwood, <nemesis@icequake.net>

[-- Attachment #2: windres.diff --]
[-- Type: text/plain, Size: 4779 bytes --]

Index: rclex.l
===================================================================
RCS file: /cvs/src/src/binutils/rclex.l,v
retrieving revision 1.10
diff -u -r1.10 rclex.l
--- rclex.l	14 Sep 2003 12:20:16 -0000	1.10
+++ rclex.l	8 Sep 2004 04:09:44 -0000
@@ -72,12 +72,16 @@
 
 %}
 
+%x QUOTE_STATE
+
 %%
 
 "BEGIN"			{ MAYBE_RETURN (BEG); }
 "{"			{ MAYBE_RETURN (BEG); }
 "END"			{ MAYBE_RETURN (END); }
 "}"			{ MAYBE_RETURN (END); }
+<QUOTE_STATE>"'"	{ BEGIN INITIAL; }
+"'"			{ BEGIN QUOTE_STATE; }
 "ACCELERATORS"		{ MAYBE_RETURN (ACCELERATORS); }
 "VIRTKEY"		{ MAYBE_RETURN (VIRTKEY); }
 "ASCII"			{ MAYBE_RETURN (ASCII); }
@@ -184,6 +188,12 @@
 			  cpp_line (yytext);
 			}
 
+<QUOTE_STATE>[0-9A-Fa-f]{2}/[[:space:]']	{
+			  yylval.i.val = strtoul (yytext, 0, 16);
+			  yylval.i.dword = 0;
+			  MAYBE_RETURN (BYTE);
+			}
+
 [0-9][x0-9A-Fa-f]*L	{
 			  yylval.i.val = strtoul (yytext, 0, 0);
 			  yylval.i.dword = 1;
@@ -229,8 +239,8 @@
 			  MAYBE_RETURN (STRING);
 			}
 
-[\n]			{ ++rc_lineno; }
-[ \t\r]+		{ /* ignore whitespace */ }
+<*>[\n]			{ ++rc_lineno; }
+<*>[ \t\r]+		{ /* ignore whitespace */ }
 .			{ MAYBE_RETURN (*yytext); }
 
 %%
Index: rcparse.y
===================================================================
RCS file: /cvs/src/src/binutils/rcparse.y,v
retrieving revision 1.19
diff -u -r1.19 rcparse.y
--- rcparse.y	14 Sep 2003 12:20:16 -0000	1.19
+++ rcparse.y	8 Sep 2004 04:09:45 -0000
@@ -58,6 +58,8 @@
    do not allow resource 'text' field in control definition. */
 static const struct res_id res_null_text = { 1, {{0, L""}}};
 
+int blob2file(struct bstring *blob, char *fname);
+
 %}
 
 %union
@@ -98,9 +100,11 @@
     unsigned long length;
     const char *s;
   } ss;
+  struct bstring bs;
+  unsigned char uc;
 };
 
-%token BEG END
+%token BEG END QUOTE
 %token ACCELERATORS VIRTKEY ASCII NOINVERT SHIFT CONTROL ALT
 %token BITMAP
 %token CURSOR
@@ -127,6 +131,7 @@
 %token <i> NUMBER
 %token <ss> SIZEDSTRING
 %token IGNORED_TOKEN
+%token <uc> BYTE
 
 %type <pacc> acc_entries
 %type <acc> acc_entry acc_event
@@ -146,6 +151,7 @@
 %type <is> acc_options acc_option menuitem_flags menuitem_flag
 %type <s> file_name resname
 %type <i> sizednumexpr sizedposnumexpr
+%type <bs> binary_blob
 
 %left '|'
 %left '^'
@@ -314,6 +320,36 @@
 	      YYERROR;
 	    rcparse_discard_strings ();
 	  }
+	| id BITMAP memflags_move BEG binary_blob END
+	  {
+	    char *fname = ".temp.bmp";
+
+	    if (!blob2file(&$5, fname))
+	      YYERROR;
+
+	    define_bitmap ($1, &$3, fname);
+	    free($5.s);
+	    unlink(fname);
+	  }
+	;
+
+binary_blob:
+	  binary_blob BYTE 
+	  {
+	    if ($$.len == $$.alloc_len)
+	    {
+	      $$.s = xrealloc($$.s, $$.alloc_len + 256);
+	      $$.alloc_len += 256;
+	    }
+	    $$.s[$$.len++] = $2;
+	  }
+	| BYTE	
+	  {
+	    $$.s = (unsigned char *)xmalloc(256);
+	    $$.alloc_len = 256;
+	    $$.len = 0;
+	    $$.s[$$.len++] = $1;
+	  }
 	;
 
 /* Cursor resources.  */
@@ -326,6 +362,17 @@
 	      YYERROR;
 	    rcparse_discard_strings ();
 	  }
+	| id CURSOR memflags_move_discard BEG binary_blob END
+	  {
+	    char *fname = ".temp.cur";
+
+	    if (!blob2file(&$5, fname))
+	      YYERROR;
+
+	    define_cursor ($1, &$3, fname);
+	    free($5.s);
+	    unlink(fname);
+	  }
 	;
 
 /* Dialog resources.  */
@@ -959,6 +1006,17 @@
 	      YYERROR;
 	    rcparse_discard_strings ();
 	  }
+	| id ICON memflags_move_discard BEG binary_blob END
+	  {
+	    char *fname = ".temp.ico";
+
+	    if (!blob2file(&$5, fname))
+	      YYERROR;
+
+	    define_icon ($1, &$3, fname);
+	    free($5.s);
+	    unlink(fname);
+	  }
 	;
 
 /* Language command.  This changes the static variable language, which
@@ -1766,3 +1824,29 @@
 {
   language = lang;
 }
+
+int blob2file(struct bstring *blob, char *fname) {
+
+  FILE *newfile;
+  newfile = fopen(fname, "w+");
+
+  if (newfile == NULL)
+  {
+    printf("Couldn't create file %s for resource\n", fname);
+    return 0;
+  }
+  if (fwrite(blob->s, 1, blob->len, newfile) < blob->len)
+  {
+    printf("Couldn't write resource to file %s\n", fname);
+    return 0;
+  }
+  if (fclose(newfile) == -1)
+  {
+    printf("Couldn't close %s: %s\n", fname, strerror(errno));
+    return 0;
+  }
+
+  return 1;
+}
+
+
Index: windres.h
===================================================================
RCS file: /cvs/src/src/binutils/windres.h,v
retrieving revision 1.11
diff -u -r1.11 windres.h
--- windres.h	14 Sep 2003 12:20:17 -0000	1.11
+++ windres.h	8 Sep 2004 04:09:45 -0000
@@ -746,6 +746,16 @@
   unsigned char *data;
 };
 
+/* A structure to hold a binary blob as it is being parsed from the
+ * rc file. */
+
+struct bstring
+{
+  unsigned long len;
+  unsigned long alloc_len;
+  unsigned char *s;
+};
+
 extern int verbose;
 
 /* Function declarations.  */

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: windres borland compatibility patch
  2004-09-08  4:10   ` Ryan Underwood
@ 2004-09-08 13:45     ` Ian Lance Taylor
  2004-09-08 21:24       ` Ryan Underwood
  0 siblings, 1 reply; 6+ messages in thread
From: Ian Lance Taylor @ 2004-09-08 13:45 UTC (permalink / raw)
  To: Ryan Underwood; +Cc: binutils

Ryan Underwood <nemesis-lists@icequake.net> writes:

> On Mon, Sep 06, 2004 at 07:42:41PM -0500, Ryan Underwood wrote:
> > 
> > > I hacked up a little patch that parses the byte-blob format that Borland
> > > resource files use.  With it, I was able to compile the resource file of
> > > an application I am porting.  The form is like this:
> 
> Here's a better patch.  I didn't realize I was using asprintf on a
> constant string.  Originally I intended to derive the temporary file
> name from the resource name, but then I realized the resource name was
> in Unicode and I didn't know of a clean way to do a conversion.  Anyone
> know?

It's probably better to use mkstemps for a temporary file name anyhow.

Ian

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: windres borland compatibility patch
  2004-09-08 13:45     ` Ian Lance Taylor
@ 2004-09-08 21:24       ` Ryan Underwood
  2004-09-13  0:50         ` Ryan Underwood
  0 siblings, 1 reply; 6+ messages in thread
From: Ryan Underwood @ 2004-09-08 21:24 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: binutils


[-- Attachment #1.1: Type: text/plain, Size: 142 bytes --]


> It's probably better to use mkstemps for a temporary file name anyhow.

How's this one?

-- 
Ryan Underwood, <nemesis@icequake.net>

[-- Attachment #1.2: windres.diff --]
[-- Type: text/plain, Size: 5162 bytes --]

Index: rclex.l
===================================================================
RCS file: /cvs/src/src/binutils/rclex.l,v
retrieving revision 1.10
diff -u -r1.10 rclex.l
--- rclex.l	14 Sep 2003 12:20:16 -0000	1.10
+++ rclex.l	8 Sep 2004 21:23:08 -0000
@@ -72,12 +72,16 @@
 
 %}
 
+%x QUOTE_STATE
+
 %%
 
 "BEGIN"			{ MAYBE_RETURN (BEG); }
 "{"			{ MAYBE_RETURN (BEG); }
 "END"			{ MAYBE_RETURN (END); }
 "}"			{ MAYBE_RETURN (END); }
+<QUOTE_STATE>"'"	{ BEGIN INITIAL; }
+"'"			{ BEGIN QUOTE_STATE; }
 "ACCELERATORS"		{ MAYBE_RETURN (ACCELERATORS); }
 "VIRTKEY"		{ MAYBE_RETURN (VIRTKEY); }
 "ASCII"			{ MAYBE_RETURN (ASCII); }
@@ -184,6 +188,12 @@
 			  cpp_line (yytext);
 			}
 
+<QUOTE_STATE>[0-9A-Fa-f]{2}/[[:space:]']	{
+			  yylval.i.val = strtoul (yytext, 0, 16);
+			  yylval.i.dword = 0;
+			  MAYBE_RETURN (BYTE);
+			}
+
 [0-9][x0-9A-Fa-f]*L	{
 			  yylval.i.val = strtoul (yytext, 0, 0);
 			  yylval.i.dword = 1;
@@ -229,8 +239,8 @@
 			  MAYBE_RETURN (STRING);
 			}
 
-[\n]			{ ++rc_lineno; }
-[ \t\r]+		{ /* ignore whitespace */ }
+<*>[\n]			{ ++rc_lineno; }
+<*>[ \t\r]+		{ /* ignore whitespace */ }
 .			{ MAYBE_RETURN (*yytext); }
 
 %%
Index: rcparse.y
===================================================================
RCS file: /cvs/src/src/binutils/rcparse.y,v
retrieving revision 1.19
diff -u -r1.19 rcparse.y
--- rcparse.y	14 Sep 2003 12:20:16 -0000	1.19
+++ rcparse.y	8 Sep 2004 21:23:08 -0000
@@ -58,6 +58,8 @@
    do not allow resource 'text' field in control definition. */
 static const struct res_id res_null_text = { 1, {{0, L""}}};
 
+int blob2file(struct bstring *blob, char *fname);
+
 %}
 
 %union
@@ -98,9 +100,11 @@
     unsigned long length;
     const char *s;
   } ss;
+  struct bstring bs;
+  unsigned char uc;
 };
 
-%token BEG END
+%token BEG END QUOTE
 %token ACCELERATORS VIRTKEY ASCII NOINVERT SHIFT CONTROL ALT
 %token BITMAP
 %token CURSOR
@@ -127,6 +131,7 @@
 %token <i> NUMBER
 %token <ss> SIZEDSTRING
 %token IGNORED_TOKEN
+%token <uc> BYTE
 
 %type <pacc> acc_entries
 %type <acc> acc_entry acc_event
@@ -146,6 +151,7 @@
 %type <is> acc_options acc_option menuitem_flags menuitem_flag
 %type <s> file_name resname
 %type <i> sizednumexpr sizedposnumexpr
+%type <bs> binary_blob
 
 %left '|'
 %left '^'
@@ -314,6 +320,36 @@
 	      YYERROR;
 	    rcparse_discard_strings ();
 	  }
+	| id BITMAP memflags_move BEG binary_blob END
+	  {
+	    char fname[] = "windres_bitmap_XXXXXX";
+
+	    if (!blob2file(&$5, fname))
+	      YYERROR;
+
+	    define_bitmap ($1, &$3, fname);
+	    free($5.s);
+	    unlink(fname);
+	  }
+	;
+
+binary_blob:
+	  binary_blob BYTE 
+	  {
+	    if ($$.len == $$.alloc_len)
+	    {
+	      $$.s = xrealloc($$.s, $$.alloc_len + 256);
+	      $$.alloc_len += 256;
+	    }
+	    $$.s[$$.len++] = $2;
+	  }
+	| BYTE	
+	  {
+	    $$.s = (unsigned char *)xmalloc(256);
+	    $$.alloc_len = 256;
+	    $$.len = 0;
+	    $$.s[$$.len++] = $1;
+	  }
 	;
 
 /* Cursor resources.  */
@@ -326,6 +362,17 @@
 	      YYERROR;
 	    rcparse_discard_strings ();
 	  }
+	| id CURSOR memflags_move_discard BEG binary_blob END
+	  {
+	    char fname[] = "windres_cur_XXXXXX";
+
+	    if (!blob2file(&$5, fname))
+	      YYERROR;
+
+	    define_cursor ($1, &$3, fname);
+	    free($5.s);
+	    unlink(fname);
+	  }
 	;
 
 /* Dialog resources.  */
@@ -959,6 +1006,17 @@
 	      YYERROR;
 	    rcparse_discard_strings ();
 	  }
+	| id ICON memflags_move_discard BEG binary_blob END
+	  {
+	    char fname[] = "windres_icon_XXXXXX";
+
+	    if (!blob2file(&$5, fname))
+	      YYERROR;
+
+	    define_icon ($1, &$3, fname);
+	    free($5.s);
+	    unlink(fname);
+	  }
 	;
 
 /* Language command.  This changes the static variable language, which
@@ -1766,3 +1824,35 @@
 {
   language = lang;
 }
+
+/* Turn a Borland-style resource binary blob into a temporary file. */
+
+int blob2file(struct bstring *blob, char *fname) {
+
+  int tmpfd;
+  int ret;
+
+  if ((tmpfd = mkstemp(fname)) == -1)
+  {
+    printf("Creating temporary file %s failed\n", fname);
+    return 0;
+  }
+
+  ret = write(tmpfd, blob->s, blob->len);
+
+  if ((ret < 0) || ((unsigned long)ret < blob->len))
+  {
+    printf("Couldn't write resource to file %s: %s\n", fname, strerror(errno));
+    return 0;
+  }
+
+  if (close(tmpfd) == -1)
+  {
+    printf("Couldn't close %s: %s\n", fname, strerror(errno));
+    return 0;
+  }
+
+  return 1;
+}
+
+
Index: windres.h
===================================================================
RCS file: /cvs/src/src/binutils/windres.h,v
retrieving revision 1.11
diff -u -r1.11 windres.h
--- windres.h	14 Sep 2003 12:20:17 -0000	1.11
+++ windres.h	8 Sep 2004 21:23:08 -0000
@@ -746,6 +746,16 @@
   unsigned char *data;
 };
 
+/* A structure to hold a binary blob as it is being parsed from the
+ * rc file. */
+
+struct bstring
+{
+  unsigned long len;
+  unsigned long alloc_len;
+  unsigned char *s;
+};
+
 extern int verbose;
 
 /* Function declarations.  */

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: windres borland compatibility patch
  2004-09-08 21:24       ` Ryan Underwood
@ 2004-09-13  0:50         ` Ryan Underwood
  0 siblings, 0 replies; 6+ messages in thread
From: Ryan Underwood @ 2004-09-13  0:50 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 269 bytes --]


So, is anyone interested in this patch?  It helped me compile a Borland
project without having to manually split out all the inline resources
into other files (and thus diverge from the original tree
unnecessarily).

-- 
Ryan Underwood, <nemesis@icequake.net>

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-09-13  0:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-07  0:32 windres borland compatibility patch Ryan Underwood
2004-09-07  0:42 ` Ryan Underwood
2004-09-08  4:10   ` Ryan Underwood
2004-09-08 13:45     ` Ian Lance Taylor
2004-09-08 21:24       ` Ryan Underwood
2004-09-13  0:50         ` Ryan Underwood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).