-*.o
-*.lo
-*.la
+*.a
*.gobstamp
-Makefile
-Makefile.in
-.libs
+*.la
+*.lo
+*.o
.deps
.dirstamp
-/config.*
-/configure
+.libs
+/INSTALL
+/Makefile
+/Makefile.in
/aclocal.m4
+/atconfig
+/atlocal
/autom4te.cache
-/libtool
+/compile
+/config.*
+/configure
+/depcomp
+/exported.sh
+/install-sh
+/lib
/libltdl
+/libtool
+/libuobject.pc
/ltmain.sh
-/install-sh
-/depcomp
/missing
/mkinstalldirs
-/stamp-h1
-/compile
-/libuobject.pc
-/lib
+/package.m4
/snippet
-/upkg
-/test-suite.log
+/stamp-h1
/test-driver
-/exported.sh
+/test-suite.log
+/testsuite
+/testsuite.deps
+/testsuite.dir
+/testsuite.log
+/upkg
[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
- url = git://git.draconx.ca/dxcommon.git
+ url = https://git.draconx.ca/dxcommon.git
-# 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.
-AUTOMAKE_OPTIONS = parallel-tests color-tests
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
+CLEANFILES = $(EXTRA_LTLIBRARIES) $(EXTRA_LIBRARIES)
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)
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_OBJECTS): $(gnulib_headers)
uobjectdir = $(includedir)/uobject
uobject_HEADERS = src/uobject/uobject.h src/uobject/exportable.h \
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)
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
engine_la_LIBADD += $(LIBMODPLUG_LIBS)
endif
-check_LTLIBRARIES = libtest.la
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_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)
-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@)
$(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
.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)/common/snippet/autotest.mk
#!/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.
#
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}
+: ${AUTOMAKE=automake}
: ${GNULIB=gnulib}
: ${GIT=git}
: ${PERL=perl}
$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
- 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 \
- || 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
# 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
-Subproject commit 4705ffd69e7b7551bab4650f9e49756667be783b
+Subproject commit 262d3eaea39294df3f6172b28213e927e2f3b424
-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.
-AC_PREREQ(2.62)
+DX_PATCH_GNULIB
+
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_PROG_CC_C99
gl_EARLY
+AC_C_FLEXIBLE_ARRAY_MEMBER
+
LT_CONFIG_LTDL_DIR([libltdl])
LT_INIT([dlopen])
LTDL_INIT([nonrecursive])
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],
])
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
-.Dd June 17, 2010
-.Os libuobject
+.Dd December 1, 2023
.Dt UPKG \&1 "UObject Reference Manual"
+.Os libuobject
.Sh NAME
.Nm upkg
.Nd manipulate UObject packages
.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.
-.It Fl l , -list
+.It Fl l , \-list
List objects belonging to a package.
-.It Fl x , -export
+.It Fl x , \-export
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.
-.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.
-.It Fl V , -version
+.It Fl V , \-version
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
.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.
-Subproject commit 233419c39c6d13d84439b95766328a238ffb6518
+Subproject commit 8a1e1616f143ccebf13ea477a1d0a4040ce2ddc4
00gnulib.m4
+absolute-header.m4
copysignf.m4
exponentd.m4
exponentf.m4
exponentl.m4
extensions.m4
extern-inline.m4
+flexmember.m4
float_h.m4
fpieee.m4
getopt.m4
-gnulib-cache.m4~
gnulib-common.m4
gnulib-comp.m4
-gnulib-comp.m4~
gnulib-tool.m4
include_next.m4
+inline.m4
isnand.m4
isnanf.m4
isnanl.m4
mathfunc.m4
nocrash.m4
off_t.m4
+pid_t.m4
signbit.m4
ssize_t.m4
stddef_h.m4
strings_h.m4
sys_types_h.m4
unistd_h.m4
+vararrays.m4
warn-on-use.m4
wchar_t.m4
+zzgnulib.m4
-# 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
-# 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,
# 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
# 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
+ inline
ldexpf
strcase
])
--- /dev/null
+/upkgopts.h
/*
- * 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>
%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"
+
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t)-1)
+#endif
%}
%h{
/*
- * 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>
/*
- * 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>
%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>
%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>
%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>
%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>
unsigned long width, height;
unsigned long datalen;
- unsigned char data[];
+ unsigned char data[FLEXIBLE_ARRAY_MEMBER];
};
%}
/*
- * 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>
#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
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);
- 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;
}
02110-1301 USA.
*/
+#include <config.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
/*
- * 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"
/*
- * 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)
/*
- * 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>
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;
- 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;
/*
- * 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>
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);
- return priv->native;
+ return !!priv->native;
}
/*
- * 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>
-#include <stdbool.h>
#define U_PKG_TYPE (u_pkg_get_type())
#define U_PKG(obj) \
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
/*
- * 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 <string.h>
#include <math.h>
#include <stdarg.h>
-#include <stdbool.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)
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t)-1)
+#endif
struct prop_head {
const char *prop_name, *struct_name;
unsigned long size, array_idx;
- bool tag_msb;
+ gboolean tag_msb;
enum {
PROPERTY_END,
/*
- * 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>
const char *name;
struct upkg *f;
size_t sz;
- char buf[];
+ char buf[FLEXIBLE_ARRAY_MEMBER];
};
static int foreachfile(const char *filename, void *_st)
/*
- * 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 <uobject/package.h>
#include <uobject/vfs.h>
+#include "help.h"
+
enum {
MODE_INFO,
MODE_LIST,
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);
- 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);
+ 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);
- 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)
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]);
--- /dev/null
+-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.
/*
* 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
* 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 <getopt.h>
#include "common.h"
+#include "help.h"
/*
* Decode a hexadecimal string into a sequence of bytes. If there are an
char tmp[] = "00";
for (len = 0; hex[len]; len++) {
- if (!isxdigit(hex[len]))
+ if (!isxdigit((unsigned char)hex[len]))
return -1;
}
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');
+ }
+}
+/*
+ * 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_
+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
/*
* 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
* 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>
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)
fprintf(f, "%*s", indent, "");
if (n == 0) {
- printf("(empty)\n");
+ fprintf(f, "(empty)\n");
return;
}
progname, hex);
goto out;
}
-
+
rc = upkg_decode_index(&index, buf, n);
if (rc == 0) {
fprintf(stderr, "%s: invalid index encoding:\n", progname);
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':
- print_usage(stdout);
+ print_help();
return EXIT_SUCCESS;
default:
print_usage(stderr);
/*
* 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
* 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>
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)
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':
- print_usage(stdout);
+ print_help();
return EXIT_SUCCESS;
default:
print_usage(stderr);
+++ /dev/null
-#!/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
--- /dev/null
+# 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
--- /dev/null
+# 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
+++ /dev/null
-#!/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
--- /dev/null
+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])