]> git.draconx.ca Git - upkg.git/commitdiff
Stop using gnulib's flexmember module. master
authorNick Bowler <nbowler@draconx.ca>
Fri, 1 Dec 2023 06:15:29 +0000 (01:15 -0500)
committerNick Bowler <nbowler@draconx.ca>
Fri, 1 Dec 2023 06:15:29 +0000 (01:15 -0500)
The only thing we're actually using from this module is provided
directly by Autoconf, via AC_C_FLEXIBLE_ARRAY_MEMBER, so we can
just use that macro instead.

41 files changed:
.gitignore
.gitmodules
Makefile.am
bootstrap
common
configure.ac
doc/man/upkg.1
gnulib
m4/.gitignore
m4/gnulib-cache.m4
src/.gitignore [new file with mode: 0644]
src/engine/engine.c
src/engine/mesh.gob
src/engine/music-dummymod.c
src/engine/music-modplug.c
src/engine/music.gob
src/engine/palette.gob
src/engine/sound.gob
src/engine/texture.gob
src/libupkg.c
src/uobject/avl.c
src/uobject/exportable.c
src/uobject/loadable.c
src/uobject/module.c
src/uobject/package.c
src/uobject/package.h
src/uobject/uobject.c
src/uobject/vfs.c
src/upkg.c
src/upkgopts.opt [new file with mode: 0644]
test/common.c
test/common.h
test/decodeindex.c
test/pcxrle.c
tests/data/hatch2x2.pcx [new file with mode: 0644]
tests/data/test0.utx [new file with mode: 0644]
tests/engine-pcx-rlencode.sh [deleted file]
tests/export.at [new file with mode: 0644]
tests/functions.at [new file with mode: 0644]
tests/libupkg-index-decode.sh [deleted file]
testsuite.at [new file with mode: 0644]

index 15c133e6e3580bdcb245dfcfe0c3fa1c8d457fd7..f0171109248031582d59033a561ac171ad542028 100644 (file)
@@ -1,29 +1,38 @@
-*.o
-*.lo
-*.la
+*.a
 *.gobstamp
 *.gobstamp
-Makefile
-Makefile.in
-.libs
+*.la
+*.lo
+*.o
 .deps
 .dirstamp
 .deps
 .dirstamp
-/config.*
-/configure
+.libs
+/INSTALL
+/Makefile
+/Makefile.in
 /aclocal.m4
 /aclocal.m4
+/atconfig
+/atlocal
 /autom4te.cache
 /autom4te.cache
-/libtool
+/compile
+/config.*
+/configure
+/depcomp
+/exported.sh
+/install-sh
+/lib
 /libltdl
 /libltdl
+/libtool
+/libuobject.pc
 /ltmain.sh
 /ltmain.sh
-/install-sh
-/depcomp
 /missing
 /mkinstalldirs
 /missing
 /mkinstalldirs
-/stamp-h1
-/compile
-/libuobject.pc
-/lib
+/package.m4
 /snippet
 /snippet
-/upkg
-/test-suite.log
+/stamp-h1
 /test-driver
 /test-driver
-/exported.sh
+/test-suite.log
+/testsuite
+/testsuite.deps
+/testsuite.dir
+/testsuite.log
+/upkg
index 13c6889c31de538944a21e573883bce870286538..c2e605275ad8c36d2ac18b0104abe6d5cf8588d5 100644 (file)
@@ -1,6 +1,6 @@
 [submodule "gnulib"]
        path = gnulib
 [submodule "gnulib"]
        path = gnulib
-       url = git://git.savannah.gnu.org/gnulib.git
+       url = https://git.savannah.gnu.org/git/gnulib.git
 [submodule "common"]
        path = common
 [submodule "common"]
        path = common
-       url = git://git.draconx.ca/dxcommon.git
+       url = https://git.draconx.ca/dxcommon.git
index e5140a4679fddcccc4d4b2b9ddaa7e46a6aa2768..fa034c3ed5080fd873c951e68a13262db126da61 100644 (file)
@@ -1,22 +1,24 @@
-# Copyright © 2009-2012, 2015, 2019-2020 Nick Bowler
+# Copyright © 2009-2012, 2015, 2019-2020, 2022 Nick Bowler
 #
 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
 # This is free software: you are free to do what the fuck you want to.
 # There is NO WARRANTY, to the extent permitted by law.
 
 #
 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
 # This is free software: you are free to do what the fuck you want to.
 # There is NO WARRANTY, to the extent permitted by law.
 
-AUTOMAKE_OPTIONS = parallel-tests color-tests
 ACLOCAL_AMFLAGS = -I m4 -I common/m4
 MAINTAINERCLEANFILES =
 MOSTLYCLEANFILES =
 DISTCLEANFILES =
 ACLOCAL_AMFLAGS = -I m4 -I common/m4
 MAINTAINERCLEANFILES =
 MOSTLYCLEANFILES =
 DISTCLEANFILES =
-CLEANFILES =
+
+# Distribution should be buildable without working gob.
+AM_DISTCHECK_CONFIGURE_FLAGS = GOB2=false
 
 EXTRA_DIST = $(MAINTAINERCLEANFILES) m4/gnulib-cache.m4
 
 EXTRA_DIST = $(MAINTAINERCLEANFILES) m4/gnulib-cache.m4
+CLEANFILES = $(EXTRA_LTLIBRARIES) $(EXTRA_LIBRARIES)
 
 AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src \
 
 AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src \
-       -I$(top_srcdir)/$(DX_BASEDIR)/src \
-       -I$(top_builddir)/lib -I$(top_srcdir)/lib \
-       -DPKGLIBDIR=\"$(pkglibdir)\" -DPKGDATADIR=\"$(pkgdatadir)\"
+              -I$(top_builddir)/lib -I$(top_srcdir)/lib \
+              -I$(DX_BASEDIR)/src -DPKGLIBDIR=\"$(pkglibdir)\" \
+              -DPKGDATADIR=\"$(pkgdatadir)\"
 
 AM_CFLAGS = $(LTDLINCL) $(GLIB_CFLAGS) $(LIBMODPLUG_CFLAGS)
 
 
 AM_CFLAGS = $(LTDLINCL) $(GLIB_CFLAGS) $(LIBMODPLUG_CFLAGS)
 
@@ -29,16 +31,14 @@ include_HEADERS =
 
 dist_man_MANS = doc/man/upkg.1
 
 
 dist_man_MANS = doc/man/upkg.1
 
-# This trick should define orderonly to | iff we're using GNU make.
-have_orderonly = $(findstring order-only,$(.FEATURES))
-orderonly = $(have_orderonly:order-only=|)
-
-upkg_SOURCES  = src/upkg.c src/upkg.h
-upkg_LDFLAGS  = $(AM_LDFLAGS) -export-dynamic
-upkg_LDADD    = libuobject.la libupkg.la libgnu.la $(GLIB_LIBS)
-$(upkg_OBJECTS): $(gnulib_headers)
+upkg_SOURCES = src/upkg.c src/upkg.h src/upkgopts.h \
+               common/src/help.c common/src/help.h
+upkg_LDFLAGS = $(AM_LDFLAGS) -export-dynamic
+upkg_LDADD   = libuobject.la libupkg.la libgnu.la $(GLIB_LIBS)
+$(upkg_OBJECTS): $(gnulib_headers) src/upkgopts.h
 
 libupkg_la_SOURCES = src/libupkg.c common/src/pack.c common/src/pack.h
 
 libupkg_la_SOURCES = src/libupkg.c common/src/pack.c common/src/pack.h
+$(libupkg_la_OBJECTS): $(gnulib_headers)
 
 uobjectdir = $(includedir)/uobject
 uobject_HEADERS = src/uobject/uobject.h src/uobject/exportable.h \
 
 uobjectdir = $(includedir)/uobject
 uobject_HEADERS = src/uobject/uobject.h src/uobject/exportable.h \
@@ -60,6 +60,7 @@ moduleflags = -module -avoid-version -export-symbols-regex _LTX_
 
 engine_GOBS = src/engine/palette.gob src/engine/texture.gob \
        src/engine/music.gob src/engine/sound.gob src/engine/mesh.gob
 
 engine_GOBS = src/engine/palette.gob src/engine/texture.gob \
        src/engine/music.gob src/engine/sound.gob src/engine/mesh.gob
+EXTRA_DIST += $(engine_GOBS)
 
 MAINTAINERCLEANFILES += $(engine_GOBS:.gob=.gobstamp) \
        $(engine_GOBS:.gob=.c) $(engine_GOBS:.gob=.h)
 
 MAINTAINERCLEANFILES += $(engine_GOBS:.gob=.gobstamp) \
        $(engine_GOBS:.gob=.c) $(engine_GOBS:.gob=.h)
