First stab at Windows resource compiler:

* windres.h: New file.
	* windres.c: New file.
	* resrc.c: New file.
	* rcparse.y: New file.
	* rclex.l: New file.
	* configure.in: Define and substitute BUILD_WINDRES.
	* configure: Rebuild.
	* Makefile.in: Rebuild dependencies.
 	(WINDRES_PROG): New variable.
	(PROGS): Add @BUILD_WINDRES@.
	(HFILES): Add dlltool.h and windres.h.
	(CFILES): Add windres.c and resrc.c.
	(GENERATED_CFILES): Add rcparse.c and rclex.c.
	(WINDRES_OBJS): New variable.
	$(WINDRES_PROG): New target.
	(rcparse.c, rcparse.h, rclex.c): New targets.
Snapshot.  windres can parse and print rc files.
This commit is contained in:
Ian Lance Taylor 1997-06-22 21:35:35 +00:00
parent 677a92a07d
commit 1d371d35ee
10 changed files with 5953 additions and 85 deletions

View File

@ -82,6 +82,9 @@ objdump.c
prdbg.c
ranlib.1
ranlib.sh
rclex.l
rcparse.y
resrc.c
rdcoff.c
rddbg.c
sanity.sh
@ -98,6 +101,8 @@ syslex.l
sysroff.info
testsuite
version.c
windres.h
windres.c
wrstabs.c
Things-to-lose:

View File

@ -1,3 +1,23 @@
Sun Jun 22 17:29:41 1997 Ian Lance Taylor <ian@cygnus.com>
First stab at Windows resource compiler:
* windres.h: New file.
* windres.c: New file.
* resrc.c: New file.
* rcparse.y: New file.
* rclex.l: New file.
* configure.in: Define and substitute BUILD_WINDRES.
* configure: Rebuild.
* Makefile.in: Rebuild dependencies.
(WINDRES_PROG): New variable.
(PROGS): Add @BUILD_WINDRES@.
(HFILES): Add dlltool.h and windres.h.
(CFILES): Add windres.c and resrc.c.
(GENERATED_CFILES): Add rcparse.c and rclex.c.
(WINDRES_OBJS): New variable.
$(WINDRES_PROG): New target.
(rcparse.c, rcparse.h, rclex.c): New targets.
Thu Jun 12 12:27:51 1997 Ian Lance Taylor <ian@cygnus.com>
* dlltool.c (export_type): Add data field.

View File