@@ -71,7 +72,7 @@ engine_la_SOURCES = $(engine_GOBS:.gob=.c) $(engine_GOBS:.gob=.h) \
        src/engine/pcx.h
 engine_la_LDFLAGS  = $(AM_LDFLAGS) $(moduleflags)
 engine_la_LIBADD   = $(GLIB_LIBS)
        src/engine/pcx.h
 engine_la_LDFLAGS  = $(AM_LDFLAGS) $(moduleflags)
 engine_la_LIBADD   = $(GLIB_LIBS)
-$(engine_la_OBJECTS): $(orderonly) $(engine_GOBS:.gob=.gobstamp)
+$(engine_la_OBJECTS): $(gnulib_headers) $(engine_GOBS:.gob=.gobstamp)
 
 if USE_DUMMYMOD
 engine_la_SOURCES += src/engine/music-dummymod.c
 
 if USE_DUMMYMOD
 engine_la_SOURCES += src/engine/music-dummymod.c
@@ -82,22 +83,20 @@ engine_la_SOURCES  += src/engine/music-modplug.c src/engine/modplug-types.h
 engine_la_LIBADD   += $(LIBMODPLUG_LIBS)
 endif
 
 engine_la_LIBADD   += $(LIBMODPLUG_LIBS)
 endif
 
-check_LTLIBRARIES = libtest.la
 check_PROGRAMS = test/decodeindex test/pcxrle
 check_PROGRAMS = test/decodeindex test/pcxrle
+check_LIBRARIES = libtest.a
+
+libtest_a_SOURCES = test/common.c test/common.h common/src/help.c
+$(libtest_a_OBJECTS): $(gnulib_headers)
 
 
-libtest_la_SOURCES = test/common.c test/common.h
+TEST_LIBS = libtest.a libgnu.la
 
 
-test_decodeindex_LDADD = libupkg.la libgnu.la libtest.la
+test_decodeindex_LDADD = libupkg.la $(TEST_LIBS)
 $(test_decodeindex_OBJECTS): $(gnulib_headers)
 $(test_decodeindex_OBJECTS): $(gnulib_headers)
-test_pcxrle_LDADD = src/engine/pcx.lo libupkg.la libgnu.la libtest.la
+test_pcxrle_LDADD = src/engine/pcx.lo libupkg.la $(TEST_LIBS)
 $(test_pcxrle_OBJECTS): $(gnulib_headers)
 
 $(test_pcxrle_OBJECTS): $(gnulib_headers)
 
-TESTS_ENVIRONMENT = SHELL='$(SHELL)' EXEEXT='$(EXEEXT)'
-TEST_EXTENSIONS = .sh
-SH_LOG_COMPILER = $(SHELL)
-
-TESTS = tests/libupkg-index-decode.sh tests/engine-pcx-rlencode.sh
-EXTRA_DIST += $(TESTS)
+EXTRA_DIST += tests/data/test0.utx tests/data/hatch2x2.pcx
 
 # Supporting rules for GObject Builder
 GOB_V   = $(GOB_V_@AM_V@)
 
 # Supporting rules for GObject Builder
 GOB_V   = $(GOB_V_@AM_V@)
@@ -113,7 +112,8 @@ if HAVE_GOB2_DYN
        $(GOB_V) od='$(@D)'; case $$od in \
          src/*) od=src ;; \
          */src/*) od=$${od%/src/*}/src ;; \
        $(GOB_V) od='$(@D)'; case $$od in \
          src/*) od=src ;; \
          */src/*) od=$${od%/src/*}/src ;; \
-         esac; $(GOB2) -o "$$od" --file-sep=/ --no-private-header $<
+         esac; $(GOB2) -o "$$od" --file-sep=/ \
+           --no-private-header --no-touch-headers $<
        $(AM_V_at) mv -f $@.tmp $@
 else
 if HAVE_GOB2
        $(AM_V_at) mv -f $@.tmp $@
 else
 if HAVE_GOB2
@@ -136,5 +136,33 @@ STAMP_RECOVER = \
 .gobstamp.c: ; $(STAMP_RECOVER)
 .gobstamp.h: ; $(STAMP_RECOVER)
 
 .gobstamp.c: ; $(STAMP_RECOVER)
 .gobstamp.h: ; $(STAMP_RECOVER)
 
+OPTFILES = src/upkgopts.opt
+.opt.h:
+       $(AM_V_GEN) $(AWK) -f $(DX_BASEDIR)/scripts/gen-options.awk $< >$@.tmp
+       $(AM_V_at) mv -f $@.tmp $@
+$(OPTFILES:.opt=.h): $(DX_BASEDIR)/scripts/gen-options.awk
+MAINTAINERCLEANFILES += $(OPTFILES:.opt=.h)
+EXTRA_DIST += $(DX_BASEDIR)/scripts/gen-options.awk $(OPTFILES)
+
+# The gob rules refrain from updating unchanged headers for the convenience of
+# developers, but the headers should be distributed with up-to-date timestamps.
+dist-hook: update-headers
+update-headers: unfuck-distdir
+       for f in $(engine_GOBS:.gob=.h); do \
+         touch -c '$(distdir)'/"$$f" || exit; \
+       done
+.PHONY: update-headers
+
+# When running "make dist" in a VPATH build with a read-only srcdir, Automake
+# will produce a distribution with all files read-only.  Moreover, the files
+# are read-only in distdir when the dist hooks are run.  This hook will
+# manually fix up the permissions.  All dist hooks that modify files in
+# distdir should list unfuck-distdir as a prerequisite.
+dist-hook: unfuck-distdir
+unfuck-distdir:
+       find '$(distdir)' -type f -exec chmod u+w {} +
+.PHONY: unfuck-distdir
+
 include $(top_srcdir)/lib/gnulib.mk
 include $(top_srcdir)/libltdl/ltdl.mk
 include $(top_srcdir)/lib/gnulib.mk
 include $(top_srcdir)/libltdl/ltdl.mk
+include $(top_srcdir)/common/snippet/autotest.mk
index d7e5087db43f9784761cb01796a426534999d897..2ab4a587fc333cc5efb54514d68aae19c249889c 100755 (executable)
--- a/bootstrap
+++ b/bootstrap
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
 #!/bin/sh
 #
-# Copyright © 2011-2012, 2015 Nick Bowler
+# Copyright © 2011-2012, 2015, 2021-2023 Nick Bowler
 #
 # Simple script to get started from a fresh git checkout.
 #
 #
 # Simple script to get started from a fresh git checkout.
 #
 
 scriptname=$0
 
 
 scriptname=$0
 
-err() {
-       printf '%s: %s\n' "$scriptname" "$@" 1>&2
-}
-
-die() {
-       err "$@"
-       exit 1
-}
+err() { printf '%s: %s\n' "$scriptname" "$*" 1>&2; }
+die() { err "$@"; exit 1; }
 
 : ${LIBTOOLIZE=libtoolize}
 : ${AUTORECONF=autoreconf}
 
 : ${LIBTOOLIZE=libtoolize}
 : ${AUTORECONF=autoreconf}
+: ${AUTOMAKE=automake}
 : ${GNULIB=gnulib}
 : ${GIT=git}
 : ${PERL=perl}
 : ${GNULIB=gnulib}
 : ${GIT=git}
 : ${PERL=perl}
@@ -28,13 +23,25 @@ die() {
 $GIT submodule update --init || err "Failed to update submodules from git."
 
 if test -x $GNULIB/gnulib-tool; then
 $GIT submodule update --init || err "Failed to update submodules from git."
 
 if test -x $GNULIB/gnulib-tool; then
-       $GNULIB/gnulib-tool --update -S || die "Failed to update Gnulib."
+  $GNULIB/gnulib-tool --update -S || die "Failed to update Gnulib."
 else
 else
-       die "Gnulib sources are not properly installed in gnulib/."
+  err "Gnulib sources are not properly installed in $GNULIB/"
+  cat >&2 <<'EOF'
+
+To bootstrap this package using an external Gnulib, you can set the GNULIB
+environment variable to indicate the location of the Gnulib sources.
+EOF
+
+  test ! -f configure || cat >&2 <<'EOF'
+
+However, it seems this package is already bootstrapped.  It should not
+normally be necessary to run this script from a release tarball.
+EOF
+  exit 1
 fi
 
 $PERL common/scripts/fix-gnulib.pl -o lib/gnulib.mk -i lib/gnulib.mk.in \
 fi
 
 $PERL common/scripts/fix-gnulib.pl -o lib/gnulib.mk -i lib/gnulib.mk.in \
-       || die "Failed to fixup Gnulib makefile fragment."
+  || die "Failed to fixup Gnulib makefile fragment."
 
 # Frustratingly, libtoolize has changed the name of its nonrecursive ltdl
 # makefile output, which broke all packages depending on previous documented
 
 # Frustratingly, libtoolize has changed the name of its nonrecursive ltdl
 # makefile output, which broke all packages depending on previous documented
@@ -50,4 +57,9 @@ $PERL common/scripts/fix-ltdl.pl -o libltdl/ltdl.mk -i libltdl/ltdl.mk.in \
 # Punt some automake-generated files so that Gentoo's wrapper script doesn't
 # try to detect the automake version in use.
 rm -f Makefile.in aclocal.m4
 # Punt some automake-generated files so that Gentoo's wrapper script doesn't
 # try to detect the automake version in use.
 rm -f Makefile.in aclocal.m4
-LIBTOOLIZE=true $AUTORECONF -fis
+LIBTOOLIZE=true $AUTORECONF -fis || exit
+
+amdir=`$AUTOMAKE --print-libdir`
+if test -f "$amdir/INSTALL"; then
+  ln -sf "$amdir/INSTALL" INSTALL
+fi
diff --git a/common b/common
index 4705ffd69e7b7551bab4650f9e49756667be783b..262d3eaea39294df3f6172b28213e927e2f3b424 160000 (submodule)
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 4705ffd69e7b7551bab4650f9e49756667be783b
+Subproject commit 262d3eaea39294df3f6172b28213e927e2f3b424
index 36c3ffdae6f53e8e4e8e7b87ed7ff05f8f1d7a8e..1b3a262ce38876a77901b1722f9a455a4595501a 100644 (file)
@@ -1,13 +1,14 @@
-dnl Copyright © 2009-2012, 2015, 2019-2020 Nick Bowler
+dnl Copyright © 2009-2012, 2015, 2019-2020, 2022-2023 Nick Bowler
 dnl
 dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
 dnl This is free software: you are free to do what the fuck you want to.
 dnl There is NO WARRANTY, to the extent permitted by law.
 
 dnl
 dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
 dnl This is free software: you are free to do what the fuck you want to.
 dnl There is NO WARRANTY, to the extent permitted by law.
 
-AC_PREREQ(2.62)
+DX_PATCH_GNULIB
+
 AC_INIT([upkg],[0.1],[nbowler@draconx.ca])
 AC_CONFIG_SRCDIR([src/libupkg.c])
 AC_INIT([upkg],[0.1],[nbowler@draconx.ca])
 AC_CONFIG_SRCDIR([src/libupkg.c])
-AC_CONFIG_HEADER([config.h])
+AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_MACRO_DIR([m4])
 
 AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign subdir-objects])
 AC_CONFIG_MACRO_DIR([m4])
 
 AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign subdir-objects])
@@ -17,6 +18,8 @@ DX_AUTOMAKE_COMPAT
 AC_PROG_CC_C99
 gl_EARLY
 
 AC_PROG_CC_C99
 gl_EARLY
 
+AC_C_FLEXIBLE_ARRAY_MEMBER
+
 LT_CONFIG_LTDL_DIR([libltdl])
 LT_INIT([dlopen])
 LTDL_INIT([nonrecursive])
 LT_CONFIG_LTDL_DIR([libltdl])
 LT_INIT([dlopen])
 LTDL_INIT([nonrecursive])
@@ -28,6 +31,8 @@ AC_CACHE_SAVE
 m4_include([lib/gnulib.mk])
 
 DX_LIB_GLIB2([], [gobject])
 m4_include([lib/gnulib.mk])
 
 DX_LIB_GLIB2([], [gobject])
+AC_DEFINE([GLIB_DISABLE_DEPRECATION_WARNINGS], [1],
+  [Define to shut up glib deprecation silliness.])
 
 AC_ARG_WITH([modlib],
        [AS_HELP_STRING([--with-modlib],
 
 AC_ARG_WITH([modlib],
        [AS_HELP_STRING([--with-modlib],
@@ -74,5 +79,9 @@ CFLAGS=$save_CFLAGS LIBS=$save_LIBS])
 ])
 AM_CONDITIONAL([HAVE_GOB2_DYN], [test x"$dx_cv_gob2_dynamic_types" = x"yes"])
 
 ])
 AM_CONDITIONAL([HAVE_GOB2_DYN], [test x"$dx_cv_gob2_dynamic_types" = x"yes"])
 
+AC_CONFIG_TESTDIR([.], [test:.])
+DX_PROG_AUTOTEST
+AM_CONDITIONAL([HAVE_AUTOTEST], [test x"$dx_cv_autotest_works" = x"yes"])
+
 AC_CONFIG_FILES([Makefile libuobject.pc])
 AC_OUTPUT
 AC_CONFIG_FILES([Makefile libuobject.pc])
 AC_OUTPUT
index f3a100901be8758500cd9efbad96c02c05a08fba..521ab19ec0fa071283398078aa6ce6de49627f48 100644 (file)
@@ -1,6 +1,6 @@
-.Dd June 17, 2010
-.Os libuobject
+.Dd December 1, 2023
 .Dt UPKG \&1 "UObject Reference Manual"
 .Dt UPKG \&1 "UObject Reference Manual"
+.Os libuobject
 .Sh NAME
 .Nm upkg
 .Nd manipulate UObject packages
 .Sh NAME
 .Nm upkg
 .Nd manipulate UObject packages
 .Op Ar object ...
 .Sh OPTIONS
 .Bl -tag -width indent
 .Op Ar object ...
 .Sh OPTIONS
 .Bl -tag -width indent
-.It Fl i , -info
+.It Fl i , \-info
 Display information about a package.  More information is displayed at higher
 verbosity levels.
 Display information about a package.  More information is displayed at higher
 verbosity levels.
-.It Fl l , -list
+.It Fl l , \-list
 List objects belonging to a package.
 List objects belonging to a package.
-.It Fl x , -export
+.It Fl x , \-export
 Export all exportable objects from a package.
 Export all exportable objects from a package.
-.It Fl v , -verbose
+.It Fl v , \-verbose
 Increase the amount of information printed to standard output.  This option can
 be specified multiple times for increased effect.
 Increase the amount of information printed to standard output.  This option can
 be specified multiple times for increased effect.
-.It Fl f , -file Ar package
+.It Fl f , \-file Ar package
 Loads a specific package by filename.  Currently, this is the only way to load
 packages.
 Loads a specific package by filename.  Currently, this is the only way to load
 packages.
-.It Fl V , -version
+.It Fl V , \-version
 Print a version message and exit.
 Print a version message and exit.
-.It Fl H , -help
+.It Fl H , \-help
 Print a help message and exit.
 .It Ar object
 Specifies the object(s) upon which
 Print a help message and exit.
 .It Ar object
 Specifies the object(s) upon which
@@ -38,3 +38,12 @@ will use the last package specified by the
 .Fl f
 option.
 .El
 .Fl f
 option.
 .El
+.Sh AUTHORS
+Nick Bowler <nbowler@draconx.ca>
+.Sh COPYRIGHT
+Copyright \(co 2009\(en2011, 2023 Nick Bowler
+.Pp
+Permission is granted to copy, distribute and/or modify this manual under the
+terms of the GNU General Public License as published by the Free Software
+Foundation, either version 3 of the License, or (at your option) any later
+version.
diff --git a/gnulib b/gnulib
index 233419c39c6d13d84439b95766328a238ffb6518..8a1e1616f143ccebf13ea477a1d0a4040ce2ddc4 160000 (submodule)
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 233419c39c6d13d84439b95766328a238ffb6518
+Subproject commit 8a1e1616f143ccebf13ea477a1d0a4040ce2ddc4
index d89469b5b4655ed18fd50cf5cd566f75e8ddd3c6..f49561a7dda415e4b8ed4af1839d653e73577047 100644 (file)
@@ -1,19 +1,20 @@
 00gnulib.m4
 00gnulib.m4
+absolute-header.m4
 copysignf.m4
 exponentd.m4
 exponentf.m4
 exponentl.m4
 extensions.m4
 extern-inline.m4
 copysignf.m4
 exponentd.m4
 exponentf.m4
 exponentl.m4
 extensions.m4
 extern-inline.m4
+flexmember.m4
 float_h.m4
 fpieee.m4
 getopt.m4
 float_h.m4
 fpieee.m4
 getopt.m4
-gnulib-cache.m4~
 gnulib-common.m4
 gnulib-comp.m4
 gnulib-common.m4
 gnulib-comp.m4
-gnulib-comp.m4~
 gnulib-tool.m4
 include_next.m4
 gnulib-tool.m4
 include_next.m4
+inline.m4
 isnand.m4
 isnanf.m4
 isnanl.m4
 isnand.m4
 isnanf.m4
 isnanl.m4
@@ -30,6 +31,7 @@ math_h.m4
 mathfunc.m4
 nocrash.m4
 off_t.m4
 mathfunc.m4
 nocrash.m4
 off_t.m4
+pid_t.m4
 signbit.m4
 ssize_t.m4
 stddef_h.m4
 signbit.m4
 ssize_t.m4
 stddef_h.m4
@@ -37,5 +39,7 @@ strcase.m4
 strings_h.m4
 sys_types_h.m4
 unistd_h.m4
 strings_h.m4
 sys_types_h.m4
 unistd_h.m4
+vararrays.m4
 warn-on-use.m4
 wchar_t.m4
 warn-on-use.m4
 wchar_t.m4
+zzgnulib.m4
index 39ed0f60ae7923f547499d544e219e2827d2efaf..5159cac58dfcdb95ee3fcb56a7ddd745205c6dee 100644 (file)
@@ -1,8 +1,8 @@
-# Copyright (C) 2002-2013 Free Software Foundation, Inc.
+# Copyright (C) 2002-2022 Free Software Foundation, Inc.
 #
 # This file is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 #
 # This file 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 3 of the License, or
+# the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
 #
 # This file is distributed in the hope that it will be useful,
 # (at your option) any later version.
 #
 # This file is distributed in the hope that it will be useful,
@@ -11,7 +11,7 @@
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+# along with this file.  If not, see <https://www.gnu.org/licenses/>.
 #
 # As a special exception to the GNU General Public License,
 # this file may be distributed as part of a program that
 #
 # As a special exception to the GNU General Public License,
 # this file may be distributed as part of a program that
 
 
 # Specification in the form of a command-line invocation:
 
 
 # Specification in the form of a command-line invocation:
-#   gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk.in --conditional-dependencies --libtool --macro-prefix=gl --no-vc-files copysignf getopt-gnu ldexpf strcase
+# gnulib-tool --import \
+#  --lib=libgnu \
+#  --source-base=lib \
+#  --m4-base=m4 \
+#  --doc-base=doc \
+#  --tests-base=tests \
+#  --aux-dir=. \
+#  --makefile-name=gnulib.mk.in \
+#  --conditional-dependencies \
+#  --libtool \
+#  --macro-prefix=gl \
+#  --no-vc-files \
+#  copysignf \
+#  getopt-gnu \
+#  inline \
+#  ldexpf \
+#  strcase
 
 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([])
 gl_MODULES([
   copysignf
   getopt-gnu
 
 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([])
 gl_MODULES([
   copysignf
   getopt-gnu
+  inline
   ldexpf
   strcase
 ])
   ldexpf
   strcase
 ])
diff --git a/src/.gitignore b/src/.gitignore
new file mode 100644 (file)
index 0000000..b5b19dd
--- /dev/null
@@ -0,0 +1 @@
+/upkgopts.h
index 652614a795a4c937b215e8620a75a430eac4e4cd..093a41fd6ee907b22ee4742bcf821485e8ad31dd 100644 (file)
@@ -1,21 +1,22 @@
 /*
 /*
- *  upkg: tool for manipulating Unreal Tournament packages.
- *  Copyright © 2009-2012, 2020 Nick Bowler
+ * upkg: tool for manipulating Unreal Tournament packages.
+ * Copyright © 2009-2012, 2020, 2022 Nick Bowler
  *
  *
- *  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 3 of the License, or
- *  (at your option) any later version.
+ * 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 3 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.
+ * 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, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
  */
 