@ -103,12 +103,13 @@ ADDR2LINE_PROG=addr2line
NLMCONV_PROG=nlmconv
DLLTOOL_PROG=dlltool
WINDRES_PROG=windres
SRCONV_PROG=srconv sysdump coffdump
MANPAGES= ar nm objdump ranlib size strings strip objcopy addr2line nlmconv
PROGS = $(SIZE_PROG) $(OBJDUMP_PROG) $(NM_PROG) $(AR_PROG) $(STRINGS_PROG) $(STRIP_PROG) $(RANLIB_PROG) $(DEMANGLER_PROG) $(OBJCOPY_PROG) $(ADDR2LINE_PROG) @BUILD_NLMCONV@ @BUILD_SRCONV@ @BUILD_DLLTOOL@
PROGS = $(SIZE_PROG) $(OBJDUMP_PROG) $(NM_PROG) $(AR_PROG) $(STRINGS_PROG) $(STRIP_PROG) $(RANLIB_PROG) $(DEMANGLER_PROG) $(OBJCOPY_PROG) $(ADDR2LINE_PROG) @BUILD_NLMCONV@ @BUILD_SRCONV@ @BUILD_DLLTOOL@ @BUILD_WINDRES@
STAGESTUFF = $(PROGS) *.o
# Files that can be generated, but should be in the distribution.
# Don't build $(DEMANGLER_PROG).1, since its name may vary with the
@ -127,7 +128,8 @@ DEP = mkdep
ALL_CFLAGS = -D_GNU_SOURCE $(INCLUDES) @HDEFINES@ $(CFLAGS)
HFILES = arsup.h bucomm.h budbg.h coffgrok.h debug.h nlmconv.h
HFILES = arsup.h bucomm.h budbg.h coffgrok.h debug.h nlmconv.h dlltool.h \
windres.h
GENERATED_HFILES = arparse.h sysroff.h sysinfo.h defparse.h
@ -135,11 +137,12 @@ CFILES = addr2line.c ar.c arsup.c bucomm.c coffdump.c coffgrok.c debug.c \
dlltool.c filemode.c ieee.c is-ranlib.c is-strip.c maybe-ranlib.c \
maybe-strip.c nlmconv.c nm.c not-ranlib.c not-strip.c \
objcopy.c objdump.c prdbg.c rdcoff.c rddbg.c size.c srconv.c \
stabs.c strings.c sysdump.c version.c wrstabs.c
stabs.c strings.c sysdump.c version.c wrstabs.c \
windres.c resrc.c
GENERATED_CFILES = \
underscore.c arparse.c arlex.c sysroff.c sysinfo.c syslex.c \
defparse.c deflex.c nlmheader.c
defparse.c deflex.c nlmheader.c rcparse.c rclex.c
.c.o:
$(CC) -c $(ALL_CFLAGS) $<
@ -235,7 +238,7 @@ check: site.exp
TCL_LIBRARY=$${srcroot}/../tcl/library ; \
export TCL_LIBRARY ; else true; fi ; \
$(RUNTEST) --tool binutils --srcdir $(srcdir)/testsuite \
$(RUNTESTFLAGS) CC="$(CC_FOR_TARGET)" CFLAGS="$(CFLAGS)"
$(RUNTESTFLAGS) CC_FOR_TARGET="$(CC_FOR_TARGET)" CFLAGS_FOR_TARGET="$(CFLAGS)"
installcheck:
/bin/sh $(srcdir)/sanity.sh $(bindir)
@ -406,6 +409,26 @@ nlmconv.o: nlmconv.c $(INCDIR)/coff/sym.h $(INCDIR)/coff/ecoff.h
$(NLMCONV_PROG): nlmconv.o nlmheader.o $(ADDL_DEPS)
$(HLDENV) $(CC) $(HLDFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ nlmconv.o nlmheader.o $(ADDL_LIBS) $(EXTRALIBS)
WINDRES_OBJS = windres.o resrc.o rcparse.o rclex.o
$(WINDRES_PROG): $(WINDRES_OBJS) $(ADDL_DEPS)
$(HLDENV) $(CC) $(HLDFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(WINDRES_OBJS) $(ADDL_LIBS) $(EXTRALIBS)
# Depend upon defparse.c to avoid building both defparse.c and
# rcparse.c simultaneously.
rcparse.c: rcparse.y defparse.c
$(BISON) $(BISONFLAGS) $(srcdir)/rcparse.y
mv -f y.tab.c rcparse.c
mv -f y.tab.h rcparse.h
rcparse.h: rcparse.c
# Depend upon deflex.c to avoid building both deflex.c and rclex.c
# simultaneously.
rclex.c: rclex.l deflex.c
$(LEX) $(LEX_OPTIONS) $(srcdir)/rclex.l
mv lex.yy.c rclex.c
# Targets to rebuild dependencies in this Makefile.
# Have to get rid of .dep1 here so that "$?" later includes all of $(CFILES).
.dep: dep.sed $(CFILES) $(HFILES) $(GENERATED_CFILES) $(GENERATED_HFILES) config.h
@ -533,7 +556,7 @@ distclean:
maintainer-clean realclean: clean distclean
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
-rm -f $(DISTSTUFF) *.info* TAGS
-rm -f $(DISTSTUFF) binutils.info* TAGS
etags tags: TAGS
@ -680,7 +703,7 @@ debug.o: debug.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
debug.h
dlltool.o: dlltool.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
$(INCDIR)/libiberty.h bucomm.h config.h $(INCDIR)/fopen-same.h \
$(INCDIR)/getopt.h $(INCDIR)/demangle.h
$(INCDIR)/getopt.h $(INCDIR)/demangle.h dlltool.h
filemode.o: filemode.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
bucomm.h config.h $(INCDIR)/fopen-same.h
ieee.o: ieee.c ../bfd/bfd.h $(INCDIR)/ansidecl.h $(INCDIR)/ieee.h \
@ -737,6 +760,12 @@ wrstabs.o: wrstabs.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
bucomm.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/libiberty.h \
debug.h budbg.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
$(INCDIR)/aout/stab.def
windres.o: windres.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
$(INCDIR)/getopt.h bucomm.h config.h $(INCDIR)/fopen-same.h \
$(INCDIR)/libiberty.h windres.h
resrc.o: resrc.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
bucomm.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/libiberty.h \
windres.h
underscore.o: underscore.c
arparse.o: arparse.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
bucomm.h config.h $(INCDIR)/fopen-same.h arsup.h
@ -744,10 +773,18 @@ arlex.o: arlex.c $(INCDIR)/libiberty.h arparse.h
sysroff.o: sysroff.c
sysinfo.o: sysinfo.c
syslex.o: syslex.c sysinfo.h
defparse.o: defparse.c
deflex.o: deflex.c defparse.h
defparse.o: defparse.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
bucomm.h config.h $(INCDIR)/fopen-same.h dlltool.h
deflex.o: deflex.c $(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h \
defparse.h dlltool.h
nlmheader.o: nlmheader.c ../bfd/bfd.h bucomm.h config.h \
$(INCDIR)/fopen-same.h $(INCDIR)/nlm/common.h $(INCDIR)/nlm/internal.h \
nlmconv.h
rcparse.o: rcparse.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
bucomm.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/libiberty.h \
windres.h
rclex.o: rclex.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
bucomm.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/libiberty.h \
windres.h rcparse.h
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY

157
binutils/configure vendored
View File

@ -1006,8 +1006,13 @@ esac
if test "${commonbfdlib}" = "true"; then
# when a shared libbfd is built with --enable-commonbfdlib,
# all of libopcodes is available in libbfd.so
OPCODES=
# all of libopcodes is available in libbfd.so. Unfortunately, on
# HP/UX, when using gcc -g, the linker does a static link, so we
# need to continue linking against opcodes on that platform.
case "${host}" in
*-*-hpux*) ;;
*) OPCODES= ;;
esac
fi
@ -1024,7 +1029,7 @@ fi
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
echo "configure:1028: checking how to run the C preprocessor" >&5
echo "configure:1033: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@ -1039,13 +1044,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
#line 1043 "configure"
#line 1048 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1049: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1054: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
:
@ -1056,13 +1061,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
#line 1060 "configure"
#line 1065 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1066: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1071: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
:
@ -1088,17 +1093,17 @@ for ac_hdr in string.h strings.h stdlib.h unistd.h fcntl.h sys/file.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:1092: checking for $ac_hdr" >&5
echo "configure:1097: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1097 "configure"
#line 1102 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1102: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1107: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
@ -1125,12 +1130,12 @@ fi
done
echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
echo "configure:1129: checking for sys/wait.h that is POSIX.1 compatible" >&5
echo "configure:1134: checking for sys/wait.h that is POSIX.1 compatible" >&5
if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1134 "configure"
#line 1139 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/wait.h>
@ -1146,7 +1151,7 @@ wait (&s);
s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
; return 0; }
EOF
if { (eval echo configure:1150: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:1155: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_header_sys_wait_h=yes
else
@ -1169,19 +1174,19 @@ fi
# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
# for constant arguments. Useless!
echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
echo "configure:1173: checking for working alloca.h" >&5
echo "configure:1178: checking for working alloca.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1178 "configure"
#line 1183 "configure"
#include "confdefs.h"
#include <alloca.h>
int main() {
char *p = alloca(2 * sizeof(int));
; return 0; }
EOF
if { (eval echo configure:1185: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
if { (eval echo configure:1190: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
ac_cv_header_alloca_h=yes
else
@ -1202,12 +1207,12 @@ EOF
fi
echo $ac_n "checking for alloca""... $ac_c" 1>&6
echo "configure:1206: checking for alloca" >&5
echo "configure:1211: checking for alloca" >&5
if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1211 "configure"
#line 1216 "configure"
#include "confdefs.h"
#ifdef __GNUC__
@ -1230,7 +1235,7 @@ int main() {
char *p = (char *) alloca(1);
; return 0; }
EOF
if { (eval echo configure:1234: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
if { (eval echo configure:1239: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
ac_cv_func_alloca_works=yes
else
@ -1262,12 +1267,12 @@ EOF
echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
echo "configure:1266: checking whether alloca needs Cray hooks" >&5
echo "configure:1271: checking whether alloca needs Cray hooks" >&5
if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1271 "configure"
#line 1276 "configure"
#include "confdefs.h"
#if defined(CRAY) && ! defined(CRAY2)
webecray
@ -1292,12 +1297,12 @@ echo "$ac_t""$ac_cv_os_cray" 1>&6
if test $ac_cv_os_cray = yes; then
for ac_func in _getb67 GETB67 getb67; do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:1296: checking for $ac_func" >&5
echo "configure:1301: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1301 "configure"
#line 1306 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -1320,7 +1325,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:1324: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
if { (eval echo configure:1329: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@ -1347,7 +1352,7 @@ done
fi
echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
echo "configure:1351: checking stack direction for C alloca" >&5
echo "configure:1356: checking stack direction for C alloca" >&5
if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1355,7 +1360,7 @@ else
ac_cv_c_stack_direction=0
else
cat > conftest.$ac_ext <<EOF
#line 1359 "configure"
#line 1364 "configure"
#include "confdefs.h"
find_stack_direction ()
{
@ -1374,7 +1379,7 @@ main ()
exit (find_stack_direction() < 0);
}
EOF
if { (eval echo configure:1378: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
if { (eval echo configure:1383: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_c_stack_direction=1
else
@ -1398,12 +1403,12 @@ fi
for ac_func in sbrk utimes
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:1402: checking for $ac_func" >&5
echo "configure:1407: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1407 "configure"
#line 1412 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -1426,7 +1431,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:1430: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
if { (eval echo configure:1435: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@ -1452,12 +1457,12 @@ done
if test "x$cross_compiling" = "xno"; then
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
echo "configure:1456: checking for ANSI C header files" >&5
echo "configure:1461: checking for ANSI C header files" >&5
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1461 "configure"
#line 1466 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
@ -1465,7 +1470,7 @@ else
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1469: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1474: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
@ -1482,7 +1487,7 @@ rm -f conftest*
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
#line 1486 "configure"
#line 1491 "configure"
#include "confdefs.h"
#include <string.h>
EOF
@ -1500,7 +1505,7 @@ fi
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
#line 1504 "configure"
#line 1509 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
@ -1521,7 +1526,7 @@ if test "$cross_compiling" = yes; then
:
else
cat > conftest.$ac_ext <<EOF
#line 1525 "configure"
#line 1530 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@ -1532,7 +1537,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
exit (0); }
EOF
if { (eval echo configure:1536: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
if { (eval echo configure:1541: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
:
else
@ -1556,12 +1561,12 @@ EOF
fi
echo $ac_n "checking for pid_t""... $ac_c" 1>&6
echo "configure:1560: checking for pid_t" >&5
echo "configure:1565: checking for pid_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1565 "configure"
#line 1570 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@ -1590,17 +1595,17 @@ fi
ac_safe=`echo "vfork.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for vfork.h""... $ac_c" 1>&6
echo "configure:1594: checking for vfork.h" >&5
echo "configure:1599: checking for vfork.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1599 "configure"
#line 1604 "configure"
#include "confdefs.h"
#include <vfork.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1604: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1609: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
@ -1625,18 +1630,18 @@ else
fi
echo $ac_n "checking for working vfork""... $ac_c" 1>&6
echo "configure:1629: checking for working vfork" >&5
echo "configure:1634: checking for working vfork" >&5
if eval "test \"`echo '$''{'ac_cv_func_vfork_works'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test "$cross_compiling" = yes; then
echo $ac_n "checking for vfork""... $ac_c" 1>&6
echo "configure:1635: checking for vfork" >&5
echo "configure:1640: checking for vfork" >&5
if eval "test \"`echo '$''{'ac_cv_func_vfork'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1640 "configure"
#line 1645 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char vfork(); below. */
@ -1659,7 +1664,7 @@ vfork();
; return 0; }
EOF
if { (eval echo configure:1663: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
if { (eval echo configure:1668: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_vfork=yes"
else
@ -1680,7 +1685,7 @@ fi
else
cat > conftest.$ac_ext <<EOF
#line 1684 "configure"
#line 1689 "configure"
#include "confdefs.h"
/* Thanks to Paul Eggert for this test. */
#include <stdio.h>
@ -1775,7 +1780,7 @@ main() {
}
}
EOF
if { (eval echo configure:1779: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
if { (eval echo configure:1784: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_func_vfork_works=yes
else
@ -1799,12 +1804,12 @@ fi
else
echo $ac_n "checking for vfork""... $ac_c" 1>&6
echo "configure:1803: checking for vfork" >&5
echo "configure:1808: checking for vfork" >&5
if eval "test \"`echo '$''{'ac_cv_func_vfork'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1808 "configure"
#line 1813 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char vfork(); below. */
@ -1827,7 +1832,7 @@ vfork();
; return 0; }
EOF
if { (eval echo configure:1831: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
if { (eval echo configure:1836: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_vfork=yes"
else
@ -1853,19 +1858,19 @@ fi
fi
echo $ac_n "checking for time_t in time.h""... $ac_c" 1>&6
echo "configure:1857: checking for time_t in time.h" >&5
echo "configure:1862: checking for time_t in time.h" >&5
if eval "test \"`echo '$''{'bu_cv_decl_time_t_time_h'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1862 "configure"
#line 1867 "configure"
#include "confdefs.h"
#include <time.h>
int main() {
time_t i;
; return 0; }
EOF
if { (eval echo configure:1869: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:1874: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bu_cv_decl_time_t_time_h=yes
else
@ -1886,19 +1891,19 @@ EOF
fi
echo $ac_n "checking for time_t in sys/types.h""... $ac_c" 1>&6
echo "configure:1890: checking for time_t in sys/types.h" >&5
echo "configure:1895: checking for time_t in sys/types.h" >&5
if eval "test \"`echo '$''{'bu_cv_decl_time_t_types_h'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1895 "configure"
#line 1900 "configure"
#include "confdefs.h"
#include <sys/types.h>
int main() {
time_t i;
; return 0; }
EOF
if { (eval echo configure:1902: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:1907: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bu_cv_decl_time_t_types_h=yes
else
@ -1921,12 +1926,12 @@ fi
# Under Next 3.2 <utime.h> apparently does not define struct utimbuf
# by default.
echo $ac_n "checking for utime.h""... $ac_c" 1>&6
echo "configure:1925: checking for utime.h" >&5
echo "configure:1930: checking for utime.h" >&5
if eval "test \"`echo '$''{'bu_cv_header_utime_h'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1930 "configure"
#line 1935 "configure"
#include "confdefs.h"
#include <sys/types.h>
#ifdef HAVE_TIME_H
@ -1937,7 +1942,7 @@ int main() {
struct utimbuf s;
; return 0; }
EOF
if { (eval echo configure:1941: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:1946: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bu_cv_header_utime_h=yes
else
@ -1958,12 +1963,12 @@ EOF
fi
echo $ac_n "checking whether fprintf must be declared""... $ac_c" 1>&6
echo "configure:1962: checking whether fprintf must be declared" >&5
echo "configure:1967: checking whether fprintf must be declared" >&5
if eval "test \"`echo '$''{'bfd_cv_decl_needed_fprintf'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1967 "configure"
#line 1972 "configure"
#include "confdefs.h"
#include <stdio.h>
@ -1984,7 +1989,7 @@ int main() {
char *(*pfn) = (char *(*)) fprintf
; return 0; }
EOF
if { (eval echo configure:1988: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:1993: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bfd_cv_decl_needed_fprintf=no
else
@ -2006,12 +2011,12 @@ EOF
fi
echo $ac_n "checking whether strstr must be declared""... $ac_c" 1>&6
echo "configure:2010: checking whether strstr must be declared" >&5
echo "configure:2015: checking whether strstr must be declared" >&5
if eval "test \"`echo '$''{'bfd_cv_decl_needed_strstr'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2015 "configure"
#line 2020 "configure"
#include "confdefs.h"
#include <stdio.h>
@ -2032,7 +2037,7 @@ int main() {
char *(*pfn) = (char *(*)) strstr
; return 0; }
EOF
if { (eval echo configure:2036: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2041: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bfd_cv_decl_needed_strstr=no
else
@ -2054,12 +2059,12 @@ EOF
fi
echo $ac_n "checking whether sbrk must be declared""... $ac_c" 1>&6
echo "configure:2058: checking whether sbrk must be declared" >&5
echo "configure:2063: checking whether sbrk must be declared" >&5
if eval "test \"`echo '$''{'bfd_cv_decl_needed_sbrk'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2063 "configure"
#line 2068 "configure"
#include "confdefs.h"
#include <stdio.h>
@ -2080,7 +2085,7 @@ int main() {
char *(*pfn) = (char *(*)) sbrk
; return 0; }
EOF
if { (eval echo configure:2084: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2089: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bfd_cv_decl_needed_sbrk=no
else
@ -2102,12 +2107,12 @@ EOF
fi
echo $ac_n "checking whether getenv must be declared""... $ac_c" 1>&6
echo "configure:2106: checking whether getenv must be declared" >&5
echo "configure:2111: checking whether getenv must be declared" >&5
if eval "test \"`echo '$''{'bfd_cv_decl_needed_getenv'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2111 "configure"
#line 2116 "configure"
#include "confdefs.h"
#include <stdio.h>
@ -2128,7 +2133,7 @@ int main() {
char *(*pfn) = (char *(*)) getenv
; return 0; }
EOF
if { (eval echo configure:2132: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2137: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bfd_cv_decl_needed_getenv=no
else
@ -2165,7 +2170,7 @@ esac
if test -n "$enable_targets"; then
for targ in `echo $enable_targets | sed 's/,/ /g'`
do
result=`$ac_config_sub $targ 2>/dev/null`
result=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $targ 2>/dev/null`
if test -n "$result"; then
canon_targets="$canon_targets $result"
else
@ -2181,6 +2186,7 @@ NLMCONV_DEFS=
BUILD_SRCONV=
BUILD_DLLTOOL=
DLLTOOL_DEFS=
BUILD_WINDRES=
for targ in $target $canon_targets
do
@ -2215,14 +2221,17 @@ do
arm-*pe*)
BUILD_DLLTOOL='$(DLLTOOL_PROG)'
DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_ARM"
BUILD_WINDRES='$(WINDRES_PROG)'
;;
i[3-6]86-*pe* | i[3-6]86-*-cygwin32)
BUILD_DLLTOOL='$(DLLTOOL_PROG)'
DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_I386"
BUILD_WINDRES='$(WINDRES_PROG)'
;;
powerpc*-*-*pe* | powerpc*-*-cygwin32)
BUILD_DLLTOOL='$(DLLTOOL_PROG)'
DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_PPC"
BUILD_WINDRES='$(WINDRES_PROG)'
;;
esac
fi
@ -2234,6 +2243,7 @@ done
targ=$target
. $srcdir/../bfd/config.bfd
if test "x$targ_underscore" = "xyes"; then
@ -2408,6 +2418,7 @@ s%@BUILD_NLMCONV@%$BUILD_NLMCONV%g
s%@BUILD_SRCONV@%$BUILD_SRCONV%g
s%@BUILD_DLLTOOL@%$BUILD_DLLTOOL%g
s%@DLLTOOL_DEFS@%$DLLTOOL_DEFS%g
s%@BUILD_WINDRES@%$BUILD_WINDRES%g
s%@UNDERSCORE@%$UNDERSCORE%g
CEOF

View File

@ -98,8 +98,13 @@ esac
if test "${commonbfdlib}" = "true"; then
# when a shared libbfd is built with --enable-commonbfdlib,
# all of libopcodes is available in libbfd.so
OPCODES=
# all of libopcodes is available in libbfd.so. Unfortunately, on
# HP/UX, when using gcc -g, the linker does a static link, so we
# need to continue linking against opcodes on that platform.
case "${host}" in
*-*-hpux*) ;;
*) OPCODES= ;;
esac
fi
AC_SUBST(BFDLIB)
@ -166,7 +171,7 @@ BFD_BINARY_FOPEN
if test -n "$enable_targets"; then
for targ in `echo $enable_targets | sed 's/,/ /g'`
do
result=`$ac_config_sub $targ 2>/dev/null`
result=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $targ 2>/dev/null`
if test -n "$result"; then
canon_targets="$canon_targets $result"
else
@ -182,6 +187,7 @@ NLMCONV_DEFS=
BUILD_SRCONV=
BUILD_DLLTOOL=
DLLTOOL_DEFS=
BUILD_WINDRES=
for targ in $target $canon_targets
do
@ -218,16 +224,19 @@ changequote([,])dnl
arm-*pe*)
BUILD_DLLTOOL='$(DLLTOOL_PROG)'
DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_ARM"
BUILD_WINDRES='$(WINDRES_PROG)'
;;
changequote(,)dnl
i[3-6]86-*pe* | i[3-6]86-*-cygwin32)
changequote([,])dnl
BUILD_DLLTOOL='$(DLLTOOL_PROG)'
DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_I386"
BUILD_WINDRES='$(WINDRES_PROG)'
;;
powerpc*-*-*pe* | powerpc*-*-cygwin32)
BUILD_DLLTOOL='$(DLLTOOL_PROG)'
DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_PPC"
BUILD_WINDRES='$(WINDRES_PROG)'
;;
esac
fi
@ -238,6 +247,7 @@ AC_SUBST(BUILD_NLMCONV)
AC_SUBST(BUILD_SRCONV)
AC_SUBST(BUILD_DLLTOOL)
AC_SUBST(DLLTOOL_DEFS)
AC_SUBST(BUILD_WINDRES)
targ=$target
. $srcdir/../bfd/config.bfd

320
binutils/rclex.l Normal file
View File

@ -0,0 +1,320 @@
%{ /* rclex.l -- lexer for Windows rc files parser */
/* Copyright 1997 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support.
This file is part of GNU Binutils.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
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. */
/* This is a lex input file which generates a lexer used by the
Windows rc file parser. It basically just recognized a bunch of
keywords. */
#include "bfd.h"
#include "bucomm.h"
#include "libiberty.h"
#include "windres.h"
#include "rcparse.h"
#include <ctype.h>
#include <assert.h>
static void cpp_line PARAMS ((const char *));
static char *handle_quotes PARAMS ((const char *));
%}
%%
"BEGIN" { return BEG; }
"END" { return END; }
"ACCELERATORS" { return ACCELERATORS; }
"VIRTKEY" { return VIRTKEY; }
"ASCII" { return ASCII; }
"NOINVERT" { return NOINVERT; }
"SHIFT" { return SHIFT; }
"CONTROL" { return CONTROL; }
"ALT" { return ALT; }
"BITMAP" { return BITMAP; }
"CURSOR" { return CURSOR; }
"DIALOG" { return DIALOG; }
"DIALOGEX" { return DIALOGEX; }
"EXSTYLE" { return EXSTYLE; }
"CAPTION" { return CAPTION; }
"CLASS" { return CLASS; }
"STYLE" { return STYLE; }
"AUTO3STATE" { return AUTO3STATE; }
"AUTOCHECKBOX" { return AUTOCHECKBOX; }
"AUTORADIOBUTTON" { return AUTORADIOBUTTON; }
"CHECKBOX" { return CHECKBOX; }
"COMBOBOX" { return COMBOBOX; }
"CTEXT" { return CTEXT; }
"DEFPUSHBUTTON" { return DEFPUSHBUTTON; }
"EDITTEXT" { return EDITTEXT; }
"GROUPBOX" { return GROUPBOX; }
"LISTBOX" { return LISTBOX; }
"LTEXT" { return LTEXT; }
"PUSHBOX" { return PUSHBOX; }
"PUSHBUTTON" { return PUSHBUTTON; }
"RADIOBUTTON" { return RADIOBUTTON; }
"RTEXT" { return RTEXT; }
"SCROLLBAR" { return SCROLLBAR; }
"STATE3" { return STATE3; }
"USERBUTTON" { return USERBUTTON; }
"BEDIT" { return BEDIT; }
"HEDIT" { return HEDIT; }
"IEDIT" { return IEDIT; }
"FONT" { return FONT; }
"ICON" { return ICON; }
"LANGUAGE" { return LANGUAGE; }
"CHARACTERISTICS" { return CHARACTERISTICS; }
"VERSION" { return VERSION; }
"MENU" { return MENU; }
"MENUEX" { return MENUEX; }
"MENUITEM" { return MENUITEM; }
"SEPARATOR" { return SEPARATOR; }
"POPUP" { return POPUP; }
"CHECKED" { return CHECKED; }
"GRAYED" { return GRAYED; }
"HELP" { return HELP; }
"INACTIVE" { return INACTIVE; }
"MENUBARBREAK" { return MENUBARBREAK; }
"MENUBREAK" { return MENUBREAK; }
"MESSAGETABLE" { return MESSAGETABLE; }
"RCDATA" { return RCDATA; }
"STRINGTABLE" { return STRINGTABLE; }
"VERSIONINFO" { return VERSIONINFO; }
"FILEVERSION" { return FILEVERSION; }
"PRODUCTVERSION" { return PRODUCTVERSION; }
"FILEFLAGSMASK" { return FILEFLAGSMASK; }
"FILEFLAGS" { return FILEFLAGS; }
"FILEOS" { return FILEOS; }
"FILETYPE" { return FILETYPE; }
"FILESUBTYPE" { return FILESUBTYPE; }
"VALUE" { return VALUE; }
"MOVEABLE" { return MOVEABLE; }
"FIXED" { return FIXED; }
"PURE" { return PURE; }
"IMPURE" { return IMPURE; }
"PRELOAD" { return PRELOAD; }
"LOADONCALL" { return LOADONCALL; }
"DISCARDABLE" { return DISCARDABLE; }
"NOT" { return NOT; }
"BLOCK"[ \t\n]*"\""[^\#\n]*"\"" {
char *s, *send;
/* This is a hack to let us parse version
information easily. */
s = strchr (yytext, '"');
++s;
send = strchr (s, '"');
if (strncmp (s, "StringFileInfo",
sizeof "StringFileInfo" - 1) == 0
&& s + sizeof "StringFileInfo" - 1 == send)
return BLOCKSTRINGFILEINFO;
else if (strncmp (s, "VarFileInfo",
sizeof "VarFileInfo" - 1) == 0
&& s + sizeof "VarFileInfo" - 1 == send)
return BLOCKVARFILEINFO;
else
{
yylval.s = (char *) xmalloc (send - s + 1);
strncpy (yylval.s, s, send - s);
yylval.s[send - s] = '\0';
return BLOCK;
}
}
"#"[^\n]* {
cpp_line (yytext);
}
[0-9][x0-9A-Fa-f]*L {
yylval.i.val = strtoul (yytext, 0, 0);
yylval.i.dword = 1;
return NUMBER;
}
[0-9][x0-9A-Fa-f]* {
yylval.i.val = strtoul (yytext, 0, 0);
yylval.i.dword = 0;
return NUMBER;
}
("\""[^\"\n]*"\""[ \t]*)+ {
yylval.s = handle_quotes (yytext);
return QUOTEDSTRING;
}
[A-Za-z][^ \t\r\n]* {
yylval.s = xstrdup (yytext);
return STRING;
}
[\n] { ++rc_lineno; }
[ \t\r]+ { /* ignore whitespace */ }
. { return *yytext; }
%%
#ifndef yywrap
/* This is needed for some versions of lex. */
int yywrap ()
{
return 1;
}
#endif
/* Handle a C preprocessor line. */
static void
cpp_line (s)
const char *s;
{
int line;
char *send, *fn;
++s;
while (isspace (*s))
++s;
line = strtol (s, &send, 0);
if (*send != '\0' && ! isspace (*send))
return;
/* Subtract 1 because we are about to count the newline. */
rc_lineno = line - 1;
s = send;
while (isspace (*s))
++s;
if (*s != '"')
return;
++s;
send = strchr (s, '"');
if (send == NULL)
return;
fn = (char *) xmalloc (send - s + 1);
strncpy (fn, s, send - s);
fn[send - s] = '\0';
free (rc_filename);
rc_filename = fn;
}
/* Handle a quoted string. The quotes are stripped. A pair of quotes
in a string are turned into a single quote. Adjacent strings are
merged separated by whitespace are merged, as in C. */
static char *
handle_quotes (input)
const char *input;
{
char *ret, *s;
const char *t;
int ch;
ret = (char *) xmalloc (strlen (input) + 1);
s = ret;
t = input;
if (*t == '"')
++t;
while (*t != '\0')
{
if (*t == '\\')
{
++t;
switch (*t)
{
case '\0':
rcparse_warning ("backslash at end of string");
break;
case '\"':
rcparse_warning ("use \"\" to put \" in a string");
break;
case '\\':
*s++ = *t++;
break;
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
ch = *t - '0';
++t;
if (*t >= '0' && *t <= '7')
{
ch = (ch << 3) | (*t - '0');
++t;
if (*t >= '0' && *t <= '7')
{
ch = (ch << 3) | (*t - '0');
++t;
}
}
*s++ = ch;
break;
case 'x':
++t;
ch = 0;
while (1)
{
if (*t >= '0' && *t <= '9')
ch = (ch << 4) | (*t - '0');
else if (*t >= 'a' && *t <= 'f')
ch = (ch << 4) | (*t - 'a');
else if (*t >= 'A' && *t <= 'F')
ch = (ch << 4) | (*t - 'A');
else
break;
++t;
}
*s++ = ch;
break;
}
}
else if (*t != '"')
*s++ = *t++;
else if (t[1] == '\0')
break;
else if (t[1] == '"')
{
*s++ = '"';
t += 2;
}
else
{
++t;
assert (isspace (*t));
while (isspace (*t))
++t;
if (*t == '\0')
break;
assert (*t == '"');
++t;
}
}
*s = '\0';
return ret;
}

1513
binutils/rcparse.y Normal file

File diff suppressed because it is too large Load Diff

2220
binutils/resrc.c Normal file

File diff suppressed because it is too large Load Diff

912
binutils/windres.c Normal file
View File

@ -0,0 +1,912 @@
/* windres.c -- a program to manipulate Windows resources
Copyright 1997 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support.
This file is part of GNU Binutils.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
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. */
/* This program can read and write Windows resources in various
formats. In particular, it can act like the rc resource compiler
program, and it can act like the cvtres res to COFF conversion
program.
It is based on information taken from the following sources:
* Microsoft documentation.
* The rcl program, written by Gunther Ebert
<gunther.ebert@ixos-leipzig.de>.
* The res2coff program, written by Pedro A. Aranda <paag@tid.es>.
*/
#include "bfd.h"
#include "getopt.h"
#include "bucomm.h"
#include "libiberty.h"
#include "windres.h"
#include <assert.h>
#include <ctype.h>
/* An enumeration of format types. */
enum res_format
{
/* Unknown format. */
RES_FORMAT_UNKNOWN,
/* Textual RC file. */
RES_FORMAT_RC,
/* Binary RES file. */
RES_FORMAT_RES,
/* COFF file. */
RES_FORMAT_COFF
};
/* A structure used to map between format types and strings. */
struct format_map
{
const char *name;
enum res_format format;
};
/* A mapping between names and format types. */
static const struct format_map format_names[] =
{
{ "rc", RES_FORMAT_RC },
{ "res", RES_FORMAT_RES },
{ "coff", RES_FORMAT_COFF },
{ NULL, RES_FORMAT_UNKNOWN }
};
/* A mapping from file extensions to format types. */
static const struct format_map format_fileexts[] =
{
{ "rc", RES_FORMAT_RC },
{ "res", RES_FORMAT_RES },
{ "exe", RES_FORMAT_COFF },
{ "obj", RES_FORMAT_COFF },
{ "o", RES_FORMAT_COFF },
{ NULL, RES_FORMAT_UNKNOWN }
};
/* A list of include directories. */
struct include_dir
{
struct include_dir *next;
char *dir;
};
static struct include_dir *include_dirs;
/* Long options. */
/* 150 isn't special; it's just an arbitrary non-ASCII char value. */
#define OPTION_DEFINE 150
#define OPTION_HELP (OPTION_DEFINE + 1)
#define OPTION_INCLUDE_DIR (OPTION_HELP + 1)
#define OPTION_LANGUAGE (OPTION_INCLUDE_DIR + 1)
#define OPTION_PREPROCESSOR (OPTION_LANGUAGE + 1)
#define OPTION_VERSION (OPTION_PREPROCESSOR + 1)
#define OPTION_YYDEBUG (OPTION_VERSION + 1)
static const struct option long_options[] =
{
{"define", required_argument, 0, OPTION_DEFINE},
{"help", no_argument, 0, OPTION_HELP},
{"include-dir", required_argument, 0, OPTION_INCLUDE_DIR},
{"input-format", required_argument, 0, 'I'},
{"language", required_argument, 0, OPTION_LANGUAGE},
{"output-format", required_argument, 0, 'O'},
{"preprocessor", required_argument, 0, OPTION_PREPROCESSOR},
{"target", required_argument, 0, 'F'},
{"version", no_argument, 0, OPTION_VERSION},
{"yydebug", no_argument, 0, OPTION_YYDEBUG},
{0, no_argument, 0, 0}
};
/* Static functions. */
static enum res_format format_from_name PARAMS ((const char *));
static enum res_format format_from_filename PARAMS ((const char *, int));
static void usage PARAMS ((FILE *, int));
/* Open a file using the include directory search list. */
FILE *
open_file_search (filename, mode, errmsg, real_filename)
const char *filename;
const char *mode;
const char *errmsg;
char **real_filename;
{
FILE *e;
struct include_dir *d;
e = fopen (filename, mode);
if (e != NULL)
{
*real_filename = xstrdup (filename);
return e;
}
if (errno == ENOENT)
{
for (d = include_dirs; d != NULL; d = d->next)
{
char *n;
n = (char *) xmalloc (strlen (d->dir) + strlen (filename) + 2);
sprintf (n, "%s/%s", d->dir, filename);
e = fopen (n, mode);
if (e != NULL)
{
*real_filename = n;
return e;
}
if (errno != ENOENT)
break;
}
}
fatal ("can't open %s `%s': %s", errmsg, filename, strerror (errno));
/* Return a value to avoid a compiler warning. */
return NULL;
}
/* Unicode support. */
/* Convert an ASCII string to a unicode string. We just copy it,
expanding chars to shorts, rather than doing something intelligent. */
void
unicode_from_ascii (length, unicode, ascii)
unsigned short *length;
unsigned short **unicode;
const char *ascii;
{
int len;
const char *s;
unsigned short *w;
len = strlen (ascii);
if (length != NULL)
{
if (len > 0xffff)
fatal ("string too long (%d chars > 0xffff)", len);
*length = len;
}
*unicode = (unsigned short *) xmalloc ((len + 1) * sizeof (unsigned short));
for (s = ascii, w = *unicode; *s != '\0'; s++, w++)
*w = *s & 0xff;
*w = 0;
}
/* Print the unicode string UNICODE to the file E. LENGTH is the
number of characters to print, or -1 if we should print until the
end of the string. */
void
unicode_print (e, unicode, length)
FILE *e;
const unsigned short *unicode;
int length;
{
while (1)
{
unsigned short ch;
if (length == 0)
return;
if (length > 0)
--length;
ch = *unicode;
if (ch == 0)
return;
++unicode;
if ((ch & 0x7f) == ch && isprint (ch))
putc (ch, e);
else if ((ch & 0xff) == ch)
fprintf (e, "\\%03o", (unsigned int) ch);
else
fprintf (e, "\\x%x", (unsigned int) ch);
}
}
/* Compare two resource ID's. We consider name entries to come before
numeric entries, because that is how they appear in the COFF .rsrc
section. */
int
res_id_cmp (a, b)
struct res_id a;
struct res_id b;
{
if (! a.named)
{
if (b.named)
return 1;
if (a.u.id > b.u.id)
return 1;
else if (a.u.id < b.u.id)
return -1;
else
return 0;
}
else
{
unsigned short *as, *ase, *bs, *bse;
if (! b.named)
return -1;
as = a.u.n.name;
ase = as + a.u.n.length;
bs = b.u.n.name;
bse = bs + b.u.n.length;
while (as < ase)
{
int i;
if (bs >= bse)
return 1;
i = (int) *as - (int) *bs;
if (i != 0)
return i;
++as;
++bs;
}
if (bs < bse)
return -1;
return 0;
}
}
/* Print a resource ID. */
void
res_id_print (stream, id, quote)
FILE *stream;
struct res_id id;
int quote;
{
if (! id.named)
fprintf (stream, "%lu", id.u.id);
else
{
unsigned short *s, *se;
if (quote)
putc ('"', stream);
s = id.u.n.name;
se = s + id.u.n.length;
while (s < se)
{
if (*s == '"')
fprintf (stream, "\\\"");
else if ((*s & 0xff) == *s && isprint (*s))
putc (*s, stream);
else
fprintf (stream, "\\%03o", *s);
++s;
}
if (quote)
putc ('"', stream);
}
}
/* Print a list of resource ID's. */
void
res_ids_print (stream, cids, ids)
FILE *stream;
int cids;
const struct res_id *ids;
{
int i;
for (i = 0; i < cids; i++)
{
res_id_print (stream, ids[i], 1);
if (i + 1 < cids)
fprintf (stream, ": ");
}
}
/* Convert an ASCII string to a resource ID. */
void
res_string_to_id (res_id, string)
struct res_id *res_id;
const char *string;
{
res_id->named = 1;
unicode_from_ascii (&res_id->u.n.length, &res_id->u.n.name, string);
}
/* Define a resource. The arguments are the resource tree, RESOURCES,
and the location at which to put it in the tree, CIDS and IDS.
This returns a newly allocated res_resource structure, which the
caller is expected to initialize. If DUPOK is non-zero, then if a
resource with this ID exists, it is returned. Otherwise, a warning
is issued, and a new resource is created replacing the existing
one. */
struct res_resource *
define_resource (resources, cids, ids, dupok)
struct res_directory **resources;
int cids;
const struct res_id *ids;
int dupok;
{
struct res_entry *re = NULL;
int i;
assert (cids > 0);
for (i = 0; i < cids; i++)
{
struct res_entry **pp;
if (*resources == NULL)
{
*resources = (struct res_directory *) xmalloc (sizeof **resources);
(*resources)->characteristics = 0;
(*resources)->time = 0;
(*resources)->major = 0;
(*resources)->minor = 0;
(*resources)->entries = NULL;
}
for (pp = &(*resources)->entries; *pp != NULL; pp = &(*pp)->next)
if (res_id_cmp ((*pp)->id, ids[i]) == 0)
break;
if (*pp != NULL)
re = *pp;
else
{
re = (struct res_entry *) xmalloc (sizeof *re);
re->next = NULL;
re->id = ids[i];
if ((i + 1) < cids)
{
re->subdir = 1;
re->u.dir = NULL;
}
else
{
re->subdir = 0;
re->u.res = NULL;
}
*pp = re;
}
if ((i + 1) < cids)
{
if (! re->subdir)
{
fprintf (stderr, "%s: ", program_name);
res_ids_print (stderr, i, ids);
fprintf (stderr, ": expected to be a directory\n");
xexit (1);
}
resources = &re->u.dir;
}
}
if (re->subdir)
{
fprintf (stderr, "%s: ", program_name);
res_ids_print (stderr, cids, ids);
fprintf (stderr, ": expected to be a leaf\n");
xexit (1);
}
if (re->u.res != NULL)
{
if (dupok)
return re->u.res;
fprintf (stderr, "%s: warning: ", program_name);
res_ids_print (stderr, cids, ids);
fprintf (stderr, ": duplicate value\n");
}
re->u.res = (struct res_resource *) xmalloc (sizeof (struct res_resource));
re->u.res->type = RES_TYPE_UNINITIALIZED;
memset (&re->u.res->res_info, 0, sizeof (struct res_res_info));
memset (&re->u.res->coff_info, 0, sizeof (struct res_coff_info));
return re->u.res;
}
/* Define a standard resource. This is a version of define_resource
that just takes type, name, and language arguments. */
struct res_resource *
define_standard_resource (resources, type, name, language, dupok)
struct res_directory **resources;
int type;
struct res_id name;
int language;
int dupok;
{
struct res_id a[3];
a[0].named = 0;
a[0].u.id = type;
a[1] = name;
a[2].named = 0;
a[2].u.id = language;
return define_resource (resources, 3, a, dupok);
}
/* Return whether the dialog resource DIALOG is a DIALOG or a
DIALOGEX. */
int
extended_dialog (dialog)
const struct dialog *dialog;
{
const struct dialog_control *c;
if (dialog->ex != NULL)
return 1;
for (c = dialog->controls; c != NULL; c = c->next)
if (c->data != NULL || c->help != 0)
return 1;
return 0;
}
/* Return whether MENUITEMS are a MENU or a MENUEX. */
int
extended_menu (menuitems)
const struct menuitem *menuitems;
{
const struct menuitem *mi;
for (mi = menuitems; mi != NULL; mi = mi->next)
{
if (mi->help != 0 || mi->state != 0)
return 1;
if (mi->popup != NULL && mi->id != 0)
return 1;
if ((mi->type
& ~ (MENUITEM_CHECKED
| MENUITEM_GRAYED
| MENUITEM_HELP
| MENUITEM_INACTIVE
| MENUITEM_MENUBARBREAK
| MENUITEM_MENUBREAK))
!= 0)
return 1;
if (mi->popup != NULL)
{
if (extended_menu (mi->popup))
return 1;
}
}
return 0;
}
/* Convert a string to a format type, or exit if it can't be done. */
static enum res_format
format_from_name (name)
const char *name;
{
const struct format_map *m;
for (m = format_names; m->name != NULL; m++)
if (strcasecmp (m->name, name) == 0)
break;
if (m->name == NULL)
{
fprintf (stderr, "%s: unknown format type `%s'\n", program_name, name);
fprintf (stderr, "%s: supported formats:", program_name);
for (m = format_names; m->name != NULL; m++)
fprintf (stderr, " %s", m->name);
fprintf (stderr, "\n");
xexit (1);
}
return m->format;
}
/* Work out a format type given a file name. If INPUT is non-zero,
it's OK to look at the file itself. */
static enum res_format
format_from_filename (filename, input)
const char *filename;
int input;
{
const char *ext;
FILE *e;
unsigned char b1, b2, b3, b4, b5;
int magic;
/* If we have an extension, see if we recognize it as implying a
particular format. */
ext = strrchr (filename, '.');
if (ext != NULL)
{
const struct format_map *m;
++ext;
for (m = format_fileexts; m->name != NULL; m++)
if (strcasecmp (m->name, ext) == 0)
return m->format;
}
/* If we don't recognize the name of an output file, assume it's a
COFF file. */
if (! input)
return RES_FORMAT_COFF;
/* Read the first few bytes of the file to see if we can guess what
it is. */
e = fopen (filename, FOPEN_RB);
if (e == NULL)
fatal ("%s: %s", filename, strerror (errno));
b1 = getc (e);
b2 = getc (e);
b3 = getc (e);
b4 = getc (e);
b5 = getc (e);
fclose (e);
/* A PE executable starts with 0x4d 0x5a 0x90 0x00. */
if (b1 == 0x4d && b2 == 0x5a && b3 == 0x90 && b4 == 0)
return RES_FORMAT_COFF;
/* A COFF .o file starts with a COFF magic number. */
magic = (b2 << 8) | b1;
switch (magic)
{
case 0x14c: /* i386 */
case 0x166: /* MIPS */
case 0x184: /* Alpha */
case 0x268: /* 68k */
case 0x1f0: /* PowerPC */
case 0x290: /* PA */
return RES_FORMAT_COFF;
}
/* A RES file starts with 0x0 0x0 0x0 0x0 0x20 0x0 0x0 0x0. */
if (b1 == 0 && b2 == 0 && b3 == 0 && b4 == 0 && b5 == 0x20)
return RES_FORMAT_RES;
/* If every character is printable or space, assume it's an RC file. */
if ((isprint (b1) || isspace (b1))
&& (isprint (b2) || isspace (b2))
&& (isprint (b3) || isspace (b3))
&& (isprint (b4) || isspace (b4))
&& (isprint (b5) || isspace (b5)))
return RES_FORMAT_RC;
/* Otherwise, we give up. */
fatal ("can not determine type of file `%s'; use the -I option",
filename);
/* Return something to silence the compiler warning. */
return RES_FORMAT_UNKNOWN;
}
/* Print a usage message and exit. */
static void
usage (stream, status)
FILE *stream;
int status;
{
fprintf (stream, "Usage: %s [options] [input-file] [output-file]\n",
program_name);
fprintf (stream, "\
Options:\n\
-i FILE, --input FILE Name input file\n\
-o FILE, --output FILE Name output file\n\
-I FORMAT, --input-format FORMAT\n\
Specify input format\n\
-O FORMAT, --output-format FORMAT\n\
Specify output format\n\
-F TARGET, --target TARGET Specify COFF target\n\
--preprocessor PROGRAM Program to use to preprocess rc file\n\
--include-dir DIR Include directory when preprocessing rc file\n\
--define SYM[=VAL] Define SYM when preprocessing rc file\n\
--language VAL Set language when reading rc file\n\
#ifdef YYDEBUG
--yydebug Turn on parser debugging\n\
#endif
--help Print this help message\n\
--version Print version information\n");
fprintf (stream, "\
FORMAT is one of rc, res, or coff, and is deduced from the file name\n\
extension if not specified. A single file name is an input file.\n\
No input-file is stdin, default rc. No output-file is stdout, default rc.\n");
list_supported_targets (program_name, stream);
if (status == 0)
fprintf (stream, "Report bugs to bug-gnu-utils@prep.ai.mit.edu\n");
exit (status);
}
/* The main function. */
int
main (argc, argv)
int argc;
char **argv;
{
int c;
char *input_filename;
char *output_filename;
enum res_format input_format;
enum res_format output_format;
char *target;
char *preprocessor;
char *preprocargs;
int language;
struct res_directory *resources;
program_name = argv[0];
xmalloc_set_program_name (program_name);
bfd_init ();
set_default_bfd_target ();
input_filename = NULL;
output_filename = NULL;
input_format = RES_FORMAT_UNKNOWN;
output_format = RES_FORMAT_UNKNOWN;
target = NULL;
preprocessor = NULL;
preprocargs = NULL;
language = -1;
while ((c = getopt_long (argc, argv, "i:o:I:O:F:", long_options,
(int *) 0)) != EOF)
{
switch (c)
{
case 'i':
input_filename = optarg;
break;
case 'o':
output_filename = optarg;
break;
case 'I':
input_format = format_from_name (optarg);
break;
case 'O':
output_format = format_from_name (optarg);
break;
case 'F':
target = optarg;
break;
case OPTION_PREPROCESSOR:
preprocessor = optarg;
break;
case OPTION_DEFINE:
if (preprocargs == NULL)
{
preprocargs = xmalloc (strlen (optarg) + 3);
sprintf (preprocargs, "-D%s", optarg);
}
else
{
char *n;
n = xmalloc (strlen (preprocargs) + strlen (optarg) + 4);
sprintf (n, "%s -D%s", preprocargs, optarg);
free (preprocargs);
preprocargs = n;
}
break;
case OPTION_INCLUDE_DIR:
if (preprocargs == NULL)
{
preprocargs = xmalloc (strlen (optarg) + 3);
sprintf (preprocargs, "-I%s", optarg);
}
else
{
char *n;
n = xmalloc (strlen (preprocargs) + strlen (optarg) + 4);
sprintf (n, "%s -I%s", preprocargs, optarg);
free (preprocargs);
preprocargs = n;
}
{
struct include_dir *n, **pp;
n = (struct include_dir *) xmalloc (sizeof *n);
n->next = NULL;
n->dir = optarg;
for (pp = &include_dirs; *pp != NULL; pp = &(*pp)->next)
;
*pp = n;
}
break;
case OPTION_LANGUAGE:
language = strtol (optarg, (char **) NULL, 16);
break;
#ifdef YYDEBUG
case OPTION_YYDEBUG:
yydebug = 1;
break;
#endif
case OPTION_HELP:
usage (stdout, 0);
break;
case OPTION_VERSION:
print_version ("windres");
break;
default:
usage (stderr, 1);
break;
}
}
if (input_filename == NULL && optind < argc)
{
input_filename = argv[optind];
++optind;
}
if (output_filename == NULL && optind < argc)
{
output_filename = argv[optind];
++optind;
}
if (argc != optind)
usage (stderr, 1);
if (input_format == RES_FORMAT_UNKNOWN)
{
if (input_filename == NULL)
input_format = RES_FORMAT_RC;
else
input_format = format_from_filename (input_filename, 1);
}
if (output_format == RES_FORMAT_UNKNOWN)
{
if (output_filename == NULL)
output_format = RES_FORMAT_RC;
else
output_format = format_from_filename (output_filename, 0);
}
/* Read the input file. */
switch (input_format)
{
default:
abort ();
case RES_FORMAT_RC:
resources = read_rc_file (input_filename, preprocessor, preprocargs,
language);
break;
case RES_FORMAT_RES:
resources = read_res_file (input_filename);
break;
case RES_FORMAT_COFF:
resources = read_coff_rsrc (input_filename, target);
break;
}
/* Write the output file. */
switch (output_format)
{
default:
abort ();
case RES_FORMAT_RC:
write_rc_file (output_filename, resources);
break;
case RES_FORMAT_RES:
write_res_file (output_filename, resources);
break;
case RES_FORMAT_COFF:
write_coff_file (output_filename, target, resources);
break;
}
xexit (0);
return 0;
}
struct res_directory *
read_res_file (filename)
const char *filename;
{
fatal ("read_res_file unimplemented");
return NULL;
}
struct res_directory *
read_coff_rsrc (filename, target)
const char *filename;
const char *target;
{
fatal ("read_coff_rsrc unimplemented");
return NULL;
}
void
write_res_file (filename, resources)
const char *filename;
const struct res_directory *resources;
{
fatal ("write_res_file unimplemented");
}
void
write_coff_file (filename, target, resources)
const char *filename;
const char *target;
const struct res_directory *resources;
{
fatal ("write_coff_file unimplemented");
}

820
binutils/windres.h Normal file
View File

@ -0,0 +1,820 @@
/* windres.h -- header file for windres program.
Copyright 1997 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support.
This file is part of GNU Binutils.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
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. */
#include <ansidecl.h>
/* This is the header file for the windres program. It defines
structures and declares functions used within the program. */
/* We represent resources internally as a tree, similar to the tree
used in the .rsrc section of a COFF file. The root is a
res_directory structure. */
struct res_directory
{
/* Resource flags. According to the MS docs, this is currently
always zero. */
unsigned long characteristics;
/* Time/date stamp. */
unsigned long time;
/* Major version number. */
unsigned short major;
/* Minor version number. */
unsigned short minor;
/* Directory entries. */
struct res_entry *entries;
};
/* A resource ID is stored in a res_id structure. */
struct res_id
{
/* Non-zero if this entry has a name rather than an ID. */
unsigned int named : 1;
union
{
/* If the named field is non-zero, this is the name. */
struct
{
/* Length of the name. */
unsigned short length;
/* Pointer to the name, which is a Unicode string. */
unsigned short *name;
} n;
/* If the named field is zero, this is the ID. */
unsigned long id;
} u;
};
/* Each entry in the tree is a res_entry structure. We mix
directories and resources because in a COFF file all entries in a
directory are sorted together, whether the entries are
subdirectories or resources. */
struct res_entry
{
/* Next entry. */
struct res_entry *next;
/* Resource ID. */
struct res_id id;
/* Non-zero if this entry is a subdirectory rather than a leaf. */
unsigned int subdir : 1;
union
{
/* If the subdir field is non-zero, this is a pointer to the
subdirectory. */
struct res_directory *dir;
/* If the subdir field is zero, this is a pointer to the resource
data. */
struct res_resource *res;
} u;
};
/* Types of resources. */
enum res_type
{
RES_TYPE_UNINITIALIZED,
RES_TYPE_ACCELERATOR,
RES_TYPE_BITMAP,
RES_TYPE_CURSOR,
RES_TYPE_GROUP_CURSOR,
RES_TYPE_DIALOG,
RES_TYPE_FONT,
RES_TYPE_FONTDIR,
RES_TYPE_ICON,
RES_TYPE_GROUP_ICON,
RES_TYPE_MENU,
RES_TYPE_MESSAGETABLE,
RES_TYPE_RCDATA,
RES_TYPE_STRINGTABLE,
RES_TYPE_USERDATA,
RES_TYPE_VERSIONINFO
};
/* A res file and a COFF file store information differently. The
res_info structures holds data which in a res file is stored with
each resource, but in a COFF file is stored elsewhere. */
struct res_res_info
{
/* Language. In a COFF file, the third level of the directory is
keyed by the language, so the language of a resource is defined
by its location in the resource tree. */
unsigned short language;
/* Characteristics of the resource. Entirely user defined. In a
COFF file, the res_directory structure has a characteristics
field, but I don't know if it's related to the one in the res
file. */
unsigned long characteristics;
/* Version of the resource. Entirely user defined. In a COFF file,
the res_directory structure has a characteristics field, but I
don't know if it's related to the one in the res file. */
unsigned long version;
/* Memory flags. This is a combination of the MEMFLAG values
defined below. Most of these values are historical, and are not
meaningful for win32. I don't think there is any way to store
this information in a COFF file. */
unsigned short memflags;
};
/* Each resource in a COFF file has some information which can does
not appear in a res file. */
struct res_coff_info
{
/* The code page used for the data. I don't really know what this
should be. */
unsigned long codepage;
/* A resource entry in a COFF file has a reserved field, which we
record here when reading a COFF file. When writing a COFF file,
we set this field to zero. */
unsigned long reserved;
};
/* Resource data is stored in a res_resource structure. */
struct res_resource
{
/* The type of resource. */
enum res_type type;
/* The data for the resource. */
union
{
struct
{
unsigned long length;
unsigned char *data;
} data;
struct accelerator *acc;
struct cursor *cursor;
struct group_cursor *group_cursor;
struct dialog *dialog;
struct fontdir *fontdir;
struct group_icon *group_icon;
struct menuitem *menu;
struct rcdata_data *rcdata;
struct stringtable *stringtable;
struct rcdata_data *userdata;
struct versioninfo *versioninfo;
} u;
/* Information from a res file. */
struct res_res_info res_info;
/* Information from a COFF file. */
struct res_coff_info coff_info;
};
/* Memory flags in the memflags field of a struct res_resource. */
#define MEMFLAG_MOVEABLE 0x10
#define MEMFLAG_PURE 0x20
#define MEMFLAG_PRELOAD 0x40
#define MEMFLAG_DISCARDABLE 0x1000
/* Standard resource type codes. These are used in the ID field of a
res_entry structure. */
#define RT_CURSOR 1
#define RT_BITMAP 2
#define RT_ICON 3
#define RT_MENU 4
#define RT_DIALOG 5
#define RT_STRING 6
#define RT_FONTDIR 7
#define RT_FONT 8
#define RT_ACCELERATORS 9
#define RT_RCDATA 10
#define RT_MESSAGETABLE 11
#define RT_GROUP_CURSOR 12
#define RT_GROUP_ICON 14
#define RT_VERSION 16
#define RT_DLGINCLUDE 17
#define RT_PLUGPLAY 18
#define RT_VXD 19
#define RT_ANICURSOR 21
#define RT_ANIICON 22
/* An accelerator resource is a linked list of these structures. */
struct accelerator
{
/* Next accelerator. */
struct accelerator *next;
/* Flags. A combination of the ACC values defined below. */
unsigned short flags;
/* Key value. */
unsigned short key;
/* Resource ID. */
unsigned short id;
};
/* Accelerator flags in the flags field of a struct accelerator.
These are the same values that appear in a res file. I hope. */
#define ACC_VIRTKEY 0x01
#define ACC_NOINVERT 0x02
#define ACC_SHIFT 0x04
#define ACC_CONTROL 0x08
#define ACC_ALT 0x10
#define ACC_LAST 0x80
/* A cursor resource. */
struct cursor
{
/* X coordinate of hotspot. */
short xhotspot;
/* Y coordinate of hotspot. */
short yhotspot;
/* Length of bitmap data. */
unsigned long length;
/* Data. */
unsigned char *data;
};
/* A group_cursor resource is a list of group_cursor structures. */
struct group_cursor
{
/* Next cursor in group. */
struct group_cursor *next;
/* Width. */
unsigned short width;
/* Height. */
unsigned short height;
/* Planes. */
unsigned short planes;
/* Bits per pixel. */
unsigned short bits;
/* Number of bytes in cursor resource. */
unsigned long bytes;
/* Index of cursor resource. */
unsigned short index;
};
/* A dialog resource. */
struct dialog
{
/* Basic window style. */
unsigned long style;
/* Extended window style. */
unsigned long exstyle;
/* X coordinate. */
unsigned short x;
/* Y coordinate. */
unsigned short y;
/* Width. */
unsigned short width;
/* Height. */
unsigned short height;
/* Menu name. */
struct res_id menu;
/* Class name. */
struct res_id class;
/* Caption. */
char *caption;
/* Font point size. */
unsigned short pointsize;
/* Font name. */
char *font;
/* Extended information for a dialogex. */
struct dialog_ex *ex;
/* Controls. */
struct dialog_control *controls;
};
/* An extended dialog has additional information. */
struct dialog_ex
{
/* Help ID. */
unsigned long help;
/* Font weight. */
unsigned short weight;
/* Whether the font is italic. */
unsigned short italic;
};
/* Window style flags, from the winsup Defines.h header file. These
can appear in the style field of a struct dialog or a struct
dialog_control. */
#define CW_USEDEFAULT (0x80000000)
#define WS_BORDER (0x800000L)
#define WS_CAPTION (0xc00000L)
#define WS_CHILD (0x40000000L)
#define WS_CHILDWINDOW (0x40000000L)
#define WS_CLIPCHILDREN (0x2000000L)
#define WS_CLIPSIBLINGS (0x4000000L)
#define WS_DISABLED (0x8000000L)
#define WS_DLGFRAME (0x400000L)
#define WS_GROUP (0x20000L)
#define WS_HSCROLL (0x100000L)
#define WS_ICONIC (0x20000000L)
#define WS_MAXIMIZE (0x1000000L)
#define WS_MAXIMIZEBOX (0x10000L)
#define WS_MINIMIZE (0x20000000L)
#define WS_MINIMIZEBOX (0x20000L)
#define WS_OVERLAPPED (0L)
#define WS_OVERLAPPEDWINDOW (0xcf0000L)
#define WS_POPUP (0x80000000L)
#define WS_POPUPWINDOW (0x80880000L)
#define WS_SIZEBOX (0x40000L)
#define WS_SYSMENU (0x80000L)
#define WS_TABSTOP (0x10000L)
#define WS_THICKFRAME (0x40000L)
#define WS_TILED (0L)
#define WS_TILEDWINDOW (0xcf0000L)
#define WS_VISIBLE (0x10000000L)
#define WS_VSCROLL (0x200000L)
#define MDIS_ALLCHILDSTYLES (0x1)
#define BS_3STATE (0x5L)
#define BS_AUTO3STATE (0x6L)
#define BS_AUTOCHECKBOX (0x3L)
#define BS_AUTORADIOBUTTON (0x9L)
#define BS_BITMAP (0x80L)
#define BS_BOTTOM (0x800L)
#define BS_CENTER (0x300L)
#define BS_CHECKBOX (0x2L)
#define BS_DEFPUSHBUTTON (0x1L)
#define BS_GROUPBOX (0x7L)
#define BS_ICON (0x40L)
#define BS_LEFT (0x100L)
#define BS_LEFTTEXT (0x20L)
#define BS_MULTILINE (0x2000L)
#define BS_NOTIFY (0x4000L)
#define BS_OWNERDRAW (0xbL)
#define BS_PUSHBOX (0xcL) /* FIXME! What should this be? */
#define BS_PUSHBUTTON (0L)
#define BS_PUSHLIKE (0x1000L)
#define BS_RADIOBUTTON (0x4L)
#define BS_RIGHT (0x200L)
#define BS_RIGHTBUTTON (0x20L)
#define BS_TEXT (0L)
#define BS_TOP (0x400L)
#define BS_USERBUTTON (0x8L)
#define BS_VCENTER (0xc00L)
#define CBS_AUTOHSCROLL (0x40L)
#define CBS_DISABLENOSCROLL (0x800L)
#define CBS_DROPDOWN (0x2L)
#define CBS_DROPDOWNLIST (0x3L)
#define CBS_HASSTRINGS (0x200L)
#define CBS_LOWERCASE (0x4000L)
#define CBS_NOINTEGRALHEIGHT (0x400L)
#define CBS_OEMCONVERT (0x80L)
#define CBS_OWNERDRAWFIXED (0x10L)
#define CBS_OWNERDRAWVARIABLE (0x20L)
#define CBS_SIMPLE (0x1L)
#define CBS_SORT (0x100L)
#define CBS_UPPERCASE (0x2000L)
#define ES_AUTOHSCROLL (0x80L)
#define ES_AUTOVSCROLL (0x40L)
#define ES_CENTER (0x1L)
#define ES_LEFT (0L)
#define ES_LOWERCASE (0x10L)
#define ES_MULTILINE (0x4L)
#define ES_NOHIDESEL (0x100L)
#define ES_NUMBER (0x2000L)
#define ES_OEMCONVERT (0x400L)
#define ES_PASSWORD (0x20L)
#define ES_READONLY (0x800L)
#define ES_RIGHT (0x2L)
#define ES_UPPERCASE (0x8L)
#define ES_WANTRETURN (0x1000L)
#define LBS_DISABLENOSCROLL (0x1000L)
#define LBS_EXTENDEDSEL (0x800L)
#define LBS_HASSTRINGS (0x40L)
#define LBS_MULTICOLUMN (0x200L)
#define LBS_MULTIPLESEL (0x8L)
#define LBS_NODATA (0x2000L)
#define LBS_NOINTEGRALHEIGHT (0x100L)
#define LBS_NOREDRAW (0x4L)
#define LBS_NOSEL (0x4000L)
#define LBS_NOTIFY (0x1L)
#define LBS_OWNERDRAWFIXED (0x10L)
#define LBS_OWNERDRAWVARIABLE (0x20L)
#define LBS_SORT (0x2L)
#define LBS_STANDARD (0xa00003L)
#define LBS_USETABSTOPS (0x80L)
#define LBS_WANTKEYBOARDINPUT (0x400L)
#define SBS_BOTTOMALIGN (0x4L)
#define SBS_HORZ (0L)
#define SBS_LEFTALIGN (0x2L)
#define SBS_RIGHTALIGN (0x4L)
#define SBS_SIZEBOX (0x8L)
#define SBS_SIZEBOXBOTTOMRIGHTALIGN (0x4L)
#define SBS_SIZEBOXTOPLEFTALIGN (0x2L)
#define SBS_SIZEGRIP (0x10L)
#define SBS_TOPALIGN (0x2L)
#define SBS_VERT (0x1L)
#define SS_BITMAP (0xeL)
#define SS_BLACKFRAME (0x7L)
#define SS_BLACKRECT (0x4L)
#define SS_CENTER (0x1L)
#define SS_CENTERIMAGE (0x200L)
#define SS_ENHMETAFILE (0xfL)
#define SS_ETCHEDFRAME (0x12L)
#define SS_ETCHEDHORZ (0x10L)
#define SS_ETCHEDVERT (0x11L)
#define SS_GRAYFRAME (0x8L)
#define SS_GRAYRECT (0x5L)
#define SS_ICON (0x3L)
#define SS_LEFT (0L)
#define SS_LEFTNOWORDWRAP (0xcL)
#define SS_NOPREFIX (0x80L)
#define SS_NOTIFY (0x100L)
#define SS_OWNERDRAW (0xdL)
#define SS_REALSIZEIMAGE (0x800L)
#define SS_RIGHT (0x2L)
#define SS_RIGHTJUST (0x400L)
#define SS_SIMPLE (0xbL)
#define SS_SUNKEN (0x1000L)
#define SS_USERITEM (0xaL)
#define SS_WHITEFRAME (0x9L)
#define SS_WHITERECT (0x6L)
#define DS_3DLOOK (0x4L)
#define DS_ABSALIGN (0x1L)
#define DS_CENTER (0x800L)
#define DS_CENTERMOUSE (0x1000L)
#define DS_CONTEXTHELP (0x2000L)
#define DS_CONTROL (0x400L)
#define DS_FIXEDSYS (0x8L)
#define DS_LOCALEDIT (0x20L)
#define DS_MODALFRAME (0x80L)
#define DS_NOFAILCREATE (0x10L)
#define DS_NOIDLEMSG (0x100L)
#define DS_SETFONT (0x40L)
#define DS_SETFOREGROUND (0x200L)
#define DS_SYSMODAL (0x2L)
/* A dialog control. */
struct dialog_control
{
/* Next control. */
struct dialog_control *next;
/* ID. */
unsigned short id;
/* Style. */
unsigned long style;
/* Extended style. */
unsigned long exstyle;
/* X coordinate. */
unsigned short x;
/* Y coordinate. */
unsigned short y;
/* Width. */
unsigned short width;
/* Height. */
unsigned short height;
/* Class name. */
struct res_id class;
/* Associated text. */
struct res_id text;
/* Extra data for the window procedure. */
struct rcdata_data *data;
/* Help ID. Only used in an extended dialog. */
unsigned long help;
};
/* Control classes. These can be used as the ID field in a struct
dialog_control. */
#define CTL_BUTTON 0x80
#define CTL_EDIT 0x81
#define CTL_STATIC 0x82
#define CTL_LISTBOX 0x83
#define CTL_SCROLLBAR 0x84
#define CTL_COMBOBOX 0x85
/* A fontdir resource is a list of fontdir structures. */
struct fontdir
{
struct fontdir *next;
/* Index of font entry. */
short index;
/* Length of font information. */
unsigned long length;
/* Font information. */
unsigned char *data;
};
/* A group_icon resource is a list of group_icon structures. */
struct group_icon
{
/* Next icon in group. */
struct group_icon *next;
/* Width. */
unsigned char width;
/* Height. */
unsigned char height;
/* Color count. */
unsigned char colors;
/* Planes. */
unsigned short planes;
/* Bits per pixel. */
unsigned short bits;
/* Number of bytes in cursor resource. */
unsigned long bytes;
/* Index of cursor resource. */
unsigned short index;
};
/* A menu resource is a list of menuitem structures. */
struct menuitem
{
/* Next menuitem. */
struct menuitem *next;
/* Type. In a normal menu, rather than a menuex, this is the flags
field. */
unsigned long type;
/* State. This is only used in a menuex. */
unsigned long state;
/* Id. */
unsigned short id;
/* Text. */
char *text;
/* Popup menu items for a popup. */
struct menuitem *popup;
/* Help ID. This is only used in a menuex. */
unsigned long help;
};
/* Menu item flags. These can appear in the flags field of a struct
menuitem. */
#define MENUITEM_GRAYED 0x001
#define MENUITEM_INACTIVE 0x002
#define MENUITEM_BITMAP 0x004
#define MENUITEM_OWNERDRAW 0x100
#define MENUITEM_CHECKED 0x008
#define MENUITEM_POPUP 0x010
#define MENUITEM_MENUBARBREAK 0x020
#define MENUITEM_MENUBREAK 0x040
#define MENUITEM_HELP 0x4000
/* An rcdata resource is a pointer to an rcdata_data structure. */
struct rcdata_data
{
/* First data item. */
struct rcdata_item *first;
/* Last data item. */
struct rcdata_item *last;
};
/* For an rcdata resource we keep a list of rcdata_item structures. */
struct rcdata_item
{
/* Next data item. */
struct rcdata_item *next;
/* Type of data. */
enum
{
RCDATA_WORD,
RCDATA_DWORD,
RCDATA_STRING,
RCDATA_WSTRING,
RCDATA_BUFFER
} type;
union
{
unsigned int word;
unsigned long dword;
char *string;
unsigned short *wstring;
struct
{
unsigned long length;
unsigned char *data;
} buffer;
} u;
};
/* A stringtable resource is a pointer to a stringtable structure. */
struct stringtable
{
/* Each stringtable resource is a list of 16 unicode strings. */
struct
{
/* Length of string. */
unsigned short length;
/* String data if length > 0. */
unsigned short *string;
} strings[16];
};
/* A versioninfo resource points to a versioninfo structure. */
struct versioninfo
{
/* Fixed version information. */
struct fixed_versioninfo *fixed;
/* Variable version information. */
struct ver_info *var;
};
/* The fixed portion of a versioninfo resource. */
struct fixed_versioninfo
{
/* The file version, which is two 32 bit integers. */
unsigned long file_version_ms;
unsigned long file_version_ls;
/* The product version, which is two 32 bit integers. */
unsigned long product_version_ms;
unsigned long product_version_ls;
/* The file flags mask. */
unsigned long file_flags_mask;
/* The file flags. */
unsigned long file_flags;
/* The OS type. */
unsigned long file_os;
/* The file type. */
unsigned long file_type;
/* The file subtype. */
unsigned long file_subtype;
/* The date, which in Windows is two 32 bit integers. */
unsigned long file_date_ms;
unsigned long file_date_ls;
};
/* A list of variable version information. */
struct ver_info
{
/* Next item. */
struct ver_info *next;
/* Type of data. */
enum { VERINFO_STRING, VERINFO_VAR } type;
union
{
/* StringFileInfo data. */
struct
{
/* Language. */
unsigned short *language;
/* Strings. */
struct ver_stringinfo *strings;
} string;
/* VarFileInfo data. */
struct
{
/* Key. */
unsigned short *key;
/* Values. */
struct ver_varinfo *var;
} var;
} u;
};
/* A list of string version information. */
struct ver_stringinfo
{
/* Next string. */
struct ver_stringinfo *next;
/* Key. */
unsigned short *key;
/* Value. */
unsigned short *value;
};
/* A list of variable version information. */
struct ver_varinfo
{
/* Next item. */
struct ver_varinfo *next;
/* Language ID. */
unsigned short language;
/* Character set ID. */
unsigned short charset;
};
/* Function declarations. */
extern struct res_directory *read_rc_file
PARAMS ((const char *, const char *, const char *, int));
extern struct res_directory *read_res_file PARAMS ((const char *));
extern struct res_directory *read_coff_rsrc
PARAMS ((const char *, const char *));
extern void write_rc_file
PARAMS ((const char *, const struct res_directory *));
extern void write_res_file
PARAMS ((const char *, const struct res_directory *));
extern void write_coff_file
PARAMS ((const char *, const char *, const struct res_directory *));
extern FILE *open_file_search
PARAMS ((const char *, const char *, const char *, char **));
/* Resource ID handling. */
extern int res_id_cmp PARAMS ((struct res_id, struct res_id));
extern void res_id_print PARAMS ((FILE *, struct res_id, int));
extern void res_ids_print PARAMS ((FILE *, int, const struct res_id *));
extern void res_string_to_id PARAMS ((struct res_id *, const char *));
/* Unicode support. */
extern void unicode_from_ascii
PARAMS ((unsigned short *, unsigned short **, const char *));
extern void unicode_print PARAMS ((FILE *, const unsigned short *, int));
/* Manipulation of the resource tree. */
extern struct res_resource *define_resource
PARAMS ((struct res_directory **, int, const struct res_id *, int));
extern struct res_resource *define_standard_resource
PARAMS ((struct res_directory **, int, struct res_id, int, int));
extern int extended_dialog PARAMS ((const struct dialog *));
extern int extended_menu PARAMS ((const struct menuitem *));
/* Communication between the rc file support and the parser and lexer. */
extern int yydebug;
extern FILE *yyin;
extern char *rc_filename;
extern int rc_lineno;
extern int yyparse PARAMS ((void));
extern int yylex PARAMS ((void));
extern void yyerror PARAMS ((const char *));
extern void rcparse_warning PARAMS ((const char *));
extern void rcparse_set_language PARAMS ((int));
extern void define_accelerator
PARAMS ((struct res_id, const struct res_res_info *, struct accelerator *));
extern void define_bitmap
PARAMS ((struct res_id, const struct res_res_info *, const char *));
extern void define_cursor
PARAMS ((struct res_id, const struct res_res_info *, const char *));
extern void define_dialog
PARAMS ((struct res_id, const struct res_res_info *, const struct dialog *));
extern struct dialog_control *define_control
PARAMS ((char *, unsigned long, unsigned long, unsigned long,
unsigned long, unsigned long, unsigned long, unsigned long,
unsigned long));
extern void define_font
PARAMS ((struct res_id, const struct res_res_info *, const char *));
extern void define_icon
PARAMS ((struct res_id, const struct res_res_info *, const char *));
extern void define_menu
PARAMS ((struct res_id, const struct res_res_info *, struct menuitem *));
extern struct menuitem *define_menuitem
PARAMS ((char *, int, unsigned long, unsigned long, unsigned long,
struct menuitem *));
extern void define_messagetable
PARAMS ((struct res_id, const struct res_res_info *, const char *));
extern void define_rcdata
PARAMS ((struct res_id, const struct res_res_info *, struct rcdata_data *));
extern struct rcdata_data *append_rcdata_item
PARAMS ((struct rcdata_data *, struct rcdata_item *));
extern struct rcdata_data *append_rcdata_string
PARAMS ((struct rcdata_data *, char *));
extern struct rcdata_data *append_rcdata_number
PARAMS ((struct rcdata_data *, unsigned long, int));
extern void define_stringtable
PARAMS ((const struct res_res_info *, unsigned long, char *));
extern void define_user_data
PARAMS ((struct res_id, struct res_id, const struct res_res_info *,
struct rcdata_data *));
extern void define_user_file
PARAMS ((struct res_id, struct res_id, const struct res_res_info *,
const char *));
extern void define_versioninfo
PARAMS ((struct res_id, int, struct fixed_versioninfo *,
struct ver_info *));
extern struct ver_info *append_ver_stringfileinfo
PARAMS ((struct ver_info *, char *, struct ver_stringinfo *));
extern struct ver_info *append_ver_varfileinfo
PARAMS ((struct ver_info *, char *, struct ver_varinfo *));
extern struct ver_stringinfo *append_verval
PARAMS ((struct ver_stringinfo *, char *, char *));
extern struct ver_varinfo *append_vertrans
PARAMS ((struct ver_varinfo *, unsigned long, unsigned long));