+#include <config.h>
 #include <stdio.h>
 #include <glib-object.h>
 
 #include <stdio.h>
 #include <glib-object.h>
 
index ed633a88ef69cf5568fe5b8bf0edc2d43a33dd15..8e60828ab0870c149e7b2ff4c9c1153a119acb6a 100644 (file)
@@ -1,28 +1,36 @@
 %alltop{
 /*
 %alltop{
 /*
- *  upkg: tool for manipulating Unreal Tournament packages.
- *  Copyright © 2020 Nick Bowler
+ * upkg: tool for manipulating Unreal Tournament packages.
+ * Copyright © 2020, 2022 Nick Bowler
  *
  *
- *  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 3 of the License, or
- *  (at your option) any later version.
+ * 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 3 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.
+ * 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, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 %}
 
  */
 %}
 
+%ctop{
+#include <config.h>
+%}
+
 %{
 %{
-#include <stdint.h>
+#include <inttypes.h>
 #include <uobject/loadable.h>
 #include <uobject/exportable.h>
 #include "pack.h"
 #include <uobject/loadable.h>
 #include <uobject/exportable.h>
 #include "pack.h"
+
+#ifndef SIZE_MAX
+#  define SIZE_MAX ((size_t)-1)
+#endif
 %}
 
 %h{
 %}
 
 %h{
index c9094e71912a5a35e750884ca4f5207a41fb8ce8..ef1cff1d64657828651b37d571ee2f548107c42d 100644 (file)
@@ -1,21 +1,22 @@
 /*
 /*
- *  upkg: tool for manipulating Unreal Tournament packages.
- *  Copyright © 2009-2011 Nick Bowler
+ * upkg: tool for manipulating Unreal Tournament packages.
+ * Copyright © 2009-2011, 2022 Nick Bowler
  *
  *
- *  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 3 of the License, or
- *  (at your option) any later version.
+ * 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 3 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.
+ * 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, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
  */
 
+#include <config.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
index 449a48027d8186a90645bdf549fa4ecbde60763c..ecd306278e75000591647699ccad20144a372bea 100644 (file)
@@ -1,21 +1,22 @@
 /*
 /*
- *  upkg: tool for manipulating Unreal Tournament packages.
- *  Copyright © 2009-2011, 2019 Nick Bowler
+ * upkg: tool for manipulating Unreal Tournament packages.
+ * Copyright © 2009-2011, 2019, 2022 Nick Bowler
  *
  *
- *  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 3 of the License, or
- *  (at your option) any later version.
+ * 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 3 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.
+ * 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, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
  */
 
+#include <config.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <libmodplug/modplug.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <libmodplug/modplug.h>
index f0bde09f4ace15b4aa0c48225e245c03e13afa67..e0d13b6e7428854d509947349633ed6070ef25e1 100644 (file)
@@ -1,23 +1,27 @@
 %alltop{
 /*
 %alltop{
 /*
- *  upkg: tool for manipulating Unreal Tournament packages.
- *  Copyright © 2009-2011 Nick Bowler
+ * upkg: tool for manipulating Unreal Tournament packages.
+ * Copyright © 2009-2012, 2022 Nick Bowler
  *
  *
- *  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 3 of the License, or
- *  (at your option) any later version.
+ * 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 3 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.
+ * 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, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 %}
 
  */
 %}
 
+%ctop{
+#include <config.h>
+%}
+
 %{
 #include <stdio.h>
 #include <string.h>
 %{
 #include <stdio.h>
 #include <string.h>
index ce5745926c773847dc0d9793dea451bd3233855f..79712a69ba7df89b92282ebd91e9dbe4dc295f5f 100644 (file)
@@ -1,23 +1,27 @@
 %alltop{
 /*
 %alltop{
 /*
- *  upkg: tool for manipulating Unreal Tournament packages.
- *  Copyright © 2011, 2020 Nick Bowler
+ * upkg: tool for manipulating Unreal Tournament packages.
+ * Copyright © 2011, 2020, 2022 Nick Bowler
  *
  *
- *  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 3 of the License, or
- *  (at your option) any later version.
+ * 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 3 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.
+ * 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, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 %}
 
  */
 %}
 
+%ctop{
+#include <config.h>
+%}
+
 %{
 #include <stdio.h>
 #include <stdlib.h>
 %{
 #include <stdio.h>
 #include <stdlib.h>
index fd0a060e29a31cde7f5e2b4b0755c4bdb642f326..71c4a39356d02285aa8514be5db434f66fae8101 100644 (file)
@@ -1,23 +1,27 @@
 %alltop{
 /*
 %alltop{
 /*
- *  upkg: tool for manipulating Unreal Tournament packages.
- *  Copyright © 2011 Nick Bowler
+ * upkg: tool for manipulating Unreal Tournament packages.
+ * Copyright © 2012, 2022 Nick Bowler
  *
  *
- *  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 3 of the License, or
- *  (at your option) any later version.
+ * 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 3 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.
+ * 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, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 %}
 
  */
 %}
 
+%ctop{
+#include <config.h>
+%}
+
 %{
 #include <stdio.h>
 #include <stdlib.h>
 %{
 #include <stdio.h>
 #include <stdlib.h>
index 630013e0f21031e3a45839715e4ed1f515759d50..cc6b2712f776f89e63a576f05b4f532608ca474e 100644 (file)
@@ -1,23 +1,27 @@
 %alltop{
 /*
 %alltop{
 /*
- *  upkg: tool for manipulating Unreal Tournament packages.
- *  Copyright © 2009-2012, 2020 Nick Bowler
+ * upkg: tool for manipulating Unreal Tournament packages.
+ * Copyright © 2009-2012, 2020, 2022 Nick Bowler
  *
  *
- *  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 3 of the License, or
- *  (at your option) any later version.
+ * 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 3 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.
+ * 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, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 %}
 
  */
 %}
 
+%ctop{
+#include <config.h>
+%}
+
 %{
 #include <stdio.h>
 #include <stdlib.h>
 %{
 #include <stdio.h>
 #include <stdlib.h>
@@ -36,7 +40,7 @@ struct engine_texture_data {
        unsigned long width, height;
 
        unsigned long datalen;
        unsigned long width, height;
 
        unsigned long datalen;
-       unsigned char data[];
+       unsigned char data[FLEXIBLE_ARRAY_MEMBER];
 };
 
 %}
 };
 
 %}
index c87f66887a0c95ad071b328953a535a480c79699..60dcab09f83af704ad1b4cb91ad0e7f5358058d6 100644 (file)
@@ -1,21 +1,22 @@
 /*
 /*
- *  upkg: tool for manipulating Unreal Tournament packages.
- *  Copyright © 2009-2011 Nick Bowler
+ * upkg: tool for manipulating Unreal Tournament packages.
+ * Copyright © 2009-2012, 2022 Nick Bowler
  *
  *
- *  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 3 of the License, or
- *  (at your option) any later version.
+ * 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 3 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.
+ * 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, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
  */
 
+#include <config.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
 #define MIN(a, b) ((a) < (b) ? (a) : (b))
 
 
 #define MIN(a, b) ((a) < (b) ? (a) : (b))
 
+#define UPKG_HDR_OFFSET_VERSION        4
+#define UPKG_HDR_OFFSET_LICENSE        6
+#define UPKG_HDR_OFFSET_FLAGS          8
+#define UPKG_HDR_OFFSET_NAME_COUNT    12
+#define UPKG_HDR_OFFSET_NAME_OFFSET   16
+#define UPKG_HDR_OFFSET_EXPORT_COUNT  20
+#define UPKG_HDR_OFFSET_EXPORT_OFFSET 24
+#define UPKG_HDR_OFFSET_IMPORT_COUNT  28
+#define UPKG_HDR_OFFSET_IMPORT_OFFSET 32
+
 /*
  * Print a message and execute some statement(s) if the expression evaluates
  * to zero.  Intended to help verify that assumed constraints on the file
 /*
  * Print a message and execute some statement(s) if the expression evaluates
  * to zero.  Intended to help verify that assumed constraints on the file
@@ -131,28 +142,23 @@ size_t upkg_decode_index(long *val, const unsigned char *bytes, size_t n)
        return 0;
 }
 
        return 0;
 }
 
-static struct upkg_priv *init_upkg(unsigned char hdr[static UPKG_HDR_SIZE])
+static struct upkg_priv *init_upkg(const unsigned char *hdr)
 {
 {
-       struct upkg_priv *pkg;
+       struct upkg_priv *pkg, tmp = {0};
+
+       tmp.pub.version      = unpack_16_le(hdr+UPKG_HDR_OFFSET_VERSION);
+       tmp.pub.license      = unpack_16_le(hdr+UPKG_HDR_OFFSET_LICENSE);
+       tmp.pub.flags        = unpack_32_le(hdr+UPKG_HDR_OFFSET_FLAGS);
+       tmp.pub.name_count   = unpack_32_le(hdr+UPKG_HDR_OFFSET_NAME_COUNT);
+       tmp.pub.export_count = unpack_32_le(hdr+UPKG_HDR_OFFSET_EXPORT_COUNT);
+       tmp.pub.import_count = unpack_32_le(hdr+UPKG_HDR_OFFSET_IMPORT_COUNT);
+       tmp.name_offset      = unpack_32_le(hdr+UPKG_HDR_OFFSET_NAME_OFFSET);
+       tmp.export_offset    = unpack_32_le(hdr+UPKG_HDR_OFFSET_EXPORT_OFFSET);
+       tmp.import_offset    = unpack_32_le(hdr+UPKG_HDR_OFFSET_IMPORT_OFFSET);
 
        pkg = malloc(sizeof *pkg);
 
        pkg = malloc(sizeof *pkg);
-       if (!pkg)
-               return NULL;
-
-       *pkg = (struct upkg_priv) {
-               .pub = {
-                       .version      = unpack_16_le(hdr+4),
-                       .license      = unpack_16_le(hdr+6),
-                       .flags        = unpack_32_le(hdr+8),
-                       .name_count   = unpack_32_le(hdr+12),
-                       .export_count = unpack_32_le(hdr+20),
-                       .import_count = unpack_32_le(hdr+28),
-               },
-
-               .name_offset   = unpack_32_le(hdr+16),
-               .export_offset = unpack_32_le(hdr+24),
-               .import_offset = unpack_32_le(hdr+32),
-       };
+       if (pkg)
+               *pkg = tmp;
 
        return pkg;
 }
 
        return pkg;
 }
index b9a5c43d431504d96134b12771cefca6bcf07e33..9ded83b5710d48673e68c02ce1733417580e0f97 100644 (file)
@@ -20,6 +20,7 @@
    02110-1301 USA.
 */
 
    02110-1301 USA.
 */
 
+#include <config.h>
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
index 541e6980017a7aa7220a7e393bc6a08642739145..6e75f252bfd64c5a33bf33281382d407737885e3 100644 (file)
@@ -1,21 +1,22 @@
 /*
 /*
- *  upkg: tool for manipulating Unreal Tournament packages.
- *  Copyright © 2009-2011 Nick Bowler
+ * upkg: tool for manipulating Unreal Tournament packages.
+ * Copyright © 2009-2011, 2022 Nick Bowler
  *
  *
- *  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 3 of the License, or
- *  (at your option) any later version.
+ * 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 3 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.
+ * 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, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
  */
 
+#include <config.h>
 #include <stdio.h>
 #include "exportable.h"
 
 #include <stdio.h>
 #include "exportable.h"
 
index 1e41c465157c198cbd4cfd4a3641ef0cccb25c8d..d0fef5843193501e593f69d85bc23232a7854490 100644 (file)
@@ -1,21 +1,22 @@
 /*
 /*
- *  upkg: tool for manipulating Unreal Tournament packages.
- *  Copyright © 2009-2011 Nick Bowler
+ * upkg: tool for manipulating Unreal Tournament packages.
+ * Copyright © 2009-2011, 2022 Nick Bowler
  *
  *
- *  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 3 of the License, or
- *  (at your option) any later version.
+ * 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 3 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.
+ * 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, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
  */
 
+#include <config.h>
 #include "loadable.h"
 
 GType u_object_loadable_get_type(void)
 #include "loadable.h"
 
 GType u_object_loadable_get_type(void)
index 057d1d0080ee23d685baf05113862208a8cace3d..1d41d0758be650eb5505e57947cdc6d9c9a6cf25 100644 (file)
@@ -1,21 +1,22 @@
 /*
 /*
- *  upkg: tool for manipulating Unreal Tournament packages.
- *  Copyright © 2009-2011 Nick Bowler
+ * upkg: tool for manipulating Unreal Tournament packages.
+ * Copyright © 2009-2012, 2022 Nick Bowler
  *
  *
- *  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 3 of the License, or
- *  (at your option) any later version.
+ * 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 3 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.
+ * 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, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
  */
 
+#include <config.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -79,19 +80,16 @@ int u_object_module_exit(void)
 
 static int lookup_module(GTypeModule **out, const char *name)
 {
 
 static int lookup_module(GTypeModule **out, const char *name)
 {
-       struct { GTypeModule pkg; char buf[]; } *search_key;
-       GTypeModule *result;
+       GTypeModule *result, key = {0};
+       char *buf;
 
 
-       search_key = malloc(sizeof *search_key + strlen(name) + 1);
-       if (!search_key)
+       buf = malloc(strlen(name) + 1);
+       if (!buf)
                return -1;
 
                return -1;
 
-       search_key->pkg = (GTypeModule) {
-               .name = str_cpy_lower(search_key->buf, name),
-       };
-
-       result = avl_find(package_tree, search_key);
-       free(search_key);
+       key.name = str_cpy_lower(buf, name);
+       result = avl_find(package_tree, &key);
+       free(buf);
 
        *out = result;
        return 0;
 
        *out = result;
        return 0;
index 3b8091bbbdd9a20a4503071d7ae49993f57f818c..30a42cc062550454a8c6be3de285d5f258012e1c 100644 (file)
@@ -1,21 +1,22 @@
 /*
 /*
- *  upkg: tool for manipulating Unreal Tournament packages.
- *  Copyright © 2009-2011 Nick Bowler
+ * upkg: tool for manipulating Unreal Tournament packages.
+ * Copyright © 2009-2011, 2022 Nick Bowler
  *
  *
- *  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 3 of the License, or
- *  (at your option) any later version.
+ * 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 3 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.
+ * 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, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
  */
 
+#include <config.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -158,9 +159,9 @@ GTypeModule *u_pkg_open(const char *name)
        return mod;
 }
 
        return mod;
 }
 
-bool u_pkg_is_native(GTypeModule *m)
+int u_pkg_is_native(GTypeModule *m)
 {
        struct upkg_priv *priv = U_PKG_GET_PRIV(m);
 
 {
        struct upkg_priv *priv = U_PKG_GET_PRIV(m);
 
-       return priv->native;
+       return !!priv->native;
 }
 }
index eb217aad2626aa606d4051f7ae38b51ad81f1949..74a0b9dc902e47037bd9fa0a2163151a879187de 100644 (file)
@@ -1,26 +1,25 @@
 /*
 /*
- *  upkg: tool for manipulating Unreal Tournament packages.
- *  Copyright © 2009-2011 Nick Bowler
+ * upkg: tool for manipulating Unreal Tournament packages.
+ * Copyright © 2009-2011, 2022 Nick Bowler
  *
  *
- *  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 3 of the License, or
- *  (at your option) any later version.
+ * 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 3 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.
+ * 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, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #ifndef U_OBJECT_PACKAGE_H_
 #define U_OBJECT_PACKAGE_H_
 
 #include <glib-object.h>
  */
 
 #ifndef U_OBJECT_PACKAGE_H_
 #define U_OBJECT_PACKAGE_H_
 
 #include <glib-object.h>
-#include <stdbool.h>
 
 #define U_PKG_TYPE (u_pkg_get_type())
 #define U_PKG(obj) \
 
 #define U_PKG_TYPE (u_pkg_get_type())
 #define U_PKG(obj) \
@@ -49,6 +48,6 @@ struct UPkgClass {
 GType u_pkg_get_type(void);
 GTypeModule *u_pkg_open(const char *name);
 
 GType u_pkg_get_type(void);
 GTypeModule *u_pkg_open(const char *name);
 
-bool u_pkg_is_native(GTypeModule *pkg);
+int u_pkg_is_native(GTypeModule *pkg);
 
 #endif
 
 #endif
index 3bada241cf9e7ed06a4c71c76dff59685fc7a275..cf07735d3b500fa935a1b86fc79f835e309c017d 100644 (file)
@@ -1,19 +1,19 @@
 /*
 /*
- *  upkg: tool for manipulating Unreal Tournament packages.
- *  Copyright © 2009-2012, 2015, 2020 Nick Bowler
+ * upkg: tool for manipulating Unreal Tournament packages.
+ * Copyright © 2009-2012, 2015, 2020, 2022 Nick Bowler
  *
  *
- *  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 3 of the License, or
- *  (at your option) any later version.
+ * 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 3 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.
+ * 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, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #include <config.h>
  */
 
 #include <config.h>
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <math.h>
 #include <stdarg.h>
 #include <string.h>
 #include <math.h>
 #include <stdarg.h>
-#include <stdbool.h>
 #include <inttypes.h>
 #include <assert.h>
 #include <glib-object.h>
 #include <inttypes.h>
 #include <assert.h>
 #include <glib-object.h>
 #define U_OBJECT_GET_PRIV(o) \
        G_TYPE_INSTANCE_GET_PRIVATE(o, U_TYPE_OBJECT, struct u_object_priv)
 
 #define U_OBJECT_GET_PRIV(o) \
        G_TYPE_INSTANCE_GET_PRIVATE(o, U_TYPE_OBJECT, struct u_object_priv)
 
+#ifndef SIZE_MAX
+#  define SIZE_MAX ((size_t)-1)
+#endif
 
 struct prop_head {
        const char *prop_name, *struct_name;
        unsigned long size, array_idx;
 
 struct prop_head {
        const char *prop_name, *struct_name;
        unsigned long size, array_idx;
-       bool tag_msb;
+       gboolean tag_msb;
 
        enum {
                PROPERTY_END,
 
        enum {
                PROPERTY_END,
index 819dbc2e410b8df7c9b04c449beb067f08b7782f..ac73ca4c9d89abb33f5d9a25fd600b0c559eca4d 100644 (file)
@@ -1,19 +1,19 @@
 /*
 /*
- *  Functions for handling UObject package search paths.
- *  Copyright © 2009-2011 Nick Bowler
+ * Functions for handling UObject package search paths.
+ * Copyright © 2009-2011, 2022 Nick Bowler
  *
  *
- *  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 3 of the License, or
- *  (at your option) any later version.
+ * 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 3 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.
+ * 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, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #include <config.h>
  */
 
 #include <config.h>
@@ -187,7 +187,7 @@ struct foreach_state {
        const char *name;
        struct upkg *f;
        size_t sz;
        const char *name;
        struct upkg *f;
        size_t sz;
-       char buf[];
+       char buf[FLEXIBLE_ARRAY_MEMBER];
 };
 
 static int foreachfile(const char *filename, void *_st)
 };
 
 static int foreachfile(const char *filename, void *_st)
index 55d13f8f37f71c1c0d7449ed3bb259f2edfbe9c2..db9a747d39eb1ccedaaa6ed49d61f45b5a09c418 100644 (file)
@@ -1,19 +1,19 @@
 /*
 /*
- *  upkg: tool for manipulating Unreal Tournament packages.
- *  Copyright © 2009-2011 Nick Bowler
+ * upkg: tool for manipulating Unreal Tournament packages.
+ * Copyright © 2009-2012, 2022 Nick Bowler
  *
  *
- *  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 3 of the License, or
- *  (at your option) any later version.
+ * 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 3 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.
+ * 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, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #include <config.h>
  */
 
 #include <config.h>
@@ -34,6 +34,8 @@
 #include <uobject/package.h>
 #include <uobject/vfs.h>
 
 #include <uobject/package.h>
 #include <uobject/vfs.h>
 
+#include "help.h"
+
 enum {
        MODE_INFO,
        MODE_LIST,
 enum {
        MODE_INFO,
        MODE_LIST,
@@ -44,50 +46,49 @@ enum {
 int verbose = 0;
 
 static const char *progname = "upkg";
 int verbose = 0;
 
 static const char *progname = "upkg";
-static const char *sopts = "ilxvf:VH";
-static const struct option lopts[] = {
-       { "info",     0, NULL, 'i' },
-       { "list",     0, NULL, 'l' },
-       { "export",   0, NULL, 'x' },
-       { "file",     1, NULL, 'f' },
-       { "verbose",  0, NULL, 'v' },
-       { "version",  0, NULL, 'V' },
-       { "help",     0, NULL, 'H' },
-       { 0 }
-};
 
 
-void print_version(void)
+#include "upkgopts.h"
+static const char sopts[] = SOPT_STRING;
+static const struct option lopts[] = { LOPTS_INITIALIZER, {0} };
+
+static void print_version(void)
 {
        printf("%s\n", PACKAGE_STRING);
 {
        printf("%s\n", PACKAGE_STRING);
-       puts("\
-Copyright (C) 2009 Nick Bowler.\n\
-License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\n\
-This is free software: you are free to change and redistribute it.\n\
-There is NO WARRANTY, to the extent permitted by law."
-       );
+       puts("Copyright (C) 2022 Nick Bowler.");
+       puts("License GPLv3+: GNU GPL version 3 or any later version.");
+       puts("This is free software: you are free to change and redistribute it.");
+       puts("There is NO WARRANTY, to the extent permitted by law.");
 }
 
 }
 
-void print_usage(FILE *f)
+static void print_usage(FILE *f)
 {
        fprintf(f, "Usage: %s [options] [object ...]\n", progname);
 {
        fprintf(f, "Usage: %s [options] [object ...]\n", progname);
+       if (f != stdout)
+               fprintf(f, "Try %s --help for more information.\n", progname);
 }
 
 }
 
-void print_help(void)
+static void print_help(void)
 {
 {
+       const struct option *opt;
+
        print_usage(stdout);
        print_usage(stdout);
-       puts("Detailed help coming soon.  Until then, I'll just list my options.");
-       for (unsigned i = 0; lopts[i].name; i++) {
-               const struct option *o = &lopts[i];
-               printf("\t--%s", o->name);
-
-               if (o->has_arg == 1) {
-                       printf("=val");
-               } else if (o->has_arg == 2) {
-                       printf("[=val]");
-               }
 
 
-               printf(" (-%c)\n", o->val);
+       putchar('\n');
+       puts("Options:");
+       for (opt = lopts; opt->name; opt++) {
+               struct lopt_help help;
+
+               if (!lopt_get_help(opt, &help))
+                       continue;
+
+               help_print_option(opt, help.arg, help.desc, 20);
        }
        }
+       putchar('\n');
+
+       puts("For more information, see the upkg(1) man page.");
+       putchar('\n');
+
+       printf("Report bugs to <%s>.\n", PACKAGE_BUGREPORT);
 }
 
 static void print_upkg_flags(const char *prefix, unsigned long flags)
 }
 
 static void print_upkg_flags(const char *prefix, unsigned long flags)
@@ -170,7 +171,7 @@ static void print_upkg_object_flags(const char *prefix, unsigned long flags)
                printf("%sDebugDestroy\n", prefix);
 }
 
                printf("%sDebugDestroy\n", prefix);
 }
 
-void print_guid(unsigned char guid[static 16])
+static void print_guid(unsigned char *guid)
 {
        for (unsigned i = 0; i < 16; i++) {
                printf("%02hhx", guid[i]);
 {
        for (unsigned i = 0; i < 16; i++) {
                printf("%02hhx", guid[i]);
diff --git a/src/upkgopts.opt b/src/upkgopts.opt
new file mode 100644 (file)
index 0000000..2b19e98
--- /dev/null
@@ -0,0 +1,20 @@
+-i, --info
+Display information about the package.
+
+-l, --list
+List objects belonging to the package.
+
+-x, --export
+Export objects from the package.
+
+-v, --verbose
+Display additional information on standard output.
+
+-f, --file=PKG
+Load the specified package file.
+
+-V, --version
+Print a version message and then exit.
+
+-H, --help
+Print this message and then exit.
index c99862463f3919773a958cacf3625fbdda6a0981..9919b1b66ea501126ccaf20fbaa2a0bf22afe481 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Helper functions for test programs.
 /*
  * Helper functions for test programs.
- * Copyright © 2012 Nick Bowler
+ * Copyright © 2012, 2022 Nick Bowler
  *
  * 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
  *
  * 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
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * 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, see <http://www.gnu.org/licenses/>.
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
  */
+
+#include <config.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
 #include <stdlib.h>
 #include <ctype.h>
+#include <getopt.h>
 
 #include "common.h"
 
 #include "common.h"
+#include "help.h"
 
 /*
  * Decode a hexadecimal string into a sequence of bytes.  If there are an
 
 /*
  * Decode a hexadecimal string into a sequence of bytes.  If there are an
@@ -35,7 +40,7 @@ size_t test_decode_hex(const char *hex, unsigned char *buf, size_t n)
        char tmp[] = "00";
 
        for (len = 0; hex[len]; len++) {
        char tmp[] = "00";
 
        for (len = 0; hex[len]; len++) {
-               if (!isxdigit(hex[len]))
+               if (!isxdigit((unsigned char)hex[len]))
                        return -1;
        }
 
                        return -1;
        }
 
@@ -55,3 +60,23 @@ size_t test_decode_hex(const char *hex, unsigned char *buf, size_t n)
 
        return count;
 }
 
        return count;
 }
+
+void test_print_version(const char *program)
+{
+       printf("%s (%s) %s\n", program, PACKAGE_NAME, PACKAGE_VERSION);
+       puts("Copyright (C) 2022 Nick Bowler.");
+       puts("License GPLv3+: GNU GPL version 3 or any later version.");
+       puts("This is free software: you are free to change and redistribute it.");
+       puts("There is NO WARRANTY, to the extent permitted by law.");
+}
+
+void test_print_options(const struct option *lopts)
+{
+       const struct option *opt;
+
+       puts("\nOptions:");
+       for (opt = lopts; opt->val; opt++) {
+               if (help_print_optstring(opt, "ARG", 20))
+                       putchar('\n');
+       }
+}
index 907ee5a6931c851964717c99c07c6174cea86d38..675ebe217131e43f9d6cff80db88d62c23a431e7 100644 (file)
@@ -1,6 +1,29 @@
+/*
+ * Helper functions for test programs.
+ * Copyright © 2012, 2022 Nick Bowler
+ *
+ * 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 3 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, see <https://www.gnu.org/licenses/>.
+ */
+
 #ifndef TEST_COMMON_H_
 #define TEST_COMMON_H_
 
 #ifndef TEST_COMMON_H_
 #define TEST_COMMON_H_
 
+struct option;
+
+void test_print_version(const char *program);
+void test_print_options(const struct option *lopts);
+
 size_t test_decode_hex(const char *hex, unsigned char *buf, size_t n);
 
 #endif
 size_t test_decode_hex(const char *hex, unsigned char *buf, size_t n);
 
 #endif
index c072a07c25f72a41c800aa5a7ef368dc02489d3e..1d4643beeba5357b8c6acabc6caae2d382d58744 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Tool for decoding compact index values for testing.
 /*
  * Tool for decoding compact index values for testing.
- * Copyright © 2012 Nick Bowler
+ * Copyright © 2012, 2022 Nick Bowler
  *
  * 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
  *
  * 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
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * 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, see <http://www.gnu.org/licenses/>.
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #include <config.h>
  */
 
 #include <config.h>
@@ -38,13 +38,10 @@ static void print_usage(FILE *f)
        fprintf(f, "Usage: %s [options] index [index ...]\n", progname);
 }
 
        fprintf(f, "Usage: %s [options] index [index ...]\n", progname);
 }
 
-static void print_version(void)
+static void print_help(void)
 {
 {
-       printf("%s (%s) %s\n", PROGNAME, PACKAGE_NAME, PACKAGE_VERSION);
-       puts("Copyright (C) 2012 Nick Bowler.");
-       puts("License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.");
-       puts("This is free software: you are free to change and redistribute it.");
-       puts("There is NO WARRANTY, to the extent permitted by law.");
+       print_usage(stdout);
+       test_print_options(lopts);
 }
 
 static void print_bytes(FILE *f, int indent, void *buf, size_t n)
 }
 
 static void print_bytes(FILE *f, int indent, void *buf, size_t n)
@@ -52,7 +49,7 @@ static void print_bytes(FILE *f, int indent, void *buf, size_t n)
        fprintf(f, "%*s", indent, "");
 
        if (n == 0) {
        fprintf(f, "%*s", indent, "");
 
        if (n == 0) {
-               printf("(empty)\n");
+               fprintf(f, "(empty)\n");
                return;
        }
 
                return;
        }
 
@@ -78,7 +75,7 @@ static int print_index(const char *hex)
                                progname, hex);
                goto out;
        }
                                progname, hex);
                goto out;
        }
-               
+
        rc = upkg_decode_index(&index, buf, n);
        if (rc == 0) {
                fprintf(stderr, "%s: invalid index encoding:\n", progname);
        rc = upkg_decode_index(&index, buf, n);
        if (rc == 0) {
                fprintf(stderr, "%s: invalid index encoding:\n", progname);
@@ -106,10 +103,10 @@ int main(int argc, char **argv)
        while ((opt = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) {
                switch (opt) {
                case 'V':
        while ((opt = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) {
                switch (opt) {
                case 'V':
-                       print_version();
+                       test_print_version(PROGNAME);
                        return EXIT_SUCCESS;
                case 'H':
                        return EXIT_SUCCESS;
                case 'H':
-                       print_usage(stdout);
+                       print_help();
                        return EXIT_SUCCESS;
                default:
                        print_usage(stderr);
                        return EXIT_SUCCESS;
                default:
                        print_usage(stderr);
index 6824fd09263fd5ea3e7186f9db01ee2809873783..34c50cebc187f2bb3348418957e2c70448159473 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Tool for testing PCX run-length encoding.
 /*
  * Tool for testing PCX run-length encoding.
- * Copyright © 2012 Nick Bowler
+ * Copyright © 2012, 2022 Nick Bowler
  *
  * 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
  *
  * 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
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * 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, see <http://www.gnu.org/licenses/>.
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #include <config.h>
  */
 
 #include <config.h>
@@ -41,13 +41,10 @@ static void print_usage(FILE *f)
        fprintf(f, "Usage: %s [options] bytes [bytes ...]\n", progname);
 }
 
        fprintf(f, "Usage: %s [options] bytes [bytes ...]\n", progname);
 }
 
-static void print_version(void)
+static void print_help(void)
 {
 {
-       printf("%s (%s) %s\n", PROGNAME, PACKAGE_NAME, PACKAGE_VERSION);
-       puts("Copyright (C) 2012 Nick Bowler.");
-       puts("License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.");
-       puts("This is free software: you are free to change and redistribute it.");
-       puts("There is NO WARRANTY, to the extent permitted by law.");
+       print_usage(stdout);
+       test_print_options(lopts);
 }
 
 static void rle_error(const unsigned char *raw, size_t n, const char *str)
 }
 
 static void rle_error(const unsigned char *raw, size_t n, const char *str)
@@ -163,10 +160,10 @@ int main(int argc, char **argv)
        while ((opt = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) {
                switch (opt) {
                case 'V':
        while ((opt = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) {
                switch (opt) {
                case 'V':
-                       print_version();
+                       test_print_version(PROGNAME);
                        return EXIT_SUCCESS;
                case 'H':
                        return EXIT_SUCCESS;
                case 'H':
-                       print_usage(stdout);
+                       print_help();
                        return EXIT_SUCCESS;
                default:
                        print_usage(stderr);
                        return EXIT_SUCCESS;
                default:
                        print_usage(stderr);
diff --git a/tests/data/hatch2x2.pcx b/tests/data/hatch2x2.pcx
new file mode 100644 (file)
index 0000000..b5bead6
Binary files /dev/null and b/tests/data/hatch2x2.pcx differ
diff --git a/tests/data/test0.utx b/tests/data/test0.utx
new file mode 100644 (file)
index 0000000..433c56c
Binary files /dev/null and b/tests/data/test0.utx differ
diff --git a/tests/engine-pcx-rlencode.sh b/tests/engine-pcx-rlencode.sh
deleted file mode 100644 (file)
index 3a05444..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/sh
-#
-# Check corner cases of the PCX run-length encoder.
-# Copyright © 2012 Nick Bowler
-#
-# License WTFPL2: Do What The Fuck You Want To Public License, version 2.
-# This is free software: you are free to do what the fuck you want to.
-# There is NO WARRANTY, to the extent permitted by law.
-
-pcxrle=test/pcxrle$EXEEXT
-
-$pcxrle 00   || exit 1
-$pcxrle 0000 || exit 1
-$pcxrle c100 || exit 1
-
-# Test RLE rollover
-t1=00
-t2=$t1$t1
-t4=$t2$t2
-t8=$t4$t4
-t16=$t8$t8
-t32=$t16$t16
-t64=$t32$t32
-
-$pcxrle "$t32$t16$t8$t4$t2$t1" || exit 1 # maximum possible run
-$pcxrle "$t64" || exit 1
-$pcxrle "$t64$t64$t64" || exit 1
diff --git a/tests/export.at b/tests/export.at
new file mode 100644 (file)
index 0000000..09f1397
--- /dev/null
@@ -0,0 +1,26 @@
+# Copyright © 2022 Nick Bowler
+#
+# 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 3 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, see <https://www.gnu.org/licenses/>.
+
+AT_SETUP([export texture hatch2x2])
+
+# Until we implement all properties we must ignore warnings printed to stderr
+AT_CHECK([upkg -xf "$srcdir/tests/data/test0.utx" test0.testgroup.hatch2x2],
+[0], [exporting test0.testgroup.hatch2x2 to hatch2x2.pcx
+], [ignore])
+
+dnl TODO make this independent of irrelevant file format details
+AT_CHECK([cmp "$srcdir/tests/data/hatch2x2.pcx" hatch2x2.pcx])
+
+AT_CLEANUP
diff --git a/tests/functions.at b/tests/functions.at
new file mode 100644 (file)
index 0000000..fe8632e
--- /dev/null
@@ -0,0 +1,62 @@
+# Copyright © 2012, 2022 Nick Bowler
+#
+# 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 3 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, see <https://www.gnu.org/licenses/>.
+
+AT_SETUP([upkg_decode_index])
+AT_KEYWORDS([core function])
+
+# various encodings of zero
+m4_foreach_w([INDEX], [00 4000 408000 40808000 4080808000],
+  [AT_CHECK([decodeindex INDEX], [0], [0
+])
+])
+
+# truncated encodings of zero
+m4_foreach_w([INDEX], ['' 40 4080 408080 40808080],
+  [AT_CHECK([decodeindex INDEX], [1], [ignore], [ignore])
+])
+
+# overlong encoding of zero
+AT_CHECK([decodeindex 408080808000], [1], [ignore], [ignore])
+
+AT_CLEANUP
+
+AT_SETUP([pcx_write_scanline run-length encoding])
+AT_KEYWORDS([engine function])
+
+AT_CHECK([pcxrle 00], [0], [00
+])
+AT_CHECK([pcxrle 0000], [0], [c200
+])
+AT_CHECK([pcxrle c100], [0], [c1c100
+])
+
+zero1=00
+zero4=$zero1$zero1$zero1$zero1
+zero16=$zero4$zero4$zero4$zero4
+zero63=$zero16$zero16$zero16$zero4$zero4$zero4$zero1$zero1$zero1
+zero64=$zero16$zero16$zero16$zero16
+zero192=$zero64$zero64$zero64
+
+AT_CHECK([# maximum possible run
+pcxrle $zero63], [0], [ff00
+])
+AT_CHECK([# one more than maximum
+pcxrle $zero64], [0], [ff0000
+])
+AT_CHECK([# consecutive runs
+pcxrle $zero192], [0], [ff00ff00ff00c300
+])
+
+AT_CLEANUP
diff --git a/tests/libupkg-index-decode.sh b/tests/libupkg-index-decode.sh
deleted file mode 100644 (file)
index f5c913d..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/bin/sh
-#
-# Check various corner cases of upkg_decode_index.
-# Copyright © 2012 Nick Bowler
-#
-# License WTFPL2: Do What The Fuck You Want To Public License, version 2.
-# This is free software: you are free to do what the fuck you want to.
-# There is NO WARRANTY, to the extent permitted by law.
-
-decodeindex=test/decodeindex$EXEEXT
-scriptname=$0
-
-test_index() {
-       decode_cmd=`exec 3>&1
-               { $decodeindex "$1" 3>&-
-                       echo decode_status=$? >&3
-               } | { read val 3>&-
-                       echo decode_val=$val >&3
-               }`
-       eval "$decode_cmd"
-
-       case $# in
-       2)
-               (exit $decode_status) || return 1
-               if test x"$decode_val" != x"$2"; then
-                       printf '%s: result (%d) does not match expected (%d)\n' \
-                               "$scriptname" "$decode_val" "$2"
-                       return 1
-               fi
-               ;;
-       1)
-               if (exit $decode_status); then
-                       printf '%s: false positive on (%s), got (%d)\n' \
-                               "$scriptname" "$1" "$decode_val"
-                       return 1
-               fi
-               ;;
-       esac
-}
-
-test_index 00 0         || exit 1
-test_index 4000 0       || exit 1
-test_index 408000 0     || exit 1
-test_index 40808000 0   || exit 1
-test_index 4080808000 0 || exit 1
-
-# False positives
-test_index ''           || exit 1
-test_index 40           || exit 1
-test_index 4080         || exit 1
-test_index 408080       || exit 1
-test_index 40808080     || exit 1
-test_index 4080808080   || exit 1
-test_index 408080808000 || exit 1
diff --git a/testsuite.at b/testsuite.at
new file mode 100644 (file)
index 0000000..fbdb0c6
--- /dev/null
@@ -0,0 +1,22 @@
+AT_COPYRIGHT([Copyright © 2022 Nick Bowler])
+#
+# 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 3 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, see <https://www.gnu.org/licenses/>.
+
+AT_INIT
+AT_COLOR_TESTS
+
+AT_TESTED([upkg])
+
+m4_include([tests/functions.at])
+m4_include([tests/export.at])