summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@gnu.org>2022-01-15 14:33:53 +0000
committerDaiki Ueno <ueno@gnu.org>2022-01-15 14:33:53 +0000
commit6000b2d93b6cb9acd45adc9b4d8f7bf2f1cb49b2 (patch)
treea6d1a0c34a61ac0a3aa2e3620793a75c2c2f9098
parent6fa472075e7b8e4fb51d089eaee4ed2094e7335b (diff)
parent0bce0cbdf20a13fc8c063e5941ba0187d6d4c8f1 (diff)
downloadgnutls-6000b2d93b6cb9acd45adc9b4d8f7bf2f1cb49b2.tar.gz
Merge branch 'wip/dueno/remove-autogen' into 'master'
remove autogen dependency Closes #775, #774, and #773 See merge request gnutls/gnutls!1506
-rw-r--r--.gitignore57
-rw-r--r--.gitlab-ci.yml13
-rw-r--r--.x-sc_error_message_period1
-rw-r--r--.x-sc_error_message_uppercase1
-rw-r--r--Makefile.am17
-rw-r--r--README.md12
-rw-r--r--bootstrap.conf3
-rw-r--r--cfg.mk4
-rw-r--r--configure.ac34
-rw-r--r--doc/Makefile.am219
-rw-r--r--doc/certtool-examples.texi136
-rw-r--r--doc/certtool-files.texi321
-rw-r--r--doc/certtool-see-also.texi1
-rw-r--r--doc/danetool-examples.texi39
-rw-r--r--doc/danetool-see-also.texi1
-rw-r--r--doc/gnutls-cli-debug-examples.texi (renamed from src/cli-debug-args.def)56
-rw-r--r--doc/gnutls-cli-debug-see-also.texi1
-rw-r--r--doc/gnutls-cli-examples.texi99
-rw-r--r--doc/gnutls-cli-see-also.texi1
-rw-r--r--doc/gnutls-serv-examples.texi147
-rw-r--r--doc/gnutls-serv-see-also.texi1
-rw-r--r--doc/manpages/Makefile.am138
-rw-r--r--doc/ocsptool-description.texi6
-rw-r--r--doc/ocsptool-examples.texi128
-rw-r--r--doc/ocsptool-see-also.texi1
-rw-r--r--doc/p11tool-examples.texi34
-rw-r--r--doc/p11tool-see-also.texi1
-rw-r--r--doc/psktool-examples.texi12
-rw-r--r--doc/psktool-see-also.texi1
-rw-r--r--doc/scripts/Makefile.am2
-rwxr-xr-xdoc/scripts/cleanup-autogen.pl71
-rw-r--r--doc/scripts/gen-cmd-man.py348
-rw-r--r--doc/scripts/gen-cmd-texi.py267
-rw-r--r--doc/srptool-examples.texi19
-rw-r--r--doc/srptool-see-also.texi1
-rw-r--r--doc/systemkey-tool-see-also.texi1
-rw-r--r--doc/tpmtool-examples.texi25
-rw-r--r--doc/tpmtool-see-also.texi1
-rw-r--r--python/Makefile.am1
-rw-r--r--python/jsonopts.py257
-rw-r--r--src/Makefile.am275
-rw-r--r--src/args-std.def.in58
-rw-r--r--src/certtool-args.def1163
-rw-r--r--src/certtool-cfg.c204
-rw-r--r--src/certtool-common.c2
-rw-r--r--src/certtool-options.json579
-rw-r--r--src/certtool.c6
-rw-r--r--src/cfg.c464
-rw-r--r--src/cfg.h33
-rw-r--r--src/cli-args.def600
-rw-r--r--src/cli-debug.c2
-rw-r--r--src/cli.c2
-rw-r--r--src/danetool-args.def230
-rw-r--r--src/danetool-options.json171
-rw-r--r--src/danetool.c4
-rw-r--r--src/gen-getopt.py654
-rw-r--r--src/gnutls-cli-debug-options.json53
-rw-r--r--src/gnutls-cli-options.json421
-rw-r--r--src/gnutls-serv-options.json332
-rw-r--r--src/libopts/COPYING.gplv3674
-rw-r--r--src/libopts/COPYING.lgplv3165
-rw-r--r--src/libopts/COPYING.mbsd27
-rw-r--r--src/libopts/MakeDefs.inc0
-rw-r--r--src/libopts/Makefile.am57
-rw-r--r--src/libopts/README122
-rw-r--r--src/libopts/_Noreturn.h10
-rw-r--r--src/libopts/ag-char-map.h526
-rw-r--r--src/libopts/alias.c116
-rw-r--r--src/libopts/ao-strs.c379
-rw-r--r--src/libopts/ao-strs.h338
-rw-r--r--src/libopts/autoopts.c391
-rw-r--r--src/libopts/autoopts.h494
-rw-r--r--src/libopts/autoopts/options.h1263
-rw-r--r--src/libopts/autoopts/project.h81
-rw-r--r--src/libopts/autoopts/usage-txt.h651
-rw-r--r--src/libopts/boolean.c95
-rw-r--r--src/libopts/check.c177
-rw-r--r--src/libopts/compat/_Noreturn.h10
-rw-r--r--src/libopts/compat/compat.h383
-rw-r--r--src/libopts/compat/pathfind.c283
-rw-r--r--src/libopts/compat/snprintf.c62
-rw-r--r--src/libopts/compat/strchr.c66
-rw-r--r--src/libopts/compat/strdup.c22
-rw-r--r--src/libopts/compat/windows-config.h144
-rw-r--r--src/libopts/configfile.c1337
-rw-r--r--src/libopts/cook.c320
-rw-r--r--src/libopts/enum.c628
-rw-r--r--src/libopts/env.c261
-rw-r--r--src/libopts/file.c201
-rw-r--r--src/libopts/find.c765
-rw-r--r--src/libopts/genshell.c848
-rw-r--r--src/libopts/genshell.h224
-rw-r--r--src/libopts/gettext.h294
-rw-r--r--src/libopts/init.c289
-rw-r--r--src/libopts/intprops.h453
-rw-r--r--src/libopts/libopts.c50
-rw-r--r--src/libopts/load.c578
-rw-r--r--src/libopts/m4/libopts.m4586
-rw-r--r--src/libopts/m4/liboptschk.m427
-rw-r--r--src/libopts/m4/stdnoreturn.m451
-rw-r--r--src/libopts/makeshell.c918
-rw-r--r--src/libopts/nested.c905
-rw-r--r--src/libopts/numeric.c180
-rw-r--r--src/libopts/option-value-type.c156
-rw-r--r--src/libopts/option-value-type.h60
-rw-r--r--src/libopts/option-xat-attribute.c148
-rw-r--r--src/libopts/option-xat-attribute.h57
-rw-r--r--src/libopts/parse-duration.c604
-rw-r--r--src/libopts/parse-duration.h90
-rw-r--r--src/libopts/pgusage.c187
-rw-r--r--src/libopts/proto.h620
-rw-r--r--src/libopts/putshell.c495
-rw-r--r--src/libopts/reset.c141
-rw-r--r--src/libopts/restore.c223
-rw-r--r--src/libopts/save-flags.c248
-rw-r--r--src/libopts/save-flags.h68
-rw-r--r--src/libopts/save.c916
-rw-r--r--src/libopts/sort.c326
-rw-r--r--src/libopts/stack.c267
-rw-r--r--src/libopts/stdnoreturn.in.h60
-rw-r--r--src/libopts/streqvcmp.c284
-rw-r--r--src/libopts/text_mmap.c382
-rw-r--r--src/libopts/time.c145
-rw-r--r--src/libopts/tokenize.c322
-rw-r--r--src/libopts/usage.c1285
-rw-r--r--src/libopts/value-type.c123
-rw-r--r--src/libopts/value-type.h25
-rw-r--r--src/libopts/version.c240
-rw-r--r--src/libopts/xat-attribute.c114
-rw-r--r--src/libopts/xat-attribute.h22
-rw-r--r--src/ocsptool-args.def317
-rw-r--r--src/ocsptool-options.json164
-rw-r--r--src/ocsptool.c2
-rw-r--r--src/p11tool-args.def580
-rw-r--r--src/p11tool-options.json452
-rw-r--r--src/p11tool.c6
-rw-r--r--src/psk.c2
-rw-r--r--src/psktool-args.def70
-rw-r--r--src/psktool-options.json53
-rw-r--r--src/serv-args.def557
-rw-r--r--src/serv.c2
-rw-r--r--src/srptool-args.def106
-rw-r--r--src/srptool-options.json71
-rw-r--r--src/srptool.c2
-rw-r--r--src/systemkey-args.def43
-rw-r--r--src/systemkey-tool-options.json49
-rw-r--r--src/systemkey.c2
-rw-r--r--src/tpmtool-args.def170
-rw-r--r--src/tpmtool-options.json133
-rw-r--r--src/tpmtool.c2
-rw-r--r--src/udp-serv.c2
-rw-r--r--tests/Makefile.am30
-rwxr-xr-xtests/cert-tests/pkcs12-encode.sh12
-rw-r--r--tests/cfg-test.sh73
-rw-r--r--tests/fixtures/templates/arb-extensions.tmpl.exp17
-rw-r--r--tests/fixtures/templates/crit-extensions.tmpl.exp10
-rw-r--r--tests/fixtures/templates/inhibit-anypolicy.tmpl.exp25
-rw-r--r--tests/fixtures/templates/simple-policy.tmpl.exp9
-rw-r--r--tests/fixtures/templates/template-crq.tmpl.exp3
-rw-r--r--tests/fixtures/templates/template-date.tmpl.exp23
-rw-r--r--tests/fixtures/templates/template-dates-after2038.tmpl.exp23
-rw-r--r--tests/fixtures/templates/template-dn-err.tmpl.exp14
-rw-r--r--tests/fixtures/templates/template-dn.tmpl.exp14
-rw-r--r--tests/fixtures/templates/template-generalized.tmpl.exp23
-rw-r--r--tests/fixtures/templates/template-krb5name.tmpl.exp16
-rw-r--r--tests/fixtures/templates/template-long-dns.tmpl.exp14
-rw-r--r--tests/fixtures/templates/template-long-serial.tmpl.exp24
-rw-r--r--tests/fixtures/templates/template-nc.tmpl.exp27
-rw-r--r--tests/fixtures/templates/template-no-ca-explicit.tmpl.exp11
-rw-r--r--tests/fixtures/templates/template-no-ca-honor.tmpl.exp3
-rw-r--r--tests/fixtures/templates/template-no-ca.tmpl.exp2
-rw-r--r--tests/fixtures/templates/template-othername-xmpp.tmpl.exp15
-rw-r--r--tests/fixtures/templates/template-othername.tmpl.exp18
-rw-r--r--tests/fixtures/templates/template-overflow.tmpl.exp22
-rw-r--r--tests/fixtures/templates/template-overflow2.tmpl.exp22
-rw-r--r--tests/fixtures/templates/template-test.tmpl.exp24
-rw-r--r--tests/fixtures/templates/template-tlsfeature-crq.tmpl.exp6
-rw-r--r--tests/fixtures/templates/template-tlsfeature.tmpl.exp25
-rw-r--r--tests/fixtures/templates/template-unique.tmpl.exp16
-rw-r--r--tests/fixtures/templates/template-utf8.tmpl.exp14
-rwxr-xr-xtests/server-multi-keys.sh2
181 files changed, 6480 insertions, 27632 deletions
diff --git a/.gitignore b/.gitignore
index b0ba314bd5..dd1373a57d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -110,7 +110,6 @@ doc/gnutls.vr
doc/gnutls.vrs
doc/gnutls.xml
doc/ia-api.texi
-doc/invoke-*.menu
doc/invoke-*.texi
doc/latex/cha-tokens.tex
doc/latex/cha-upgrade.tex
@@ -251,7 +250,6 @@ lib/openpgp/libgnutls_openpgp.la
lib/openpgp/Makefile
lib/openpgp/Makefile.in
lib/openpgp/pgp-api.texi
-libopts/libopts.la
lib/priority_options.h
.libs
libtool
@@ -273,27 +271,21 @@ Makefile.user
*.o
*.out
*.plist
-src/args-std.def
src/benchmark
src/benchmark-cipher
src/benchmark-tls
src/certtool
-src/certtool-args.c
-src/certtool-args.h
-src/cfg/Makefile
-src/cfg/Makefile.in
-src/cfg/platon/Makefile
-src/cfg/platon/Makefile.in
-src/cfg/platon/str/Makefile
-src/cfg/platon/str/Makefile.in
-src/cli-args.c
-src/cli-args.h
-src/cli-debug-args.c
-src/cli-debug-args.h
+src/certtool-options.c
+src/certtool-options.h
+src/dumpcfg
+src/gnutls-cli-options.c
+src/gnutls-cli-options.h
+src/gnutls-cli-debug-options.c
+src/gnutls-cli-debug-options.h
src/crywrap/crywrap
src/danetool
-src/danetool-args.c
-src/danetool-args.h
+src/danetool-options.c
+src/danetool-options.h
src/gaa.skel
src/gl/*
!src/gl/override
@@ -301,7 +293,7 @@ src/gnutls-cli
src/gnutls-cli-debug
src/gnutls-serv
src/invoke-*.menu
-src/libcfg.la
+src/libcerttool-cfg.la
src/libcmd-certtool.la
src/libcmd-cli-debug.la
src/libcmd-cli.la
@@ -313,31 +305,30 @@ src/libcmd-serv.la
src/libcmd-srp.la
src/libcmd-systemkey.la
src/libcmd-tpmtool.la
-src/libopts/libopts.la
src/Makefile
src/Makefile.in
src/mech-list.h
src/ocsptool
-src/ocsptool-args.c
-src/ocsptool-args.h
+src/ocsptool-options.c
+src/ocsptool-options.h
src/p11tool
-src/p11tool-args.c
-src/p11tool-args.h
+src/p11tool-options.c
+src/p11tool-options.h
src/psktool
-src/psktool-args.c
-src/psktool-args.h
-src/serv-args.c
-src/serv-args.h
+src/psktool-options.c
+src/psktool-options.h
+src/gnutls-serv-options.c
+src/gnutls-serv-options.h
src/srptool
-src/srptool-args.c
-src/srptool-args.h
+src/srptool-options.c
+src/srptool-options.h
src/*.stamp
src/systemkey
-src/systemkey-args.c
-src/systemkey-args.h
+src/systemkey-tool-options.c
+src/systemkey-tool-options.h
src/tpmtool
-src/tpmtool-args.c
-src/tpmtool-args.h
+src/tpmtool-options.c
+src/tpmtool-options.h
stamp-h1
.submodule.stamp
*.swp
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 2bbf501c13..355dc076ca 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -29,7 +29,7 @@ variables:
CHECKJOBS: 16
cache:
- key: "$CI_JOB_NAME-ver22"
+ key: "$CI_JOB_NAME-ver24"
paths:
- cache/
@@ -195,8 +195,6 @@ doc-dist.Fedora:
- make -j$BUILDJOBS -C doc/latex gnutls.pdf
- DB2EPUBDIR=$(dirname $(find /usr/share/sgml/docbook/xsl-ns-stylesheets-*/epub/bin/ -name dbtoepub -print))
- PATH="$PATH:$DB2EPUBDIR" make -C doc gnutls.epub
- # check whether distribution with or without included libopts is ok
- - make -j$CHECKJOBS distcheck DISTCHECK_CONFIGURE_FLAGS="--enable-local-libopts --disable-tests"
- make -j$CHECKJOBS distcheck
@@ -538,6 +536,8 @@ fedora-static-analyzers/test:
paths:
- cache/cppcheck
script:
+ - MYPYPATH=$PWD/python mypy python/*.py doc/scripts/*.py src/*.py
+ - flake8 python/*.py doc/scripts/*.py src/*.py
- mkdir -p cache/cppcheck
- cppcheck --cppcheck-build-dir=cache/cppcheck --force -q -Ilib/includes -Igl/ -Ilib/ -I. --error-exitcode=1 lib/ -i lib/unistring -i lib/minitasn1 -i lib/nettle/backport -i lib/nettle/ecc -j2 $CPPCHECK_OPTIONS
- cppcheck --cppcheck-build-dir=cache/cppcheck --force -q -Ilib/includes -Igl/ -Ilibdane/ -I. --error-exitcode=1 libdane/ -j2 $CPPCHECK_OPTIONS
@@ -584,8 +584,6 @@ fedora-static-analyzers/test:
# - export CFLAGS="-std=c99 -O2 -g"
# - DB2EPUBDIR=$(dirname $(find /usr/share/sgml/docbook/xsl-ns-stylesheets-*/epub/bin/ -name dbtoepub -print))
# - PATH="$PATH:$DB2EPUBDIR" make -C doc gnutls.epub
-# # check whether distribution with or without included libopts is ok
-# - make -j$CHECKJOBS distcheck DISTCHECK_CONFIGURE_FLAGS="--enable-local-libopts --disable-tests"
# - make -j$CHECKJOBS distcheck
fedora-abicoverage/build:
@@ -770,10 +768,7 @@ debian-cross/aarch64-linux-gnu/test:
script:
# - mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc
# - echo ':DOSWin:M::MZ::/usr/bin/wine:' > /proc/sys/fs/binfmt_misc/register
- - dash ./configure --disable-gcc-warnings --host=${arch_name}-w64-mingw32 --target=${arch_name}-w64-mingw32 --cache-file $CCACHE_FILE --with-included-libtasn1 --disable-guile --disable-nls --with-included-unistring --enable-local-libopts --disable-non-suiteb-curves --disable-full-test-suite --disable-doc --with-pkcs12-iter-count=10000
- # since we use --enable-local-libopts the generated files must equal the .bak
- - mingw${arch_bits}-make -j$BUILDJOBS -C src certtool-args.c.bak
- - cmp src/certtool-args.c src/certtool-args.c.bak || false # TODO not really sure about what is this for
+ - dash ./configure --disable-gcc-warnings --host=${arch_name}-w64-mingw32 --target=${arch_name}-w64-mingw32 --cache-file $CCACHE_FILE --with-included-libtasn1 --disable-guile --disable-nls --with-included-unistring --disable-non-suiteb-curves --disable-full-test-suite --disable-doc --with-pkcs12-iter-count=10000
- mingw${arch_bits}-make -j$BUILDJOBS
- mingw${arch_bits}-make -j$BUILDJOBS -C tests check TESTS=""
diff --git a/.x-sc_error_message_period b/.x-sc_error_message_period
new file mode 100644
index 0000000000..205005f948
--- /dev/null
+++ b/.x-sc_error_message_period
@@ -0,0 +1 @@
+^src/gen-getopt.py
diff --git a/.x-sc_error_message_uppercase b/.x-sc_error_message_uppercase
new file mode 100644
index 0000000000..205005f948
--- /dev/null
+++ b/.x-sc_error_message_uppercase
@@ -0,0 +1 @@
+^src/gen-getopt.py
diff --git a/Makefile.am b/Makefile.am
index ae3fe27157..1cdbc1fae2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -28,7 +28,7 @@ DISTCHECK_CONFIGURE_FLAGS = \
--with-guile-extension-dir='$$(libdir)/guile/$$(GUILE_EFFECTIVE_VERSION)/extensions' \
AUTOGEN=false
-SUBDIRS = gl lib extra
+SUBDIRS = gl lib extra python
if ENABLE_DANE
SUBDIRS += libdane
@@ -57,7 +57,7 @@ if ENABLE_DOC
SUBDIRS += doc
endif
-ACLOCAL_AMFLAGS = -I m4 -I src/libopts/m4 -I src/gl/m4 -I lib/unistring/m4 --install
+ACLOCAL_AMFLAGS = -I m4 -I src/gl/m4 -I lib/unistring/m4 --install
EXTRA_DIST = cfg.mk maint.mk CONTRIBUTING.md README.md LICENSE AUTHORS NEWS \
ChangeLog THANKS INSTALL.md RELEASES.md .mailmap
@@ -180,14 +180,7 @@ distclean-local: code-coverage-dist-clean
local-code-coverage-output: code-coverage-capture
cat GnuTLS-$(VERSION)-coverage/index.html|grep headerCovTableEntry|grep '%'|head -1|sed 's/^.*>\([0-9]\+\.[0-9]\+\s*%\)<.*$$/ coverage lines: \1/' || true
-libopts-check:
- @echo "*****************************************************************"
- @echo "Checking whether included libopts matches the system's. If the"
- @echo "check fails upgrade the included libopts."
- @echo "*****************************************************************"
- test "`autoopts-config libsrc|awk -F '-' '{print $$NF}'|sed 's/.tar.gz//'`" = "`cat $(srcdir)/src/libopts/autoopts/options.h |grep OPTIONS_VERSION_STRING|cut -d '"' -f 2|sed 's/:/./g'`"
-
-files-update: libopts-check
+files-update:
$(MAKE) -C doc/ compare-makefile || mv doc/tmp-compare-makefile $(srcdir)/doc/Makefile.am
$(MAKE) -C doc/manpages compare-makefile || mv doc/manpages/tmp-compare-makefile $(srcdir)/doc/manpages/Makefile.am
$(MAKE) -C . symbol-check || mv symbols.last.tmp $(SYMBOLS_LAST_FILE)
@@ -195,7 +188,7 @@ files-update: libopts-check
@echo "updated auto-generated files; please use git diff to verify the correctness of the changes"
@echo "******************************************************************************************"
-dist-hook: libopts-check
+dist-hook:
$(PKG_CONFIG) --atleast-version=2.2.0 guile-2.2
if test -d "$(top_srcdir)/devel";then \
$(MAKE) -C $(top_srcdir) symbol-check && \
@@ -208,4 +201,4 @@ dist-hook: libopts-check
mv ChangeLog $(distdir)
touch -c $(distdir)/doc/*.html $(distdir)/doc/*.pdf $(distdir)/doc/*.info
-.PHONY: abi-check abi-dump-versioned abi-dump-latest pic-check symbol-check local-code-coverage-output files-update libopts-check AUTHORS
+.PHONY: abi-check abi-dump-versioned abi-dump-latest pic-check symbol-check local-code-coverage-output files-update AUTHORS
diff --git a/README.md b/README.md
index 3904bc4f87..d58542e777 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@ We require several tools to check out and build the software, including:
* [Make](https://www.gnu.org/software/make/)
* [Automake](https://www.gnu.org/software/automake/) (use 1.11.3 or later)
* [Autoconf](https://www.gnu.org/software/autoconf/)
-* [Autogen](https://www.gnu.org/software/autogen/) (use 5.16 or later)
+* [Python](https://www.python.org/) (use 3.6 or later)
* [Libtool](https://www.gnu.org/software/libtool/)
* [Gettext](https://www.gnu.org/software/gettext/)
* [Texinfo](https://www.gnu.org/software/texinfo/)
@@ -58,7 +58,7 @@ some hints:
Debian/Ubuntu:
```
apt-get install -y dash git-core autoconf libtool gettext autopoint
-apt-get install -y automake autogen nettle-dev libp11-kit-dev libtspi-dev libunistring-dev
+apt-get install -y automake python3 nettle-dev libp11-kit-dev libtspi-dev libunistring-dev
apt-get install -y guile-2.2-dev libtasn1-6-dev libidn2-0-dev gawk gperf
apt-get install -y libtss2-dev libunbound-dev dns-root-data bison gtk-doc-tools
apt-get install -y texinfo texlive texlive-generic-recommended texlive-extra-utils
@@ -69,14 +69,14 @@ Available backport repos, APT-Pinning or source code compilating can be used to
Fedora/RHEL:
```
-yum install -y dash git autoconf libtool gettext-devel automake autogen patch
-yum install -y nettle-devel p11-kit-devel autogen-libopts-devel libunistring-devel
+yum install -y dash git autoconf libtool gettext-devel automake patch
+yum install -y nettle-devel p11-kit-devel libunistring-devel
yum install -y tpm2-tss-devel trousers-devel guile22-devel libtasn1-devel libidn2-devel gawk gperf
yum install -y libtasn1-tools unbound-devel bison gtk-doc texinfo texlive
```
Sometimes, you may need to install more recent versions of Automake,
-Nettle, P11-kit and Autogen, which you will need to build from sources.
+Nettle, and P11-kit, which you will need to build from sources.
Dependencies that are used during make check or make dist are listed below.
Moreover, for basic interoperability testing you may want to install openssl
@@ -159,7 +159,7 @@ yum install -y wine mingw32-nettle mingw32-libtasn1 mingw32-gcc
and build as:
```
-mingw32-configure --enable-local-libopts --disable-non-suiteb-curves --disable-doc --without-p11-kit
+mingw32-configure --disable-non-suiteb-curves --disable-doc --without-p11-kit
mingw32-make
mingw32-make check
```
diff --git a/bootstrap.conf b/bootstrap.conf
index 598507b4b6..4392236bbc 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -38,7 +38,7 @@ unictype/category-all unictype/property-default-ignorable-code-point unictype/pr
"
src_modules="
-$common_modules accept bind close close-stream connect getaddrinfo getpass inttypes listen linked-list parse-datetime progname read-file recv recvfrom select send sendto servent setsockopt shutdown socket sockets socklen xalloc xlist xsize
+$common_modules accept bind close close-stream connect getaddrinfo getpass inttypes listen linked-list parse-datetime progname read-file reallocarray recv recvfrom select send sendto servent setsockopt shutdown socket sockets socklen xalloc xlist xsize
"
# Build prerequisites
@@ -50,7 +50,6 @@ git 1.4.4
perl 5.5
gperf -
autopoint -
-autogen -
"
# update git submodules
diff --git a/cfg.mk b/cfg.mk
index 3205378767..cfd835f303 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -25,7 +25,7 @@ PACKAGE ?= gnutls
.PHONY: config glimport
-INDENT_SOURCES = `find . -name \*.[ch] -o -name gnutls.h.in | grep -v -e ^./build-aux/ -e ^./lib/minitasn1/ -e ^./lib/build-aux/ -e ^./gl/ -e ^./src/libopts/ -e -args.[ch] -e asn1_tab.c -e ^./tests/suite/`
+INDENT_SOURCES = `find . -name \*.[ch] -o -name gnutls.h.in | grep -v -e ^./build-aux/ -e ^./lib/minitasn1/ -e ^./lib/build-aux/ -e ^./gl/ -e -args.[ch] -e asn1_tab.c -e ^./tests/suite/`
ifeq ($(.DEFAULT_GOAL),abort-due-to-no-makefile)
.DEFAULT_GOAL := bootstrap
@@ -42,7 +42,7 @@ local-checks-to-skip = sc_GPL_version sc_bindtextdomain \
sc_unmarked_diagnostics sc_useless_cpp_parens \
sc_two_space_separator_in_usage
-VC_LIST_ALWAYS_EXCLUDE_REGEX = ^maint.mk|gtk-doc.make|m4/pkg|doc/fdl-1.3.texi|src/.*\.bak|src/crywrap/|(devel/perlasm/|lib/accelerated/x86/|build-aux/|gl/|src/libopts/|tests/suite/ecore/|doc/protocol/).*$$
+VC_LIST_ALWAYS_EXCLUDE_REGEX = ^maint.mk|gtk-doc.make|m4/pkg|doc/fdl-1.3.texi|src/.*\.bak|src/crywrap/|(devel/perlasm/|lib/accelerated/x86/|build-aux/|gl/|tests/suite/ecore/|doc/protocol/).*$$
# Explicit syntax-check exceptions.
exclude_file_name_regexp--sc_copyright_check = ^./gnulib/.*$$
diff --git a/configure.ac b/configure.ac
index 667e07fdc2..26c890e2c5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,7 +25,7 @@ AC_PREREQ(2.64)
dnl when updating version also update LT_REVISION in m4/hooks.m4
AC_INIT([GnuTLS], [3.7.2], [bugs@gnutls.org])
AC_CONFIG_AUX_DIR([build-aux])
-AC_CONFIG_MACRO_DIRS([m4 src/gl/m4 src/libopts/m4 lib/unistring/m4])
+AC_CONFIG_MACRO_DIRS([m4 src/gl/m4 lib/unistring/m4])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([1.12.2 foreign subdir-objects no-dist-gzip dist-xz -Wall -Wno-override])
@@ -486,7 +486,7 @@ fi
AM_CONDITIONAL(WANT_TEST_SUITE, test "$full_test_suite" = "yes")
# parts of the extended test suite use Python
-AM_PATH_PYTHON(,, [:])
+AM_PATH_PYTHON([3.6],, [:])
AC_ARG_ENABLE(oldgnutls-interop,
AS_HELP_STRING([--enable-oldgnutls-interop], [enable interoperability testing with old gnutls version]),
@@ -936,33 +936,6 @@ fi
AC_DEFINE_UNQUOTED([TROUSERS_LIB], ["$ac_trousers_lib"], [the location of the trousers library])
AC_SUBST(TROUSERS_LIB)
-AM_MISSING_PROG([AUTOGEN], [autogen])
-
-included_libopts=no
-if test "$enable_tools" != "no" || test "$enable_doc" != "no"; then
- AC_CHECK_PROGS([autogen], [autogen])
-
- if test -z "$autogen"; then
- AC_MSG_WARN([[
-***
-*** autogen not found. Will not link against system libopts.
-*** ]])
- dnl simulate specifying option on the command line
- included_libopts=yes
- fi
- LIBOPTS_CHECK([src/libopts])
- if test "$NEED_LIBOPTS_DIR" = "true";then
- dnl replace libopts-generated files with distributed backups, if present
- included_libopts=yes
- fi
-else
- # Need to ensure the relevant conditionals get set
- gl_STDNORETURN_H
- AM_CONDITIONAL([INSTALL_LIBOPTS],[false])
-fi
-
-AM_CONDITIONAL(NEED_LIBOPTS, test "$included_libopts" = "yes")
-
# For minitasn1.
AC_CHECK_SIZEOF(unsigned long int, 4)
AC_CHECK_SIZEOF(unsigned int, 4)
@@ -1215,7 +1188,6 @@ AC_CONFIG_FILES([
lib/unistring/Makefile
po/Makefile.in
src/Makefile
- src/args-std.def
src/gl/Makefile
src/gl/tests/Makefile
tests/Makefile
@@ -1224,6 +1196,7 @@ AC_CONFIG_FILES([
tests/slow/Makefile
tests/suite/Makefile
fuzz/Makefile
+ python/Makefile
])
AC_OUTPUT
@@ -1239,7 +1212,6 @@ AC_MSG_NOTICE([summary of build options:
Valgrind: $opt_valgrind_tests ${VALGRIND}
CFlags: ${CFLAGS}
Library types: Shared=${enable_shared}, Static=${enable_static}
- Local libopts: ${included_libopts}
Local libtasn1: ${included_libtasn1}
Local unistring: ${included_unistring}
Use nettle-mini: ${mini_nettle}
diff --git a/doc/Makefile.am b/doc/Makefile.am
index ab414add8b..833c75ef6e 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -40,108 +40,121 @@ endif
-include $(top_srcdir)/doc/doc.mk
-invoke-gnutls-cli.texi: $(top_srcdir)/src/cli-args.def
- PATH="$(top_builddir)/src/$(PATH_SEPARATOR)$${PATH}$(PATH_SEPARATOR)" $(AUTOGEN) -L$(top_builddir)/src -Tagtexi-cmd.tpl $<; \
- if [ ! -e $@ ]; then \
- cp $(srcdir)/$@ .; \
- fi; \
- $(srcdir)/scripts/cleanup-autogen.pl < $@ > $@.tmp && \
- mv -f $@.tmp $@
-
-invoke-gnutls-cli-debug.texi: $(top_srcdir)/src/cli-debug-args.def invoke-gnutls-cli.texi
- PATH="$(top_builddir)/src/$(PATH_SEPARATOR)$${PATH}$(PATH_SEPARATOR)" $(AUTOGEN) -L$(top_builddir)/src -Tagtexi-cmd.tpl $<; \
- if [ ! -e $@ ]; then \
- cp $(srcdir)/$@ .; \
- fi; \
- $(srcdir)/scripts/cleanup-autogen.pl < $@ > $@.tmp && \
- mv -f $@.tmp $@
-
-invoke-gnutls-serv.texi: $(top_srcdir)/src/serv-args.def invoke-gnutls-cli-debug.texi
- PATH="$(top_builddir)/src/$(PATH_SEPARATOR)$${PATH}$(PATH_SEPARATOR)" $(AUTOGEN) -L$(top_builddir)/src -Tagtexi-cmd.tpl $<; \
- if [ ! -e $@ ]; then \
- cp $(srcdir)/$@ .; \
- fi; \
- $(srcdir)/scripts/cleanup-autogen.pl < $@ > $@.tmp && \
- mv -f $@.tmp $@
-
-invoke-certtool.texi: $(top_srcdir)/src/certtool-args.def invoke-gnutls-serv.texi
- PATH="$(top_builddir)/src/$(PATH_SEPARATOR)$${PATH}$(PATH_SEPARATOR)" $(AUTOGEN) -L$(top_builddir)/src -Tagtexi-cmd.tpl $<; \
- if [ ! -e $@ ]; then \
- cp $(srcdir)/$@ .; \
- fi; \
- $(srcdir)/scripts/cleanup-autogen.pl < $@ > $@.tmp && \
- rm -f $@ && \
- $(SED) -e 's/@subheading/@subsubheading/g' \
- -e 's/@section/@subsection/g' $@.tmp > $@ && \
- rm -f $@.tmp
-
-invoke-ocsptool.texi: $(top_srcdir)/src/ocsptool-args.def invoke-certtool.texi
- PATH="$(top_builddir)/src/$(PATH_SEPARATOR)$${PATH}$(PATH_SEPARATOR)" $(AUTOGEN) -L$(top_builddir)/src -Tagtexi-cmd.tpl $<; \
- if [ ! -e $@ ]; then \
- cp $(srcdir)/$@ .; \
- fi; \
- $(srcdir)/scripts/cleanup-autogen.pl < $@ > $@.tmp && \
- rm -f $@ && \
- $(SED) -e 's/@subheading/@subsubheading/g' \
- -e 's/@section/@subsection/g' $@.tmp > $@ && \
- rm -f $@.tmp
-
-invoke-danetool.texi: $(top_srcdir)/src/danetool-args.def invoke-ocsptool.texi
- PATH="$(top_builddir)/src/$(PATH_SEPARATOR)$${PATH}$(PATH_SEPARATOR)" $(AUTOGEN) -L$(top_builddir)/src -Tagtexi-cmd.tpl $<; \
- if [ ! -e $@ ]; then \
- cp $(srcdir)/$@ .; \
- fi; \
- $(srcdir)/scripts/cleanup-autogen.pl < $@ > $@.tmp && \
- rm -f $@ && \
- $(SED) -e 's/@subheading/@subsubheading/g' \
- -e 's/@section/@subsection/g' $@.tmp > $@ && \
- rm -f $@.tmp
-
-invoke-srptool.texi: $(top_srcdir)/src/srptool-args.def invoke-danetool.texi
- PATH="$(top_builddir)/src/$(PATH_SEPARATOR)$${PATH}$(PATH_SEPARATOR)" $(AUTOGEN) -L$(top_builddir)/src -Tagtexi-cmd.tpl $<; \
- if [ ! -e $@ ]; then \
- cp $(srcdir)/$@ .; \
- fi; \
- $(srcdir)/scripts/cleanup-autogen.pl < $@ > $@.tmp && \
- rm -f $@ && \
- $(SED) -e 's/@subheading/@subsubheading/g' \
- -e 's/@section/@subsubsection/g' $@.tmp > $@ && \
- rm -f $@.tmp
-
-invoke-psktool.texi: $(top_srcdir)/src/psktool-args.def invoke-srptool.texi
- PATH="$(top_builddir)/src/$(PATH_SEPARATOR)$${PATH}$(PATH_SEPARATOR)" $(AUTOGEN) -L$(top_builddir)/src -Tagtexi-cmd.tpl $<; \
- if [ ! -e $@ ]; then \
- cp $(srcdir)/$@ .; \
- fi; \
- $(srcdir)/scripts/cleanup-autogen.pl < $@ > $@.tmp && \
- rm -f $@ && \
- $(SED) -e 's/@subheading/@subsubheading/g' \
- -e 's/@section/@subsubsection/g' $@.tmp > $@ && \
- rm -f $@.tmp
-
-invoke-p11tool.texi: $(top_srcdir)/src/p11tool-args.def invoke-psktool.texi
- PATH="$(top_builddir)/src/$(PATH_SEPARATOR)$${PATH}$(PATH_SEPARATOR)" $(AUTOGEN) -L$(top_builddir)/src -Tagtexi-cmd.tpl $<; \
- if [ ! -e $@ ]; then \
- cp $(srcdir)/$@ .; \
- fi; \
- $(srcdir)/scripts/cleanup-autogen.pl < $@ > $@.tmp && \
- rm -f $@ && \
- $(SED) \
- -e 's/@subsection/@subsubheading/g' \
- -e 's/@section/@subsection/g' $@.tmp > $@ && \
- rm -f $@.tmp
-
-invoke-tpmtool.texi: $(top_srcdir)/src/tpmtool-args.def invoke-p11tool.texi
- PATH="$(top_builddir)/src/$(PATH_SEPARATOR)$${PATH}$(PATH_SEPARATOR)" $(AUTOGEN) -L$(top_builddir)/src -Tagtexi-cmd.tpl $<; \
- if [ ! -e $@ ]; then \
- cp $(srcdir)/$@ .; \
- fi; \
- $(srcdir)/scripts/cleanup-autogen.pl < $@ > $@.tmp && \
- rm -f $@ && \
- $(SED) \
- -e 's/@subsection/@subsubheading/g' \
- -e 's/@section/@subsection/g' $@.tmp > $@ && \
- rm -f $@.tmp
+INVOKE_GNUTLS_CLI_TEXI_DEPS = gnutls-cli-see-also.texi gnutls-cli-examples.texi
+EXTRA_DIST += $(INVOKE_GNUTLS_CLI_TEXI_DEPS)
+invoke-gnutls-cli.texi: $(INVOKE_GNUTLS_CLI_TEXI_DEPS)
+invoke-gnutls-cli.texi: $(top_srcdir)/src/gnutls-cli-options.json
+ $(AM_V_GEN) PYTHONPATH='$(top_srcdir)/python' \
+ $(PYTHON) $(srcdir)/scripts/gen-cmd-texi.py \
+ --see-also $(srcdir)/gnutls-cli-see-also.texi \
+ --examples $(srcdir)/gnutls-cli-examples.texi \
+ $< $@
+
+INVOKE_GNUTLS_CLI_DEBUG_TEXI_DEPS = gnutls-cli-debug-see-also.texi gnutls-cli-debug-examples.texi
+EXTRA_DIST += $(INVOKE_GNUTLS_CLI_DEBUG_TEXI_DEPS)
+invoke-gnutls-cli-debug.texi: $(INVOKE_GNUTLS_CLI_DEBUG_TEXI_DEPS)
+invoke-gnutls-cli-debug.texi: $(top_srcdir)/src/gnutls-cli-debug-options.json
+ $(AM_V_GEN) PYTHONPATH='$(top_srcdir)/python' \
+ $(PYTHON) $(srcdir)/scripts/gen-cmd-texi.py \
+ --see-also $(srcdir)/gnutls-cli-debug-see-also.texi \
+ --examples $(srcdir)/gnutls-cli-debug-examples.texi \
+ $< $@
+
+INVOKE_GNUTLS_SERV_TEXI_DEPS = gnutls-serv-see-also.texi gnutls-serv-examples.texi
+EXTRA_DIST += $(INVOKE_GNUTLS_SERV_TEXI_DEPS)
+invoke-gnutls-serv.texi: $(INVOKE_GNUTLS_SERV_TEXI_DEPS)
+invoke-gnutls-serv.texi: $(top_srcdir)/src/gnutls-serv-options.json
+ $(AM_V_GEN) PYTHONPATH='$(top_srcdir)/python' \
+ $(PYTHON) $(srcdir)/scripts/gen-cmd-texi.py \
+ --see-also $(srcdir)/gnutls-serv-see-also.texi \
+ --examples $(srcdir)/gnutls-serv-examples.texi \
+ $< $@
+
+INVOKE_CERTTOOL_TEXI_DEPS = certtool-see-also.texi certtool-examples.texi certtool-files.texi
+EXTRA_DIST += $(INVOKE_CERTTOOL_TEXI_DEPS)
+invoke-certtool.texi: $(INVOKE_CERTTOOL_TEXI_DEPS)
+invoke-certtool.texi: $(top_srcdir)/src/certtool-options.json
+ $(AM_V_GEN) PYTHONPATH='$(top_srcdir)/python' \
+ $(PYTHON) $(srcdir)/scripts/gen-cmd-texi.py \
+ --see-also $(srcdir)/certtool-see-also.texi \
+ --examples $(srcdir)/certtool-examples.texi \
+ --files $(srcdir)/certtool-files.texi \
+ --level 1 \
+ --section-node \
+ $< $@
+
+INVOKE_OCSPTOOL_TEXI_DEPS = ocsptool-see-also.texi ocsptool-examples.texi ocsptool-description.texi
+EXTRA_DIST += $(INVOKE_OCSPTOOL_TEXI_DEPS)
+invoke-ocsptool.texi: $(INVOKE_OCSPTOOL_TEXI_DEPS)
+invoke-ocsptool.texi: $(top_srcdir)/src/ocsptool-options.json
+ $(AM_V_GEN) PYTHONPATH='$(top_srcdir)/python' \
+ $(PYTHON) $(srcdir)/scripts/gen-cmd-texi.py \
+ --see-also $(srcdir)/ocsptool-see-also.texi \
+ --examples $(srcdir)/ocsptool-examples.texi \
+ --description $(srcdir)/ocsptool-description.texi \
+ --level 1 \
+ --section-node \
+ $< $@
+
+INVOKE_DANETOOL_TEXI_DEPS = danetool-see-also.texi danetool-examples.texi
+EXTRA_DIST += $(INVOKE_DANETOOL_TEXI_DEPS)
+invoke-danetool.texi: $(INVOKE_DANETOOL_TEXI_DEPS)
+invoke-danetool.texi: $(top_srcdir)/src/danetool-options.json
+ $(AM_V_GEN) PYTHONPATH='$(top_srcdir)/python' \
+ $(PYTHON) $(srcdir)/scripts/gen-cmd-texi.py \
+ --see-also $(srcdir)/danetool-see-also.texi \
+ --examples $(srcdir)/danetool-examples.texi \
+ --level 1 \
+ --section-node \
+ $< $@
+
+INVOKE_SRPTOOL_TEXI_DEPS = srptool-see-also.texi srptool-examples.texi
+EXTRA_DIST += $(INVOKE_SRPTOOL_TEXI_DEPS)
+invoke-srptool.texi: $(INVOKE_SRPTOOL_TEXI_DEPS)
+invoke-srptool.texi: $(top_srcdir)/src/srptool-options.json
+ $(AM_V_GEN) PYTHONPATH='$(top_srcdir)/python' \
+ $(PYTHON) $(srcdir)/scripts/gen-cmd-texi.py \
+ --see-also $(srcdir)/srptool-see-also.texi \
+ --examples $(srcdir)/srptool-examples.texi \
+ --level 2 \
+ --section-node \
+ $< $@
+
+INVOKE_PSKTOOL_TEXI_DEPS = psktool-see-also.texi psktool-examples.texi
+EXTRA_DIST += $(INVOKE_PSKTOOL_TEXI_DEPS)
+invoke-psktool.texi: $(INVOKE_PSKTOOL_TEXI_DEPS)
+invoke-psktool.texi: $(top_srcdir)/src/psktool-options.json
+ $(AM_V_GEN) PYTHONPATH='$(top_srcdir)/python' \
+ $(PYTHON) $(srcdir)/scripts/gen-cmd-texi.py \
+ --see-also $(srcdir)/psktool-see-also.texi \
+ --examples $(srcdir)/psktool-examples.texi \
+ --level 2 \
+ --section-node \
+ $< $@
+
+INVOKE_P11TOOL_TEXI_DEPS = p11tool-see-also.texi p11tool-examples.texi
+EXTRA_DIST += $(INVOKE_P11TOOL_TEXI_DEPS)
+invoke-p11tool.texi: $(INVOKE_P11TOOL_TEXI_DEPS)
+invoke-p11tool.texi: $(top_srcdir)/src/p11tool-options.json
+ $(AM_V_GEN) PYTHONPATH='$(top_srcdir)/python' \
+ $(PYTHON) $(srcdir)/scripts/gen-cmd-texi.py \
+ --see-also $(srcdir)/p11tool-see-also.texi \
+ --examples $(srcdir)/p11tool-examples.texi \
+ --level 1 \
+ --section-node \
+ $< $@
+
+INVOKE_TPMTOOL_TEXI_DEPS = tpmtool-see-also.texi tpmtool-examples.texi
+EXTRA_DIST += $(INVOKE_TPMTOOL_TEXI_DEPS)
+invoke-tpmtool.texi: $(INVOKE_TPMTOOL_TEXI_DEPS)
+invoke-tpmtool.texi: $(top_srcdir)/src/tpmtool-options.json
+ $(AM_V_GEN) PYTHONPATH='$(top_srcdir)/python' \
+ $(PYTHON) $(srcdir)/scripts/gen-cmd-texi.py \
+ --see-also $(srcdir)/tpmtool-see-also.texi \
+ --examples $(srcdir)/tpmtool-examples.texi \
+ --level 1 \
+ --section-node \
+ $< $@
info_TEXINFOS = gnutls.texi gnutls-guile.texi
@@ -159,6 +172,8 @@ AUTOGENED_DOC = invoke-gnutls-cli.texi invoke-gnutls-cli-debug.texi \
invoke-ocsptool.texi invoke-psktool.texi invoke-p11tool.texi \
invoke-tpmtool.texi invoke-danetool.texi
+$(AUTOGENED_DOC): $(srcdir)/scripts/gen-cmd-texi.py
+
gnutls_TEXINFOS += stamp_functions
# Examples.
diff --git a/doc/certtool-examples.texi b/doc/certtool-examples.texi
new file mode 100644
index 0000000000..c24df9b706
--- /dev/null
+++ b/doc/certtool-examples.texi
@@ -0,0 +1,136 @@
+@subheading Generating private keys
+To create an RSA private key, run:
+@example
+$ certtool --generate-privkey --outfile key.pem --rsa
+@end example
+
+To create a DSA or elliptic curves (ECDSA) private key use the
+above command combined with 'dsa' or 'ecc' options.
+
+@subheading Generating certificate requests
+To create a certificate request (needed when the certificate is issued by
+another party), run:
+@example
+certtool --generate-request --load-privkey key.pem \
+ --outfile request.pem
+@end example
+
+If the private key is stored in a smart card you can generate
+a request by specifying the private key object URL.
+@example
+$ ./certtool --generate-request --load-privkey "pkcs11:..." \
+ --load-pubkey "pkcs11:..." --outfile request.pem
+@end example
+
+
+@subheading Generating a self-signed certificate
+To create a self signed certificate, use the command:
+@example
+$ certtool --generate-privkey --outfile ca-key.pem
+$ certtool --generate-self-signed --load-privkey ca-key.pem \
+ --outfile ca-cert.pem
+@end example
+
+Note that a self-signed certificate usually belongs to a certificate
+authority, that signs other certificates.
+
+@subheading Generating a certificate
+To generate a certificate using the previous request, use the command:
+@example
+$ certtool --generate-certificate --load-request request.pem \
+ --outfile cert.pem --load-ca-certificate ca-cert.pem \
+ --load-ca-privkey ca-key.pem
+@end example
+
+To generate a certificate using the private key only, use the command:
+@example
+$ certtool --generate-certificate --load-privkey key.pem \
+ --outfile cert.pem --load-ca-certificate ca-cert.pem \
+ --load-ca-privkey ca-key.pem
+@end example
+
+@subheading Certificate information
+To view the certificate information, use:
+@example
+$ certtool --certificate-info --infile cert.pem
+@end example
+
+@subheading Changing the certificate format
+To convert the certificate from PEM to DER format, use:
+@example
+$ certtool --certificate-info --infile cert.pem --outder --outfile cert.der
+@end example
+
+@subheading PKCS #12 structure generation
+To generate a PKCS #12 structure using the previous key and certificate,
+use the command:
+@example
+$ certtool --load-certificate cert.pem --load-privkey key.pem \
+ --to-p12 --outder --outfile key.p12
+@end example
+
+Some tools (reportedly web browsers) have problems with that file
+because it does not contain the CA certificate for the certificate.
+To work around that problem in the tool, you can use the
+--load-ca-certificate parameter as follows:
+
+@example
+$ certtool --load-ca-certificate ca.pem \
+ --load-certificate cert.pem --load-privkey key.pem \
+ --to-p12 --outder --outfile key.p12
+@end example
+
+@subheading Obtaining Diffie-Hellman parameters
+To obtain the RFC7919 parameters for Diffie-Hellman key exchange, use the command:
+@example
+$ certtool --get-dh-params --outfile dh.pem --sec-param medium
+@end example
+
+@subheading Verifying a certificate
+To verify a certificate in a file against the system's CA trust store
+use the following command:
+@example
+$ certtool --verify --infile cert.pem
+@end example
+
+It is also possible to simulate hostname verification with the following
+options:
+@example
+$ certtool --verify --verify-hostname www.example.com --infile cert.pem
+@end example
+
+
+@subheading Proxy certificate generation
+Proxy certificate can be used to delegate your credential to a
+temporary, typically short-lived, certificate. To create one from the
+previously created certificate, first create a temporary key and then
+generate a proxy certificate for it, using the commands:
+
+@example
+$ certtool --generate-privkey > proxy-key.pem
+$ certtool --generate-proxy --load-ca-privkey key.pem \
+ --load-privkey proxy-key.pem --load-certificate cert.pem \
+ --outfile proxy-cert.pem
+@end example
+
+@subheading Certificate revocation list generation
+To create an empty Certificate Revocation List (CRL) do:
+
+@example
+$ certtool --generate-crl --load-ca-privkey x509-ca-key.pem \
+ --load-ca-certificate x509-ca.pem
+@end example
+
+To create a CRL that contains some revoked certificates, place the
+certificates in a file and use @code{--load-certificate} as follows:
+
+@example
+$ certtool --generate-crl --load-ca-privkey x509-ca-key.pem \
+ --load-ca-certificate x509-ca.pem --load-certificate revoked-certs.pem
+@end example
+
+To verify a Certificate Revocation List (CRL) do:
+
+@example
+$ certtool --verify-crl --load-ca-certificate x509-ca.pem < crl.pem
+@end example
diff --git a/doc/certtool-files.texi b/doc/certtool-files.texi
new file mode 100644
index 0000000000..56d3fbe03e
--- /dev/null
+++ b/doc/certtool-files.texi
@@ -0,0 +1,321 @@
+@subheading Certtool's template file format
+A template file can be used to avoid the interactive questions of
+certtool. Initially create a file named 'cert.cfg' that contains the information
+about the certificate. The template can be used as below:
+
+@example
+$ certtool --generate-certificate --load-privkey key.pem \
+ --template cert.cfg --outfile cert.pem \
+ --load-ca-certificate ca-cert.pem --load-ca-privkey ca-key.pem
+@end example
+
+An example certtool template file that can be used to generate a certificate
+request or a self signed certificate follows.
+
+@example
+# X.509 Certificate options
+#
+# DN options
+
+# The organization of the subject.
+organization = "Koko inc."
+
+# The organizational unit of the subject.
+unit = "sleeping dept."
+
+# The locality of the subject.
+# locality =
+
+# The state of the certificate owner.
+state = "Attiki"
+
+# The country of the subject. Two letter code.
+country = GR
+
+# The common name of the certificate owner.
+cn = "Cindy Lauper"
+
+# A user id of the certificate owner.
+#uid = "clauper"
+
+# Set domain components
+#dc = "name"
+#dc = "domain"
+
+# If the supported DN OIDs are not adequate you can set
+# any OID here.
+# For example set the X.520 Title and the X.520 Pseudonym
+# by using OID and string pairs.
+#dn_oid = "2.5.4.12 Dr."
+#dn_oid = "2.5.4.65 jackal"
+
+# This is deprecated and should not be used in new
+# certificates.
+# pkcs9_email = "none@@none.org"
+
+# An alternative way to set the certificate's distinguished name directly
+# is with the "dn" option. The attribute names allowed are:
+# C (country), street, O (organization), OU (unit), title, CN (common name),
+# L (locality), ST (state), placeOfBirth, gender, countryOfCitizenship,
+# countryOfResidence, serialNumber, telephoneNumber, surName, initials,
+# generationQualifier, givenName, pseudonym, dnQualifier, postalCode, name,
+# businessCategory, DC, UID, jurisdictionOfIncorporationLocalityName,
+# jurisdictionOfIncorporationStateOrProvinceName,
+# jurisdictionOfIncorporationCountryName, XmppAddr, and numeric OIDs.
+
+#dn = "cn = Nikos,st = New\, Something,C=GR,surName=Mavrogiannopoulos,2.5.4.9=Arkadias"
+
+# The serial number of the certificate
+# The value is in decimal (i.e. 1963) or hex (i.e. 0x07ab).
+# Comment the field for a random serial number.
+serial = 007
+
+# In how many days, counting from today, this certificate will expire.
+# Use -1 if there is no expiration date.
+expiration_days = 700
+
+# Alternatively you may set concrete dates and time. The GNU date string
+# formats are accepted. See:
+# https://www.gnu.org/software/tar/manual/html_node/Date-input-formats.html
+
+#activation_date = "2004-02-29 16:21:42"
+#expiration_date = "2025-02-29 16:24:41"
+
+# X.509 v3 extensions
+
+# A dnsname in case of a WWW server.
+#dns_name = "www.none.org"
+#dns_name = "www.morethanone.org"
+
+# An othername defined by an OID and a hex encoded string
+#other_name = "1.3.6.1.5.2.2 302ca00d1b0b56414e5245494e2e4f5247a11b3019a006020400000002a10f300d1b047269636b1b0561646d696e"
+#other_name_utf8 = "1.2.4.5.6 A UTF8 string"
+#other_name_octet = "1.2.4.5.6 A string that will be encoded as ASN.1 octet string"
+
+# Allows writing an XmppAddr Identifier
+#xmpp_name = juliet@@im.example.com
+
+# Names used in PKINIT
+#krb5_principal = user@@REALM.COM
+#krb5_principal = HTTP/user@@REALM.COM
+
+# A subject alternative name URI
+#uri = "https://www.example.com"
+
+# An IP address in case of a server.
+#ip_address = "192.168.1.1"
+
+# An email in case of a person
+email = "none@@none.org"
+
+# TLS feature (rfc7633) extension. That can is used to indicate mandatory TLS
+# extension features to be provided by the server. In practice this is used
+# to require the Status Request (extid: 5) extension from the server. That is,
+# to require the server holding this certificate to provide a stapled OCSP response.
+# You can have multiple lines for multiple TLS features.
+
+# To ask for OCSP status request use:
+#tls_feature = 5
+
+# Challenge password used in certificate requests
+challenge_password = 123456
+
+# Password when encrypting a private key
+#password = secret
+
+# An URL that has CRLs (certificate revocation lists)
+# available. Needed in CA certificates.
+#crl_dist_points = "https://www.getcrl.crl/getcrl/"
+
+# Whether this is a CA certificate or not
+#ca
+
+# Subject Unique ID (in hex)
+#subject_unique_id = 00153224
+
+# Issuer Unique ID (in hex)
+#issuer_unique_id = 00153225
+
+#### Key usage
+
+# The following key usage flags are used by CAs and end certificates
+
+# Whether this certificate will be used to sign data (needed
+# in TLS DHE ciphersuites). This is the digitalSignature flag
+# in RFC5280 terminology.
+signing_key
+
+# Whether this certificate will be used to encrypt data (needed
+# in TLS RSA ciphersuites). Note that it is preferred to use different
+# keys for encryption and signing. This is the keyEncipherment flag
+# in RFC5280 terminology.
+encryption_key
+
+# Whether this key will be used to sign other certificates. The
+# keyCertSign flag in RFC5280 terminology.
+#cert_signing_key
+
+# Whether this key will be used to sign CRLs. The
+# cRLSign flag in RFC5280 terminology.
+#crl_signing_key
+
+# The keyAgreement flag of RFC5280. Its purpose is loosely
+# defined. Not use it unless required by a protocol.
+#key_agreement
+
+# The dataEncipherment flag of RFC5280. Its purpose is loosely
+# defined. Not use it unless required by a protocol.
+#data_encipherment
+
+# The nonRepudiation flag of RFC5280. Its purpose is loosely
+# defined. Not use it unless required by a protocol.
+#non_repudiation
+
+#### Extended key usage (key purposes)
+
+# The following extensions are used in an end certificate
+# to clarify its purpose. Some CAs also use it to indicate
+# the types of certificates they are purposed to sign.
+
+
+# Whether this certificate will be used for a TLS client;
+# this sets the id-kp-clientAuth (1.3.6.1.5.5.7.3.2) of
+# extended key usage.
+#tls_www_client
+
+# Whether this certificate will be used for a TLS server;
+# this sets the id-kp-serverAuth (1.3.6.1.5.5.7.3.1) of
+# extended key usage.
+#tls_www_server
+
+# Whether this key will be used to sign code. This sets the
+# id-kp-codeSigning (1.3.6.1.5.5.7.3.3) of extended key usage
+# extension.
+#code_signing_key
+
+# Whether this key will be used to sign OCSP data. This sets the
+# id-kp-OCSPSigning (1.3.6.1.5.5.7.3.9) of extended key usage extension.
+#ocsp_signing_key
+
+# Whether this key will be used for time stamping. This sets the
+# id-kp-timeStamping (1.3.6.1.5.5.7.3.8) of extended key usage extension.
+#time_stamping_key
+
+# Whether this key will be used for email protection. This sets the
+# id-kp-emailProtection (1.3.6.1.5.5.7.3.4) of extended key usage extension.
+#email_protection_key
+
+# Whether this key will be used for IPsec IKE operations (1.3.6.1.5.5.7.3.17).
+#ipsec_ike_key
+
+## adding custom key purpose OIDs
+
+# for microsoft smart card logon
+# key_purpose_oid = 1.3.6.1.4.1.311.20.2.2
+
+# for email protection
+# key_purpose_oid = 1.3.6.1.5.5.7.3.4
+
+# for any purpose (must not be used in intermediate CA certificates)
+# key_purpose_oid = 2.5.29.37.0
+
+### end of key purpose OIDs
+
+### Adding arbitrary extensions
+# This requires to provide the extension OIDs, as well as the extension data in
+# hex format. The following two options are available since GnuTLS 3.5.3.
+#add_extension = "1.2.3.4 0x0AAB01ACFE"
+
+# As above but encode the data as an octet string
+#add_extension = "1.2.3.4 octet_string(0x0AAB01ACFE)"
+
+# For portability critical extensions shouldn't be set to certificates.
+#add_critical_extension = "5.6.7.8 0x1AAB01ACFE"
+
+# When generating a certificate from a certificate
+# request, then honor the extensions stored in the request
+# and store them in the real certificate.
+#honor_crq_extensions
+
+# Alternatively only specific extensions can be copied.
+#honor_crq_ext = 2.5.29.17
+#honor_crq_ext = 2.5.29.15
+
+# Path length constraint. Sets the maximum number of
+# certificates that can be used to certify this certificate.
+# (i.e. the certificate chain length)
+#path_len = -1
+#path_len = 2
+
+# OCSP URI
+# ocsp_uri = https://my.ocsp.server/ocsp
+
+# CA issuers URI
+# ca_issuers_uri = https://my.ca.issuer
+
+# Certificate policies
+#policy1 = 1.3.6.1.4.1.5484.1.10.99.1.0
+#policy1_txt = "This is a long policy to summarize"
+#policy1_url = https://www.example.com/a-policy-to-read
+
+#policy2 = 1.3.6.1.4.1.5484.1.10.99.1.1
+#policy2_txt = "This is a short policy"
+#policy2_url = https://www.example.com/another-policy-to-read
+
+# The number of additional certificates that may appear in a
+# path before the anyPolicy is no longer acceptable.
+#inhibit_anypolicy_skip_certs 1
+
+# Name constraints
+
+# DNS
+#nc_permit_dns = example.com
+#nc_exclude_dns = test.example.com
+
+# EMAIL
+#nc_permit_email = "nmav@@ex.net"
+
+# Exclude subdomains of example.com
+#nc_exclude_email = .example.com
+
+# Exclude all e-mail addresses of example.com
+#nc_exclude_email = example.com
+
+# IP
+#nc_permit_ip = 192.168.0.0/16
+#nc_exclude_ip = 192.168.5.0/24
+#nc_permit_ip = fc0a:eef2:e7e7:a56e::/64
+
+
+# Options for proxy certificates
+#proxy_policy_language = 1.3.6.1.5.5.7.21.1
+
+
+# Options for generating a CRL
+
+# The number of days the next CRL update will be due.
+# next CRL update will be in 43 days
+#crl_next_update = 43
+
+# this is the 5th CRL by this CA
+# The value is in decimal (i.e. 1963) or hex (i.e. 0x07ab).
+# Comment the field for a time-based number.
+# Time-based CRL numbers generated in GnuTLS 3.6.3 and later
+# are significantly larger than those generated in previous
+# versions. Since CRL numbers need to be monotonic, you need
+# to specify the CRL number here manually if you intend to
+# downgrade to an earlier version than 3.6.3 after publishing
+# the CRL as it is not possible to specify CRL numbers greater
+# than 2**63-2 using hex notation in those versions.
+#crl_number = 5
+
+# Specify the update dates more precisely.
+#crl_this_update_date = "2004-02-29 16:21:42"
+#crl_next_update_date = "2025-02-29 16:24:41"
+
+# The date that the certificates will be made seen as
+# being revoked.
+#crl_revocation_date = "2025-02-29 16:24:41"
+
+@end example
+
diff --git a/doc/certtool-see-also.texi b/doc/certtool-see-also.texi
new file mode 100644
index 0000000000..f9b0e55734
--- /dev/null
+++ b/doc/certtool-see-also.texi
@@ -0,0 +1 @@
+ p11tool (1), psktool (1), srptool (1)
diff --git a/doc/danetool-examples.texi b/doc/danetool-examples.texi
new file mode 100644
index 0000000000..1c5ec786ef
--- /dev/null
+++ b/doc/danetool-examples.texi
@@ -0,0 +1,39 @@
+@subheading DANE TLSA RR generation
+
+To create a DANE TLSA resource record for a certificate (or public key)
+that was issued localy and may or may not be signed by a CA use the following command.
+@example
+$ danetool --tlsa-rr --host www.example.com --load-certificate cert.pem
+@end example
+
+To create a DANE TLSA resource record for a CA signed certificate, which will
+be marked as such use the following command.
+@example
+$ danetool --tlsa-rr --host www.example.com --load-certificate cert.pem \
+ --no-domain
+@end example
+
+The former is useful to add in your DNS entry even if your certificate is signed
+by a CA. That way even users who do not trust your CA will be able to verify your
+certificate using DANE.
+
+In order to create a record for the CA signer of your certificate use the following.
+@example
+$ danetool --tlsa-rr --host www.example.com --load-certificate cert.pem \
+ --ca --no-domain
+@end example
+
+To read a server's DANE TLSA entry, use:
+@example
+$ danetool --check www.example.com --proto tcp --port 443
+@end example
+
+To verify an HTTPS server's DANE TLSA entry, use:
+@example
+$ danetool --check www.example.com --proto tcp --port 443 --load-certificate chain.pem
+@end example
+
+To verify an SMTP server's DANE TLSA entry, use:
+@example
+$ danetool --check www.example.com --proto tcp --starttls-proto=smtp --load-certificate chain.pem
+@end example
diff --git a/doc/danetool-see-also.texi b/doc/danetool-see-also.texi
new file mode 100644
index 0000000000..6647d5ae32
--- /dev/null
+++ b/doc/danetool-see-also.texi
@@ -0,0 +1 @@
+ certtool (1)
diff --git a/src/cli-debug-args.def b/doc/gnutls-cli-debug-examples.texi
index 21c6a42e30..5114fc0673 100644
--- a/src/cli-debug-args.def
+++ b/doc/gnutls-cli-debug-examples.texi
@@ -1,56 +1,3 @@
-AutoGen Definitions options;
-prog-name = gnutls-cli-debug;
-prog-title = "GnuTLS debug client";
-prog-desc = "Simple client program to check TLS server capabilities.";
-short-usage = "Usage: gnutls-cli-debug [options] hostname\n"
- "gnutls-cli --help for usage instructions.\n";
-explain = "";
-detail = "TLS debug client. It sets up multiple TLS connections to
-a server and queries its capabilities. It was created to assist in debugging
-GnuTLS, but it might be useful to extract a TLS server's capabilities.
-It connects to a TLS server, performs tests and print the server's
-capabilities. If called with the `-V' parameter more checks will be performed.
-Can be used to check for servers with special needs or bugs.";
-reorder-args;
-argument;
-
-#define VERBOSE_OPT 1
-#include args-std.def
-
-flag = {
- name = port;
- value = p;
- arg-type = number;
- arg-range = "0 -> 65536";
- descrip = "The port to connect to";
- doc = "";
-};
-
-flag = {
- name = app-proto;
- aliases = starttls-proto;
-};
-
-flag = {
- name = starttls-proto;
- arg-type = string;
- descrip = "The application protocol to be used to obtain the server's certificate (https, ftp, smtp, imap, ldap, xmpp, lmtp, pop3, nntp, sieve, postgres)";
- doc = "Specify the application layer protocol for STARTTLS. If the protocol is supported, gnutls-cli will proceed to the TLS negotiation.";
-};
-
-
-doc-section = {
- ds-type = 'SEE ALSO'; // or anything else
- ds-format = 'texi'; // or texi or mdoc format
- ds-text = <<-_EOText_
-gnutls-cli(1), gnutls-serv(1)
-_EOText_;
-};
-
-doc-section = {
- ds-type = 'EXAMPLES';
- ds-format = 'texi';
- ds-text = <<-_EOF_
@example
$ gnutls-cli-debug localhost
GnuTLS debug client 3.5.0
@@ -107,6 +54,3 @@ You could also use the client to debug services with starttls capability.
$ gnutls-cli-debug --starttls-proto smtp --port 25 localhost
@end example
-_EOF_;
-};
-
diff --git a/doc/gnutls-cli-debug-see-also.texi b/doc/gnutls-cli-debug-see-also.texi
new file mode 100644
index 0000000000..ab20906b44
--- /dev/null
+++ b/doc/gnutls-cli-debug-see-also.texi
@@ -0,0 +1 @@
+gnutls-cli(1), gnutls-serv(1)
diff --git a/doc/gnutls-cli-examples.texi b/doc/gnutls-cli-examples.texi
new file mode 100644
index 0000000000..9eec1aae8c
--- /dev/null
+++ b/doc/gnutls-cli-examples.texi
@@ -0,0 +1,99 @@
+@subheading Connecting using PSK authentication
+To connect to a server using PSK authentication, you need to enable the choice of PSK by using a cipher priority parameter such as in the example below.
+@example
+$ ./gnutls-cli -p 5556 localhost --pskusername psk_identity \
+ --pskkey 88f3824b3e5659f52d00e959bacab954b6540344 \
+ --priority NORMAL:-KX-ALL:+ECDHE-PSK:+DHE-PSK:+PSK
+Resolving 'localhost'...
+Connecting to '127.0.0.1:5556'...
+- PSK authentication.
+- Version: TLS1.1
+- Key Exchange: PSK
+- Cipher: AES-128-CBC
+- MAC: SHA1
+- Compression: NULL
+- Handshake was completed
+
+- Simple Client Mode:
+@end example
+By keeping the --pskusername parameter and removing the --pskkey parameter, it will query only for the password during the handshake.
+
+@subheading Connecting using raw public-key authentication
+To connect to a server using raw public-key authentication, you need to enable the option to negotiate raw public-keys via the priority strings such as in the example below.
+@example
+$ ./gnutls-cli -p 5556 localhost --priority NORMAL:-CTYPE-CLI-ALL:+CTYPE-CLI-RAWPK \
+ --rawpkkeyfile cli.key.pem \
+ --rawpkfile cli.rawpk.pem
+Processed 1 client raw public key pair...
+Resolving 'localhost'...
+Connecting to '127.0.0.1:5556'...
+- Successfully sent 1 certificate(s) to server.
+- Server has requested a certificate.
+- Certificate type: X.509
+- Got a certificate list of 1 certificates.
+- Certificate[0] info:
+ - skipped
+- Description: (TLS1.3-Raw Public Key-X.509)-(ECDHE-SECP256R1)-(RSA-PSS-RSAE-SHA256)-(AES-256-GCM)
+- Options:
+- Handshake was completed
+
+- Simple Client Mode:
+@end example
+
+@subheading Connecting to STARTTLS services
+
+You could also use the client to connect to services with starttls capability.
+@example
+$ gnutls-cli --starttls-proto smtp --port 25 localhost
+@end example
+
+@subheading Listing ciphersuites in a priority string
+To list the ciphersuites in a priority string:
+@example
+$ ./gnutls-cli --priority SECURE192 -l
+Cipher suites for SECURE192
+TLS_ECDHE_ECDSA_AES_256_CBC_SHA384 0xc0, 0x24 TLS1.2
+TLS_ECDHE_ECDSA_AES_256_GCM_SHA384 0xc0, 0x2e TLS1.2
+TLS_ECDHE_RSA_AES_256_GCM_SHA384 0xc0, 0x30 TLS1.2
+TLS_DHE_RSA_AES_256_CBC_SHA256 0x00, 0x6b TLS1.2
+TLS_DHE_DSS_AES_256_CBC_SHA256 0x00, 0x6a TLS1.2
+TLS_RSA_AES_256_CBC_SHA256 0x00, 0x3d TLS1.2
+
+Certificate types: CTYPE-X.509
+Protocols: VERS-TLS1.2, VERS-TLS1.1, VERS-TLS1.0, VERS-SSL3.0, VERS-DTLS1.0
+Compression: COMP-NULL
+Elliptic curves: CURVE-SECP384R1, CURVE-SECP521R1
+PK-signatures: SIGN-RSA-SHA384, SIGN-ECDSA-SHA384, SIGN-RSA-SHA512, SIGN-ECDSA-SHA512
+@end example
+
+@subheading Connecting using a PKCS #11 token
+To connect to a server using a certificate and a private key present in a PKCS #11 token you
+need to substitute the PKCS 11 URLs in the x509certfile and x509keyfile parameters.
+
+Those can be found using "p11tool --list-tokens" and then listing all the objects in the
+needed token, and using the appropriate.
+@example
+$ p11tool --list-tokens
+
+Token 0:
+ URL: pkcs11:model=PKCS15;manufacturer=MyMan;serial=1234;token=Test
+ Label: Test
+ Manufacturer: EnterSafe
+ Model: PKCS15
+ Serial: 1234
+
+$ p11tool --login --list-certs "pkcs11:model=PKCS15;manufacturer=MyMan;serial=1234;token=Test"
+
+Object 0:
+ URL: pkcs11:model=PKCS15;manufacturer=MyMan;serial=1234;token=Test;object=client;type=cert
+ Type: X.509 Certificate
+ Label: client
+ ID: 2a:97:0d:58:d1:51:3c:23:07:ae:4e:0d:72:26:03:7d:99:06:02:6a
+
+$ MYCERT="pkcs11:model=PKCS15;manufacturer=MyMan;serial=1234;token=Test;object=client;type=cert"
+$ MYKEY="pkcs11:model=PKCS15;manufacturer=MyMan;serial=1234;token=Test;object=client;type=private"
+$ export MYCERT MYKEY
+
+$ gnutls-cli www.example.com --x509keyfile $MYKEY --x509certfile $MYCERT
+@end example
+Notice that the private key only differs from the certificate in the type.
diff --git a/doc/gnutls-cli-see-also.texi b/doc/gnutls-cli-see-also.texi
new file mode 100644
index 0000000000..589896282f
--- /dev/null
+++ b/doc/gnutls-cli-see-also.texi
@@ -0,0 +1 @@
+gnutls-cli-debug(1), gnutls-serv(1)
diff --git a/doc/gnutls-serv-examples.texi b/doc/gnutls-serv-examples.texi
new file mode 100644
index 0000000000..6dd2d75c8f
--- /dev/null
+++ b/doc/gnutls-serv-examples.texi
@@ -0,0 +1,147 @@
+Running your own TLS server based on GnuTLS can be useful when
+debugging clients and/or GnuTLS itself. This section describes how to
+use @code{gnutls-serv} as a simple HTTPS server.
+
+The most basic server can be started as:
+
+@example
+gnutls-serv --http --priority "NORMAL:+ANON-ECDH:+ANON-DH"
+@end example
+
+It will only support anonymous ciphersuites, which many TLS clients
+refuse to use.
+
+The next step is to add support for X.509. First we generate a CA:
+
+@example
+$ certtool --generate-privkey > x509-ca-key.pem
+$ echo 'cn = GnuTLS test CA' > ca.tmpl
+$ echo 'ca' >> ca.tmpl
+$ echo 'cert_signing_key' >> ca.tmpl
+$ certtool --generate-self-signed --load-privkey x509-ca-key.pem \
+ --template ca.tmpl --outfile x509-ca.pem
+@end example
+
+Then generate a server certificate. Remember to change the dns_name
+value to the name of your server host, or skip that command to avoid
+the field.
+
+@example
+$ certtool --generate-privkey > x509-server-key.pem
+$ echo 'organization = GnuTLS test server' > server.tmpl
+$ echo 'cn = test.gnutls.org' >> server.tmpl
+$ echo 'tls_www_server' >> server.tmpl
+$ echo 'encryption_key' >> server.tmpl
+$ echo 'signing_key' >> server.tmpl
+$ echo 'dns_name = test.gnutls.org' >> server.tmpl
+$ certtool --generate-certificate --load-privkey x509-server-key.pem \
+ --load-ca-certificate x509-ca.pem --load-ca-privkey x509-ca-key.pem \
+ --template server.tmpl --outfile x509-server.pem
+@end example
+
+For use in the client, you may want to generate a client certificate
+as well.
+
+@example
+$ certtool --generate-privkey > x509-client-key.pem
+$ echo 'cn = GnuTLS test client' > client.tmpl
+$ echo 'tls_www_client' >> client.tmpl
+$ echo 'encryption_key' >> client.tmpl
+$ echo 'signing_key' >> client.tmpl
+$ certtool --generate-certificate --load-privkey x509-client-key.pem \
+ --load-ca-certificate x509-ca.pem --load-ca-privkey x509-ca-key.pem \
+ --template client.tmpl --outfile x509-client.pem
+@end example
+
+To be able to import the client key/certificate into some
+applications, you will need to convert them into a PKCS#12 structure.
+This also encrypts the security sensitive key with a password.
+
+@example
+$ certtool --to-p12 --load-ca-certificate x509-ca.pem \
+ --load-privkey x509-client-key.pem --load-certificate x509-client.pem \
+ --outder --outfile x509-client.p12
+@end example
+
+For icing, we'll create a proxy certificate for the client too.
+
+@example
+$ certtool --generate-privkey > x509-proxy-key.pem
+$ echo 'cn = GnuTLS test client proxy' > proxy.tmpl
+$ certtool --generate-proxy --load-privkey x509-proxy-key.pem \
+ --load-ca-certificate x509-client.pem --load-ca-privkey x509-client-key.pem \
+ --load-certificate x509-client.pem --template proxy.tmpl \
+ --outfile x509-proxy.pem
+@end example
+
+Then start the server again:
+
+@example
+$ gnutls-serv --http \
+ --x509cafile x509-ca.pem \
+ --x509keyfile x509-server-key.pem \
+ --x509certfile x509-server.pem
+@end example
+
+Try connecting to the server using your web browser. Note that the
+server listens to port 5556 by default.
+
+While you are at it, to allow connections using ECDSA, you can also
+create a ECDSA key and certificate for the server. These credentials
+will be used in the final example below.
+
+@example
+$ certtool --generate-privkey --ecdsa > x509-server-key-ecc.pem
+$ certtool --generate-certificate --load-privkey x509-server-key-ecc.pem \
+ --load-ca-certificate x509-ca.pem --load-ca-privkey x509-ca-key.pem \
+ --template server.tmpl --outfile x509-server-ecc.pem
+@end example
+
+
+The next step is to add support for SRP authentication. This requires
+an SRP password file created with @code{srptool}.
+To start the server with SRP support:
+
+@example
+gnutls-serv --http --priority NORMAL:+SRP-RSA:+SRP \
+ --srppasswdconf srp-tpasswd.conf \
+ --srppasswd srp-passwd.txt
+@end example
+
+Let's also start a server with support for PSK. This would require
+a password file created with @code{psktool}.
+
+@example
+gnutls-serv --http --priority NORMAL:+ECDHE-PSK:+PSK \
+ --pskpasswd psk-passwd.txt
+@end example
+
+If you want a server with support for raw public-keys we can also add these
+credentials. Note however that there is no identity information linked to these
+keys as is the case with regular x509 certificates. Authentication must be done
+via different means. Also we need to explicitly enable raw public-key certificates
+via the priority strings.
+
+@example
+gnutls-serv --http --priority NORMAL:+CTYPE-CLI-RAWPK:+CTYPE-SRV-RAWPK \
+ --rawpkfile srv.rawpk.pem \
+ --rawpkkeyfile srv.key.pem
+@end example
+
+
+Finally, we start the server with all the earlier parameters and you
+get this command:
+
+@example
+gnutls-serv --http --priority NORMAL:+PSK:+SRP:+CTYPE-CLI-RAWPK:+CTYPE-SRV-RAWPK \
+ --x509cafile x509-ca.pem \
+ --x509keyfile x509-server-key.pem \
+ --x509certfile x509-server.pem \
+ --x509keyfile x509-server-key-ecc.pem \
+ --x509certfile x509-server-ecc.pem \
+ --srppasswdconf srp-tpasswd.conf \
+ --srppasswd srp-passwd.txt \
+ --pskpasswd psk-passwd.txt \
+ --rawpkfile srv.rawpk.pem \
+ --rawpkkeyfile srv.key.pem
+@end example
diff --git a/doc/gnutls-serv-see-also.texi b/doc/gnutls-serv-see-also.texi
new file mode 100644
index 0000000000..00d832b601
--- /dev/null
+++ b/doc/gnutls-serv-see-also.texi
@@ -0,0 +1 @@
+gnutls-cli-debug(1), gnutls-cli(1)
diff --git a/doc/manpages/Makefile.am b/doc/manpages/Makefile.am
index c3bcac9f3b..8e1e25d06e 100644
--- a/doc/manpages/Makefile.am
+++ b/doc/manpages/Makefile.am
@@ -43,61 +43,107 @@ endif
EXTRA_DIST += $(TOOLS_MANS) $(SRP_MANS) $(DANE_MANS)
MAINTAINERCLEANFILES += $(TOOLS_MANS) $(SRP_MANS) $(DANE_MANS)
-# Note that our .def files depend on autogen
-# supporting the @subheading texi keyword. This
-# is not currently the case so we do remove it
-# before processing. Once the new version of autogen
-# is out, replace the sed and tmp files with a simple
-# autogen -L ../../src -DMAN_SECTION=1 -Tagman-cmd.tpl $<
-certtool.1: ../../src/certtool-args.def
- -sed 's/@subheading \(.*\)/@*\n@var{\1}\n@*/' $< > "$<".tmp && \
- autogen -L ../../src -DMAN_SECTION=1 -Tagman-cmd.tpl "$<".tmp && \
- rm -f "$<".tmp
+$(man_MANS): $(top_srcdir)/doc/scripts/gen-cmd-man.py
-ocsptool.1: ../../src/ocsptool-args.def
- -sed 's/@subheading \(.*\)/@*\n@var{\1}\n@*/' $< > "$<".tmp && \
- autogen -L ../../src -DMAN_SECTION=1 -Tagman-cmd.tpl "$<".tmp && \
- rm -f "$<".tmp
+GEN_CMD_MAN_OPTIONS = \
+ --license=gpl3+ \
+ --version='$(VERSION)' \
+ --authors='Nikos Mavrogiannopoulos, Simon Josefsson and others; see /usr/share/doc/gnutls/AUTHORS for a complete list.' \
+ --copyright-year=2020-2021 \
+ --copyright-holder='Free Software Foundation, and others all rights reserved.' \
+ --bug-email=bugs@gnutls.org
-danetool.1: ../../src/danetool-args.def
- -sed 's/@subheading \(.*\)/@*\n@var{\1}\n@*/' $< > "$<".tmp && \
- autogen -L ../../src -DMAN_SECTION=1 -Tagman-cmd.tpl "$<".tmp && \
- rm -f "$<".tmp
+certtool.1: $(top_srcdir)/doc/certtool-see-also.texi $(top_srcdir)/doc/certtool-examples.texi $(top_srcdir)/doc/certtool-files.texi
+certtool.1: $(top_srcdir)/src/certtool-options.json
+ $(AM_V_GEN) PYTHONPATH='$(top_srcdir)/python' \
+ $(PYTHON) $(top_srcdir)/doc/scripts/gen-cmd-man.py \
+ --see-also $(top_srcdir)/doc/certtool-see-also.texi \
+ --examples $(top_srcdir)/doc/certtool-examples.texi \
+ --files $(top_srcdir)/doc/certtool-files.texi \
+ $(GEN_CMD_MAN_OPTIONS) \
+ $< $@
-gnutls-cli.1: ../../src/cli-args.def
- -sed 's/@subheading \(.*\)/@*\n@var{\1}\n@*/' $< > "$<".tmp && \
- autogen -L ../../src -DMAN_SECTION=1 -Tagman-cmd.tpl "$<".tmp && \
- rm -f "$<".tmp
+ocsptool.1: $(top_srcdir)/doc/ocsptool-see-also.texi $(top_srcdir)/doc/ocsptool-examples.texi $(top_srcdir)/doc/ocsptool-description.texi
+ocsptool.1: $(top_srcdir)/src/ocsptool-options.json
+ $(AM_V_GEN) PYTHONPATH='$(top_srcdir)/python' \
+ $(PYTHON) $(top_srcdir)/doc/scripts/gen-cmd-man.py \
+ --see-also $(top_srcdir)/doc/ocsptool-see-also.texi \
+ --examples $(top_srcdir)/doc/ocsptool-examples.texi \
+ --description $(top_srcdir)/doc/ocsptool-description.texi \
+ $(GEN_CMD_MAN_OPTIONS) \
+ $< $@
-gnutls-serv.1: ../../src/serv-args.def
- -sed 's/@subheading \(.*\)/@*\n@var{\1}\n@*/' $< > "$<".tmp && \
- autogen -L ../../src -DMAN_SECTION=1 -Tagman-cmd.tpl "$<".tmp && \
- rm -f "$<".tmp
+danetool.1: $(top_srcdir)/doc/danetool-see-also.texi $(top_srcdir)/doc/danetool-examples.texi
+danetool.1: $(top_srcdir)/src/danetool-options.json
+ $(AM_V_GEN) PYTHONPATH='$(top_srcdir)/python' \
+ $(PYTHON) $(top_srcdir)/doc/scripts/gen-cmd-man.py \
+ --see-also $(top_srcdir)/doc/danetool-see-also.texi \
+ --examples $(top_srcdir)/doc/danetool-examples.texi \
+ $(GEN_CMD_MAN_OPTIONS) \
+ $< $@
-gnutls-cli-debug.1: ../../src/cli-debug-args.def
- -sed 's/@subheading \(.*\)/@*\n@var{\1}\n@*/' $< > "$<".tmp && \
- autogen -L ../../src -DMAN_SECTION=1 -Tagman-cmd.tpl "$<".tmp && \
- rm -f "$<".tmp
+gnutls-cli.1: $(top_srcdir)/doc/gnutls-cli-see-also.texi $(top_srcdir)/doc/gnutls-cli-examples.texi
+gnutls-cli.1: $(top_srcdir)/src/gnutls-cli-options.json
+ $(AM_V_GEN) PYTHONPATH='$(top_srcdir)/python' \
+ $(PYTHON) $(top_srcdir)/doc/scripts/gen-cmd-man.py \
+ --see-also $(top_srcdir)/doc/gnutls-cli-see-also.texi \
+ --examples $(top_srcdir)/doc/gnutls-cli-examples.texi \
+ $(GEN_CMD_MAN_OPTIONS) \
+ $< $@
-srptool.1: ../../src/srptool-args.def
- -sed 's/@subheading \(.*\)/@*\n@var{\1}\n@*/' $< > "$<".tmp && \
- autogen -L ../../src -DMAN_SECTION=1 -Tagman-cmd.tpl "$<".tmp && \
- rm -f "$<".tmp
+gnutls-serv.1: $(top_srcdir)/doc/gnutls-serv-see-also.texi $(top_srcdir)/doc/gnutls-serv-examples.texi
+gnutls-serv.1: $(top_srcdir)/src/gnutls-serv-options.json
+ $(AM_V_GEN) PYTHONPATH='$(top_srcdir)/python' \
+ $(PYTHON) $(top_srcdir)/doc/scripts/gen-cmd-man.py \
+ --see-also $(top_srcdir)/doc/gnutls-serv-see-also.texi \
+ --examples $(top_srcdir)/doc/gnutls-serv-examples.texi \
+ $(GEN_CMD_MAN_OPTIONS) \
+ $< $@
-p11tool.1: ../../src/p11tool-args.def
- -sed 's/@subheading \(.*\)/@*\n@var{\1}\n@*/' $< > "$<".tmp && \
- autogen -L ../../src -DMAN_SECTION=1 -Tagman-cmd.tpl "$<".tmp && \
- rm -f "$<".tmp
+gnutls-cli-debug.1: $(top_srcdir)/doc/gnutls-cli-debug-see-also.texi $(top_srcdir)/doc/gnutls-cli-debug-examples.texi
+gnutls-cli-debug.1: $(top_srcdir)/src/gnutls-cli-debug-options.json
+ $(AM_V_GEN) PYTHONPATH='$(top_srcdir)/python' \
+ $(PYTHON) $(top_srcdir)/doc/scripts/gen-cmd-man.py \
+ --see-also $(top_srcdir)/doc/gnutls-cli-debug-see-also.texi \
+ --examples $(top_srcdir)/doc/gnutls-cli-debug-examples.texi \
+ $(GEN_CMD_MAN_OPTIONS) \
+ $< $@
-tpmtool.1: ../../src/tpmtool-args.def
- -sed 's/@subheading \(.*\)/@*\n@var{\1}\n@*/' $< > "$<".tmp && \
- autogen -L ../../src -DMAN_SECTION=1 -Tagman-cmd.tpl "$<".tmp && \
- rm -f "$<".tmp
+srptool.1: $(top_srcdir)/doc/srptool-see-also.texi $(top_srcdir)/doc/srptool-examples.texi
+srptool.1: $(top_srcdir)/src/srptool-options.json
+ $(AM_V_GEN) PYTHONPATH='$(top_srcdir)/python' \
+ $(PYTHON) $(top_srcdir)/doc/scripts/gen-cmd-man.py \
+ --see-also $(top_srcdir)/doc/srptool-see-also.texi \
+ --examples $(top_srcdir)/doc/srptool-examples.texi \
+ $(GEN_CMD_MAN_OPTIONS) \
+ $< $@
-psktool.1: ../../src/psktool-args.def
- -sed 's/@subheading \(.*\)/@*\n@var{\1}\n@*/' $< > "$<".tmp && \
- autogen -L ../../src -DMAN_SECTION=1 -Tagman-cmd.tpl "$<".tmp && \
- rm -f "$<".tmp
+p11tool.1: $(top_srcdir)/doc/p11tool-see-also.texi $(top_srcdir)/doc/p11tool-examples.texi
+p11tool.1: $(top_srcdir)/src/p11tool-options.json
+ $(AM_V_GEN) PYTHONPATH='$(top_srcdir)/python' \
+ $(PYTHON) $(top_srcdir)/doc/scripts/gen-cmd-man.py \
+ --see-also $(top_srcdir)/doc/p11tool-see-also.texi \
+ --examples $(top_srcdir)/doc/p11tool-examples.texi \
+ $(GEN_CMD_MAN_OPTIONS) \
+ $< $@
+
+tpmtool.1: $(top_srcdir)/doc/tpmtool-see-also.texi $(top_srcdir)/doc/tpmtool-examples.texi
+tpmtool.1: $(top_srcdir)/src/tpmtool-options.json
+ $(AM_V_GEN) PYTHONPATH='$(top_srcdir)/python' \
+ $(PYTHON) $(top_srcdir)/doc/scripts/gen-cmd-man.py \
+ --see-also $(top_srcdir)/doc/tpmtool-see-also.texi \
+ --examples $(top_srcdir)/doc/tpmtool-examples.texi \
+ $(GEN_CMD_MAN_OPTIONS) \
+ $< $@
+
+psktool.1: $(top_srcdir)/doc/psktool-see-also.texi $(top_srcdir)/doc/psktool-examples.texi
+psktool.1: $(top_srcdir)/src/psktool-options.json
+ $(AM_V_GEN) PYTHONPATH='$(top_srcdir)/python' \
+ $(PYTHON) $(top_srcdir)/doc/scripts/gen-cmd-man.py \
+ --see-also $(top_srcdir)/doc/psktool-see-also.texi \
+ --examples $(top_srcdir)/doc/psktool-examples.texi \
+ $(GEN_CMD_MAN_OPTIONS) \
+ $< $@
APIMANS =
APIMANS += dane_cert_type_name.3
diff --git a/doc/ocsptool-description.texi b/doc/ocsptool-description.texi
new file mode 100644
index 0000000000..a7b080536c
--- /dev/null
+++ b/doc/ocsptool-description.texi
@@ -0,0 +1,6 @@
+@subheading On verification
+Responses are typically signed/issued by designated certificates or
+certificate authorities and thus this tool requires on verification
+the certificate of the issuer or the full certificate chain in order to
+determine the appropriate signing authority. The specified certificate
+of the issuer is assumed trusted.
diff --git a/doc/ocsptool-examples.texi b/doc/ocsptool-examples.texi
new file mode 100644
index 0000000000..38b5db7124
--- /dev/null
+++ b/doc/ocsptool-examples.texi
@@ -0,0 +1,128 @@
+@subheading Print information about an OCSP request
+
+To parse an OCSP request and print information about the content, the
+@code{-i} or @code{--request-info} parameter may be used as follows.
+The @code{-Q} parameter specify the name of the file containing the
+OCSP request, and it should contain the OCSP request in binary DER
+format.
+
+@example
+$ ocsptool -i -Q ocsp-request.der
+@end example
+
+The input file may also be sent to standard input like this:
+
+@example
+$ cat ocsp-request.der | ocsptool --request-info
+@end example
+
+@subheading Print information about an OCSP response
+
+Similar to parsing OCSP requests, OCSP responses can be parsed using
+the @code{-j} or @code{--response-info} as follows.
+
+@example
+$ ocsptool -j -Q ocsp-response.der
+$ cat ocsp-response.der | ocsptool --response-info
+@end example
+
+@subheading Generate an OCSP request
+
+The @code{-q} or @code{--generate-request} parameters are used to
+generate an OCSP request. By default the OCSP request is written to
+standard output in binary DER format, but can be stored in a file
+using @code{--outfile}. To generate an OCSP request the issuer of the
+certificate to check needs to be specified with @code{--load-issuer}
+and the certificate to check with @code{--load-cert}. By default PEM
+format is used for these files, although @code{--inder} can be used to
+specify that the input files are in DER format.
+
+@example
+$ ocsptool -q --load-issuer issuer.pem --load-cert client.pem \
+ --outfile ocsp-request.der
+@end example
+
+When generating OCSP requests, the tool will add an OCSP extension
+containing a nonce. This behaviour can be disabled by specifying
+@code{--no-nonce}.
+
+@subheading Verify signature in OCSP response
+
+To verify the signature in an OCSP response the @code{-e} or
+@code{--verify-response} parameter is used. The tool will read an
+OCSP response in DER format from standard input, or from the file
+specified by @code{--load-response}. The OCSP response is verified
+against a set of trust anchors, which are specified using
+@code{--load-trust}. The trust anchors are concatenated certificates
+in PEM format. The certificate that signed the OCSP response needs to
+be in the set of trust anchors, or the issuer of the signer
+certificate needs to be in the set of trust anchors and the OCSP
+Extended Key Usage bit has to be asserted in the signer certificate.
+
+@example
+$ ocsptool -e --load-trust issuer.pem \
+ --load-response ocsp-response.der
+@end example
+
+The tool will print status of verification.
+
+@subheading Verify signature in OCSP response against given certificate
+
+It is possible to override the normal trust logic if you know that a
+certain certificate is supposed to have signed the OCSP response, and
+you want to use it to check the signature. This is achieved using
+@code{--load-signer} instead of @code{--load-trust}. This will load
+one certificate and it will be used to verify the signature in the
+OCSP response. It will not check the Extended Key Usage bit.
+
+@example
+$ ocsptool -e --load-signer ocsp-signer.pem \
+ --load-response ocsp-response.der
+@end example
+
+This approach is normally only relevant in two situations. The first
+is when the OCSP response does not contain a copy of the signer
+certificate, so the @code{--load-trust} code would fail. The second
+is if you want to avoid the indirect mode where the OCSP response
+signer certificate is signed by a trust anchor.
+
+@subheading Real-world example
+
+Here is an example of how to generate an OCSP request for a
+certificate and to verify the response. For illustration we'll use
+the @code{blog.josefsson.org} host, which (as of writing) uses a
+certificate from CACert. First we'll use @code{gnutls-cli} to get a
+copy of the server certificate chain. The server is not required to
+send this information, but this particular one is configured to do so.
+
+@example
+$ echo | gnutls-cli -p 443 blog.josefsson.org --save-cert chain.pem
+@end example
+
+The saved certificates normally contain a pointer to where the OCSP
+responder is located, in the Authority Information Access Information
+extension. For example, from @code{certtool -i < chain.pem} there is
+this information:
+
+@example
+ Authority Information Access Information (not critical):
+ Access Method: 1.3.6.1.5.5.7.48.1 (id-ad-ocsp)
+ Access Location URI: https://ocsp.CAcert.org/
+@end example
+
+This means that ocsptool can discover the servers to contact over HTTP.
+We can now request information on the chain certificates.
+
+@example
+$ ocsptool --ask --load-chain chain.pem
+@end example
+
+The request is sent via HTTP to the OCSP server address found in
+the certificates. It is possible to override the address of the
+OCSP server as well as ask information on a particular certificate
+using --load-cert and --load-issuer.
+
+@example
+$ ocsptool --ask https://ocsp.CAcert.org/ --load-chain chain.pem
+@end example
+
diff --git a/doc/ocsptool-see-also.texi b/doc/ocsptool-see-also.texi
new file mode 100644
index 0000000000..6647d5ae32
--- /dev/null
+++ b/doc/ocsptool-see-also.texi
@@ -0,0 +1 @@
+ certtool (1)
diff --git a/doc/p11tool-examples.texi b/doc/p11tool-examples.texi
new file mode 100644
index 0000000000..09871a94e1
--- /dev/null
+++ b/doc/p11tool-examples.texi
@@ -0,0 +1,34 @@
+To view all tokens in your system use:
+@example
+$ p11tool --list-tokens
+@end example
+
+To view all objects in a token use:
+@example
+$ p11tool --login --list-all "pkcs11:TOKEN-URL"
+@end example
+
+To store a private key and a certificate in a token run:
+@example
+$ p11tool --login --write "pkcs11:URL" --load-privkey key.pem \
+ --label "Mykey"
+$ p11tool --login --write "pkcs11:URL" --load-certificate cert.pem \
+ --label "Mykey"
+@end example
+Note that some tokens require the same label to be used for the certificate
+and its corresponding private key.
+
+To generate an RSA private key inside the token use:
+@example
+$ p11tool --login --generate-privkey rsa --bits 1024 --label "MyNewKey" \
+ --outfile MyNewKey.pub "pkcs11:TOKEN-URL"
+@end example
+The bits parameter in the above example is explicitly set because some
+tokens only support limited choices in the bit length. The output file is the
+corresponding public key. This key can be used to general a certificate
+request with certtool.
+@example
+certtool --generate-request --load-privkey "pkcs11:KEY-URL" \
+ --load-pubkey MyNewKey.pub --outfile request.pem
+@end example
+
diff --git a/doc/p11tool-see-also.texi b/doc/p11tool-see-also.texi
new file mode 100644
index 0000000000..6647d5ae32
--- /dev/null
+++ b/doc/p11tool-see-also.texi
@@ -0,0 +1 @@
+ certtool (1)
diff --git a/doc/psktool-examples.texi b/doc/psktool-examples.texi
new file mode 100644
index 0000000000..343464a2b8
--- /dev/null
+++ b/doc/psktool-examples.texi
@@ -0,0 +1,12 @@
+To add a user 'psk_identity' in @file{keys.psk} for use with GnuTLS run:
+@example
+$ ./psktool -u psk_identity -p keys.psk
+Generating a random key for user 'psk_identity'
+Key stored to keys.psk
+$ cat keys.psk
+psk_identity:88f3824b3e5659f52d00e959bacab954b6540344
+$
+@end example
+
+This command will create @file{keys.psk} if it does not exist
+and will add user 'psk_identity'.
diff --git a/doc/psktool-see-also.texi b/doc/psktool-see-also.texi
new file mode 100644
index 0000000000..821c9e008a
--- /dev/null
+++ b/doc/psktool-see-also.texi
@@ -0,0 +1 @@
+ gnutls-cli-debug (1), gnutls-serv (1), srptool (1), certtool (1)
diff --git a/doc/scripts/Makefile.am b/doc/scripts/Makefile.am
index f7e192b98b..f1992c73fe 100644
--- a/doc/scripts/Makefile.am
+++ b/doc/scripts/Makefile.am
@@ -17,4 +17,4 @@
# along with this file; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-EXTRA_DIST = gdoc sort2.pl split-texi.pl cleanup-autogen.pl getfuncs.pl getfuncs-map.pl
+EXTRA_DIST = gdoc sort2.pl split-texi.pl getfuncs.pl getfuncs-map.pl gen-cmd-texi.py gen-cmd-man.py
diff --git a/doc/scripts/cleanup-autogen.pl b/doc/scripts/cleanup-autogen.pl
deleted file mode 100755
index a6b19e9e08..0000000000
--- a/doc/scripts/cleanup-autogen.pl
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright (C) 2012 Free Software Foundation, Inc.
-#
-# This file is part of GnuTLS.
-#
-# 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
-# (at your option) any later version.
-#
-# This file 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 file; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-my $line;
-my $init = 0;
-my $menu = 0;
-my $i = 0;
-
-while ($line = <>) {
-
- if ($line =~ /\@node (.*)/) {
- if ($init == 0) {
- $init = 1;
- } else {
- print "\@anchor\{$1\}\n";
- next;
- }
- }
-
- if ($line =~ /\@menu/) {
- $menu = 1;
- next;
- }
-
- if ($line =~ /\@end menu/) {
- $menu = 0;
- next;
- }
-
- next if ($menu != 0);
-
- if ($line =~ /\@subsection\s(.*)/) {
- $line = "\@subheading $1\n";
- }
-
- if ($line =~ /\@cindex\s(.*)/) {
- if ($line !~ /help/) {
- next;
- }
- }
-
- if ($line =~ /^Please send bug reports.*/) {
- next;
- }
-
- print $line;
- $i++;
-}
-
-if ($i < 2) {
- exit 1;
-}
-
-exit 0;
diff --git a/doc/scripts/gen-cmd-man.py b/doc/scripts/gen-cmd-man.py
new file mode 100644
index 0000000000..dbff09f94e
--- /dev/null
+++ b/doc/scripts/gen-cmd-man.py
@@ -0,0 +1,348 @@
+#!/usr/bin/python
+# Copyright (C) 2021 Daiki Ueno
+
+# This file is part of GnuTLS.
+
+# GnuTLS 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.
+
+# GnuTLS 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/>.
+
+from typing import Mapping, Optional, TextIO, Sequence
+import datetime
+import io
+import re
+import jsonopts
+
+
+def gen_option_docs(meta: Mapping[str, str],
+ options: Sequence[Mapping[str, str]]) -> str:
+ docs = io.StringIO()
+ for option in options:
+ long_opt = option['long-option']
+ long_opt_escaped = long_opt.replace('-', '\\-')
+ short_opt = option.get('short-option')
+ detail = option.get('detail')
+ desc = option.get('desc')
+ disable_prefix = option.get('disable-prefix')
+ if disable_prefix:
+ disable_opt: Optional[str] = f'{disable_prefix}{long_opt}'
+ else:
+ disable_opt = None
+ alias = option.get('aliases')
+ if alias:
+ docs.write(f'''\
+.TP
+.NOP \\f\\*[B-Font]\\-\\-{long_opt_escaped}\\f[]
+This is an alias for the \\fI--{alias}\\fR option.
+''')
+ if 'deprecated' in option:
+ docs.write('''\
+.sp
+.B
+NOTE: THIS OPTION IS DEPRECATED
+''')
+ continue
+
+ arg_type = option.get('arg-type')
+ if arg_type:
+ arg_name = option.get('arg-name', arg_type).lower()
+ arg = f'\\f\\*[I-Font]{arg_name}\\f[]'
+ long_arg = f'={arg}'
+ short_arg = f' {arg}'
+ else:
+ long_arg = ''
+ short_arg = ''
+ formatted_options = list()
+ if short_opt:
+ formatted_options.append(
+ f'\\f\\*[B-Font]\\-{short_opt}\\f[]{short_arg}'
+ )
+ formatted_options.append(
+ f'\\f\\*[B-Font]\\-\\-{long_opt_escaped}\\f[]{long_arg}'
+ )
+ if disable_opt:
+ disable_opt_escaped = disable_opt.replace('-', '\\-')
+ formatted_options.append(
+ f'\\f\\*[B-Font]\\-\\-{disable_opt_escaped}\\f[]'
+ )
+ docs.write(f'''\
+.TP
+.NOP {', '.join(formatted_options)}
+''')
+ if desc and desc[0].isupper():
+ docs.write(f'{desc}.\n')
+ if 'stack-arg' in option:
+ docs.write(
+ 'This option may appear an unlimited number of times.\n'
+ )
+ if arg_type == 'number':
+ docs.write(
+ 'This option takes an integer number as its argument.\n'
+ )
+ arg_min = option.get('arg-min')
+ arg_max = option.get('arg-max')
+ if arg_min and arg_max:
+ docs.write(f'''\
+The value of
+\\f\\*[I-Font]{arg_name}\\f[]
+is constrained to being:
+.in +4
+.nf
+.na
+in the range {arg_min} through {arg_max}
+.fi
+.in -4
+''')
+ conflict_opts = option.get('conflicts', '').split()
+ if len(conflict_opts) > 0:
+ docs.write(f'''\
+This option must not appear in combination with any of the following options:
+{', '.join(conflict_opts)}.
+''')
+ require_opts = option.get('requires', '').split()
+ if len(require_opts) > 0:
+ docs.write(f'''\
+This option must appear in combination with the following options:
+{', '.join(require_opts)}.
+''')
+ if disable_opt:
+ disable_opt_escaped = disable_opt.replace('-', '\\-')
+ docs.write((
+ f'The \\fI{disable_opt_escaped}\\fP form '
+ 'will disable the option.\n'
+ ))
+ if 'enabled' in option:
+ docs.write('This option is enabled by default.\n')
+ if desc and desc[0].isupper():
+ docs.write('.sp\n')
+ if detail:
+ docs.write(f'{text_to_man(detail)}\n')
+ if 'deprecated' in option:
+ docs.write('''\
+.sp
+.B
+NOTE: THIS OPTION IS DEPRECATED
+''')
+ return docs.getvalue()
+
+
+def text_to_man(s: str) -> str:
+ s = re.sub(r'-', r'\\-', s)
+ s = re.sub(r'(?m)^$', r'.sp', s)
+ s = re.sub(r"``(.*)''", r'\\(lq\1\\(rq', s)
+ return s
+
+
+def texi_to_man(s: str) -> str:
+ s = text_to_man(s)
+ s = re.sub(r'@([{}@])', r'\1', s)
+ s = re.sub(r'@code\{(.*?)\}', r'\\fB\1\\fP', s)
+ s = re.sub(r'@file\{(.*?)\}', r'\\fI\1\\fP', s)
+ s = re.sub(r'@subheading (.*)', r'''.br
+\\fB\1\\fP
+.br''', s)
+ s = re.sub(r'@example', r'''.br
+.in +4
+.nf''', s)
+ s = re.sub(r'@end example', r'''.in -4
+.fi''', s)
+ return s
+
+
+def include(name: str, includes: Mapping[str, TextIO]) -> str:
+ docs = io.StringIO()
+ f = includes.get(name)
+ if f:
+ docs.write(texi_to_man(f.read().strip()))
+ return docs.getvalue()
+
+
+LICENSES = {
+ 'gpl3+': 'the GNU General Public License, version 3 or later',
+}
+
+
+def gen(infile: TextIO,
+ meta: Mapping[str, str],
+ includes: Mapping[str, TextIO],
+ man: TextIO):
+ sections = [jsonopts.Section.from_json(section)
+ for section in json.load(args.json)]
+ sections.append(jsonopts.Section.default())
+
+ prog_name = sections[0].meta['prog-name']
+ prog_title = sections[0].meta['prog-title']
+ argument = sections[0].meta.get('argument')
+ authors = meta.get('authors', 'AUTHORS')
+ copyright_year = meta.get('copyright-year',
+ str(datetime.date.today().year))
+ copyright_holder = meta.get('copyright-holder', 'COPYRIGHT HOLDER')
+ license_text = LICENSES.get(meta['license'])
+ version = meta.get('version', '')
+ description = includes.get('description')
+ if description:
+ detail = texi_to_man(description.read())
+ else:
+ detail = sections[0].meta['detail']
+
+ section_docs = io.StringIO()
+ for section in sections:
+ section_id = section.meta.get('id', '')
+ if section_id:
+ section_desc = section.meta['desc']
+ option_docs = gen_option_docs(sections[0].meta, section.options)
+ section_docs.write(f'''\
+.SS "{section_desc}"
+{option_docs}\
+''')
+ else:
+ section_docs.write(gen_option_docs(sections[0].meta,
+ section.options))
+
+ formatted_date = datetime.date.today().strftime('%d %b %Y')
+ detail_concatenated = '\n.sp\n'.join(detail.strip().split('\n\n'))
+ man.write(f'''\
+.de1 NOP
+. it 1 an-trap
+. if \\\\n[.$] \\,\\\\$*\\/
+..
+.ie t \\
+.ds B-Font [CB]
+.ds I-Font [CI]
+.ds R-Font [CR]
+.el \\
+.ds B-Font B
+.ds I-Font I
+.ds R-Font R
+.TH {prog_name} 1 "{formatted_date}" "{version}" "User Commands"
+.SH NAME
+\\f\\*[B-Font]{prog_name}\\fP
+\\- {prog_title}
+.SH SYNOPSIS
+\\f\\*[B-Font]{prog_name}\\fP
+.\\" Mixture of short (flag) options and long options
+[\\f\\*[B-Font]\\-flags\\f[]]
+[\\f\\*[B-Font]\\-flag\\f[] [\\f\\*[I-Font]value\\f[]]]
+[\\f\\*[B-Font]\\-\\-option-name\\f[][[=| ]\\f\\*[I-Font]value\\f[]]]
+''')
+ if argument:
+ man.write(f'''\
+{argument}
+.sp \\n(Ppu
+.ne 2
+
+Operands and options may be intermixed. They will be reordered.
+.sp \\n(Ppu
+.ne 2
+''')
+ else:
+ man.write('''\
+.sp \\n(Ppu
+.ne 2
+
+All arguments must be options.
+.sp \\n(Ppu
+.ne 2
+''')
+ man.write(f'''\
+.SH "DESCRIPTION"
+{detail_concatenated}
+.sp
+.SH "OPTIONS"
+{section_docs.getvalue()}
+''')
+ if 'files' in includes:
+ man.write(f'''\
+.SH FILES
+{include('files', includes)}
+''')
+ if 'examples' in includes:
+ man.write(f'''\
+.sp
+.SH EXAMPLES
+{include('examples', includes)}
+''')
+ man.write('''\
+.SH "EXIT STATUS"
+One of the following exit values will be returned:
+.TP
+.NOP 0 " (EXIT_SUCCESS)"
+Successful program execution.
+.TP
+.NOP 1 " (EXIT_FAILURE)"
+The operation failed or the command syntax was not valid.
+.PP
+''')
+ if 'see-also' in includes:
+ man.write(f'''\
+.SH "SEE ALSO"
+{include('see-also', includes)}
+''')
+ man.write(f'''\
+.SH "AUTHORS"
+{authors}
+.SH "COPYRIGHT"
+Copyright (C) {copyright_year} {copyright_holder}
+This program is released under the terms of {license_text}.
+''')
+ bug_email = meta.get('bug-email')
+ if bug_email:
+ man.write(f'''\
+.SH "BUGS"
+Please send bug reports to: {bug_email}
+''')
+
+
+if __name__ == '__main__':
+ import argparse
+ import json
+
+ parser = argparse.ArgumentParser(description='generate man-page')
+ parser.add_argument('json', type=argparse.FileType('r'))
+ parser.add_argument('man', type=argparse.FileType('w'))
+ parser.add_argument('--description', type=argparse.FileType('r'))
+ parser.add_argument('--see-also', type=argparse.FileType('r'))
+ parser.add_argument('--examples', type=argparse.FileType('r'))
+ parser.add_argument('--files', type=argparse.FileType('r'))
+ parser.add_argument('--authors', help='authors')
+ parser.add_argument('--bug-email', help='bug report email address')
+ parser.add_argument('--copyright-year', help='copyright year')
+ parser.add_argument('--copyright-holder', help='copyright holder')
+ parser.add_argument('--license', help='license')
+ parser.add_argument('--version', help='version')
+
+ args = parser.parse_args()
+ includes = dict()
+ if args.see_also:
+ includes['see-also'] = args.see_also
+ if args.examples:
+ includes['examples'] = args.examples
+ if args.files:
+ includes['files'] = args.files
+ if args.description:
+ includes['description'] = args.description
+ meta = dict()
+ if args.authors:
+ meta['authors'] = args.authors
+ if args.bug_email:
+ meta['bug-email'] = args.bug_email
+ if args.copyright_year:
+ meta['copyright-year'] = args.copyright_year
+ if args.copyright_holder:
+ meta['copyright-holder'] = args.copyright_holder
+ if args.license:
+ meta['license'] = args.license
+ if args.version:
+ meta['version'] = args.version
+
+ gen(args.json, meta, includes, args.man)
diff --git a/doc/scripts/gen-cmd-texi.py b/doc/scripts/gen-cmd-texi.py
new file mode 100644
index 0000000000..097eda81c1
--- /dev/null
+++ b/doc/scripts/gen-cmd-texi.py
@@ -0,0 +1,267 @@
+#!/usr/bin/python
+# Copyright (C) 2021 Daiki Ueno
+
+# This file is part of GnuTLS.
+
+# GnuTLS 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.
+
+# GnuTLS 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/>.
+
+from typing import Mapping, Sequence, TextIO
+import io
+import jsonopts
+
+HEADINGS = ['@heading', '@subheading', '@subsubheading']
+
+
+def get_heading(level: int) -> str:
+ return HEADINGS[min(level, len(HEADINGS)-1)]
+
+
+SECTIONS = ['@section', '@subsection', '@subsubsection']
+
+
+def get_section(level: int) -> str:
+ return SECTIONS[min(level, len(SECTIONS)-1)]
+
+
+def shift_headings(s: str, level: int) -> str:
+ for (i, h) in reversed(list(enumerate(HEADINGS))):
+ r = get_heading(level+i)
+ s = s.replace(h, r)
+ return s
+
+
+def gen_option_docs(meta: Mapping[str, str],
+ level: int,
+ options: Sequence[Mapping[str, str]]) -> str:
+ prog_name = meta['prog-name']
+ docs = io.StringIO()
+ for option in options:
+ long_opt = option['long-option']
+ short_opt = option.get('short-option')
+ detail = option.get('detail')
+ desc = option.get('desc')
+ alias = option.get('aliases')
+ if alias:
+ docs.write(f'''\
+{get_heading(level+1)} {long_opt} option.
+@anchor{{{prog_name} {long_opt}}}
+
+This is an alias for the @code{{{alias}}} option,
+@pxref{{{prog_name} {alias}, the {alias} option documentation}}.
+
+''')
+ continue
+
+ if not detail or not desc:
+ continue
+ if short_opt:
+ docs.write(
+ f'{get_heading(level+1)} {long_opt} option (-{short_opt}).\n'
+ )
+ else:
+ docs.write(f'{get_heading(level+1)} {long_opt} option.\n')
+ docs.write(f'''\
+@anchor{{{prog_name} {long_opt}}}
+
+This is the ``{desc.lower()}'' option.
+''')
+ arg_type = option.get('arg-type')
+ if arg_type:
+ arg_name = option.get('arg-name')
+ if arg_name:
+ docs.write((
+ f'This option takes a {arg_type} argument '
+ f'@file{{{arg_name}}}.\n'
+ ))
+ else:
+ docs.write(f'This option takes a {arg_type} argument.\n')
+
+ conflict_opts = option.get('conflicts', '').split()
+ require_opts = option.get('requires', '').split()
+ disable_prefix = option.get('disable-prefix')
+ if len(conflict_opts) > 0 or len(require_opts) > 0 or \
+ ('enabled' in option):
+ docs.write('''
+@noindent
+This option has some usage constraints. It:
+@itemize @bullet
+''')
+ if len(conflict_opts) > 0:
+ docs.write(f'''\
+@item
+must not appear in combination with any of the following options:
+{', '.join(conflict_opts)}.
+''')
+ if len(require_opts) > 0:
+ docs.write(f'''\
+@item
+must appear in combination with the following options:
+{', '.join(require_opts)}.
+''')
+ if disable_prefix:
+ docs.write(f'''\
+@item
+can be disabled with --{disable_prefix}{long_opt}.
+''')
+ if 'enabled' in option:
+ docs.write('''\
+@item
+It is enabled by default.
+''')
+ docs.write('@end itemize\n\n')
+
+ docs.write(f'''\
+{detail}
+''')
+ if 'deprecated' in option:
+ docs.write('\n@strong{NOTE}@strong{: THIS OPTION IS DEPRECATED}\n')
+
+ return docs.getvalue()
+
+
+LABELS = {
+ 'see-also': 'See Also',
+ 'examples': 'Examples',
+ 'files': 'Files'
+}
+
+
+def include(meta: Mapping[str, str],
+ level: int,
+ name: str,
+ includes: Mapping[str, TextIO]) -> str:
+ prog_name = meta['prog-name']
+ docs = io.StringIO()
+ f = includes.get(name)
+ if f:
+ docs.write(f'''\
+@anchor{{{prog_name} {LABELS[name]}}}
+{get_heading(level+2)} {prog_name} {LABELS[name]}
+{shift_headings(f.read(), level)}\
+''')
+ return docs.getvalue()
+
+
+def escape_texi(s: str) -> str:
+ for c in ['@', '{', '}']:
+ s = s.replace(c, f'@{c}')
+ return s
+
+
+def gen(infile: TextIO,
+ level: int,
+ section_node: bool,
+ includes: Mapping[str, TextIO],
+ texi: TextIO):
+ sections = [jsonopts.Section.from_json(section)
+ for section in json.load(args.json)]
+ sections.append(jsonopts.Section.default())
+
+ prog_name = sections[0].meta['prog-name']
+ description = includes.get('description')
+ if description:
+ detail = description.read()
+ else:
+ detail = sections[0].meta['detail']
+
+ section_docs = io.StringIO()
+ for section in sections:
+ section_id = section.meta.get('id', '')
+ if section_id:
+ section_desc = section.meta['desc']
+ option_docs = gen_option_docs(sections[0].meta, level+1,
+ section.options)
+ section_docs.write(f'''\
+@anchor{{{prog_name} {section_id}}}
+{get_heading(level+1)} {section_id} options
+{section_desc if section_desc.endswith('.') else section_desc + '.'}
+{option_docs}\
+''')
+ else:
+ section_docs.write(gen_option_docs(sections[0].meta, level,
+ section.options))
+
+ heading = get_section(level) if section_node else get_heading(level)
+ texi.write(f'''\
+@node {prog_name} Invocation
+{heading} Invoking {prog_name}
+@pindex {prog_name}
+
+{detail}
+
+@anchor{{{prog_name} usage}}
+{get_heading(level+1)} {prog_name} help/usage (@option{{-?}})
+@cindex {prog_name} help
+
+The text printed is the same whether selected with the @code{{help}} option
+(@option{{--help}}) or the @code{{more-help}} option \
+(@option{{--more-help}}). @code{{more-help}} will print
+the usage text by passing it through a pager program.
+@code{{more-help}} is disabled on platforms without a working
+@code{{fork(2)}} function. The @code{{PAGER}} environment variable is
+used to select the program, defaulting to @file{{more}}. Both will exit
+with a status code of 0.
+
+@exampleindent 0
+@example
+{escape_texi(jsonopts.usage(sections[0].meta, sections))}
+@end example
+@exampleindent 4
+
+{section_docs.getvalue()}\
+@anchor{{{prog_name} exit status}}
+{get_heading(level+1)} {prog_name} exit status
+
+One of the following exit values will be returned:
+@table @samp
+@item 0 (EXIT_SUCCESS)
+Successful program execution.
+@item 1 (EXIT_FAILURE)
+The operation failed or the command syntax was not valid.
+@end table
+''')
+ if 'see-also' in includes:
+ texi.write(include(sections[0].meta, level, 'see-also', includes))
+ if 'examples' in includes:
+ texi.write(include(sections[0].meta, level, 'examples', includes))
+ if 'files' in includes:
+ texi.write(include(sections[0].meta, level, 'files', includes))
+
+
+if __name__ == '__main__':
+ import argparse
+ import json
+
+ parser = argparse.ArgumentParser(description='generate texinfo')
+ parser.add_argument('json', type=argparse.FileType('r'))
+ parser.add_argument('texi', type=argparse.FileType('w'))
+ parser.add_argument('--description', type=argparse.FileType('r'))
+ parser.add_argument('--see-also', type=argparse.FileType('r'))
+ parser.add_argument('--examples', type=argparse.FileType('r'))
+ parser.add_argument('--files', type=argparse.FileType('r'))
+ parser.add_argument('--level', type=int, default=0)
+ parser.add_argument('--section-node', action='store_true')
+
+ args = parser.parse_args()
+ includes = dict()
+ if args.see_also:
+ includes['see-also'] = args.see_also
+ if args.examples:
+ includes['examples'] = args.examples
+ if args.files:
+ includes['files'] = args.files
+ if args.description:
+ includes['description'] = args.description
+ gen(args.json, args.level, args.section_node, includes, args.texi)
diff --git a/doc/srptool-examples.texi b/doc/srptool-examples.texi
new file mode 100644
index 0000000000..1be2315fbd
--- /dev/null
+++ b/doc/srptool-examples.texi
@@ -0,0 +1,19 @@
+To create @file{tpasswd.conf} which holds the g and n values for SRP protocol
+(generator and a large prime), run:
+@example
+$ srptool --create-conf /etc/tpasswd.conf
+@end example
+
+This command will create @file{/etc/tpasswd} and will add user 'test' (you
+will also be prompted for a password). Verifiers are stored by default
+in the way libsrp expects.
+@example
+$ srptool --passwd /etc/tpasswd --passwd-conf /etc/tpasswd.conf -u test
+@end example
+
+
+This command will check against a password. If the password matches
+the one in @file{/etc/tpasswd} you will get an ok.
+@example
+$ srptool --passwd /etc/tpasswd --passwd\-conf /etc/tpasswd.conf --verify -u test
+@end example
diff --git a/doc/srptool-see-also.texi b/doc/srptool-see-also.texi
new file mode 100644
index 0000000000..d3c8678d5f
--- /dev/null
+++ b/doc/srptool-see-also.texi
@@ -0,0 +1 @@
+ gnutls-cli-debug (1), gnutls-serv (1), srptool (1), psktool (1), certtool (1)
diff --git a/doc/systemkey-tool-see-also.texi b/doc/systemkey-tool-see-also.texi
new file mode 100644
index 0000000000..d95af062b0
--- /dev/null
+++ b/doc/systemkey-tool-see-also.texi
@@ -0,0 +1 @@
+ p11tool (1), certtool (1)
diff --git a/doc/tpmtool-examples.texi b/doc/tpmtool-examples.texi
new file mode 100644
index 0000000000..fa70926ffc
--- /dev/null
+++ b/doc/tpmtool-examples.texi
@@ -0,0 +1,25 @@
+To generate a key that is to be stored in file system use:
+@example
+$ tpmtool --generate-rsa --bits 2048 --outfile tpmkey.pem
+@end example
+
+To generate a key that is to be stored in TPM's flash use:
+@example
+$ tpmtool --generate-rsa --bits 2048 --register --user
+@end example
+
+To get the public key of a TPM key use:
+@example
+$ tpmtool --pubkey tpmkey:uuid=58ad734b-bde6-45c7-89d8-756a55ad1891;storage=user \
+ --outfile pubkey.pem
+@end example
+
+or if the key is stored in the file system:
+@example
+$ tpmtool --pubkey tpmkey:file=tmpkey.pem --outfile pubkey.pem
+@end example
+
+To list all keys stored in TPM use:
+@example
+$ tpmtool --list
+@end example
diff --git a/doc/tpmtool-see-also.texi b/doc/tpmtool-see-also.texi
new file mode 100644
index 0000000000..d95af062b0
--- /dev/null
+++ b/doc/tpmtool-see-also.texi
@@ -0,0 +1 @@
+ p11tool (1), certtool (1)
diff --git a/python/Makefile.am b/python/Makefile.am
new file mode 100644
index 0000000000..702c200309
--- /dev/null
+++ b/python/Makefile.am
@@ -0,0 +1 @@
+EXTRA_DIST = jsonopts.py
diff --git a/python/jsonopts.py b/python/jsonopts.py
new file mode 100644
index 0000000000..0ee01de7dd
--- /dev/null
+++ b/python/jsonopts.py
@@ -0,0 +1,257 @@
+# Copyright (C) 2021 Daiki Ueno
+
+# This file is part of GnuTLS.
+
+# GnuTLS 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.
+
+# GnuTLS 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/>.
+
+from typing import Mapping, NamedTuple, Optional, Sequence
+import datetime
+import io
+import textwrap
+
+
+class Section(NamedTuple):
+ meta: Mapping[str, str]
+ options: Sequence[Mapping[str, str]]
+
+ @classmethod
+ def from_json(cls, json):
+ return cls(meta=json['meta'], options=json['options'])
+
+ @classmethod
+ def default(cls):
+ return DEFAULT_SECTION
+
+
+# Default options
+DEFAULT_SECTION = Section(
+ meta={
+ 'desc': 'Version, usage and configuration options',
+ },
+ options=[{
+ 'long-option': 'version',
+ 'short-option': 'v',
+ 'arg-type': 'keyword',
+ 'arg-optional': '',
+ 'desc': 'output version information and exit',
+ 'detail': textwrap.fill(textwrap.dedent("""\
+ Output version of program and exit.
+ The default mode is `v', a simple version.
+ The `c' mode will print copyright information and
+ `n' will print the full copyright notice.\
+ """), width=72, fix_sentence_endings=True)
+ }, {
+ 'long-option': 'help',
+ 'short-option': 'h',
+ 'desc': 'display extended usage information and exit',
+ 'detail': 'Display usage information and exit.'
+ }, {
+ 'long-option': 'more-help',
+ 'short-option': '!',
+ 'desc': 'extended usage information passed thru pager',
+ 'detail': 'Pass the extended usage information through a pager.'
+ }]
+)
+
+ARG_TYPE_TO_VALUE = {
+ 'string': 'str',
+ 'number': 'num',
+ 'file': 'file',
+ 'keyword': 'arg',
+}
+
+
+def default_arg_name(s: str) -> str:
+ return ARG_TYPE_TO_VALUE[s]
+
+
+def usage(meta: Mapping[str, str], sections: Sequence[Section]) -> str:
+ prog_name = sections[0].meta['prog-name']
+ prog_title = sections[0].meta["prog-title"]
+ out = io.StringIO()
+ out.write(f'{prog_name} - {prog_title}\n')
+ argument = sections[0].meta.get('argument', '')
+ out.write(
+ f'Usage: {prog_name} '
+ f'[ -<flag> [<val>] | --<name>[{{=| }}<val>] ]... {argument}\n'
+ )
+ for section in sections:
+ desc = section.meta["desc"]
+ out.write('\n')
+ if desc != '':
+ out.write(f'{desc}:\n\n')
+ for option in section.options:
+ if 'deprecated' in option:
+ continue
+ long_opt = option['long-option']
+ short_opt = option.get('short-option')
+ arg_type = option.get('arg-type')
+ if short_opt:
+ header = f' -{short_opt}, --{long_opt}'
+ else:
+ header = f' --{long_opt}'
+ if arg_type:
+ arg = ARG_TYPE_TO_VALUE.get(arg_type, 'arg')
+ if 'arg-optional' in option:
+ header += f'[={arg}]'
+ else:
+ header += f'={arg}'
+ if len(header) < 30:
+ header = header.ljust(30)
+ elif arg_type:
+ header += ' '
+ else:
+ header += ' '
+ alias = option.get('aliases')
+ if alias:
+ option_desc = f"an alias for the '{alias}' option"
+ else:
+ option_desc = option['desc']
+ out.write(f'{header}{option_desc}\n')
+ conflict_opts = option.get('conflicts', '').split()
+ if len(conflict_opts) == 1:
+ out.write(
+ f"\t\t\t\t- prohibits the option '{conflict_opts[0]}'\n"
+ )
+ elif len(conflict_opts) > 1:
+ conflict_opts_concatenated = '\n'.join([
+ f'\t\t\t\t{conflict_opt}' for conflict_opt in conflict_opts
+ ])
+ out.write(
+ '\t\t\t\t- prohibits these options:\n' +
+ conflict_opts_concatenated + '\n'
+ )
+ require_opts = option.get('requires', '').split()
+ if len(require_opts) == 1:
+ out.write(
+ f"\t\t\t\t- requires the option '{require_opts[0]}'\n"
+ )
+ elif len(require_opts) > 1:
+ require_opts_concatenated = '\n'.join([
+ f'\t\t\t\t{require_opt}' for require_opt in require_opts
+ ])
+ out.write(
+ '\t\t\t\t- requires these options:\n' +
+ require_opts_concatenated + '\n'
+ )
+ file_exists = option.get('file-exists', 'no')
+ if file_exists == 'yes':
+ out.write('\t\t\t\t- file must pre-exist\n')
+ disable_prefix = option.get('disable-prefix')
+ if disable_prefix:
+ out.write(
+ f"\t\t\t\t- disabled as '--{disable_prefix}{long_opt}'\n"
+ )
+ if 'enabled' in option:
+ out.write('\t\t\t\t- enabled by default\n')
+ if 'max' in option:
+ max_count = option.get('max')
+ assert max_count == 'NOLIMIT', \
+ f'max keyword with value {max_count} is not supported'
+ out.write('\t\t\t\t- may appear multiple times\n')
+ arg_min = option.get('arg-min')
+ arg_max = option.get('arg-max')
+ if arg_min and arg_max:
+ out.write(
+ '\t\t\t\t- it must be in the range:\n'
+ f'\t\t\t\t {int(arg_min)} to {int(arg_max)}\n'
+ )
+ out.write(textwrap.dedent('''
+ Options are specified by doubled hyphens and their name or by a single
+ hyphen and the flag character.
+ '''))
+ if 'argument' in sections[0].meta:
+ out.write(('Operands and options may be intermixed. '
+ 'They will be reordered.\n'))
+ out.write('\n' + sections[0].meta['detail'] + '\n')
+ bug_email = meta.get('bug-email')
+ if bug_email:
+ out.write('\n' + f'Please send bug reports to: <{bug_email}>' + '\n')
+ return out.getvalue()
+
+
+LICENSES = {
+ 'gpl3+': textwrap.dedent('''\
+ This is free software. It is licensed for use, modification and
+ redistribution under the terms of the GNU General Public License,
+ version 3 or later <http://gnu.org/licenses/gpl.html>
+ ''')
+}
+FULL_LICENSES = {
+ 'gpl3+': textwrap.dedent('''\
+ This is free software. It is licensed for use, modification and
+ redistribution under the terms of the GNU General Public License,
+ version 3 or later <http://gnu.org/licenses/gpl.html>
+
+ @prog_name@ 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.
+
+ @prog_name@ 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/>.
+ ''')
+}
+
+
+def version(meta: Mapping[str, str], what='c') -> str:
+ prog_name = meta['prog-name']
+ version = meta.get('version', '0.0.0')
+ license = meta.get('license', 'unknown')
+ if license:
+ license_text: Optional[str] = LICENSES[license]
+ full_license_text: Optional[str] = FULL_LICENSES[license]
+ else:
+ license_text = None
+ full_license_text = None
+ copyright_year = meta.get('copyright-year',
+ str(datetime.date.today().year))
+ copyright_holder = meta.get('copyright-holder', 'COPYRIGHT HOLDER')
+ bug_email = meta.get('bug-email')
+
+ out = io.StringIO()
+
+ if what == 'v':
+ out.write(f'{prog_name} {version}')
+ elif what == 'c':
+ out.write(textwrap.dedent(f'''\
+ {prog_name} {version}
+ Copyright (C) {copyright_year} {copyright_holder}
+ '''))
+ if license_text:
+ out.write(license_text)
+ if bug_email:
+ out.write(textwrap.dedent(f'''\
+
+ Please send bug reports to: <{bug_email}>\
+ '''))
+ elif what == 'n':
+ out.write(textwrap.dedent(f'''\
+ {prog_name} {version}
+ Copyright (C) {copyright_year} {copyright_holder}
+ '''))
+ if full_license_text:
+ out.write(full_license_text.replace('@prog_name@', prog_name))
+ if bug_email:
+ out.write(textwrap.dedent(f'''\
+
+ Please send bug reports to: <{bug_email}>\
+ '''))
+ return out.getvalue()
diff --git a/src/Makefile.am b/src/Makefile.am
index dc6c661ded..d867b02013 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,52 +17,34 @@
# along with this file; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-# src/gl is being added by the top level makefile
-SUBDIRS =
-
-ARGS_BUILT = \
- srptool-args.c srptool-args.h \
- psktool-args.c psktool-args.h \
- ocsptool-args.h ocsptool-args.c \
- serv-args.c serv-args.h \
- cli-args.c cli-args.h \
- cli-debug-args.c cli-debug-args.h \
- certtool-args.c certtool-args.h \
- danetool-args.c danetool-args.h \
- p11tool-args.c p11tool-args.h \
- tpmtool-args.c tpmtool-args.h \
- systemkey-args.c systemkey-args.h
-
-# We bundle autogen-generated files as *.bak files. This is awkward,
-# but it covers the common use-cases where autogen/libopts is
-# installed or not. Do not attempt to simplify it unless autogen
-# gains a support for better handling of intermediate files with
-# autotools.
-ARGS_BAK = \
- srptool-args.c.bak srptool-args.h.bak \
- psktool-args.c.bak psktool-args.h.bak \
- ocsptool-args.h.bak ocsptool-args.c.bak \
- serv-args.c.bak serv-args.h.bak \
- cli-args.c.bak cli-args.h.bak \
- cli-debug-args.c.bak cli-debug-args.h.bak \
- certtool-args.c.bak certtool-args.h.bak \
- danetool-args.c.bak danetool-args.h.bak \
- p11tool-args.c.bak p11tool-args.h.bak \
- tpmtool-args.c.bak tpmtool-args.h.bak \
- systemkey-args.c.bak systemkey-args.h.bak
-
-ARGS_STAMPS = \
- certtool-args.stamp cli-debug-args.stamp cli-args.stamp tpmtool-args.stamp \
- systemkey-args.stamp srptool-args.stamp ocsptool-args.stamp p11tool-args.stamp \
- danetool-args.stamp serv-args.stamp psktool-args.stamp
-
-BUILT_SOURCES = $(ARGS_BUILT)
-
-DISTCLEANFILES = $(BUILT_SOURCES) $(ARGS_STAMPS)
-
-EXTRA_DIST = gen-mech-list.sh $(ARGS_BAK)
-
-MAINTAINERCLEANFILES = $(ARGS_BAK)
+OPTIONS_BUILT = \
+ srptool-options.c srptool-options.h \
+ psktool-options.c psktool-options.h \
+ ocsptool-options.h ocsptool-options.c \
+ gnutls-serv-options.c gnutls-serv-options.h \
+ gnutls-cli-options.c gnutls-cli-options.h \
+ gnutls-cli-debug-options.c gnutls-cli-debug-options.h \
+ certtool-options.c certtool-options.h \
+ danetool-options.c danetool-options.h \
+ p11tool-options.c p11tool-options.h \
+ tpmtool-options.c tpmtool-options.h \
+ systemkey-tool-options.c systemkey-tool-options.h
+
+OPTIONS_JSON = \
+ certtool-options.json gnutls-cli-debug-options.json gnutls-cli-options.json tpmtool-options.json \
+ systemkey-tool-options.json srptool-options.json ocsptool-options.json p11tool-options.json \
+ danetool-options.json gnutls-serv-options.json psktool-options.json
+
+OPTIONS_STAMP = \
+ certtool-options.stamp gnutls-cli-debug-options.stamp gnutls-cli-options.stamp tpmtool-options.stamp \
+ systemkey-tool-options.stamp srptool-options.stamp ocsptool-options.stamp p11tool-options.stamp \
+ danetool-options.stamp gnutls-serv-options.stamp psktool-options.stamp
+
+BUILT_SOURCES = $(OPTIONS_BUILT)
+
+EXTRA_DIST = gen-mech-list.sh gen-getopt.py $(OPTIONS_JSON) $(OPTIONS_BUILT) $(OPTIONS_STAMP)
+
+MAINTAINERCLEANFILES = $(OPTIONS_BUILT) $(OPTIONS_STAMP)
AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
AM_CPPFLAGS = \
@@ -71,16 +53,7 @@ AM_CPPFLAGS = \
-I$(builddir)/../lib/includes \
-I$(srcdir)/../lib/includes \
-I$(srcdir)/../libdane/includes \
- -I$(srcdir)/../extra/includes \
- $(LIBOPTS_CFLAGS)
-
-if NEED_LIBOPTS
-LIBOPTS = libopts/libopts.la
-SUBDIRS += libopts
-AM_CPPFLAGS += -I$(srcdir)/libopts
-else
-LIBOPTS = $(LIBOPTS_LDADD)
-endif
+ -I$(srcdir)/../extra/includes
bin_PROGRAMS = psktool gnutls-cli-debug certtool gnutls-serv gnutls-cli
if ENABLE_SRP
@@ -112,30 +85,27 @@ noinst_LTLIBRARIES =
if ENABLE_SRP
srptool_SOURCES = srptool.c
-srptool_LDADD = ../lib/libgnutls.la libcmd-srp.la $(LIBOPTS) ../gl/libgnu.la
+srptool_LDADD = ../lib/libgnutls.la libcmd-srp.la ../gl/libgnu.la
srptool_LDADD += $(LTLIBINTL) gl/libgnu_gpl.la
noinst_LTLIBRARIES += libcmd-srp.la
-libcmd_srp_la_SOURCES = srptool-args.def
-nodist_libcmd_srp_la_SOURCES = srptool-args.c srptool-args.h
+libcmd_srp_la_SOURCES = srptool-options.c srptool-options.h
endif
psktool_SOURCES = psk.c
-psktool_LDADD = ../lib/libgnutls.la libcmd-psk.la $(LIBOPTS) ../gl/libgnu.la
+psktool_LDADD = ../lib/libgnutls.la libcmd-psk.la ../gl/libgnu.la
psktool_LDADD += $(LTLIBINTL) gl/libgnu_gpl.la
noinst_LTLIBRARIES += libcmd-psk.la
-libcmd_psk_la_SOURCES = psktool-args.def
-nodist_libcmd_psk_la_SOURCES = psktool-args.c psktool-args.h
+libcmd_psk_la_SOURCES = psktool-options.c psktool-options.h
if ENABLE_OCSP
ocsptool_SOURCES = ocsptool.c ocsptool-common.h ocsptool-common.c certtool-common.c \
socket.c common.c common.h socket.h
-ocsptool_LDADD = ../lib/libgnutls.la libcmd-ocsp.la $(LIBOPTS) ../gl/libgnu.la
+ocsptool_LDADD = ../lib/libgnutls.la libcmd-ocsp.la ../gl/libgnu.la
ocsptool_LDADD += $(LTLIBINTL) $(GETADDRINFO_LIB) gl/libgnu_gpl.la $(LIBIDN_LIBS)
noinst_LTLIBRARIES += libcmd-ocsp.la
-libcmd_ocsp_la_SOURCES = ocsptool-args.def
-nodist_libcmd_ocsp_la_SOURCES = ocsptool-args.h ocsptool-args.c
+libcmd_ocsp_la_SOURCES = ocsptool-options.h ocsptool-options.c
endif
@@ -145,12 +115,11 @@ gnutls_serv_SOURCES = \
common.h common.c \
certtool-common.h
gnutls_serv_LDADD = ../lib/libgnutls.la
-gnutls_serv_LDADD += libcmd-serv.la $(LIBOPTS) ../gl/libgnu.la
+gnutls_serv_LDADD += libcmd-serv.la ../gl/libgnu.la
gnutls_serv_LDADD += $(LTLIBINTL) gl/libgnu_gpl.la
gnutls_serv_LDADD += $(LIBSOCKET) $(GETADDRINFO_LIB) $(LIBIDN_LIBS)
noinst_LTLIBRARIES += libcmd-serv.la
-libcmd_serv_la_SOURCES = serv-args.def
-nodist_libcmd_serv_la_SOURCES = serv-args.c serv-args.h
+libcmd_serv_la_SOURCES = gnutls-serv-options.c gnutls-serv-options.h
BENCHMARK_SRCS = benchmark-cipher.c benchmark.c benchmark.h benchmark-tls.c
@@ -164,25 +133,23 @@ gnutls_cli_LDADD = ../lib/libgnutls.la -lm
if ENABLE_DANE
gnutls_cli_LDADD += ../libdane/libgnutls-dane.la
endif
-gnutls_cli_LDADD += libcmd-cli.la $(LIBOPTS) ../gl/libgnu.la $(LTLIBINTL) $(LIBIDN_LIBS)
+gnutls_cli_LDADD += libcmd-cli.la ../gl/libgnu.la $(LTLIBINTL) $(LIBIDN_LIBS)
gnutls_cli_LDADD += $(LIBSOCKET) $(GETADDRINFO_LIB) $(LIB_CLOCK_GETTIME) \
$(SERVENT_LIB) gl/libgnu_gpl.la
noinst_LTLIBRARIES += libcmd-cli.la
-libcmd_cli_la_SOURCES = cli-args.def
-nodist_libcmd_cli_la_SOURCES = cli-args.c cli-args.h
+libcmd_cli_la_SOURCES = gnutls-cli-options.c gnutls-cli-options.h
gnutls_cli_debug_SOURCES = cli-debug.c tests.h tests.c \
socket.c socket.h common.h common.c
gnutls_cli_debug_LDADD = ../lib/libgnutls.la libcmd-cli-debug.la
-gnutls_cli_debug_LDADD += $(LIBOPTS) ../gl/libgnu.la gl/libgnu_gpl.la
+gnutls_cli_debug_LDADD += ../gl/libgnu.la gl/libgnu_gpl.la
gnutls_cli_debug_LDADD += $(LTLIBINTL) $(LIBIDN_LIBS)
gnutls_cli_debug_LDADD += $(LIBSOCKET) $(GETADDRINFO_LIB)
noinst_LTLIBRARIES += libcmd-cli-debug.la
-libcmd_cli_debug_la_SOURCES = cli-debug-args.def
-nodist_libcmd_cli_debug_la_SOURCES = cli-debug-args.c cli-debug-args.h
+libcmd_cli_debug_la_SOURCES = gnutls-cli-debug-options.c gnutls-cli-debug-options.h
#certtool
-COMMON_LIBS = $(LIBOPTS) $(LTLIBINTL)
+COMMON_LIBS = $(LTLIBINTL)
if ENABLE_MINITASN1
COMMON_LIBS += ../lib/minitasn1/libminitasn1.la ../gl/libgnu.la
AM_CPPFLAGS += -I$(top_srcdir)/lib/minitasn1
@@ -196,10 +163,8 @@ certtool_LDADD = ../lib/libgnutls.la
certtool_LDADD += libcmd-certtool.la ../gl/libgnu.la gl/libgnu_gpl.la
noinst_LTLIBRARIES += libcmd-certtool.la
-libcmd_certtool_la_SOURCES = certtool-args.def \
- certtool-cfg.h certtool-cfg.c
-nodist_libcmd_certtool_la_SOURCES = certtool-args.c certtool-args.h
-libcmd_certtool_la_LIBADD = ../lib/libgnutls.la gl/libgnu_gpl.la ../gl/libgnu.la
+libcmd_certtool_la_SOURCES = certtool-options.c certtool-options.h
+libcmd_certtool_la_LIBADD = libcerttool-cfg.la ../lib/libgnutls.la gl/libgnu_gpl.la ../gl/libgnu.la
libcmd_certtool_la_LIBADD += $(COMMON_LIBS)
libcmd_certtool_la_LIBADD += $(LTLIBREADLINE) gl/libgnu_gpl.la
libcmd_certtool_la_LIBADD += $(INET_PTON_LIB) $(LIB_CLOCK_GETTIME)
@@ -213,10 +178,8 @@ danetool_LDADD += ../libdane/libgnutls-dane.la
endif
noinst_LTLIBRARIES += libcmd-danetool.la
-libcmd_danetool_la_SOURCES = danetool-args.def \
- certtool-cfg.h certtool-cfg.c
-nodist_libcmd_danetool_la_SOURCES = danetool-args.c danetool-args.h
-libcmd_danetool_la_LIBADD = ../lib/libgnutls.la gl/libgnu_gpl.la ../gl/libgnu.la
+libcmd_danetool_la_SOURCES = danetool-options.c danetool-options.h
+libcmd_danetool_la_LIBADD = libcerttool-cfg.la ../lib/libgnutls.la gl/libgnu_gpl.la ../gl/libgnu.la
libcmd_danetool_la_LIBADD += $(COMMON_LIBS)
libcmd_danetool_la_LIBADD += $(LTLIBREADLINE)
libcmd_danetool_la_LIBADD += $(INET_PTON_LIB) $(LIB_CLOCK_GETTIME)
@@ -225,7 +188,7 @@ libcmd_danetool_la_LIBADD += $(INET_PTON_LIB) $(LIB_CLOCK_GETTIME)
if ENABLE_PKCS11
BUILT_SOURCES += mech-list.h
-p11tool_SOURCES = p11tool-args.def p11tool.c pkcs11.c certtool-common.c \
+p11tool_SOURCES = p11tool-options.json p11tool.c pkcs11.c certtool-common.c \
certtool-extras.c p11tool.h common.c mech-list.h
p11tool_CPPFLAGS = $(AM_CPPFLAGS) $(P11_KIT_CFLAGS)
p11tool_LDADD = ../lib/libgnutls.la
@@ -233,26 +196,22 @@ p11tool_LDADD += libcmd-p11tool.la ../gl/libgnu.la gl/libgnu_gpl.la
p11tool_LDADD += $(COMMON_LIBS)
noinst_LTLIBRARIES += libcmd-p11tool.la
-libcmd_p11tool_la_SOURCES = p11tool-args.def \
- certtool-cfg.h certtool-cfg.c
-nodist_libcmd_p11tool_la_SOURCES = p11tool-args.c p11tool-args.h
-libcmd_p11tool_la_LIBADD = ../lib/libgnutls.la gl/libgnu_gpl.la ../gl/libgnu.la
+libcmd_p11tool_la_SOURCES = p11tool-options.c p11tool-options.h
+libcmd_p11tool_la_LIBADD = libcerttool-cfg.la ../lib/libgnutls.la gl/libgnu_gpl.la ../gl/libgnu.la
libcmd_p11tool_la_LIBADD += $(LTLIBREADLINE) $(INET_PTON_LIB) $(LIB_CLOCK_GETTIME)
endif # ENABLE_PKCS11
if ENABLE_TROUSERS
-tpmtool_SOURCES = tpmtool-args.def tpmtool.c certtool-common.c certtool-extras.c common.c
+tpmtool_SOURCES = tpmtool-options.json tpmtool.c certtool-common.c certtool-extras.c common.c
tpmtool_LDADD = ../lib/libgnutls.la
tpmtool_LDADD += libcmd-tpmtool.la ../gl/libgnu.la gl/libgnu_gpl.la
tpmtool_LDADD += $(COMMON_LIBS)
noinst_LTLIBRARIES += libcmd-tpmtool.la
-libcmd_tpmtool_la_SOURCES = tpmtool-args.def \
- certtool-cfg.h certtool-cfg.c
-nodist_libcmd_tpmtool_la_SOURCES = tpmtool-args.c tpmtool-args.h
-libcmd_tpmtool_la_LIBADD = ../lib/libgnutls.la gl/libgnu_gpl.la ../gl/libgnu.la
+libcmd_tpmtool_la_SOURCES = tpmtool-options.c tpmtool-options.h
+libcmd_tpmtool_la_LIBADD = libcerttool-cfg.la ../lib/libgnutls.la gl/libgnu_gpl.la ../gl/libgnu.la
libcmd_tpmtool_la_LIBADD += $(LTLIBREADLINE) $(INET_PTON_LIB) $(LIB_CLOCK_GETTIME)
endif # ENABLE_TROUSERS
@@ -263,96 +222,60 @@ systemkey_LDADD += libcmd-systemkey.la ../gl/libgnu.la gl/libgnu_gpl.la
systemkey_LDADD += $(COMMON_LIBS)
noinst_LTLIBRARIES += libcmd-systemkey.la
-libcmd_systemkey_la_SOURCES = systemkey-args.def \
- certtool-cfg.h certtool-cfg.c
-nodist_libcmd_systemkey_la_SOURCES = systemkey-args.c systemkey-args.h
-libcmd_systemkey_la_LIBADD = ../lib/libgnutls.la gl/libgnu_gpl.la ../gl/libgnu.la
+libcmd_systemkey_la_SOURCES = systemkey-tool-options.c systemkey-tool-options.h
+libcmd_systemkey_la_LIBADD = libcerttool-cfg.la ../lib/libgnutls.la gl/libgnu_gpl.la ../gl/libgnu.la
libcmd_systemkey_la_LIBADD += $(LTLIBREADLINE) $(INET_PTON_LIB) $(LIB_CLOCK_GETTIME)
-SUFFIXES = .stamp .def .c.bak .h.bak
-
-if NEED_LIBOPTS
-# case --enable-local-libopts: We do not call AUTOGEN unless the .bak files are missing
-.def.stamp:
- $(AM_V_GEN) b=`echo $@ | sed 's/.stamp$$//'`; \
- if ! test -f $(srcdir)/$${b}.c.bak;then \
- echo "No .bak files found; will call autogen"; \
- $(AUTOGEN) $<; \
- else \
- echo "Re-using .bak files"; \
- rm -f $${b}.c $${b}.h; \
- cp -p $(srcdir)/$${b}.c.bak $${b}.c; \
- cp -p $(srcdir)/$${b}.h.bak $${b}.h; \
- fi
- touch $@
-else
-# default case. We call autogen, and if that fails we resort to the bundled files.
-.def.stamp:
- $(AM_V_GEN) $(AUTOGEN) $< || { \
- srcdir=''; \
- b=`echo $@ | sed 's/.stamp$$//'`; \
- test -f ./$${b}.def || srcdir=$(srcdir)/; \
- cp -p $${srcdir}$${b}.c.bak $${b}.c; \
- cp -p $${srcdir}$${b}.h.bak $${b}.h; \
- } && \
- touch $@
-endif
-
-.c.c.bak:
- -@rm -f $@
- $(AM_V_GEN) cp -p $< $@
-
-.h.h.bak:
- -@rm -f $@
- $(AM_V_GEN) cp -p $< $@
+noinst_LTLIBRARIES += libcerttool-cfg.la
+libcerttool_cfg_la_SOURCES = certtool-cfg.h certtool-cfg.c cfg.c cfg.h
+libcerttool_cfg_la_LIBADD = ../gl/libgnu.la gl/libgnu_gpl.la
-danetool-args.h: danetool-args.stamp
-danetool-args.c: danetool-args.stamp
-danetool-args.stamp: args-std.def
+noinst_PROGRAMS = dumpcfg
+dumpcfg_SOURCES = cfg.c cfg.h
+dumpcfg_CFLAGS = -DTEST=1
+dumpcfg_LDADD = ../gl/libgnu.la gl/libgnu_gpl.la
-ocsptool-args.h: ocsptool-args.stamp
-ocsptool-args.c: ocsptool-args.stamp
-ocsptool-args.stamp: args-std.def
+SUFFIXES = .stamp .json
-tpmtool-args.h: tpmtool-args.stamp
-tpmtool-args.c: tpmtool-args.stamp
-tpmtool-args.stamp: args-std.def
+OPTIONS_STAMP: $(srcdir)/gen-getopt.py
-p11tool-args.h: p11tool-args.stamp
-p11tool-args.c: p11tool-args.stamp
-p11tool-args.stamp: args-std.def
-
-psktool-args.h: psktool-args.stamp
-psktool-args.c: psktool-args.stamp
-psktool-args.stamp: args-std.def
-
-cli-debug-args.h: cli-debug-args.stamp
-cli-debug-args.c: cli-debug-args.stamp
-cli-debug-args.stamp: args-std.def
-
-cli-args.h: cli-args.stamp
-cli-args.c: cli-args.stamp
-cli-args.stamp: args-std.def
-
-serv-args.h: serv-args.stamp
-serv-args.c: serv-args.stamp
-serv-args.stamp: args-std.def
-
-srptool-args.h: srptool-args.stamp
-srptool-args.c: srptool-args.stamp
-srptool-args.stamp: args-std.def
-
-certtool-args.h: certtool-args.stamp
-certtool-args.c: certtool-args.stamp
-certtool-args.stamp: args-std.def
-
-systemkey-args.h: systemkey-args.stamp
-systemkey-args.c: systemkey-args.stamp
-systemkey-args.stamp: args-std.def
+.json.stamp:
+ $(AM_V_GEN) { \
+ b=`echo $@ | sed 's/.stamp$$//'`; \
+ PYTHONPATH='$(top_srcdir)/python' \
+ $(PYTHON) $(srcdir)/gen-getopt.py \
+ --bug-email bugs@gnutls.org \
+ --copyright-year 2000-2021 \
+ --copyright-holder 'Free Software Foundation, and others' \
+ --license gpl3+ \
+ --version '$(VERSION)' $< \
+ $${b}.c $${b}.h; \
+ } && \
+ touch $@
-tpm2key-args.h: tpm2key-args.stamp
-tpm2key-args.c: tpm2key-args.stamp
-tpm2key-args.stamp: args-std.def
+danetool-options.stamp: danetool-options.json
+ocsptool-options.stamp: ocsptool-options.json
+tpmtool-options.stamp: tpmtool-options.json
+p11tool-options.stamp: p11tool-options.json
+psktool-options.stamp: psktool-options.json
+gnutls-cli-debug-options.stamp: gnutls-cli-debug-options.json
+gnutls-cli-options.stamp: gnutls-cli-options.json
+gnutls-serv-options.stamp: gnutls-serv-options.json
+srptool-options.stamp: srptool-options.json
+certtool-options.stamp: certtool-options.json
+systemkey-tool-options.stamp: systemkey-tool-options.json
+
+danetool-options.c danetool-options.h: danetool-options.stamp
+ocsptool-options.c ocsptool-options.h: ocsptool-options.stamp
+tpmtool-options.c tpmtool-options.h: tpmtool-options.stamp
+p11tool-options.c p11tool-options.h: p11tool-options.stamp
+psktool-options.c psktool-options.h: psktool-options.stamp
+gnutls-cli-debug-options.c gnutls-cli-debug-options.h: gnutls-cli-debug-options.stamp
+gnutls-cli-options.c gnutls-cli-options.h: gnutls-cli-options.stamp
+gnutls-serv-options.c gnutls-serv-options.h: gnutls-serv-options.stamp
+srptool-options.c srptool-options.h: srptool-options.stamp
+certtool-options.c certtool-options.h: certtool-options.stamp
+systemkey-tool-options.c systemkey-tool-options.h: systemkey-tool-options.stamp
mech-list.h: gen-mech-list.sh
$(AM_V_GEN) $(srcdir)/gen-mech-list.sh > $@.tmp && mv $@.tmp $@
diff --git a/src/args-std.def.in b/src/args-std.def.in
deleted file mode 100644
index 4a92c448d2..0000000000
--- a/src/args-std.def.in
+++ /dev/null
@@ -1,58 +0,0 @@
-
-prog-group = GnuTLS;
-config-header = config.h;
-gnu-usage;
-disable-save;
-long-opts;
-no-xlate = opt;
-version = "@VERSION@";
-no-misuse-usage;
-export = '#include <gettext.h>';
-
-copyright = {
- date = "2000-2020";
- owner = "Free Software Foundation, and others";
- author = "Nikos Mavrogiannopoulos, Simon Josefsson and others; "
- "see /usr/share/doc/gnutls/AUTHORS for a complete list.";
- eaddr = "@PACKAGE_BUGREPORT@";
- type = gpl;
-};
-
-help-value = h;
-flag = {
- name = debug;
- value = d;
- arg-type = number;
- arg-range = "0 -> 9999";
- descrip = "Enable debugging";
- doc = "Specifies the debug level.";
-};
-
-#ifdef VERBOSE_OPT
-flag = {
- name = verbose;
- value = V;
- max = NOLIMIT;
- descrip = "More verbose output";
- doc = "";
-};
-#endif
-
-#ifdef INFILE_OPT
-flag = {
- name = infile;
- arg-type = file;
- file-exists = yes;
- descrip = "Input file";
- doc = "";
-};
-#endif
-
-#ifdef OUTFILE_OPT
-flag = {
- name = outfile;
- arg-type = string;
- descrip = "Output file";
- doc = "";
-};
-#endif
diff --git a/src/certtool-args.def b/src/certtool-args.def
deleted file mode 100644
index 61dcb712a5..0000000000
--- a/src/certtool-args.def
+++ /dev/null
@@ -1,1163 +0,0 @@
-AutoGen Definitions options;
-prog-name = certtool;
-prog-title = "GnuTLS certificate tool";
-prog-desc = "Manipulate certificates and private keys.";
-detail = "Tool to parse and generate X.509 certificates, requests and private keys.
-It can be used interactively or non interactively by
-specifying the template command line option.
-
-The tool accepts files or supported URIs via the --infile option. In case PIN
-is required for URI access you can provide it using the environment variables GNUTLS_PIN
-and GNUTLS_SO_PIN.
-";
-short-usage = "certtool [options]\ncerttool --help for usage instructions.\n";
-explain = "";
-
-#define INFILE_OPT 1
-#define OUTFILE_OPT 1
-#define VERBOSE_OPT 1
-#include args-std.def
-
-//----------------------------------------
-flag = {
- name = cert_options;
- documentation;
- descrip = "Certificate related options";
-};
-//----------------------------------------
-
-flag = {
- name = certificate-info;
- value = i;
- descrip = "Print information on the given certificate";
- doc = "";
-};
-
-flag = {
- name = pubkey-info;
- descrip = "Print information on a public key";
- doc = "The option combined with --load-request, --load-pubkey, --load-privkey and --load-certificate will extract the public key of the object in question.";
-};
-
-flag = {
- name = generate-self-signed;
- value = s;
- descrip = "Generate a self-signed certificate";
- doc = "";
-};
-
-flag = {
- name = generate-certificate;
- value = c;
- descrip = "Generate a signed certificate";
- doc = "";
-};
-
-flag = {
- name = generate-proxy;
- descrip = "Generates a proxy certificate";
- doc = "";
-};
-
-flag = {
- name = update-certificate;
- value = u;
- descrip = "Update a signed certificate";
- doc = "";
-};
-
-flag = {
- name = fingerprint;
- descrip = "Print the fingerprint of the given certificate";
- doc = "This is a simple hash of the DER encoding of the certificate. It can be combined with the --hash parameter. However, it is recommended for identification to use the key-id which depends only on the certificate's key.";
-};
-
-flag = {
- name = key-id;
- descrip = "Print the key ID of the given certificate";
- doc = "This is a hash of the public key of the given certificate. It identifies the key uniquely, remains the same on a certificate renewal and depends only on signed fields of the certificate.";
-};
-
-flag = {
- name = certificate-pubkey;
- descrip = "Print certificate's public key";
- doc = "This option is deprecated as a duplicate of --pubkey-info";
- deprecated;
-};
-
-flag = {
- name = v1;
- descrip = "Generate an X.509 version 1 certificate (with no extensions)";
- doc = "";
-};
-
-flag = {
- name = sign-params;
- arg-type = string;
- descrip = "Sign a certificate with a specific signature algorithm";
- doc = "This option can be combined with --generate-certificate, to sign the certificate with
-a specific signature algorithm variant. The only option supported is 'RSA-PSS', and should be
-specified when the signer does not have a certificate which is marked for RSA-PSS use only.";
-};
-
-
-//----------------------------------------
-flag = {
- name = crq_options;
- documentation;
- descrip = "Certificate request related options";
-};
-//----------------------------------------
-
-flag = {
- name = crq-info;
- descrip = "Print information on the given certificate request";
- doc = "";
-};
-
-flag = {
- name = generate-request;
- value = q;
- descrip = "Generate a PKCS #10 certificate request";
- flags_cant = infile;
- doc = "Will generate a PKCS #10 certificate request. To specify a private key use --load-privkey.";
-};
-
-flag = {
- name = no-crq-extensions;
- descrip = "Do not use extensions in certificate requests";
- doc = "";
-};
-
-//----------------------------------------
-flag = {
- name = pkcs12_options;
- documentation;
- descrip = "PKCS#12 file related options";
-};
-//----------------------------------------
-
-flag = {
- name = p12-info;
- descrip = "Print information on a PKCS #12 structure";
- doc = "This option will dump the contents and print the metadata of the provided PKCS #12 structure.";
-};
-
-flag = {
- name = p12-name;
- arg-type = string;
- descrip = "The PKCS #12 friendly name to use";
- doc = "The name to be used for the primary certificate and private key in a PKCS #12 file.";
-};
-
-flag = {
- name = to-p12;
- descrip = "Generate a PKCS #12 structure";
- doc = "It requires a certificate, a private key and possibly a CA certificate to be specified.";
-};
-
-
-//----------------------------------------
-flag = {
- name = key_options;
- documentation;
- descrip = "Private key related options";
-};
-//----------------------------------------
-
-flag = {
- name = key-info;
- value = k;
- descrip = "Print information on a private key";
- doc = "";
-};
-
-flag = {
- name = p8-info;
- descrip = "Print information on a PKCS #8 structure";
- doc = "This option will print information about encrypted PKCS #8 structures. That option does not require the decryption of the structure.";
-};
-
-flag = {
- name = to-rsa;
- descrip = "Convert an RSA-PSS key to raw RSA format";
- doc = "It requires an RSA-PSS key as input and will output a raw RSA
-key. This command is necessary for compatibility with applications that
-cannot read RSA-PSS keys.";
-};
-
-flag = {
- name = generate-privkey;
- value = p;
- descrip = "Generate a private key";
- doc = "When generating RSA-PSS private keys, the --hash option will
-restrict the allowed hash for the key; in the same keys the --salt-size
-option is also acceptable.";
-};
-
-flag = {
- name = key-type;
- arg-type = string;
- descrip = "Specify the key type to use on key generation";
- doc = "This option can be combined with --generate-privkey, to specify
-the key type to be generated. Valid options are, 'rsa', 'rsa-pss', 'dsa', 'ecdsa', 'ed25519, 'ed448', 'x25519', and 'x448'.'.
-When combined with certificate generation it can be used to specify an
-RSA-PSS certificate when an RSA key is given.";
-};
-
-flag = {
- name = bits;
- arg-type = number;
- descrip = "Specify the number of bits for key generation";
- doc = "";
-};
-
-flag = {
- name = curve;
- arg-type = string;
- descrip = "Specify the curve used for EC key generation";
- doc = "Supported values are secp192r1, secp224r1, secp256r1, secp384r1 and secp521r1.";
-};
-
-flag = {
- name = sec-param;
- arg-type = string;
- arg-name = "Security parameter";
- descrip = "Specify the security level [low, legacy, medium, high, ultra]";
- doc = "This is alternative to the bits option.";
-};
-
-flag = {
- name = to-p8;
- descrip = "Convert a given key to a PKCS #8 structure";
- doc = "This needs to be combined with --load-privkey.";
-};
-
-flag = {
- name = pkcs8;
- value = 8;
- descrip = "Use PKCS #8 format for private keys";
- doc = "";
-};
-
-flag = {
- name = provable;
- descrip = "Generate a private key or parameters from a seed using a provable method";
- doc = "This will use the FIPS PUB186-4 algorithms (i.e., Shawe-Taylor) for provable key generation.
-When specified the private keys or parameters will be generated from a seed, and can be
-later validated with --verify-provable-privkey to be correctly generated from the seed. You may
-specify --seed or allow GnuTLS to generate one (recommended). This option can be combined with
---generate-privkey or --generate-dh-params.
-
-That option applies to RSA and DSA keys. On the DSA keys the PQG parameters
-are generated using the seed, and on RSA the two primes.";
-};
-
-flag = {
- name = verify-provable-privkey;
- descrip = "Verify a private key generated from a seed using a provable method";
- doc = "This will use the FIPS-186-4 algorithms for provable key generation. You may specify --seed or use the seed stored in the private key structure.";
-};
-
-flag = {
- name = seed;
- descrip = "When generating a private key use the given hex-encoded seed";
- arg-type = string;
- doc = "The seed acts as a security parameter for the private key, and
-thus a seed size which corresponds to the security level of the private key
-should be provided (e.g., 256-bits seed).";
-};
-
-
-//----------------------------------------
-flag = {
- name = crl_options;
- documentation;
- descrip = "CRL related options";
-};
-//----------------------------------------
-
-flag = {
- name = crl-info;
- value = l;
- descrip = "Print information on the given CRL structure";
- doc = "";
-};
-
-
-flag = {
- name = generate-crl;
- descrip = "Generate a CRL";
- doc = "This option generates a Certificate Revocation List. When combined with --load-crl it would use the loaded CRL as base for the generated (i.e., all revoked certificates in the base will be copied to the new CRL).
-To add new certificates to the CRL use --load-certificate.";
-};
-
-
-flag = {
- name = verify-crl;
- descrip = "Verify a Certificate Revocation List using a trusted list";
- doc = "The trusted certificate list must be loaded with --load-ca-certificate.";
- flags-must = load-ca-certificate;
-};
-
-//----------------------------------------
-flag = {
- name = cert_verify_options;
- documentation;
- descrip = "Certificate verification related options";
-};
-//----------------------------------------
-
-flag = {
- name = verify-chain;
- value = e;
- descrip = "Verify a PEM encoded certificate chain";
- doc = "Verifies the validity of a certificate chain. That is, an ordered set of
-certificates where each one is the issuer of the previous, and the first is
-the end-certificate to be validated. In a proper chain the last certificate
-is a self signed one. It can be combined with --verify-purpose or --verify-hostname.";
-};
-
-flag = {
- name = verify;
- descrip = "Verify a PEM encoded certificate (chain) against a trusted set";
- doc = "The trusted certificate list can be loaded with --load-ca-certificate. If no
-certificate list is provided, then the system's trusted certificate list is used. Note that
-during verification multiple paths may be explored. On a successful verification
-the successful path will be the last one. It can be combined with --verify-purpose or --verify-hostname.";
-};
-
-flag = {
- name = verify-hostname;
- descrip = "Specify a hostname to be used for certificate chain verification";
- arg-type = string;
- doc = "This is to be combined with one of the verify certificate options.";
-};
-
-flag = {
- name = verify-email;
- descrip = "Specify a email to be used for certificate chain verification";
- arg-type = string;
- doc = "This is to be combined with one of the verify certificate options.";
- flags-cant = verify-hostname;
-};
-
-flag = {
- name = verify-purpose;
- descrip = "Specify a purpose OID to be used for certificate chain verification";
- arg-type = string;
- doc = "This object identifier restricts the purpose of the certificates to be verified. Example purposes are 1.3.6.1.5.5.7.3.1 (TLS WWW), 1.3.6.1.5.5.7.3.4 (EMAIL) etc. Note that a CA certificate without a purpose set (extended key usage) is valid for any purpose.";
-};
-
-flag = {
- name = verify-allow-broken;
- descrip = "Allow broken algorithms, such as MD5 for verification";
- doc = "This can be combined with --p7-verify, --verify or --verify-chain.";
-};
-
-flag = {
- name = verify-profile;
- descrip = "Specify a security level profile to be used for verification";
- arg-type = string;
- doc = "This option can be used to specify a certificate verification profile. Certificate
- verification profiles correspond to the security level. This should be one of
- 'none', 'very weak', 'low', 'legacy', 'medium', 'high', 'ultra',
- 'future'. Note that by default no profile is applied, unless one is set
- as minimum in the gnutls configuration file.";
-};
-
-//----------------------------------------
-flag = {
- name = pkcs7_options;
- documentation;
- descrip = "PKCS#7 structure options";
-};
-//----------------------------------------
-
-flag = {
- name = p7-generate;
- descrip = "Generate a PKCS #7 structure";
- doc = "This option generates a PKCS #7 certificate container structure. To add certificates in the structure use --load-certificate and --load-crl.";
-};
-
-flag = {
- name = p7-sign;
- descrip = "Signs using a PKCS #7 structure";
- doc = "This option generates a PKCS #7 structure containing a signature for the provided data from infile. The data are stored within the structure. The signer certificate has to be specified using --load-certificate and --load-privkey. The input to --load-certificate can be a list of certificates. In case of a list, the first certificate is used for signing and the other certificates are included in the structure.";
-};
-
-
-flag = {
- name = p7-detached-sign;
- descrip = "Signs using a detached PKCS #7 structure";
- doc = "This option generates a PKCS #7 structure containing a signature for the provided data from infile. The signer certificate has to be specified using --load-certificate and --load-privkey. The input to --load-certificate can be a list of certificates. In case of a list, the first certificate is used for signing and the other certificates are included in the structure.";
-};
-
-flag = {
- name = p7-include-cert;
- disable = "no";
- enabled;
- descrip = "The signer's certificate will be included in the cert list.";
- doc = "This options works with --p7-sign or --p7-detached-sign and will include or exclude the signer's certificate into the generated signature.";
-};
-
-flag = {
- name = p7-time;
- disable = "no";
- disabled;
- descrip = "Will include a timestamp in the PKCS #7 structure";
- doc = "This option will include a timestamp in the generated signature";
-};
-
-flag = {
- name = p7-show-data;
- disable = "no";
- disabled;
- descrip = "Will show the embedded data in the PKCS #7 structure";
- doc = "This option can be combined with --p7-verify or --p7-info and will display the embedded signed data in the PKCS #7 structure.";
-};
-
-flag = {
- name = p7-info;
- descrip = "Print information on a PKCS #7 structure";
- doc = "";
-};
-
-flag = {
- name = p7-verify;
- descrip = "Verify the provided PKCS #7 structure";
- doc = "This option verifies the signed PKCS #7 structure. The certificate list to use for verification can be specified with --load-ca-certificate. When no certificate list is provided, then the system's certificate list is used. Alternatively a direct signer can be provided using --load-certificate. A key purpose can be enforced with the --verify-purpose option, and the --load-data option will utilize detached data.";
-};
-
-flag = {
- name = smime-to-p7;
- descrip = "Convert S/MIME to PKCS #7 structure";
- doc = "";
-};
-
-
-
-//----------------------------------------
-flag = {
- name = other_options;
- documentation;
- descrip = "Other options";
-};
-//----------------------------------------
-
-flag = {
- name = generate-dh-params;
- descrip = "Generate PKCS #3 encoded Diffie-Hellman parameters";
- doc = "The will generate random parameters to be used with
-Diffie-Hellman key exchange. The output parameters will be in PKCS #3
-format. Note that it is recommended to use the --get-dh-params option
-instead.";
- deprecated;
-};
-
-flag = {
- name = get-dh-params;
- descrip = "List the included PKCS #3 encoded Diffie-Hellman parameters";
- doc = "Returns stored DH parameters in GnuTLS. Those parameters returned
-are defined in RFC7919, and can be considered standard parameters for a TLS
-key exchange. This option is provided for old applications which require
-DH parameters to be specified; modern GnuTLS applications should not require
-them.";
-};
-
-flag = {
- name = dh-info;
- descrip = "Print information PKCS #3 encoded Diffie-Hellman parameters";
- doc = "";
-};
-
-flag = {
- name = load-privkey;
- descrip = "Loads a private key file";
- arg-type = string;
- doc = "This can be either a file or a PKCS #11 URL";
-};
-
-flag = {
- name = load-pubkey;
- descrip = "Loads a public key file";
- arg-type = string;
- doc = "This can be either a file or a PKCS #11 URL";
-};
-
-flag = {
- name = load-request;
- descrip = "Loads a certificate request file";
- arg-type = string;
- doc = "This option can be used with a file";
-};
-
-flag = {
- name = load-certificate;
- descrip = "Loads a certificate file";
- arg-type = string;
- doc = "This option can be used with a file";
-};
-
-flag = {
- name = load-ca-privkey;
- descrip = "Loads the certificate authority's private key file";
- arg-type = string;
- doc = "This can be either a file or a PKCS #11 URL";
-};
-
-flag = {
- name = load-ca-certificate;
- descrip = "Loads the certificate authority's certificate file";
- arg-type = string;
- doc = "This can be either a file or a PKCS #11 URL";
-};
-
-flag = {
- name = load-crl;
- descrip = "Loads the provided CRL";
- arg-type = string;
- doc = "This option can be used with a file";
-};
-
-flag = {
- name = load-data;
- descrip = "Loads auxiliary data";
- arg-type = string;
- doc = "This option can be used with a file";
-};
-
-flag = {
- name = password;
- arg-type = string;
- descrip = "Password to use";
- doc = "You can use this option to specify the password in the command line instead of reading it from the tty. Note, that the command line arguments are available for view in others in the system. Specifying password as '' is the same as specifying no password.";
-};
-
-flag = {
- name = null-password;
- descrip = "Enforce a NULL password";
- doc = "This option enforces a NULL password. This is different than the empty or no password in schemas like PKCS #8.";
-};
-
-flag = {
- name = empty-password;
- descrip = "Enforce an empty password";
- doc = "This option enforces an empty password. This is different than the NULL or no password in schemas like PKCS #8.";
-};
-
-
-flag = {
- name = hex-numbers;
- descrip = "Print big number in an easier format to parse";
- doc = "";
-};
-
-flag = {
- name = cprint;
- descrip = "In certain operations it prints the information in C-friendly format";
- doc = "In certain operations it prints the information in C-friendly format, suitable for including into C programs.";
-};
-
-flag = {
- name = rsa;
- descrip = "Generate RSA key";
- doc = "When combined with --generate-privkey generates an RSA private key.";
- description = "This option is equivalent to '--key-type rsa'.";
- deprecated;
-};
-
-flag = {
- name = dsa;
- descrip = "Generate DSA key";
- doc = "When combined with --generate-privkey generates a DSA private key.";
- description = "This option is equivalent to '--key-type dsa'.";
- deprecated;
-};
-
-flag = {
- name = ecc;
- descrip = "Generate ECC (ECDSA) key";
- doc = "When combined with --generate-privkey generates an elliptic curve private key to be used with ECDSA.";
- description = "This option is equivalent to '--key-type ecdsa'.";
- deprecated;
-};
-
-flag = {
- name = ecdsa;
- aliases = ecc;
- deprecated;
-};
-
-flag = {
- name = hash;
- arg-type = string;
- descrip = "Hash algorithm to use for signing";
- doc = "Available hash functions are SHA1, RMD160, SHA256, SHA384, SHA512, SHA3-224, SHA3-256, SHA3-384, SHA3-512.";
-};
-
-flag = {
- name = salt-size;
- arg-type = number;
- descrip = "Specify the RSA-PSS key default salt size";
- doc = "Typical keys shouldn't set or restrict this option.";
-};
-
-flag = {
- name = inder;
- descrip = "Use DER format for input certificates, private keys, and DH parameters ";
- disabled;
- disable = "no";
- doc = "The input files will be assumed to be in DER or RAW format.
-Unlike options that in PEM input would allow multiple input data (e.g. multiple
-certificates), when reading in DER format a single data structure is read.";
-};
-
-flag = {
- name = inraw;
- aliases = inder;
-};
-
-flag = {
- name = outder;
- descrip = "Use DER format for output certificates, private keys, and DH parameters";
- disabled;
- disable = "no";
- doc = "The output will be in DER or RAW format.";
-};
-
-flag = {
- name = outraw;
- aliases = outder;
-};
-
-flag = {
- name = disable-quick-random;
- descrip = "No effect";
- doc = "";
- deprecated;
-};
-
-flag = {
- name = template;
- arg-type = string;
- descrip = "Template file to use for non-interactive operation";
- doc = "";
-};
-
-flag = {
- name = stdout-info;
- descrip = "Print information to stdout instead of stderr";
- doc = "";
-};
-
-flag = {
- name = ask-pass;
- disabled;
- descrip = "Enable interaction for entering password when in batch mode.";
- doc = "This option will enable interaction to enter password when in batch mode. That is useful when the template option has been specified.";
-};
-
-flag = {
- name = pkcs-cipher;
- arg-type = string;
- arg-name = "Cipher";
- descrip = "Cipher to use for PKCS #8 and #12 operations";
- doc = "Cipher may be one of 3des, 3des-pkcs12, aes-128, aes-192, aes-256, rc2-40, arcfour.";
-};
-
-flag = {
- name = provider;
- arg-type = string;
- descrip = "Specify the PKCS #11 provider library";
- doc = "This will override the default options in /etc/gnutls/pkcs11.conf";
-};
-
-flag = {
- name = text;
- descrip = "Output textual information before PEM-encoded certificates, private keys, etc";
- enabled;
- disable = "no";
- doc = "Output textual information before PEM-encoded data";
-};
-
-doc-section = {
- ds-type = 'SEE ALSO';
- ds-format = 'texi';
- ds-text = <<-_EOT_
- p11tool (1), psktool (1), srptool (1)
-_EOT_;
-};
-
-doc-section = {
- ds-type = 'EXAMPLES';
- ds-format = 'texi';
- ds-text = <<-_EOT_
-@subheading Generating private keys
-To create an RSA private key, run:
-@example
-$ certtool --generate-privkey --outfile key.pem --rsa
-@end example
-
-To create a DSA or elliptic curves (ECDSA) private key use the
-above command combined with 'dsa' or 'ecc' options.
-
-@subheading Generating certificate requests
-To create a certificate request (needed when the certificate is issued by
-another party), run:
-@example
-certtool --generate-request --load-privkey key.pem \
- --outfile request.pem
-@end example
-
-If the private key is stored in a smart card you can generate
-a request by specifying the private key object URL.
-@example
-$ ./certtool --generate-request --load-privkey "pkcs11:..." \
- --load-pubkey "pkcs11:..." --outfile request.pem
-@end example
-
-
-@subheading Generating a self-signed certificate
-To create a self signed certificate, use the command:
-@example
-$ certtool --generate-privkey --outfile ca-key.pem
-$ certtool --generate-self-signed --load-privkey ca-key.pem \
- --outfile ca-cert.pem
-@end example
-
-Note that a self-signed certificate usually belongs to a certificate
-authority, that signs other certificates.
-
-@subheading Generating a certificate
-To generate a certificate using the previous request, use the command:
-@example
-$ certtool --generate-certificate --load-request request.pem \
- --outfile cert.pem --load-ca-certificate ca-cert.pem \
- --load-ca-privkey ca-key.pem
-@end example
-
-To generate a certificate using the private key only, use the command:
-@example
-$ certtool --generate-certificate --load-privkey key.pem \
- --outfile cert.pem --load-ca-certificate ca-cert.pem \
- --load-ca-privkey ca-key.pem
-@end example
-
-@subheading Certificate information
-To view the certificate information, use:
-@example
-$ certtool --certificate-info --infile cert.pem
-@end example
-
-@subheading Changing the certificate format
-To convert the certificate from PEM to DER format, use:
-@example
-$ certtool --certificate-info --infile cert.pem --outder --outfile cert.der
-@end example
-
-@subheading PKCS #12 structure generation
-To generate a PKCS #12 structure using the previous key and certificate,
-use the command:
-@example
-$ certtool --load-certificate cert.pem --load-privkey key.pem \
- --to-p12 --outder --outfile key.p12
-@end example
-
-Some tools (reportedly web browsers) have problems with that file
-because it does not contain the CA certificate for the certificate.
-To work around that problem in the tool, you can use the
---load-ca-certificate parameter as follows:
-
-@example
-$ certtool --load-ca-certificate ca.pem \
- --load-certificate cert.pem --load-privkey key.pem \
- --to-p12 --outder --outfile key.p12
-@end example
-
-@subheading Obtaining Diffie-Hellman parameters
-To obtain the RFC7919 parameters for Diffie-Hellman key exchange, use the command:
-@example
-$ certtool --get-dh-params --outfile dh.pem --sec-param medium
-@end example
-
-@subheading Verifying a certificate
-To verify a certificate in a file against the system's CA trust store
-use the following command:
-@example
-$ certtool --verify --infile cert.pem
-@end example
-
-It is also possible to simulate hostname verification with the following
-options:
-@example
-$ certtool --verify --verify-hostname www.example.com --infile cert.pem
-@end example
-
-
-@subheading Proxy certificate generation
-Proxy certificate can be used to delegate your credential to a
-temporary, typically short-lived, certificate. To create one from the
-previously created certificate, first create a temporary key and then
-generate a proxy certificate for it, using the commands:
-
-@example
-$ certtool --generate-privkey > proxy-key.pem
-$ certtool --generate-proxy --load-ca-privkey key.pem \
- --load-privkey proxy-key.pem --load-certificate cert.pem \
- --outfile proxy-cert.pem
-@end example
-
-@subheading Certificate revocation list generation
-To create an empty Certificate Revocation List (CRL) do:
-
-@example
-$ certtool --generate-crl --load-ca-privkey x509-ca-key.pem \
- --load-ca-certificate x509-ca.pem
-@end example
-
-To create a CRL that contains some revoked certificates, place the
-certificates in a file and use @code{--load-certificate} as follows:
-
-@example
-$ certtool --generate-crl --load-ca-privkey x509-ca-key.pem \
- --load-ca-certificate x509-ca.pem --load-certificate revoked-certs.pem
-@end example
-
-To verify a Certificate Revocation List (CRL) do:
-
-@example
-$ certtool --verify-crl --load-ca-certificate x509-ca.pem < crl.pem
-@end example
-_EOT_;
-};
-
-
-doc-section = {
- ds-type = 'FILES';
- ds-format = 'texi';
- ds-text = <<-_EOT_
-@subheading Certtool's template file format
-A template file can be used to avoid the interactive questions of
-certtool. Initially create a file named 'cert.cfg' that contains the information
-about the certificate. The template can be used as below:
-
-@example
-$ certtool --generate-certificate --load-privkey key.pem \
- --template cert.cfg --outfile cert.pem \
- --load-ca-certificate ca-cert.pem --load-ca-privkey ca-key.pem
-@end example
-
-An example certtool template file that can be used to generate a certificate
-request or a self signed certificate follows.
-
-@example
-# X.509 Certificate options
-#
-# DN options
-
-# The organization of the subject.
-organization = "Koko inc."
-
-# The organizational unit of the subject.
-unit = "sleeping dept."
-
-# The locality of the subject.
-# locality =
-
-# The state of the certificate owner.
-state = "Attiki"
-
-# The country of the subject. Two letter code.
-country = GR
-
-# The common name of the certificate owner.
-cn = "Cindy Lauper"
-
-# A user id of the certificate owner.
-#uid = "clauper"
-
-# Set domain components
-#dc = "name"
-#dc = "domain"
-
-# If the supported DN OIDs are not adequate you can set
-# any OID here.
-# For example set the X.520 Title and the X.520 Pseudonym
-# by using OID and string pairs.
-#dn_oid = "2.5.4.12 Dr."
-#dn_oid = "2.5.4.65 jackal"
-
-# This is deprecated and should not be used in new
-# certificates.
-# pkcs9_email = "none@@none.org"
-
-# An alternative way to set the certificate's distinguished name directly
-# is with the "dn" option. The attribute names allowed are:
-# C (country), street, O (organization), OU (unit), title, CN (common name),
-# L (locality), ST (state), placeOfBirth, gender, countryOfCitizenship,
-# countryOfResidence, serialNumber, telephoneNumber, surName, initials,
-# generationQualifier, givenName, pseudonym, dnQualifier, postalCode, name,
-# businessCategory, DC, UID, jurisdictionOfIncorporationLocalityName,
-# jurisdictionOfIncorporationStateOrProvinceName,
-# jurisdictionOfIncorporationCountryName, XmppAddr, and numeric OIDs.
-
-#dn = "cn = Nikos,st = New\, Something,C=GR,surName=Mavrogiannopoulos,2.5.4.9=Arkadias"
-
-# The serial number of the certificate
-# The value is in decimal (i.e. 1963) or hex (i.e. 0x07ab).
-# Comment the field for a random serial number.
-serial = 007
-
-# In how many days, counting from today, this certificate will expire.
-# Use -1 if there is no expiration date.
-expiration_days = 700
-
-# Alternatively you may set concrete dates and time. The GNU date string
-# formats are accepted. See:
-# https://www.gnu.org/software/tar/manual/html_node/Date-input-formats.html
-
-#activation_date = "2004-02-29 16:21:42"
-#expiration_date = "2025-02-29 16:24:41"
-
-# X.509 v3 extensions
-
-# A dnsname in case of a WWW server.
-#dns_name = "www.none.org"
-#dns_name = "www.morethanone.org"
-
-# An othername defined by an OID and a hex encoded string
-#other_name = "1.3.6.1.5.2.2 302ca00d1b0b56414e5245494e2e4f5247a11b3019a006020400000002a10f300d1b047269636b1b0561646d696e"
-#other_name_utf8 = "1.2.4.5.6 A UTF8 string"
-#other_name_octet = "1.2.4.5.6 A string that will be encoded as ASN.1 octet string"
-
-# Allows writing an XmppAddr Identifier
-#xmpp_name = juliet@@im.example.com
-
-# Names used in PKINIT
-#krb5_principal = user@@REALM.COM
-#krb5_principal = HTTP/user@@REALM.COM
-
-# A subject alternative name URI
-#uri = "https://www.example.com"
-
-# An IP address in case of a server.
-#ip_address = "192.168.1.1"
-
-# An email in case of a person
-email = "none@@none.org"
-
-# TLS feature (rfc7633) extension. That can is used to indicate mandatory TLS
-# extension features to be provided by the server. In practice this is used
-# to require the Status Request (extid: 5) extension from the server. That is,
-# to require the server holding this certificate to provide a stapled OCSP response.
-# You can have multiple lines for multiple TLS features.
-
-# To ask for OCSP status request use:
-#tls_feature = 5
-
-# Challenge password used in certificate requests
-challenge_password = 123456
-
-# Password when encrypting a private key
-#password = secret
-
-# An URL that has CRLs (certificate revocation lists)
-# available. Needed in CA certificates.
-#crl_dist_points = "https://www.getcrl.crl/getcrl/"
-
-# Whether this is a CA certificate or not
-#ca
-
-# Subject Unique ID (in hex)
-#subject_unique_id = 00153224
-
-# Issuer Unique ID (in hex)
-#issuer_unique_id = 00153225
-
-#### Key usage
-
-# The following key usage flags are used by CAs and end certificates
-
-# Whether this certificate will be used to sign data (needed
-# in TLS DHE ciphersuites). This is the digitalSignature flag
-# in RFC5280 terminology.
-signing_key
-
-# Whether this certificate will be used to encrypt data (needed
-# in TLS RSA ciphersuites). Note that it is preferred to use different
-# keys for encryption and signing. This is the keyEncipherment flag
-# in RFC5280 terminology.
-encryption_key
-
-# Whether this key will be used to sign other certificates. The
-# keyCertSign flag in RFC5280 terminology.
-#cert_signing_key
-
-# Whether this key will be used to sign CRLs. The
-# cRLSign flag in RFC5280 terminology.
-#crl_signing_key
-
-# The keyAgreement flag of RFC5280. Its purpose is loosely
-# defined. Not use it unless required by a protocol.
-#key_agreement
-
-# The dataEncipherment flag of RFC5280. Its purpose is loosely
-# defined. Not use it unless required by a protocol.
-#data_encipherment
-
-# The nonRepudiation flag of RFC5280. Its purpose is loosely
-# defined. Not use it unless required by a protocol.
-#non_repudiation
-
-#### Extended key usage (key purposes)
-
-# The following extensions are used in an end certificate
-# to clarify its purpose. Some CAs also use it to indicate
-# the types of certificates they are purposed to sign.
-
-
-# Whether this certificate will be used for a TLS client;
-# this sets the id-kp-clientAuth (1.3.6.1.5.5.7.3.2) of
-# extended key usage.
-#tls_www_client
-
-# Whether this certificate will be used for a TLS server;
-# this sets the id-kp-serverAuth (1.3.6.1.5.5.7.3.1) of
-# extended key usage.
-#tls_www_server
-
-# Whether this key will be used to sign code. This sets the
-# id-kp-codeSigning (1.3.6.1.5.5.7.3.3) of extended key usage
-# extension.
-#code_signing_key
-
-# Whether this key will be used to sign OCSP data. This sets the
-# id-kp-OCSPSigning (1.3.6.1.5.5.7.3.9) of extended key usage extension.
-#ocsp_signing_key
-
-# Whether this key will be used for time stamping. This sets the
-# id-kp-timeStamping (1.3.6.1.5.5.7.3.8) of extended key usage extension.
-#time_stamping_key
-
-# Whether this key will be used for email protection. This sets the
-# id-kp-emailProtection (1.3.6.1.5.5.7.3.4) of extended key usage extension.
-#email_protection_key
-
-# Whether this key will be used for IPsec IKE operations (1.3.6.1.5.5.7.3.17).
-#ipsec_ike_key
-
-## adding custom key purpose OIDs
-
-# for microsoft smart card logon
-# key_purpose_oid = 1.3.6.1.4.1.311.20.2.2
-
-# for email protection
-# key_purpose_oid = 1.3.6.1.5.5.7.3.4
-
-# for any purpose (must not be used in intermediate CA certificates)
-# key_purpose_oid = 2.5.29.37.0
-
-### end of key purpose OIDs
-
-### Adding arbitrary extensions
-# This requires to provide the extension OIDs, as well as the extension data in
-# hex format. The following two options are available since GnuTLS 3.5.3.
-#add_extension = "1.2.3.4 0x0AAB01ACFE"
-
-# As above but encode the data as an octet string
-#add_extension = "1.2.3.4 octet_string(0x0AAB01ACFE)"
-
-# For portability critical extensions shouldn't be set to certificates.
-#add_critical_extension = "5.6.7.8 0x1AAB01ACFE"
-
-# When generating a certificate from a certificate
-# request, then honor the extensions stored in the request
-# and store them in the real certificate.
-#honor_crq_extensions
-
-# Alternatively only specific extensions can be copied.
-#honor_crq_ext = 2.5.29.17
-#honor_crq_ext = 2.5.29.15
-
-# Path length constraint. Sets the maximum number of
-# certificates that can be used to certify this certificate.
-# (i.e. the certificate chain length)
-#path_len = -1
-#path_len = 2
-
-# OCSP URI
-# ocsp_uri = https://my.ocsp.server/ocsp
-
-# CA issuers URI
-# ca_issuers_uri = https://my.ca.issuer
-
-# Certificate policies
-#policy1 = 1.3.6.1.4.1.5484.1.10.99.1.0
-#policy1_txt = "This is a long policy to summarize"
-#policy1_url = https://www.example.com/a-policy-to-read
-
-#policy2 = 1.3.6.1.4.1.5484.1.10.99.1.1
-#policy2_txt = "This is a short policy"
-#policy2_url = https://www.example.com/another-policy-to-read
-
-# The number of additional certificates that may appear in a
-# path before the anyPolicy is no longer acceptable.
-#inhibit_anypolicy_skip_certs 1
-
-# Name constraints
-
-# DNS
-#nc_permit_dns = example.com
-#nc_exclude_dns = test.example.com
-
-# EMAIL
-#nc_permit_email = "nmav@@ex.net"
-
-# Exclude subdomains of example.com
-#nc_exclude_email = .example.com
-
-# Exclude all e-mail addresses of example.com
-#nc_exclude_email = example.com
-
-# IP
-#nc_permit_ip = 192.168.0.0/16
-#nc_exclude_ip = 192.168.5.0/24
-#nc_permit_ip = fc0a:eef2:e7e7:a56e::/64
-
-
-# Options for proxy certificates
-#proxy_policy_language = 1.3.6.1.5.5.7.21.1
-
-
-# Options for generating a CRL
-
-# The number of days the next CRL update will be due.
-# next CRL update will be in 43 days
-#crl_next_update = 43
-
-# this is the 5th CRL by this CA
-# The value is in decimal (i.e. 1963) or hex (i.e. 0x07ab).
-# Comment the field for a time-based number.
-# Time-based CRL numbers generated in GnuTLS 3.6.3 and later
-# are significantly larger than those generated in previous
-# versions. Since CRL numbers need to be monotonic, you need
-# to specify the CRL number here manually if you intend to
-# downgrade to an earlier version than 3.6.3 after publishing
-# the CRL as it is not possible to specify CRL numbers greater
-# than 2**63-2 using hex notation in those versions.
-#crl_number = 5
-
-# Specify the update dates more precisely.
-#crl_this_update_date = "2004-02-29 16:21:42"
-#crl_next_update_date = "2025-02-29 16:24:41"
-
-# The date that the certificates will be made seen as
-# being revoked.
-#crl_revocation_date = "2025-02-29 16:24:41"
-
-@end example
-
-_EOT_;
-};
-
diff --git a/src/certtool-cfg.c b/src/certtool-cfg.c
index 8c658c8667..a8a135a4a4 100644
--- a/src/certtool-cfg.c
+++ b/src/certtool-cfg.c
@@ -34,7 +34,7 @@
#include <time.h>
#include <timespec.h>
#include <parse-datetime.h>
-#include <autoopts/options.h>
+#include "cfg.h"
#include <intprops.h>
#include <gnutls/crypto.h>
#include <libtasn1.h>
@@ -244,29 +244,29 @@ void cfg_init(void)
cfg.skip_certs = -1;
}
-#define READ_MULTI_LINE(name, s_name) \
- val = optionGetValue(pov, name); \
- if (val != NULL && val->valType == OPARG_TYPE_STRING) \
+#define READ_MULTI_LINE(k_name, s_name) \
+ val = cfg_next(pov, k_name); \
+ if (val != NULL) \
{ \
if (s_name == NULL) { \
i = 0; \
s_name = malloc(sizeof(char*)*MAX_ENTRIES); \
CHECK_MALLOC(s_name); \
do { \
- if (val && strcmp(val->pzName, name)!=0) \
+ if (val && strcmp(val->name, k_name)!=0) \
continue; \
- s_name[i] = strdup(val->v.strVal); \
+ s_name[i] = strdup(val->value); \
i++; \
if (i>=MAX_ENTRIES) \
break; \
- } while((val = optionNextValue(pov, val)) != NULL); \
+ } while((val = cfg_next(val + 1, val->name)) != NULL); \
s_name[i] = NULL; \
} \
}
-#define READ_MULTI_LINE_TOKENIZED(name, s_name) \
- val = optionGetValue(pov, name); \
- if (val != NULL && val->valType == OPARG_TYPE_STRING) \
+#define READ_MULTI_LINE_TOKENIZED(k_name, s_name) \
+ val = cfg_next(pov, k_name); \
+ if (val != NULL) \
{ \
char *str; \
char *p; \
@@ -275,12 +275,12 @@ void cfg_init(void)
s_name = malloc(sizeof(char*)*MAX_ENTRIES); \
CHECK_MALLOC(s_name); \
do { \
- if (val && strcmp(val->pzName, name)!=0) \
+ if (val && strcmp(val->name, k_name)!=0) \
continue; \
- str = strdup(val->v.strVal); \
+ str = strdup(val->value); \
CHECK_MALLOC(str); \
if ((p=strchr(str, ' ')) == NULL && (p=strchr(str, '\t')) == NULL) { \
- fprintf(stderr, "Error parsing %s\n", name); \
+ fprintf(stderr, "Error parsing %s\n", k_name); \
exit(1); \
} \
p[0] = 0; \
@@ -288,7 +288,7 @@ void cfg_init(void)
s_name[i] = strdup(str); \
while(*p==' ' || *p == '\t') p++; \
if (p[0] == 0) { \
- fprintf(stderr, "Error (2) parsing %s\n", name); \
+ fprintf(stderr, "Error (2) parsing %s\n", k_name); \
exit(1); \
} \
s_name[i+1] = strdup(p); \
@@ -296,13 +296,13 @@ void cfg_init(void)
free(str); \
if (i>=MAX_ENTRIES) \
break; \
- } while((val = optionNextValue(pov, val)) != NULL); \
+ } while((val = cfg_next(val + 1, val->name)) != NULL); \
s_name[i] = NULL; \
} \
}
#define READ_BOOLEAN(name, s_name) \
- val = optionGetValue(pov, name); \
+ val = cfg_next(pov, name); \
if (val != NULL) \
{ \
s_name = 1; \
@@ -310,13 +310,10 @@ void cfg_init(void)
/* READ_NUMERIC only returns a long */
#define READ_NUMERIC(name, s_name) \
- val = optionGetValue(pov, name); \
+ val = cfg_next(pov, name); \
if (val != NULL) \
{ \
- if (val->valType == OPARG_TYPE_NUMERIC) \
- s_name = val->v.longVal; \
- else if (val->valType == OPARG_TYPE_STRING) \
- s_name = strtol(val->v.strVal, NULL, 10); \
+ s_name = strtol(val->value, NULL, 10); \
}
#define HEX_DECODE(hex, output, output_size) \
@@ -345,17 +342,17 @@ void cfg_init(void)
}
-static int handle_option(const tOptionValue* val)
+static int handle_option(cfg_option_t val)
{
-unsigned j;
-unsigned len, cmp;
+ unsigned j;
+ unsigned len, cmp;
for (j=0;j<sizeof(available_options)/sizeof(available_options[0]);j++) {
len = strlen(available_options[j].name);
if (len > 2 && available_options[j].name[len-1] == '*')
- cmp = strncasecmp(val->pzName, available_options[j].name, len-1);
+ cmp = strncasecmp(val->name, available_options[j].name, len-1);
else
- cmp = strcasecmp(val->pzName, available_options[j].name);
+ cmp = strcasecmp(val->name, available_options[j].name);
if (cmp == 0) {
if (available_options[j].type != OPTION_MULTI_LINE &&
@@ -375,24 +372,21 @@ int template_parse(const char *template)
/* Parsing return code */
unsigned int i;
int ret;
- tOptionValue const *pov;
- const tOptionValue *val, *prev;
+ cfg_option_t pov;
+ cfg_option_t val;
char tmpstr[256];
- pov = configFileLoad(template);
+ pov = cfg_load(template);
if (pov == NULL) {
perror("configFileLoad");
fprintf(stderr, "Error loading template: %s\n", template);
exit(1);
}
- val = optionGetValue(pov, NULL);
- while (val != NULL) {
+ for (val = pov; val->name; val++) {
if (handle_option(val) == 0) {
- fprintf(stderr, "Warning: skipping unknown option '%s'\n", val->pzName);
+ fprintf(stderr, "Warning: skipping unknown option '%s'\n", val->name);
}
- prev = val;
- val = optionNextValue(pov, prev);
}
/* Option variables */
@@ -406,92 +400,90 @@ int template_parse(const char *template)
READ_MULTI_LINE("o", cfg.organization);
}
- val = optionGetValue(pov, "locality");
- if (val != NULL && val->valType == OPARG_TYPE_STRING)
- cfg.locality = strdup(val->v.strVal);
+ val = cfg_next(pov, "locality");
+ if (val != NULL)
+ cfg.locality = strdup(val->value);
- val = optionGetValue(pov, "state");
- if (val != NULL && val->valType == OPARG_TYPE_STRING)
- cfg.state = strdup(val->v.strVal);
+ val = cfg_next(pov, "state");
+ if (val != NULL)
+ cfg.state = strdup(val->value);
- val = optionGetValue(pov, "dn");
- if (val != NULL && val->valType == OPARG_TYPE_STRING)
- cfg.dn = strdup(val->v.strVal);
+ val = cfg_next(pov, "dn");
+ if (val != NULL)
+ cfg.dn = strdup(val->value);
- val = optionGetValue(pov, "cn");
- if (val != NULL && val->valType == OPARG_TYPE_STRING)
- cfg.cn = strdup(val->v.strVal);
+ val = cfg_next(pov, "cn");
+ if (val != NULL)
+ cfg.cn = strdup(val->value);
- val = optionGetValue(pov, "uid");
- if (val != NULL && val->valType == OPARG_TYPE_STRING)
- cfg.uid = strdup(val->v.strVal);
+ val = cfg_next(pov, "uid");
+ if (val != NULL)
+ cfg.uid = strdup(val->value);
- val = optionGetValue(pov, "issuer_unique_id");
- if (val != NULL && val->valType == OPARG_TYPE_STRING)
- HEX_DECODE(val->v.strVal, cfg.issuer_unique_id, cfg.issuer_unique_id_size);
+ val = cfg_next(pov, "issuer_unique_id");
+ if (val != NULL)
+ HEX_DECODE(val->value, cfg.issuer_unique_id, cfg.issuer_unique_id_size);
- val = optionGetValue(pov, "subject_unique_id");
- if (val != NULL && val->valType == OPARG_TYPE_STRING)
- HEX_DECODE(val->v.strVal, cfg.subject_unique_id, cfg.subject_unique_id_size);
+ val = cfg_next(pov, "subject_unique_id");
+ if (val != NULL)
+ HEX_DECODE(val->value, cfg.subject_unique_id, cfg.subject_unique_id_size);
- val = optionGetValue(pov, "challenge_password");
- if (val != NULL && val->valType == OPARG_TYPE_STRING)
- cfg.challenge_password = strdup(val->v.strVal);
+ val = cfg_next(pov, "challenge_password");
+ if (val != NULL)
+ cfg.challenge_password = strdup(val->value);
- val = optionGetValue(pov, "password");
- if (val != NULL && val->valType == OPARG_TYPE_STRING)
- cfg.password = strdup(val->v.strVal);
+ val = cfg_next(pov, "password");
+ if (val != NULL)
+ cfg.password = strdup(val->value);
- val = optionGetValue(pov, "pkcs9_email");
- if (val != NULL && val->valType == OPARG_TYPE_STRING)
- cfg.pkcs9_email = strdup(val->v.strVal);
+ val = cfg_next(pov, "pkcs9_email");
+ if (val != NULL)
+ cfg.pkcs9_email = strdup(val->value);
- val = optionGetValue(pov, "country");
- if (val != NULL && val->valType == OPARG_TYPE_STRING)
- cfg.country = strdup(val->v.strVal);
+ val = cfg_next(pov, "country");
+ if (val != NULL)
+ cfg.country = strdup(val->value);
- val = optionGetValue(pov, "expiration_date");
- if (val != NULL && val->valType == OPARG_TYPE_STRING)
- cfg.expiration_date = strdup(val->v.strVal);
+ val = cfg_next(pov, "expiration_date");
+ if (val != NULL)
+ cfg.expiration_date = strdup(val->value);
- val = optionGetValue(pov, "activation_date");
- if (val != NULL && val->valType == OPARG_TYPE_STRING)
- cfg.activation_date = strdup(val->v.strVal);
+ val = cfg_next(pov, "activation_date");
+ if (val != NULL)
+ cfg.activation_date = strdup(val->value);
- val = optionGetValue(pov, "crl_revocation_date");
- if (val != NULL && val->valType == OPARG_TYPE_STRING)
- cfg.revocation_date = strdup(val->v.strVal);
+ val = cfg_next(pov, "crl_revocation_date");
+ if (val != NULL)
+ cfg.revocation_date = strdup(val->value);
- val = optionGetValue(pov, "crl_this_update_date");
- if (val != NULL && val->valType == OPARG_TYPE_STRING)
- cfg.this_update_date = strdup(val->v.strVal);
+ val = cfg_next(pov, "crl_this_update_date");
+ if (val != NULL)
+ cfg.this_update_date = strdup(val->value);
- val = optionGetValue(pov, "crl_next_update_date");
- if (val != NULL && val->valType == OPARG_TYPE_STRING)
- cfg.next_update_date = strdup(val->v.strVal);
+ val = cfg_next(pov, "crl_next_update_date");
+ if (val != NULL)
+ cfg.next_update_date = strdup(val->value);
READ_NUMERIC("inhibit_anypolicy_skip_certs", cfg.skip_certs);
for (i = 0; i < MAX_POLICIES; i++) {
snprintf(tmpstr, sizeof(tmpstr), "policy%d", i + 1);
- val = optionGetValue(pov, tmpstr);
- if (val != NULL && val->valType == OPARG_TYPE_STRING)
- cfg.policy_oid[i] = strdup(val->v.strVal);
+ val = cfg_next(pov, tmpstr);
+ if (val != NULL)
+ cfg.policy_oid[i] = strdup(val->value);
if (cfg.policy_oid[i] != NULL) {
snprintf(tmpstr, sizeof(tmpstr), "policy%d_url",
i + 1);
- val = optionGetValue(pov, tmpstr);
- if (val != NULL
- && val->valType == OPARG_TYPE_STRING)
- cfg.policy_url[i] = strdup(val->v.strVal);
+ val = cfg_next(pov, tmpstr);
+ if (val != NULL)
+ cfg.policy_url[i] = strdup(val->value);
snprintf(tmpstr, sizeof(tmpstr), "policy%d_txt",
i + 1);
- val = optionGetValue(pov, tmpstr);
- if (val != NULL
- && val->valType == OPARG_TYPE_STRING) {
- cfg.policy_txt[i] = strdup(val->v.strVal);
+ val = cfg_next(pov, tmpstr);
+ if (val != NULL) {
+ cfg.policy_txt[i] = strdup(val->value);
}
}
}
@@ -523,27 +515,27 @@ int template_parse(const char *template)
READ_MULTI_LINE("crl_dist_points", cfg.crl_dist_points);
- val = optionGetValue(pov, "pkcs12_key_name");
- if (val != NULL && val->valType == OPARG_TYPE_STRING)
- cfg.pkcs12_key_name = strdup(val->v.strVal);
+ val = cfg_next(pov, "pkcs12_key_name");
+ if (val != NULL)
+ cfg.pkcs12_key_name = strdup(val->value);
- val = optionGetValue(pov, "serial");
- if (val != NULL && val->valType == OPARG_TYPE_STRING)
- SERIAL_DECODE(val->v.strVal, cfg.serial, cfg.serial_size);
+ val = cfg_next(pov, "serial");
+ if (val != NULL)
+ SERIAL_DECODE(val->value, cfg.serial, cfg.serial_size);
READ_NUMERIC("expiration_days", cfg.expiration_days);
READ_NUMERIC("crl_next_update", cfg.crl_next_update);
- val = optionGetValue(pov, "crl_number");
- if (val != NULL && val->valType == OPARG_TYPE_STRING)
- SERIAL_DECODE(val->v.strVal, cfg.crl_number, cfg.crl_number_size);
+ val = cfg_next(pov, "crl_number");
+ if (val != NULL)
+ SERIAL_DECODE(val->value, cfg.crl_number, cfg.crl_number_size);
READ_NUMERIC("path_len", cfg.path_len);
- val = optionGetValue(pov, "proxy_policy_language");
- if (val != NULL && val->valType == OPARG_TYPE_STRING)
- cfg.proxy_policy_language = strdup(val->v.strVal);
+ val = cfg_next(pov, "proxy_policy_language");
+ if (val != NULL)
+ cfg.proxy_policy_language = strdup(val->value);
READ_MULTI_LINE("ocsp_uri", cfg.ocsp_uris);
READ_MULTI_LINE("ca_issuers_uri", cfg.ca_issuers_uris);
@@ -570,7 +562,7 @@ int template_parse(const char *template)
READ_MULTI_LINE("tls_feature", cfg.tls_features);
- optionUnloadNested(pov);
+ cfg_free(pov);
return 0;
}
diff --git a/src/certtool-common.c b/src/certtool-common.c
index 5e7bc5666c..fae3a489d4 100644
--- a/src/certtool-common.c
+++ b/src/certtool-common.c
@@ -40,7 +40,7 @@
#include <fcntl.h>
#include <common.h>
#include "certtool-common.h"
-#include "certtool-args.h"
+#include "certtool-options.h"
#include "certtool-cfg.h"
#include "common.h"
#include <minmax.h>
diff --git a/src/certtool-options.json b/src/certtool-options.json
new file mode 100644
index 0000000000..34ecaa7714
--- /dev/null
+++ b/src/certtool-options.json
@@ -0,0 +1,579 @@
+[
+ {
+ "meta": {
+ "desc": "",
+ "prog-name": "certtool",
+ "prog-title": "GnuTLS certificate tool",
+ "prog-desc": "Manipulate certificates and private keys.",
+ "detail": "Tool to parse and generate X.509 certificates, requests and private keys.\nIt can be used interactively or non interactively by\nspecifying the template command line option.\n\nThe tool accepts files or supported URIs via the --infile option. In case PIN\nis required for URI access you can provide it using the environment variables GNUTLS_PIN \nand GNUTLS_SO_PIN.\n",
+ "short-usage": "certtool [options]\ncerttool --help for usage instructions.\n",
+ "explain": ""
+ },
+ "options": [
+ {
+ "long-option": "debug",
+ "short-option": "d",
+ "arg-min": "0 ",
+ "desc": "Enable debugging",
+ "arg-max": " 9999",
+ "detail": "Specifies the debug level.",
+ "arg-type": "number"
+ },
+ {
+ "short-option": "V",
+ "max": "NOLIMIT",
+ "long-option": "verbose",
+ "desc": "More verbose output",
+ "disabled": "",
+ "detail": ""
+ },
+ {
+ "long-option": "infile",
+ "detail": "",
+ "arg-type": "file",
+ "desc": "Input file",
+ "file-exists": "yes"
+ },
+ {
+ "detail": "",
+ "arg-type": "string",
+ "desc": "Output file",
+ "long-option": "outfile"
+ }
+ ]
+ },
+ {
+ "meta": {
+ "id": "cert-options",
+ "desc": "Certificate related options"
+ },
+ "options": [
+ {
+ "detail": "",
+ "desc": "Print information on the given certificate",
+ "short-option": "i",
+ "long-option": "certificate-info"
+ },
+ {
+ "desc": "Print information on a public key",
+ "long-option": "pubkey-info",
+ "detail": "The option combined with --load-request, --load-pubkey, --load-privkey and --load-certificate will extract the public key of the object in question."
+ },
+ {
+ "long-option": "generate-self-signed",
+ "short-option": "s",
+ "desc": "Generate a self-signed certificate",
+ "detail": ""
+ },
+ {
+ "short-option": "c",
+ "long-option": "generate-certificate",
+ "desc": "Generate a signed certificate",
+ "detail": ""
+ },
+ {
+ "detail": "",
+ "desc": "Generates a proxy certificate",
+ "long-option": "generate-proxy"
+ },
+ {
+ "short-option": "u",
+ "long-option": "update-certificate",
+ "detail": "",
+ "desc": "Update a signed certificate"
+ },
+ {
+ "desc": "Print the fingerprint of the given certificate",
+ "long-option": "fingerprint",
+ "detail": "This is a simple hash of the DER encoding of the certificate. It can be combined with the --hash parameter. However, it is recommended for identification to use the key-id which depends only on the certificate's key."
+ },
+ {
+ "long-option": "key-id",
+ "desc": "Print the key ID of the given certificate",
+ "detail": "This is a hash of the public key of the given certificate. It identifies the key uniquely, remains the same on a certificate renewal and depends only on signed fields of the certificate."
+ },
+ {
+ "deprecated": "",
+ "long-option": "certificate-pubkey",
+ "desc": "Print certificate's public key",
+ "detail": "This option is deprecated as a duplicate of --pubkey-info"
+ },
+ {
+ "desc": "Generate an X.509 version 1 certificate (with no extensions)",
+ "long-option": "v1",
+ "detail": ""
+ },
+ {
+ "desc": "Sign a certificate with a specific signature algorithm",
+ "arg-type": "string",
+ "detail": "This option can be combined with --generate-certificate, to sign the certificate with\na specific signature algorithm variant. The only option supported is 'RSA-PSS', and should be\nspecified when the signer does not have a certificate which is marked for RSA-PSS use only.",
+ "long-option": "sign-params"
+ }
+ ]
+ },
+ {
+ "meta": {
+ "desc": "Certificate request related options",
+ "id": "crq-options"
+ },
+ "options": [
+ {
+ "detail": "",
+ "long-option": "crq-info",
+ "desc": "Print information on the given certificate request"
+ },
+ {
+ "detail": "Will generate a PKCS #10 certificate request. To specify a private key use --load-privkey.",
+ "conflicts": "infile",
+ "long-option": "generate-request",
+ "desc": "Generate a PKCS #10 certificate request",
+ "short-option": "q"
+ },
+ {
+ "desc": "Do not use extensions in certificate requests",
+ "detail": "",
+ "long-option": "no-crq-extensions"
+ }
+ ]
+ },
+ {
+ "meta": {
+ "desc": "PKCS#12 file related options",
+ "id": "pkcs12-options"
+ },
+ "options": [
+ {
+ "detail": "This option will dump the contents and print the metadata of the provided PKCS #12 structure.",
+ "desc": "Print information on a PKCS #12 structure",
+ "long-option": "p12-info"
+ },
+ {
+ "arg-type": "string",
+ "desc": "The PKCS #12 friendly name to use",
+ "detail": "The name to be used for the primary certificate and private key in a PKCS #12 file.",
+ "long-option": "p12-name"
+ },
+ {
+ "detail": "It requires a certificate, a private key and possibly a CA certificate to be specified.",
+ "desc": "Generate a PKCS #12 structure",
+ "long-option": "to-p12"
+ }
+ ]
+ },
+ {
+ "meta": {
+ "id": "key-options",
+ "desc": "Private key related options"
+ },
+ "options": [
+ {
+ "short-option": "k",
+ "long-option": "key-info",
+ "detail": "",
+ "desc": "Print information on a private key"
+ },
+ {
+ "desc": "Print information on a PKCS #8 structure",
+ "detail": "This option will print information about encrypted PKCS #8 structures. That option does not require the decryption of the structure.",
+ "long-option": "p8-info"
+ },
+ {
+ "detail": "It requires an RSA-PSS key as input and will output a raw RSA\nkey. This command is necessary for compatibility with applications that\ncannot read RSA-PSS keys.",
+ "long-option": "to-rsa",
+ "desc": "Convert an RSA-PSS key to raw RSA format"
+ },
+ {
+ "long-option": "generate-privkey",
+ "detail": "When generating RSA-PSS private keys, the --hash option will\nrestrict the allowed hash for the key; in the same keys the --salt-size\noption is also acceptable.",
+ "desc": "Generate a private key",
+ "short-option": "p"
+ },
+ {
+ "arg-type": "string",
+ "long-option": "key-type",
+ "desc": "Specify the key type to use on key generation",
+ "detail": "This option can be combined with --generate-privkey, to specify\nthe key type to be generated. Valid options are, 'rsa', 'rsa-pss', 'dsa', 'ecdsa', 'ed25519, 'ed448', 'x25519', and 'x448'.'.\nWhen combined with certificate generation it can be used to specify an\nRSA-PSS certificate when an RSA key is given."
+ },
+ {
+ "long-option": "bits",
+ "desc": "Specify the number of bits for key generation",
+ "detail": "",
+ "arg-type": "number"
+ },
+ {
+ "detail": "Supported values are secp192r1, secp224r1, secp256r1, secp384r1 and secp521r1.",
+ "arg-type": "string",
+ "long-option": "curve",
+ "desc": "Specify the curve used for EC key generation"
+ },
+ {
+ "detail": "This is alternative to the bits option.",
+ "arg-type": "string",
+ "long-option": "sec-param",
+ "arg-name": "Security parameter",
+ "desc": "Specify the security level [low, legacy, medium, high, ultra]"
+ },
+ {
+ "detail": "This needs to be combined with --load-privkey.",
+ "desc": "Convert a given key to a PKCS #8 structure",
+ "long-option": "to-p8"
+ },
+ {
+ "short-option": "8",
+ "long-option": "pkcs8",
+ "desc": "Use PKCS #8 format for private keys",
+ "detail": ""
+ },
+ {
+ "desc": "Generate a private key or parameters from a seed using a provable method",
+ "detail": "This will use the FIPS PUB186-4 algorithms (i.e., Shawe-Taylor) for provable key generation.\nWhen specified the private keys or parameters will be generated from a seed, and can be\nlater validated with --verify-provable-privkey to be correctly generated from the seed. You may\nspecify --seed or allow GnuTLS to generate one (recommended). This option can be combined with\n--generate-privkey or --generate-dh-params.\n\nThat option applies to RSA and DSA keys. On the DSA keys the PQG parameters\nare generated using the seed, and on RSA the two primes.",
+ "long-option": "provable"
+ },
+ {
+ "detail": "This will use the FIPS-186-4 algorithms for provable key generation. You may specify --seed or use the seed stored in the private key structure.",
+ "long-option": "verify-provable-privkey",
+ "desc": "Verify a private key generated from a seed using a provable method"
+ },
+ {
+ "detail": "The seed acts as a security parameter for the private key, and\nthus a seed size which corresponds to the security level of the private key\nshould be provided (e.g., 256-bits seed).",
+ "arg-type": "string",
+ "desc": "When generating a private key use the given hex-encoded seed",
+ "long-option": "seed"
+ }
+ ]
+ },
+ {
+ "meta": {
+ "desc": "CRL related options",
+ "id": "crl-options"
+ },
+ "options": [
+ {
+ "short-option": "l",
+ "desc": "Print information on the given CRL structure",
+ "long-option": "crl-info",
+ "detail": ""
+ },
+ {
+ "long-option": "generate-crl",
+ "detail": "This option generates a Certificate Revocation List. When combined with --load-crl it would use the loaded CRL as base for the generated (i.e., all revoked certificates in the base will be copied to the new CRL).\nTo add new certificates to the CRL use --load-certificate.",
+ "desc": "Generate a CRL"
+ },
+ {
+ "requires": "load-ca-certificate",
+ "desc": "Verify a Certificate Revocation List using a trusted list",
+ "long-option": "verify-crl",
+ "detail": "The trusted certificate list must be loaded with --load-ca-certificate."
+ }
+ ]
+ },
+ {
+ "meta": {
+ "desc": "Certificate verification related options",
+ "id": "cert-verify-options"
+ },
+ "options": [
+ {
+ "long-option": "verify-chain",
+ "desc": "Verify a PEM encoded certificate chain",
+ "detail": "Verifies the validity of a certificate chain. That is, an ordered set of\ncertificates where each one is the issuer of the previous, and the first is\nthe end-certificate to be validated. In a proper chain the last certificate\nis a self signed one. It can be combined with --verify-purpose or --verify-hostname.",
+ "short-option": "e"
+ },
+ {
+ "detail": "The trusted certificate list can be loaded with --load-ca-certificate. If no\ncertificate list is provided, then the system's trusted certificate list is used. Note that\nduring verification multiple paths may be explored. On a successful verification\nthe successful path will be the last one. It can be combined with --verify-purpose or --verify-hostname.",
+ "desc": "Verify a PEM encoded certificate (chain) against a trusted set",
+ "long-option": "verify"
+ },
+ {
+ "long-option": "verify-hostname",
+ "desc": "Specify a hostname to be used for certificate chain verification",
+ "arg-type": "string",
+ "detail": "This is to be combined with one of the verify certificate options."
+ },
+ {
+ "detail": "This is to be combined with one of the verify certificate options.",
+ "long-option": "verify-email",
+ "desc": "Specify a email to be used for certificate chain verification",
+ "conflicts": "verify-hostname",
+ "arg-type": "string"
+ },
+ {
+ "detail": "This object identifier restricts the purpose of the certificates to be verified. Example purposes are 1.3.6.1.5.5.7.3.1 (TLS WWW), 1.3.6.1.5.5.7.3.4 (EMAIL) etc. Note that a CA certificate without a purpose set (extended key usage) is valid for any purpose.",
+ "long-option": "verify-purpose",
+ "arg-type": "string",
+ "desc": "Specify a purpose OID to be used for certificate chain verification"
+ },
+ {
+ "long-option": "verify-allow-broken",
+ "detail": "This can be combined with --p7-verify, --verify or --verify-chain.",
+ "desc": "Allow broken algorithms, such as MD5 for verification"
+ },
+ {
+ "detail": "This option can be used to specify a certificate verification profile. Certificate\n verification profiles correspond to the security level. This should be one of\n 'none', 'very weak', 'low', 'legacy', 'medium', 'high', 'ultra',\n 'future'. Note that by default no profile is applied, unless one is set\n as minimum in the gnutls configuration file.",
+ "long-option": "verify-profile",
+ "arg-type": "string",
+ "desc": "Specify a security level profile to be used for verification"
+ }
+ ]
+ },
+ {
+ "meta": {
+ "desc": "PKCS#7 structure options",
+ "id": "pkcs7-options"
+ },
+ "options": [
+ {
+ "desc": "Generate a PKCS #7 structure",
+ "detail": "This option generates a PKCS #7 certificate container structure. To add certificates in the structure use --load-certificate and --load-crl.",
+ "long-option": "p7-generate"
+ },
+ {
+ "long-option": "p7-sign",
+ "detail": "This option generates a PKCS #7 structure containing a signature for the provided data from infile. The data are stored within the structure. The signer certificate has to be specified using --load-certificate and --load-privkey. The input to --load-certificate can be a list of certificates. In case of a list, the first certificate is used for signing and the other certificates are included in the structure.",
+ "desc": "Signs using a PKCS #7 structure"
+ },
+ {
+ "desc": "Signs using a detached PKCS #7 structure",
+ "detail": "This option generates a PKCS #7 structure containing a signature for the provided data from infile. The signer certificate has to be specified using --load-certificate and --load-privkey. The input to --load-certificate can be a list of certificates. In case of a list, the first certificate is used for signing and the other certificates are included in the structure.",
+ "long-option": "p7-detached-sign"
+ },
+ {
+ "disable-prefix": "no-",
+ "long-option": "p7-include-cert",
+ "desc": "The signer's certificate will be included in the cert list.",
+ "detail": "This options works with --p7-sign or --p7-detached-sign and will include or exclude the signer's certificate into the generated signature.",
+ "enabled": ""
+ },
+ {
+ "detail": "This option will include a timestamp in the generated signature",
+ "disable-prefix": "no-",
+ "disabled": "",
+ "desc": "Will include a timestamp in the PKCS #7 structure",
+ "long-option": "p7-time"
+ },
+ {
+ "disable-prefix": "no-",
+ "disabled": "",
+ "desc": "Will show the embedded data in the PKCS #7 structure",
+ "long-option": "p7-show-data",
+ "detail": "This option can be combined with --p7-verify or --p7-info and will display the embedded signed data in the PKCS #7 structure."
+ },
+ {
+ "long-option": "p7-info",
+ "desc": "Print information on a PKCS #7 structure",
+ "detail": ""
+ },
+ {
+ "detail": "This option verifies the signed PKCS #7 structure. The certificate list to use for verification can be specified with --load-ca-certificate. When no certificate list is provided, then the system's certificate list is used. Alternatively a direct signer can be provided using --load-certificate. A key purpose can be enforced with the --verify-purpose option, and the --load-data option will utilize detached data.",
+ "long-option": "p7-verify",
+ "desc": "Verify the provided PKCS #7 structure"
+ },
+ {
+ "long-option": "smime-to-p7",
+ "desc": "Convert S/MIME to PKCS #7 structure",
+ "detail": ""
+ }
+ ]
+ },
+ {
+ "meta": {
+ "desc": "Other options",
+ "id": "other-options"
+ },
+ "options": [
+ {
+ "detail": "The will generate random parameters to be used with\nDiffie-Hellman key exchange. The output parameters will be in PKCS #3\nformat. Note that it is recommended to use the --get-dh-params option\ninstead.",
+ "desc": "Generate PKCS #3 encoded Diffie-Hellman parameters",
+ "deprecated": "",
+ "long-option": "generate-dh-params"
+ },
+ {
+ "long-option": "get-dh-params",
+ "desc": "List the included PKCS #3 encoded Diffie-Hellman parameters",
+ "detail": "Returns stored DH parameters in GnuTLS. Those parameters returned\nare defined in RFC7919, and can be considered standard parameters for a TLS\nkey exchange. This option is provided for old applications which require\nDH parameters to be specified; modern GnuTLS applications should not require\nthem."
+ },
+ {
+ "desc": "Print information PKCS #3 encoded Diffie-Hellman parameters",
+ "detail": "",
+ "long-option": "dh-info"
+ },
+ {
+ "detail": "This can be either a file or a PKCS #11 URL",
+ "long-option": "load-privkey",
+ "arg-type": "string",
+ "desc": "Loads a private key file"
+ },
+ {
+ "arg-type": "string",
+ "desc": "Loads a public key file",
+ "detail": "This can be either a file or a PKCS #11 URL",
+ "long-option": "load-pubkey"
+ },
+ {
+ "long-option": "load-request",
+ "desc": "Loads a certificate request file",
+ "detail": "This option can be used with a file",
+ "arg-type": "string"
+ },
+ {
+ "arg-type": "string",
+ "long-option": "load-certificate",
+ "detail": "This option can be used with a file",
+ "desc": "Loads a certificate file"
+ },
+ {
+ "desc": "Loads the certificate authority's private key file",
+ "arg-type": "string",
+ "detail": "This can be either a file or a PKCS #11 URL",
+ "long-option": "load-ca-privkey"
+ },
+ {
+ "desc": "Loads the certificate authority's certificate file",
+ "detail": "This can be either a file or a PKCS #11 URL",
+ "arg-type": "string",
+ "long-option": "load-ca-certificate"
+ },
+ {
+ "desc": "Loads the provided CRL",
+ "arg-type": "string",
+ "long-option": "load-crl",
+ "detail": "This option can be used with a file"
+ },
+ {
+ "detail": "This option can be used with a file",
+ "desc": "Loads auxiliary data",
+ "arg-type": "string",
+ "long-option": "load-data"
+ },
+ {
+ "detail": "You can use this option to specify the password in the command line instead of reading it from the tty. Note, that the command line arguments are available for view in others in the system. Specifying password as '' is the same as specifying no password.",
+ "arg-type": "string",
+ "desc": "Password to use",
+ "long-option": "password"
+ },
+ {
+ "desc": "Enforce a NULL password",
+ "long-option": "null-password",
+ "detail": "This option enforces a NULL password. This is different than the empty or no password in schemas like PKCS #8."
+ },
+ {
+ "detail": "This option enforces an empty password. This is different than the NULL or no password in schemas like PKCS #8.",
+ "long-option": "empty-password",
+ "desc": "Enforce an empty password"
+ },
+ {
+ "long-option": "hex-numbers",
+ "detail": "",
+ "desc": "Print big number in an easier format to parse"
+ },
+ {
+ "long-option": "cprint",
+ "desc": "In certain operations it prints the information in C-friendly format",
+ "detail": "In certain operations it prints the information in C-friendly format, suitable for including into C programs."
+ },
+ {
+ "desc": "Generate RSA key",
+ "detail": "When combined with --generate-privkey generates an RSA private key.",
+ "long-option": "rsa",
+ "description": "This option is equivalent to '--key-type rsa'.",
+ "deprecated": ""
+ },
+ {
+ "description": "This option is equivalent to '--key-type dsa'.",
+ "deprecated": "",
+ "long-option": "dsa",
+ "detail": "When combined with --generate-privkey generates a DSA private key.",
+ "desc": "Generate DSA key"
+ },
+ {
+ "desc": "Generate ECC (ECDSA) key",
+ "description": "This option is equivalent to '--key-type ecdsa'.",
+ "long-option": "ecc",
+ "detail": "When combined with --generate-privkey generates an elliptic curve private key to be used with ECDSA.",
+ "deprecated": ""
+ },
+ {
+ "aliases": "ecc",
+ "deprecated": "",
+ "long-option": "ecdsa"
+ },
+ {
+ "long-option": "hash",
+ "detail": "Available hash functions are SHA1, RMD160, SHA256, SHA384, SHA512, SHA3-224, SHA3-256, SHA3-384, SHA3-512.",
+ "desc": "Hash algorithm to use for signing",
+ "arg-type": "string"
+ },
+ {
+ "desc": "Specify the RSA-PSS key default salt size",
+ "arg-type": "number",
+ "long-option": "salt-size",
+ "detail": "Typical keys shouldn't set or restrict this option."
+ },
+ {
+ "desc": "Use DER format for input certificates, private keys, and DH parameters ",
+ "detail": "The input files will be assumed to be in DER or RAW format. \nUnlike options that in PEM input would allow multiple input data (e.g. multiple \ncertificates), when reading in DER format a single data structure is read.",
+ "disabled": "",
+ "disable-prefix": "no-",
+ "long-option": "inder"
+ },
+ {
+ "aliases": "inder",
+ "long-option": "inraw"
+ },
+ {
+ "long-option": "outder",
+ "disabled": "",
+ "desc": "Use DER format for output certificates, private keys, and DH parameters",
+ "disable-prefix": "no-",
+ "detail": "The output will be in DER or RAW format."
+ },
+ {
+ "aliases": "outder",
+ "long-option": "outraw"
+ },
+ {
+ "desc": "No effect",
+ "long-option": "disable-quick-random",
+ "deprecated": "",
+ "detail": ""
+ },
+ {
+ "arg-type": "string",
+ "long-option": "template",
+ "desc": "Template file to use for non-interactive operation",
+ "detail": ""
+ },
+ {
+ "long-option": "stdout-info",
+ "detail": "",
+ "desc": "Print information to stdout instead of stderr"
+ },
+ {
+ "long-option": "ask-pass",
+ "disabled": "",
+ "desc": "Enable interaction for entering password when in batch mode.",
+ "detail": "This option will enable interaction to enter password when in batch mode. That is useful when the template option has been specified."
+ },
+ {
+ "arg-name": "Cipher",
+ "detail": "Cipher may be one of 3des, 3des-pkcs12, aes-128, aes-192, aes-256, rc2-40, arcfour.",
+ "long-option": "pkcs-cipher",
+ "desc": "Cipher to use for PKCS #8 and #12 operations",
+ "arg-type": "string"
+ },
+ {
+ "arg-type": "string",
+ "long-option": "provider",
+ "detail": "This will override the default options in /etc/gnutls/pkcs11.conf",
+ "desc": "Specify the PKCS #11 provider library"
+ },
+ {
+ "enabled": "",
+ "long-option": "text",
+ "disable-prefix": "no-",
+ "desc": "Output textual information before PEM-encoded certificates, private keys, etc",
+ "detail": "Output textual information before PEM-encoded data"
+ }
+ ]
+ }
+] \ No newline at end of file
diff --git a/src/certtool.c b/src/certtool.c
index 1d7a98064d..c128500614 100644
--- a/src/certtool.c
+++ b/src/certtool.c
@@ -50,7 +50,7 @@
#include <certtool-cfg.h>
#include <common.h>
-#include "certtool-args.h"
+#include "certtool-options.h"
#include "certtool-common.h"
#define MAX_HASH_SIZE 64
@@ -1265,12 +1265,12 @@ static void cmd_parser(int argc, char **argv)
fix_lbuffer(0);
- if (HAVE_OPT(INDER) || HAVE_OPT(INRAW))
+ if (HAVE_OPT(INDER))
incert_format = GNUTLS_X509_FMT_DER;
else
incert_format = GNUTLS_X509_FMT_PEM;
- if (HAVE_OPT(OUTDER) || HAVE_OPT(OUTRAW))
+ if (HAVE_OPT(OUTDER))
outcert_format = GNUTLS_X509_FMT_DER;
else
outcert_format = GNUTLS_X509_FMT_PEM;
diff --git a/src/cfg.c b/src/cfg.c
new file mode 100644
index 0000000000..b8925f9c7c
--- /dev/null
+++ b/src/cfg.c
@@ -0,0 +1,464 @@
+/*
+ * Copyright (C) 2021 Daiki Ueno
+ *
+ * This file is part of GnuTLS.
+ *
+ * GnuTLS 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.
+ *
+ * GnuTLS 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/>.
+ */
+
+#include "config.h"
+
+#include "cfg.h"
+
+#include <assert.h>
+#include <ctype.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "xsize.h"
+
+#define SIZEOF(x) (sizeof(x) / sizeof((x)[0]))
+
+struct options_st {
+ struct cfg_option_st *data;
+ size_t length;
+ size_t capacity;
+};
+
+struct parser_st
+{
+ FILE *fp;
+ char pushback[2];
+ size_t pushback_length;
+};
+
+static inline void
+clear_option(struct cfg_option_st *option)
+{
+ free(option->name);
+ free(option->value);
+ memset(option, 0, sizeof(*option));
+}
+
+void
+cfg_free(cfg_option_t options)
+{
+ for (size_t i = 0; options[i].name; i++) {
+ clear_option(&options[i]);
+ }
+ free(options);
+}
+
+#define HORIZONTAL_WHITESPACE "\t "
+#define WHITESPACE HORIZONTAL_WHITESPACE "\n\v\f\r\b"
+#define ALPHABETIC "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+#define DECIMAL "0123456789"
+#define NAME_FIRST_CHARS "_" ALPHABETIC
+#define VALUE_NAME_CHARS ":^-" NAME_FIRST_CHARS DECIMAL
+
+struct buffer_st {
+ char *data;
+ size_t length;
+ size_t capacity;
+};
+
+static int
+buffer_append(struct buffer_st *buffer, int c)
+{
+ size_t new_length = xsum(buffer->length, 1);
+ if (size_overflow_p(new_length)) {
+ return -EINVAL;
+ }
+ if (buffer->capacity < new_length) {
+ size_t new_capacity;
+ char *new_array;
+
+ new_capacity = xtimes(xsum(buffer->capacity, 1), 2);
+ if (size_overflow_p(new_capacity)) {
+ return -EINVAL;
+ }
+ new_array = realloc(buffer->data, new_capacity);
+ if (!new_array) {
+ return -errno;
+ }
+ buffer->capacity = new_capacity;
+ buffer->data = new_array;
+ }
+ assert(buffer->data);
+ buffer->data[buffer->length++] = c;
+ return 0;
+}
+
+static int
+parser_getc(struct parser_st *parser)
+{
+ if (parser->pushback_length > 0) {
+ return parser->pushback[--parser->pushback_length];
+ }
+ int c = getc(parser->fp);
+ return c;
+}
+
+static void
+parser_ungetc(struct parser_st *parser, int c)
+{
+ assert(parser->pushback_length < SIZEOF(parser->pushback));
+ parser->pushback[parser->pushback_length++] = c;
+}
+
+static void
+skip_comment(struct parser_st *parser)
+{
+ int c;
+
+ c = parser_getc(parser);
+ if (c == EOF) {
+ return;
+ }
+
+ if (c == '#') {
+ for (;;) {
+ c = parser_getc(parser);
+ if (c == EOF) {
+ return;
+ }
+ if (c == '\n') {
+ break;
+ }
+ }
+ }
+ parser_ungetc(parser, c);
+}
+
+static void
+skip_chars(struct parser_st *parser, const char *chars)
+{
+ int c;
+
+ for (;;) {
+ c = parser_getc(parser);
+ if (c == EOF) {
+ return;
+ }
+ if (!strchr(chars, c)) {
+ break;
+ }
+ }
+ parser_ungetc(parser, c);
+}
+
+static void
+skip_comments_and_whitespaces(struct parser_st *parser)
+{
+ int c;
+
+ for (;;) {
+ c = parser_getc(parser);
+ if (c == EOF) {
+ return;
+ }
+ parser_ungetc(parser, c);
+ if (c == '#') {
+ skip_comment(parser);
+ } else if (strchr(WHITESPACE, c)) {
+ skip_chars(parser, WHITESPACE);
+ } else {
+ break;
+ }
+ }
+}
+
+/* Read the name part of an option. Returns NULL if it fails. */
+static char *
+read_name(struct parser_st *parser)
+{
+ struct buffer_st buffer;
+ int c;
+
+ memset(&buffer, 0, sizeof(buffer));
+
+ skip_comments_and_whitespaces(parser);
+
+ c = parser_getc(parser);
+ if (c == EOF) {
+ return NULL;
+ }
+
+ if (!strchr(NAME_FIRST_CHARS, c)) {
+ parser_ungetc(parser, c);
+ return NULL;
+ }
+
+ buffer_append(&buffer, c);
+ for (;;) {
+ c = parser_getc(parser);
+ if (c == EOF) {
+ break;
+ }
+ if (!strchr(VALUE_NAME_CHARS, c)) {
+ parser_ungetc(parser, c);
+ break;
+ }
+ buffer_append(&buffer, c);
+ }
+ assert(buffer.data);
+ if (buffer.data[buffer.length - 1] == ':') {
+ buffer.data[buffer.length - 1] = '\0';
+ buffer.length--;
+ parser_ungetc(parser, ':');
+ }
+
+ /* NUL terminate */
+ buffer_append(&buffer, '\0');
+ return buffer.data;
+}
+
+static char *
+read_quoted_value(struct parser_st *parser)
+{
+ struct buffer_st buffer;
+ int c, quote_char;
+
+ memset(&buffer, 0, sizeof(buffer));
+
+ c = parser_getc(parser);
+ if (c == EOF) {
+ assert(false);
+ return NULL;
+ }
+
+ if (c == '"' || c == '\'') {
+ quote_char = c;
+ } else {
+ assert(false);
+ return NULL;
+ }
+
+ for (;;) {
+ c = parser_getc(parser);
+ if (c == EOF) {
+ break;
+ }
+ if (c == '\\') {
+ c = parser_getc(parser);
+ if (c == EOF) {
+ /* unmatched quote */
+ free(buffer.data);
+ return NULL;
+ }
+ if (c == '\n') {
+ buffer_append(&buffer, ' ');
+ } else if (c == quote_char) {
+ buffer_append(&buffer, c);
+ }
+ } else if (c == quote_char) {
+ break;
+ } else {
+ buffer_append(&buffer, c);
+ }
+ }
+
+ /* NUL terminate */
+ buffer_append(&buffer, '\0');
+ return buffer.data;
+}
+
+/* Read the value part of an option. Returns NULL if it fails. */
+static char *
+read_value(struct parser_st *parser)
+{
+ struct buffer_st buffer;
+ int c;
+
+ memset(&buffer, 0, sizeof(buffer));
+
+ skip_chars(parser, HORIZONTAL_WHITESPACE);
+
+ c = parser_getc(parser);
+ if (c == EOF) {
+ goto out;
+ }
+
+ /* skip delimiter if any, followed by horizontal whitespaces */
+ if (c == ':' || c == '=') {
+ c = parser_getc(parser);
+ if (c == EOF) {
+ goto out;
+ }
+ parser_ungetc(parser, c);
+ skip_chars(parser, HORIZONTAL_WHITESPACE);
+ c = parser_getc(parser);
+ if (c == EOF) {
+ goto out;
+ }
+ }
+
+ if (c == '\n') {
+ return strdup(""); /* empty value */
+ } else if (c == '"' || c == '\'') {
+ parser_ungetc(parser, c);
+ return read_quoted_value(parser);
+ }
+
+ buffer_append(&buffer, c);
+ for (;;) {
+ c = parser_getc(parser);
+ if (c == EOF) {
+ break;
+ }
+ if (c == '\\') {
+ c = parser_getc(parser);
+ if (c == EOF) {
+ break;
+ }
+ if (c == '\n') {
+ buffer_append(&buffer, c);
+ }
+ } else if (c == '\n') {
+ break;
+ } else {
+ buffer_append(&buffer, c);
+ }
+ }
+
+ out:
+ /* NUL terminate */
+ buffer_append(&buffer, '\0');
+ return buffer.data;
+}
+
+/* Append OPTION to OPTIONS. Take ownership of the fields of OPTION. */
+static int
+take_option(struct options_st *options, struct cfg_option_st *option)
+{
+ size_t new_length = xsum(options->length, 1);
+ if (size_overflow_p(new_length)) {
+ return -EINVAL;
+ }
+ if (options->capacity < new_length) {
+ size_t new_capacity;
+ struct cfg_option_st *new_array;
+
+ new_capacity = xtimes(xsum(options->capacity, 1), 2);
+ if (size_overflow_p(new_capacity)) {
+ return -EINVAL;
+ }
+ new_array = reallocarray(options->data, new_capacity,
+ sizeof(*option));
+ if (!new_array) {
+ return -errno;
+ }
+ options->capacity = new_capacity;
+ options->data = new_array;
+ }
+
+ assert(options->data);
+
+ options->data[options->length].name = option->name;
+ options->data[options->length].value = option->value;
+
+ options->length++;
+
+ option->name = NULL;
+ option->value = NULL;
+
+ return 0;
+}
+
+static void
+clear_options(struct options_st *options)
+{
+ for (size_t i = 0; options->length; i++) {
+ clear_option(&options->data[i]);
+ }
+}
+
+cfg_option_t
+cfg_load(const char *filename)
+{
+ struct parser_st parser;
+ struct options_st options;
+ struct cfg_option_st null_option = { NULL, NULL };
+
+ memset(&parser, 0, sizeof(parser));
+ memset(&options, 0, sizeof(options));
+
+ parser.fp = fopen(filename, "r");
+ if (!parser.fp) {
+ return NULL;
+ }
+
+ for (;;) {
+ struct cfg_option_st option;
+
+ option.name = read_name(&parser);
+ if (!option.name) {
+ break;
+ }
+
+ option.value = read_value(&parser);
+ if (!option.value) {
+ clear_option(&option);
+ goto error;
+ }
+
+ if (take_option(&options, &option) < 0) {
+ clear_option(&option);
+ goto error;
+ }
+ assert(!option.name && !option.value);
+ }
+
+ fclose(parser.fp);
+ /* NUL terminate */
+ take_option(&options, &null_option);
+ return options.data;
+
+error:
+ clear_options(&options);
+ fclose(parser.fp);
+ return NULL;
+}
+
+cfg_option_t
+cfg_next(const cfg_option_t options, const char *name)
+{
+ for (size_t i = 0; options[i].name; i++) {
+ if (strcmp(options[i].name, name) == 0) {
+ return &options[i];
+ }
+ }
+ return NULL;
+}
+
+#ifdef TEST
+int
+main(int argc, char **argv)
+{
+ cfg_option_t opts;
+
+ assert(argc == 2);
+
+ opts = cfg_load(argv[1]);
+ for (size_t i = 0; opts[i].name; i++) {
+ printf("%s: %s\n", opts[i].name, opts[i].value);
+ }
+ cfg_free(opts);
+
+ return 0;
+}
+#endif
diff --git a/src/cfg.h b/src/cfg.h
new file mode 100644
index 0000000000..20e8fc9faa
--- /dev/null
+++ b/src/cfg.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2021 Daiki Ueno
+ *
+ * This file is part of GnuTLS.
+ *
+ * GnuTLS 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.
+ *
+ * GnuTLS 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 CFG_H_
+#define CFG_H_ 1
+
+typedef struct cfg_option_st {
+ char *name;
+ char *value;
+} *cfg_option_t;
+
+cfg_option_t cfg_load(const char *filename);
+void cfg_free(cfg_option_t options);
+cfg_option_t cfg_next(const cfg_option_t options, const char *name);
+
+#endif /* CFG_H_ */
diff --git a/src/cli-args.def b/src/cli-args.def
deleted file mode 100644
index 2279b9cc0a..0000000000
--- a/src/cli-args.def
+++ /dev/null
@@ -1,600 +0,0 @@
-AutoGen Definitions options;
-prog-name = gnutls-cli;
-prog-title = "GnuTLS client";
-prog-desc = "Simple client program to set up a TLS connection.";
-short-usage = "Usage: gnutls-cli [options] hostname\ngnutls-cli --help for usage instructions.\n";
-explain = "";
-detail = "Simple client program to set up a TLS connection to some other computer.
-It sets up a TLS connection and forwards data from the standard input to the secured socket and vice versa.";
-reorder-args;
-argument = "[hostname]";
-
-#define VERBOSE_OPT 1
-#include args-std.def
-
-flag = {
- name = tofu;
- descrip = "Enable trust on first use authentication";
- disabled;
- disable = "no";
- doc = "This option will, in addition to certificate authentication, perform authentication
-based on previously seen public keys, a model similar to SSH authentication. Note that when tofu
-is specified (PKI) and DANE authentication will become advisory to assist the public key acceptance
-process.";
-};
-
-flag = {
- name = strict-tofu;
- descrip = "Fail to connect if a certificate is unknown or a known certificate has changed";
- disabled;
- disable = "no";
- doc = "This option will perform authentication as with option --tofu; however, no questions shall be asked whatsoever, neither to accept an unknown certificate nor a changed one.";
-
-};
-
-flag = {
- name = dane;
- descrip = "Enable DANE certificate verification (DNSSEC)";
- disabled;
- disable = "no";
- doc = "This option will, in addition to certificate authentication using
-the trusted CAs, verify the server certificates using on the DANE information
-available via DNSSEC.";
-};
-
-flag = {
- name = local-dns;
- descrip = "Use the local DNS server for DNSSEC resolving";
- disabled;
- disable = "no";
- doc = "This option will use the local DNS server for DNSSEC.
-This is disabled by default due to many servers not allowing DNSSEC.";
-};
-
-flag = {
- name = ca-verification;
- descrip = "Enable CA certificate verification";
- enabled;
- disable = "no";
- doc = "This option can be used to enable or disable CA certificate verification. It is to be used with the --dane or --tofu options.";
-};
-
-flag = {
- name = ocsp;
- descrip = "Enable OCSP certificate verification";
- disabled;
- disable = "no";
- doc = "This option will enable verification of the peer's certificate using ocsp";
-};
-
-flag = {
- name = resume;
- value = r;
- descrip = "Establish a session and resume";
- doc = "Connect, establish a session, reconnect and resume.";
-};
-
-flag = {
- name = earlydata;
- arg-type = string;
- descrip = "Send early data on resumption from the specified file";
- doc = "";
-};
-
-flag = {
- name = rehandshake;
- value = e;
- descrip = "Establish a session and rehandshake";
- doc = "Connect, establish a session and rehandshake immediately.";
-};
-
-flag = {
- name = sni-hostname;
- descrip = "Server's hostname for server name indication extension";
- arg-type = string;
- doc = "Set explicitly the server name used in the TLS server name indication extension. That is useful when testing with servers setup on different DNS name than the intended. If not specified, the provided hostname is used. Even with this option server certificate verification still uses the hostname passed on the main commandline. Use --verify-hostname to change this.";
-};
-
-flag = {
- name = verify-hostname;
- descrip = "Server's hostname to use for validation";
- arg-type = string;
- doc = "Set explicitly the server name to be used when validating the server's certificate.";
-};
-
-flag = {
- name = starttls;
- value = s;
- descrip = "Connect, establish a plain session and start TLS";
- doc = "The TLS session will be initiated when EOF or a SIGALRM is received.";
-};
-
-flag = {
- name = app-proto;
- aliases = starttls-proto;
-};
-
-flag = {
- name = starttls-proto;
- descrip = "The application protocol to be used to obtain the server's certificate (https, ftp, smtp, imap, ldap, xmpp, lmtp, pop3, nntp, sieve, postgres)";
- arg-type = string;
- doc = "Specify the application layer protocol for STARTTLS. If the protocol is supported, gnutls-cli will proceed to the TLS negotiation.";
- flags-cant = starttls;
-};
-
-flag = {
- name = udp;
- value = u;
- descrip = "Use DTLS (datagram TLS) over UDP";
- doc = "";
-};
-
-flag = {
- name = mtu;
- arg-type = number;
- arg-range = "0->17000";
- descrip = "Set MTU for datagram TLS";
- doc = "";
-};
-
-flag = {
- name = crlf;
- descrip = "Send CR LF instead of LF";
- doc = "";
-};
-
-flag = {
- name = fastopen;
- descrip = "Enable TCP Fast Open";
- doc = "";
-};
-
-flag = {
- name = x509fmtder;
- descrip = "Use DER format for certificates to read from";
- doc = "";
-};
-
-flag = {
- name = print-cert;
- descrip = "Print peer's certificate in PEM format";
- doc = "";
-};
-
-flag = {
- name = save-cert;
- arg-type = string;
- descrip = "Save the peer's certificate chain in the specified file in PEM format";
- doc = "";
-};
-
-flag = {
- name = save-ocsp;
- arg-type = string;
- descrip = "Save the peer's OCSP status response in the provided file";
- doc = "";
- flags-cant = save-ocsp-multi;
-};
-
-flag = {
- name = save-ocsp-multi;
- arg-type = string;
- descrip = "Save all OCSP responses provided by the peer in this file";
- doc = "The file will contain a list of PEM encoded OCSP status responses if any were provided by the peer, starting with the one for the peer's server certificate.";
- flags-cant = save-ocsp;
-};
-
-flag = {
- name = save-server-trace;
- arg-type = string;
- descrip = "Save the server-side TLS message trace in the provided file";
- doc = "";
-};
-
-flag = {
- name = save-client-trace;
- arg-type = string;
- descrip = "Save the client-side TLS message trace in the provided file";
- doc = "";
-};
-
-flag = {
- name = dh-bits;
- arg-type = number;
- descrip = "The minimum number of bits allowed for DH";
- doc = "This option sets the minimum number of bits allowed for a Diffie-Hellman key exchange. You may want to lower the default value if the peer sends a weak prime and you get an connection error with unacceptable prime.";
-};
-
-flag = {
- name = priority;
- arg-type = string;
- descrip = "Priorities string";
- doc = "TLS algorithms and protocols to enable. You can
-use predefined sets of ciphersuites such as PERFORMANCE,
-NORMAL, PFS, SECURE128, SECURE256. The default is NORMAL.
-
-Check the GnuTLS manual on section ``Priority strings'' for more
-information on the allowed keywords";
-};
-
-flag = {
- name = x509cafile;
- arg-type = string;
- descrip = "Certificate file or PKCS #11 URL to use";
- doc = "";
-};
-
-flag = {
- name = x509crlfile;
- arg-type = file;
- file-exists = yes;
- descrip = "CRL file to use";
- doc = "";
-};
-
-flag = {
- name = x509keyfile;
- arg-type = string;
- descrip = "X.509 key file or PKCS #11 URL to use";
- doc = "";
-};
-
-flag = {
- name = x509certfile;
- arg-type = string;
- descrip = "X.509 Certificate file or PKCS #11 URL to use";
- doc = "";
- flags-must = x509keyfile;
-};
-
-flag = {
- name = rawpkkeyfile;
- arg-type = string;
- descrip = "Private key file (PKCS #8 or PKCS #12) or PKCS #11 URL to use";
- doc = "In order to instruct the application to negotiate raw public keys one
-must enable the respective certificate types via the priority strings (i.e. CTYPE-CLI-*
-and CTYPE-SRV-* flags).
-
-Check the GnuTLS manual on section ``Priority strings'' for more
-information on how to set certificate types.";
-};
-
-flag = {
- name = rawpkfile;
- arg-type = string;
- descrip = "Raw public-key file to use";
- doc = "In order to instruct the application to negotiate raw public keys one
-must enable the respective certificate types via the priority strings (i.e. CTYPE-CLI-*
-and CTYPE-SRV-* flags).
-
-Check the GnuTLS manual on section ``Priority strings'' for more
-information on how to set certificate types.";
- flags-must = rawpkkeyfile;
-};
-
-flag = {
- name = srpusername;
- arg-type = string;
- descrip = "SRP username to use";
- doc = "";
-};
-
-flag = {
- name = srppasswd;
- arg-type = string;
- descrip = "SRP password to use";
- doc = "";
-};
-
-flag = {
- name = pskusername;
- arg-type = string;
- descrip = "PSK username to use";
- doc = "";
-};
-
-flag = {
- name = pskkey;
- arg-type = string;
- descrip = "PSK key (in hex) to use";
- doc = "";
-};
-
-
-flag = {
- name = port;
- value = p;
- arg-type = string;
- descrip = "The port or service to connect to";
- doc = "";
-};
-
-flag = {
- name = insecure;
- descrip = "Don't abort program if server certificate can't be validated";
- doc = "";
-};
-
-flag = {
- name = verify-allow-broken;
- descrip = "Allow broken algorithms, such as MD5 for certificate verification";
- doc = "";
-};
-
-flag = {
- name = ranges;
- descrip = "Use length-hiding padding to prevent traffic analysis";
- doc = "When possible (e.g., when using CBC ciphersuites), use length-hiding padding to prevent traffic analysis.";
- deprecated;
-};
-
-flag = {
- name = benchmark-ciphers;
- descrip = "Benchmark individual ciphers";
- doc = "By default the benchmarked ciphers will utilize any capabilities of the local CPU to improve performance. To test against the raw software implementation set the environment variable GNUTLS_CPUID_OVERRIDE to 0x1.";
-};
-
-flag = {
- name = benchmark-tls-kx;
- descrip = "Benchmark TLS key exchange methods";
- doc = "";
-};
-
-flag = {
- name = benchmark-tls-ciphers;
- descrip = "Benchmark TLS ciphers";
- doc = "By default the benchmarked ciphers will utilize any capabilities of the local CPU to improve performance. To test against the raw software implementation set the environment variable GNUTLS_CPUID_OVERRIDE to 0x1.";
-};
-
-flag = {
- name = list;
- value = l;
- descrip = "Print a list of the supported algorithms and modes";
- doc = "Print a list of the supported algorithms and modes. If a priority string is given then only the enabled ciphersuites are shown.";
- flags-cant = port;
-};
-
-flag = {
- name = priority-list;
- descrip = "Print a list of the supported priority strings";
- doc = "Print a list of the supported priority strings. The ciphersuites corresponding to each priority string can be examined using -l -p.";
-};
-
-flag = {
- name = noticket;
- descrip = "Don't allow session tickets";
- doc = "Disable the request of receiving of session tickets under TLS1.2 or earlier";
-};
-
-flag = {
- name = srtp_profiles;
- arg-type = string;
- descrip = "Offer SRTP profiles";
- doc = "";
-};
-
-flag = {
- name = alpn;
- arg-type = string;
- descrip = "Application layer protocol";
- max = NOLIMIT; /* occurrence limit (none) */
- stack-arg; /* save opt args in a stack */
- doc = "This option will set and enable the Application Layer Protocol Negotiation (ALPN) in the TLS protocol.";
-};
-
-flag = {
- name = heartbeat;
- value = b;
- descrip = "Activate heartbeat support";
- doc = "";
-};
-
-flag = {
- name = recordsize;
- arg-type = number;
- arg-range = "0->4096";
- descrip = "The maximum record size to advertise";
- doc = "";
-};
-
-flag = {
- name = disable-sni;
- descrip = "Do not send a Server Name Indication (SNI)";
- doc = "";
-};
-
-flag = {
- name = disable-extensions;
- descrip = "Disable all the TLS extensions";
- doc = "This option disables all TLS extensions. Deprecated option. Use the priority string.";
- deprecated;
-};
-
-flag = {
- name = single-key-share;
- descrip = "Send a single key share under TLS1.3";
- doc = "This option switches the default mode of sending multiple
-key shares, to send a single one (the top one).";
-};
-
-flag = {
- name = post-handshake-auth;
- descrip = "Enable post-handshake authentication under TLS1.3";
- doc = "This option enables post-handshake authentication when under TLS1.3.";
-};
-
-flag = {
- name = inline-commands;
- descrip = "Inline commands of the form ^<cmd>^";
- doc = "Enable inline commands of the form ^<cmd>^. The inline commands are expected to be in a line by themselves. The available commands are: resume, rekey1 (local rekey), rekey (rekey on both peers) and renegotiate.";
-};
-
-flag = {
- name = inline-commands-prefix;
- arg-type = string;
- descrip = "Change the default delimiter for inline commands.";
- doc = "Change the default delimiter (^) used for inline commands. The delimiter is expected to be a single US-ASCII character (octets 0 - 127). This option is only relevant if inline commands are enabled via the inline-commands option";
-};
-
-flag = {
- name = provider;
- arg-type = file;
- file-exists = yes;
- descrip = "Specify the PKCS #11 provider library";
- doc = "This will override the default options in /etc/gnutls/pkcs11.conf";
-};
-
-flag = {
- name = fips140-mode;
- descrip = "Reports the status of the FIPS140-2 mode in gnutls library";
- doc = "";
-};
-
-flag = {
- name = logfile;
- arg-type = string;
- descrip = "Redirect informational messages to a specific file.";
- doc = "Redirect informational messages to a specific file. The file may be /dev/null also to make the gnutls client quiet to use it in piped server connections where only the server communication may appear on stdout.";
-};
-
-flag = {
- name = keymatexport;
- arg-type = string;
- descrip = "Label used for exporting keying material";
- doc = "";
-};
-
-flag = {
- name = keymatexportsize;
- arg-type = number;
- descrip = "Size of the exported keying material";
- doc = "";
-};
-
-flag = {
- name = waitresumption;
- descrip = "Block waiting for the resumption data under TLS1.3";
- doc = "This option makes the client to block waiting for the resumption data under TLS1.3. The option has effect only when --resume is provided.";
-};
-
-flag = {
- name = ca-auto-retrieve;
- descrip = "Enable automatic retrieval of missing CA certificates";
- disabled;
- disable = "no";
- doc = "This option enables the client to automatically retrieve the missing intermediate CA certificates in the certificate chain, based on the Authority Information Access (AIA) extension.";
-};
-
-doc-section = {
- ds-type = 'SEE ALSO'; // or anything else
- ds-format = 'texi'; // or texi or mdoc format
- ds-text = <<-_EOF_
-gnutls-cli-debug(1), gnutls-serv(1)
-_EOF_;
-};
-
-doc-section = {
- ds-type = 'EXAMPLES';
- ds-format = 'texi';
- ds-text = <<-_EOF_
-@subheading Connecting using PSK authentication
-To connect to a server using PSK authentication, you need to enable the choice of PSK by using a cipher priority parameter such as in the example below.
-@example
-$ ./gnutls-cli -p 5556 localhost --pskusername psk_identity \
- --pskkey 88f3824b3e5659f52d00e959bacab954b6540344 \
- --priority NORMAL:-KX-ALL:+ECDHE-PSK:+DHE-PSK:+PSK
-Resolving 'localhost'...
-Connecting to '127.0.0.1:5556'...
-- PSK authentication.
-- Version: TLS1.1
-- Key Exchange: PSK
-- Cipher: AES-128-CBC
-- MAC: SHA1
-- Compression: NULL
-- Handshake was completed
-
-- Simple Client Mode:
-@end example
-By keeping the --pskusername parameter and removing the --pskkey parameter, it will query only for the password during the handshake.
-
-@subheading Connecting using raw public-key authentication
-To connect to a server using raw public-key authentication, you need to enable the option to negotiate raw public-keys via the priority strings such as in the example below.
-@example
-$ ./gnutls-cli -p 5556 localhost --priority NORMAL:-CTYPE-CLI-ALL:+CTYPE-CLI-RAWPK \
- --rawpkkeyfile cli.key.pem \
- --rawpkfile cli.rawpk.pem
-Processed 1 client raw public key pair...
-Resolving 'localhost'...
-Connecting to '127.0.0.1:5556'...
-- Successfully sent 1 certificate(s) to server.
-- Server has requested a certificate.
-- Certificate type: X.509
-- Got a certificate list of 1 certificates.
-- Certificate[0] info:
- - skipped
-- Description: (TLS1.3-Raw Public Key-X.509)-(ECDHE-SECP256R1)-(RSA-PSS-RSAE-SHA256)-(AES-256-GCM)
-- Options:
-- Handshake was completed
-
-- Simple Client Mode:
-@end example
-
-@subheading Connecting to STARTTLS services
-
-You could also use the client to connect to services with starttls capability.
-@example
-$ gnutls-cli --starttls-proto smtp --port 25 localhost
-@end example
-
-@subheading Listing ciphersuites in a priority string
-To list the ciphersuites in a priority string:
-@example
-$ ./gnutls-cli --priority SECURE192 -l
-Cipher suites for SECURE192
-TLS_ECDHE_ECDSA_AES_256_CBC_SHA384 0xc0, 0x24 TLS1.2
-TLS_ECDHE_ECDSA_AES_256_GCM_SHA384 0xc0, 0x2e TLS1.2
-TLS_ECDHE_RSA_AES_256_GCM_SHA384 0xc0, 0x30 TLS1.2
-TLS_DHE_RSA_AES_256_CBC_SHA256 0x00, 0x6b TLS1.2
-TLS_DHE_DSS_AES_256_CBC_SHA256 0x00, 0x6a TLS1.2
-TLS_RSA_AES_256_CBC_SHA256 0x00, 0x3d TLS1.2
-
-Certificate types: CTYPE-X.509
-Protocols: VERS-TLS1.2, VERS-TLS1.1, VERS-TLS1.0, VERS-SSL3.0, VERS-DTLS1.0
-Compression: COMP-NULL
-Elliptic curves: CURVE-SECP384R1, CURVE-SECP521R1
-PK-signatures: SIGN-RSA-SHA384, SIGN-ECDSA-SHA384, SIGN-RSA-SHA512, SIGN-ECDSA-SHA512
-@end example
-
-@subheading Connecting using a PKCS #11 token
-To connect to a server using a certificate and a private key present in a PKCS #11 token you
-need to substitute the PKCS 11 URLs in the x509certfile and x509keyfile parameters.
-
-Those can be found using "p11tool --list-tokens" and then listing all the objects in the
-needed token, and using the appropriate.
-@example
-$ p11tool --list-tokens
-
-Token 0:
- URL: pkcs11:model=PKCS15;manufacturer=MyMan;serial=1234;token=Test
- Label: Test
- Manufacturer: EnterSafe
- Model: PKCS15
- Serial: 1234
-
-$ p11tool --login --list-certs "pkcs11:model=PKCS15;manufacturer=MyMan;serial=1234;token=Test"
-
-Object 0:
- URL: pkcs11:model=PKCS15;manufacturer=MyMan;serial=1234;token=Test;object=client;type=cert
- Type: X.509 Certificate
- Label: client
- ID: 2a:97:0d:58:d1:51:3c:23:07:ae:4e:0d:72:26:03:7d:99:06:02:6a
-
-$ MYCERT="pkcs11:model=PKCS15;manufacturer=MyMan;serial=1234;token=Test;object=client;type=cert"
-$ MYKEY="pkcs11:model=PKCS15;manufacturer=MyMan;serial=1234;token=Test;object=client;type=private"
-$ export MYCERT MYKEY
-
-$ gnutls-cli www.example.com --x509keyfile $MYKEY --x509certfile $MYCERT
-@end example
-Notice that the private key only differs from the certificate in the type.
-_EOF_;
-};
diff --git a/src/cli-debug.c b/src/cli-debug.c
index c98c0c6f4a..cdd88b96ea 100644
--- a/src/cli-debug.c
+++ b/src/cli-debug.c
@@ -35,7 +35,7 @@
#include <tests.h>
#include <common.h>
#include <ctype.h>
-#include <cli-debug-args.h>
+#include "gnutls-cli-debug-options.h"
#include <socket.h>
/* Gnulib portability files. */
diff --git a/src/cli.c b/src/cli.c
index 2384a0cab3..09f7efc2c3 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -71,7 +71,7 @@
#include <common.h>
#include <socket.h>
-#include <cli-args.h>
+#include "gnutls-cli-options.h"
#include <ocsptool-common.h>
#define MAX_BUF 4096
diff --git a/src/danetool-args.def b/src/danetool-args.def
deleted file mode 100644
index 61d11a3fff..0000000000
--- a/src/danetool-args.def
+++ /dev/null
@@ -1,230 +0,0 @@
-AutoGen Definitions options;
-prog-name = danetool;
-prog-title = "GnuTLS DANE tool";
-prog-desc = "Generate DANE TLSA RR entries.";
-detail = "Tool to generate and check DNS resource records for the DANE protocol.";
-short-usage = "danetool --[tlsa-rr|check] [options]
-danetool --help for additional usage instructions.\n";
-explain = "";
-
-#define INFILE_OPT 0
-#define OUTFILE_OPT 1
-#define VERBOSE_OPT 1
-#include args-std.def
-
-flag = {
- name = load-pubkey;
- descrip = "Loads a public key file";
- arg-type = string;
- doc = "This can be either a file or a PKCS #11 URL";
-};
-
-flag = {
- name = load-certificate;
- descrip = "Loads a certificate file";
- arg-type = string;
- doc = "This can be either a file or a PKCS #11 URL";
-};
-
-flag = {
- name = dlv;
- descrip = "Sets a DLV file";
- arg-type = string;
- doc = "This sets a DLV file to be used for DNSSEC verification.";
-};
-
-flag = {
- name = hash;
- arg-type = string;
- descrip = "Hash algorithm to use for signing";
- doc = "Available hash functions are SHA1, RMD160, SHA256, SHA384, SHA512.";
-};
-
-flag = {
- name = check;
- arg-type = string;
- descrip = "Check a host's DANE TLSA entry";
- doc = "Obtains the DANE TLSA entry from the given hostname and prints information. Note that the actual certificate of the host can be provided using --load-certificate, otherwise danetool will connect to the server to obtain it. The exit code on verification success will be zero.";
-};
-
-flag = {
- name = check-ee;
- descrip = "Check only the end-entity's certificate";
- doc = "Checks the end-entity's certificate only. Trust anchors or CAs are not considered.";
-};
-
-flag = {
- name = check-ca;
- descrip = "Check only the CA's certificate";
- doc = "Checks the trust anchor's and CA's certificate only. End-entities are not considered.";
-};
-
-flag = {
- name = tlsa-rr;
- descrip = "Print the DANE RR data on a certificate or public key";
- flags_must = host;
- doc = "This command prints the DANE RR data needed to enable DANE on a DNS server.";
-};
-
-flag = {
- name = host;
- descrip = "Specify the hostname to be used in the DANE RR";
- arg-type = string;
- arg-name = "Hostname";
- doc = "This command sets the hostname for the DANE RR.";
-};
-
-flag = {
- name = proto;
- descrip = "The protocol set for DANE data (tcp, udp etc.)";
- arg-type = string;
- arg-name = "Protocol";
- doc = "This command specifies the protocol for the service set in the DANE data.";
-};
-
-flag = {
- name = port;
- arg-type = string;
- descrip = "The port or service to connect to, for DANE data";
- default-value = "443";
- doc = "";
-};
-
-flag = {
- name = app-proto;
- aliases = starttls-proto;
-};
-
-flag = {
- name = starttls-proto;
- descrip = "The application protocol to be used to obtain the server's certificate (https, ftp, smtp, imap, ldap, xmpp, lmtp, pop3, nntp, sieve, postgres)";
- arg-type = string;
- doc = "When the server's certificate isn't provided danetool will connect to the server to obtain the certificate. In that case it is required to know the protocol to talk with the server prior to initiating the TLS handshake.";
-};
-
-flag = {
- name = ca;
- descrip = "Whether the provided certificate or public key is a Certificate Authority";
- doc = "Marks the DANE RR as a CA certificate if specified.";
-};
-
-flag = {
- name = x509;
- descrip = "Use the hash of the X.509 certificate, rather than the public key";
- doc = "This option forces the generated record to contain the hash of the full X.509 certificate. By default only the hash of the public key is used.";
-};
-
-flag = {
- name = local;
- aliases = domain;
-};
-
-flag = {
- name = domain;
- descrip = "The provided certificate or public key is issued by the local domain";
- enabled;
- disable = "no";
- doc = "DANE distinguishes certificates and public keys offered via the DNSSEC to trusted and local entities. This flag indicates that this is a domain-issued certificate, meaning that there could be no CA involved.";
-};
-
-flag = {
- name = local-dns;
- descrip = "Use the local DNS server for DNSSEC resolving";
- disabled;
- disable = "no";
- doc = "This option will use the local DNS server for DNSSEC.
-This is disabled by default due to many servers not allowing DNSSEC.";
-};
-
-flag = {
- name = insecure;
- descrip = "Do not verify any DNSSEC signature";
- doc = "Ignores any DNSSEC signature verification results.";
-};
-
-flag = {
- name = inder;
- descrip = "Use DER format for input certificates and private keys";
- disabled;
- disable = "no";
- doc = "The input files will be assumed to be in DER or RAW format.
-Unlike options that in PEM input would allow multiple input data (e.g. multiple
-certificates), when reading in DER format a single data structure is read.";
-};
-
-flag = {
- name = inraw;
- aliases = inder;
-};
-
-flag = {
- name = print-raw;
- descrip = "Print the received DANE data in raw format";
- disabled;
- disable = "no";
- doc = "This option will print the received DANE data.";
-};
-
-flag = {
- name = quiet;
- descrip = "Suppress several informational messages";
- doc = "In that case on the exit code can be used as an indication of verification success";
-};
-
-
-
-doc-section = {
- ds-type = 'SEE ALSO';
- ds-format = 'texi';
- ds-text = <<-_EOT_
- certtool (1)
-_EOT_;
-};
-
-doc-section = {
- ds-type = 'EXAMPLES';
- ds-format = 'texi';
- ds-text = <<-_EOT_
-@subheading DANE TLSA RR generation
-
-To create a DANE TLSA resource record for a certificate (or public key)
-that was issued localy and may or may not be signed by a CA use the following command.
-@example
-$ danetool --tlsa-rr --host www.example.com --load-certificate cert.pem
-@end example
-
-To create a DANE TLSA resource record for a CA signed certificate, which will
-be marked as such use the following command.
-@example
-$ danetool --tlsa-rr --host www.example.com --load-certificate cert.pem \
- --no-domain
-@end example
-
-The former is useful to add in your DNS entry even if your certificate is signed
-by a CA. That way even users who do not trust your CA will be able to verify your
-certificate using DANE.
-
-In order to create a record for the CA signer of your certificate use the following.
-@example
-$ danetool --tlsa-rr --host www.example.com --load-certificate cert.pem \
- --ca --no-domain
-@end example
-
-To read a server's DANE TLSA entry, use:
-@example
-$ danetool --check www.example.com --proto tcp --port 443
-@end example
-
-To verify an HTTPS server's DANE TLSA entry, use:
-@example
-$ danetool --check www.example.com --proto tcp --port 443 --load-certificate chain.pem
-@end example
-
-To verify an SMTP server's DANE TLSA entry, use:
-@example
-$ danetool --check www.example.com --proto tcp --starttls-proto=smtp --load-certificate chain.pem
-@end example
-_EOT_;
-};
-
-
diff --git a/src/danetool-options.json b/src/danetool-options.json
new file mode 100644
index 0000000000..c744498323
--- /dev/null
+++ b/src/danetool-options.json
@@ -0,0 +1,171 @@
+[
+ {
+ "meta": {
+ "detail": "Tool to generate and check DNS resource records for the DANE protocol.",
+ "explain": "",
+ "desc": "",
+ "prog-title": "GnuTLS DANE tool",
+ "prog-desc": "Generate DANE TLSA RR entries.",
+ "short-usage": "danetool --[tlsa-rr|check] [options]\ndanetool --help for additional usage instructions.\n",
+ "prog-name": "danetool"
+ },
+ "options": [
+ {
+ "long-option": "debug",
+ "desc": "Enable debugging",
+ "short-option": "d",
+ "arg-max": " 9999",
+ "arg-min": "0 ",
+ "arg-type": "number",
+ "detail": "Specifies the debug level."
+ },
+ {
+ "desc": "More verbose output",
+ "detail": "",
+ "long-option": "verbose",
+ "short-option": "V",
+ "max": "NOLIMIT",
+ "disabled": ""
+ },
+ {
+ "detail": "",
+ "desc": "Output file",
+ "arg-type": "string",
+ "long-option": "outfile"
+ },
+ {
+ "desc": "Loads a public key file",
+ "long-option": "load-pubkey",
+ "detail": "This can be either a file or a PKCS #11 URL",
+ "arg-type": "string"
+ },
+ {
+ "desc": "Loads a certificate file",
+ "detail": "This can be either a file or a PKCS #11 URL",
+ "arg-type": "string",
+ "long-option": "load-certificate"
+ },
+ {
+ "arg-type": "string",
+ "desc": "Sets a DLV file",
+ "detail": "This sets a DLV file to be used for DNSSEC verification.",
+ "long-option": "dlv"
+ },
+ {
+ "detail": "Available hash functions are SHA1, RMD160, SHA256, SHA384, SHA512.",
+ "arg-type": "string",
+ "desc": "Hash algorithm to use for signing",
+ "long-option": "hash"
+ },
+ {
+ "arg-type": "string",
+ "desc": "Check a host's DANE TLSA entry",
+ "detail": "Obtains the DANE TLSA entry from the given hostname and prints information. Note that the actual certificate of the host can be provided using --load-certificate, otherwise danetool will connect to the server to obtain it. The exit code on verification success will be zero.",
+ "long-option": "check"
+ },
+ {
+ "long-option": "check-ee",
+ "desc": "Check only the end-entity's certificate",
+ "detail": "Checks the end-entity's certificate only. Trust anchors or CAs are not considered."
+ },
+ {
+ "desc": "Check only the CA's certificate",
+ "long-option": "check-ca",
+ "detail": "Checks the trust anchor's and CA's certificate only. End-entities are not considered."
+ },
+ {
+ "desc": "Print the DANE RR data on a certificate or public key",
+ "requires": "host",
+ "long-option": "tlsa-rr",
+ "detail": "This command prints the DANE RR data needed to enable DANE on a DNS server."
+ },
+ {
+ "long-option": "host",
+ "arg-type": "string",
+ "desc": "Specify the hostname to be used in the DANE RR",
+ "detail": "This command sets the hostname for the DANE RR.",
+ "arg-name": "Hostname"
+ },
+ {
+ "arg-type": "string",
+ "arg-name": "Protocol",
+ "long-option": "proto",
+ "desc": "The protocol set for DANE data (tcp, udp etc.)",
+ "detail": "This command specifies the protocol for the service set in the DANE data."
+ },
+ {
+ "default-value": "443",
+ "long-option": "port",
+ "arg-type": "string",
+ "desc": "The port or service to connect to, for DANE data",
+ "detail": ""
+ },
+ {
+ "aliases": "starttls-proto",
+ "long-option": "app-proto"
+ },
+ {
+ "desc": "The application protocol to be used to obtain the server's certificate (https, ftp, smtp, imap, ldap, xmpp, lmtp, pop3, nntp, sieve, postgres)",
+ "detail": "When the server's certificate isn't provided danetool will connect to the server to obtain the certificate. In that case it is required to know the protocol to talk with the server prior to initiating the TLS handshake.",
+ "arg-type": "string",
+ "long-option": "starttls-proto"
+ },
+ {
+ "long-option": "ca",
+ "desc": "Whether the provided certificate or public key is a Certificate Authority",
+ "detail": "Marks the DANE RR as a CA certificate if specified."
+ },
+ {
+ "detail": "This option forces the generated record to contain the hash of the full X.509 certificate. By default only the hash of the public key is used.",
+ "long-option": "x509",
+ "desc": "Use the hash of the X.509 certificate, rather than the public key"
+ },
+ {
+ "aliases": "domain",
+ "long-option": "local"
+ },
+ {
+ "disable-prefix": "no-",
+ "detail": "DANE distinguishes certificates and public keys offered via the DNSSEC to trusted and local entities. This flag indicates that this is a domain-issued certificate, meaning that there could be no CA involved.",
+ "long-option": "domain",
+ "desc": "The provided certificate or public key is issued by the local domain",
+ "enabled": ""
+ },
+ {
+ "disabled": "",
+ "detail": "This option will use the local DNS server for DNSSEC.\nThis is disabled by default due to many servers not allowing DNSSEC.",
+ "desc": "Use the local DNS server for DNSSEC resolving",
+ "long-option": "local-dns",
+ "disable-prefix": "no-"
+ },
+ {
+ "long-option": "insecure",
+ "detail": "Ignores any DNSSEC signature verification results.",
+ "desc": "Do not verify any DNSSEC signature"
+ },
+ {
+ "disable-prefix": "no-",
+ "detail": "The input files will be assumed to be in DER or RAW format. \nUnlike options that in PEM input would allow multiple input data (e.g. multiple \ncertificates), when reading in DER format a single data structure is read.",
+ "long-option": "inder",
+ "desc": "Use DER format for input certificates and private keys",
+ "disabled": ""
+ },
+ {
+ "aliases": "inder",
+ "long-option": "inraw"
+ },
+ {
+ "desc": "Print the received DANE data in raw format",
+ "detail": "This option will print the received DANE data.",
+ "long-option": "print-raw",
+ "disabled": "",
+ "disable-prefix": "no-"
+ },
+ {
+ "desc": "Suppress several informational messages",
+ "detail": "In that case on the exit code can be used as an indication of verification success",
+ "long-option": "quiet"
+ }
+ ]
+ }
+] \ No newline at end of file
diff --git a/src/danetool.c b/src/danetool.c
index 91b422028d..add5d05a1f 100644
--- a/src/danetool.c
+++ b/src/danetool.c
@@ -48,7 +48,7 @@
#include <minmax.h>
#include <common.h>
-#include "danetool-args.h"
+#include "danetool-options.h"
#include "certtool-common.h"
#include "socket.h"
@@ -154,7 +154,7 @@ static void cmd_parser(int argc, char **argv)
memset(&cinfo, 0, sizeof(cinfo));
- if (HAVE_OPT(INDER) || HAVE_OPT(INRAW))
+ if (HAVE_OPT(INDER))
cinfo.incert_format = GNUTLS_X509_FMT_DER;
else
cinfo.incert_format = GNUTLS_X509_FMT_PEM;
diff --git a/src/gen-getopt.py b/src/gen-getopt.py
new file mode 100644
index 0000000000..d01c095be7
--- /dev/null
+++ b/src/gen-getopt.py
@@ -0,0 +1,654 @@
+#!/usr/bin/python
+# Copyright (C) 2021 Daiki Ueno
+
+# This file is part of GnuTLS.
+
+# GnuTLS 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.
+
+# GnuTLS 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/>.
+
+from typing import Mapping, MutableMapping, MutableSequence, Sequence
+from typing import TextIO, Union
+import io
+import os.path
+import jsonopts
+import sys
+
+INDENT = ' '
+
+
+def get_aliases(options) -> Mapping[str, Sequence[str]]:
+ aliases: MutableMapping[str, MutableSequence[str]] = dict()
+ for option in options:
+ long_opt = option['long-option']
+ key = option.get('aliases')
+ if key:
+ val = aliases.get(key, list())
+ val.append(long_opt)
+ aliases[key] = val
+ return aliases
+
+
+def get_chars(options) -> Mapping[str, Union[str, int]]:
+ chars = dict()
+ chars_counter = 1
+ short_opts: MutableMapping[str, str] = dict()
+ for option in options:
+ long_opt = option['long-option']
+ short_opt = option.get('short-option')
+ # If the short option is already taken, do not register twice
+ if short_opt and short_opt in short_opts:
+ print((f'short option {short_opt} for {long_opt} is already '
+ f'taken by {short_opts[short_opt]}'),
+ file=sys.stderr)
+ short_opt = None
+ if short_opt:
+ chars[long_opt] = short_opt
+ short_opts[short_opt] = long_opt
+ else:
+ chars[long_opt] = chars_counter
+ chars_counter += 1
+ disable_prefix = option.get('disable-prefix')
+ if disable_prefix:
+ chars[f'{disable_prefix}{long_opt}'] = chars_counter
+ chars_counter += 1
+ return chars
+
+
+def mangle(name: str) -> str:
+ return ''.join([c if c in 'abcdefghijklmnopqrstuvwxyz0123456789_' else '_'
+ for c in name.lower()])
+
+
+def format_long_opt(c: Union[str, int], long_opt: str, has_arg: str) -> str:
+ if isinstance(c, str):
+ return f"{INDENT}{{ \"{long_opt}\", {has_arg}, 0, '{c}' }},\n"
+ else:
+ return f'{INDENT}{{ "{long_opt}", {has_arg}, 0, CHAR_MAX + {c} }},\n'
+
+
+def format_switch_case(c: Union[str, int], long_opt: str) -> str:
+ if isinstance(c, str):
+ return f"{INDENT*3}case '{c}':\n"
+ else:
+ return f'{INDENT*3}case CHAR_MAX + {c}: /* --{long_opt} */\n'
+
+
+def gen_c(meta: Mapping[str, str],
+ options: Sequence[Mapping[str, str]],
+ aliases: Mapping[str, Sequence[str]],
+ usage: str,
+ outfile: TextIO):
+ long_opts = io.StringIO()
+ short_opts = list()
+ switch_cases = io.StringIO()
+ enable_statements = io.StringIO()
+ constraint_statements = io.StringIO()
+ has_list_arg = False
+ has_number_arg = False
+
+ chars = get_chars(options)
+
+ prog_name = meta['prog-name']
+ struct_name = f'{mangle(prog_name)}_opts'
+ global_name = f'{mangle(prog_name)}Options'
+
+ switch_cases.write(f"{INDENT*3}case '\\0': /* Long option. */\n")
+ switch_cases.write(f'{INDENT*4}break;\n')
+
+ for option in options:
+ long_opt = option['long-option']
+ arg_type = option.get('arg-type')
+ lower_opt = mangle(long_opt)
+ upper_opt = lower_opt.upper()
+
+ # aliases are handled differently
+ if 'aliases' in option:
+ continue
+
+ if arg_type:
+ if 'arg-optional' in option:
+ has_arg = 'optional_argument'
+ else:
+ has_arg = 'required_argument'
+ else:
+ has_arg = 'no_argument'
+
+ c = chars[long_opt]
+
+ if isinstance(c, str):
+ if arg_type:
+ short_opts.append(c + ':')
+ else:
+ short_opts.append(c)
+
+ long_opts.write(format_long_opt(c, long_opt, has_arg))
+ switch_cases.write(format_switch_case(c, long_opt))
+
+ for alias in aliases.get(long_opt, list()):
+ c = chars[alias]
+ long_opts.write(format_long_opt(c, alias, has_arg))
+ switch_cases.write(format_switch_case(c, alias))
+
+ switch_cases.write(f'{INDENT*4}opts->present.{lower_opt} = true;\n')
+
+ if arg_type:
+ if 'stack-arg' in option:
+ has_list_arg = True
+ switch_cases.write((
+ f'{INDENT*4}append_to_list (&opts->list.{lower_opt}, '
+ f'"{long_opt}", optarg);\n'
+ ))
+ else:
+ switch_cases.write(
+ f'{INDENT*4}opts->arg.{lower_opt} = optarg;\n'
+ )
+ if arg_type == 'number':
+ has_number_arg = True
+ switch_cases.write((
+ f'{INDENT*4}opts->value.{lower_opt} = '
+ 'parse_number(optarg);\n'
+ ))
+ if 'enabled' in option or 'disabled' in option:
+ switch_cases.write(
+ f'{INDENT*4}opts->enabled.{lower_opt} = true;\n'
+ )
+
+ switch_cases.write(f'{INDENT*4}break;\n')
+
+ if 'enabled' in option:
+ enable_statements.write(
+ f'{INDENT}opts->enabled.{lower_opt} = true;\n'
+ )
+ disable_prefix = option.get('disable-prefix')
+ if disable_prefix:
+ disable_opt = f'{disable_prefix}{long_opt}'
+ c = chars[disable_opt]
+ long_opts.write(format_long_opt(c, disable_opt, has_arg))
+ switch_cases.write(format_switch_case(c, disable_opt))
+ switch_cases.write(
+ f'{INDENT*4}opts->present.{lower_opt} = true;\n'
+ )
+ switch_cases.write(
+ f'{INDENT*4}opts->enabled.{lower_opt} = false;\n'
+ )
+ switch_cases.write(f'{INDENT*4}break;\n')
+
+ conflict_opts = option.get('conflicts', '').split()
+ for conflict_opt in conflict_opts:
+ constraint_statements.write(f'''\
+{INDENT}if (HAVE_OPT({upper_opt}) && HAVE_OPT({mangle(conflict_opt).upper()}))
+{INDENT*2}{{
+{INDENT*3}error (EXIT_FAILURE, 0, "the '%s' and '%s' options conflict",
+{INDENT*3} "{long_opt}", "{mangle(conflict_opt)}");
+{INDENT*2}}}
+''')
+ require_opts = option.get('requires', '').split()
+ for require_opt in require_opts:
+ constraint_statements.write(f'''\
+{INDENT}if (HAVE_OPT({upper_opt}) && !HAVE_OPT({mangle(require_opt).upper()}))
+{INDENT*2}{{
+{INDENT*3}error (EXIT_FAILURE, 0, "%s option requires the %s options",
+{INDENT*3} "{long_opt}", "{mangle(require_opt)}");
+{INDENT*2}}}
+''')
+ arg_min = option.get('arg-min')
+ if arg_min:
+ constraint_statements.write(f'''\
+{INDENT}if (HAVE_OPT({upper_opt}) && OPT_VALUE_{upper_opt} < {int(arg_min)})
+{INDENT*2}{{
+{INDENT*3}error (EXIT_FAILURE, 0, "%s option value %d is out of range.",
+{INDENT*3} "{long_opt}", opts->value.{lower_opt});
+{INDENT*2}}}
+''')
+ arg_max = option.get('arg-max')
+ if arg_max:
+ constraint_statements.write(f'''\
+{INDENT}if (HAVE_OPT({upper_opt}) && OPT_VALUE_{upper_opt} > {int(arg_max)})
+{INDENT*2}{{
+{INDENT*3}error (EXIT_FAILURE, 0, "%s option value %d is out of range",
+{INDENT*3} "{long_opt}", opts->value.{lower_opt});
+{INDENT*2}}}
+''')
+
+ long_opts.write(f'{INDENT}{{ 0, 0, 0, 0 }}\n')
+
+ switch_cases.write(f'{INDENT*3}default:\n')
+ switch_cases.write(f'{INDENT*4}usage (stderr, EXIT_FAILURE);\n')
+ switch_cases.write(f'{INDENT*4}break;\n')
+
+ argument = meta.get('argument')
+ if argument:
+ if argument.startswith('[') and argument.endswith(']'):
+ argument = argument[1:-1]
+ argument_statement = ''
+ else:
+ argument_statement = f'''\
+{INDENT}if (optind == argc)
+{INDENT*2}{{
+{INDENT*3}error (EXIT_FAILURE, 0, "Command line arguments required");
+{INDENT*2}}}
+'''
+ else:
+ argument_statement = f'''\
+{INDENT}if (optind < argc)
+{INDENT*2}{{
+{INDENT*3}error (EXIT_FAILURE, 0, "Command line arguments are not allowed.");
+{INDENT*2}}}
+'''
+
+ short_opts_concatenated = ''.join(sorted(short_opts))
+ usage_stringified = '\n'.join([
+ f'{INDENT*2}"{line}\\n"' for line in usage.split('\n')
+ ])
+ brief_version = jsonopts.version(meta, 'v')
+ version = jsonopts.version(meta, 'c')
+ full_version = jsonopts.version(meta, 'n')
+ brief_version_stringified = '\n'.join([
+ f'{INDENT*6}"{line}\\n"' for line in brief_version.split('\n')
+ ])
+ version_stringified = '\n'.join([
+ f'{INDENT*6}"{line}\\n"' for line in version.split('\n')
+ ])
+ full_version_stringified = '\n'.join([
+ f'{INDENT*6}"{line}\\n"' for line in full_version.split('\n')
+ ])
+
+ outfile.write(f'''\
+/* This file is auto-generated from {meta['infile']}; do not edit */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "{meta['header']}"
+#include <errno.h>
+#include <error.h>
+#include <getopt.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+#ifndef _WIN32
+#include <unistd.h>
+#endif /* !_WIN32 */
+#include "xsize.h"
+
+struct {struct_name} {global_name};
+
+''')
+
+ if has_list_arg:
+ outfile.write(f'''\
+static void
+append_to_list (struct {mangle(prog_name)}_list *list,
+ const char *name, const char *arg)
+{{
+{INDENT}const char **tmp;
+{INDENT}size_t new_count = xsum (list->count, 1);
+
+{INDENT}if (size_overflow_p (new_count))
+{INDENT*2}error (EXIT_FAILURE, 0, "too many arguments for %s",
+{INDENT*2} name);
+
+{INDENT}tmp = reallocarray (list->args, new_count, sizeof (char *));
+{INDENT}if (!tmp)
+{INDENT*2}error (EXIT_FAILURE, 0, "unable to allocate memory for %s",
+{INDENT*2} name);
+
+{INDENT}list->args = tmp;
+{INDENT}list->args[list->count] = optarg;
+{INDENT}list->count = new_count;
+}}
+
+''')
+
+ if has_number_arg:
+ outfile.write(f'''\
+static long
+parse_number (const char *arg)
+{{
+{INDENT}char *endptr = NULL;
+{INDENT}errno = 0;
+{INDENT}long result;
+
+{INDENT}if (strncmp (arg, "0x", 2) == 0)
+{INDENT*2}result = strtol (arg + 2, &endptr, 16);
+{INDENT}else if (strncmp (arg, "0", 1) == 0
+{INDENT} && strspn (arg, "012345678") == strlen (optarg))
+{INDENT*2}result = strtol (arg + 1, &endptr, 8);
+{INDENT}else
+{INDENT*2}result = strtol (arg, &endptr, 10);
+
+{INDENT}if (errno != 0 || (endptr && *endptr != '\\0'))
+{INDENT*2}error (EXIT_FAILURE, errno, "'%s' is not a recognizable number.",
+{INDENT*2} arg);
+
+{INDENT}return result;
+}}
+
+''')
+
+ outfile.write(f'''\
+/* Long options. */
+static const struct option long_options[] =
+{{
+{long_opts.getvalue()}
+}};
+
+int
+optionProcess (struct {struct_name} *opts, int argc, char **argv)
+{{
+{INDENT}int opt;
+
+{enable_statements.getvalue().rstrip()}
+{INDENT}while ((opt = getopt_long (argc, argv, "{short_opts_concatenated}",
+{INDENT} long_options, NULL)) != EOF)
+{INDENT*2}switch (opt)
+{INDENT*3}{{
+{switch_cases.getvalue().rstrip()}
+{INDENT*3}}}
+
+{constraint_statements.getvalue().rstrip()}
+{argument_statement}
+
+{INDENT}if (HAVE_OPT(HELP))
+{INDENT*2}{{
+{INDENT*3}USAGE(0);
+{INDENT*2}}}
+
+{INDENT}if (HAVE_OPT(MORE_HELP))
+#ifdef _WIN32
+{INDENT*2}{{
+{INDENT*3}USAGE(0);
+{INDENT*2}}}
+#else /* _WIN32 */
+{INDENT*2}{{
+{INDENT*3}pid_t pid;
+{INDENT*3}int pfds[2];
+
+{INDENT*3}if (pipe (pfds) < 0)
+{INDENT*4}error (EXIT_FAILURE, errno, "pipe");
+
+{INDENT*3}pid = fork ();
+{INDENT*3}if (pid < 0)
+{INDENT*4}error (EXIT_FAILURE, errno, "fork");
+
+{INDENT*3}if (pid == 0)
+{INDENT*4}{{
+{INDENT*5}close (pfds[0]);
+{INDENT*5}dup2 (pfds[1], STDOUT_FILENO);
+{INDENT*5}close (pfds[1]);
+
+{INDENT*5}usage (stdout, 0);
+{INDENT*4}}}
+{INDENT*3}else
+{INDENT*4}{{
+{INDENT*5}const char *args[2];
+{INDENT*5}const char *envvar;
+
+{INDENT*5}close (pfds[1]);
+{INDENT*5}dup2 (pfds[0], STDIN_FILENO);
+{INDENT*5}close (pfds[0]);
+
+{INDENT*5}envvar = secure_getenv ("PAGER");
+{INDENT*5}if (!envvar || *envvar == '\\0')
+{INDENT*6}args[0] = "more";
+{INDENT*5}else
+{INDENT*6}args[0] = envvar;
+
+{INDENT*5}args[1] = NULL;
+
+{INDENT*5}execvp (args[0], (char * const *)args);
+
+{INDENT*5}exit (EXIT_FAILURE);
+{INDENT*4}}}
+{INDENT*2}}}
+#endif /* !_WIN32 */
+
+{INDENT}if (HAVE_OPT(VERSION))
+{INDENT*2}{{
+{INDENT*3}if (!OPT_ARG_VERSION || !strcmp (OPT_ARG_VERSION, "c"))
+{INDENT*4}{{
+{INDENT*5}const char str[] =
+{version_stringified};
+{INDENT*5}fprintf (stdout, "%s", str);
+{INDENT*5}exit(0);
+{INDENT*4}}}
+{INDENT*3}else if (!strcmp (OPT_ARG_VERSION, "v"))
+{INDENT*4}{{
+{INDENT*5}const char str[] =
+{brief_version_stringified};
+{INDENT*5}fprintf (stdout, "%s", str);
+{INDENT*5}exit(0);
+{INDENT*4}}}
+{INDENT*3}else if (!strcmp (OPT_ARG_VERSION, "n"))
+{INDENT*4}{{
+{INDENT*5}const char str[] =
+{full_version_stringified};
+{INDENT*5}fprintf (stdout, "%s", str);
+{INDENT*5}exit(0);
+{INDENT*4}}}
+{INDENT*3}else
+{INDENT*4}{{
+{INDENT*5}error (EXIT_FAILURE, 0,
+{INDENT*5} "version option argument 'a' invalid. Use:\\n"
+{INDENT*5} " 'v' - version only\\n"
+{INDENT*5} " 'c' - version and copyright\\n"
+{INDENT*5} " 'n' - version and full copyright notice");
+{INDENT*4}}}
+{INDENT*2}}}
+
+{INDENT}return optind;
+}}
+
+void
+usage (FILE *out, int status)
+{{
+{INDENT}const char str[] =
+{usage_stringified};
+{INDENT}fprintf (out, "%s", str);
+{INDENT}exit (status);
+}}
+''')
+
+
+def gen_h(meta: Mapping[str, str],
+ options: Sequence[Mapping[str, str]],
+ aliases: Mapping[str, Sequence[str]],
+ outfile: TextIO):
+ struct_members_present = io.StringIO()
+ struct_members_arg = io.StringIO()
+ struct_members_value = io.StringIO()
+ struct_members_enabled = io.StringIO()
+ struct_members_list = io.StringIO()
+ have_opts = io.StringIO()
+ opt_args = io.StringIO()
+ opt_values = io.StringIO()
+ enabled_opts = io.StringIO()
+ stackct_opts = io.StringIO()
+ stacklst_opts = io.StringIO()
+
+ prog_name = meta['prog-name']
+ struct_name = f'{mangle(prog_name)}_opts'
+ global_name = f'{mangle(prog_name)}Options'
+ list_struct_name = f'{mangle(prog_name)}_list'
+
+ for option in options:
+ long_opt = option['long-option']
+ arg_type = option.get('arg-type')
+ lower_opt = mangle(long_opt)
+ upper_opt = lower_opt.upper()
+
+ # aliases are handled differently
+ if 'aliases' in option:
+ continue
+
+ struct_members_present.write(f'{INDENT*2}bool {lower_opt};\n')
+
+ if arg_type:
+ if 'stack-arg' in option:
+ struct_members_list.write(
+ f'{INDENT*2}struct {list_struct_name} {lower_opt};\n'
+ )
+ stackct_opts.write((
+ f'#define STACKCT_OPT_{upper_opt} '
+ f'{global_name}.list.{lower_opt}.count\n'
+ ))
+ stacklst_opts.write((
+ f'#define STACKLST_OPT_{upper_opt} '
+ f'{global_name}.list.{lower_opt}.args\n'
+ ))
+ else:
+ struct_members_arg.write(
+ f'{INDENT*2}const char *{lower_opt};\n'
+ )
+ if arg_type == 'number':
+ struct_members_value.write(f'{INDENT*2}int {lower_opt};\n')
+ opt_values.write((
+ f'#define OPT_VALUE_{upper_opt} '
+ f'{global_name}.value.{lower_opt}\n'
+ ))
+
+ if 'enabled' in option or 'disabled' in option:
+ struct_members_enabled.write(f'{INDENT*2}bool {lower_opt};\n')
+ enabled_opts.write((
+ f'#define ENABLED_OPT_{upper_opt} '
+ f'{global_name}.enabled.{lower_opt}\n'
+ ))
+
+ have_opts.write((
+ f'#define HAVE_OPT_{upper_opt} '
+ f'{global_name}.present.{lower_opt}\n'
+ ))
+ opt_args.write((
+ f'#define OPT_ARG_{upper_opt} '
+ f'{global_name}.arg.{lower_opt}\n'
+ ))
+
+ header_guard = f'{mangle(meta["header"]).upper()}_'
+
+ outfile.write(f'''\
+/* This file is auto-generated from {meta["infile"]}; do not edit */
+#include <stdbool.h>
+#include <stdio.h>
+
+#ifndef {header_guard}
+#define {header_guard} 1
+
+struct {list_struct_name}
+{{
+{INDENT}const char **args;
+{INDENT}unsigned int count;
+}};
+
+struct {struct_name}
+{{
+{INDENT}/* Options present in the command line */
+{INDENT}struct
+{INDENT}{{
+{struct_members_present.getvalue().rstrip()}
+{INDENT}}} present;
+
+{INDENT}/* Option arguments in raw string form */
+{INDENT}struct
+{INDENT}{{
+{struct_members_arg.getvalue().rstrip()}
+{INDENT}}} arg;
+
+{INDENT}/* Option arguments parsed as integer */
+{INDENT}struct
+{INDENT}{{
+{struct_members_value.getvalue().rstrip()}
+{INDENT}}} value;
+
+{INDENT}/* Option arguments parsed as list */
+{INDENT}struct
+{INDENT}{{
+{struct_members_list.getvalue().rstrip()}
+{INDENT}}} list;
+
+{INDENT}/* Option enablement status */
+{INDENT}struct
+{INDENT}{{
+{struct_members_enabled.getvalue().rstrip()}
+{INDENT}}} enabled;
+}};
+
+#define HAVE_OPT(name) HAVE_OPT_ ## name
+#define OPT_ARG(name) OPT_ARG_ ## name
+#define ENABLED_OPT(name) ENABLED_OPT_ ## name
+#define STACKCT_OPT(name) STACKCT_OPT_ ## name
+#define STACKLST_OPT(name) STACKLST_OPT_ ## name
+#define USAGE(status) usage (stdout, (status))
+
+{have_opts.getvalue()}
+{opt_args.getvalue()}
+{opt_values.getvalue()}
+{enabled_opts.getvalue()}
+{stackct_opts.getvalue()}
+{stacklst_opts.getvalue()}
+
+extern struct {struct_name} {global_name};
+int optionProcess(struct {struct_name} *opts, int argc, char **argv);
+void usage (FILE *out, int status);
+
+#endif /* {header_guard} */
+''')
+
+
+def gen(infile: TextIO, meta: Mapping[str, str], c: TextIO, h: TextIO):
+ sections = [jsonopts.Section.from_json(section)
+ for section in json.load(args.json)]
+ sections.append(jsonopts.Section.default())
+ meta = {
+ **meta,
+ **sections[0].meta,
+ **{
+ 'header': os.path.basename(h.name),
+ 'infile': os.path.basename(infile.name)
+ }
+ }
+ options = [option for section in sections for option in section.options]
+ aliases = get_aliases(options)
+ usage = jsonopts.usage(meta, sections)
+ gen_c(meta, options, aliases, usage, c)
+ gen_h(meta, options, aliases, h)
+
+
+if __name__ == '__main__':
+ import argparse
+ import json
+
+ parser = argparse.ArgumentParser(description='generate getopt wrapper')
+ parser.add_argument('json', type=argparse.FileType('r'))
+ parser.add_argument('c', type=argparse.FileType('w'))
+ parser.add_argument('h', type=argparse.FileType('w'))
+ parser.add_argument('--bug-email', help='bug report email address')
+ parser.add_argument('--copyright-year', help='copyright year')
+ parser.add_argument('--copyright-holder', help='copyright holder')
+ parser.add_argument('--license', help='license')
+ parser.add_argument('--version', help='version')
+
+ args = parser.parse_args()
+ meta = dict()
+ if args.bug_email:
+ meta['bug-email'] = args.bug_email
+ if args.copyright_year:
+ meta['copyright-year'] = args.copyright_year
+ if args.copyright_holder:
+ meta['copyright-holder'] = args.copyright_holder
+ if args.license:
+ meta['license'] = args.license
+ if args.version:
+ meta['version'] = args.version
+
+ gen(args.json, meta, args.c, args.h)
diff --git a/src/gnutls-cli-debug-options.json b/src/gnutls-cli-debug-options.json
new file mode 100644
index 0000000000..5c286577f8
--- /dev/null
+++ b/src/gnutls-cli-debug-options.json
@@ -0,0 +1,53 @@
+[
+ {
+ "meta": {
+ "argument": "[hostname]",
+ "reorder-args": "",
+ "explain": "",
+ "prog-title": "GnuTLS debug client",
+ "short-usage": "Usage: gnutls-cli-debug [options] hostname\ngnutls-cli --help for usage instructions.\n",
+ "detail": "TLS debug client. It sets up multiple TLS connections to \na server and queries its capabilities. It was created to assist in debugging \nGnuTLS, but it might be useful to extract a TLS server's capabilities.\nIt connects to a TLS server, performs tests and print the server's \ncapabilities. If called with the `-V' parameter more checks will be performed.\nCan be used to check for servers with special needs or bugs.",
+ "prog-desc": "Simple client program to check TLS server capabilities.",
+ "prog-name": "gnutls-cli-debug",
+ "desc": ""
+ },
+ "options": [
+ {
+ "short-option": "d",
+ "detail": "Specifies the debug level.",
+ "arg-max": " 9999",
+ "arg-type": "number",
+ "arg-min": "0 ",
+ "long-option": "debug",
+ "desc": "Enable debugging"
+ },
+ {
+ "max": "NOLIMIT",
+ "disabled": "",
+ "desc": "More verbose output",
+ "short-option": "V",
+ "long-option": "verbose",
+ "detail": ""
+ },
+ {
+ "short-option": "p",
+ "long-option": "port",
+ "arg-min": "0 ",
+ "desc": "The port to connect to",
+ "arg-max": " 65536",
+ "arg-type": "number",
+ "detail": ""
+ },
+ {
+ "aliases": "starttls-proto",
+ "long-option": "app-proto"
+ },
+ {
+ "detail": "Specify the application layer protocol for STARTTLS. If the protocol is supported, gnutls-cli will proceed to the TLS negotiation.",
+ "arg-type": "string",
+ "desc": "The application protocol to be used to obtain the server's certificate (https, ftp, smtp, imap, ldap, xmpp, lmtp, pop3, nntp, sieve, postgres)",
+ "long-option": "starttls-proto"
+ }
+ ]
+ }
+] \ No newline at end of file
diff --git a/src/gnutls-cli-options.json b/src/gnutls-cli-options.json
new file mode 100644
index 0000000000..0777e6b198
--- /dev/null
+++ b/src/gnutls-cli-options.json
@@ -0,0 +1,421 @@
+[
+ {
+ "meta": {
+ "detail": "Simple client program to set up a TLS connection to some other computer. \nIt sets up a TLS connection and forwards data from the standard input to the secured socket and vice versa.",
+ "prog-desc": "Simple client program to set up a TLS connection.",
+ "explain": "",
+ "short-usage": "Usage: gnutls-cli [options] hostname\ngnutls-cli --help for usage instructions.\n",
+ "reorder-args": "",
+ "prog-name": "gnutls-cli",
+ "desc": "",
+ "argument": "[hostname]",
+ "prog-title": "GnuTLS client"
+ },
+ "options": [
+ {
+ "short-option": "d",
+ "desc": "Enable debugging",
+ "arg-type": "number",
+ "arg-min": "0 ",
+ "arg-max": " 9999",
+ "detail": "Specifies the debug level.",
+ "long-option": "debug"
+ },
+ {
+ "disabled": "",
+ "long-option": "verbose",
+ "detail": "",
+ "desc": "More verbose output",
+ "short-option": "V",
+ "max": "NOLIMIT"
+ },
+ {
+ "detail": "This option will, in addition to certificate authentication, perform authentication\nbased on previously seen public keys, a model similar to SSH authentication. Note that when tofu \nis specified (PKI) and DANE authentication will become advisory to assist the public key acceptance\nprocess.",
+ "disabled": "",
+ "desc": "Enable trust on first use authentication",
+ "disable-prefix": "no-",
+ "long-option": "tofu"
+ },
+ {
+ "detail": "This option will perform authentication as with option --tofu; however, no questions shall be asked whatsoever, neither to accept an unknown certificate nor a changed one.",
+ "desc": "Fail to connect if a certificate is unknown or a known certificate has changed",
+ "long-option": "strict-tofu",
+ "disabled": "",
+ "disable-prefix": "no-"
+ },
+ {
+ "detail": "This option will, in addition to certificate authentication using \nthe trusted CAs, verify the server certificates using on the DANE information\navailable via DNSSEC.",
+ "desc": "Enable DANE certificate verification (DNSSEC)",
+ "disabled": "",
+ "disable-prefix": "no-",
+ "long-option": "dane"
+ },
+ {
+ "disable-prefix": "no-",
+ "detail": "This option will use the local DNS server for DNSSEC.\nThis is disabled by default due to many servers not allowing DNSSEC.",
+ "desc": "Use the local DNS server for DNSSEC resolving",
+ "long-option": "local-dns",
+ "disabled": ""
+ },
+ {
+ "desc": "Enable CA certificate verification",
+ "detail": "This option can be used to enable or disable CA certificate verification. It is to be used with the --dane or --tofu options.",
+ "disable-prefix": "no-",
+ "enabled": "",
+ "long-option": "ca-verification"
+ },
+ {
+ "desc": "Enable OCSP certificate verification",
+ "detail": "This option will enable verification of the peer's certificate using ocsp",
+ "disable-prefix": "no-",
+ "long-option": "ocsp",
+ "disabled": ""
+ },
+ {
+ "detail": "Connect, establish a session, reconnect and resume.",
+ "desc": "Establish a session and resume",
+ "short-option": "r",
+ "long-option": "resume"
+ },
+ {
+ "desc": "Send early data on resumption from the specified file",
+ "detail": "",
+ "arg-type": "string",
+ "long-option": "earlydata"
+ },
+ {
+ "short-option": "e",
+ "desc": "Establish a session and rehandshake",
+ "long-option": "rehandshake",
+ "detail": "Connect, establish a session and rehandshake immediately."
+ },
+ {
+ "desc": "Server's hostname for server name indication extension",
+ "arg-type": "string",
+ "detail": "Set explicitly the server name used in the TLS server name indication extension. That is useful when testing with servers setup on different DNS name than the intended. If not specified, the provided hostname is used. Even with this option server certificate verification still uses the hostname passed on the main commandline. Use --verify-hostname to change this.",
+ "long-option": "sni-hostname"
+ },
+ {
+ "long-option": "verify-hostname",
+ "desc": "Server's hostname to use for validation",
+ "detail": "Set explicitly the server name to be used when validating the server's certificate.",
+ "arg-type": "string"
+ },
+ {
+ "long-option": "starttls",
+ "desc": "Connect, establish a plain session and start TLS",
+ "detail": "The TLS session will be initiated when EOF or a SIGALRM is received.",
+ "short-option": "s"
+ },
+ {
+ "aliases": "starttls-proto",
+ "long-option": "app-proto"
+ },
+ {
+ "conflicts": "starttls",
+ "arg-type": "string",
+ "desc": "The application protocol to be used to obtain the server's certificate (https, ftp, smtp, imap, ldap, xmpp, lmtp, pop3, nntp, sieve, postgres)",
+ "long-option": "starttls-proto",
+ "detail": "Specify the application layer protocol for STARTTLS. If the protocol is supported, gnutls-cli will proceed to the TLS negotiation."
+ },
+ {
+ "short-option": "u",
+ "desc": "Use DTLS (datagram TLS) over UDP",
+ "long-option": "udp",
+ "detail": ""
+ },
+ {
+ "arg-type": "number",
+ "detail": "",
+ "arg-max": "17000",
+ "long-option": "mtu",
+ "desc": "Set MTU for datagram TLS",
+ "arg-min": "0"
+ },
+ {
+ "detail": "",
+ "long-option": "crlf",
+ "desc": "Send CR LF instead of LF"
+ },
+ {
+ "detail": "",
+ "long-option": "fastopen",
+ "desc": "Enable TCP Fast Open"
+ },
+ {
+ "desc": "Use DER format for certificates to read from",
+ "long-option": "x509fmtder",
+ "detail": ""
+ },
+ {
+ "desc": "Print peer's certificate in PEM format",
+ "long-option": "print-cert",
+ "detail": ""
+ },
+ {
+ "desc": "Save the peer's certificate chain in the specified file in PEM format",
+ "long-option": "save-cert",
+ "detail": "",
+ "arg-type": "string"
+ },
+ {
+ "detail": "",
+ "conflicts": "save-ocsp-multi",
+ "long-option": "save-ocsp",
+ "desc": "Save the peer's OCSP status response in the provided file",
+ "arg-type": "string"
+ },
+ {
+ "arg-type": "string",
+ "detail": "The file will contain a list of PEM encoded OCSP status responses if any were provided by the peer, starting with the one for the peer's server certificate.",
+ "long-option": "save-ocsp-multi",
+ "desc": "Save all OCSP responses provided by the peer in this file",
+ "conflicts": "save-ocsp"
+ },
+ {
+ "long-option": "save-server-trace",
+ "desc": "Save the server-side TLS message trace in the provided file",
+ "detail": "",
+ "arg-type": "string"
+ },
+ {
+ "arg-type": "string",
+ "desc": "Save the client-side TLS message trace in the provided file",
+ "detail": "",
+ "long-option": "save-client-trace"
+ },
+ {
+ "long-option": "dh-bits",
+ "arg-type": "number",
+ "detail": "This option sets the minimum number of bits allowed for a Diffie-Hellman key exchange. You may want to lower the default value if the peer sends a weak prime and you get an connection error with unacceptable prime.",
+ "desc": "The minimum number of bits allowed for DH"
+ },
+ {
+ "arg-type": "string",
+ "long-option": "priority",
+ "desc": "Priorities string",
+ "detail": "TLS algorithms and protocols to enable. You can\nuse predefined sets of ciphersuites such as PERFORMANCE,\nNORMAL, PFS, SECURE128, SECURE256. The default is NORMAL.\n\nCheck the GnuTLS manual on section ``Priority strings'' for more\ninformation on the allowed keywords"
+ },
+ {
+ "detail": "",
+ "desc": "Certificate file or PKCS #11 URL to use",
+ "arg-type": "string",
+ "long-option": "x509cafile"
+ },
+ {
+ "arg-type": "file",
+ "file-exists": "yes",
+ "long-option": "x509crlfile",
+ "detail": "",
+ "desc": "CRL file to use"
+ },
+ {
+ "detail": "",
+ "arg-type": "string",
+ "desc": "X.509 key file or PKCS #11 URL to use",
+ "long-option": "x509keyfile"
+ },
+ {
+ "arg-type": "string",
+ "requires": "x509keyfile",
+ "long-option": "x509certfile",
+ "desc": "X.509 Certificate file or PKCS #11 URL to use",
+ "detail": ""
+ },
+ {
+ "desc": "Private key file (PKCS #8 or PKCS #12) or PKCS #11 URL to use",
+ "arg-type": "string",
+ "long-option": "rawpkkeyfile",
+ "detail": "In order to instruct the application to negotiate raw public keys one\nmust enable the respective certificate types via the priority strings (i.e. CTYPE-CLI-*\nand CTYPE-SRV-* flags).\n\nCheck the GnuTLS manual on section ``Priority strings'' for more\ninformation on how to set certificate types."
+ },
+ {
+ "requires": "rawpkkeyfile",
+ "detail": "In order to instruct the application to negotiate raw public keys one\nmust enable the respective certificate types via the priority strings (i.e. CTYPE-CLI-*\nand CTYPE-SRV-* flags).\n\nCheck the GnuTLS manual on section ``Priority strings'' for more\ninformation on how to set certificate types.",
+ "desc": "Raw public-key file to use",
+ "long-option": "rawpkfile",
+ "arg-type": "string"
+ },
+ {
+ "desc": "SRP username to use",
+ "detail": "",
+ "arg-type": "string",
+ "long-option": "srpusername"
+ },
+ {
+ "arg-type": "string",
+ "detail": "",
+ "desc": "SRP password to use",
+ "long-option": "srppasswd"
+ },
+ {
+ "desc": "PSK username to use",
+ "arg-type": "string",
+ "detail": "",
+ "long-option": "pskusername"
+ },
+ {
+ "arg-type": "string",
+ "long-option": "pskkey",
+ "desc": "PSK key (in hex) to use",
+ "detail": ""
+ },
+ {
+ "arg-type": "string",
+ "short-option": "p",
+ "detail": "",
+ "desc": "The port or service to connect to",
+ "long-option": "port"
+ },
+ {
+ "long-option": "insecure",
+ "detail": "",
+ "desc": "Don't abort program if server certificate can't be validated"
+ },
+ {
+ "desc": "Allow broken algorithms, such as MD5 for certificate verification",
+ "detail": "",
+ "long-option": "verify-allow-broken"
+ },
+ {
+ "desc": "Use length-hiding padding to prevent traffic analysis",
+ "deprecated": "",
+ "long-option": "ranges",
+ "detail": "When possible (e.g., when using CBC ciphersuites), use length-hiding padding to prevent traffic analysis."
+ },
+ {
+ "long-option": "benchmark-ciphers",
+ "detail": "By default the benchmarked ciphers will utilize any capabilities of the local CPU to improve performance. To test against the raw software implementation set the environment variable GNUTLS_CPUID_OVERRIDE to 0x1.",
+ "desc": "Benchmark individual ciphers"
+ },
+ {
+ "long-option": "benchmark-tls-kx",
+ "detail": "",
+ "desc": "Benchmark TLS key exchange methods"
+ },
+ {
+ "long-option": "benchmark-tls-ciphers",
+ "desc": "Benchmark TLS ciphers",
+ "detail": "By default the benchmarked ciphers will utilize any capabilities of the local CPU to improve performance. To test against the raw software implementation set the environment variable GNUTLS_CPUID_OVERRIDE to 0x1."
+ },
+ {
+ "long-option": "list",
+ "desc": "Print a list of the supported algorithms and modes",
+ "short-option": "l",
+ "detail": "Print a list of the supported algorithms and modes. If a priority string is given then only the enabled ciphersuites are shown.",
+ "conflicts": "port"
+ },
+ {
+ "desc": "Print a list of the supported priority strings",
+ "detail": "Print a list of the supported priority strings. The ciphersuites corresponding to each priority string can be examined using -l -p.",
+ "long-option": "priority-list"
+ },
+ {
+ "detail": "Disable the request of receiving of session tickets under TLS1.2 or earlier",
+ "long-option": "noticket",
+ "desc": "Don't allow session tickets"
+ },
+ {
+ "arg-type": "string",
+ "long-option": "srtp-profiles",
+ "desc": "Offer SRTP profiles",
+ "detail": ""
+ },
+ {
+ "arg-type": "string",
+ "stack-arg": "",
+ "desc": "Application layer protocol",
+ "long-option": "alpn",
+ "detail": "This option will set and enable the Application Layer Protocol Negotiation (ALPN) in the TLS protocol.",
+ "max": "NOLIMIT"
+ },
+ {
+ "detail": "",
+ "long-option": "heartbeat",
+ "short-option": "b",
+ "desc": "Activate heartbeat support"
+ },
+ {
+ "arg-max": "4096",
+ "arg-min": "0",
+ "long-option": "recordsize",
+ "detail": "",
+ "arg-type": "number",
+ "desc": "The maximum record size to advertise"
+ },
+ {
+ "detail": "",
+ "long-option": "disable-sni",
+ "desc": "Do not send a Server Name Indication (SNI)"
+ },
+ {
+ "desc": "Disable all the TLS extensions",
+ "detail": "This option disables all TLS extensions. Deprecated option. Use the priority string.",
+ "long-option": "disable-extensions",
+ "deprecated": ""
+ },
+ {
+ "detail": "This option switches the default mode of sending multiple\nkey shares, to send a single one (the top one).",
+ "desc": "Send a single key share under TLS1.3",
+ "long-option": "single-key-share"
+ },
+ {
+ "detail": "This option enables post-handshake authentication when under TLS1.3.",
+ "long-option": "post-handshake-auth",
+ "desc": "Enable post-handshake authentication under TLS1.3"
+ },
+ {
+ "desc": "Inline commands of the form ^<cmd>^",
+ "long-option": "inline-commands",
+ "detail": "Enable inline commands of the form ^<cmd>^. The inline commands are expected to be in a line by themselves. The available commands are: resume, rekey1 (local rekey), rekey (rekey on both peers) and renegotiate."
+ },
+ {
+ "long-option": "inline-commands-prefix",
+ "arg-type": "string",
+ "detail": "Change the default delimiter (^) used for inline commands. The delimiter is expected to be a single US-ASCII character (octets 0 - 127). This option is only relevant if inline commands are enabled via the inline-commands option",
+ "desc": "Change the default delimiter for inline commands."
+ },
+ {
+ "long-option": "provider",
+ "file-exists": "yes",
+ "arg-type": "file",
+ "desc": "Specify the PKCS #11 provider library",
+ "detail": "This will override the default options in /etc/gnutls/pkcs11.conf"
+ },
+ {
+ "detail": "",
+ "long-option": "fips140-mode",
+ "desc": "Reports the status of the FIPS140-2 mode in gnutls library"
+ },
+ {
+ "desc": "Redirect informational messages to a specific file.",
+ "arg-type": "string",
+ "long-option": "logfile",
+ "detail": "Redirect informational messages to a specific file. The file may be /dev/null also to make the gnutls client quiet to use it in piped server connections where only the server communication may appear on stdout."
+ },
+ {
+ "detail": "",
+ "desc": "Label used for exporting keying material",
+ "arg-type": "string",
+ "long-option": "keymatexport"
+ },
+ {
+ "detail": "",
+ "arg-type": "number",
+ "long-option": "keymatexportsize",
+ "desc": "Size of the exported keying material"
+ },
+ {
+ "long-option": "waitresumption",
+ "desc": "Block waiting for the resumption data under TLS1.3",
+ "detail": "This option makes the client to block waiting for the resumption data under TLS1.3. The option has effect only when --resume is provided."
+ },
+ {
+ "long-option": "ca-auto-retrieve",
+ "disabled": "",
+ "disable-prefix": "no-",
+ "desc": "Enable automatic retrieval of missing CA certificates",
+ "detail": "This option enables the client to automatically retrieve the missing intermediate CA certificates in the certificate chain, based on the Authority Information Access (AIA) extension."
+ }
+ ]
+ }
+] \ No newline at end of file
diff --git a/src/gnutls-serv-options.json b/src/gnutls-serv-options.json
new file mode 100644
index 0000000000..ef074385b0
--- /dev/null
+++ b/src/gnutls-serv-options.json
@@ -0,0 +1,332 @@
+[
+ {
+ "meta": {
+ "desc": "",
+ "prog-desc": "Simple server program to act as an HTTPS or TLS echo service.",
+ "explain": "",
+ "short-usage": "Usage: gnutls-serv [options]\ngnutls-serv --help for usage instructions.\n",
+ "detail": "Server program that listens to incoming TLS connections.",
+ "prog-name": "gnutls-serv",
+ "prog-title": "GnuTLS server"
+ },
+ "options": [
+ {
+ "arg-type": "number",
+ "arg-max": " 9999",
+ "arg-min": "0 ",
+ "short-option": "d",
+ "detail": "Specifies the debug level.",
+ "long-option": "debug",
+ "desc": "Enable debugging"
+ },
+ {
+ "arg-type": "string",
+ "detail": "Server name of type host_name that the server will recognise as its own. If the server receives client hello with different name, it will send a warning-level unrecognized_name alert.",
+ "desc": "Server's hostname for server name extension",
+ "long-option": "sni-hostname"
+ },
+ {
+ "long-option": "sni-hostname-fatal",
+ "desc": "Send fatal alert on sni-hostname mismatch",
+ "detail": ""
+ },
+ {
+ "max": "NOLIMIT",
+ "detail": "Specify the (textual) ALPN protocol for the server to use.",
+ "desc": "Specify ALPN protocol to be enabled by the server",
+ "long-option": "alpn",
+ "arg-type": "string",
+ "stack-arg": ""
+ },
+ {
+ "detail": "",
+ "long-option": "alpn-fatal",
+ "desc": "Send fatal alert on non-matching ALPN name"
+ },
+ {
+ "desc": "Don't accept session tickets",
+ "detail": "",
+ "long-option": "noticket"
+ },
+ {
+ "detail": "",
+ "long-option": "earlydata",
+ "desc": "Accept early data"
+ },
+ {
+ "arg-type": "number",
+ "desc": "The maximum early data size to accept",
+ "detail": "",
+ "arg-max": "",
+ "long-option": "maxearlydata",
+ "arg-min": "1"
+ },
+ {
+ "long-option": "nocookie",
+ "detail": "",
+ "desc": "Don't require cookie on DTLS sessions"
+ },
+ {
+ "detail": "",
+ "long-option": "generate",
+ "short-option": "g",
+ "desc": "Generate Diffie-Hellman parameters"
+ },
+ {
+ "short-option": "q",
+ "desc": "Suppress some messages",
+ "long-option": "quiet",
+ "detail": ""
+ },
+ {
+ "long-option": "nodb",
+ "desc": "Do not use a resumption database",
+ "detail": ""
+ },
+ {
+ "desc": "Act as an HTTP server",
+ "long-option": "http",
+ "detail": ""
+ },
+ {
+ "desc": "Act as an Echo server",
+ "detail": "",
+ "long-option": "echo"
+ },
+ {
+ "long-option": "crlf",
+ "desc": "Do not replace CRLF by LF in Echo server mode",
+ "detail": ""
+ },
+ {
+ "desc": "Use DTLS (datagram TLS) over UDP",
+ "short-option": "u",
+ "long-option": "udp",
+ "detail": ""
+ },
+ {
+ "arg-type": "number",
+ "desc": "Set MTU for datagram TLS",
+ "arg-min": "0",
+ "detail": "",
+ "arg-max": "17000",
+ "long-option": "mtu"
+ },
+ {
+ "detail": "",
+ "long-option": "srtp-profiles",
+ "desc": "Offer SRTP profiles",
+ "arg-type": "string"
+ },
+ {
+ "desc": "Do not request a client certificate",
+ "short-option": "a",
+ "conflicts": "require-client-cert",
+ "detail": "",
+ "long-option": "disable-client-cert"
+ },
+ {
+ "disabled": "",
+ "detail": "This option before 3.6.0 used to imply --verify-client-cert.\nSince 3.6.0 it will no longer verify the certificate by default.",
+ "long-option": "require-client-cert",
+ "desc": "Require a client certificate",
+ "short-option": "r"
+ },
+ {
+ "disabled": "",
+ "desc": "If a client certificate is sent then verify it.",
+ "detail": "Do not require, but if a client certificate is sent then verify it and close the connection if invalid.",
+ "long-option": "verify-client-cert"
+ },
+ {
+ "long-option": "heartbeat",
+ "desc": "Activate heartbeat support",
+ "detail": "Regularly ping client via heartbeat extension messages",
+ "short-option": "b"
+ },
+ {
+ "desc": "Use DER format for certificates to read from",
+ "detail": "",
+ "long-option": "x509fmtder"
+ },
+ {
+ "detail": "TLS algorithms and protocols to enable. You can\nuse predefined sets of ciphersuites such as PERFORMANCE,\nNORMAL, SECURE128, SECURE256. The default is NORMAL.\n\nCheck the GnuTLS manual on section ``Priority strings'' for more\ninformation on allowed keywords",
+ "arg-type": "string",
+ "long-option": "priority",
+ "desc": "Priorities string"
+ },
+ {
+ "detail": "",
+ "long-option": "dhparams",
+ "arg-type": "file",
+ "file-exists": "yes",
+ "desc": "DH params file to use"
+ },
+ {
+ "arg-type": "string",
+ "desc": "Certificate file or PKCS #11 URL to use",
+ "detail": "",
+ "long-option": "x509cafile"
+ },
+ {
+ "desc": "CRL file to use",
+ "detail": "",
+ "arg-type": "file",
+ "file-exists": "yes",
+ "long-option": "x509crlfile"
+ },
+ {
+ "detail": "",
+ "deprecated": "",
+ "long-option": "pgpkeyfile",
+ "file-exists": "yes",
+ "desc": "PGP Key file to use",
+ "arg-type": "file"
+ },
+ {
+ "stack-arg": "",
+ "max": "NOLIMIT",
+ "long-option": "x509keyfile",
+ "detail": "Specify the private key file or URI to use; it must correspond to\nthe certificate specified in --x509certfile. Multiple keys and certificates\ncan be specified with this option and in that case each occurrence of keyfile\nmust be followed by the corresponding x509certfile or vice-versa.",
+ "desc": "X.509 key file or PKCS #11 URL to use",
+ "arg-type": "string"
+ },
+ {
+ "detail": "Specify the certificate file or URI to use; it must correspond to\nthe key specified in --x509keyfile. Multiple keys and certificates\ncan be specified with this option and in that case each occurrence of keyfile\nmust be followed by the corresponding x509certfile or vice-versa.",
+ "arg-type": "string",
+ "stack-arg": "",
+ "max": "NOLIMIT",
+ "long-option": "x509certfile",
+ "desc": "X.509 Certificate file or PKCS #11 URL to use"
+ },
+ {
+ "aliases": "x509keyfile",
+ "long-option": "x509dsakeyfile",
+ "desc": "Alternative X.509 key file or PKCS #11 URL to use",
+ "deprecated": ""
+ },
+ {
+ "long-option": "x509dsacertfile",
+ "desc": "Alternative X.509 Certificate file or PKCS #11 URL to use",
+ "deprecated": "",
+ "aliases": "x509certfile"
+ },
+ {
+ "deprecated": "",
+ "long-option": "x509ecckeyfile",
+ "aliases": "x509keyfile",
+ "desc": "Alternative X.509 key file or PKCS #11 URL to use"
+ },
+ {
+ "desc": "Alternative X.509 Certificate file or PKCS #11 URL to use",
+ "aliases": "x509certfile",
+ "deprecated": "",
+ "long-option": "x509ecccertfile"
+ },
+ {
+ "stack-arg": "",
+ "long-option": "rawpkkeyfile",
+ "max": "NOLIMIT",
+ "desc": "Private key file (PKCS #8 or PKCS #12) or PKCS #11 URL to use",
+ "arg-type": "string",
+ "detail": "Specify the private key file or URI to use; it must correspond to\nthe raw public-key specified in --rawpkfile. Multiple key pairs\ncan be specified with this option and in that case each occurrence of keyfile\nmust be followed by the corresponding rawpkfile or vice-versa.\n\nIn order to instruct the application to negotiate raw public keys one\nmust enable the respective certificate types via the priority strings (i.e. CTYPE-CLI-*\nand CTYPE-SRV-* flags).\n\nCheck the GnuTLS manual on section ``Priority strings'' for more\ninformation on how to set certificate types."
+ },
+ {
+ "detail": "Specify the raw public-key file to use; it must correspond to\nthe private key specified in --rawpkkeyfile. Multiple key pairs\ncan be specified with this option and in that case each occurrence of keyfile\nmust be followed by the corresponding rawpkfile or vice-versa.\n\nIn order to instruct the application to negotiate raw public keys one\nmust enable the respective certificate types via the priority strings (i.e. CTYPE-CLI-*\nand CTYPE-SRV-* flags).\n\nCheck the GnuTLS manual on section ``Priority strings'' for more\ninformation on how to set certificate types.",
+ "requires": "rawpkkeyfile",
+ "desc": "Raw public-key file to use",
+ "stack-arg": "",
+ "max": "NOLIMIT",
+ "long-option": "rawpkfile",
+ "arg-type": "string"
+ },
+ {
+ "detail": "",
+ "desc": "SRP password file to use",
+ "long-option": "srppasswd",
+ "file-exists": "yes",
+ "arg-type": "file"
+ },
+ {
+ "desc": "SRP password configuration file to use",
+ "long-option": "srppasswdconf",
+ "file-exists": "yes",
+ "arg-type": "file",
+ "detail": ""
+ },
+ {
+ "detail": "",
+ "file-exists": "yes",
+ "desc": "PSK password file to use",
+ "arg-type": "file",
+ "long-option": "pskpasswd"
+ },
+ {
+ "arg-type": "string",
+ "desc": "PSK identity hint to use",
+ "detail": "",
+ "long-option": "pskhint"
+ },
+ {
+ "desc": "The OCSP response to send to client",
+ "max": "NOLIMIT",
+ "detail": "If the client requested an OCSP response, return data from this file to the client.",
+ "long-option": "ocsp-response",
+ "stack-arg": "",
+ "arg-type": "string"
+ },
+ {
+ "long-option": "ignore-ocsp-response-errors",
+ "desc": "Ignore any errors when setting the OCSP response",
+ "detail": "That option instructs gnutls to not attempt to match the provided OCSP responses with the certificates."
+ },
+ {
+ "desc": "The port to connect to",
+ "detail": "",
+ "arg-type": "number",
+ "short-option": "p",
+ "long-option": "port"
+ },
+ {
+ "desc": "Print a list of the supported algorithms and modes",
+ "detail": "Print a list of the supported algorithms and modes. If a priority string is given then only the enabled ciphersuites are shown.",
+ "short-option": "l",
+ "long-option": "list"
+ },
+ {
+ "desc": "Specify the PKCS #11 provider library",
+ "file-exists": "yes",
+ "arg-type": "file",
+ "detail": "This will override the default options in /etc/gnutls/pkcs11.conf",
+ "long-option": "provider"
+ },
+ {
+ "arg-type": "string",
+ "long-option": "keymatexport",
+ "detail": "",
+ "desc": "Label used for exporting keying material"
+ },
+ {
+ "desc": "Size of the exported keying material",
+ "long-option": "keymatexportsize",
+ "arg-type": "number",
+ "detail": ""
+ },
+ {
+ "desc": "The maximum record size to advertise",
+ "arg-max": "16384",
+ "arg-type": "number",
+ "detail": "",
+ "long-option": "recordsize",
+ "arg-min": "0"
+ },
+ {
+ "detail": "",
+ "arg-type": "file",
+ "long-option": "httpdata",
+ "file-exists": "yes",
+ "desc": "The data used as HTTP response"
+ }
+ ]
+ }
+] \ No newline at end of file
diff --git a/src/libopts/COPYING.gplv3 b/src/libopts/COPYING.gplv3
deleted file mode 100644
index 67532741f9..0000000000
--- a/src/libopts/COPYING.gplv3
+++ /dev/null
@@ -1,674 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 1992-2015 by Bruce Korb - all rights reserved
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) by Bruce Korb - all rights reserved
-
- 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/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- <program> Copyright (C) by Bruce Korb - all rights reserved
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-<https://www.gnu.org/licenses/>.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-<https://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/src/libopts/COPYING.lgplv3 b/src/libopts/COPYING.lgplv3
deleted file mode 100644
index b6db23288f..0000000000
--- a/src/libopts/COPYING.lgplv3
+++ /dev/null
@@ -1,165 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 1992-2015 by Bruce Korb - all rights reserved
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/src/libopts/COPYING.mbsd b/src/libopts/COPYING.mbsd
deleted file mode 100644
index 74948befa5..0000000000
--- a/src/libopts/COPYING.mbsd
+++ /dev/null
@@ -1,27 +0,0 @@
-Copyright (C) 1992-2015 by Bruce Korb - all rights reserved
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
-
- 3. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior
- written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
-IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
diff --git a/src/libopts/MakeDefs.inc b/src/libopts/MakeDefs.inc
deleted file mode 100644
index e69de29bb2..0000000000
--- a/src/libopts/MakeDefs.inc
+++ /dev/null
diff --git a/src/libopts/Makefile.am b/src/libopts/Makefile.am
deleted file mode 100644
index 1c46ca3d98..0000000000
--- a/src/libopts/Makefile.am
+++ /dev/null
@@ -1,57 +0,0 @@
-## LIBOPTS Makefile
-MAINTAINERCLEANFILES = Makefile.in
-
-noinst_LTLIBRARIES = libopts.la
-libopts_la_SOURCES = libopts.c
-libopts_la_CPPFLAGS = -I$(top_builddir) -I$(srcdir)
-libopts_la_LIBADD = $(LTLIBINTL)
-EXTRA_DIST =
-BUILT_SOURCES =
-MOSTLYCLEANFILES =
-
-libopts.c: $(BUILT_SOURCES)
- @: do-nothing rule to avoid default SCCS get
-
-
-# Makefile fragment from gnulib-s stdnoreturn module:
-#
-_NORETURN_H=$(srcdir)/compat/_Noreturn.h
-EXTRA_DIST += $(srcdir)/compat/_Noreturn.h
-BUILT_SOURCES += $(STDNORETURN_H)
-if GL_GENERATE_STDNORETURN_H
-stdnoreturn.h: stdnoreturn.in.h $(top_builddir)/config.status $(_NORETURN_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e '/definition of _Noreturn/r $(_NORETURN_H)' \
- < $(srcdir)/stdnoreturn.in.h; \
- } > $@-t && \
- mv $@-t $@
-else
-stdnoreturn.h: $(top_builddir)/config.status
- rm -f $@
-endif
-MOSTLYCLEANFILES += stdnoreturn.h stdnoreturn.h-t
-EXTRA_DIST += stdnoreturn.in.h
-
-EXTRA_DIST += \
- COPYING.gplv3 COPYING.lgplv3 COPYING.mbsd \
- MakeDefs.inc README ag-char-map.h \
- alias.c ao-strs.c ao-strs.h \
- autoopts/project.h autoopts/options.h autoopts/usage-txt.h \
- autoopts.c autoopts.h boolean.c \
- check.c compat/compat.h compat/windows-config.h \
- compat/pathfind.c compat/snprintf.c compat/strchr.c \
- compat/strdup.c compat/_Noreturn.h configfile.c \
- cook.c enum.c env.c \
- file.c find.c genshell.c \
- genshell.h gettext.h init.c \
- intprops.h load.c m4/libopts.m4 \
- m4/stdnoreturn.m4 m4/liboptschk.m4 makeshell.c \
- nested.c numeric.c option-value-type.c \
- option-value-type.h option-xat-attribute.c option-xat-attribute.h \
- parse-duration.c parse-duration.h pgusage.c \
- proto.h putshell.c reset.c \
- restore.c save.c sort.c \
- stack.c stdnoreturn.in.h streqvcmp.c \
- text_mmap.c time.c tokenize.c \
- usage.c version.c save-flags.c save-flags.h
diff --git a/src/libopts/README b/src/libopts/README
deleted file mode 100644
index 98e4f3c677..0000000000
--- a/src/libopts/README
+++ /dev/null
@@ -1,122 +0,0 @@
- THIS TARBALL IS NOT A FULL DISTRIBUTION.
-
-The contents of this tarball is designed to be incorporated into
-software packages that utilize the AutoOpts option automation package
-and are intended to be installed on systems that may not have libopts
-installed. It is redistributable under the terms of either the LGPL
-(see COPYING.lgpl) or under the terms of the advertising clause free BSD
-license (see COPYING.mbsd).
-
-Usage Instructions for autoconf/automake/libtoolized projects:
-
-1. Install the unrolled tarball into your package source tree,
- copying ``libopts.m4'' to your autoconf macro directory.
-
- In your bootstrap (pre-configure) script, you can do this:
-
- rm -rf libopts libopts-*
- gunzip -c `autoopts-config libsrc` | tar -xvf -
- mv -f libopts-*.*.* libopts
- cp -fp libopts/m4/*.m4 m4/.
-
- I tend to put my configure auxiliary files in "m4".
- Whatever directory you choose, if it is not ".", then
- be sure to tell autoconf about it with:
-
- AC_CONFIG_AUX_DIR(m4)
-
- This is one macro where you *MUST* remember to *NOT* quote
- the argument. If you do, automake will get lost.
-
-2. Add an invocation of either LIBOPTS_CHECK or LIBOPTS_CHECK_NOBUILD
- to your configure.ac file. See LIBOPTS_CHECK: below for details.
-
-3. Add the following to your top level ``Makefile.am'' file:
-
- if NEED_LIBOPTS
- SUBDIRS += $(LIBOPTS_DIR)
- endif
-
- where ``<...>'' can be whatever other files or directories you may
- need. The SUBDIRS must be properly ordered. *PLEASE NOTE* it is
- crucial that the SUBDIRS be set under the control of an automake
- conditional. To work correctly, automake has to know the range of
- possible values of SUBDIRS. It's a magical name with magical
- properties. ``NEED_LIBOPTS'' will be correctly set by the
- ``LIBOPTS_CHECK'' macro, above.
-
-4. Add ``$(LIBOPTS_CFLAGS)'' to relevant compiler flags and
- ``$(LIBOPTS_LDADD)'' to relevant link options whereever
- you need them in your build tree.
-
-5. Make sure your object files explicitly depend upon the
- generated options header file. e.g.:
-
- $(prog_OBJECTS) : prog-opts.h
- prog-opts.h : prog-opts.c
- prog-opts.c : prog-opts.def
- autogen prog-opts.def
-
-6. *OPTIONAL* --
- If you are creating man pages and texi documentation from
- the program options, you will need these rules somewhere, too:
-
- man_MANS = prog.1
- prog.1 : prog-opts.def
- autogen -Tagman-cmd.tpl -bprog prog-opts.def
-
- invoke-prog.texi : prog-opts.def
- autogen -Tagtexi-cmd.tpl prog-opts.def
-
-If your package does not utilize the auto* tools, then you
-will need to hand craft the rules for building the library.
-
-LIBOPTS_CHECK:
-
-The arguments to both macro are a relative path to the directory with
-the libopts source code. It is optional and defaults to "libopts".
-These macros work as follows:
-
-1. LIBOPTS_CHECK([libopts/rel/path/optional])
-
- Adds two command-line options to the generated configure script,
- --enable-local-libopts and --disable-libopts-install. AC_SUBST's
- LIBOPTS_CFLAGS, LIBOPTS_LDADD, and LIBOPTS_DIR for use in
- Makefile.am files. Adds Automake conditional NEED_LIBOPTS which
- will be true when the local copy of libopts should be built. Uses
- AC_CONFIG_FILES([$libopts-dir/Makefile]) to cause the local libopts
- into the package build. If the optional relative path to libopts is
- not provided, it defaults to simply "libopts".
-
-2. LIBOPTS_CHECK_NOBUILD([libopts/rel/path/optional])
-
- This variant of LIBOPTS_CHECK is useful when multiple configure.ac
- files in a package make use of a single libopts tearoff. In that
- case, only one of the configure.ac files should build libopts and
- others should simply use it. Consider this package arrangment:
-
- all-tools/
- configure.ac
- common-tools/
- configure.ac
- libopts/
-
- The parent package all-tools contains a subpackage common-tools
- which can be torn off and used independently. Programs configured
- by both configure.ac files link against the common-tools/libopts
- tearoff, when not using the system's libopts. The top-level
- configure.ac uses LIBOPTS_CHECK_NOBUILD([common-tools/libopts]),
- while common-tools/configure.ac uses LIBOPTS_CHECK. The difference
- is LIBOPTS_CHECK_NOBUILD will never build the libopts tearoff,
- leaving that to the subpackage configure.ac's LIBOPTS_CHECK.
- Specifically, LIBOPTS_CHECK_NOBUILD always results in the
- NEED_LIBOPTS Automake conditional being false, and does not invoke
- AC_CONFIG_FILES(path-to-libopts/Makefile).
-
-LICENSING:
-
-This material is Copyright (C) 1992-2015 by Bruce Korb. You are
-licensed to use this under the terms of either the GNU Lesser General
-Public License (see: COPYING.lgpl), or, at your option, the modified
-Berkeley Software Distribution License (see: COPYING.mbsd). Both of
-these files should be included with this tarball.
diff --git a/src/libopts/_Noreturn.h b/src/libopts/_Noreturn.h
deleted file mode 100644
index c44ad89b7c..0000000000
--- a/src/libopts/_Noreturn.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#if !defined _Noreturn && __STDC_VERSION__ < 201112
-# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
- || 0x5110 <= __SUNPRO_C)
-# define _Noreturn __attribute__ ((__noreturn__))
-# elif 1200 <= _MSC_VER
-# define _Noreturn __declspec (noreturn)
-# else
-# define _Noreturn
-# endif
-#endif
diff --git a/src/libopts/ag-char-map.h b/src/libopts/ag-char-map.h
deleted file mode 100644
index cced2303ab..0000000000
--- a/src/libopts/ag-char-map.h
+++ /dev/null
@@ -1,526 +0,0 @@
-/*
- * 29 bits for 46 character classifications
- * generated by char-mapper on 08/26/18 at 10:44:22
- *
- * This file contains the character classifications
- * used by AutoGen and AutoOpts for identifying tokens.
- * The table is static scope, so %guard is empty.
- *
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-#ifndef AG_CHAR_MAP_H_GUARD
-#define AG_CHAR_MAP_H_GUARD 1
-
-#ifdef HAVE_CONFIG_H
-# if defined(HAVE_INTTYPES_H)
-# include <inttypes.h>
-
-# elif defined(HAVE_STDINT_H)
-# include <stdint.h>
-
-# elif !defined(HAVE_UINT32_T)
-# if SIZEOF_INT == 4
- typedef unsigned int uint32_t;
-# elif SIZEOF_LONG == 4
- typedef unsigned long uint32_t;
-# endif
-# endif /* HAVE_*INT*_H header */
-
-#else /* not HAVE_CONFIG_H -- */
-# include <inttypes.h>
-#endif /* HAVE_CONFIG_H */
-
-#if 0 /* mapping specification source (from autogen.map) */
-//
-// %guard
-// %file ag-char-map.h
-// %backup
-// %optimize
-//
-// %comment -- see above
-// %
-//
-// newline "\n"
-// nul-byte "\x00"
-// dir-sep "/\\"
-// percent "%"
-// comma ","
-// colon ":"
-// underscore "_"
-// plus "+"
-// dollar "$"
-// option-marker "-"
-//
-// horiz-white "\t "
-// alt-white "\v\f\r\b"
-// whitespace +horiz-white +newline +alt-white
-// non-nl-white +horiz-white +alt-white
-// quote "'\""
-// parentheses "()"
-//
-// graphic "!-~"
-// inversion "~-"
-// oct-digit "0-7"
-// dec-digit "89" +oct-digit
-// hex-digit "a-fA-F" +dec-digit
-// lower-case "a-z"
-// upper-case "A-Z"
-// alphabetic +lower-case +upper-case
-// alphanumeric +alphabetic +dec-digit
-// var-first +underscore +alphabetic
-// variable-name +var-first +dec-digit
-// option-name "^-" +variable-name
-// value-name +colon +option-name
-// name-sep "[.]"
-// compound-name +value-name +name-sep +horiz-white
-// scheme-note +parentheses +quote
-//
-// unquotable "!-~" -"#,;<=>[\\]`{}?*" -quote -parentheses
-// end-xml-token "/>" +whitespace
-// plus-n-space +plus +whitespace
-// punctuation "!-~" -alphanumeric -"_"
-// suffix "-._" +alphanumeric
-// suffix-fmt +percent +suffix +dir-sep
-// false-type "nNfF0" +nul-byte
-// file-name +dir-sep +suffix
-// end-token +nul-byte +whitespace
-// end-list-entry +comma +end-token
-// set-separator "|+-!" +end-list-entry
-// signed-number +inversion +dec-digit
-// make-script +dollar +newline
-// load-line-skip +horiz-white +option-marker
-//
-#endif /* 0 -- mapping spec. source */
-
-
-typedef uint32_t ag_char_map_mask_t;
-
-#define IS_NEWLINE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000001)
-#define SPN_NEWLINE_CHARS(_s) spn_ag_char_map_chars(_s, 0)
-#define BRK_NEWLINE_CHARS(_s) brk_ag_char_map_chars(_s, 0)
-#define SPN_NEWLINE_BACK(s,e) spn_ag_char_map_back(s, e, 0)
-#define BRK_NEWLINE_BACK(s,e) brk_ag_char_map_back(s, e, 0)
-#define IS_NUL_BYTE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000002)
-#define SPN_NUL_BYTE_CHARS(_s) spn_ag_char_map_chars(_s, 1)
-#define BRK_NUL_BYTE_CHARS(_s) brk_ag_char_map_chars(_s, 1)
-#define SPN_NUL_BYTE_BACK(s,e) spn_ag_char_map_back(s, e, 1)
-#define BRK_NUL_BYTE_BACK(s,e) brk_ag_char_map_back(s, e, 1)
-#define IS_DIR_SEP_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000004)
-#define SPN_DIR_SEP_CHARS(_s) spn_ag_char_map_chars(_s, 2)
-#define BRK_DIR_SEP_CHARS(_s) brk_ag_char_map_chars(_s, 2)
-#define SPN_DIR_SEP_BACK(s,e) spn_ag_char_map_back(s, e, 2)
-#define BRK_DIR_SEP_BACK(s,e) brk_ag_char_map_back(s, e, 2)
-#define IS_PERCENT_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000008)
-#define SPN_PERCENT_CHARS(_s) spn_ag_char_map_chars(_s, 3)
-#define BRK_PERCENT_CHARS(_s) brk_ag_char_map_chars(_s, 3)
-#define SPN_PERCENT_BACK(s,e) spn_ag_char_map_back(s, e, 3)
-#define BRK_PERCENT_BACK(s,e) brk_ag_char_map_back(s, e, 3)
-#define IS_COMMA_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000010)
-#define SPN_COMMA_CHARS(_s) spn_ag_char_map_chars(_s, 4)
-#define BRK_COMMA_CHARS(_s) brk_ag_char_map_chars(_s, 4)
-#define SPN_COMMA_BACK(s,e) spn_ag_char_map_back(s, e, 4)
-#define BRK_COMMA_BACK(s,e) brk_ag_char_map_back(s, e, 4)
-#define IS_COLON_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000020)
-#define SPN_COLON_CHARS(_s) spn_ag_char_map_chars(_s, 5)
-#define BRK_COLON_CHARS(_s) brk_ag_char_map_chars(_s, 5)
-#define SPN_COLON_BACK(s,e) spn_ag_char_map_back(s, e, 5)
-#define BRK_COLON_BACK(s,e) brk_ag_char_map_back(s, e, 5)
-#define IS_UNDERSCORE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000040)
-#define SPN_UNDERSCORE_CHARS(_s) spn_ag_char_map_chars(_s, 6)
-#define BRK_UNDERSCORE_CHARS(_s) brk_ag_char_map_chars(_s, 6)
-#define SPN_UNDERSCORE_BACK(s,e) spn_ag_char_map_back(s, e, 6)
-#define BRK_UNDERSCORE_BACK(s,e) brk_ag_char_map_back(s, e, 6)
-#define IS_PLUS_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000080)
-#define SPN_PLUS_CHARS(_s) spn_ag_char_map_chars(_s, 7)
-#define BRK_PLUS_CHARS(_s) brk_ag_char_map_chars(_s, 7)
-#define SPN_PLUS_BACK(s,e) spn_ag_char_map_back(s, e, 7)
-#define BRK_PLUS_BACK(s,e) brk_ag_char_map_back(s, e, 7)
-#define IS_DOLLAR_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000100)
-#define SPN_DOLLAR_CHARS(_s) spn_ag_char_map_chars(_s, 8)
-#define BRK_DOLLAR_CHARS(_s) brk_ag_char_map_chars(_s, 8)
-#define SPN_DOLLAR_BACK(s,e) spn_ag_char_map_back(s, e, 8)
-#define BRK_DOLLAR_BACK(s,e) brk_ag_char_map_back(s, e, 8)
-#define IS_OPTION_MARKER_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000200)
-#define SPN_OPTION_MARKER_CHARS(_s) spn_ag_char_map_chars(_s, 9)
-#define BRK_OPTION_MARKER_CHARS(_s) brk_ag_char_map_chars(_s, 9)
-#define SPN_OPTION_MARKER_BACK(s,e) spn_ag_char_map_back(s, e, 9)
-#define BRK_OPTION_MARKER_BACK(s,e) brk_ag_char_map_back(s, e, 9)
-#define IS_HORIZ_WHITE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000400)
-#define SPN_HORIZ_WHITE_CHARS(_s) spn_ag_char_map_chars(_s, 10)
-#define BRK_HORIZ_WHITE_CHARS(_s) brk_ag_char_map_chars(_s, 10)
-#define SPN_HORIZ_WHITE_BACK(s,e) spn_ag_char_map_back(s, e, 10)
-#define BRK_HORIZ_WHITE_BACK(s,e) brk_ag_char_map_back(s, e, 10)
-#define IS_ALT_WHITE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000800)
-#define SPN_ALT_WHITE_CHARS(_s) spn_ag_char_map_chars(_s, 11)
-#define BRK_ALT_WHITE_CHARS(_s) brk_ag_char_map_chars(_s, 11)
-#define SPN_ALT_WHITE_BACK(s,e) spn_ag_char_map_back(s, e, 11)
-#define BRK_ALT_WHITE_BACK(s,e) brk_ag_char_map_back(s, e, 11)
-#define IS_WHITESPACE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000C01)
-#define SPN_WHITESPACE_CHARS(_s) spn_ag_char_map_chars(_s, 12)
-#define BRK_WHITESPACE_CHARS(_s) brk_ag_char_map_chars(_s, 12)
-#define SPN_WHITESPACE_BACK(s,e) spn_ag_char_map_back(s, e, 12)
-#define BRK_WHITESPACE_BACK(s,e) brk_ag_char_map_back(s, e, 12)
-#define IS_NON_NL_WHITE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000C00)
-#define SPN_NON_NL_WHITE_CHARS(_s) spn_ag_char_map_chars(_s, 13)
-#define BRK_NON_NL_WHITE_CHARS(_s) brk_ag_char_map_chars(_s, 13)
-#define SPN_NON_NL_WHITE_BACK(s,e) spn_ag_char_map_back(s, e, 13)
-#define BRK_NON_NL_WHITE_BACK(s,e) brk_ag_char_map_back(s, e, 13)
-#define IS_QUOTE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00001000)
-#define SPN_QUOTE_CHARS(_s) spn_ag_char_map_chars(_s, 14)
-#define BRK_QUOTE_CHARS(_s) brk_ag_char_map_chars(_s, 14)
-#define SPN_QUOTE_BACK(s,e) spn_ag_char_map_back(s, e, 14)
-#define BRK_QUOTE_BACK(s,e) brk_ag_char_map_back(s, e, 14)
-#define IS_PARENTHESES_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00002000)
-#define SPN_PARENTHESES_CHARS(_s) spn_ag_char_map_chars(_s, 15)
-#define BRK_PARENTHESES_CHARS(_s) brk_ag_char_map_chars(_s, 15)
-#define SPN_PARENTHESES_BACK(s,e) spn_ag_char_map_back(s, e, 15)
-#define BRK_PARENTHESES_BACK(s,e) brk_ag_char_map_back(s, e, 15)
-#define IS_GRAPHIC_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00004000)
-#define SPN_GRAPHIC_CHARS(_s) spn_ag_char_map_chars(_s, 16)
-#define BRK_GRAPHIC_CHARS(_s) brk_ag_char_map_chars(_s, 16)
-#define SPN_GRAPHIC_BACK(s,e) spn_ag_char_map_back(s, e, 16)
-#define BRK_GRAPHIC_BACK(s,e) brk_ag_char_map_back(s, e, 16)
-#define IS_INVERSION_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00008000)
-#define SPN_INVERSION_CHARS(_s) spn_ag_char_map_chars(_s, 17)
-#define BRK_INVERSION_CHARS(_s) brk_ag_char_map_chars(_s, 17)
-#define SPN_INVERSION_BACK(s,e) spn_ag_char_map_back(s, e, 17)
-#define BRK_INVERSION_BACK(s,e) brk_ag_char_map_back(s, e, 17)
-#define IS_OCT_DIGIT_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00010000)
-#define SPN_OCT_DIGIT_CHARS(_s) spn_ag_char_map_chars(_s, 18)
-#define BRK_OCT_DIGIT_CHARS(_s) brk_ag_char_map_chars(_s, 18)
-#define SPN_OCT_DIGIT_BACK(s,e) spn_ag_char_map_back(s, e, 18)
-#define BRK_OCT_DIGIT_BACK(s,e) brk_ag_char_map_back(s, e, 18)
-#define IS_DEC_DIGIT_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00030000)
-#define SPN_DEC_DIGIT_CHARS(_s) spn_ag_char_map_chars(_s, 19)
-#define BRK_DEC_DIGIT_CHARS(_s) brk_ag_char_map_chars(_s, 19)
-#define SPN_DEC_DIGIT_BACK(s,e) spn_ag_char_map_back(s, e, 19)
-#define BRK_DEC_DIGIT_BACK(s,e) brk_ag_char_map_back(s, e, 19)
-#define IS_HEX_DIGIT_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00070000)
-#define SPN_HEX_DIGIT_CHARS(_s) spn_ag_char_map_chars(_s, 20)
-#define BRK_HEX_DIGIT_CHARS(_s) brk_ag_char_map_chars(_s, 20)
-#define SPN_HEX_DIGIT_BACK(s,e) spn_ag_char_map_back(s, e, 20)
-#define BRK_HEX_DIGIT_BACK(s,e) brk_ag_char_map_back(s, e, 20)
-#define IS_LOWER_CASE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00080000)
-#define SPN_LOWER_CASE_CHARS(_s) spn_ag_char_map_chars(_s, 21)
-#define BRK_LOWER_CASE_CHARS(_s) brk_ag_char_map_chars(_s, 21)
-#define SPN_LOWER_CASE_BACK(s,e) spn_ag_char_map_back(s, e, 21)
-#define BRK_LOWER_CASE_BACK(s,e) brk_ag_char_map_back(s, e, 21)
-#define IS_UPPER_CASE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00100000)
-#define SPN_UPPER_CASE_CHARS(_s) spn_ag_char_map_chars(_s, 22)
-#define BRK_UPPER_CASE_CHARS(_s) brk_ag_char_map_chars(_s, 22)
-#define SPN_UPPER_CASE_BACK(s,e) spn_ag_char_map_back(s, e, 22)
-#define BRK_UPPER_CASE_BACK(s,e) brk_ag_char_map_back(s, e, 22)
-#define IS_ALPHABETIC_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00180000)
-#define SPN_ALPHABETIC_CHARS(_s) spn_ag_char_map_chars(_s, 23)
-#define BRK_ALPHABETIC_CHARS(_s) brk_ag_char_map_chars(_s, 23)
-#define SPN_ALPHABETIC_BACK(s,e) spn_ag_char_map_back(s, e, 23)
-#define BRK_ALPHABETIC_BACK(s,e) brk_ag_char_map_back(s, e, 23)
-#define IS_ALPHANUMERIC_CHAR( _c) is_ag_char_map_char((char)(_c), 0x001B0000)
-#define SPN_ALPHANUMERIC_CHARS(_s) spn_ag_char_map_chars(_s, 24)
-#define BRK_ALPHANUMERIC_CHARS(_s) brk_ag_char_map_chars(_s, 24)
-#define SPN_ALPHANUMERIC_BACK(s,e) spn_ag_char_map_back(s, e, 24)
-#define BRK_ALPHANUMERIC_BACK(s,e) brk_ag_char_map_back(s, e, 24)
-#define IS_VAR_FIRST_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00180040)
-#define SPN_VAR_FIRST_CHARS(_s) spn_ag_char_map_chars(_s, 25)
-#define BRK_VAR_FIRST_CHARS(_s) brk_ag_char_map_chars(_s, 25)
-#define SPN_VAR_FIRST_BACK(s,e) spn_ag_char_map_back(s, e, 25)
-#define BRK_VAR_FIRST_BACK(s,e) brk_ag_char_map_back(s, e, 25)
-#define IS_VARIABLE_NAME_CHAR( _c) is_ag_char_map_char((char)(_c), 0x001B0040)
-#define SPN_VARIABLE_NAME_CHARS(_s) spn_ag_char_map_chars(_s, 26)
-#define BRK_VARIABLE_NAME_CHARS(_s) brk_ag_char_map_chars(_s, 26)
-#define SPN_VARIABLE_NAME_BACK(s,e) spn_ag_char_map_back(s, e, 26)
-#define BRK_VARIABLE_NAME_BACK(s,e) brk_ag_char_map_back(s, e, 26)
-#define IS_OPTION_NAME_CHAR( _c) is_ag_char_map_char((char)(_c), 0x003B0040)
-#define SPN_OPTION_NAME_CHARS(_s) spn_ag_char_map_chars(_s, 27)
-#define BRK_OPTION_NAME_CHARS(_s) brk_ag_char_map_chars(_s, 27)
-#define SPN_OPTION_NAME_BACK(s,e) spn_ag_char_map_back(s, e, 27)
-#define BRK_OPTION_NAME_BACK(s,e) brk_ag_char_map_back(s, e, 27)
-#define IS_VALUE_NAME_CHAR( _c) is_ag_char_map_char((char)(_c), 0x003B0060)
-#define SPN_VALUE_NAME_CHARS(_s) spn_ag_char_map_chars(_s, 28)
-#define BRK_VALUE_NAME_CHARS(_s) brk_ag_char_map_chars(_s, 28)
-#define SPN_VALUE_NAME_BACK(s,e) spn_ag_char_map_back(s, e, 28)
-#define BRK_VALUE_NAME_BACK(s,e) brk_ag_char_map_back(s, e, 28)
-#define IS_NAME_SEP_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00400000)
-#define SPN_NAME_SEP_CHARS(_s) spn_ag_char_map_chars(_s, 29)
-#define BRK_NAME_SEP_CHARS(_s) brk_ag_char_map_chars(_s, 29)
-#define SPN_NAME_SEP_BACK(s,e) spn_ag_char_map_back(s, e, 29)
-#define BRK_NAME_SEP_BACK(s,e) brk_ag_char_map_back(s, e, 29)
-#define IS_COMPOUND_NAME_CHAR( _c) is_ag_char_map_char((char)(_c), 0x007B0460)
-#define SPN_COMPOUND_NAME_CHARS(_s) spn_ag_char_map_chars(_s, 30)
-#define BRK_COMPOUND_NAME_CHARS(_s) brk_ag_char_map_chars(_s, 30)
-#define SPN_COMPOUND_NAME_BACK(s,e) spn_ag_char_map_back(s, e, 30)
-#define BRK_COMPOUND_NAME_BACK(s,e) brk_ag_char_map_back(s, e, 30)
-#define IS_SCHEME_NOTE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00003000)
-#define SPN_SCHEME_NOTE_CHARS(_s) spn_ag_char_map_chars(_s, 31)
-#define BRK_SCHEME_NOTE_CHARS(_s) brk_ag_char_map_chars(_s, 31)
-#define SPN_SCHEME_NOTE_BACK(s,e) spn_ag_char_map_back(s, e, 31)
-#define BRK_SCHEME_NOTE_BACK(s,e) brk_ag_char_map_back(s, e, 31)
-#define IS_UNQUOTABLE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00800000)
-#define SPN_UNQUOTABLE_CHARS(_s) spn_ag_char_map_chars(_s, 32)
-#define BRK_UNQUOTABLE_CHARS(_s) brk_ag_char_map_chars(_s, 32)
-#define SPN_UNQUOTABLE_BACK(s,e) spn_ag_char_map_back(s, e, 32)
-#define BRK_UNQUOTABLE_BACK(s,e) brk_ag_char_map_back(s, e, 32)
-#define IS_END_XML_TOKEN_CHAR( _c) is_ag_char_map_char((char)(_c), 0x01000C01)
-#define SPN_END_XML_TOKEN_CHARS(_s) spn_ag_char_map_chars(_s, 33)
-#define BRK_END_XML_TOKEN_CHARS(_s) brk_ag_char_map_chars(_s, 33)
-#define SPN_END_XML_TOKEN_BACK(s,e) spn_ag_char_map_back(s, e, 33)
-#define BRK_END_XML_TOKEN_BACK(s,e) brk_ag_char_map_back(s, e, 33)
-#define IS_PLUS_N_SPACE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000C81)
-#define SPN_PLUS_N_SPACE_CHARS(_s) spn_ag_char_map_chars(_s, 34)
-#define BRK_PLUS_N_SPACE_CHARS(_s) brk_ag_char_map_chars(_s, 34)
-#define SPN_PLUS_N_SPACE_BACK(s,e) spn_ag_char_map_back(s, e, 34)
-#define BRK_PLUS_N_SPACE_BACK(s,e) brk_ag_char_map_back(s, e, 34)
-#define IS_PUNCTUATION_CHAR( _c) is_ag_char_map_char((char)(_c), 0x02000000)
-#define SPN_PUNCTUATION_CHARS(_s) spn_ag_char_map_chars(_s, 35)
-#define BRK_PUNCTUATION_CHARS(_s) brk_ag_char_map_chars(_s, 35)
-#define SPN_PUNCTUATION_BACK(s,e) spn_ag_char_map_back(s, e, 35)
-#define BRK_PUNCTUATION_BACK(s,e) brk_ag_char_map_back(s, e, 35)
-#define IS_SUFFIX_CHAR( _c) is_ag_char_map_char((char)(_c), 0x041B0000)
-#define SPN_SUFFIX_CHARS(_s) spn_ag_char_map_chars(_s, 36)
-#define BRK_SUFFIX_CHARS(_s) brk_ag_char_map_chars(_s, 36)
-#define SPN_SUFFIX_BACK(s,e) spn_ag_char_map_back(s, e, 36)
-#define BRK_SUFFIX_BACK(s,e) brk_ag_char_map_back(s, e, 36)
-#define IS_SUFFIX_FMT_CHAR( _c) is_ag_char_map_char((char)(_c), 0x041B000C)
-#define SPN_SUFFIX_FMT_CHARS(_s) spn_ag_char_map_chars(_s, 37)
-#define BRK_SUFFIX_FMT_CHARS(_s) brk_ag_char_map_chars(_s, 37)
-#define SPN_SUFFIX_FMT_BACK(s,e) spn_ag_char_map_back(s, e, 37)
-#define BRK_SUFFIX_FMT_BACK(s,e) brk_ag_char_map_back(s, e, 37)
-#define IS_FALSE_TYPE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x08000002)
-#define SPN_FALSE_TYPE_CHARS(_s) spn_ag_char_map_chars(_s, 38)
-#define BRK_FALSE_TYPE_CHARS(_s) brk_ag_char_map_chars(_s, 38)
-#define SPN_FALSE_TYPE_BACK(s,e) spn_ag_char_map_back(s, e, 38)
-#define BRK_FALSE_TYPE_BACK(s,e) brk_ag_char_map_back(s, e, 38)
-#define IS_FILE_NAME_CHAR( _c) is_ag_char_map_char((char)(_c), 0x041B0004)
-#define SPN_FILE_NAME_CHARS(_s) spn_ag_char_map_chars(_s, 39)
-#define BRK_FILE_NAME_CHARS(_s) brk_ag_char_map_chars(_s, 39)
-#define SPN_FILE_NAME_BACK(s,e) spn_ag_char_map_back(s, e, 39)
-#define BRK_FILE_NAME_BACK(s,e) brk_ag_char_map_back(s, e, 39)
-#define IS_END_TOKEN_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000C03)
-#define SPN_END_TOKEN_CHARS(_s) spn_ag_char_map_chars(_s, 40)
-#define BRK_END_TOKEN_CHARS(_s) brk_ag_char_map_chars(_s, 40)
-#define SPN_END_TOKEN_BACK(s,e) spn_ag_char_map_back(s, e, 40)
-#define BRK_END_TOKEN_BACK(s,e) brk_ag_char_map_back(s, e, 40)
-#define IS_END_LIST_ENTRY_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000C13)
-#define SPN_END_LIST_ENTRY_CHARS(_s) spn_ag_char_map_chars(_s, 41)
-#define BRK_END_LIST_ENTRY_CHARS(_s) brk_ag_char_map_chars(_s, 41)
-#define SPN_END_LIST_ENTRY_BACK(s,e) spn_ag_char_map_back(s, e, 41)
-#define BRK_END_LIST_ENTRY_BACK(s,e) brk_ag_char_map_back(s, e, 41)
-#define IS_SET_SEPARATOR_CHAR( _c) is_ag_char_map_char((char)(_c), 0x10000C13)
-#define SPN_SET_SEPARATOR_CHARS(_s) spn_ag_char_map_chars(_s, 42)
-#define BRK_SET_SEPARATOR_CHARS(_s) brk_ag_char_map_chars(_s, 42)
-#define SPN_SET_SEPARATOR_BACK(s,e) spn_ag_char_map_back(s, e, 42)
-#define BRK_SET_SEPARATOR_BACK(s,e) brk_ag_char_map_back(s, e, 42)
-#define IS_SIGNED_NUMBER_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00038000)
-#define SPN_SIGNED_NUMBER_CHARS(_s) spn_ag_char_map_chars(_s, 43)
-#define BRK_SIGNED_NUMBER_CHARS(_s) brk_ag_char_map_chars(_s, 43)
-#define SPN_SIGNED_NUMBER_BACK(s,e) spn_ag_char_map_back(s, e, 43)
-#define BRK_SIGNED_NUMBER_BACK(s,e) brk_ag_char_map_back(s, e, 43)
-#define IS_MAKE_SCRIPT_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000101)
-#define SPN_MAKE_SCRIPT_CHARS(_s) spn_ag_char_map_chars(_s, 44)
-#define BRK_MAKE_SCRIPT_CHARS(_s) brk_ag_char_map_chars(_s, 44)
-#define SPN_MAKE_SCRIPT_BACK(s,e) spn_ag_char_map_back(s, e, 44)
-#define BRK_MAKE_SCRIPT_BACK(s,e) brk_ag_char_map_back(s, e, 44)
-#define IS_LOAD_LINE_SKIP_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000600)
-#define SPN_LOAD_LINE_SKIP_CHARS(_s) spn_ag_char_map_chars(_s, 45)
-#define BRK_LOAD_LINE_SKIP_CHARS(_s) brk_ag_char_map_chars(_s, 45)
-#define SPN_LOAD_LINE_SKIP_BACK(s,e) spn_ag_char_map_back(s, e, 45)
-#define BRK_LOAD_LINE_SKIP_BACK(s,e) brk_ag_char_map_back(s, e, 45)
-
-static ag_char_map_mask_t const ag_char_map_table[128] = {
- /*NUL*/ 0x00000002, /*x01*/ 0x00000000, /*x02*/ 0x00000000, /*x03*/ 0x00000000,
- /*x04*/ 0x00000000, /*x05*/ 0x00000000, /*x06*/ 0x00000000, /*BEL*/ 0x00000000,
- /* BS*/ 0x00000800, /* HT*/ 0x00000400, /* NL*/ 0x00000001, /* VT*/ 0x00000800,
- /* FF*/ 0x00000800, /* CR*/ 0x00000800, /*x0E*/ 0x00000000, /*x0F*/ 0x00000000,
- /*x10*/ 0x00000000, /*x11*/ 0x00000000, /*x12*/ 0x00000000, /*x13*/ 0x00000000,
- /*x14*/ 0x00000000, /*x15*/ 0x00000000, /*x16*/ 0x00000000, /*x17*/ 0x00000000,
- /*x18*/ 0x00000000, /*x19*/ 0x00000000, /*x1A*/ 0x00000000, /*ESC*/ 0x00000000,
- /*x1C*/ 0x00000000, /*x1D*/ 0x00000000, /*x1E*/ 0x00000000, /*x1F*/ 0x00000000,
- /* */ 0x00000400, /* ! */ 0x02804000, /* " */ 0x02005000, /* # */ 0x02004000,
- /* $ */ 0x02804100, /* % */ 0x02804008, /* & */ 0x02804000, /* ' */ 0x02005000,
- /* ( */ 0x02006000, /* ) */ 0x02006000, /* * */ 0x02004000, /* + */ 0x12804080,
- /* , */ 0x02004010, /* - */ 0x06A0C200, /* . */ 0x06C04000, /* / */ 0x03804004,
- /* 0 */ 0x08814000, /* 1 */ 0x00814000, /* 2 */ 0x00814000, /* 3 */ 0x00814000,
- /* 4 */ 0x00814000, /* 5 */ 0x00814000, /* 6 */ 0x00814000, /* 7 */ 0x00814000,
- /* 8 */ 0x00824000, /* 9 */ 0x00824000, /* : */ 0x02804020, /* ; */ 0x02004000,
- /* < */ 0x02004000, /* = */ 0x02004000, /* > */ 0x03004000, /* ? */ 0x02004000,
- /* @ */ 0x02804000, /* A */ 0x00944000, /* B */ 0x00944000, /* C */ 0x00944000,
- /* D */ 0x00944000, /* E */ 0x00944000, /* F */ 0x08944000, /* G */ 0x00904000,
- /* H */ 0x00904000, /* I */ 0x00904000, /* J */ 0x00904000, /* K */ 0x00904000,
- /* L */ 0x00904000, /* M */ 0x00904000, /* N */ 0x08904000, /* O */ 0x00904000,
- /* P */ 0x00904000, /* Q */ 0x00904000, /* R */ 0x00904000, /* S */ 0x00904000,
- /* T */ 0x00904000, /* U */ 0x00904000, /* V */ 0x00904000, /* W */ 0x00904000,
- /* X */ 0x00904000, /* Y */ 0x00904000, /* Z */ 0x00904000, /* [ */ 0x02404000,
- /* \ */ 0x02004004, /* ] */ 0x02404000, /* ^ */ 0x02A04000, /* _ */ 0x04804040,
- /* ` */ 0x02004000, /* a */ 0x008C4000, /* b */ 0x008C4000, /* c */ 0x008C4000,
- /* d */ 0x008C4000, /* e */ 0x008C4000, /* f */ 0x088C4000, /* g */ 0x00884000,
- /* h */ 0x00884000, /* i */ 0x00884000, /* j */ 0x00884000, /* k */ 0x00884000,
- /* l */ 0x00884000, /* m */ 0x00884000, /* n */ 0x08884000, /* o */ 0x00884000,
- /* p */ 0x00884000, /* q */ 0x00884000, /* r */ 0x00884000, /* s */ 0x00884000,
- /* t */ 0x00884000, /* u */ 0x00884000, /* v */ 0x00884000, /* w */ 0x00884000,
- /* x */ 0x00884000, /* y */ 0x00884000, /* z */ 0x00884000, /* { */ 0x02004000,
- /* | */ 0x12804000, /* } */ 0x02004000, /* ~ */ 0x0280C000, /*x7F*/ 0x00000000
-};
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifndef _
-# define _(_s) _s
-#endif
-
-static unsigned char const * ag_char_map_spanners[46];
-/**
- * Character category masks. Some categories may have multiple bits,
- * if their definition incorporates other character categories.
- * This mask array is only used by calc_ag_char_map_spanners().
- */
-static ag_char_map_mask_t const ag_char_map_masks[46] = {
- 0x00000001, /* NEWLINE */
- 0x00000002, /* NUL_BYTE */
- 0x00000004, /* DIR_SEP */
- 0x00000008, /* PERCENT */
- 0x00000010, /* COMMA */
- 0x00000020, /* COLON */
- 0x00000040, /* UNDERSCORE */
- 0x00000080, /* PLUS */
- 0x00000100, /* DOLLAR */
- 0x00000200, /* OPTION_MARKER */
- 0x00000400, /* HORIZ_WHITE */
- 0x00000800, /* ALT_WHITE */
- 0x00000C01, /* WHITESPACE */
- 0x00000C00, /* NON_NL_WHITE */
- 0x00001000, /* QUOTE */
- 0x00002000, /* PARENTHESES */
- 0x00004000, /* GRAPHIC */
- 0x00008000, /* INVERSION */
- 0x00010000, /* OCT_DIGIT */
- 0x00030000, /* DEC_DIGIT */
- 0x00070000, /* HEX_DIGIT */
- 0x00080000, /* LOWER_CASE */
- 0x00100000, /* UPPER_CASE */
- 0x00180000, /* ALPHABETIC */
- 0x001B0000, /* ALPHANUMERIC */
- 0x00180040, /* VAR_FIRST */
- 0x001B0040, /* VARIABLE_NAME */
- 0x003B0040, /* OPTION_NAME */
- 0x003B0060, /* VALUE_NAME */
- 0x00400000, /* NAME_SEP */
- 0x007B0460, /* COMPOUND_NAME */
- 0x00003000, /* SCHEME_NOTE */
- 0x00800000, /* UNQUOTABLE */
- 0x01000C01, /* END_XML_TOKEN */
- 0x00000C81, /* PLUS_N_SPACE */
- 0x02000000, /* PUNCTUATION */
- 0x041B0000, /* SUFFIX */
- 0x041B000C, /* SUFFIX_FMT */
- 0x08000002, /* FALSE_TYPE */
- 0x041B0004, /* FILE_NAME */
- 0x00000C03, /* END_TOKEN */
- 0x00000C13, /* END_LIST_ENTRY */
- 0x10000C13, /* SET_SEPARATOR */
- 0x00038000, /* SIGNED_NUMBER */
- 0x00000101, /* MAKE_SCRIPT */
- 0x00000600, /* LOAD_LINE_SKIP */
-};
-#undef LOCK_SPANNER_TABLES
-
-static unsigned char const *
-calc_ag_char_map_spanners(unsigned int mask_ix)
-{
-#ifdef LOCK_SPANNER_TABLES
- if (ag_char_map_spanners[mask_ix] != NULL)
- return ag_char_map_spanners[mask_ix];
-
- pthread_mutex_lock(&ag_char_map_mutex);
- if (ag_char_map_spanners[mask_ix] == NULL)
-#endif
- {
- int ix = 1;
- ag_char_map_mask_t mask = ag_char_map_masks[mask_ix];
- unsigned char * res = malloc(256 /* 1 << NBBY */);
- if (res == NULL) {
- fputs(_("no memory for char-mapper span map\n"), stderr);
- exit(EXIT_FAILURE);
- }
-
- memset(res, 0, 256);
- for (; ix < 128; ix++)
- if (ag_char_map_table[ix] & mask)
- res[ix] = 1;
- ag_char_map_spanners[mask_ix] = res;
- }
-#ifdef LOCK_SPANNER_TABLES
- pthread_mutex_unlock(&ag_char_map_mutex);
-#endif
- return ag_char_map_spanners[mask_ix];
-}
-#define ag_char_map_masks POISONED_ag_char_map_masks
-
-static inline int
-is_ag_char_map_char(char ch, ag_char_map_mask_t mask)
-{
- unsigned int ix = (unsigned char)ch;
- return ((ix < 128) && ((ag_char_map_table[ix] & mask) != 0));
-}
-
-static inline char *
-spn_ag_char_map_chars(char const * p, unsigned int mask_ix)
-{
- unsigned char const * v = ag_char_map_spanners[mask_ix];
- if (v == NULL)
- v = calc_ag_char_map_spanners(mask_ix);
- while (v[(unsigned char)*p]) p++;
- return (char *)(uintptr_t)p;
-}
-
-static inline char *
-brk_ag_char_map_chars(char const * p, unsigned int mask_ix)
-{
- unsigned char const * v = ag_char_map_spanners[mask_ix];
- if (v == NULL)
- v = calc_ag_char_map_spanners(mask_ix);
- while ((*p != '\0') && (! v[(unsigned char)*p])) p++;
- return (char *)(uintptr_t)p;
-}
-
-static inline char *
-spn_ag_char_map_back(char const * s, char const * e, unsigned int mask_ix)
-{
- unsigned char const * v = ag_char_map_spanners[mask_ix];
- if (v == NULL)
- v = calc_ag_char_map_spanners(mask_ix);
- if (s >= e) e = s + strlen(s);
- while ((e > s) && v[(unsigned char)e[-1]]) e--;
- return (char *)(uintptr_t)e;
-}
-
-static inline char *
-brk_ag_char_map_back(char const * s, char const * e, unsigned int mask_ix)
-{
- unsigned char const * v = ag_char_map_spanners[mask_ix];
- if (v == NULL)
- v = calc_ag_char_map_spanners(mask_ix);
- if (s == e) e += strlen(e);
- while ((e > s) && (! v[(unsigned char)e[-1]])) e--;
- return (char *)(uintptr_t)e;
-}
-#endif /* AG_CHAR_MAP_H_GUARD */
diff --git a/src/libopts/alias.c b/src/libopts/alias.c
deleted file mode 100644
index 231f275d50..0000000000
--- a/src/libopts/alias.c
+++ /dev/null
@@ -1,116 +0,0 @@
-
-/**
- * \file alias.c
- *
- * Handle options that are aliases for another option.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This routine will forward an option alias to the correct option code.
- *
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-static tSuccess
-too_many_occurrences(tOptions * opts, tOptDesc * od)
-{
- if ((opts->fOptSet & OPTPROC_ERRSTOP) != 0) {
- char const * eqv = (od->optEquivIndex != NO_EQUIVALENT) ? zequiv : zNil;
-
- fprintf(stderr, ztoo_often_fmt, opts->pzProgName);
-
- if (od->optMaxCt > 1)
- fprintf(stderr, zat_most, od->optMaxCt, od->pz_Name, eqv);
- else
- fprintf(stderr, zonly_one, od->pz_Name, eqv);
- (*opts->pUsageProc)(opts, EXIT_FAILURE);
- /* NOTREACHED */
- }
-
- return FAILURE;
-}
-
-/*=export_func optionAlias
- * private:
- *
- * what: relay an option to its alias
- * arg: + tOptions * + opts + program options descriptor +
- * arg: + tOptDesc * + old_od + the descriptor for this arg +
- * arg: + unsigned int + alias + the aliased-to option index +
- * ret-type: int
- *
- * doc:
- * Handle one option as if it had been specified as another. Exactly.
- * Returns "-1" if the aliased-to option has appeared too many times.
-=*/
-int
-optionAlias(tOptions * opts, tOptDesc * old_od, unsigned int alias)
-{
- tOptDesc * new_od;
-
- if (opts <= OPTPROC_EMIT_LIMIT)
- return 0;
-
- new_od = opts->pOptDesc + alias;
- if ((unsigned)opts->optCt <= alias) {
- fputs(zbad_alias_id, stderr);
- option_exits(EXIT_FAILURE);
- }
-
- /*
- * Copy over the option instance flags
- */
- new_od->fOptState &= OPTST_PERSISTENT_MASK;
- new_od->fOptState |= (old_od->fOptState & ~OPTST_PERSISTENT_MASK);
- new_od->optArg.argString = old_od->optArg.argString;
-
- /*
- * Keep track of count only for DEFINED (command line) options.
- * IF we have too many, build up an error message and bail.
- */
- if ( (new_od->fOptState & OPTST_DEFINED)
- && (++new_od->optOccCt > new_od->optMaxCt) )
- return too_many_occurrences(opts, new_od);
-
- /*
- * Clear the state bits and counters
- */
- old_od->fOptState &= OPTST_PERSISTENT_MASK;
- old_od->optOccCt = 0;
-
- /*
- * If there is a procedure to call, call it
- */
- if (new_od->pOptProc != NULL)
- (*new_od->pOptProc)(opts, new_od);
- return 0;
-}
-
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/alias.c */
diff --git a/src/libopts/ao-strs.c b/src/libopts/ao-strs.c
deleted file mode 100644
index 7f59372601..0000000000
--- a/src/libopts/ao-strs.c
+++ /dev/null
@@ -1,379 +0,0 @@
-/* -*- buffer-read-only: t -*- vi: set ro:
- *
- * DO NOT EDIT THIS FILE (ao-strs.c)
- *
- * It has been AutoGen-ed
- * From the definitions ao-strs.def
- * and the template file strings
- *
- * Copyright (C) 2011-2018 Bruce Korb, all rights reserved.
- * This is free software. It is licensed for use, modification and
- * redistribution under the terms of the
- * Modified (3 clause) Berkeley Software Distribution License
- * <http://www.xfree86.org/3.3.6/COPYRIGHT2.html>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name ``Bruce Korb'' nor the name of any other
- * contributor may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * strings IS PROVIDED BY Bruce Korb ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Bruce Korb OR ANY OTHER CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "ao-strs.h"
-
-char const ao_strs_strtable[6714] =
-/* 0 */ "-_^\0"
-/* 4 */ " %s%s\n\0"
-/* 12 */ "<?auto-options\0"
-/* 27 */ "<?program\0"
-/* 37 */ "%%-%ds %%s\n\0"
-/* 49 */ "<?program %s>\n\0"
-/* 64 */ "\n"
- "%s\n\n\0"
-/* 70 */ "=file\0"
-/* 76 */ "=Mbr\0"
-/* 81 */ "=Cplx\0"
-/* 87 */ "[=arg]\0"
-/* 94 */ "--%2$s%1$s\0"
-/* 105 */ "=Tim\0"
-/* 110 */ "none\0"
-/* 115 */ "# preset/initialization file\n"
- "# %s#\n\0"
-/* 153 */ " %3s %-14s %s\0"
-/* 167 */ "%s\0"
-/* 170 */ "T/F\0"
-/* 174 */ "\n"
- "%s\n\n"
- "%s\0"
-/* 182 */ "Fil\0"
-/* 186 */ "KWd\0"
-/* 190 */ "Mbr\0"
-/* 194 */ "Cpx\0"
-/* 198 */ "no \0"
-/* 202 */ "Num\0"
-/* 206 */ "opt\0"
-/* 210 */ "YES\0"
-/* 214 */ "Str\0"
-/* 218 */ "Tim\0"
-/* 222 */ "\t\t\t\t- \0"
-/* 229 */ "\t\t\t\t \0"
-/* 236 */ "\t\t\t\t-- and \0"
-/* 248 */ "\t\t\t\t%s\n\0"
-/* 256 */ " \0"
-/* 263 */ " \0"
-/* 269 */ " \0"
-/* 273 */ " \0"
-/* 276 */ "all\0"
-/* 280 */ " \t\n"
- ":=\0"
-/* 286 */ "%s_%s_%d=\0"
-/* 296 */ "''\0"
-/* 299 */ " ;;\n\n\0"
-/* 312 */ "'\n\n\0"
-/* 316 */ "</%s>\n\0"
-/* 323 */ " %s\n\0"
-/* 329 */ "%%-%ds\0"
-/* 336 */ "\n"
- "export %s_%s_%d\n\0"
-/* 354 */ "false\0"
-/* 360 */ " -* )\n\0"
-/* 370 */ "flag\0"
-/* 375 */ "INVALID-%d\0"
-/* 386 */ "*INVALID*\0"
-/* 396 */ "\\n\\\n\0"
-/* 401 */ " --* )\n\0"
-/* 412 */ "--\0"
-/* 415 */ "LONGUSAGE\0"
-/* 425 */ " %s\n\0"
-/* 441 */ "\\%03o\0"
-/* 447 */ "more\0"
-/* 452 */ "<%s type=nested>\n\0"
-/* 470 */ "%s\n\0"
-/* 474 */ "%s\n"
- " \0"
-/* 480 */ "OPT_ARG_NEEDED=NO\0"
-/* 498 */ "<%s/>\n\0"
-/* 505 */ "OPT_ARG_NEEDED=OK\0"
-/* 523 */ "\t\0"
-/* 525 */ "<%s>\0"
-/* 530 */ "option\0"
-/* 537 */ "\n"
- "export %s_%s\n\0"
-/* 552 */ "%s_%s=\0"
-/* 559 */ " | \0"
-/* 563 */ "PAGER\0"
-/* 569 */ "%1$s %2$s ; rm -f %2$s\0"
-/* 592 */ " + \0"
-/* 596 */ " puts(_(%s));\n\0"
-/* 612 */ "\\'\0"
-/* 615 */ "'%s'\0"
-/* 620 */ " -- %s\0"
-/* 627 */ "%s_%s_TEXT='\0"
-/* 640 */ "#! %s\n\0"
-/* 647 */ "\n"
- "env | grep '^%s_'\n\0"
-/* 667 */ "=%1$lu # 0x%1$lX\n\0"
-/* 685 */ "stdout\0"
-/* 692 */ "%A %B %e, %Y at %r %Z\0"
-/* 714 */ "TMPDIR\0"
-/* 721 */ "%s/use-%u.XXXXXX\0"
-/* 738 */ "true\0"
-/* 743 */ "<%s type=%s>\0"
-/* 756 */ "VERSION\0"
-/* 764 */ "#x%02X;\0"
-/* 772 */ "OPT_ARG_NEEDED=YES\0"
-/* 791 */ "\n"
- "# %s -- %s\n\0"
-/* 804 */ "# DEFAULT: \0"
-/* 816 */ "'\\''\0"
-/* 821 */ " '%s'\0"
-/* 827 */ "libopts misguessed length of string\n\0"
-/* 864 */ "\n"
- "OPTION_CT=0\n\0"
-/* 878 */ "set --\0"
-/* 885 */ "/tmp\0"
-/* 890 */ " ;;\n\n\0"
-/* 907 */ " '%c' )\n\0"
-/* 923 */ " '%s' )\n\0"
-/* 939 */ " '%s' | \\\n\0"
-/* 957 */ "<%1$s type=boolean>%2$s</%1$s>\n\0"
-/* 989 */ "# From the %s option definitions\n"
- "#\n\0"
-/* 1026 */ "echo 'Warning: Cannot load options files' >&2\0"
-/* 1073 */ "echo 'Warning: Cannot save options files' >&2\0"
-/* 1120 */ "echo 'Warning: Cannot suppress the loading of options files' >&2\0"
-/* 1186 */ "<%1$s type=integer>0x%2$lX</%1$s>\n\0"
-/* 1221 */ "%1$s_%2$s_TEXT='no %2$s text'\n\0"
-/* 1252 */ "%1$s_%2$s_MODE='%3$s'\n"
- "export %1$s_%2$s_MODE\n\0"
-/* 1297 */ "%1$s_%2$s='%3$s'\n"
- "export %1$s_%2$s\n\0"
-/* 1332 */ "%1$s_%2$s_CT=%3$d\n"
- "export %1$s_%2$s_CT\n\0"
-/* 1371 */ "OPTION_CT=%d\n"
- "export OPTION_CT\n\0"
-/* 1402 */ "%1$s_%2$s=%3$s\n"
- "export %1$s_%2$s\n\0"
-/* 1435 */ "%1$s_%2$s=%3$d # 0x%3$X\n"
- "export %1$s_%2$s\n\0"
-/* 1477 */ " case \"${OPT_CODE}\" in\n\0"
-/* 1508 */ " if [ $%1$s_%2$s_CT -gt %3$u ] ; then\n"
- " echo 'Error: more than %3$d %2$s options'\n"
- " echo \"$%1$s_USAGE_TEXT\"\n"
- " exit 1\n"
- " fi >&2\n\0"
-/* 1699 */ "test ${%1$s_%2$s_CT-0} -ge %3$u || {\n"
- " echo %1$s_%2$s has not been set\n"
- " exit 1\n"
- "} 1>&2\n\0"
-/* 1791 */ "test -n \"$%1$s_%2$s\" || {\n"
- " echo %1$s_%2$s has not been set\n"
- " exit 1\n"
- "} 1>&2\n\0"
-/* 1872 */ " echo \"$%s_%s_TEXT\"\n"
- " exit 0\n\0"
-/* 1923 */ "\n"
- "# # # # # # # # # #\n"
- "#\n"
- "# END OF AUTOMATED OPTION PROCESSING\n"
- "#\n"
- "# # # # # # # # # # -- do not modify this marker --\n\0"
-/* 2039 */ " if [ -n \"${OPT_ARG_VAL}\" ]\n"
- " then\n"
- " eval %1$s_${OPT_NAME}${OPT_ELEMENT}=\"'${OPT_ARG_VAL}'\"\n"
- " export %1$s_${OPT_NAME}${OPT_ELEMENT}\n"
- " fi\n"
- "done\n"
- "OPTION_COUNT=`expr $ARG_COUNT - $#`\n"
- "OPERAND_COUNT=$#\n"
- "unset OPT_PROCESS || :\n"
- "unset OPT_ELEMENT || :\n"
- "unset OPT_ARG || :\n"
- "unset OPT_ARG_NEEDED || :\n"
- "unset OPT_NAME || :\n"
- "unset OPT_CODE || :\n"
- "unset OPT_ARG_VAL || :\n\0"
-/* 2418 */ " OPT_CODE=`echo \"X${OPT_ARG}\"|sed 's/^X-*//'`\n"
- " shift\n"
- " OPT_ARG=$1\n"
- " case \"${OPT_CODE}\" in *=* )\n"
- " OPT_ARG_VAL=`echo \"${OPT_CODE}\"|sed 's/^[^=]*=//'`\n"
- " OPT_CODE=`echo \"${OPT_CODE}\"|sed 's/=.*$//'` ;; esac\n\0"
-/* 2669 */ " OPT_CODE=`echo \"X${OPT_ARG}\" | sed 's/X-\\(.\\).*/\\1/'`\n"
- " OPT_ARG=` echo \"X${OPT_ARG}\" | sed 's/X-.//'`\n\0"
-/* 2786 */ "\n"
- "ARG_COUNT=$#\n"
- "OPT_PROCESS=true\n"
- "OPT_ARG=$1\n"
- "while ${OPT_PROCESS} && [ $# -gt 0 ]\n"
- "do\n"
- " OPT_ELEMENT=''\n"
- " OPT_ARG_VAL=''\n\n"
- " case \"${OPT_ARG}\" in\n"
- " -- )\n"
- " OPT_PROCESS=false\n"
- " shift\n"
- " ;;\n\0"
-/* 2993 */ " case \"${OPT_ARG_NEEDED}\" in\n"
- " NO )\n"
- " OPT_ARG_VAL=''\n"
- " ;;\n"
- " YES )\n"
- " if [ -z \"${OPT_ARG_VAL}\" ]\n"
- " then\n"
- " if [ $# -eq 0 ]\n"
- " then\n"
- " echo No argument provided for ${OPT_NAME} option\n"
- " echo \"$%s_USAGE_TEXT\"\n"
- " exit 1\n"
- " fi >&2\n"
- " OPT_ARG_VAL=${OPT_ARG}\n"
- " shift\n"
- " OPT_ARG=$1\n"
- " fi\n"
- " ;;\n"
- " OK )\n"
- " if [ -z \"${OPT_ARG_VAL}\" ] && [ $# -gt 0 ]\n"
- " then\n"
- " case \"${OPT_ARG}\" in -* ) ;; * )\n"
- " OPT_ARG_VAL=${OPT_ARG}\n"
- " shift\n"
- " OPT_ARG=$1 ;; esac\n"
- " fi\n"
- " ;;\n"
- " esac\n\0"
-/* 3772 */ " %1$s_%2$s_CT=`expr ${%1$s_%2$s_CT} + 1`\n"
- " OPT_ELEMENT=\"_${%1$s_%2$s_CT}\"\n"
- " OPT_NAME='%2$s'\n\0"
-/* 3896 */ "\n"
- "if test -z \"${%1$s_%2$s}\"\n"
- "then\n"
- " %1$s_%2$s_CT=0\n"
- " export %1$s_%2$s_CT\n"
- "else\n"
- " %1$s_%2$s_CT=1\n"
- " %1$s_%2$s_1=${%1$s_%2$s}\n"
- " export %1$s_%2$s_CT %1$s_%2$s_1\n"
- "fi\n\0"
-/* 4054 */ " * )\n"
- " OPT_PROCESS=false\n"
- " ;;\n"
- " esac\n\0"
-/* 4111 */ " %1$s_%2$s_CT=0\n"
- " OPT_ELEMENT=''\n"
- " %1$s_%2$s='%3$s'\n"
- " export %1$s_%2$s\n"
- " OPT_NAME='%2$s'\n\0"
-/* 4252 */ " if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n"
- " echo 'Error: duplicate %2$s option'\n"
- " echo \"$%1$s_USAGE_TEXT\"\n"
- " exit 1\n"
- " fi >&2\n"
- " %1$s_%2$s_set=true\n"
- " %1$s_%2$s='%3$s'\n"
- " export %1$s_%2$s\n"
- " OPT_NAME='%2$s'\n\0"
-/* 4569 */ "\n"
- "ARG_COUNT=$#\n"
- "OPT_ARG=$1\n"
- "while [ $# -gt 0 ]\n"
- "do\n"
- " OPT_ELEMENT=''\n"
- " OPT_ARG_VAL=''\n"
- " OPT_ARG=${1}\n\0"
-/* 4672 */ " case \"${OPT_ARG_NEEDED}\" in\n"
- " NO )\n"
- " if [ -n \"${OPT_ARG}\" ]\n"
- " then\n"
- " OPT_ARG=-${OPT_ARG}\n"
- " else\n"
- " shift\n"
- " OPT_ARG=$1\n"
- " fi\n"
- " ;;\n"
- " YES )\n"
- " if [ -n \"${OPT_ARG}\" ]\n"
- " then\n"
- " OPT_ARG_VAL=${OPT_ARG}\n"
- " else\n"
- " if [ $# -eq 0 ]\n"
- " then\n"
- " echo No argument provided for ${OPT_NAME} option\n"
- " echo \"$%s_USAGE_TEXT\"\n"
- " exit 1\n"
- " fi >&2\n"
- " shift\n"
- " OPT_ARG_VAL=$1\n"
- " fi\n"
- " shift\n"
- " OPT_ARG=$1\n"
- " ;;\n"
- " OK )\n"
- " if [ -n \"${OPT_ARG}\" ]\n"
- " then\n"
- " OPT_ARG_VAL=${OPT_ARG}\n"
- " shift\n"
- " OPT_ARG=$1\n"
- " else\n"
- " shift\n"
- " if [ $# -gt 0 ]\n"
- " then\n"
- " case \"$1\" in -* ) ;; * )\n"
- " OPT_ARG_VAL=$1\n"
- " shift ;; esac\n"
- " OPT_ARG=$1\n"
- " fi\n"
- " fi\n"
- " ;;\n"
- " esac\n\0"
-/* 5826 */ " echo \"$%s_LONGUSAGE_TEXT\" | ${PAGER-more}\n"
- " exit 0\n\0"
-/* 5900 */ "%s OF %s\n"
- "#\n"
- "# From here to the next `-- do not modify this marker --',\n"
- "# the text has been generated %s\n\0"
-/* 6006 */ " eval %1$s_%2$s${OPT_ELEMENT}=true\n"
- " export %1$s_%2$s${OPT_ELEMENT}\n\0"
-/* 6096 */ " if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n"
- " echo 'Error: duplicate %2$s option'\n"
- " echo \"$%1$s_USAGE_TEXT\"\n"
- " exit 1\n"
- " fi >&2\n"
- " %1$s_%2$s_set=true\n"
- " OPT_NAME='%2$s'\n\0"
-/* 6355 */ "\n"
- "%1$s_%2$s=${%1$s_%2$s-'%3$s'}\n"
- "%1$s_%2$s_set=false\n"
- "export %1$s_%2$s\n\0"
-/* 6424 */ "\n"
- "%1$s_%2$s=${%1$s_%2$s}\n"
- "%1$s_%2$s_set=false\n"
- "export %1$s_%2$s\n\0"
-/* 6486 */ "# # # # # # # # # # -- do not modify this marker --\n"
- "#\n"
- "# DO NOT EDIT THIS SECTION\n\0"
-/* 6569 */ " * )\n"
- " echo Unknown %s: \"${OPT_CODE}\" >&2\n"
- " echo \"$%s_USAGE_TEXT\" >&2\n"
- " exit 1\n"
- " ;;\n"
- " esac\n";
-
-/* end of ao-strs.c */
diff --git a/src/libopts/ao-strs.h b/src/libopts/ao-strs.h
deleted file mode 100644
index 95036ef726..0000000000
--- a/src/libopts/ao-strs.h
+++ /dev/null
@@ -1,338 +0,0 @@
-/* -*- buffer-read-only: t -*- vi: set ro:
- *
- * DO NOT EDIT THIS FILE (ao-strs.h)
- *
- * It has been AutoGen-ed
- * From the definitions ao-strs.def
- * and the template file strings
- *
- * Copyright (C) 2011-2018 Bruce Korb, all rights reserved.
- * This is free software. It is licensed for use, modification and
- * redistribution under the terms of the
- * Modified (3 clause) Berkeley Software Distribution License
- * <http://www.xfree86.org/3.3.6/COPYRIGHT2.html>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name ``Bruce Korb'' nor the name of any other
- * contributor may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * strings IS PROVIDED BY Bruce Korb ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Bruce Korb OR ANY OTHER CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef STRINGS_AO_STRS_H_GUARD
-#define STRINGS_AO_STRS_H_GUARD 1
-/*
- * 146 strings in ao_strs_strtable string table
- */
-#define ARG_BREAK_STR (ao_strs_strtable+280)
-#define ARG_BREAK_STR_LEN 5
-#define ARG_BY_NUM_FMT (ao_strs_strtable+286)
-#define ARG_BY_NUM_FMT_LEN 9
-#define BOOL_ATR_FMT (ao_strs_strtable+957)
-#define BOOL_ATR_FMT_LEN 31
-#define CHK_MAX_COUNT (ao_strs_strtable+1508)
-#define CHK_MAX_COUNT_LEN 190
-#define CHK_MIN_COUNT (ao_strs_strtable+1699)
-#define CHK_MIN_COUNT_LEN 91
-#define CHK_ONE_REQUIRED (ao_strs_strtable+1791)
-#define CHK_ONE_REQUIRED_LEN 80
-#define ECHO_N_EXIT (ao_strs_strtable+1872)
-#define ECHO_N_EXIT_LEN 50
-#define EMPTY_ARG (ao_strs_strtable+296)
-#define EMPTY_ARG_LEN 2
-#define END_MARK (ao_strs_strtable+1923)
-#define END_MARK_LEN 115
-#define END_OPT_SEL_STR (ao_strs_strtable+299)
-#define END_OPT_SEL_STR_LEN 12
-#define END_PRE_FMT (ao_strs_strtable+989)
-#define END_PRE_FMT_LEN 36
-#define END_SET_TEXT (ao_strs_strtable+312)
-#define END_SET_TEXT_LEN 3
-#define END_XML_FMT (ao_strs_strtable+316)
-#define END_XML_FMT_LEN 6
-#define ENUM_ERR_LINE (ao_strs_strtable+323)
-#define ENUM_ERR_LINE_LEN 5
-#define ENUM_ERR_WIDTH (ao_strs_strtable+329)
-#define ENUM_ERR_WIDTH_LEN 6
-#define EXPORT_ARG_FMT (ao_strs_strtable+336)
-#define EXPORT_ARG_FMT_LEN 17
-#define FALSE_STR (ao_strs_strtable+354)
-#define FALSE_STR_LEN 5
-#define FINISH_LOOP (ao_strs_strtable+2039)
-#define FINISH_LOOP_LEN 378
-#define FLAG_OPT_MARK (ao_strs_strtable+360)
-#define FLAG_OPT_MARK_LEN 9
-#define FLAG_STR (ao_strs_strtable+370)
-#define FLAG_STR_LEN 4
-#define INIT_LOPT_STR (ao_strs_strtable+2418)
-#define INIT_LOPT_STR_LEN 250
-#define INIT_OPT_STR (ao_strs_strtable+2669)
-#define INIT_OPT_STR_LEN 116
-#define INVALID_FMT (ao_strs_strtable+375)
-#define INVALID_FMT_LEN 10
-#define INVALID_STR (ao_strs_strtable+386)
-#define INVALID_STR_LEN 9
-#define LINE_SPLICE (ao_strs_strtable+396)
-#define LINE_SPLICE_LEN 4
-#define LONG_OPT_MARK (ao_strs_strtable+401)
-#define LONG_OPT_MARKER (ao_strs_strtable+412)
-#define LONG_OPT_MARKER_LEN 2
-#define LONG_OPT_MARK_LEN 10
-#define LONG_USE_STR (ao_strs_strtable+415)
-#define LONG_USE_STR_LEN 9
-#define LOOP_STR (ao_strs_strtable+2786)
-#define LOOP_STR_LEN 206
-#define LOPT_ARG_FMT (ao_strs_strtable+2993)
-#define LOPT_ARG_FMT_LEN 778
-#define LVL3_CMD (ao_strs_strtable+425)
-#define LVL3_CMD_LEN 15
-#define MK_STR_OCT_FMT (ao_strs_strtable+441)
-#define MK_STR_OCT_FMT_LEN 5
-#define MORE_STR (ao_strs_strtable+447)
-#define MORE_STR_LEN 4
-#define MULTI_ARG_FMT (ao_strs_strtable+3772)
-#define MULTI_ARG_FMT_LEN 123
-#define MULTI_DEF_FMT (ao_strs_strtable+3896)
-#define MULTI_DEF_FMT_LEN 157
-#define NESTED_OPT_FMT (ao_strs_strtable+452)
-#define NESTED_OPT_FMT_LEN 17
-#define NLSTR_FMT (ao_strs_strtable+470)
-#define NLSTR_FMT_LEN 3
-#define NLSTR_SPACE_FMT (ao_strs_strtable+474)
-#define NLSTR_SPACE_FMT_LEN 5
-#define NONE_STR (ao_strs_strtable+110)
-#define NONE_STR_LEN 4
-#define NOT_FOUND_STR (ao_strs_strtable+4054)
-#define NOT_FOUND_STR_LEN 56
-#define NO_ARG_NEEDED (ao_strs_strtable+480)
-#define NO_ARG_NEEDED_LEN 17
-#define NO_LOAD_WARN (ao_strs_strtable+1026)
-#define NO_LOAD_WARN_LEN 46
-#define NO_MULTI_ARG_FMT (ao_strs_strtable+4111)
-#define NO_MULTI_ARG_FMT_LEN 140
-#define NO_SAVE_OPTS (ao_strs_strtable+1073)
-#define NO_SAVE_OPTS_LEN 46
-#define NO_SGL_ARG_FMT (ao_strs_strtable+4252)
-#define NO_SGL_ARG_FMT_LEN 316
-#define NO_SUPPRESS_LOAD (ao_strs_strtable+1120)
-#define NO_SUPPRESS_LOAD_LEN 65
-#define NULL_ATR_FMT (ao_strs_strtable+498)
-#define NULL_ATR_FMT_LEN 6
-#define NUMB_ATR_FMT (ao_strs_strtable+1186)
-#define NUMB_ATR_FMT_LEN 34
-#define OK_NEED_OPT_ARG (ao_strs_strtable+505)
-#define OK_NEED_OPT_ARG_LEN 17
-#define ONE_TAB_STR (ao_strs_strtable+523)
-#define ONE_TAB_STR_LEN 1
-#define ONLY_OPTS_LOOP (ao_strs_strtable+4569)
-#define ONLY_OPTS_LOOP_LEN 102
-#define OPEN_CLOSE_FMT (ao_strs_strtable+498)
-#define OPEN_CLOSE_FMT_LEN 6
-#define OPEN_XML_FMT (ao_strs_strtable+525)
-#define OPEN_XML_FMT_LEN 4
-#define OPTION_STR (ao_strs_strtable+530)
-#define OPTION_STR_LEN 6
-#define OPT_ARG_FMT (ao_strs_strtable+4672)
-#define OPT_ARG_FMT_LEN 1153
-#define OPT_END_FMT (ao_strs_strtable+537)
-#define OPT_END_FMT_LEN 14
-#define OPT_VAL_FMT (ao_strs_strtable+552)
-#define OPT_VAL_FMT_LEN 6
-#define OR_STR (ao_strs_strtable+559)
-#define OR_STR_LEN 3
-#define PAGER_NAME (ao_strs_strtable+563)
-#define PAGER_NAME_LEN 5
-#define PAGE_USAGE_FMT (ao_strs_strtable+569)
-#define PAGE_USAGE_FMT_LEN 22
-#define PAGE_USAGE_TEXT (ao_strs_strtable+5826)
-#define PAGE_USAGE_TEXT_LEN 73
-#define PLUS_STR (ao_strs_strtable+592)
-#define PLUS_STR_LEN 3
-#define PREAMBLE_FMT (ao_strs_strtable+5900)
-#define PREAMBLE_FMT_LEN 105
-#define PUTS_FMT (ao_strs_strtable+596)
-#define PUTS_FMT_LEN 15
-#define QUOT_APOS (ao_strs_strtable+612)
-#define QUOT_APOS_LEN 2
-#define QUOT_ARG_FMT (ao_strs_strtable+615)
-#define QUOT_ARG_FMT_LEN 4
-#define SET_MULTI_ARG (ao_strs_strtable+6006)
-#define SET_MULTI_ARG_LEN 89
-#define SET_NO_TEXT_FMT (ao_strs_strtable+1221)
-#define SET_NO_TEXT_FMT_LEN 30
-#define SET_OFF_FMT (ao_strs_strtable+620)
-#define SET_OFF_FMT_LEN 6
-#define SET_TEXT_FMT (ao_strs_strtable+627)
-#define SET_TEXT_FMT_LEN 12
-#define SGL_ARG_FMT (ao_strs_strtable+6096)
-#define SGL_ARG_FMT_LEN 258
-#define SGL_DEF_FMT (ao_strs_strtable+6355)
-#define SGL_DEF_FMT_LEN 68
-#define SGL_NO_DEF_FMT (ao_strs_strtable+6424)
-#define SGL_NO_DEF_FMT_LEN 61
-#define SHELL_MAGIC (ao_strs_strtable+640)
-#define SHELL_MAGIC_LEN 6
-#define SHOW_PROG_ENV (ao_strs_strtable+647)
-#define SHOW_PROG_ENV_LEN 19
-#define SHOW_VAL_FMT (ao_strs_strtable+667)
-#define SHOW_VAL_FMT_LEN 17
-#define START_MARK (ao_strs_strtable+6486)
-#define START_MARK_LEN 82
-#define STDOUT (ao_strs_strtable+685)
-#define STDOUT_LEN 6
-#define TIME_FMT (ao_strs_strtable+692)
-#define TIME_FMT_LEN 21
-#define TMPDIR (ao_strs_strtable+714)
-#define TMPDIR_LEN 6
-#define TMP_FILE_FMT (ao_strs_strtable+721)
-#define TMP_FILE_FMT_LEN 16
-#define TMP_USAGE_FMT (ao_strs_strtable+721)
-#define TMP_USAGE_FMT_LEN 16
-#define TRUE_STR (ao_strs_strtable+738)
-#define TRUE_STR_LEN 4
-#define TWO_SPACES_STR (ao_strs_strtable+273)
-#define TWO_SPACES_STR_LEN 2
-#define TYPE_ATR_FMT (ao_strs_strtable+743)
-#define TYPE_ATR_FMT_LEN 12
-#define UNK_OPT_FMT (ao_strs_strtable+6569)
-#define UNK_OPT_FMT_LEN 144
-#define VER_STR (ao_strs_strtable+756)
-#define VER_STR_LEN 7
-#define XML_HEX_BYTE_FMT (ao_strs_strtable+764)
-#define XML_HEX_BYTE_FMT_LEN 7
-#define YES_NEED_OPT_ARG (ao_strs_strtable+772)
-#define YES_NEED_OPT_ARG_LEN 18
-#define ao_default_use (ao_strs_strtable+804)
-#define ao_default_use_LEN 11
-#define ao_name_use_fmt (ao_strs_strtable+791)
-#define ao_name_use_fmt_LEN 12
-#define apostrophe (ao_strs_strtable+816)
-#define apostrophe_LEN 4
-#define arg_fmt (ao_strs_strtable+821)
-#define arg_fmt_LEN 5
-#define init_optct (ao_strs_strtable+864)
-#define init_optct_LEN 13
-#define misguess_len (ao_strs_strtable+827)
-#define misguess_len_LEN 36
-#define set_dash (ao_strs_strtable+878)
-#define set_dash_LEN 6
-#define tmp_dir (ao_strs_strtable+885)
-#define tmp_dir_LEN 4
-#define zAll (ao_strs_strtable+276)
-#define zAll_LEN 3
-#define zCfgAO_Flags (ao_strs_strtable+12)
-#define zCfgAO_Flags_LEN 14
-#define zCfgProg (ao_strs_strtable+27)
-#define zCfgProg_LEN 9
-#define zEquivMode (ao_strs_strtable+1252)
-#define zEquivMode_LEN 44
-#define zFiveSpaces (ao_strs_strtable+263)
-#define zFiveSpaces_LEN 5
-#define zFmtFmt (ao_strs_strtable+37)
-#define zFmtFmt_LEN 11
-#define zFmtProg (ao_strs_strtable+49)
-#define zFmtProg_LEN 14
-#define zFullOptFmt (ao_strs_strtable+1297)
-#define zFullOptFmt_LEN 34
-#define zGnuBreak (ao_strs_strtable+64)
-#define zGnuBreak_LEN 5
-#define zGnuFileArg (ao_strs_strtable+70)
-#define zGnuFileArg_LEN 5
-#define zGnuKeyLArg (ao_strs_strtable+76)
-#define zGnuKeyLArg_LEN 4
-#define zGnuNestArg (ao_strs_strtable+81)
-#define zGnuNestArg_LEN 5
-#define zGnuOptArg (ao_strs_strtable+87)
-#define zGnuOptArg_LEN 6
-#define zGnuOptFmt (ao_strs_strtable+94)
-#define zGnuOptFmt_LEN 10
-#define zGnuTimeArg (ao_strs_strtable+105)
-#define zGnuTimeArg_LEN 4
-#define zNone (ao_strs_strtable+110)
-#define zNone_LEN 4
-#define zOptCookieCt (ao_strs_strtable+1332)
-#define zOptCookieCt_LEN 38
-#define zOptCtFmt (ao_strs_strtable+1371)
-#define zOptCtFmt_LEN 30
-#define zOptDisabl (ao_strs_strtable+1402)
-#define zOptDisabl_LEN 32
-#define zOptNumFmt (ao_strs_strtable+1435)
-#define zOptNumFmt_LEN 41
-#define zOptionCase (ao_strs_strtable+1477)
-#define zOptionCase_LEN 30
-#define zOptionEndSelect (ao_strs_strtable+890)
-#define zOptionEndSelect_LEN 16
-#define zOptionFlag (ao_strs_strtable+907)
-#define zOptionFlag_LEN 15
-#define zOptionFullName (ao_strs_strtable+923)
-#define zOptionFullName_LEN 15
-#define zOptionPartName (ao_strs_strtable+939)
-#define zOptionPartName_LEN 17
-#define zPresetFile (ao_strs_strtable+115)
-#define zPresetFile_LEN 37
-#define zReqOptFmt (ao_strs_strtable+153)
-#define zReqOptFmt_LEN 13
-#define zSepChars (ao_strs_strtable+0)
-#define zSepChars_LEN 3
-#define zShrtGnuOptFmt (ao_strs_strtable+167)
-#define zShrtGnuOptFmt_LEN 2
-#define zSixSpaces (ao_strs_strtable+256)
-#define zSixSpaces_LEN 6
-#define zStdBoolArg (ao_strs_strtable+170)
-#define zStdBoolArg_LEN 3
-#define zStdBreak (ao_strs_strtable+174)
-#define zStdBreak_LEN 7
-#define zStdFileArg (ao_strs_strtable+182)
-#define zStdFileArg_LEN 3
-#define zStdKeyArg (ao_strs_strtable+186)
-#define zStdKeyArg_LEN 3
-#define zStdKeyLArg (ao_strs_strtable+190)
-#define zStdKeyLArg_LEN 3
-#define zStdNestArg (ao_strs_strtable+194)
-#define zStdNestArg_LEN 3
-#define zStdNoArg (ao_strs_strtable+198)
-#define zStdNoArg_LEN 3
-#define zStdNumArg (ao_strs_strtable+202)
-#define zStdNumArg_LEN 3
-#define zStdOptArg (ao_strs_strtable+206)
-#define zStdOptArg_LEN 3
-#define zStdReqArg (ao_strs_strtable+210)
-#define zStdReqArg_LEN 3
-#define zStdStrArg (ao_strs_strtable+214)
-#define zStdStrArg_LEN 3
-#define zStdTimeArg (ao_strs_strtable+218)
-#define zStdTimeArg_LEN 3
-#define zTabHyp (ao_strs_strtable+222)
-#define zTabHypAnd (ao_strs_strtable+236)
-#define zTabHypAnd_LEN 11
-#define zTabHyp_LEN 6
-#define zTabSpace (ao_strs_strtable+229)
-#define zTabSpace_LEN 6
-#define zTabout (ao_strs_strtable+248)
-#define zTabout_LEN 7
-#define zThreeSpaces (ao_strs_strtable+269)
-#define zThreeSpaces_LEN 3
-#define zTwoSpaces (ao_strs_strtable+273)
-#define zTwoSpaces_LEN 2
-#define zambig_file (ao_strs_strtable+4)
-#define zambig_file_LEN 7
-extern char const ao_strs_strtable[6714];
-
-#endif /* STRINGS_AO_STRS_H_GUARD */
diff --git a/src/libopts/autoopts.c b/src/libopts/autoopts.c
deleted file mode 100644
index 643d277239..0000000000
--- a/src/libopts/autoopts.c
+++ /dev/null
@@ -1,391 +0,0 @@
-
-/**
- * \file autoopts.c
- *
- * This file contains all of the routines that must be linked into
- * an executable to use the generated option processing. The optional
- * routines are in separately compiled modules so that they will not
- * necessarily be linked in.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-/**
- * The number of tab characters to skip when printing continuation lines.
- */
- static unsigned int tab_skip_ct = 0;
-
-#ifndef HAVE_PATHFIND
-# define pathfind(_p, _n, _m) option_pathfind(_p, _n, _m)
-# include "compat/pathfind.c"
-#endif
-
-#ifndef HAVE_SNPRINTF
-# define vsnprintf option_vsnprintf
-# define snprintf option_snprintf
-# include "compat/snprintf.c"
-#endif
-
-#ifndef HAVE_STRDUP
-# define strdup(_s) option_strdup(_s)
-# include "compat/strdup.c"
-#endif
-
-#ifndef HAVE_STRCHR
-# define strrchr(_s, _c) option_strrchr(_s, _c)
-# define strchr(_s, _c) option_strchr(_s, _c)
-# include "compat/strchr.c"
-#endif
-
-static void *
-ao_malloc(size_t sz)
-{
- void * res = malloc(sz);
- if (res == NULL) {
- fprintf(stderr, zalloc_fail, (int)sz);
- option_exits(EXIT_FAILURE);
- }
- return res;
-}
-
-static void *
-ao_realloc(void *p, size_t sz)
-{
- void * res = (p == NULL) ? malloc(sz) : realloc(p, sz);
- if (res == NULL) {
- fprintf(stderr, zrealloc_fail, (int)sz, p);
- option_exits(EXIT_FAILURE);
- }
- return res;
-}
-
-static char *
-ao_strdup(char const *str)
-{
- char * res = strdup(str);
- if (res == NULL) {
- fprintf(stderr, zalloc_fail, (int)strlen(str));
- option_exits(EXIT_FAILURE);
- }
- return res;
-}
-
-/**
- * handle an option.
- *
- * This routine handles equivalencing, sets the option state flags and
- * invokes the handler procedure, if any.
- */
-static tSuccess
-handle_opt(tOptions * opts, tOptState * o_st)
-{
- /*
- * Save a copy of the option procedure pointer.
- * If this is an equivalence class option, we still want this proc.
- */
- tOptDesc * od = o_st->pOD;
- tOptProc * opt_proc = od->pOptProc;
- if (od->fOptState & OPTST_ALLOC_ARG)
- AGFREE(od->optArg.argString);
-
- od->optArg.argString = o_st->pzOptArg;
-
- /*
- * IF we are presetting options, then we will ignore any un-presettable
- * options. They are the ones either marked as such.
- */
- if ( ((opts->fOptSet & OPTPROC_PRESETTING) != 0)
- && ((od->fOptState & OPTST_NO_INIT) != 0)
- )
- return PROBLEM;
-
- /*
- * IF this is an equivalence class option,
- * THEN
- * Save the option value that got us to this option
- * entry. (It may not be od->optChar[0], if this is an
- * equivalence entry.)
- * set the pointer to the equivalence class base
- */
- if (od->optEquivIndex != NO_EQUIVALENT) {
- tOptDesc * eqv_od = opts->pOptDesc + od->optEquivIndex;
-
- /*
- * IF the current option state has not been defined (set on the
- * command line), THEN we will allow continued resetting of
- * the value. Once "defined", then it must not change.
- */
- if ((od->fOptState & OPTST_DEFINED) != 0) {
- /*
- * The equivalenced-to option has been found on the command
- * line before. Make sure new occurrences are the same type.
- *
- * IF this option has been previously equivalenced and
- * it was not the same equivalenced-to option,
- * THEN we have a usage problem.
- */
- if (eqv_od->optActualIndex != od->optIndex) {
- fprintf(stderr, zmultiway_bug, eqv_od->pz_Name, od->pz_Name,
- (opts->pOptDesc + eqv_od->optActualIndex)->pz_Name);
- return FAILURE;
- }
- } else {
- /*
- * Set the equivalenced-to actual option index to no-equivalent
- * so that we set all the entries below. This option may either
- * never have been selected before, or else it was selected by
- * some sort of "presetting" mechanism.
- */
- eqv_od->optActualIndex = NO_EQUIVALENT;
- }
-
- if (eqv_od->optActualIndex != od->optIndex) {
- /*
- * First time through, copy over the state
- * and add in the equivalence flag
- */
- eqv_od->optActualValue = od->optValue;
- eqv_od->optActualIndex = od->optIndex;
- o_st->flags |= OPTST_EQUIVALENCE;
- }
-
- /*
- * Copy the most recent option argument. set membership state
- * is kept in 'eqv_od->optCookie'. Do not overwrite.
- */
- eqv_od->optArg.argString = od->optArg.argString;
- od = eqv_od;
-
- } else {
- od->optActualValue = od->optValue;
- od->optActualIndex = od->optIndex;
- }
-
- od->fOptState &= OPTST_PERSISTENT_MASK;
- od->fOptState |= (o_st->flags & ~OPTST_PERSISTENT_MASK);
-
- /*
- * Keep track of count only for DEFINED (command line) options.
- * IF we have too many, build up an error message and bail.
- */
- if ( (od->fOptState & OPTST_DEFINED)
- && (++od->optOccCt > od->optMaxCt) )
- return too_many_occurrences(opts, od);
- /*
- * If provided a procedure to call, call it
- */
- if (opt_proc != NULL)
- (*opt_proc)(opts, od);
-
- return SUCCESS;
-}
-
-/**
- * Find the option descriptor and option argument (if any) for the
- * next command line argument. DO NOT modify the descriptor. Put
- * all the state in the state argument so that the option can be skipped
- * without consequence (side effect).
- *
- * @param opts the program option descriptor
- * @param o_st the state of the next found option
- */
-static tSuccess
-next_opt(tOptions * opts, tOptState * o_st)
-{
- {
- tSuccess res = find_opt(opts, o_st);
- if (! SUCCESSFUL(res))
- return res;
- }
-
- if ( ((o_st->flags & OPTST_DEFINED) != 0)
- && ((o_st->pOD->fOptState & OPTST_NO_COMMAND) != 0)) {
- fprintf(stderr, zNotCmdOpt, o_st->pOD->pz_Name);
- return FAILURE;
- }
-
- return get_opt_arg(opts, o_st);
-}
-
-/**
- * Process all the options from our current position onward. (This allows
- * interspersed options and arguments for the few non-standard programs that
- * require it.) Thus, do not rewind option indexes because some programs
- * choose to re-invoke after a non-option.
- *
- * @param[in,out] opts program options descriptor
- * @returns SUCCESS or FAILURE
- */
-static tSuccess
-regular_opts(tOptions * opts)
-{
- /* assert: opts->fOptSet & OPTPROC_IMMEDIATE == 0 */
- for (;;) {
- tOptState opt_st = OPTSTATE_INITIALIZER(DEFINED);
-
- switch (next_opt(opts, &opt_st)) {
- case FAILURE: goto failed_option;
- case PROBLEM: return SUCCESS; /* no more args */
- case SUCCESS: break;
- }
-
- /*
- * IF this is an immediate action option,
- * THEN skip it (unless we are supposed to do it a second time).
- */
- if (! DO_NORMALLY(opt_st.flags)) {
- if (! DO_SECOND_TIME(opt_st.flags))
- continue;
- opt_st.pOD->optOccCt--; /* don't count this repetition */
- }
-
- if (! SUCCESSFUL(handle_opt(opts, &opt_st)))
- break;
- } failed_option:;
-
- if ((opts->fOptSet & OPTPROC_ERRSTOP) != 0)
- (*opts->pUsageProc)(opts, EXIT_FAILURE);
-
- return FAILURE;
-}
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *
- * THESE ROUTINES ARE CALLABLE FROM THE GENERATED OPTION PROCESSING CODE
- */
-/*=--subblock=arg=arg_type,arg_name,arg_desc =*/
-/*=*
- * library: opts
- * header: your-opts.h
- *
- * lib_description:
- *
- * These are the routines that libopts users may call directly from their
- * code. There are several other routines that can be called by code
- * generated by the libopts option templates, but they are not to be
- * called from any other user code. The @file{options.h} header is
- * fairly clear about this, too.
-=*/
-
-/*=export_func optionProcess
- *
- * what: this is the main option processing routine
- *
- * arg: + tOptions * + opts + program options descriptor +
- * arg: + int + a_ct + program arg count +
- * arg: + char ** + a_v + program arg vector +
- *
- * ret_type: int
- * ret_desc: the count of the arguments processed
- *
- * doc:
- *
- * This is the main entry point for processing options. It is intended
- * that this procedure be called once at the beginning of the execution of
- * a program. Depending on options selected earlier, it is sometimes
- * necessary to stop and restart option processing, or to select completely
- * different sets of options. This can be done easily, but you generally
- * do not want to do this.
- *
- * The number of arguments processed always includes the program name.
- * If one of the arguments is "--", then it is counted and the processing
- * stops. If an error was encountered and errors are to be tolerated, then
- * the returned value is the index of the argument causing the error.
- * A hyphen by itself ("-") will also cause processing to stop and will
- * @emph{not} be counted among the processed arguments. A hyphen by itself
- * is treated as an operand. Encountering an operand stops option
- * processing.
- *
- * err: Errors will cause diagnostics to be printed. @code{exit(3)} may
- * or may not be called. It depends upon whether or not the options
- * were generated with the "allow-errors" attribute, or if the
- * ERRSKIP_OPTERR or ERRSTOP_OPTERR macros were invoked.
-=*/
-int
-optionProcess(tOptions * opts, int a_ct, char ** a_v)
-{
- if (! SUCCESSFUL(validate_struct(opts, a_v[0])))
- ao_bug(zbad_data_msg);
-
- /*
- * Establish the real program name, the program full path,
- * and do all the presetting the first time thru only.
- */
- if (! ao_initialize(opts, a_ct, a_v))
- return 0;
-
- /*
- * IF we are (re)starting,
- * THEN reset option location
- */
- if (opts->curOptIdx <= 0) {
- opts->curOptIdx = 1;
- opts->pzCurOpt = NULL;
- }
-
- if (! SUCCESSFUL(regular_opts(opts)))
- return (int)opts->origArgCt;
-
- /*
- * IF there were no errors
- * AND we have RC/INI files
- * AND there is a request to save the files
- * THEN do that now before testing for conflicts.
- * (conflicts are ignored in preset options)
- */
- switch (opts->specOptIdx.save_opts) {
- case 0:
- case NO_EQUIVALENT:
- break;
- default:
- {
- tOptDesc * od = opts->pOptDesc + opts->specOptIdx.save_opts;
-
- if (SELECTED_OPT(od)) {
- optionSaveFile(opts);
- option_exits(EXIT_SUCCESS);
- }
- }
- }
-
- /*
- * IF we are checking for errors,
- * THEN look for too few occurrences of required options
- */
- if (((opts->fOptSet & OPTPROC_ERRSTOP) != 0)
- && (! is_consistent(opts)))
- (*opts->pUsageProc)(opts, EXIT_FAILURE);
-
- return (int)opts->curOptIdx;
-}
-
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/autoopts.c */
diff --git a/src/libopts/autoopts.h b/src/libopts/autoopts.h
deleted file mode 100644
index 36bb43f29d..0000000000
--- a/src/libopts/autoopts.h
+++ /dev/null
@@ -1,494 +0,0 @@
-
-/*
- * \file autoopts.h
- *
- * This file defines all the global structures and special values
- * used in the automated option processing library.
- *
- * @group autoopts
- * @{
- */
-/*
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-#ifndef AUTOGEN_AUTOOPTS_H
-#define AUTOGEN_AUTOOPTS_H
-#include <stdnoreturn.h>
-
-#define AO_NAME_LIMIT 127
-#define AO_NAME_SIZE ((size_t)(AO_NAME_LIMIT + 1))
-
-#ifndef AG_PATH_MAX
-# ifdef PATH_MAX
-# define AG_PATH_MAX ((size_t)PATH_MAX)
-# else
-# ifdef __gnu_hurd__
-# define size_t unsigned long
-# endif
-# define AG_PATH_MAX ((size_t)4096)
-# endif
-#else
-# if defined(PATH_MAX) && (PATH_MAX > MAXPATHLEN)
-# undef AG_PATH_MAX
-# define AG_PATH_MAX ((size_t)PATH_MAX)
-# endif
-#endif
-
-#undef EXPORT
-#define EXPORT
-
-#ifndef NUL
-#define NUL '\0'
-#endif
-#define BEL '\a'
-#define BS '\b'
-#define HT '\t'
-#define LF '\n'
-#define VT '\v'
-#define FF '\f'
-#define CR '\r'
-
-#if defined(_WIN32) && !defined(__CYGWIN__)
-# define DIRCH '\\'
-#else
-# define DIRCH '/'
-#endif
-
-#ifndef EX_USAGE
- /**
- * Command line usage problem
- */
-# define EX_USAGE 64
-#endif
-#ifndef EX_DATAERR
- /**
- * The input data was incorrect in some way.
- */
-# define EX_DATAERR 64
-#endif
-#ifndef EX_NOINPUT
- /**
- * option state was requested from a file that cannot be loaded.
- */
-# define EX_NOINPUT 66
-#endif
-#ifndef EX_SOFTWARE
- /**
- * AutoOpts Software failure.
- */
-# define EX_SOFTWARE 70
-#endif
-#ifndef EX_OSERR
- /**
- * Command line usage problem
- */
-# define EX_OSERR 71
-#endif
-
-#define NL '\n'
-#ifndef C
-/**
- * Coercive cast. Compel an address to be interpreted as the type
- * of the first argument. No complaints, just do it.
- */
-#define C(_t,_p) ((_t)VOIDP(_p))
-#endif
-
-/* The __attribute__((__warn_unused_result__)) feature
- is available in gcc versions 3.4 and newer,
- while the typeof feature has been available since 2.7 at least. */
-# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4)
-# define ignore_val(x) ((void) (x))
-# else
-# define ignore_val(x) (({ __typeof__ (x) __x = (x); (void) __x; }))
-# endif
-
-/*
- * Convert the number to a list usable in a printf call
- */
-#define NUM_TO_VER(n) ((n) >> 12), ((n) >> 7) & 0x001F, (n) & 0x007F
-
-#define NAMED_OPTS(po) \
- (((po)->fOptSet & (OPTPROC_SHORTOPT | OPTPROC_LONGOPT)) == 0)
-
-#define SKIP_OPT(p) (((p)->fOptState & OPTST_IMMUTABLE_MASK) != 0)
-
-typedef int tDirection;
-/**
- * handling option presets. Start with command line and work through
- * config settings in reverse order.
- */
-#define DIRECTION_PRESET -1
-/**
- * handling normal options. Start with first config file, then environment
- * variables and finally the command line.
- */
-#define DIRECTION_PROCESS 1
-/**
- * An initialzation phase or an option being loaded from program sources.
- */
-#define DIRECTION_CALLED 0
-
-#define PROCESSING(d) ((d)>0)
-#define PRESETTING(d) ((d)<0)
-#define CALLED(d) ((d)==0)
-
-/**
- * When loading a line (or block) of text as an option, the value can
- * be processed in any of several modes.
- */
-typedef enum {
- /**
- * If the value looks like a quoted string, then process it. Double
- * quoted strings are processed the way strings are in "C" programs,
- * except they are treated as regular characters if the following
- * character is not a well-established escape sequence. Single quoted
- * strings (quoted with apostrophies) are handled the way strings are
- * handled in shell scripts, *except* that backslash escapes are
- * honored before backslash escapes and apostrophies.
- */
- OPTION_LOAD_COOKED,
-
- /**
- * Even if the value begins with quote characters, do not do quote
- * processing. Strip leading and trailing white space.
- */
- OPTION_LOAD_UNCOOKED,
-
- /**
- * Keep every part of the value between the delimiters.
- */
- OPTION_LOAD_KEEP
-} tOptionLoadMode;
-
-static tOptionLoadMode option_load_mode;
-
-/**
- * The pager state is used by optionPagedUsage() procedure.
- * When it runs, it sets itself up to be called again on exit.
- * If, however, a routine needs a child process to do some work
- * before it is done, then 'pagerState' must be set to
- * 'PAGER_STATE_CHILD' so that optionPagedUsage() will not try
- * to run the pager program before its time.
- */
-typedef enum {
- PAGER_STATE_INITIAL, //@< initial option paging state
-
- /**
- * temp file created and optionPagedUsage is scheduled to run at exit
- */
- PAGER_STATE_READY,
-
- /**
- * This is a child process used in creating shell script usage.
- */
- PAGER_STATE_CHILD
-} tePagerState;
-
-typedef enum {
- ENV_ALL,
- ENV_IMM,
- ENV_NON_IMM
-} teEnvPresetType;
-
-typedef enum {
- TOPT_UNDEFINED = 0,
- TOPT_SHORT,
- TOPT_LONG,
- TOPT_DEFAULT
-} teOptType;
-
-typedef struct {
- tOptDesc * pOD;
- char const * pzOptArg;
- opt_state_mask_t flags;
- teOptType optType;
-} tOptState;
-#define OPTSTATE_INITIALIZER(st) \
- { NULL, NULL, OPTST_ ## st, TOPT_UNDEFINED }
-
-#define TEXTTO_TABLE \
- _TT_(LONGUSAGE) \
- _TT_(USAGE) \
- _TT_(VERSION)
-#define _TT_(n) \
- TT_ ## n ,
-
-typedef enum { TEXTTO_TABLE COUNT_TT } teTextTo;
-
-#undef _TT_
-
-/**
- * option argument types. Used to create usage information for
- * particular options.
- */
-typedef struct {
- char const * pzStr;
- char const * pzReq;
- char const * pzNum;
- char const * pzFile;
- char const * pzKey;
- char const * pzKeyL;
- char const * pzBool;
- char const * pzNest;
- char const * pzOpt;
- char const * pzNo;
- char const * pzBrk;
- char const * pzNoF;
- char const * pzSpc;
- char const * pzOptFmt;
- char const * pzTime;
-} arg_types_t;
-
-#define AGALOC(_c, _w) ao_malloc((size_t)_c)
-#define AGREALOC(_p, _c, _w) ao_realloc(VOIDP(_p), (size_t)_c)
-#define AGFREE(_p) free(VOIDP(_p))
-#define AGDUPSTR(_p, _s, _w) (_p = ao_strdup(_s))
-
-static void *
-ao_malloc(size_t sz);
-
-static void *
-ao_realloc(void *p, size_t sz);
-
-#define ao_free(_p) free(VOIDP(_p))
-
-static char *
-ao_strdup(char const * str);
-
-/**
- * DO option handling?
- *
- * Options are examined at two times: at immediate handling time and at
- * normal handling time. If an option is disabled, the timing may be
- * different from the handling of the undisabled option. The OPTST_DIABLED
- * bit indicates the state of the currently discovered option.
- * So, here's how it works:
- *
- * A) handling at "immediate" time, either 1 or 2:
- *
- * 1. OPTST_DISABLED is not set:
- * IMM must be set
- * DISABLE_IMM don't care
- * TWICE don't care
- * DISABLE_TWICE don't care
- * 0 -and- 1 x x x
- *
- * 2. OPTST_DISABLED is set:
- * IMM don't care
- * DISABLE_IMM must be set
- * TWICE don't care
- * DISABLE_TWICE don't care
- * 1 -and- x 1 x x
- */
-#define DO_IMMEDIATELY(_flg) \
- ( (((_flg) & (OPTST_DISABLED|OPTST_IMM)) == OPTST_IMM) \
- || ( ((_flg) & (OPTST_DISABLED|OPTST_DISABLE_IMM)) \
- == (OPTST_DISABLED|OPTST_DISABLE_IMM) ))
-
-/**
- * B) handling at "regular" time because it was not immediate
- *
- * 1. OPTST_DISABLED is not set:
- * IMM must *NOT* be set
- * DISABLE_IMM don't care
- * TWICE don't care
- * DISABLE_TWICE don't care
- * 0 -and- 0 x x x
- *
- * 2. OPTST_DISABLED is set:
- * IMM don't care
- * DISABLE_IMM don't care
- * TWICE must be set
- * DISABLE_TWICE don't care
- * 1 -and- x x 1 x
- */
-#define DO_NORMALLY(_flg) ( \
- (((_flg) & (OPTST_DISABLED|OPTST_IMM)) == 0) \
- || (((_flg) & (OPTST_DISABLED|OPTST_DISABLE_IMM)) == \
- OPTST_DISABLED) )
-
-/**
- * C) handling at "regular" time because it is to be handled twice.
- * The immediate bit was already tested and found to be set:
- *
- * 3. OPTST_DISABLED is not set:
- * IMM is set (but don't care)
- * DISABLE_IMM don't care
- * TWICE must be set
- * DISABLE_TWICE don't care
- * 0 -and- ? x 1 x
- *
- * 4. OPTST_DISABLED is set:
- * IMM don't care
- * DISABLE_IMM is set (but don't care)
- * TWICE don't care
- * DISABLE_TWICE must be set
- * 1 -and- x ? x 1
- */
-#define DO_SECOND_TIME(_flg) ( \
- (((_flg) & (OPTST_DISABLED|OPTST_TWICE)) == \
- OPTST_TWICE) \
- || (((_flg) & (OPTST_DISABLED|OPTST_DISABLE_TWICE)) == \
- (OPTST_DISABLED|OPTST_DISABLE_TWICE) ))
-
-/*
- * text_mmap structure. Only active on platforms with mmap(2).
- */
-#ifdef HAVE_SYS_MMAN_H
-# include <sys/mman.h>
-#else
-# ifndef PROT_READ
-# define PROT_READ 0x01
-# endif
-# ifndef PROT_WRITE
-# define PROT_WRITE 0x02
-# endif
-# ifndef MAP_SHARED
-# define MAP_SHARED 0x01
-# endif
-# ifndef MAP_PRIVATE
-# define MAP_PRIVATE 0x02
-# endif
-#endif
-
-#ifndef MAP_FAILED
-# define MAP_FAILED VOIDP(-1)
-#endif
-
-#ifndef _SC_PAGESIZE
-# ifdef _SC_PAGE_SIZE
-# define _SC_PAGESIZE _SC_PAGE_SIZE
-# endif
-#endif
-
-#ifndef HAVE_STRCHR
-extern char * strchr(char const * s, int c);
-extern char * strrchr(char const * s, int c);
-#endif
-
-/**
- * INQUERY_CALL() tests whether the option handling function has been
- * called by an inquery (help text needed, or option being reset),
- * or called by a set-the-option operation.
- */
-#define INQUERY_CALL(_o, _d) ( \
- ((_o) <= OPTPROC_EMIT_LIMIT) \
- || ((_d) == NULL) \
- || (((_d)->fOptState & OPTST_RESET) != 0) )
-
-/**
- * Define and initialize all the user visible strings.
- * We do not do translations. If translations are to be done, then
- * the client will provide a callback for that purpose.
- */
-#undef DO_TRANSLATIONS
-#include "autoopts/usage-txt.h"
-
-/**
- * File pointer for usage output
- */
-FILE * option_usage_fp;
-/**
- * If provided in the option structure
- */
-static char const * program_pkgdatadir;
-/**
- * privately exported functions
- */
-extern tOptProc optionPrintVersion, optionPagedUsage, optionLoadOpt;
-
-#ifdef AUTOOPTS_INTERNAL
-
-#ifndef PKGDATADIR
-# define PKGDATADIR ""
-#endif
-#define APOSTROPHE '\''
-
-#define OPTPROC_L_N_S (OPTPROC_LONGOPT | OPTPROC_SHORTOPT)
-#if defined(ENABLE_NLS) && defined(HAVE_LIBINTL_H)
-# include <libintl.h>
-#endif
-
-typedef struct {
- size_t fnm_len;
- uint32_t fnm_mask;
- char const * fnm_name;
-} ao_flag_names_t;
-
-/**
- * Automated Options Usage Flags.
- * NB: no entry may be a prefix of another entry
- */
-#define AOFLAG_TABLE \
- _aof_(gnu, OPTPROC_GNUUSAGE ) \
- _aof_(autoopts, ~OPTPROC_GNUUSAGE) \
- _aof_(no_misuse_usage, OPTPROC_MISUSE ) \
- _aof_(misuse_usage, ~OPTPROC_MISUSE ) \
- _aof_(compute, OPTPROC_COMPUTE )
-
-#define _aof_(_n, _f) AOUF_ ## _n ## _ID,
-typedef enum { AOFLAG_TABLE AOUF_COUNT } ao_flag_id_t;
-#undef _aof_
-
-#define _aof_(_n, _f) AOUF_ ## _n = (1 << AOUF_ ## _n ## _ID),
-typedef enum { AOFLAG_TABLE } ao_flags_t;
-#undef _aof_
-
-static char const zNil[] = "";
-static arg_types_t argTypes = { NULL };
-static char line_fmt_buf[32];
-static bool displayEnum = false;
-static char const pkgdatadir_default[] = PKGDATADIR;
-static char const * program_pkgdatadir = pkgdatadir_default;
-static tOptionLoadMode option_load_mode = OPTION_LOAD_UNCOOKED;
-static tePagerState pagerState = PAGER_STATE_INITIAL;
-
-static noreturn void option_exits(int exit_code);
-static noreturn void fserr_exit(char const * prog, char const * op,
- char const * fname);
-static void fserr_warn(char const * prog, char const * op,
- char const * fname);
-static noreturn void ao_bug(char const * msg);
-
- FILE * option_usage_fp = NULL;
-
-static char const * pz_enum_err_fmt;
-
-tOptions * optionParseShellOptions = NULL;
-
-static char const * shell_prog = NULL;
-static char * script_leader = NULL;
-static char * script_trailer = NULL;
-static char * script_text = NULL;
-static bool print_exit = false;
-#endif /* AUTOOPTS_INTERNAL */
-
-#endif /* AUTOGEN_AUTOOPTS_H */
-/**
- * @}
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/autoopts.h */
diff --git a/src/libopts/autoopts/options.h b/src/libopts/autoopts/options.h
deleted file mode 100644
index 08dc546214..0000000000
--- a/src/libopts/autoopts/options.h
+++ /dev/null
@@ -1,1263 +0,0 @@
-/* -*- buffer-read-only: t -*- vi: set ro:
- *
- * DO NOT EDIT THIS FILE (options.h)
- *
- * It has been AutoGen-ed
- * From the definitions funcs.def
- * and the template file options_h
- *
- * This file defines all the global structures and special values
- * used in the automated option processing library.
- *
- * Automated Options Copyright (C) 1992-2018 by Bruce Korb
- *
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-#ifndef AUTOOPTS_OPTIONS_H_GUARD
-#define AUTOOPTS_OPTIONS_H_GUARD 1
-/** \file options.h
- *
- * @addtogroup autoopts
- * @{
- */
-#include <sys/types.h>
-#include <stdio.h>
-
-#ifndef COMPAT_H_GUARD
-/*
- * This is needed for test compilations where the "compat.h"
- * header is not usually available.
- */
-# if defined(HAVE_STDINT_H)
-# include <stdint.h>
-# elif defined(HAVE_INTTYPES_H)
-# include <inttypes.h>
-# endif /* HAVE_STDINT/INTTYPES_H */
-
-# if defined(HAVE_LIMITS_H)
-# include <limits.h>
-# elif defined(HAVE_SYS_LIMITS_H)
-# include <sys/limits.h>
-# endif /* HAVE_LIMITS/SYS_LIMITS_H */
-
-# if defined(HAVE_SYSEXITS_H)
-# include <sysexits.h>
-# endif /* HAVE_SYSEXITS_H */
-
-# if defined(HAVE_STDBOOL_H)
-# include <stdbool.h>
-# elif ! defined(bool)
- typedef enum { false = 0, true = 1 } _Bool;
-# define bool _Bool
-
- /* The other macros must be usable in preprocessor directives. */
-# define false 0
-# define true 1
-# endif /* HAVE_SYSEXITS_H */
-#endif /* COMPAT_H_GUARD */
-// END-CONFIGURED-HEADERS
-
-/**
- * Defined to abnormal value of EX_USAGE. Used to indicate that paged usage
- * was requested. It is used to distinguish a --usage from a --help request.
- * --usage is abbreviated and --help gives as much help as possible.
- */
-#define AO_EXIT_REQ_USAGE 10064
-
-#undef VOIDP
-/**
- * Coerce a value into a void pointer with no const or volatile attributes.
- * Somewhere along the line, the above set of includes need to set up
- * the "uintptr_t" type.
- */
-#define VOIDP(_a) ((void *)(uintptr_t)(_a))
-
-/**
- * PUBLIC DEFINES
- *
- * The following defines may be used in applications that need to test the
- * state of an option. To test against these masks and values, a pointer
- * to an option descriptor must be obtained. There are two ways:
- *
- * 1. inside an option processing procedure, it is the second argument,
- * conventionally "tOptDesc * pOD".
- *
- * 2. Outside of an option procedure (or to reference a different option
- * descriptor), use either "&DESC( opt_name )" or "&pfx_DESC( opt_name )".
- *
- * See the relevant generated header file to determine which and what
- * values for "opt_name" are available.
- * @group version
- * @{
- */
-/// autoopts structure version
-#define OPTIONS_STRUCT_VERSION 172033
-/// autoopts structure version string
-#define OPTIONS_VERSION_STRING "42:1:17"
-/// minimum version the autoopts library supports
-#define OPTIONS_MINIMUM_VERSION 102400
-/// minimum version the autoopts library supports as a string
-#define OPTIONS_MIN_VER_STRING "25:0:0"
-/// the display version of the autoopts library, as a string
-#define OPTIONS_DOTTED_VERSION "42.1"
-/// convert a version/release number pair to an integer value
-#define OPTIONS_VER_TO_NUM(_v, _r) (((_v) * 4096) + (_r))
-/// @}
-
-/**
- * Option argument types. This must fit in the OPTST_ARG_TYPE_MASK
- * field of the fOptState field of an option descriptor (tOptDesc).
- * It will be a problem to extend beyond 4 bits.
- */
-typedef enum {
- OPARG_TYPE_NONE = 0, ///< does not take an argument
- OPARG_TYPE_STRING = 1, ///< default type/ vanilla string
- OPARG_TYPE_ENUMERATION = 2, ///< opt arg is an enum (keyword list)
- OPARG_TYPE_BOOLEAN = 3, ///< opt arg is boolean-valued
- OPARG_TYPE_MEMBERSHIP = 4, ///< opt arg sets set membership bits
- OPARG_TYPE_NUMERIC = 5, ///< opt arg is a long int
- OPARG_TYPE_HIERARCHY = 6, ///< option arg is hierarchical value
- OPARG_TYPE_FILE = 7, ///< option arg names a file
- OPARG_TYPE_TIME = 8, ///< opt arg is a time duration
- OPARG_TYPE_FLOAT = 9, ///< opt arg is a floating point num
- OPARG_TYPE_DOUBLE = 10, ///< opt arg is a double prec. float
- OPARG_TYPE_LONG_DOUBLE = 11, ///< opt arg is a long double prec.
- OPARG_TYPE_LONG_LONG = 12, ///< opt arg is a long long int
- OPARG_TYPE_STATIC = 13 ///<
-} teOptArgType;
-
-/**
- * value descriptor for sub options
- */
-typedef struct optionValue {
- teOptArgType valType; ///< which argument type
- char * pzName; ///< name of the sub-option
- union {
- char strVal[1]; ///< OPARG_TYPE_STRING
- unsigned int enumVal; ///< OPARG_TYPE_ENUMERATION
- unsigned int boolVal; ///< OPARG_TYPE_BOOLEAN
- unsigned long setVal; ///< OPARG_TYPE_MEMBERSHIP
- long longVal; ///< OPARG_TYPE_NUMERIC
- void * nestVal; ///< OPARG_TYPE_HIERARCHY
- } v;
-} tOptionValue;
-
-/**
- * file argument state and handling.
- */
-typedef enum {
- FTYPE_MODE_MAY_EXIST = 0x00, ///< may or may not exist
- FTYPE_MODE_MUST_EXIST = 0x01, ///< must pre-exist
- FTYPE_MODE_MUST_NOT_EXIST = 0x02, ///< must *not* pre-exist
- FTYPE_MODE_EXIST_MASK = 0x03, ///< mask for these bits
- FTYPE_MODE_NO_OPEN = 0x00, ///< leave file closed
- FTYPE_MODE_OPEN_FD = 0x10, ///< call open(2)
- FTYPE_MODE_FOPEN_FP = 0x20, ///< call fopen(3)
- FTYPE_MODE_OPEN_MASK = 0x30 ///< open/fopen/not open
-} teOptFileType;
-
-/**
- * the open flag bits or the mode string, depending on the open type.
- */
-typedef union {
- int file_flags; ///< open(2) flag bits
- char const * file_mode; ///< fopen(3) mode string
-} tuFileMode;
-
-/// initial number of option argument holders to allocate
-#define MIN_ARG_ALLOC_CT 6
-/// amount by which to increment the argument holder allocation.
-#define INCR_ARG_ALLOC_CT 8
-/**
- * an argument list. When an option appears multiple times and
- * the values get "stacked". \a apzArgs holds 8 pointers initially
- * and is incremented by \a INCR_ARG_ALLOC_CT as needed.
- */
-typedef struct {
- int useCt; ///< elements in use
-
- /// allocated elements, mininum \a MIN_ARG_ALLOC_CT
- /// steps by \a INCR_ARG_ALLOC_CT
- int allocCt;
- char const * apzArgs[MIN_ARG_ALLOC_CT]; ///< element array
-} tArgList;
-
-/**
- * Bits in the fOptState option descriptor field.
- * @{
- */
-
-/** integral type for holding opt_state masks */
-typedef uint32_t opt_state_mask_t;
-
-#define OPTST_ARG_TYPE_SHIFT 12
-/** bits defined for opt_state_mask_t */
-/** Set via the "SET_OPT()" macro */
-#define OPTST_SET 0x0000001U
-/** Set via an RC/INI file */
-#define OPTST_PRESET 0x0000002U
-/** Set via a command line option */
-#define OPTST_DEFINED 0x0000004U
-/** Reset via command line option */
-#define OPTST_RESET 0x0000008U
-/** selected by equiv'ed option */
-#define OPTST_EQUIVALENCE 0x0000010U
-/** option is in disabled state */
-#define OPTST_DISABLED 0x0000020U
-/** pzOptArg was allocated */
-#define OPTST_ALLOC_ARG 0x0000040U
-/** option cannot be preset */
-#define OPTST_NO_INIT 0x0000100U
-/** opt value (flag) is any digit */
-#define OPTST_NUMBER_OPT 0x0000200U
-/** opt uses optionStackArg proc */
-#define OPTST_STACKED 0x0000400U
-/** option defaults to enabled */
-#define OPTST_INITENABLED 0x0000800U
-/** bit 1 of arg type enum */
-#define OPTST_ARG_TYPE_1 0x0001000U
-/** bit 2 of arg type enum */
-#define OPTST_ARG_TYPE_2 0x0002000U
-/** bit 3 of arg type enum */
-#define OPTST_ARG_TYPE_3 0x0004000U
-/** bit 4 of arg type enum */
-#define OPTST_ARG_TYPE_4 0x0008000U
-/** the option arg not required */
-#define OPTST_ARG_OPTIONAL 0x0010000U
-/** process opt on first pass */
-#define OPTST_IMM 0x0020000U
-/** process disablement immed. */
-#define OPTST_DISABLE_IMM 0x0040000U
-/** compiled out of program */
-#define OPTST_OMITTED 0x0080000U
-/** must be set or pre-set */
-#define OPTST_MUST_SET 0x0100000U
-/** opt is for doc only */
-#define OPTST_DOCUMENT 0x0200000U
-/** process opt twice - imm + reg */
-#define OPTST_TWICE 0x0400000U
-/** process disabled option twice */
-#define OPTST_DISABLE_TWICE 0x0800000U
-/** scaled integer value */
-#define OPTST_SCALED_NUM 0x1000000U
-/** disable from cmd line */
-#define OPTST_NO_COMMAND 0x2000000U
-/** support is being removed */
-#define OPTST_DEPRECATED 0x4000000U
-/** alias for other option */
-#define OPTST_ALIAS 0x8000000U
-
-/** bits in SET mask:
- * set preset reset defined */
-#define OPTST_SET_MASK 0x000000FU
-
-/** bits in MUTABLE mask:
- * set preset reset defined equivalence disabled
- * alloc_arg */
-#define OPTST_MUTABLE_MASK 0x000007FU
-
-/** bits omitted from PERSISTENT mask:
- * mutable_mask */
-#define OPTST_PERSISTENT_MASK 0xFFFFF00U
-
-/** bits in SELECTED mask:
- * set defined */
-#define OPTST_SELECTED_MASK 0x0000005U
-
-/** bits in ARG_TYPE mask:
- * arg_type_1 arg_type_2 arg_type_3 arg_type_4 */
-#define OPTST_ARG_TYPE_MASK 0x000F000U
-
-/** bits in NO_USAGE mask:
- * omitted no_command deprecated */
-#define OPTST_NO_USAGE_MASK 0x6080000U
-
-/** bits in IMMUTABLE mask:
- * document omitted */
-#define OPTST_IMMUTABLE_MASK 0x0280000U
-
-/** bits in DO_NOT_SAVE mask:
- * document omitted no_init */
-#define OPTST_DO_NOT_SAVE_MASK 0x0280100U
-
-/** bits in NO_OUTPUT mask:
- * document omitted alias */
-#define OPTST_NO_OUTPUT_MASK 0x8280000U
-
-/** all bits in opt_state_mask_t masks */
-#define OPTST_MASK_ALL 0xFFFFF7FU
-
-/** no bits in opt_state_mask_t */
-#define OPTST_INIT 0x0000000U
-/** @} */
-
-#ifdef NO_OPTIONAL_OPT_ARGS
-# undef OPTST_ARG_OPTIONAL
-# define OPTST_ARG_OPTIONAL 0
-#endif
-
-#define VENDOR_OPTION_VALUE 'W'
-
-#define SELECTED_OPT(_od) ((_od)->fOptState & OPTST_SELECTED_MASK)
-#define UNUSED_OPT( _od) (((_od)->fOptState & OPTST_SET_MASK) == 0)
-#define DISABLED_OPT(_od) ((_od)->fOptState & OPTST_DISABLED)
-#define OPTION_STATE(_od) ((_od)->fOptState)
-#define OPTST_SET_ARGTYPE(_n) ((_n) << OPTST_ARG_TYPE_SHIFT)
-#define OPTST_GET_ARGTYPE(_f) \
- (((_f)&OPTST_ARG_TYPE_MASK) >> OPTST_ARG_TYPE_SHIFT)
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *
- * PRIVATE INTERFACES
- *
- * The following values are used in the generated code to communicate
- * with the option library procedures. They are not for public use
- * and may be subject to change.
- */
-
-/**
- * Define the processing state flags
- * @{
- */
-
-/** integral type for holding proc_state masks */
-typedef uint32_t proc_state_mask_t;
-
-/** bits defined for proc_state_mask_t */
-/** Process long style options */
-#define OPTPROC_LONGOPT 0x000001U
-/** Process short style "flags" */
-#define OPTPROC_SHORTOPT 0x000002U
-/** Stop on argument errors */
-#define OPTPROC_ERRSTOP 0x000004U
-/** Current option is disabled */
-#define OPTPROC_DISABLEDOPT 0x000008U
-/** no options are required */
-#define OPTPROC_NO_REQ_OPT 0x000010U
-/** there is a number option */
-#define OPTPROC_NUM_OPT 0x000020U
-/** have inits been done? */
-#define OPTPROC_INITDONE 0x000040U
-/** any negation options? */
-#define OPTPROC_NEGATIONS 0x000080U
-/** check environment? */
-#define OPTPROC_ENVIRON 0x000100U
-/** Disallow remaining arguments */
-#define OPTPROC_NO_ARGS 0x000200U
-/** Require args after options */
-#define OPTPROC_ARGS_REQ 0x000400U
-/** reorder operands after opts */
-#define OPTPROC_REORDER 0x000800U
-/** emit usage in GNU style */
-#define OPTPROC_GNUUSAGE 0x001000U
-/** Translate strings in tOptions */
-#define OPTPROC_TRANSLATE 0x002000U
-/** no usage on usage error */
-#define OPTPROC_MISUSE 0x004000U
-/** immediate options active */
-#define OPTPROC_IMMEDIATE 0x008000U
-/** suppress for config only */
-#define OPTPROC_NXLAT_OPT_CFG 0x010000U
-/** suppress xlation always */
-#define OPTPROC_NXLAT_OPT 0x020000U
-/** vendor options active */
-#define OPTPROC_VENDOR_OPT 0x040000U
-/** opt processing in preset state */
-#define OPTPROC_PRESETTING 0x080000U
-/** Ignore pzFullUsage, compute usage text */
-#define OPTPROC_COMPUTE 0x100000U
-/** Program outputs digested option state for shell scripts. Usage text
- * always written to stderr */
-#define OPTPROC_SHELL_OUTPUT 0x200000U
-
-/** bits in NO_XLAT mask:
- * nxlat_opt_cfg nxlat_opt */
-#define OPTPROC_NO_XLAT_MASK 0x030000U
-
-/** all bits in proc_state_mask_t masks */
-#define OPTPROC_MASK_ALL 0x3FFFFFU
-
-/** no bits in proc_state_mask_t */
-#define OPTPROC_NONE 0x000000U
-/** @} */
-
-#define STMTS(s) do { s; } while (false)
-
-/**
- * Abbreviation for const memory character.
- */
-#define tCC char const
-
-/**
- * Magical values for the program's option pointer
- * @{
- */
-typedef enum {
- OP_VAL_EMIT_USAGE = 1, ///< request for usage
- OP_VAL_EMIT_SHELL = 2, ///< emit value for Bourne shell evaluation
- OP_VAL_RETURN_VALNAME = 3, ///< return the value as a string
- OP_VAL_EMIT_LIMIT = 15 ///< limit for magic values
-} opt_proc_vals_t;
-
-/// \a OPT_VAL_EMIT_USAGE cast as a pointer
-#define OPTPROC_EMIT_USAGE ((tOptions *)OP_VAL_EMIT_USAGE)
-
-/// \a OPT_VAL_EMIT_SHELL cast as a pointer
-#define OPTPROC_EMIT_SHELL ((tOptions *)OP_VAL_EMIT_SHELL)
-
-/// \a OPT_VAL_RETURN_VALNAME cast as a pointer
-#define OPTPROC_RETURN_VALNAME ((tOptions *)OP_VAL_RETURN_VALNAME)
-
-/// \a OPT_VAL_EMIT_LIMIT cast as a pointer
-#define OPTPROC_EMIT_LIMIT ((tOptions *)OP_VAL_EMIT_LIMIT)
-/** @} */
-
-/** group option processing procedure types
- * @{
- */
-/** forward declaration for tOptDesc */
-typedef struct opt_desc tOptDesc;
-/** forward declaration for tOptiond */
-typedef struct options tOptions;
-
-/**
- * The option procedures do the special processing for each
- * option flag that needs it.
- */
-typedef void (tOptProc)(tOptions * pOpts, tOptDesc * pOptDesc);
-
-/**
- * a pointer to an option processing procedure
- */
-typedef tOptProc * tpOptProc;
-
-/**
- * The usage procedure will never return. It calls "exit(2)"
- * with the "exitCode" argument passed to it.
- */
-// coverity[+kill]
-typedef void (tUsageProc)(tOptions * pOpts, int exitCode);
-
-/**
- * a pointer to a procedure that prints usage and exits.
- */
-typedef tUsageProc * tpUsageProc;
-/** @} */
-
-/**
- * Special definitions. "NOLIMIT" is the 'max' value to use when
- * a flag may appear multiple times without limit. "NO_EQUIVALENT"
- * is an illegal value for 'optIndex' (option description index).
- * @{
- */
-#define NOLIMIT USHRT_MAX ///< no occurrance count limit
-#define OPTION_LIMIT SHRT_MAX ///< maximum number of option types
-/// option index to indicate no equivalance or alias
-#define NO_EQUIVALENT (OPTION_LIMIT+1)
-/** @} */
-
-/**
- * Option argument value. Which is valid is determined by:
- * (fOptState & OPTST_ARG_TYPE_MASK) >> OPTST_ARG_TYPE_SHIFT
- * which will yield one of the teOptArgType values.
- */
-typedef union {
- char const * argString; ///< as a string
- uintptr_t argEnum; ///< as an enumeration value
- uintptr_t argIntptr; ///< as an integer big enough to hold pointer
- long argInt; ///< as a long integer
- unsigned long argUint; ///< as an unsigned long ingeger
- unsigned int argBool; ///< as a boolean value
- FILE * argFp; ///< as a FILE * pointer
- int argFd; ///< as a file descriptor (int)
-} opt_arg_union_t;
-
-/// Compatibility define: \a pzLastArg is now \a optArg.argString
-#define pzLastArg optArg.argString
-/// The old amorphous argument bucket is now the opt_arg_union_t union.
-#define optArgBucket_t opt_arg_union_t
-
-/**
- * Enumeration of AutoOpts defined options. The enumeration is used in
- * marking each option that is defined by AutoOpts so libopts can find
- * the correct descriptor. This renders \a option_spec_idx_t redundant.
- */
-typedef enum {
- AOUSE_USER_DEFINED = 0, ///< user specified option
- AOUSE_RESET_OPTION, ///< reset option state option
- AOUSE_VERSION, ///< request version
- AOUSE_HELP, ///< request usage help
- AOUSE_MORE_HELP, ///< request paged usage
- AOUSE_USAGE, ///< request short usage
- AOUSE_SAVE_OPTS, ///< save option state
- AOUSE_LOAD_OPTS, ///< load options from file
- AOUSE_VENDOR_OPT ///< specify a vendor option
-} opt_usage_t;
-
-/**
- * Descriptor structure for each option.
- * Only the fields marked "PUBLIC" are for public use.
- */
-struct opt_desc {
- /// Public, the index of this descriptor
- uint16_t const optIndex;
- /// Public, the flag character (value)
- uint16_t const optValue;
- /// Public, the index of the option used to activate option
- uint16_t optActualIndex;
- /// Public, the flag character of the activating option
- uint16_t optActualValue;
-
- /// Public, the index of the equivalenced-to option.
- /// This is NO_EQUIVALENT unless activated.
- uint16_t const optEquivIndex;
- /// Private, the minimum occurrance count
- uint16_t const optMinCt;
- /// Private, the maximum occurrance count (NOLIMIT, if unlimited)
- uint16_t const optMaxCt;
- /// Public, the actual occurrance count
- uint16_t optOccCt;
-
- /// Public, the option processing state
- opt_state_mask_t fOptState;
- /// Private, how the option is used (opt_usage_t)
- uint32_t optUsage;
- /// Public, The current option argument value
- opt_arg_union_t optArg;
- /// Public, data that is actually private to the code that handles
- /// this particular option. It is public IFF you have your own
- /// handling function.
- void * optCookie;
-
- /// Private, a list of options that must be specified when this option
- /// has been specified
- int const * const pOptMust;
-
- /// Private, a list of options that cannot be specified when this option
- /// has been specified
- int const * const pOptCant;
-
- /// Private, the function to call for handling this option
- tpOptProc const pOptProc;
-
- /// Private, usage information about this option
- char const * const pzText;
-
- /// Public, the UPPER CASE, shell variable name syntax name of the option
- char const * const pz_NAME;
-
- /// the unmodified name of the option
- char const * const pz_Name;
-
- /// the option name to use to disable the option. Long options names
- /// must be active.
- char const * const pz_DisableName;
-
- /// the special prefix that makes the normal option name become the
- /// disablement name.
- char const * const pz_DisablePfx;
-};
-
-/**
- * Some options need special processing, so we store their
- * indexes in a known place.
- */
-typedef struct {
- uint16_t const more_help; ///< passes help text through pager
- uint16_t const save_opts; ///< stores option state to a file
- uint16_t const number_option; ///< the option "name" is an integer
- /// all arguments are options, this is the default option that must
- /// take an argument. That argument is the unrecognized option.
- uint16_t const default_opt;
-} option_spec_idx_t;
-
-/**
- * The procedure generated for translating option text
- */
-typedef void (tOptionXlateProc)(void);
-
-/**
- * Everything marked "PUBLIC" is also marked "const". Public access is not
- * a license to modify. Other fields are used and modified by the library.
- * They are also subject to change without any notice.
- * Do not even look at these outside of libopts.
- */
-struct options {
- int const structVersion; ///< The version of this struct
- unsigned int origArgCt; ///< program argument count
- char ** origArgVect; ///< program argument vector
- proc_state_mask_t fOptSet; ///< option proc. state flags
- unsigned int curOptIdx; ///< current option index
- char * pzCurOpt; ///< current option text
-
- /// Public, the full path of the program
- char const * const pzProgPath;
- /// Public, the name of the executable, without any path
- char const * const pzProgName;
- /// Public, the upper-cased, shell variable syntax-ed program name
- char const * const pzPROGNAME;
- /// the name of the "rc file" (configuration file)
- char const * const pzRcName;
- /// the copyright text
- char const * const pzCopyright;
- /// the full copyright notice
- char const * const pzCopyNotice;
- /// a string with the program name, project name and version
- char const * const pzFullVersion;
- /// a list of pointers to directories to search for the config file
- char const * const * const papzHomeList;
- /// the title line for usage
- char const * const pzUsageTitle;
- /// some added explanation for what this program is trying to do
- char const * const pzExplain;
- /// a detailed explanation of the program's purpose, for use when
- /// full help has been requested
- char const * const pzDetail;
- /// The public array of option descriptors
- tOptDesc * const pOptDesc;
- /// the email address for reporting bugs
- char const * const pzBugAddr;
-
- /// Reserved for future use
- void * pExtensions;
- /// A copy of the option state when optionSaveState was called.
- void * pSavedState;
-
- /// The procedure to call to print usage text
- /* __attribute__((__noreturn__)) */
- // coverity[+kill]
- tpUsageProc pUsageProc;
- /// The procedure to call to translate translatable option messages
- tOptionXlateProc * pTransProc;
-
- /// Special option indexes.
- option_spec_idx_t specOptIdx;
- /// the total number of options for the program
- int const optCt;
- /// The number of "presettable" options, though some may be marked
- /// "no-preset". Includes all user specified options, plus a few
- /// that are specified by AutoOpts.
- int const presetOptCt;
- /// user specified full usage text
- char const * pzFullUsage;
- /// user specifed short usage (usage error triggered) message
- char const * pzShortUsage;
- /// The option argument settings active when optionSaveState was called
- opt_arg_union_t const * const originalOptArgArray;
- /// any saved cookie value
- void * const * const originalOptArgCookie;
- /// the package data directory (e.g. global configuration files)
- char const * const pzPkgDataDir;
- /// email address of the project packager
- char const * const pzPackager;
-};
-
-/*
- * Versions where in various fields first appear:
- * ($AO_CURRENT * 4096 + $AO_REVISION, but $AO_REVISION must be zero)
- */
-/**
- * The version that first stored the original argument vector
- */
-#define originalOptArgArray_STRUCT_VERSION 0x20000 /* AO_CURRENT = 32 */
-#define HAS_originalOptArgArray(_opt) \
- ((_opt)->structVersion >= originalOptArgArray_STRUCT_VERSION)
-
-/**
- * The version that first stored the package data directory
- */
-#define pzPkgDataDir_STRUCT_VERSION 0x22000 /* AO_CURRENT = 34 */
-#define HAS_pzPkgDataDir(_opt) \
- ((_opt)->structVersion >= pzPkgDataDir_STRUCT_VERSION)
-
-/**
- * The version that first stored the option usage in each option descriptor
- */
-#define opt_usage_t_STRUCT_VERSION 0x26000 /* AO_CURRENT = 38 */
-#define HAS_opt_usage_t(_opt) \
- ((_opt)->structVersion >= opt_usage_t_STRUCT_VERSION)
-
-/**
- * "token list" structure returned by "string_tokenize()"
- */
-typedef struct {
- unsigned long tkn_ct; ///< number of tokens found
- unsigned char * tkn_list[1]; ///< array of pointers to tokens
-} token_list_t;
-
-/*
- * Hide the interface - it pollutes a POSIX claim, but leave it for
- * anyone #include-ing this header
- */
-#define strneqvcmp option_strneqvcmp
-#define streqvcmp option_streqvcmp
-#define streqvmap option_streqvmap
-#define strequate option_strequate
-#define strtransform option_strtransform
-
-/**
- * Everything needed to be known about an mmap-ed file.
- *
- * This is an output only structure used by text_mmap and text_munmap.
- * Clients must not alter the contents and must provide it to both
- * the text_mmap and text_munmap procedures. BE ADVISED: if you are
- * mapping the file with PROT_WRITE the NUL byte at the end MIGHT NOT
- * BE WRITABLE. In any event, that byte is not be written back
- * to the source file. ALSO: if "txt_data" is valid and "txt_errno"
- * is not zero, then there *may* not be a terminating NUL.
- */
-typedef struct {
- void * txt_data; ///< text file data
- size_t txt_size; ///< actual file size
- size_t txt_full_size; ///< mmaped mem size
- int txt_fd; ///< file descriptor
- int txt_zero_fd; ///< fd for /dev/zero
- int txt_errno; ///< warning code
- int txt_prot; ///< "prot" flags
- int txt_flags; ///< mapping type
-} tmap_info_t;
-
-/**
- * mmap result wrapper that yields "true" when mmap has failed.
- */
-#define TEXT_MMAP_FAILED_ADDR(a) (VOIDP(a) == VOIDP(MAP_FAILED))
-
-#ifdef __cplusplus
-#define CPLUSPLUS_OPENER extern "C" {
-CPLUSPLUS_OPENER
-#define CPLUSPLUS_CLOSER }
-#else
-#define CPLUSPLUS_CLOSER
-#endif
-
-/**
- * The following routines may be coded into AutoOpts client code:
- */
-
-/**
- * ao_string_tokenize - tokenize an input string
- *
- * This function will convert one input string into a list of strings.
- * The list of strings is derived by separating the input based on
- * white space separation. However, if the input contains either single
- * or double quote characters, then the text after that character up to
- * a matching quote will become the string in the list.
- *
- * The returned pointer should be deallocated with @code{free(3C)} when
- * are done using the data. The data are placed in a single block of
- * allocated memory. Do not deallocate individual token/strings.
- *
- * The structure pointed to will contain at least these two fields:
- * @table @samp
- * @item tkn_ct
- * The number of tokens found in the input string.
- * @item tok_list
- * An array of @code{tkn_ct + 1} pointers to substring tokens, with
- * the last pointer set to NULL.
- * @end table
- *
- * There are two types of quoted strings: single quoted (@code{'}) and
- * double quoted (@code{"}). Singly quoted strings are fairly raw in that
- * escape characters (@code{\\}) are simply another character, except when
- * preceding the following characters:
- * @example
- * @code{\\} double backslashes reduce to one
- * @code{'} incorporates the single quote into the string
- * @code{\n} suppresses both the backslash and newline character
- * @end example
- *
- * Double quote strings are formed according to the rules of string
- * constants in ANSI-C programs.
- *
- * @param string string to be tokenized
- *
- * @return token_list_t * - pointer to a structure that lists each token
- */
-extern token_list_t * ao_string_tokenize(char const *);
-
-
-/**
- * configFileLoad - parse a configuration file
- *
- * This routine will load a named configuration file and parse the
- * text as a hierarchically valued option. The option descriptor
- * created from an option definition file is not used via this interface.
- * The returned value is "named" with the input file name and is of
- * type "@code{OPARG_TYPE_HIERARCHY}". It may be used in calls to
- * @code{optionGetValue()}, @code{optionNextValue()} and
- * @code{optionUnloadNested()}.
- *
- * @param fname the file to load
- *
- * @return const tOptionValue * - An allocated, compound value structure
- */
-extern const tOptionValue * configFileLoad(char const *);
-
-
-/**
- * optionFileLoad - Load the locatable config files, in order
- *
- * This function looks in all the specified directories for a configuration
- * file ("rc" file or "ini" file) and processes any found twice. The first
- * time through, they are processed in reverse order (last file first). At
- * that time, only "immediate action" configurables are processed. For
- * example, if the last named file specifies not processing any more
- * configuration files, then no more configuration files will be processed.
- * Such an option in the @strong{first} named directory will have no effect.
- *
- * Once the immediate action configurables have been handled, then the
- * directories are handled in normal, forward order. In that way, later
- * config files can override the settings of earlier config files.
- *
- * See the AutoOpts documentation for a thorough discussion of the
- * config file format.
- *
- * Configuration files not found or not decipherable are simply ignored.
- *
- * @param opts program options descriptor
- * @param prog program name
- *
- * @return int - 0 -> SUCCESS, -1 -> FAILURE
- */
-extern int optionFileLoad(tOptions *, char const *);
-
-
-/**
- * optionFindNextValue - find a hierarcicaly valued option instance
- *
- * This routine will find the next entry in a nested value option or
- * configurable. It will search through the list and return the next entry
- * that matches the criteria.
- *
- * @param odesc an option with a nested arg type
- * @param pPrevVal the last entry
- * @param name name of value to find
- * @param value the matching value
- *
- * @return const tOptionValue * - a compound value structure
- */
-extern const tOptionValue * optionFindNextValue(const tOptDesc *, const tOptionValue *, char const *, char const *);
-
-
-/**
- * optionFindValue - find a hierarcicaly valued option instance
- *
- * This routine will find an entry in a nested value option or configurable.
- * It will search through the list and return a matching entry.
- *
- * @param odesc an option with a nested arg type
- * @param name name of value to find
- * @param val the matching value
- *
- * @return const tOptionValue * - a compound value structure
- */
-extern const tOptionValue * optionFindValue(const tOptDesc *, char const *, char const *);
-
-
-/**
- * optionFree - free allocated option processing memory
- *
- * AutoOpts sometimes allocates memory and puts pointers to it in the
- * option state structures. This routine deallocates all such memory.
- *
- * @param pOpts program options descriptor
- */
-extern void optionFree(tOptions *);
-
-
-/**
- * optionGetValue - get a specific value from a hierarcical list
- *
- * This routine will find an entry in a nested value option or configurable.
- * If "valueName" is NULL, then the first entry is returned. Otherwise,
- * the first entry with a name that exactly matches the argument will be
- * returned. If there is no matching value, NULL is returned and errno is
- * set to ENOENT. If the provided option value is not a hierarchical value,
- * NULL is also returned and errno is set to EINVAL.
- *
- * @param pOptValue a hierarchcal value
- * @param valueName name of value to get
- *
- * @return const tOptionValue * - a compound value structure
- */
-extern const tOptionValue * optionGetValue(const tOptionValue *, char const *);
-
-
-/**
- * optionLoadLine - process a string for an option name and value
- *
- * This is a client program callable routine for setting options from, for
- * example, the contents of a file that they read in. Only one option may
- * appear in the text. It will be treated as a normal (non-preset) option.
- *
- * When passed a pointer to the option struct and a string, it will find
- * the option named by the first token on the string and set the option
- * argument to the remainder of the string. The caller must NUL terminate
- * the string. The caller need not skip over any introductory hyphens.
- * Any embedded new lines will be included in the option
- * argument. If the input looks like one or more quoted strings, then the
- * input will be "cooked". The "cooking" is identical to the string
- * formation used in AutoGen definition files (@pxref{basic expression}),
- * except that you may not use backquotes.
- *
- * @param opts program options descriptor
- * @param line NUL-terminated text
- */
-extern void optionLoadLine(tOptions *, char const *);
-
-
-/**
- * optionMemberList - Get the list of members of a bit mask set
- *
- * This converts the OPT_VALUE_name mask value to a allocated string.
- * It is the caller's responsibility to free the string.
- *
- * @param od the set membership option description
- *
- * @return char * - the names of the set bits
- */
-extern char * optionMemberList(tOptDesc *);
-
-
-/**
- * optionNextValue - get the next value from a hierarchical list
- *
- * This routine will return the next entry after the entry passed in. At the
- * end of the list, NULL will be returned. If the entry is not found on the
- * list, NULL will be returned and "@var{errno}" will be set to EINVAL.
- * The "@var{pOldValue}" must have been gotten from a prior call to this
- * routine or to "@code{opitonGetValue()}".
- *
- * @param pOptValue a hierarchcal list value
- * @param pOldValue a value from this list
- *
- * @return const tOptionValue * - a compound value structure
- */
-extern const tOptionValue * optionNextValue(const tOptionValue *, const tOptionValue *);
-
-
-/**
- * optionOnlyUsage - Print usage text for just the options
- *
- * This routine will print only the usage for each option.
- * This function may be used when the emitted usage must incorporate
- * information not available to AutoOpts.
- *
- * @param pOpts program options descriptor
- * @param ex_code exit code for calling exit(3)
- */
-extern void optionOnlyUsage(tOptions *, int);
-
-
-/**
- * optionPrintVersion - Print the program version
- *
- * This routine will print the version to stdout.
- *
- * @param opts program options descriptor
- * @param od the descriptor for this arg
- */
-extern void optionPrintVersion(tOptions *, tOptDesc *);
-
-
-/**
- * optionPrintVersionAndReturn - Print the program version
- *
- * This routine will print the version to stdout and return
- * instead of exiting. Please see the source for the
- * @code{print_ver} funtion for details on selecting how
- * verbose to be after this function returns.
- *
- * @param opts program options descriptor
- * @param od the descriptor for this arg
- */
-extern void optionPrintVersionAndReturn(tOptions *, tOptDesc *);
-
-
-/**
- * optionProcess - this is the main option processing routine
- *
- * This is the main entry point for processing options. It is intended
- * that this procedure be called once at the beginning of the execution of
- * a program. Depending on options selected earlier, it is sometimes
- * necessary to stop and restart option processing, or to select completely
- * different sets of options. This can be done easily, but you generally
- * do not want to do this.
- *
- * The number of arguments processed always includes the program name.
- * If one of the arguments is "--", then it is counted and the processing
- * stops. If an error was encountered and errors are to be tolerated, then
- * the returned value is the index of the argument causing the error.
- * A hyphen by itself ("-") will also cause processing to stop and will
- * @emph{not} be counted among the processed arguments. A hyphen by itself
- * is treated as an operand. Encountering an operand stops option
- * processing.
- *
- * @param opts program options descriptor
- * @param a_ct program arg count
- * @param a_v program arg vector
- *
- * @return int - the count of the arguments processed
- */
-extern int optionProcess(tOptions *, int, char **);
-
-
-/**
- * optionRestore - restore option state from memory copy
- *
- * Copy back the option state from saved memory.
- * The allocated memory is left intact, so this routine can be
- * called repeatedly without having to call optionSaveState again.
- * If you are restoring a state that was saved before the first call
- * to optionProcess(3AO), then you may change the contents of the
- * argc/argv parameters to optionProcess.
- *
- * @param pOpts program options descriptor
- */
-extern void optionRestore(tOptions *);
-
-
-/**
- * optionSaveFile - saves the option state to a file
- *
- * This routine will save the state of option processing to a file. The name
- * of that file can be specified with the argument to the @code{--save-opts}
- * option, or by appending the @code{rcfile} attribute to the last
- * @code{homerc} attribute. If no @code{rcfile} attribute was specified, it
- * will default to @code{.@i{programname}rc}. If you wish to specify another
- * file, you should invoke the @code{SET_OPT_SAVE_OPTS(@i{filename})} macro.
- *
- * The recommend usage is as follows:
- * @example
- * optionProcess(&progOptions, argc, argv);
- * if (i_want_a_non_standard_place_for_this)
- * SET_OPT_SAVE_OPTS("myfilename");
- * optionSaveFile(&progOptions);
- * @end example
- *
- * @param opts program options descriptor
- */
-extern void optionSaveFile(tOptions *);
-
-
-/**
- * optionSaveState - saves the option state to memory
- *
- * This routine will allocate enough memory to save the current option
- * processing state. If this routine has been called before, that memory
- * will be reused. You may only save one copy of the option state. This
- * routine may be called before optionProcess(3AO). If you do call it
- * before the first call to optionProcess, then you may also change the
- * contents of argc/argv after you call optionRestore(3AO)
- *
- * In fact, more strongly put: it is safest to only use this function
- * before having processed any options. In particular, the saving and
- * restoring of stacked string arguments and hierarchical values is
- * disabled. The values are not saved.
- *
- * @param pOpts program options descriptor
- */
-extern void optionSaveState(tOptions *);
-
-
-/**
- * optionUnloadNested - Deallocate the memory for a nested value
- *
- * A nested value needs to be deallocated. The pointer passed in should
- * have been gotten from a call to @code{configFileLoad()} (See
- * @pxref{libopts-configFileLoad}).
- *
- * @param pOptVal the hierarchical value
- */
-extern void optionUnloadNested(tOptionValue const *);
-
-
-/**
- * optionVersion - return the compiled AutoOpts version number
- *
- * Returns the full version string compiled into the library.
- * The returned string cannot be modified.
- *
- * @return char const * - the version string in constant memory
- */
-extern char const * optionVersion(void);
-
-
-/**
- * strequate - map a list of characters to the same value
- *
- * Each character in the input string get mapped to the first character
- * in the string.
- * This function name is mapped to option_strequate so as to not conflict
- * with the POSIX name space.
- *
- * @param ch_list characters to equivalence
- */
-extern void strequate(char const *);
-
-
-/**
- * streqvcmp - compare two strings with an equivalence mapping
- *
- * Using a character mapping, two strings are compared for "equivalence".
- * Each input character is mapped to a comparison character and the
- * mapped-to characters are compared for the two NUL terminated input strings.
- * This function name is mapped to option_streqvcmp so as to not conflict
- * with the POSIX name space.
- *
- * @param str1 first string
- * @param str2 second string
- *
- * @return int - the difference between two differing characters
- */
-extern int streqvcmp(char const *, char const *);
-
-
-/**
- * streqvmap - Set the character mappings for the streqv functions
- *
- * Set the character mapping. If the count (@code{ct}) is set to zero, then
- * the map is cleared by setting all entries in the map to their index
- * value. Otherwise, the "@code{From}" character is mapped to the "@code{To}"
- * character. If @code{ct} is greater than 1, then @code{From} and @code{To}
- * are incremented and the process repeated until @code{ct} entries have been
- * set. For example,
- * @example
- * streqvmap('a', 'A', 26);
- * @end example
- * @noindent
- * will alter the mapping so that all English lower case letters
- * will map to upper case.
- *
- * This function name is mapped to option_streqvmap so as to not conflict
- * with the POSIX name space.
- *
- * @param from Input character
- * @param to Mapped-to character
- * @param ct compare length
- */
-extern void streqvmap(char, char, int);
-
-
-/**
- * strneqvcmp - compare two strings with an equivalence mapping
- *
- * Using a character mapping, two strings are compared for "equivalence".
- * Each input character is mapped to a comparison character and the
- * mapped-to characters are compared for the two NUL terminated input strings.
- * The comparison is limited to @code{ct} bytes.
- * This function name is mapped to option_strneqvcmp so as to not conflict
- * with the POSIX name space.
- *
- * @param str1 first string
- * @param str2 second string
- * @param ct compare length
- *
- * @return int - the difference between two differing characters
- */
-extern int strneqvcmp(char const *, char const *, int);
-
-
-/**
- * strtransform - convert a string into its mapped-to value
- *
- * Each character in the input string is mapped and the mapped-to
- * character is put into the output.
- * This function name is mapped to option_strtransform so as to not conflict
- * with the POSIX name space.
- *
- * The source and destination may be the same.
- *
- * @param dest output string
- * @param src input string
- */
-extern void strtransform(char *, char const *);
-
-/* AutoOpts PRIVATE FUNCTIONS: */
-tOptProc optionStackArg, optionUnstackArg, optionBooleanVal, optionNumericVal;
-
-extern char * ao_string_cook(char *, int *);
-
-extern unsigned int ao_string_cook_escape_char(char const *, char *, unsigned int);
-
-extern void genshelloptUsage(tOptions *, int);
-
-extern int optionAlias(tOptions *, tOptDesc *, unsigned int);
-
-extern void optionBooleanVal(tOptions *, tOptDesc *);
-
-extern uintptr_t optionEnumerationVal(tOptions *, tOptDesc *, char const * const *, unsigned int);
-
-extern void optionFileCheck(tOptions *, tOptDesc *, teOptFileType, tuFileMode);
-
-extern char const * optionKeywordName(tOptDesc *, unsigned int);
-
-extern void optionLoadOpt(tOptions *, tOptDesc *);
-
-extern bool optionMakePath(char *, int, char const *, char const *);
-
-extern void optionNestedVal(tOptions *, tOptDesc *);
-
-extern void optionNumericVal(tOptions *, tOptDesc *);
-
-extern void optionPagedUsage(tOptions *, tOptDesc *);
-
-extern void optionParseShell(tOptions *);
-
-extern void optionPrintParagraphs(char const *, bool, FILE *);
-
-extern void optionPutShell(tOptions *);
-
-extern char const * optionQuoteString(char const *, char const *);
-
-extern void optionResetOpt(tOptions *, tOptDesc *);
-
-extern void optionSetMembers(tOptions *, tOptDesc *, char const * const *, unsigned int);
-
-extern void optionShowRange(tOptions *, tOptDesc *, void *, int);
-
-extern void optionStackArg(tOptions *, tOptDesc *);
-
-extern void optionTimeDate(tOptions *, tOptDesc *);
-
-extern void optionTimeVal(tOptions *, tOptDesc *);
-
-extern void optionUnstackArg(tOptions *, tOptDesc *);
-
-extern void optionUsage(tOptions *, int);
-
-extern void optionVendorOption(tOptions *, tOptDesc *);
-
-extern void optionVersionStderr(tOptions *, tOptDesc *);
-
-extern void * text_mmap(char const *, int, int, tmap_info_t *);
-
-extern int text_munmap(tmap_info_t *);
-
-CPLUSPLUS_CLOSER
-#endif /* AUTOOPTS_OPTIONS_H_GUARD */
-/** @}
- *
- * Local Variables:
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * options.h ends here */
diff --git a/src/libopts/autoopts/project.h b/src/libopts/autoopts/project.h
deleted file mode 100644
index 1f196efa0f..0000000000
--- a/src/libopts/autoopts/project.h
+++ /dev/null
@@ -1,81 +0,0 @@
-
-/**
- * \file project.h
- *
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-#ifndef AUTOGEN_PROJECT_H
-#define AUTOGEN_PROJECT_H
-
-#include "config.h"
-#include "compat/compat.h"
-#include "ag-char-map.h"
-
-/*
- * Procedure success codes
- *
- * USAGE: define procedures to return "tSuccess". Test their results
- * with the SUCCEEDED, FAILED and HADGLITCH macros.
- *
- * Microsoft sticks its nose into user space here, so for Windows' sake,
- * make sure all of these are undefined.
- */
-#undef SUCCESS
-#undef FAILURE
-#undef PROBLEM
-#undef SUCCEEDED
-#undef SUCCESSFUL
-#undef FAILED
-#undef HADGLITCH
-
-#define SUCCESS ((tSuccess) 0)
-#define FAILURE ((tSuccess)-1)
-#define PROBLEM ((tSuccess) 1)
-
-typedef int tSuccess;
-
-#define SUCCEEDED(p) ((p) == SUCCESS)
-#define SUCCESSFUL(p) SUCCEEDED(p)
-#define FAILED(p) ((p) < SUCCESS)
-#define HADGLITCH(p) ((p) > SUCCESS)
-
-#ifndef STR
-# define __STR(s) #s
-# define STR(s) __STR(s)
-#endif
-
-#ifdef DEFINING
-# define VALUE(s) = s
-# define MODE
-#else
-# define VALUE(s)
-# define MODE extern
-#endif
-
-#undef NUL
-#define NUL '\0'
-
-#define MOD_LOCAL static
-#define parse_duration option_parse_duration
-
-#endif /* AUTOGEN_PROJECT_H */
-/* end of project.h */
diff --git a/src/libopts/autoopts/usage-txt.h b/src/libopts/autoopts/usage-txt.h
deleted file mode 100644
index e94337d69b..0000000000
--- a/src/libopts/autoopts/usage-txt.h
+++ /dev/null
@@ -1,651 +0,0 @@
-/* -*- buffer-read-only: t -*- vi: set ro:
- *
- * DO NOT EDIT THIS FILE (usage-txt.h)
- *
- * It has been AutoGen-ed
- * From the definitions usage-txt.def
- * and the template file usage-txt.tpl
- *
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2017 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-/** @file usage-txt.h
- *
- * This file handles all the bookkeeping required for tracking all the little
- * tiny strings used by the AutoOpts library. There are 107
- * of them. This is not versioned because it is entirely internal to the
- * library and accessed by client code only in a very well-controlled way:
- * they may substitute translated strings using a procedure that steps through
- * all the string pointers.
- */
-#ifndef AUTOOPTS_USAGE_TXT_H_GUARD
-#define AUTOOPTS_USAGE_TXT_H_GUARD 1
-
-/*
- * One structure to hold all the pointers to all the translatable strings.
- */
-typedef struct {
- int field_ct;
- char * utpz_GnuBoolArg;
- char * utpz_GnuKeyArg;
- char * utpz_GnuNumArg;
- char * utpz_GnuStrArg;
- char const * apz_str[103];
-} usage_text_t;
-
-/*
- * Declare the global structure with all the pointers to translatable
- * strings and the text array containing untranslatable strings.
- */
-extern usage_text_t option_xlateable_txt;
-extern char const option_lib_text[4267];
-
-#if defined(AUTOOPTS_INTERNAL)
-/*
- * Provide a mapping from a short name to either the text directly
- * (for untranslatable strings), or to pointers to the text, rendering
- * them translatable.
- */
-#define zalloc_fail (option_xlateable_txt.apz_str[ 0])
-#define zno_opt_arg (option_xlateable_txt.apz_str[ 1])
-#define ztoo_new (option_xlateable_txt.apz_str[ 2])
-#define zwrong_ver (option_xlateable_txt.apz_str[ 3])
-#define zrealloc_fail (option_xlateable_txt.apz_str[ 4])
-#define ztoo_old (option_xlateable_txt.apz_str[ 5])
-#define zao_ver_fmt (option_xlateable_txt.apz_str[ 6])
-#define zao_bug_msg (option_xlateable_txt.apz_str[ 7])
-#define zno_reset (option_xlateable_txt.apz_str[ 8])
-#define zmissing_help_msg (option_xlateable_txt.apz_str[ 9])
-#define zbad_data_msg (option_xlateable_txt.apz_str[ 10])
-#define zbad_arg_type_msg (option_xlateable_txt.apz_str[ 11])
-#define zbad_default_msg (option_xlateable_txt.apz_str[ 12])
-#define zbad_alias_id (option_xlateable_txt.apz_str[ 13])
-#define zambiguous_key (option_xlateable_txt.apz_str[ 14])
-#define zambig_list_msg (option_xlateable_txt.apz_str[ 15])
-#define zambig_opt_fmt (option_xlateable_txt.apz_str[ 16])
-#define zargs_must (option_xlateable_txt.apz_str[ 17])
-#define zat_most (option_xlateable_txt.apz_str[ 18])
-#define zfserr_fmt (option_xlateable_txt.apz_str[ 19])
-#define zinter_proc_pipe (option_xlateable_txt.apz_str[ 20])
-#define zBadVerArg (option_xlateable_txt.apz_str[ 21])
-#define zconflict_fmt (option_xlateable_txt.apz_str[ 22])
-#define zDisabledErr (option_xlateable_txt.apz_str[ 23])
-#define zequiv (option_xlateable_txt.apz_str[ 24])
-#define zGnuBoolArg (option_xlateable_txt.utpz_GnuBoolArg)
-#define zGnuKeyArg (option_xlateable_txt.utpz_GnuKeyArg)
-#define zGnuNumArg (option_xlateable_txt.utpz_GnuNumArg)
-#define zGnuStrArg (option_xlateable_txt.utpz_GnuStrArg)
-#define zIllOptChr (option_xlateable_txt.apz_str[ 25])
-#define zIllOptStr (option_xlateable_txt.apz_str[ 26])
-#define zIllVendOptStr (option_xlateable_txt.apz_str[ 27])
-#define zIntRange (option_xlateable_txt.apz_str[ 28])
-#define zbad_od (option_xlateable_txt.apz_str[ 29])
-#define zInvalOptName (option_xlateable_txt.apz_str[ 30])
-#define zMisArg (option_xlateable_txt.apz_str[ 31])
-#define zmultiway_bug (option_xlateable_txt.apz_str[ 32])
-#define zneed_one (option_xlateable_txt.apz_str[ 33])
-#define zNoArg (option_xlateable_txt.apz_str[ 34])
-#define zNoArgs (option_xlateable_txt.apz_str[ 35])
-#define zNoCreat (option_xlateable_txt.apz_str[ 36])
-#define zNoKey (option_xlateable_txt.apz_str[ 37])
-#define zreset_arg (option_xlateable_txt.apz_str[ 38])
-#define zNoStat (option_xlateable_txt.apz_str[ 39])
-#define zNoState (option_xlateable_txt.apz_str[ 40])
-#define zNotCmdOpt (option_xlateable_txt.apz_str[ 41])
-#define zNotDate (option_xlateable_txt.apz_str[ 42])
-#define zNotDuration (option_xlateable_txt.apz_str[ 43])
-#define zneed_more (option_xlateable_txt.apz_str[ 44])
-#define zNotNumber (option_xlateable_txt.apz_str[ 45])
-#define znum_too_large (option_xlateable_txt.apz_str[ 46])
-#define zoffer_usage_fmt (option_xlateable_txt.apz_str[ 47])
-#define zonly_one (option_xlateable_txt.apz_str[ 48])
-#define zstdout_name (option_xlateable_txt.apz_str[ 49])
-#define zstderr_name (option_xlateable_txt.apz_str[ 50])
-#define zwriting (option_xlateable_txt.apz_str[ 51])
-#define zRangeErr (option_xlateable_txt.apz_str[ 52])
-#define zneed_fmt (option_xlateable_txt.apz_str[ 53])
-#define zsave_warn (option_xlateable_txt.apz_str[ 54])
-#define zalt_opt (option_xlateable_txt.apz_str[ 55])
-#define zAuto (option_xlateable_txt.apz_str[ 56])
-#define zDefaultOpt (option_xlateable_txt.apz_str[ 57])
-#define zDis (option_xlateable_txt.apz_str[ 58])
-#define zDisabledOpt (option_xlateable_txt.apz_str[ 59])
-#define zDisabledWhy (option_xlateable_txt.apz_str[ 60])
-#define zEnab (option_xlateable_txt.apz_str[ 61])
-#define ztoo_often_fmt (option_xlateable_txt.apz_str[ 62])
-#define zExamineFmt (option_xlateable_txt.apz_str[ 63])
-#define zFileCannotExist (option_xlateable_txt.apz_str[ 64])
-#define zFileMustExist (option_xlateable_txt.apz_str[ 65])
-#define zFlagOkay (option_xlateable_txt.apz_str[ 66])
-#define zGenshell (option_xlateable_txt.apz_str[ 67])
-#define zLowerBits (option_xlateable_txt.apz_str[ 68])
-#define zMembers (option_xlateable_txt.apz_str[ 69])
-#define zMust (option_xlateable_txt.apz_str[ 70])
-#define zNoFlags (option_xlateable_txt.apz_str[ 71])
-#define zNoLim (option_xlateable_txt.apz_str[ 72])
-#define zNoPreset (option_xlateable_txt.apz_str[ 73])
-#define zNoRq_NoShrtTtl (option_xlateable_txt.apz_str[ 74])
-#define zNoRq_ShrtTtl (option_xlateable_txt.apz_str[ 75])
-#define zNrmOptFmt (option_xlateable_txt.apz_str[ 76])
-#define zNumberOpt (option_xlateable_txt.apz_str[ 77])
-#define zOptsOnly (option_xlateable_txt.apz_str[ 78])
-#define zPathFmt (option_xlateable_txt.apz_str[ 79])
-#define zPlsSendBugs (option_xlateable_txt.apz_str[ 80])
-#define zPreset (option_xlateable_txt.apz_str[ 81])
-#define zPresetIntro (option_xlateable_txt.apz_str[ 82])
-#define zProhib (option_xlateable_txt.apz_str[ 83])
-#define zProhibOne (option_xlateable_txt.apz_str[ 84])
-#define zRange (option_xlateable_txt.apz_str[ 85])
-#define zRangeAbove (option_xlateable_txt.apz_str[ 86])
-#define zRangeExact (option_xlateable_txt.apz_str[ 87])
-#define zRangeLie (option_xlateable_txt.apz_str[ 88])
-#define zRangeOnly (option_xlateable_txt.apz_str[ 89])
-#define zRangeOr (option_xlateable_txt.apz_str[ 90])
-#define zRangeScaled (option_xlateable_txt.apz_str[ 91])
-#define zRangeUpto (option_xlateable_txt.apz_str[ 92])
-#define zReorder (option_xlateable_txt.apz_str[ 93])
-#define zReqOne (option_xlateable_txt.apz_str[ 94])
-#define zReqThese (option_xlateable_txt.apz_str[ 95])
-#define zReq_NoShrtTtl (option_xlateable_txt.apz_str[ 96])
-#define zReq_ShrtTtl (option_xlateable_txt.apz_str[ 97])
-#define zSetMemberSettings (option_xlateable_txt.apz_str[ 98])
-#define zUpTo (option_xlateable_txt.apz_str[ 99])
-#define zValidKeys (option_xlateable_txt.apz_str[100])
-#define zVendIntro (option_xlateable_txt.apz_str[101])
-#define zVendOptsAre (option_xlateable_txt.apz_str[102])
-
- /*
- * First, set up the strings. Some of these are writable. These are all in
- * English. This gets compiled into libopts and is distributed here so that
- * xgettext (or equivalents) can extract these strings for translation.
- */
-static char eng_zGnuBoolArg[] = "=T/F";
-static char eng_zGnuKeyArg[] = "=KWd";
-static char eng_zGnuNumArg[] = "=num";
-static char eng_zGnuStrArg[] = "=str";
-char const option_lib_text[4267] =
-/* 0 */ "allocation of %d bytes failed\n\0"
-/* 31 */ "AutoOpts function called without option descriptor\n\0"
-/* 83 */ "\tThis exceeds the compiled library version: \0"
-/* 129 */ "Automated Options Processing Error!\n"
- "\t%s called AutoOpts function with structure version %d:%d:%d.\n\0"
-/* 228 */ "realloc of %d bytes at 0x%p failed\n\0"
-/* 264 */ "\tThis is less than the minimum library version: \0"
-/* 314 */ "Automated Options version %s\n"
- "\tCopyright (C) 1999-2017 by Bruce Korb - all rights reserved\n\0"
-/* 405 */ "(AutoOpts bug): %s.\n\0"
-/* 427 */ "optionResetOpt() called, but reset-option not configured\0"
-/* 484 */ "could not locate the 'help' option\0"
-/* 519 */ "optionProcess() was called with invalid data\0"
-/* 564 */ "invalid argument type specified\0"
-/* 596 */ "defaulted to option with optional arg\0"
-/* 634 */ "aliasing option is out of range.\0"
-/* 667 */ "%s error: the keyword '%s' is ambiguous for %s\n\0"
-/* 716 */ " The following options match:\n\0"
-/* 748 */ "%s: ambiguous option name: %s (matches %d options)\n\0"
-/* 800 */ "%s: Command line arguments required\n\0"
-/* 837 */ "%d %s%s options allowed\n\0"
-/* 862 */ "%s error %d (%s) calling %s for '%s'\n\0"
-/* 900 */ "interprocess pipe\0"
-/* 918 */ "error: version option argument '%c' invalid. Use:\n"
- "\t'v' - version only\n"
- "\t'c' - version and copyright\n"
- "\t'n' - version and full copyright notice\n\0"
-/* 1060 */ "%s error: the '%s' and '%s' options conflict\n\0"
-/* 1107 */ "%s: The '%s' option has been disabled.\0"
-/* 1146 */ "-equivalence\0"
-/* 1159 */ "%s: illegal option -- %c\n\0"
-/* 1185 */ "%s: illegal option -- %s\n\0"
-/* 1211 */ "%s: unknown vendor extension option -- %s\n\0"
-/* 1254 */ " or an integer from %d through %d\n\0"
-/* 1290 */ "%s error: invalid option descriptor for %s\n\0"
-/* 1335 */ "%s: invalid option name: %s\n\0"
-/* 1364 */ "%s: The '%s' option requires an argument.\n\0"
-/* 1407 */ "(AutoOpts bug): Equivalenced option '%s' was equivalenced to both\n"
- "\t'%s' and '%s'.\0"
-/* 1490 */ "%s error: The %s option is required\n\0"
-/* 1528 */ "%s: The '%s' option cannot have an argument.\n\0"
-/* 1574 */ "%s: Command line arguments are not allowed.\n\0"
-/* 1619 */ "error %d (%s) creating %s\n\0"
-/* 1646 */ "%s error: '%s' does not match any %s keywords.\n\0"
-/* 1695 */ "%s error: The '%s' option requires an argument.\n\0"
-/* 1744 */ "error %d (%s) stat-ing %s\n\0"
-/* 1771 */ "%s error: no saved option state\n\0"
-/* 1804 */ "'%s' is not a command line option.\n\0"
-/* 1840 */ "%s error: '%s' is not a recognizable date/time.\n\0"
-/* 1890 */ "%s error: '%s' is not a recognizable time duration.\n\0"
-/* 1944 */ "%s error: The %s option must appear %d times.\n\0"
-/* 1992 */ "%s error: '%s' is not a recognizable number.\n\0"
-/* 2039 */ "%s error: %s exceeds %s keyword count\n\0"
-/* 2079 */ "Try '%s %s' for more information.\n\0"
-/* 2114 */ "one %s%s option allowed\n\0"
-/* 2139 */ "standard output\0"
-/* 2155 */ "standard error\0"
-/* 2170 */ "write\0"
-/* 2176 */ "%s error: %s option value %ld is out of range.\n\0"
-/* 2225 */ "%s error: %s option requires the %s option\n\0"
-/* 2270 */ "%s warning: cannot save options - %s not regular file\n\0"
-/* 2326 */ "\t\t\t\t- an alternate for '%s'\n\0"
-/* 2355 */ "Version, usage and configuration options:\0"
-/* 2397 */ "\t\t\t\t- default option for unnamed options\n\0"
-/* 2439 */ "\t\t\t\t- disabled as '--%s'\n\0"
-/* 2465 */ " --- %-14s %s\n\0"
-/* 2480 */ "This option has been disabled\0"
-/* 2510 */ "\t\t\t\t- enabled by default\n\0"
-/* 2536 */ "%s error: only \0"
-/* 2553 */ " - examining environment variables named %s_*\n\0"
-/* 2600 */ "\t\t\t\t- file must not pre-exist\n\0"
-/* 2631 */ "\t\t\t\t- file must pre-exist\n\0"
-/* 2658 */ "Options are specified by doubled hyphens and their name or by a single\n"
- "hyphen and the flag character.\n\0"
-/* 2761 */ "\n"
- "= = = = = = = =\n\n"
- "This incarnation of genshell will produce\n"
- "a shell script to parse the options for %s:\n\n\0"
-/* 2867 */ " or an integer mask with any of the lower %d bits set\n\0"
-/* 2923 */ "\t\t\t\t- is a set membership option\n\0"
-/* 2957 */ "\t\t\t\t- must appear between %d and %d times\n\0"
-/* 3000 */ "Options are specified by single or double hyphens and their name.\n\0"
-/* 3067 */ "\t\t\t\t- may appear multiple times\n\0"
-/* 3100 */ "\t\t\t\t- may not be preset\n\0"
-/* 3125 */ " Arg Option-Name Description\n\0"
-/* 3160 */ " Flg Arg Option-Name Description\n\0"
-/* 3198 */ " %3s %s\0"
-/* 3206 */ "The '-#<number>' option may omit the hash char\n\0"
-/* 3254 */ "All arguments are named options.\n\0"
-/* 3288 */ " - reading file %s\0"
-/* 3307 */ "\n"
- "Please send bug reports to: <%s>\n\0"
-/* 3343 */ "\t\t\t\t- may NOT appear - preset only\n\0"
-/* 3379 */ "\n"
- "The following option preset mechanisms are supported:\n\0"
-/* 3435 */ "prohibits these options:\n\0"
-/* 3461 */ "prohibits the option '%s'\n\0"
-/* 3488 */ "%s%ld to %ld\0"
-/* 3501 */ "%sgreater than or equal to %ld\0"
-/* 3532 */ "%s%ld exactly\0"
-/* 3546 */ "%sit must lie in one of the ranges:\n\0"
-/* 3583 */ "%sit must be in the range:\n\0"
-/* 3611 */ ", or\n\0"
-/* 3617 */ "%sis scalable with a suffix: k/K/m/M/g/G/t/T\n\0"
-/* 3663 */ "%sless than or equal to %ld\0"
-/* 3691 */ "Operands and options may be intermixed. They will be reordered.\n\0"
-/* 3757 */ "requires the option '%s'\n\0"
-/* 3783 */ "requires these options:\n\0"
-/* 3808 */ " Arg Option-Name Req? Description\n\0"
-/* 3848 */ " Flg Arg Option-Name Req? Description\n\0"
-/* 3891 */ "or you may use a numeric representation. Preceding these with a '!'\n"
- "will clear the bits, specifying 'none' will clear all bits, and 'all'\n"
- "will set them all. Multiple entries may be passed as an option\n"
- "argument list.\n\0"
-/* 4110 */ "\t\t\t\t- may appear up to %d times\n\0"
-/* 4143 */ "The valid \"%s\" option keywords are:\n\0"
-/* 4180 */ "The next option supports vendor supported extra options:\0"
-/* 4237 */ "These additional options are:";
-
-/*
- * Now, define (and initialize) the structure that contains
- * the pointers to all these strings.
- * Aren't you glad you don't maintain this by hand?
- */
-usage_text_t option_xlateable_txt = {
- 107,
- eng_zGnuBoolArg, eng_zGnuKeyArg, eng_zGnuNumArg, eng_zGnuStrArg,
- {
- option_lib_text + 0, option_lib_text + 31, option_lib_text + 83,
- option_lib_text + 129, option_lib_text + 228, option_lib_text + 264,
- option_lib_text + 314, option_lib_text + 405, option_lib_text + 427,
- option_lib_text + 484, option_lib_text + 519, option_lib_text + 564,
- option_lib_text + 596, option_lib_text + 634, option_lib_text + 667,
- option_lib_text + 716, option_lib_text + 748, option_lib_text + 800,
- option_lib_text + 837, option_lib_text + 862, option_lib_text + 900,
- option_lib_text + 918, option_lib_text + 1060, option_lib_text + 1107,
- option_lib_text + 1146, option_lib_text + 1159, option_lib_text + 1185,
- option_lib_text + 1211, option_lib_text + 1254, option_lib_text + 1290,
- option_lib_text + 1335, option_lib_text + 1364, option_lib_text + 1407,
- option_lib_text + 1490, option_lib_text + 1528, option_lib_text + 1574,
- option_lib_text + 1619, option_lib_text + 1646, option_lib_text + 1695,
- option_lib_text + 1744, option_lib_text + 1771, option_lib_text + 1804,
- option_lib_text + 1840, option_lib_text + 1890, option_lib_text + 1944,
- option_lib_text + 1992, option_lib_text + 2039, option_lib_text + 2079,
- option_lib_text + 2114, option_lib_text + 2139, option_lib_text + 2155,
- option_lib_text + 2170, option_lib_text + 2176, option_lib_text + 2225,
- option_lib_text + 2270, option_lib_text + 2326, option_lib_text + 2355,
- option_lib_text + 2397, option_lib_text + 2439, option_lib_text + 2465,
- option_lib_text + 2480, option_lib_text + 2510, option_lib_text + 2536,
- option_lib_text + 2553, option_lib_text + 2600, option_lib_text + 2631,
- option_lib_text + 2658, option_lib_text + 2761, option_lib_text + 2867,
- option_lib_text + 2923, option_lib_text + 2957, option_lib_text + 3000,
- option_lib_text + 3067, option_lib_text + 3100, option_lib_text + 3125,
- option_lib_text + 3160, option_lib_text + 3198, option_lib_text + 3206,
- option_lib_text + 3254, option_lib_text + 3288, option_lib_text + 3307,
- option_lib_text + 3343, option_lib_text + 3379, option_lib_text + 3435,
- option_lib_text + 3461, option_lib_text + 3488, option_lib_text + 3501,
- option_lib_text + 3532, option_lib_text + 3546, option_lib_text + 3583,
- option_lib_text + 3611, option_lib_text + 3617, option_lib_text + 3663,
- option_lib_text + 3691, option_lib_text + 3757, option_lib_text + 3783,
- option_lib_text + 3808, option_lib_text + 3848, option_lib_text + 3891,
- option_lib_text + 4110, option_lib_text + 4143, option_lib_text + 4180,
- option_lib_text + 4237
- } };
-#endif /* AUTOOPTS_INTERNAL */
-
-#ifdef XGETTEXT_SCAN_DO_NOT_COMPILE
-do not compile this section.
-/* TRANSLATORS: The following dummy functions were crated solely so that
- * xgettext can extract the correct strings. These strings are actually
- * referenced where the preceding "#line" directive states, though you will
- * not see the literal string there. The literal string is defined above in
- * the @code{option_lib_text} table and referenced via a #define name that
- * redirects into the @code{option_xlateable_txt} structure above. When
- * translating is activated, the pointers in @code{option_xlateable_txt} are
- * updated to point to translated strings.
- */
-static void dummy_func(void) {
- /* LIBOPTS-MESSAGES: */
-#line 67 "../autoopts.c"
- puts(_("allocation of %d bytes failed\n"));
-#line 89 "../autoopts.c"
- puts(_("allocation of %d bytes failed\n"));
-#line 48 "../init.c"
- puts(_("AutoOpts function called without option descriptor\n"));
-#line 81 "../init.c"
- puts(_("\tThis exceeds the compiled library version: "));
-#line 79 "../init.c"
- puts(_("Automated Options Processing Error!\n"
- "\t%s called AutoOpts function with structure version %d:%d:%d.\n"));
-#line 78 "../autoopts.c"
- puts(_("realloc of %d bytes at 0x%p failed\n"));
-#line 83 "../init.c"
- puts(_("\tThis is less than the minimum library version: "));
-#line 121 "../version.c"
- puts(_("Automated Options version %s\n"
- "\tCopyright (C) 1999-2017 by Bruce Korb - all rights reserved\n"));
-#line 49 "../makeshell.c"
- puts(_("(AutoOpts bug): %s.\n"));
-#line 90 "../reset.c"
- puts(_("optionResetOpt() called, but reset-option not configured"));
-#line 241 "../usage.c"
- puts(_("could not locate the 'help' option"));
-#line 330 "../autoopts.c"
- puts(_("optionProcess() was called with invalid data"));
-#line 697 "../usage.c"
- puts(_("invalid argument type specified"));
-#line 568 "../find.c"
- puts(_("defaulted to option with optional arg"));
-#line 76 "../alias.c"
- puts(_("aliasing option is out of range."));
-#line 210 "../enum.c"
- puts(_("%s error: the keyword '%s' is ambiguous for %s\n"));
-#line 78 "../find.c"
- puts(_(" The following options match:\n"));
-#line 263 "../find.c"
- puts(_("%s: ambiguous option name: %s (matches %d options)\n"));
-#line 161 "../check.c"
- puts(_("%s: Command line arguments required\n"));
-#line 43 "../alias.c"
- puts(_("%d %s%s options allowed\n"));
-#line 56 "../makeshell.c"
- puts(_("%s error %d (%s) calling %s for '%s'\n"));
-#line 268 "../makeshell.c"
- puts(_("interprocess pipe"));
-#line 171 "../version.c"
- puts(_("error: version option argument '%c' invalid. Use:\n"
- "\t'v' - version only\n"
- "\t'c' - version and copyright\n"
- "\t'n' - version and full copyright notice\n"));
-#line 58 "../check.c"
- puts(_("%s error: the '%s' and '%s' options conflict\n"));
-#line 187 "../find.c"
- puts(_("%s: The '%s' option has been disabled."));
-#line 400 "../find.c"
- puts(_("%s: The '%s' option has been disabled."));
-#line 38 "../alias.c"
- puts(_("-equivalence"));
-#line 439 "../find.c"
- puts(_("%s: illegal option -- %c\n"));
-#line 110 "../reset.c"
- puts(_("%s: illegal option -- %c\n"));
-#line 241 "../find.c"
- puts(_("%s: illegal option -- %s\n"));
-#line 740 "../find.c"
- puts(_("%s: illegal option -- %s\n"));
-#line 118 "../reset.c"
- puts(_("%s: illegal option -- %s\n"));
-#line 305 "../find.c"
- puts(_("%s: unknown vendor extension option -- %s\n"));
-#line 135 "../enum.c"
- puts(_(" or an integer from %d through %d\n"));
-#line 145 "../enum.c"
- puts(_(" or an integer from %d through %d\n"));
-#line 696 "../usage.c"
- puts(_("%s error: invalid option descriptor for %s\n"));
-#line 1030 "../usage.c"
- puts(_("%s error: invalid option descriptor for %s\n"));
-#line 355 "../find.c"
- puts(_("%s: invalid option name: %s\n"));
-#line 497 "../find.c"
- puts(_("%s: The '%s' option requires an argument.\n"));
-#line 150 "../autoopts.c"
- puts(_("(AutoOpts bug): Equivalenced option '%s' was equivalenced to both\n"
- "\t'%s' and '%s'."));
-#line 94 "../check.c"
- puts(_("%s error: The %s option is required\n"));
-#line 602 "../find.c"
- puts(_("%s: The '%s' option cannot have an argument.\n"));
-#line 151 "../check.c"
- puts(_("%s: Command line arguments are not allowed.\n"));
-#line 568 "../save.c"
- puts(_("error %d (%s) creating %s\n"));
-#line 210 "../enum.c"
- puts(_("%s error: '%s' does not match any %s keywords.\n"));
-#line 93 "../reset.c"
- puts(_("%s error: The '%s' option requires an argument.\n"));
-#line 122 "../save.c"
- puts(_("error %d (%s) stat-ing %s\n"));
-#line 175 "../save.c"
- puts(_("error %d (%s) stat-ing %s\n"));
-#line 143 "../restore.c"
- puts(_("%s error: no saved option state\n"));
-#line 225 "../autoopts.c"
- puts(_("'%s' is not a command line option.\n"));
-#line 113 "../time.c"
- puts(_("%s error: '%s' is not a recognizable date/time.\n"));
-#line 50 "../time.c"
- puts(_("%s error: '%s' is not a recognizable time duration.\n"));
-#line 92 "../check.c"
- puts(_("%s error: The %s option must appear %d times.\n"));
-#line 165 "../numeric.c"
- puts(_("%s error: '%s' is not a recognizable number.\n"));
-#line 176 "../enum.c"
- puts(_("%s error: %s exceeds %s keyword count\n"));
-#line 279 "../usage.c"
- puts(_("Try '%s %s' for more information.\n"));
-#line 45 "../alias.c"
- puts(_("one %s%s option allowed\n"));
-#line 170 "../makeshell.c"
- puts(_("standard output"));
-#line 905 "../makeshell.c"
- puts(_("standard output"));
-#line 223 "../usage.c"
- puts(_("standard output"));
-#line 364 "../usage.c"
- puts(_("standard output"));
-#line 574 "../usage.c"
- puts(_("standard output"));
-#line 178 "../version.c"
- puts(_("standard output"));
-#line 223 "../usage.c"
- puts(_("standard error"));
-#line 364 "../usage.c"
- puts(_("standard error"));
-#line 574 "../usage.c"
- puts(_("standard error"));
-#line 178 "../version.c"
- puts(_("standard error"));
-#line 170 "../makeshell.c"
- puts(_("write"));
-#line 905 "../makeshell.c"
- puts(_("write"));
-#line 222 "../usage.c"
- puts(_("write"));
-#line 363 "../usage.c"
- puts(_("write"));
-#line 573 "../usage.c"
- puts(_("write"));
-#line 177 "../version.c"
- puts(_("write"));
-#line 60 "../numeric.c"
- puts(_("%s error: %s option value %ld is out of range.\n"));
-#line 44 "../check.c"
- puts(_("%s error: %s option requires the %s option\n"));
-#line 121 "../save.c"
- puts(_("%s warning: cannot save options - %s not regular file\n"));
-#line 174 "../save.c"
- puts(_("%s warning: cannot save options - %s not regular file\n"));
-#line 193 "../save.c"
- puts(_("%s warning: cannot save options - %s not regular file\n"));
-#line 567 "../save.c"
- puts(_("%s warning: cannot save options - %s not regular file\n"));
- /* END-LIBOPTS-MESSAGES */
-
- /* USAGE-TEXT: */
-#line 822 "../usage.c"
- puts(_("\t\t\t\t- an alternate for '%s'\n"));
-#line 1097 "../usage.c"
- puts(_("Version, usage and configuration options:"));
-#line 873 "../usage.c"
- puts(_("\t\t\t\t- default option for unnamed options\n"));
-#line 786 "../usage.c"
- puts(_("\t\t\t\t- disabled as '--%s'\n"));
-#line 1066 "../usage.c"
- puts(_(" --- %-14s %s\n"));
-#line 1064 "../usage.c"
- puts(_("This option has been disabled"));
-#line 813 "../usage.c"
- puts(_("\t\t\t\t- enabled by default\n"));
-#line 40 "../alias.c"
- puts(_("%s error: only "));
-#line 1143 "../usage.c"
- puts(_(" - examining environment variables named %s_*\n"));
-#line 168 "../file.c"
- puts(_("\t\t\t\t- file must not pre-exist\n"));
-#line 172 "../file.c"
- puts(_("\t\t\t\t- file must pre-exist\n"));
-#line 329 "../usage.c"
- puts(_("Options are specified by doubled hyphens and their name or by a single\n"
- "hyphen and the flag character.\n"));
-#line 882 "../makeshell.c"
- puts(_("\n"
- "= = = = = = = =\n\n"
- "This incarnation of genshell will produce\n"
- "a shell script to parse the options for %s:\n\n"));
-#line 142 "../enum.c"
- puts(_(" or an integer mask with any of the lower %d bits set\n"));
-#line 846 "../usage.c"
- puts(_("\t\t\t\t- is a set membership option\n"));
-#line 867 "../usage.c"
- puts(_("\t\t\t\t- must appear between %d and %d times\n"));
-#line 331 "../usage.c"
- puts(_("Options are specified by single or double hyphens and their name.\n"));
-#line 853 "../usage.c"
- puts(_("\t\t\t\t- may appear multiple times\n"));
-#line 840 "../usage.c"
- puts(_("\t\t\t\t- may not be preset\n"));
-#line 1258 "../usage.c"
- puts(_(" Arg Option-Name Description\n"));
-#line 1194 "../usage.c"
- puts(_(" Flg Arg Option-Name Description\n"));
-#line 1252 "../usage.c"
- puts(_(" Flg Arg Option-Name Description\n"));
-#line 1253 "../usage.c"
- puts(_(" %3s %s"));
-#line 1259 "../usage.c"
- puts(_(" %3s %s"));
-#line 336 "../usage.c"
- puts(_("The '-#<number>' option may omit the hash char\n"));
-#line 332 "../usage.c"
- puts(_("All arguments are named options.\n"));
-#line 920 "../usage.c"
- puts(_(" - reading file %s"));
-#line 358 "../usage.c"
- puts(_("\n"
- "Please send bug reports to: <%s>\n"));
-#line 100 "../version.c"
- puts(_("\n"
- "Please send bug reports to: <%s>\n"));
-#line 129 "../version.c"
- puts(_("\n"
- "Please send bug reports to: <%s>\n"));
-#line 852 "../usage.c"
- puts(_("\t\t\t\t- may NOT appear - preset only\n"));
-#line 893 "../usage.c"
- puts(_("\n"
- "The following option preset mechanisms are supported:\n"));
-#line 1141 "../usage.c"
- puts(_("\n"
- "The following option preset mechanisms are supported:\n"));
-#line 631 "../usage.c"
- puts(_("prohibits these options:\n"));
-#line 626 "../usage.c"
- puts(_("prohibits the option '%s'\n"));
-#line 81 "../numeric.c"
- puts(_("%s%ld to %ld"));
-#line 79 "../numeric.c"
- puts(_("%sgreater than or equal to %ld"));
-#line 75 "../numeric.c"
- puts(_("%s%ld exactly"));
-#line 68 "../numeric.c"
- puts(_("%sit must lie in one of the ranges:\n"));
-#line 68 "../numeric.c"
- puts(_("%sit must be in the range:\n"));
-#line 88 "../numeric.c"
- puts(_(", or\n"));
-#line 66 "../numeric.c"
- puts(_("%sis scalable with a suffix: k/K/m/M/g/G/t/T\n"));
-#line 77 "../numeric.c"
- puts(_("%sless than or equal to %ld"));
-#line 339 "../usage.c"
- puts(_("Operands and options may be intermixed. They will be reordered.\n"));
-#line 601 "../usage.c"
- puts(_("requires the option '%s'\n"));
-#line 604 "../usage.c"
- puts(_("requires these options:\n"));
-#line 1270 "../usage.c"
- puts(_(" Arg Option-Name Req? Description\n"));
-#line 1264 "../usage.c"
- puts(_(" Flg Arg Option-Name Req? Description\n"));
-#line 143 "../enum.c"
- puts(_("or you may use a numeric representation. Preceding these with a '!'\n"
- "will clear the bits, specifying 'none' will clear all bits, and 'all'\n"
- "will set them all. Multiple entries may be passed as an option\n"
- "argument list.\n"));
-#line 859 "../usage.c"
- puts(_("\t\t\t\t- may appear up to %d times\n"));
-#line 52 "../enum.c"
- puts(_("The valid \"%s\" option keywords are:\n"));
-#line 1101 "../usage.c"
- puts(_("The next option supports vendor supported extra options:"));
-#line 722 "../usage.c"
- puts(_("These additional options are:"));
- /* END-USAGE-TEXT */
-}
-#endif /* XGETTEXT_SCAN_DO_NOT_COMPILE */
-#endif /* AUTOOPTS_USAGE_TXT_H_GUARD */
diff --git a/src/libopts/boolean.c b/src/libopts/boolean.c
deleted file mode 100644
index 80e0b0e97c..0000000000
--- a/src/libopts/boolean.c
+++ /dev/null
@@ -1,95 +0,0 @@
-
-/**
- * \file boolean.c
- *
- * Handle options with true/false values for arguments.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This routine will run run-on options through a pager so the
- * user may examine, print or edit them at their leisure.
- *
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-/*=export_func optionBooleanVal
- * private:
- *
- * what: Decipher a boolean value
- * arg: + tOptions * + opts + program options descriptor +
- * arg: + tOptDesc * + od + the descriptor for this arg +
- *
- * doc:
- * Decipher a true or false value for a boolean valued option argument.
- * The value is true, unless it starts with 'n' or 'f' or "#f" or
- * it is an empty string or it is a number that evaluates to zero.
-=*/
-void
-optionBooleanVal(tOptions * opts, tOptDesc * od)
-{
- char * pz;
- bool res = true;
-
- if (INQUERY_CALL(opts, od))
- return;
-
- if (od->optArg.argString == NULL) {
- od->optArg.argBool = false;
- return;
- }
-
- switch (*(od->optArg.argString)) {
- case '0':
- {
- long val = strtol(od->optArg.argString, &pz, 0);
- if ((val != 0) || (*pz != NUL))
- break;
- }
- /* FALLTHROUGH */
- case 'N':
- case 'n':
- case 'F':
- case 'f':
- case NUL:
- res = false;
- break;
- case '#':
- if (od->optArg.argString[1] != 'f')
- break;
- res = false;
- }
-
- if (od->fOptState & OPTST_ALLOC_ARG) {
- AGFREE(od->optArg.argString);
- od->fOptState &= ~OPTST_ALLOC_ARG;
- }
- od->optArg.argBool = res;
-}
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/boolean.c */
diff --git a/src/libopts/check.c b/src/libopts/check.c
deleted file mode 100644
index 7e75e7eca6..0000000000
--- a/src/libopts/check.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/**
- * @file check.c
- *
- * @brief option consistency checks.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-/**
- * Check for conflicts based on "must" and "cannot" attributes.
- */
-static bool
-has_conflict(tOptions * pOpts, tOptDesc * od)
-{
- if (od->pOptMust != NULL) {
- int const * must = od->pOptMust;
-
- while (*must != NO_EQUIVALENT) {
- tOptDesc * p = pOpts->pOptDesc + *(must++);
- if (UNUSED_OPT(p)) {
- const tOptDesc * ood = pOpts->pOptDesc + must[-1];
- fprintf(stderr, zneed_fmt, pOpts->pzProgName,
- od->pz_Name, ood->pz_Name);
- return true;
- }
- }
- }
-
- if (od->pOptCant != NULL) {
- int const * cant = od->pOptCant;
-
- while (*cant != NO_EQUIVALENT) {
- tOptDesc * p = pOpts->pOptDesc + *(cant++);
- if (SELECTED_OPT(p)) {
- const tOptDesc * ood = pOpts->pOptDesc + cant[-1];
- fprintf(stderr, zconflict_fmt, pOpts->pzProgName,
- od->pz_Name, ood->pz_Name);
- return true;
- }
- }
- }
-
- return false;
-}
-
-/**
- * Check that the option occurs often enough. Too often is already checked.
- */
-static bool
-occurs_enough(tOptions * pOpts, tOptDesc * pOD)
-{
- (void)pOpts;
-
- /*
- * IF the occurrence counts have been satisfied,
- * THEN there is no problem.
- */
- if (pOD->optOccCt >= pOD->optMinCt)
- return true;
-
- /*
- * IF MUST_SET means SET and PRESET are okay,
- * so min occurrence count doesn't count
- */
- if ( (pOD->fOptState & OPTST_MUST_SET)
- && (pOD->fOptState & (OPTST_PRESET | OPTST_SET)) )
- return true;
-
- if (pOD->optMinCt > 1)
- fprintf(stderr, zneed_more, pOpts->pzProgName, pOD->pz_Name,
- pOD->optMinCt);
- else fprintf(stderr, zneed_one, pOpts->pzProgName, pOD->pz_Name);
- return false;
-}
-
-/**
- * Verify option consistency.
- *
- * Make sure that the argument list passes our consistency tests.
- */
-static bool
-is_consistent(tOptions * pOpts)
-{
- tOptDesc * pOD = pOpts->pOptDesc;
- int oCt = pOpts->presetOptCt;
-
- /*
- * FOR each of "oCt" options, ...
- */
- for (;;) {
- /*
- * IF the current option was provided on the command line
- * THEN ensure that any "MUST" requirements are not
- * "DEFAULT" (unspecified) *AND* ensure that any
- * "CANT" options have not been SET or DEFINED.
- */
- if (SELECTED_OPT(pOD)) {
- if (has_conflict(pOpts, pOD))
- return false;
- }
-
- /*
- * IF this option is not equivalenced to another,
- * OR it is equivalenced to itself (is the equiv. root)
- * THEN we need to make sure it occurs often enough.
- */
- if ( (pOD->optEquivIndex == NO_EQUIVALENT)
- || (pOD->optEquivIndex == pOD->optIndex) )
-
- if (! occurs_enough(pOpts, pOD))
- return false;
-
- if (--oCt <= 0)
- break;
- pOD++;
- }
-
- /*
- * IF we are stopping on errors, check to see if any remaining
- * arguments are required to be there or prohibited from being there.
- */
- if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) {
-
- /*
- * Check for prohibition
- */
- if ((pOpts->fOptSet & OPTPROC_NO_ARGS) != 0) {
- if (pOpts->origArgCt > pOpts->curOptIdx) {
- fprintf(stderr, zNoArgs, pOpts->pzProgName);
- return false;
- }
- }
-
- /*
- * ELSE not prohibited, check for being required
- */
- else if ((pOpts->fOptSet & OPTPROC_ARGS_REQ) != 0) {
- if (pOpts->origArgCt <= pOpts->curOptIdx) {
- fprintf(stderr, zargs_must, pOpts->pzProgName);
- return false;
- }
- }
- }
-
- return true;
-}
-
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/check.c */
diff --git a/src/libopts/compat/_Noreturn.h b/src/libopts/compat/_Noreturn.h
deleted file mode 100644
index c44ad89b7c..0000000000
--- a/src/libopts/compat/_Noreturn.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#if !defined _Noreturn && __STDC_VERSION__ < 201112
-# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
- || 0x5110 <= __SUNPRO_C)
-# define _Noreturn __attribute__ ((__noreturn__))
-# elif 1200 <= _MSC_VER
-# define _Noreturn __declspec (noreturn)
-# else
-# define _Noreturn
-# endif
-#endif
diff --git a/src/libopts/compat/compat.h b/src/libopts/compat/compat.h
deleted file mode 100644
index 70a5652a23..0000000000
--- a/src/libopts/compat/compat.h
+++ /dev/null
@@ -1,383 +0,0 @@
-/* -*- Mode: C -*-
- *
- * compat.h is free software.
- * This file is part of AutoGen and AutoOpts.
- *
- * AutoGen Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-/**
- * \file compat.h
- * fake the preprocessor into handlng stuff portability
- */
-#ifndef COMPAT_H_GUARD
-#define COMPAT_H_GUARD 1
-
-#if defined(HAVE_CONFIG_H)
-# include <config.h>
-
-#elif defined(_WIN32) && !defined(__CYGWIN__)
-# include "windows-config.h"
-
-#else
-# error "compat.h" requires "config.h"
- choke me.
-#endif
-
-
-#ifndef HAVE_STRSIGNAL
-# ifndef HAVE_RAW_DECL_STRSIGNAL
- char * strsignal(int signo);
-# endif
-#endif
-
-#define _GNU_SOURCE 1 /* for strsignal in GNU's libc */
-#define __USE_GNU 1 /* exact same thing as above */
-#define __EXTENSIONS__ 1 /* and another way to call for it */
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *
- * SYSTEM HEADERS:
- */
-#include <sys/types.h>
-#ifdef HAVE_SYS_MMAN_H
-# include <sys/mman.h>
-#endif
-#include <sys/param.h>
-#if HAVE_SYS_PROCSET_H
-# include <sys/procset.h>
-#endif
-#include <sys/stat.h>
-#ifdef HAVE_SYS_WAIT_H
-# include <sys/wait.h>
-#endif
-
-#if defined( HAVE_SOLARIS_SYSINFO )
-# include <sys/systeminfo.h>
-#elif defined( HAVE_UNAME_SYSCALL )
-# include <sys/utsname.h>
-#endif
-
-#ifdef DAEMON_ENABLED
-# if HAVE_SYS_STROPTS_H
-# include <sys/stropts.h>
-# endif
-
-# if HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-# endif
-
-# if ! defined(HAVE_SYS_POLL_H) && ! defined(HAVE_SYS_SELECT_H)
-# error This system cannot support daemon processing
- Choke Me.
-# endif
-
-# if HAVE_SYS_POLL_H
-# include <sys/poll.h>
-# endif
-
-# if HAVE_SYS_SELECT_H
-# include <sys/select.h>
-# endif
-
-# if HAVE_NETINET_IN_H
-# include <netinet/in.h>
-# endif
-
-# if HAVE_SYS_UN_H
-# include <sys/un.h>
-# endif
-#endif
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *
- * USER HEADERS:
- */
-#include <stdio.h>
-#include <assert.h>
-#include <ctype.h>
-
-/*
- * Directory opening stuff:
- */
-# if defined (_POSIX_SOURCE)
-/* Posix does not require that the d_ino field be present, and some
- systems do not provide it. */
-# define REAL_DIR_ENTRY(dp) 1
-# else /* !_POSIX_SOURCE */
-# define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
-# endif /* !_POSIX_SOURCE */
-
-# if defined (HAVE_DIRENT_H)
-# include <dirent.h>
-# define D_NAMLEN(dirent) strlen((dirent)->d_name)
-# else /* !HAVE_DIRENT_H */
-# define dirent direct
-# define D_NAMLEN(dirent) (dirent)->d_namlen
-# if defined (HAVE_SYS_NDIR_H)
-# include <sys/ndir.h>
-# endif /* HAVE_SYS_NDIR_H */
-# if defined (HAVE_SYS_DIR_H)
-# include <sys/dir.h>
-# endif /* HAVE_SYS_DIR_H */
-# if defined (HAVE_NDIR_H)
-# include <ndir.h>
-# endif /* HAVE_NDIR_H */
-# endif /* !HAVE_DIRENT_H */
-
-#include <errno.h>
-#ifdef HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-#ifndef O_NONBLOCK
-# define O_NONBLOCK FNDELAY
-#endif
-
-#if defined(HAVE_LIBGEN) && defined(HAVE_LIBGEN_H)
-# include <libgen.h>
-#endif
-
-#if defined(HAVE_LIMITS_H) /* this is also in options.h */
-# include <limits.h>
-#elif defined(HAVE_SYS_LIMITS_H)
-# include <sys/limits.h>
-#endif /* HAVE_LIMITS/SYS_LIMITS_H */
-
-#include <memory.h>
-#include <setjmp.h>
-#include <signal.h>
-
-#if defined(HAVE_STDINT_H)
-# include <stdint.h>
-
-#elif defined(HAVE_INTTYPES_H)
-# include <inttypes.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-
-#ifdef HAVE_UTIME_H
-# include <utime.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if defined(HAVE_STDBOOL_H)
-# include <stdbool.h>
-#elif ! defined(bool)
- typedef enum { false = 0, true = 1 } _Bool;
-# define bool _Bool
-
- /* The other macros must be usable in preprocessor directives. */
-# define false 0
-# define true 1
-#endif
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *
- * FIXUPS and CONVIENCE STUFF:
- */
-#ifdef __cplusplus
-# define EXTERN extern "C"
-#else
-# define EXTERN extern
-#endif
-
-/* some systems #def errno! and others do not declare it!! */
-#ifndef errno
- extern int errno;
-#endif
-
-/* Some machines forget this! */
-
-# ifndef EXIT_FAILURE
-# define EXIT_SUCCESS 0
-# define EXIT_FAILURE 1
-# endif
-
-#ifndef NUL
-# define NUL '\0'
-#endif
-
-#ifndef NULL
-# define NULL 0
-#endif
-
-#if !defined (MAXPATHLEN) && defined (HAVE_SYS_PARAM_H)
-# include <sys/param.h>
-#endif /* !MAXPATHLEN && HAVE_SYS_PARAM_H */
-
-#if !defined (MAXPATHLEN) && defined (PATH_MAX)
-# define MAXPATHLEN PATH_MAX
-#endif /* !MAXPATHLEN && PATH_MAX */
-
-#if !defined (MAXPATHLEN) && defined(_MAX_PATH)
-# define PATH_MAX _MAX_PATH
-# define MAXPATHLEN _MAX_PATH
-#endif
-
-#if !defined (MAXPATHLEN)
-# define MAXPATHLEN 4096
-#endif /* MAXPATHLEN */
-
-#define AG_PATH_MAX ((size_t)MAXPATHLEN)
-
-#ifndef LONG_MAX
-# define LONG_MAX ~(1L << (8*sizeof(long) -1))
-# define INT_MAX ~(1 << (8*sizeof(int) -1))
-#endif
-
-#ifndef ULONG_MAX
-# define ULONG_MAX ~(OUL)
-# define UINT_MAX ~(OU)
-#endif
-
-#ifndef SHORT_MAX
-# define SHORT_MAX ~(1 << (8*sizeof(short) - 1))
-#else
-# define USHORT_MAX ~(OUS)
-#endif
-
-#ifndef HAVE_INT8_T
- typedef signed char int8_t;
-# define HAVE_INT8_T 1
-#endif
-#ifndef HAVE_UINT8_T
- typedef unsigned char uint8_t;
-# define HAVE_UINT8_T 1
-#endif
-#ifndef HAVE_INT16_T
- typedef signed short int16_t;
-# define HAVE_INT16_T 1
-#endif
-#ifndef HAVE_UINT16_T
- typedef unsigned short uint16_t;
-# define HAVE_UINT16_T 1
-#endif
-
-#ifndef HAVE_INT32_T
-# if SIZEOF_INT == 4
- typedef signed int int32_t;
-# elif SIZEOF_LONG == 4
- typedef signed long int32_t;
-# endif
-# define HAVE_INT32_T 1
-#endif
-
-#ifndef HAVE_UINT32_T
-# if SIZEOF_INT == 4
- typedef unsigned int uint32_t;
-# elif SIZEOF_LONG == 4
- typedef unsigned long uint32_t;
-# else
-# error Cannot create a uint32_t type.
- Choke Me.
-# endif
-# define HAVE_UINT32_T 1
-#endif
-
-#ifndef HAVE_INTPTR_T
-# if SIZEOF_CHARP == SIZEOF_LONG
- typedef signed long intptr_t;
-# else
- typedef signed int intptr_t;
-# endif
-# define HAVE_INTPTR_T 1
-#endif
-
-#ifndef HAVE_UINTPTR_T
-# if SIZEOF_CHARP == SIZEOF_LONG
- typedef unsigned long intptr_t;
-# else
- typedef unsigned int intptr_t;
-# endif
-# define HAVE_INTPTR_T 1
-#endif
-
-#ifndef HAVE_UINT_T
- typedef unsigned int uint_t;
-# define HAVE_UINT_T 1
-#endif
-
-#ifndef HAVE_SIZE_T
- typedef unsigned int size_t;
-# define HAVE_SIZE_T 1
-#endif
-#ifndef HAVE_WINT_T
- typedef unsigned int wint_t;
-# define HAVE_WINT_T 1
-#endif
-#ifndef HAVE_PID_T
- typedef signed int pid_t;
-# define HAVE_PID_T 1
-#endif
-
-/* redefine these for BSD style string libraries */
-#ifndef HAVE_STRCHR
-# define strchr index
-# define strrchr rindex
-#endif
-
-#ifdef USE_FOPEN_BINARY
-# ifndef FOPEN_BINARY_FLAG
-# define FOPEN_BINARY_FLAG "b"
-# endif
-# ifndef FOPEN_TEXT_FLAG
-# define FOPEN_TEXT_FLAG "t"
-# endif
-#else
-# ifndef FOPEN_BINARY_FLAG
-# define FOPEN_BINARY_FLAG
-# endif
-# ifndef FOPEN_TEXT_FLAG
-# define FOPEN_TEXT_FLAG
-# endif
-#endif
-
-#ifndef STR
-# define _STR(s) #s
-# define STR(s) _STR(s)
-#endif
-
-/* ##### Pointer sized word ##### */
-
-/* FIXME: the MAX stuff in here is broken! */
-#if SIZEOF_CHARP > SIZEOF_INT
- typedef long t_word;
- #define WORD_MAX LONG_MAX
- #define WORD_MIN LONG_MIN
-#else /* SIZEOF_CHARP <= SIZEOF_INT */
- typedef int t_word;
- #define WORD_MAX INT_MAX
- #define WORD_MIN INT_MIN
-#endif
-
-#endif /* COMPAT_H_GUARD */
-
-/*
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of compat/compat.h */
diff --git a/src/libopts/compat/pathfind.c b/src/libopts/compat/pathfind.c
deleted file mode 100644
index e188b72813..0000000000
--- a/src/libopts/compat/pathfind.c
+++ /dev/null
@@ -1,283 +0,0 @@
-/* -*- Mode: C -*- */
-
-/* pathfind.c --- find a FILE MODE along PATH */
-
-/* Author: Gary V Vaughan <gvaughan@oranda.demon.co.uk> */
-
-/* Code: */
-
-static char *
-pathfind( char const * path,
- char const * fname,
- char const * mode );
-
-#include "compat.h"
-#ifndef HAVE_PATHFIND
-#if defined(__windows__) && !defined(__CYGWIN__)
-static char *
-pathfind( char const * path,
- char const * fname,
- char const * mode )
-{
- return strdup(fname);
-}
-#else
-
-static char * make_absolute(char const * string, char const * dot_path);
-static char * canonicalize_pathname(char * path);
-static char * extract_colon_unit(char * dir, char const * string, int * p_index);
-
-/**
- * local implementation of pathfind.
- * @param[in] path colon separated list of directories
- * @param[in] fname the name we are hunting for
- * @param[in] mode the required file mode
- * @returns an allocated string with the full path, or NULL
- */
-static char *
-pathfind( char const * path,
- char const * fname,
- char const * mode )
-{
- int p_index = 0;
- int mode_bits = 0;
- char * res_path = NULL;
- char zPath[ AG_PATH_MAX + 1 ];
-
- if (strchr( mode, 'r' )) mode_bits |= R_OK;
- if (strchr( mode, 'w' )) mode_bits |= W_OK;
- if (strchr( mode, 'x' )) mode_bits |= X_OK;
-
- /*
- * FOR each non-null entry in the colon-separated path, DO ...
- */
- for (;;) {
- DIR * dirP;
- char * colon_unit = extract_colon_unit( zPath, path, &p_index );
-
- if (colon_unit == NULL)
- break;
-
- dirP = opendir( colon_unit );
-
- /*
- * IF the directory is inaccessable, THEN next directory
- */
- if (dirP == NULL)
- continue;
-
- for (;;) {
- struct dirent *entP = readdir( dirP );
-
- if (entP == (struct dirent *)NULL)
- break;
-
- /*
- * IF the file name matches the one we are looking for, ...
- */
- if (strcmp(entP->d_name, fname) == 0) {
- char * abs_name = make_absolute(fname, colon_unit);
-
- /*
- * Make sure we can access it in the way we want
- */
- if (access(abs_name, mode_bits) >= 0) {
- /*
- * We can, so normalize the name and return it below
- */
- res_path = canonicalize_pathname(abs_name);
- }
-
- free(abs_name);
- break;
- }
- }
-
- closedir( dirP );
-
- if (res_path != NULL)
- break;
- }
-
- return res_path;
-}
-
-/*
- * Turn STRING (a pathname) into an absolute pathname, assuming that
- * DOT_PATH contains the symbolic location of `.'. This always returns
- * a new string, even if STRING was an absolute pathname to begin with.
- */
-static char *
-make_absolute( char const * string, char const * dot_path )
-{
- char * result;
- int result_len;
-
- if (!dot_path || *string == '/') {
- result = strdup( string );
- } else {
- if (dot_path && dot_path[0]) {
- result = malloc( 2 + strlen( dot_path ) + strlen( string ) );
- strcpy( result, dot_path );
- result_len = (int)strlen(result);
- if (result[result_len - 1] != '/') {
- result[result_len++] = '/';
- result[result_len] = '\0';
- }
- } else {
- result = malloc( 3 + strlen( string ) );
- result[0] = '.'; result[1] = '/'; result[2] = '\0';
- result_len = 2;
- }
-
- strcpy( result + result_len, string );
- }
-
- return result;
-}
-
-/*
- * Canonicalize PATH, and return a new path. The new path differs from
- * PATH in that:
- *
- * Multiple `/'s are collapsed to a single `/'.
- * Leading `./'s are removed.
- * Trailing `/.'s are removed.
- * Trailing `/'s are removed.
- * Non-leading `../'s and trailing `..'s are handled by removing
- * portions of the path.
- */
-static char *
-canonicalize_pathname( char *path )
-{
- int i, start;
- char stub_char, *result;
-
- /* The result cannot be larger than the input PATH. */
- result = strdup( path );
-
- stub_char = (*path == '/') ? '/' : '.';
-
- /* Walk along RESULT looking for things to compact. */
- i = 0;
- while (result[i]) {
- while (result[i] != '\0' && result[i] != '/')
- i++;
-
- start = i++;
-
- /* If we didn't find any slashes, then there is nothing left to
- * do.
- */
- if (!result[start])
- break;
-
- /* Handle multiple `/'s in a row. */
- while (result[i] == '/')
- i++;
-
-#if !defined (apollo)
- if ((start + 1) != i)
-#else
- if ((start + 1) != i && (start != 0 || i != 2))
-#endif /* apollo */
- {
- strcpy( result + start + 1, result + i );
- i = start + 1;
- }
-
- /* Handle backquoted `/'. */
- if (start > 0 && result[start - 1] == '\\')
- continue;
-
- /* Check for trailing `/', and `.' by itself. */
- if ((start && !result[i])
- || (result[i] == '.' && !result[i+1])) {
- result[--i] = '\0';
- break;
- }
-
- /* Check for `../', `./' or trailing `.' by itself. */
- if (result[i] == '.') {
- /* Handle `./'. */
- if (result[i + 1] == '/') {
- strcpy( result + i, result + i + 1 );
- i = (start < 0) ? 0 : start;
- continue;
- }
-
- /* Handle `../' or trailing `..' by itself. */
- if (result[i + 1] == '.' &&
- (result[i + 2] == '/' || !result[i + 2])) {
- while (--start > -1 && result[start] != '/')
- ;
- memmove( result + start + 1, result + i + 2, strlen(result + i + 2) + 1 );
- i = (start < 0) ? 0 : start;
- continue;
- }
- }
- }
-
- if (!*result) {
- *result = stub_char;
- result[1] = '\0';
- }
-
- return result;
-}
-
-/*
- * Given a string containing units of information separated by colons,
- * return the next one pointed to by (P_INDEX), or NULL if there are no
- * more. Advance (P_INDEX) to the character after the colon.
- */
-static char *
-extract_colon_unit(char * pzDir, char const * string, int * p_index)
-{
- char * pzDest = pzDir;
- int ix = *p_index;
-
- if (string == NULL)
- return NULL;
-
- if ((unsigned)ix >= strlen( string ))
- return NULL;
-
- {
- char const * pzSrc = string + ix;
-
- while (*pzSrc == ':') pzSrc++;
-
- for (;;) {
- char ch = (*(pzDest++) = *(pzSrc++));
- switch (ch) {
- case ':':
- pzDest[-1] = NUL;
- /* FALLTHROUGH */
- case NUL:
- goto copy_done;
- }
-
- if ((unsigned long)(pzDest - pzDir) >= AG_PATH_MAX)
- break;
- } copy_done:;
-
- ix = (int)(pzSrc - string);
- }
-
- if (*pzDir == NUL)
- return NULL;
-
- *p_index = ix;
- return pzDir;
-}
-#endif /* __windows__ / __CYGWIN__ */
-#endif /* HAVE_PATHFIND */
-
-/*
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of compat/pathfind.c */
diff --git a/src/libopts/compat/snprintf.c b/src/libopts/compat/snprintf.c
deleted file mode 100644
index eccea1faf0..0000000000
--- a/src/libopts/compat/snprintf.c
+++ /dev/null
@@ -1,62 +0,0 @@
-
-#ifndef HAVE_VPRINTF
-#include "choke-me: no vprintf and no snprintf"
- choke me.
-#endif
-
-#if defined(HAVE_STDARG_H)
-# include <stdarg.h>
-# ifndef VA_START
-# define VA_START(a, f) va_start(a, f)
-# define VA_END(a) va_end(a)
-# endif /* VA_START */
-# define SNV_USING_STDARG_H
-
-#elif defined(HAVE_VARARGS_H)
-# include <varargs.h>
-# ifndef VA_START
-# define VA_START(a, f) va_start(a)
-# define VA_END(a) va_end(a)
-# endif /* VA_START */
-# undef SNV_USING_STDARG_H
-
-#else
-# include "must-have-stdarg-or-varargs"
- choke me.
-#endif
-
-static int
-snprintf(char *str, size_t n, char const *fmt, ...)
-{
- va_list ap;
- int rval;
-
-#ifdef VSPRINTF_CHARSTAR
- char *rp;
- VA_START(ap, fmt);
- rp = vsprintf(str, fmt, ap);
- VA_END(ap);
- rval = strlen(rp);
-
-#else
- VA_START(ap, fmt);
- rval = vsprintf(str, fmt, ap);
- VA_END(ap);
-#endif
-
- if (rval > n) {
- fprintf(stderr, "snprintf buffer overrun %d > %d\n", rval, (int)n);
- abort();
- }
- return rval;
-}
-
-static int
-vsnprintf( char *str, size_t n, char const *fmt, va_list ap )
-{
-#ifdef VSPRINTF_CHARSTAR
- return (strlen(vsprintf(str, fmt, ap)));
-#else
- return (vsprintf(str, fmt, ap));
-#endif
-}
diff --git a/src/libopts/compat/strchr.c b/src/libopts/compat/strchr.c
deleted file mode 100644
index f40938707b..0000000000
--- a/src/libopts/compat/strchr.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- SYNOPSIS
- #include <string.h>
-
- char *strchr(char const *s, int c);
-
- char *strrchr(char const *s, int c);
-
- DESCRIPTION
- The strchr() function returns a pointer to the first occurrence of the
- character c in the string s.
-
- The strrchr() function returns a pointer to the last occurrence of the
- character c in the string s.
-
- Here "character" means "byte" - these functions do not work with wide
- or multi-byte characters.
-
- RETURN VALUE
- The strchr() and strrchr() functions return a pointer to the matched
- character or NULL if the character is not found.
-
- CONFORMING TO
- SVID 3, POSIX, BSD 4.3, ISO 9899
-*/
-
-static char *
-strchr(char const *s, int c);
-
-static char *
-strrchr(char const *s, int c);
-
-static char *
-strchr(char const *s, int c)
-{
- do {
- if ((unsigned char)*s == (unsigned char)c)
- return s;
-
- } while (*(++s) != NUL);
-
- return NULL;
-}
-
-static char *
-strrchr(char const *s, int c)
-{
- char const *e = s + strlen(s);
-
- for (;;) {
- if (--e < s)
- break;
-
- if ((unsigned char)*e == (unsigned char)c)
- return e;
- }
- return NULL;
-}
-
-/*
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of compat/strsignal.c */
diff --git a/src/libopts/compat/strdup.c b/src/libopts/compat/strdup.c
deleted file mode 100644
index f3a40770d0..0000000000
--- a/src/libopts/compat/strdup.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Platforms without strdup ?!?!?!
- */
-
-static char *
-strdup( char const *s );
-
-static char *
-strdup( char const *s )
-{
- char *cp;
-
- if (s == NULL)
- return NULL;
-
- cp = (char *) AGALOC((unsigned) (strlen(s)+1), "strdup");
-
- if (cp != NULL)
- (void) strcpy(cp, s);
-
- return cp;
-}
diff --git a/src/libopts/compat/windows-config.h b/src/libopts/compat/windows-config.h
deleted file mode 100644
index 7ce1636416..0000000000
--- a/src/libopts/compat/windows-config.h
+++ /dev/null
@@ -1,144 +0,0 @@
-
-/**
- * \file windows-config.h
- *
- * This file contains all of the routines that must be linked into
- * an executable to use the generated option processing. The optional
- * routines are in separately compiled modules so that they will not
- * necessarily be linked in.
- *
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-#ifndef WINDOWS_CONFIG_HACKERY
-#define WINDOWS_CONFIG_HACKERY 1
-
-/*
- * The definitions below have been stolen from NTP's config.h for Windows.
- * However, they may be kept here in order to keep libopts independent from
- * the NTP project.
- */
-#ifndef __windows__
-# define __windows__ 4
-#endif
-
-/*
- * Miscellaneous functions that Microsoft maps to other names
- */
-#define snprintf _snprintf
-
-#define SIZEOF_INT 4
-#define SIZEOF_CHARP 4
-#define SIZEOF_LONG 4
-#define SIZEOF_SHORT 2
-
-#define HAVE_LIMITS_H 1
-#define HAVE_STRDUP 1
-#define HAVE_STRCHR 1
-#define HAVE_FCNTL_H 1
-
-/*
- * VS.NET's version of wspiapi.h has a bug in it where it assigns a value
- * to a variable inside an if statement. It should be comparing them.
- * We prevent inclusion since we are not using this code so we don't have
- * to see the warning messages
- */
-#ifndef _WSPIAPI_H_
-#define _WSPIAPI_H_
-#endif
-
-/* Prevent inclusion of winsock.h in windows.h */
-#ifndef _WINSOCKAPI_
-#define _WINSOCKAPI_
-#endif
-
-#ifndef __RPCASYNC_H__
-#define __RPCASYNC_H__
-#endif
-
-/* Include Windows headers */
-#include <windows.h>
-#include <winsock2.h>
-#include <limits.h>
-
-/*
- * Compatibility declarations for Windows, assuming SYS_WINNT
- * has been defined.
- */
-#define strdup _strdup
-#define stat _stat /* struct stat from <sys/stat.h> */
-#define unlink _unlink
-#define fchmod( _x, _y )
-#define ssize_t SSIZE_T
-
-#include <io.h>
-#define open _open
-#define close _close
-#define read _read
-#define write _write
-#define lseek _lseek
-#define pipe _pipe
-#define dup2 _dup2
-
-#define O_RDWR _O_RDWR
-#define O_RDONLY _O_RDONLY
-#define O_EXCL _O_EXCL
-
-#ifndef S_ISREG
-# define S_IFREG _S_IFREG
-# define S_ISREG(mode) (((mode) & S_IFREG) == S_IFREG)
-#endif
-
-#ifndef S_ISDIR
-# define S_IFDIR _S_IFDIR
-# define S_ISDIR(mode) (((mode) & S_IFDIR) == S_IFDIR)
-#endif
-
-/* C99 exact size integer support. */
-#if defined(HAVE_INTTYPES_H)
-# include <inttypes.h>
-
-#elif defined(HAVE_STDINT_H)
-# include <stdint.h>
-# define MISSING_INTTYPES_H 1
-
-#elif ! defined(ADDED_EXACT_SIZE_INTEGERS)
-# define ADDED_EXACT_SIZE_INTEGERS 1
-# define MISSING_INTTYPES_H 1
-
- typedef __int8 int8_t;
- typedef unsigned __int8 uint8_t;
-
- typedef __int16 int16_t;
- typedef unsigned __int16 uint16_t;
-
- typedef __int32 int32_t;
- typedef unsigned __int32 uint32_t;
-
- typedef __int64 int64_t;
- typedef unsigned __int64 uint64_t;
-
- typedef unsigned long uintptr_t;
- typedef long intptr_t;
-#endif
-
-#endif /* WINDOWS_CONFIG_HACKERY */
-/* windows-config.h ends here */
diff --git a/src/libopts/configfile.c b/src/libopts/configfile.c
deleted file mode 100644
index 783a9d8acd..0000000000
--- a/src/libopts/configfile.c
+++ /dev/null
@@ -1,1337 +0,0 @@
-/**
- * \file configfile.c
- *
- * configuration/rc/ini file handling.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-/**
- * Skip over some unknown attribute
- * @param[in] txt start of skpped text
- * @returns character after skipped text
- */
-inline static char const *
-skip_unkn(char const * txt)
-{
- txt = BRK_END_XML_TOKEN_CHARS(txt);
- return (*txt == NUL) ? NULL : txt;
-}
-
-/*=export_func configFileLoad
- *
- * what: parse a configuration file
- * arg: + char const * + fname + the file to load +
- *
- * ret_type: const tOptionValue *
- * ret_desc: An allocated, compound value structure
- *
- * doc:
- * This routine will load a named configuration file and parse the
- * text as a hierarchically valued option. The option descriptor
- * created from an option definition file is not used via this interface.
- * The returned value is "named" with the input file name and is of
- * type "@code{OPARG_TYPE_HIERARCHY}". It may be used in calls to
- * @code{optionGetValue()}, @code{optionNextValue()} and
- * @code{optionUnloadNested()}.
- *
- * err:
- * If the file cannot be loaded or processed, @code{NULL} is returned and
- * @var{errno} is set. It may be set by a call to either @code{open(2)}
- * @code{mmap(2)} or other file system calls, or it may be:
- * @itemize @bullet
- * @item
- * @code{ENOENT} - the file was not found.
- * @item
- * @code{ENOMSG} - the file was empty.
- * @item
- * @code{EINVAL} - the file contents are invalid -- not properly formed.
- * @item
- * @code{ENOMEM} - not enough memory to allocate the needed structures.
- * @end itemize
-=*/
-const tOptionValue *
-configFileLoad(char const * fname)
-{
- tmap_info_t cfgfile;
- tOptionValue * res = NULL;
- tOptionLoadMode save_mode = option_load_mode;
-
- char * txt = text_mmap(fname, PROT_READ, MAP_PRIVATE, &cfgfile);
-
- if (TEXT_MMAP_FAILED_ADDR(txt))
- return NULL; /* errno is set */
-
- option_load_mode = OPTION_LOAD_COOKED;
- res = optionLoadNested(txt, fname, strlen(fname));
-
- if (res == NULL) {
- int err = errno;
- text_munmap(&cfgfile);
- errno = err;
- } else
- text_munmap(&cfgfile);
-
- option_load_mode = save_mode;
- return res;
-}
-
-
-/*=export_func optionFindValue
- *
- * what: find a hierarcicaly valued option instance
- * arg: + const tOptDesc * + odesc + an option with a nested arg type +
- * arg: + char const * + name + name of value to find +
- * arg: + char const * + val + the matching value +
- *
- * ret_type: const tOptionValue *
- * ret_desc: a compound value structure
- *
- * doc:
- * This routine will find an entry in a nested value option or configurable.
- * It will search through the list and return a matching entry.
- *
- * err:
- * The returned result is NULL and errno is set:
- * @itemize @bullet
- * @item
- * @code{EINVAL} - the @code{pOptValue} does not point to a valid
- * hierarchical option value.
- * @item
- * @code{ENOENT} - no entry matched the given name.
- * @end itemize
-=*/
-const tOptionValue *
-optionFindValue(const tOptDesc * odesc, char const * name, char const * val)
-{
- const tOptionValue * res = NULL;
-
- if ( (odesc == NULL)
- || (OPTST_GET_ARGTYPE(odesc->fOptState) != OPARG_TYPE_HIERARCHY)) {
- errno = EINVAL;
- }
-
- else if (odesc->optCookie == NULL) {
- errno = ENOENT;
- }
-
- else do {
- tArgList * argl = odesc->optCookie;
- int argct = argl->useCt;
- void ** poptv = (void **)(argl->apzArgs);
-
- if (argct == 0) {
- errno = ENOENT;
- break;
- }
-
- if (name == NULL) {
- res = (tOptionValue *)*poptv;
- break;
- }
-
- while (--argct >= 0) {
- const tOptionValue * ov = *(poptv++);
- const tOptionValue * rv = optionGetValue(ov, name);
-
- if (rv == NULL)
- continue;
-
- if (val == NULL) {
- res = ov;
- break;
- }
- }
- if (res == NULL)
- errno = ENOENT;
- } while (false);
-
- return res;
-}
-
-
-/*=export_func optionFindNextValue
- *
- * FIXME: the handling of 'pzName' and 'pzVal' is just wrong.
- *
- * what: find a hierarcicaly valued option instance
- * arg: + const tOptDesc * + odesc + an option with a nested arg type +
- * arg: + const tOptionValue * + pPrevVal + the last entry +
- * arg: + char const * + name + name of value to find +
- * arg: + char const * + value + the matching value +
- *
- * ret_type: const tOptionValue *
- * ret_desc: a compound value structure
- *
- * doc:
- * This routine will find the next entry in a nested value option or
- * configurable. It will search through the list and return the next entry
- * that matches the criteria.
- *
- * err:
- * The returned result is NULL and errno is set:
- * @itemize @bullet
- * @item
- * @code{EINVAL} - the @code{pOptValue} does not point to a valid
- * hierarchical option value.
- * @item
- * @code{ENOENT} - no entry matched the given name.
- * @end itemize
-=*/
-tOptionValue const *
-optionFindNextValue(const tOptDesc * odesc, const tOptionValue * pPrevVal,
- char const * pzName, char const * pzVal)
-{
- bool old_found = false;
- tOptionValue * res = NULL;
-
- (void)pzName;
- (void)pzVal;
-
- if ( (odesc == NULL)
- || (OPTST_GET_ARGTYPE(odesc->fOptState) != OPARG_TYPE_HIERARCHY)) {
- errno = EINVAL;
- }
-
- else if (odesc->optCookie == NULL) {
- errno = ENOENT;
- }
-
- else do {
- tArgList * argl = odesc->optCookie;
- int ct = argl->useCt;
- void ** poptv = (void **)argl->apzArgs;
-
- while (--ct >= 0) {
- tOptionValue * pOV = *(poptv++);
- if (old_found) {
- res = pOV;
- break;
- }
- if (pOV == pPrevVal)
- old_found = true;
- }
- if (res == NULL)
- errno = ENOENT;
- } while (false);
-
- return res;
-}
-
-
-/*=export_func optionGetValue
- *
- * what: get a specific value from a hierarcical list
- * arg: + const tOptionValue * + pOptValue + a hierarchcal value +
- * arg: + char const * + valueName + name of value to get +
- *
- * ret_type: const tOptionValue *
- * ret_desc: a compound value structure
- *
- * doc:
- * This routine will find an entry in a nested value option or configurable.
- * If "valueName" is NULL, then the first entry is returned. Otherwise,
- * the first entry with a name that exactly matches the argument will be
- * returned. If there is no matching value, NULL is returned and errno is
- * set to ENOENT. If the provided option value is not a hierarchical value,
- * NULL is also returned and errno is set to EINVAL.
- *
- * err:
- * The returned result is NULL and errno is set:
- * @itemize @bullet
- * @item
- * @code{EINVAL} - the @code{pOptValue} does not point to a valid
- * hierarchical option value.
- * @item
- * @code{ENOENT} - no entry matched the given name.
- * @end itemize
-=*/
-tOptionValue const *
-optionGetValue(tOptionValue const * oov, char const * vname)
-{
- tArgList * arg_list;
- tOptionValue * res = NULL;
-
- if ((oov == NULL) || (oov->valType != OPARG_TYPE_HIERARCHY)) {
- errno = EINVAL;
- return res;
- }
- arg_list = oov->v.nestVal;
-
- if (arg_list->useCt > 0) {
- int ct = arg_list->useCt;
- void ** ovlist = (void **)(arg_list->apzArgs);
-
- if (vname == NULL) {
- res = (tOptionValue *)*ovlist;
-
- } else do {
- tOptionValue * opt_val = *(ovlist++);
- if (strcmp(opt_val->pzName, vname) == 0) {
- res = opt_val;
- break;
- }
- } while (--ct > 0);
- }
- if (res == NULL)
- errno = ENOENT;
- return res;
-}
-
-/*=export_func optionNextValue
- *
- * what: get the next value from a hierarchical list
- * arg: + const tOptionValue * + pOptValue + a hierarchcal list value +
- * arg: + const tOptionValue * + pOldValue + a value from this list +
- *
- * ret_type: const tOptionValue *
- * ret_desc: a compound value structure
- *
- * doc:
- * This routine will return the next entry after the entry passed in. At the
- * end of the list, NULL will be returned. If the entry is not found on the
- * list, NULL will be returned and "@var{errno}" will be set to EINVAL.
- * The "@var{pOldValue}" must have been gotten from a prior call to this
- * routine or to "@code{opitonGetValue()}".
- *
- * err:
- * The returned result is NULL and errno is set:
- * @itemize @bullet
- * @item
- * @code{EINVAL} - the @code{pOptValue} does not point to a valid
- * hierarchical option value or @code{pOldValue} does not point to a
- * member of that option value.
- * @item
- * @code{ENOENT} - the supplied @code{pOldValue} pointed to the last entry.
- * @end itemize
-=*/
-tOptionValue const *
-optionNextValue(tOptionValue const * ov_list,tOptionValue const * oov )
-{
- tArgList * arg_list;
- tOptionValue * res = NULL;
- int err = EINVAL;
-
- if ((ov_list == NULL) || (ov_list->valType != OPARG_TYPE_HIERARCHY)) {
- errno = EINVAL;
- return NULL;
- }
- arg_list = ov_list->v.nestVal;
- {
- int ct = arg_list->useCt;
- void ** o_list = (void **)(arg_list->apzArgs);
-
- while (ct-- > 0) {
- tOptionValue * nov = *(o_list++);
- if (nov == oov) {
- if (ct == 0) {
- err = ENOENT;
-
- } else {
- err = 0;
- res = (tOptionValue *)*o_list;
- }
- break;
- }
- }
- }
- if (err != 0)
- errno = err;
- return res;
-}
-
-/**
- * Load a file containing presetting information (a configuration file).
- */
-static void
-file_preset(tOptions * opts, char const * fname, int dir)
-{
- tmap_info_t cfgfile;
- tOptState optst = OPTSTATE_INITIALIZER(PRESET);
- opt_state_mask_t st_flags = optst.flags;
- opt_state_mask_t fl_save = opts->fOptSet;
- char * ftext =
- text_mmap(fname, PROT_READ|PROT_WRITE, MAP_PRIVATE, &cfgfile);
-
- if (TEXT_MMAP_FAILED_ADDR(ftext))
- return;
-
- /*
- * While processing config files, we ignore errors.
- */
- opts->fOptSet &= ~OPTPROC_ERRSTOP;
-
- if (dir == DIRECTION_CALLED) {
- st_flags = OPTST_DEFINED;
- dir = DIRECTION_PROCESS;
- }
-
- /*
- * IF this is called via "optionProcess", then we are presetting.
- * This is the default and the PRESETTING bit will be set.
- * If this is called via "optionFileLoad", then the bit is not set
- * and we consider stuff set herein to be "set" by the client program.
- */
- if ((opts->fOptSet & OPTPROC_PRESETTING) == 0)
- st_flags = OPTST_SET;
-
- do {
- optst.flags = st_flags;
- ftext = SPN_WHITESPACE_CHARS(ftext);
-
- if (IS_VAR_FIRST_CHAR(*ftext)) {
- ftext = handle_cfg(opts, &optst, ftext, dir);
-
- } else switch (*ftext) {
- case '<':
- if (IS_VAR_FIRST_CHAR(ftext[1]))
- ftext = handle_struct(opts, &optst, ftext, dir);
-
- else switch (ftext[1]) {
- case '?':
- ftext = handle_directive(opts, ftext);
- break;
-
- case '!':
- ftext = handle_comment(ftext);
- break;
-
- case '/':
- ftext = strchr(ftext + 2, '>');
- if (ftext++ != NULL)
- break;
- /* FALLTHROUGH */
-
- default:
- ftext = NULL;
- }
- if (ftext == NULL)
- goto all_done;
- break;
-
- case '[':
- ftext = handle_section(opts, ftext);
- break;
-
- case '#':
- ftext = strchr(ftext + 1, NL);
- break;
-
- default:
- goto all_done; /* invalid format */
- }
- } while (ftext != NULL);
-
- all_done:
- text_munmap(&cfgfile);
- opts->fOptSet = fl_save;
-}
-
-/**
- * "txt" points to a "<!" sequence.
- * Theoretically, we should ensure that it begins with "<!--",
- * but actually I don't care that much. It ends with "-->".
- */
-static char *
-handle_comment(char * txt)
-{
- char * pz = strstr(txt, "-->");
- if (pz != NULL)
- pz += 3;
- return pz;
-}
-
-/**
- * "txt" points to the start of some value name.
- * The end of the entry is the end of the line that is not preceded by
- * a backslash escape character. The string value is always processed
- * in "cooked" mode.
- */
-static char *
-handle_cfg(tOptions * opts, tOptState * ost, char * txt, int dir)
-{
- char * pzName = txt++;
- char * pzEnd = strchr(txt, NL);
-
- if (pzEnd == NULL)
- return txt + strlen(txt);
-
- txt = SPN_VALUE_NAME_CHARS(txt);
- txt = SPN_WHITESPACE_CHARS(txt);
- if (txt > pzEnd) {
- name_only:
- *pzEnd++ = NUL;
- load_opt_line(opts, ost, pzName, dir, OPTION_LOAD_UNCOOKED);
- return pzEnd;
- }
-
- /*
- * Either the first character after the name is a ':' or '=',
- * or else we must have skipped over white space. Anything else
- * is an invalid format and we give up parsing the text.
- */
- if ((*txt == '=') || (*txt == ':')) {
- txt = SPN_WHITESPACE_CHARS(txt+1);
- if (txt > pzEnd)
- goto name_only;
- } else if (! IS_WHITESPACE_CHAR(txt[-1]))
- return NULL;
-
- /*
- * IF the value is continued, remove the backslash escape and push "pzEnd"
- * on to a newline *not* preceded by a backslash.
- */
- if (pzEnd[-1] == '\\') {
- char * pcD = pzEnd-1;
- char * pcS = pzEnd;
-
- for (;;) {
- char ch = *(pcS++);
- switch (ch) {
- case NUL:
- pcS = NULL;
- /* FALLTHROUGH */
-
- case NL:
- *pcD = NUL;
- pzEnd = pcS;
- goto copy_done;
-
- case '\\':
- if (*pcS == NL)
- ch = *(pcS++);
- /* FALLTHROUGH */
- default:
- *(pcD++) = ch;
- }
- } copy_done:;
-
- } else {
- /*
- * The newline was not preceded by a backslash. NUL it out
- */
- *(pzEnd++) = NUL;
- }
-
- /*
- * "pzName" points to what looks like text for one option/configurable.
- * It is NUL terminated. Process it.
- */
- load_opt_line(opts, ost, pzName, dir, OPTION_LOAD_UNCOOKED);
-
- return pzEnd;
-}
-
-/**
- * "txt" points to a "<?" sequence.
- * We handle "<?program" and "<?auto-options" directives.
- * All others are treated as comments.
- *
- * @param[in,out] opts program option descriptor
- * @param[in] txt scanning pointer
- * @returns the next character to look at
- */
-static char *
-handle_directive(tOptions * opts, char * txt)
-{
-# define DIRECTIVE_TABLE \
- _dt_(zCfgProg, program_directive) \
- _dt_(zCfgAO_Flags, aoflags_directive)
-
- typedef char * (directive_func_t)(tOptions *, char *);
-# define _dt_(_s, _fn) _fn,
- static directive_func_t * dir_disp[] = {
- DIRECTIVE_TABLE
- };
-# undef _dt_
-
-# define _dt_(_s, _fn) 1 +
- static int const dir_ct = DIRECTIVE_TABLE 0;
- static char const * dir_names[DIRECTIVE_TABLE 0];
-# undef _dt_
-
- int ix;
-
- if (dir_names[0] == NULL) {
- ix = 0;
-# define _dt_(_s, _fn) dir_names[ix++] = _s;
- DIRECTIVE_TABLE;
-# undef _dt_
- }
-
- for (ix = 0; ix < dir_ct; ix++) {
- size_t len = strlen(dir_names[ix]);
- if ( (strncmp(txt, dir_names[ix], len) == 0)
- && (! IS_VALUE_NAME_CHAR(txt[len])) )
- return dir_disp[ix](opts, txt + len);
- }
-
- /*
- * We don't know what this is. Skip it.
- */
- txt = strchr(txt+2, '>');
- if (txt != NULL)
- txt++;
- return txt;
-# undef DIRECTIVE_TABLE
-}
-
-/**
- * handle AutoOpts mode flags.
- *
- * @param[in,out] opts program option descriptor
- * @param[in] txt scanning pointer
- * @returns the next character to look at
- */
-static char *
-aoflags_directive(tOptions * opts, char * txt)
-{
- char * pz;
-
- pz = SPN_WHITESPACE_CHARS(txt+1);
- txt = strchr(pz, '>');
- if (txt != NULL) {
-
- size_t len = (unsigned)(txt - pz);
- char * ftxt = AGALOC(len + 1, "aoflags");
-
- memcpy(ftxt, pz, len);
- ftxt[len] = NUL;
- set_usage_flags(opts, ftxt);
- AGFREE(ftxt);
-
- txt++;
- }
-
- return txt;
-}
-
-/**
- * handle program segmentation of config file.
- *
- * @param[in,out] opts program option descriptor
- * @param[in] txt scanning pointer
- * @returns the next character to look at
- */
-static char *
-program_directive(tOptions * opts, char * txt)
-{
- size_t name_len = strlen(opts->pzProgName);
-
- for (;; txt += zCfgProg_LEN) {
- txt = SPN_WHITESPACE_CHARS(txt);
-
- if ( (strneqvcmp(txt, opts->pzProgName, (int)name_len) == 0)
- && (IS_END_XML_TOKEN_CHAR(txt[name_len])) )
-
- return txt + name_len;
-
- txt = strstr(txt, zCfgProg);
- if (txt == NULL)
- return txt;
- }
-
- for (;;) {
- if (*txt == NUL)
- return NULL;
-
- if (*(txt++) == '>')
- return txt;
- }
-}
-
-/**
- * "txt" points to a '[' character.
- * The "traditional" [PROG_NAME] segmentation of the config file.
- * Do not ever mix with the "<?program prog-name>" variation.
- * The templates reject program names over 16 characters.
- *
- * @param[in,out] opts program option descriptor
- * @param[in] txt scanning pointer
- * @returns the next character to look at
- */
-static char *
-handle_section(tOptions * opts, char * txt)
-{
- size_t len = strlen(opts->pzPROGNAME);
- if ( (strncmp(txt+1, opts->pzPROGNAME, len) == 0)
- && (txt[len+1] == ']'))
- return strchr(txt + len + 2, NL);
-
- if (len > 16)
- return NULL;
-
- {
- char z[24] = "[";
- memcpy(z+1, opts->pzPROGNAME, len);
- z[++len] = ']';
- z[++len] = NUL;
- txt = strstr(txt, z);
- }
-
- if (txt != NULL)
- txt = strchr(txt, NL);
- return txt;
-}
-
-/**
- * parse XML encodings
- */
-static int
-parse_xml_encoding(char ** ppz)
-{
-# define XMLTABLE \
- _xmlNm_(amp, '&') \
- _xmlNm_(lt, '<') \
- _xmlNm_(gt, '>') \
- _xmlNm_(ff, '\f') \
- _xmlNm_(ht, '\t') \
- _xmlNm_(cr, '\r') \
- _xmlNm_(vt, '\v') \
- _xmlNm_(bel, '\a') \
- _xmlNm_(nl, NL) \
- _xmlNm_(space, ' ') \
- _xmlNm_(quot, '"') \
- _xmlNm_(apos, '\'')
-
- static struct {
- char const * const nm_str;
- unsigned short nm_len;
- short nm_val;
- } const xml_names[] = {
-# define _xmlNm_(_n, _v) { #_n ";", sizeof(#_n), _v },
- XMLTABLE
-# undef _xmlNm_
-# undef XMLTABLE
- };
-
- static int const nm_ct = sizeof(xml_names) / sizeof(xml_names[0]);
- int base = 10;
-
- char * pz = *ppz;
-
- if (*pz == '#') {
- pz++;
- goto parse_number;
- }
-
- if (IS_DEC_DIGIT_CHAR(*pz)) {
- unsigned long v;
-
- parse_number:
- switch (*pz) {
- case 'x': case 'X':
- /*
- * Some forms specify hex with: &#xNN;
- */
- base = 16;
- pz++;
- break;
-
- case '0':
- /*
- * &#0022; is hex and &#22; is decimal. Cool.
- * Ya gotta love it.
- */
- if (pz[1] == '0')
- base = 16;
- break;
- }
-
- v = strtoul(pz, &pz, base);
- if ((*pz != ';') || (v > 0x7F))
- return NUL;
- *ppz = pz + 1;
- return (int)v;
- }
-
- {
- int ix = 0;
- do {
- if (strncmp(pz, xml_names[ix].nm_str, xml_names[ix].nm_len)
- == 0) {
- *ppz = pz + xml_names[ix].nm_len;
- return xml_names[ix].nm_val;
- }
- } while (++ix < nm_ct);
- }
-
- return NUL;
-}
-
-/**
- * Find the end marker for the named section of XML.
- * Trim that text there, trimming trailing white space for all modes
- * except for OPTION_LOAD_UNCOOKED.
- */
-static char *
-trim_xml_text(char * intxt, char const * pznm, tOptionLoadMode mode)
-{
- size_t nm_len = strlen(pznm);
- char * etext;
-
- {
- char z[64], *pz = z;
-
- if (nm_len + 4 >= sizeof(z))
- pz = AGALOC(nm_len + 4, "scan name");
-
- pz[0] = '<';
- pz[1] = '/';
- memcpy(pz+2, pznm, nm_len);
- nm_len += 2;
- pz[nm_len++] = '>';
- pz[nm_len] = NUL;
-
- *intxt = ' ';
- etext = strstr(intxt, pz);
- if (pz != z) AGFREE(pz);
- }
-
- if (etext == NULL)
- return etext;
-
- {
- char * result = etext + nm_len;
-
- if (mode != OPTION_LOAD_UNCOOKED)
- etext = SPN_WHITESPACE_BACK(intxt, etext);
-
- *etext = NUL;
- return result;
- }
-}
-
-/**
- */
-static void
-cook_xml_text(char * pzData)
-{
- char * pzs = pzData;
- char * pzd = pzData;
- char bf[4];
- bf[2] = NUL;
-
- for (;;) {
- int ch = ((int)*(pzs++)) & 0xFF;
- switch (ch) {
- case NUL:
- *pzd = NUL;
- return;
-
- case '&':
- ch = parse_xml_encoding(&pzs);
- *(pzd++) = (char)ch;
- if (ch == NUL)
- return;
- break;
-
- case '%':
- bf[0] = *(pzs++);
- bf[1] = *(pzs++);
- if ((bf[0] == NUL) || (bf[1] == NUL)) {
- *pzd = NUL;
- return;
- }
-
- ch = (int)strtoul(bf, NULL, 16);
- /* FALLTHROUGH */
-
- default:
- *(pzd++) = (char)ch;
- }
- }
-}
-
-/**
- * "txt" points to a '<' character, followed by an alpha.
- * The end of the entry is either the "/>" following the name, or else a
- * "</name>" string.
- */
-static char *
-handle_struct(tOptions * opts, tOptState * ost, char * txt, int dir)
-{
- tOptionLoadMode mode = option_load_mode;
- tOptionValue valu;
-
- char * pzName = ++txt;
- char * pzData;
- char * pcNulPoint;
-
- txt = SPN_VALUE_NAME_CHARS(txt);
- pcNulPoint = txt;
- valu.valType = OPARG_TYPE_STRING;
-
- switch (*txt) {
- case ' ':
- case '\t':
- txt = VOIDP(parse_attrs(
- opts, SPN_WHITESPACE_CHARS(txt), &mode, &valu));
- if (txt == NULL)
- return txt;
- if (*txt == '>')
- break;
- if (*txt != '/')
- return NULL;
- /* FALLTHROUGH */
-
- case '/':
- if (txt[1] != '>')
- return NULL;
- *txt = NUL;
- txt += 2;
- load_opt_line(opts, ost, pzName, dir, mode);
- return txt;
-
- case '>':
- break;
-
- default:
- txt = strchr(txt, '>');
- if (txt != NULL)
- txt++;
- return txt;
- }
-
- /*
- * If we are here, we have a value. "txt" points to a closing angle
- * bracket. Separate the name from the value for a moment.
- */
- *pcNulPoint = NUL;
- pzData = ++txt;
- txt = trim_xml_text(txt, pzName, mode);
- if (txt == NULL)
- return txt;
-
- /*
- * Rejoin the name and value for parsing by "load_opt_line()".
- * Erase any attributes parsed by "parse_attrs()".
- */
- memset(pcNulPoint, ' ', (size_t)(pzData - pcNulPoint));
-
- /*
- * If we are getting a "string" value that is to be cooked,
- * then process the XML-ish &xx; XML-ish and %XX hex characters.
- */
- if ( (valu.valType == OPARG_TYPE_STRING)
- && (mode == OPTION_LOAD_COOKED))
- cook_xml_text(pzData);
-
- /*
- * "pzName" points to what looks like text for one option/configurable.
- * It is NUL terminated. Process it.
- */
- load_opt_line(opts, ost, pzName, dir, mode);
-
- return txt;
-}
-
-/**
- * Load a configuration file. This may be invoked either from
- * scanning the "homerc" list, or from a specific file request.
- * (see "optionFileLoad()", the implementation for --load-opts)
- */
-static void
-intern_file_load(tOptions * opts)
-{
- uint32_t svfl;
- int idx;
- int inc;
- char f_name[ AG_PATH_MAX+1 ];
-
- if (opts->papzHomeList == NULL)
- return;
-
- svfl = opts->fOptSet;
- inc = DIRECTION_PRESET;
-
- /*
- * Never stop on errors in config files.
- */
- opts->fOptSet &= ~OPTPROC_ERRSTOP;
-
- /*
- * Find the last RC entry (highest priority entry)
- */
- for (idx = 0; opts->papzHomeList[ idx+1 ] != NULL; ++idx) ;
-
- /*
- * For every path in the home list, ... *TWICE* We start at the last
- * (highest priority) entry, work our way down to the lowest priority,
- * handling the immediate options.
- * Then we go back up, doing the normal options.
- */
- for (;;) {
- struct stat sb;
- cch_t * path;
-
- /*
- * IF we've reached the bottom end, change direction
- */
- if (idx < 0) {
- inc = DIRECTION_PROCESS;
- idx = 0;
- }
-
- path = opts->papzHomeList[ idx ];
-
- /*
- * IF we've reached the top end, bail out
- */
- if (path == NULL)
- break;
-
- idx += inc;
-
- if (! optionMakePath(f_name, (int)sizeof(f_name),
- path, opts->pzProgPath))
- continue;
-
- /*
- * IF the file name we constructed is a directory,
- * THEN append the Resource Configuration file name
- * ELSE we must have the complete file name
- */
- if (stat(f_name, &sb) != 0)
- continue; /* bogus name - skip the home list entry */
-
- if (S_ISDIR(sb.st_mode)) {
- size_t len = strlen(f_name);
- size_t nln = strlen(opts->pzRcName) + 1;
- char * pz = f_name + len;
-
- if (len + 1 + nln >= sizeof(f_name))
- continue;
-
- if (pz[-1] != DIRCH)
- *(pz++) = DIRCH;
- memcpy(pz, opts->pzRcName, nln);
- }
-
- file_preset(opts, f_name, inc);
-
- /*
- * IF we are now to skip config files AND we are presetting,
- * THEN change direction. We must go the other way.
- */
- {
- tOptDesc * od = opts->pOptDesc + opts->specOptIdx.save_opts + 1;
- if (DISABLED_OPT(od) && PRESETTING(inc)) {
- idx -= inc; /* go back and reprocess current file */
- inc = DIRECTION_PROCESS;
- }
- }
- } /* twice for every path in the home list, ... */
-
- opts->fOptSet = svfl;
-}
-
-/*=export_func optionFileLoad
- *
- * what: Load the locatable config files, in order
- *
- * arg: + tOptions * + opts + program options descriptor +
- * arg: + char const * + prog + program name +
- *
- * ret_type: int
- * ret_desc: 0 -> SUCCESS, -1 -> FAILURE
- *
- * doc:
- *
- * This function looks in all the specified directories for a configuration
- * file ("rc" file or "ini" file) and processes any found twice. The first
- * time through, they are processed in reverse order (last file first). At
- * that time, only "immediate action" configurables are processed. For
- * example, if the last named file specifies not processing any more
- * configuration files, then no more configuration files will be processed.
- * Such an option in the @strong{first} named directory will have no effect.
- *
- * Once the immediate action configurables have been handled, then the
- * directories are handled in normal, forward order. In that way, later
- * config files can override the settings of earlier config files.
- *
- * See the AutoOpts documentation for a thorough discussion of the
- * config file format.
- *
- * Configuration files not found or not decipherable are simply ignored.
- *
- * err: Returns the value, "-1" if the program options descriptor
- * is out of date or indecipherable. Otherwise, the value "0" will
- * always be returned.
-=*/
-int
-optionFileLoad(tOptions * opts, char const * prog)
-{
- if (! SUCCESSFUL(validate_struct(opts, prog)))
- return -1;
-
- /*
- * The pointer to the program name is "const". However, the
- * structure is in writable memory, so we coerce the address
- * of this pointer to point to writable memory.
- */
- {
- char const ** pp = VOIDP(&(opts->pzProgName));
- *pp = prog;
- }
-
- intern_file_load(opts);
- return 0;
-}
-
-/*=export_func optionLoadOpt
- * private:
- *
- * what: Load an option rc/ini file
- * arg: + tOptions * + opts + program options descriptor +
- * arg: + tOptDesc * + odesc + the descriptor for this arg +
- *
- * doc:
- * Processes the options found in the file named with
- * odesc->optArg.argString.
-=*/
-void
-optionLoadOpt(tOptions * opts, tOptDesc * odesc)
-{
- struct stat sb;
-
- if (opts <= OPTPROC_EMIT_LIMIT)
- return;
-
- /*
- * IF the option is not being disabled, THEN load the file. There must
- * be a file. (If it is being disabled, then the disablement processing
- * already took place. It must be done to suppress preloading of ini/rc
- * files.)
- */
- if ( DISABLED_OPT(odesc)
- || ((odesc->fOptState & OPTST_RESET) != 0))
- return;
-
- if (stat(odesc->optArg.argString, &sb) != 0) {
- if ((opts->fOptSet & OPTPROC_ERRSTOP) == 0)
- return;
-
- fserr_exit(opts->pzProgName, "stat", odesc->optArg.argString);
- /* NOT REACHED */
- }
-
- if (! S_ISREG(sb.st_mode)) {
- if ((opts->fOptSet & OPTPROC_ERRSTOP) == 0)
- return;
- errno = EINVAL;
- fserr_exit(opts->pzProgName, "stat", odesc->optArg.argString);
- /* NOT REACHED */
- }
-
- file_preset(opts, odesc->optArg.argString, DIRECTION_CALLED);
-}
-
-/**
- * Parse the various attributes of an XML-styled config file entry
- *
- * @returns NULL on failure, otherwise the scan point
- */
-static char const *
-parse_attrs(tOptions * opts, char const * txt, tOptionLoadMode * pMode,
- tOptionValue * pType)
-{
- size_t len = 0;
-
- for (;;) {
- len = (size_t)(SPN_LOWER_CASE_CHARS(txt) - txt);
-
- /*
- * The enumeration used in this switch is derived from this switch
- * statement itself. The "find_option_xat_attribute_cmd" function
- * will return XAT_CMD_MEMBERS for the "txt" string value
- * "members", etc.
- */
- switch (find_option_xat_attribute_cmd(txt, len)) {
- case XAT_CMD_TYPE:
- txt = parse_value(txt+len, pType);
- break;
-
- case XAT_CMD_WORDS:
- txt = parse_keyword(opts, txt+len, pType);
- break;
-
- case XAT_CMD_MEMBERS:
- txt = parse_set_mem(opts, txt+len, pType);
- break;
-
- case XAT_CMD_COOKED:
- txt += len;
- if (! IS_END_XML_TOKEN_CHAR(*txt))
- goto invalid_kwd;
-
- *pMode = OPTION_LOAD_COOKED;
- break;
-
- case XAT_CMD_UNCOOKED:
- txt += len;
- if (! IS_END_XML_TOKEN_CHAR(*txt))
- goto invalid_kwd;
-
- *pMode = OPTION_LOAD_UNCOOKED;
- break;
-
- case XAT_CMD_KEEP:
- txt += len;
- if (! IS_END_XML_TOKEN_CHAR(*txt))
- goto invalid_kwd;
-
- *pMode = OPTION_LOAD_KEEP;
- break;
-
- default:
- case XAT_INVALID_CMD:
- invalid_kwd:
- pType->valType = OPARG_TYPE_NONE;
- return skip_unkn(txt);
- }
-
- if (txt == NULL)
- return NULL;
- txt = SPN_WHITESPACE_CHARS(txt);
- switch (*txt) {
- case '/': pType->valType = OPARG_TYPE_NONE;
- /* FALLTHROUGH */
- case '>': return txt;
- }
- if (! IS_LOWER_CASE_CHAR(*txt))
- return NULL;
- }
-}
-
-/**
- * "txt" points to the character after "words=".
- * What should follow is a name of a keyword (enumeration) list.
- *
- * @param opts unused
- * @param[in] txt keyword to skip over
- * @param type unused value type
- * @returns pointer after skipped text
- */
-static char const *
-parse_keyword(tOptions * opts, char const * txt, tOptionValue * typ)
-{
- (void)opts;
- (void)typ;
-
- return skip_unkn(txt);
-}
-
-/**
- * "txt" points to the character after "members="
- * What should follow is a name of a "set membership".
- * A collection of bit flags.
- *
- * @param opts unused
- * @param[in] txt keyword to skip over
- * @param type unused value type
- * @returns pointer after skipped text
- */
-static char const *
-parse_set_mem(tOptions * opts, char const * txt, tOptionValue * typ)
-{
- (void)opts;
- (void)typ;
-
- return skip_unkn(txt);
-}
-
-/**
- * parse the type. The keyword "type" was found, now figure out
- * the type that follows the type.
- *
- * @param[in] txt points to the '=' character after the "type" keyword.
- * @param[out] typ where to store the type found
- * @returns the next byte after the type name
- */
-static char const *
-parse_value(char const * txt, tOptionValue * typ)
-{
- size_t len = 0;
-
- if (*(txt++) != '=')
- goto woops;
-
- len = (size_t)(SPN_OPTION_NAME_CHARS(txt) - txt);
-
- if ((len == 0) || (! IS_END_XML_TOKEN_CHAR(txt[len]))) {
- woops:
- typ->valType = OPARG_TYPE_NONE;
- return skip_unkn(txt + len);
- }
-
- /*
- * The enumeration used in this switch is derived from this switch
- * statement itself. The "find_option_value_type_cmd" function
- * will return VTP_CMD_INTEGER for the "txt" string value
- * "integer", etc.
- */
- switch (find_option_value_type_cmd(txt, len)) {
- default:
- case VTP_INVALID_CMD: goto woops;
-
- case VTP_CMD_STRING:
- typ->valType = OPARG_TYPE_STRING;
- break;
-
- case VTP_CMD_INTEGER:
- typ->valType = OPARG_TYPE_NUMERIC;
- break;
-
- case VTP_CMD_BOOL:
- case VTP_CMD_BOOLEAN:
- typ->valType = OPARG_TYPE_BOOLEAN;
- break;
-
- case VTP_CMD_KEYWORD:
- typ->valType = OPARG_TYPE_ENUMERATION;
- break;
-
- case VTP_CMD_SET:
- case VTP_CMD_SET_MEMBERSHIP:
- typ->valType = OPARG_TYPE_MEMBERSHIP;
- break;
-
- case VTP_CMD_NESTED:
- case VTP_CMD_HIERARCHY:
- typ->valType = OPARG_TYPE_HIERARCHY;
- }
-
- return txt + len;
-}
-
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/configfile.c */
diff --git a/src/libopts/cook.c b/src/libopts/cook.c
deleted file mode 100644
index 5240540f3a..0000000000
--- a/src/libopts/cook.c
+++ /dev/null
@@ -1,320 +0,0 @@
-/**
- * \file cook.c
- *
- * This file contains the routines that deal with processing quoted strings
- * into an internal format.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-/*=export_func ao_string_cook_escape_char
- * private:
- *
- * what: escape-process a string fragment
- * arg: + char const * + pzScan + points to character after the escape +
- * arg: + char * + pRes + Where to put the result byte +
- * arg: + unsigned int + nl_ch + replacement char if scanned char is \n +
- *
- * ret-type: unsigned int
- * ret-desc: The number of bytes consumed processing the escaped character.
- *
- * doc:
- *
- * This function converts "t" into "\t" and all your other favorite
- * escapes, including numeric ones: hex and ocatal, too.
- * The returned result tells the caller how far to advance the
- * scan pointer (passed in). The default is to just pass through the
- * escaped character and advance the scan by one.
- *
- * Some applications need to keep an escaped newline, others need to
- * suppress it. This is accomplished by supplying a '\n' replacement
- * character that is different from \n, if need be. For example, use
- * 0x7F and never emit a 0x7F.
- *
- * err: @code{NULL} is returned if the string is mal-formed.
-=*/
-unsigned int
-ao_string_cook_escape_char(char const * pzIn, char * pRes, uint_t nl)
-{
- unsigned int res = 1;
-
- switch (*pRes = *pzIn++) {
- case NUL: /* NUL - end of input string */
- return 0;
- case '\r':
- if (*pzIn != NL)
- return 1;
- res++;
- /* FALLTHROUGH */
- case NL: /* NL - emit newline */
- *pRes = (char)nl;
- return res;
-
- case 'a': *pRes = '\a'; break;
- case 'b': *pRes = '\b'; break;
- case 'f': *pRes = '\f'; break;
- case 'n': *pRes = NL; break;
- case 'r': *pRes = '\r'; break;
- case 't': *pRes = '\t'; break;
- case 'v': *pRes = '\v'; break;
-
- case 'x':
- case 'X': /* HEX Escape */
- if (IS_HEX_DIGIT_CHAR(*pzIn)) {
- char z[4];
- unsigned int ct = 0;
-
- do {
- z[ct] = pzIn[ct];
- if (++ct >= 2)
- break;
- } while (IS_HEX_DIGIT_CHAR(pzIn[ct]));
- z[ct] = NUL;
- *pRes = (char)strtoul(z, NULL, 16);
- return ct + 1;
- }
- break;
-
- case '0': case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
- {
- /*
- * IF the character copied was an octal digit,
- * THEN set the output character to an octal value.
- * The 3 octal digit result might exceed 0xFF, so check it.
- */
- char z[4];
- unsigned long val;
- unsigned int ct = 0;
-
- z[ct++] = *--pzIn;
- while (IS_OCT_DIGIT_CHAR(pzIn[ct])) {
- z[ct] = pzIn[ct];
- if (++ct >= 3)
- break;
- }
-
- z[ct] = NUL;
- val = strtoul(z, NULL, 8);
- if (val > 0xFF)
- val = 0xFF;
- *pRes = (char)val;
- return ct;
- }
-
- default: /* quoted character is result character */;
- }
-
- return res;
-}
-
-/**
- * count newlines between start and end
- */
-static char *
-nl_count(char * start, char * end, int * lnct_p)
-{
- while (start < end) {
- if (*(start++) == NL)
- (*lnct_p)++;
- }
- return end;
-}
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *
- * A quoted string has been found.
- * Find the end of it and compress any escape sequences.
- */
-static bool
-contiguous_quote(char ** pps, char * pq, int * lnct_p)
-{
- char * ps = *pps + 1;
-
- for (;;) {
- while (IS_WHITESPACE_CHAR(*ps))
- if (*(ps++) == NL)
- (*lnct_p)++;
-
- /*
- * IF the next character is a quote character,
- * THEN we will concatenate the strings.
- */
- switch (*ps) {
- case '"':
- case '\'':
- *pq = *(ps++); /* assign new quote character and return */
- *pps = ps;
- return true;
-
- case '/':
- /*
- * Allow for a comment embedded in the concatenated string.
- */
- switch (ps[1]) {
- default:
- goto fail_return;
-
- case '/':
- /*
- * Skip to end of line
- */
- ps = strchr(ps, NL);
- if (ps == NULL)
- goto fail_return;
- break;
-
- case '*':
- ps = nl_count(ps + 2, strstr(ps + 2, "*/"), lnct_p);
- if (ps == NULL)
- goto fail_return;
- ps += 2;
- }
- continue;
-
- default:
- /*
- * The next non-whitespace character is not a quote.
- * The series of quoted strings has come to an end.
- */
- *pps = ps;
- return false;
- }
- }
-
- fail_return:
- *pps = NULL;
- return false;
-}
-
-/*=export_func ao_string_cook
- * private:
- *
- * what: concatenate and escape-process strings
- * arg: + char * + pzScan + The *MODIFIABLE* input buffer +
- * arg: + int * + lnct_p + The (possibly NULL) pointer to a line count +
- *
- * ret-type: char *
- * ret-desc: The address of the text following the processed strings.
- * The return value is NULL if the strings are ill-formed.
- *
- * doc:
- *
- * A series of one or more quoted strings are concatenated together.
- * If they are quoted with double quotes (@code{"}), then backslash
- * escapes are processed per the C programming language. If they are
- * single quote strings, then the backslashes are honored only when they
- * precede another backslash or a single quote character.
- *
- * err: @code{NULL} is returned if the string(s) is/are mal-formed.
-=*/
-char *
-ao_string_cook(char * pzScan, int * lnct_p)
-{
- int l = 0;
- char q = *pzScan;
-
- /*
- * It is a quoted string. Process the escape sequence characters
- * (in the set "abfnrtv") and make sure we find a closing quote.
- */
- char * pzD = pzScan++;
- char * pzS = pzScan;
-
- if (lnct_p == NULL)
- lnct_p = &l;
-
- for (;;) {
- /*
- * IF the next character is the quote character, THEN we may end the
- * string. We end it unless the next non-blank character *after* the
- * string happens to also be a quote. If it is, then we will change
- * our quote character to the new quote character and continue
- * condensing text.
- */
- while (*pzS == q) {
- *pzD = NUL; /* This is probably the end of the line */
- if (! contiguous_quote(&pzS, &q, lnct_p))
- return pzS;
- }
-
- /*
- * We are inside a quoted string. Copy text.
- */
- switch (*(pzD++) = *(pzS++)) {
- case NUL:
- return NULL;
-
- case NL:
- (*lnct_p)++;
- break;
-
- case '\\':
- /*
- * IF we are escaping a new line,
- * THEN drop both the escape and the newline from
- * the result string.
- */
- if (*pzS == NL) {
- pzS++;
- pzD--;
- (*lnct_p)++;
- }
-
- /*
- * ELSE IF the quote character is '"' or '`',
- * THEN we do the full escape character processing
- */
- else if (q != '\'') {
- unsigned int ct;
- ct = ao_string_cook_escape_char(pzS, pzD-1, (uint_t)NL);
- if (ct == 0)
- return NULL;
-
- pzS += ct;
- } /* if (q != '\'') */
-
- /*
- * OTHERWISE, we only process "\\", "\'" and "\#" sequences.
- * The latter only to easily hide preprocessing directives.
- */
- else switch (*pzS) {
- case '\\':
- case '\'':
- case '#':
- pzD[-1] = *pzS++;
- }
- } /* switch (*(pzD++) = *(pzS++)) */
- } /* for (;;) */
-}
-
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/cook.c */
diff --git a/src/libopts/enum.c b/src/libopts/enum.c
deleted file mode 100644
index 7f92e0b022..0000000000
--- a/src/libopts/enum.c
+++ /dev/null
@@ -1,628 +0,0 @@
-
-/**
- * \file enumeration.c
- *
- * Handle options with enumeration names and bit mask bit names
- * for their arguments.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This routine will run run-on options through a pager so the
- * user may examine, print or edit them at their leisure.
- *
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-static void
-enum_err(tOptions * pOpts, tOptDesc * pOD,
- char const * const * paz_names, int name_ct)
-{
- size_t max_len = 0;
- size_t ttl_len = 0;
- int ct_down = name_ct;
- int hidden = 0;
-
- /*
- * A real "pOpts" pointer means someone messed up. Give a real error.
- */
- if (pOpts > OPTPROC_EMIT_LIMIT)
- fprintf(option_usage_fp, pz_enum_err_fmt, pOpts->pzProgName,
- pOD->optArg.argString, pOD->pz_Name);
-
- fprintf(option_usage_fp, zValidKeys, pOD->pz_Name);
-
- /*
- * If the first name starts with this funny character, then we have
- * a first value with an unspellable name. You cannot specify it.
- * So, we don't list it either.
- */
- if (**paz_names == 0x7F) {
- paz_names++;
- hidden = 1;
- ct_down = --name_ct;
- }
-
- /*
- * Figure out the maximum length of any name, plus the total length
- * of all the names.
- */
- {
- char const * const * paz = paz_names;
-
- do {
- size_t len = strlen(*(paz++)) + 1;
- if (len > max_len)
- max_len = len;
- ttl_len += len;
- } while (--ct_down > 0);
-
- ct_down = name_ct;
- }
-
- /*
- * IF any one entry is about 1/2 line or longer, print one per line
- */
- if (max_len > 35) {
- do {
- fprintf(option_usage_fp, ENUM_ERR_LINE, *(paz_names++));
- } while (--ct_down > 0);
- }
-
- /*
- * ELSE IF they all fit on one line, then do so.
- */
- else if (ttl_len < 76) {
- fputc(' ', option_usage_fp);
- do {
- fputc(' ', option_usage_fp);
- fputs(*(paz_names++), option_usage_fp);
- } while (--ct_down > 0);
- fputc(NL, option_usage_fp);
- }
-
- /*
- * Otherwise, columnize the output
- */
- else {
- unsigned int ent_no = 0;
- char fmt[16]; /* format for all-but-last entries on a line */
-
- if (snprintf(fmt, 16, ENUM_ERR_WIDTH, (int)max_len) >= 16)
- option_exits(EXIT_FAILURE);
- max_len = 78 / max_len; /* max_len is now max entries on a line */
- fputs(TWO_SPACES_STR, option_usage_fp);
-
- /*
- * Loop through all but the last entry
- */
- ct_down = name_ct;
- while (--ct_down > 0) {
- if (++ent_no == max_len) {
- /*
- * Last entry on a line. Start next line, too.
- */
- fprintf(option_usage_fp, NLSTR_SPACE_FMT, *(paz_names++));
- ent_no = 0;
- }
-
- else
- fprintf(option_usage_fp, fmt, *(paz_names++) );
- }
- fprintf(option_usage_fp, NLSTR_FMT, *paz_names);
- }
-
- if (pOpts > OPTPROC_EMIT_LIMIT) {
- fprintf(option_usage_fp, zIntRange, hidden, name_ct - 1 + hidden);
-
- (*(pOpts->pUsageProc))(pOpts, EXIT_FAILURE);
- /* NOTREACHED */
- }
-
- if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_MEMBERSHIP) {
- fprintf(option_usage_fp, zLowerBits, name_ct);
- fputs(zSetMemberSettings, option_usage_fp);
- } else {
- fprintf(option_usage_fp, zIntRange, hidden, name_ct - 1 + hidden);
- }
-}
-
-/**
- * Convert a name or number into a binary number.
- * "~0" and "-1" will be converted to the largest value in the enumeration.
- *
- * @param name the keyword name (number) to convert
- * @param pOpts the program's option descriptor
- * @param pOD the option descriptor for this option
- * @param paz_names the list of keywords for this option
- * @param name_ct the count of keywords
- */
-static uintptr_t
-find_name(char const * name, tOptions * pOpts, tOptDesc * pOD,
- char const * const * paz_names, unsigned int name_ct)
-{
- /*
- * Return the matching index as a pointer sized integer.
- * The result gets stashed in a char * pointer.
- */
- uintptr_t res = name_ct;
- size_t len = strlen((char *)name);
- uintptr_t idx;
-
- if (IS_DEC_DIGIT_CHAR(*name)) {
- char * pz = VOIDP(name);
- unsigned long val = strtoul(pz, &pz, 0);
- if ((*pz == NUL) && (val < name_ct))
- return (uintptr_t)val;
- pz_enum_err_fmt = znum_too_large;
- option_usage_fp = stderr;
- enum_err(pOpts, pOD, paz_names, (int)name_ct);
- return name_ct;
- }
-
- if (IS_INVERSION_CHAR(*name) && (name[2] == NUL)) {
- if ( ((name[0] == '~') && (name[1] == '0'))
- || ((name[0] == '-') && (name[1] == '1')))
- return (uintptr_t)(name_ct - 1);
- goto oops;
- }
-
- /*
- * Look for an exact match, but remember any partial matches.
- * Multiple partial matches means we have an ambiguous match.
- */
- for (idx = 0; idx < name_ct; idx++) {
- if (strncmp((char *)paz_names[idx], (char *)name, len) == 0) {
- if (paz_names[idx][len] == NUL)
- return idx; /* full match */
-
- if (res == name_ct)
- res = idx; /* save partial match */
- else
- res = (uintptr_t)~0; /* may yet find full match */
- }
- }
-
- if (res < name_ct)
- return res; /* partial match */
-
- oops:
-
- pz_enum_err_fmt = (res == name_ct) ? zNoKey : zambiguous_key;
- option_usage_fp = stderr;
- enum_err(pOpts, pOD, paz_names, (int)name_ct);
- return name_ct;
-}
-
-
-/*=export_func optionKeywordName
- * what: Convert between enumeration values and strings
- * private:
- *
- * arg: tOptDesc *, pOD, enumeration option description
- * arg: unsigned int, enum_val, the enumeration value to map
- *
- * ret_type: char const *
- * ret_desc: the enumeration name from const memory
- *
- * doc: This converts an enumeration value into the matching string.
-=*/
-char const *
-optionKeywordName(tOptDesc * pOD, unsigned int enum_val)
-{
- tOptDesc od = { 0 };
- od.optArg.argEnum = enum_val;
-
- (*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, &od );
- return od.optArg.argString;
-}
-
-
-/*=export_func optionEnumerationVal
- * what: Convert from a string to an enumeration value
- * private:
- *
- * arg: tOptions *, pOpts, the program options descriptor
- * arg: tOptDesc *, pOD, enumeration option description
- * arg: char const * const *, paz_names, list of enumeration names
- * arg: unsigned int, name_ct, number of names in list
- *
- * ret_type: uintptr_t
- * ret_desc: the enumeration value
- *
- * doc: This converts the optArg.argString string from the option description
- * into the index corresponding to an entry in the name list.
- * This will match the generated enumeration value.
- * Full matches are always accepted. Partial matches are accepted
- * if there is only one partial match.
-=*/
-uintptr_t
-optionEnumerationVal(tOptions * pOpts, tOptDesc * pOD,
- char const * const * paz_names, unsigned int name_ct)
-{
- uintptr_t res = 0UL;
-
- /*
- * IF the program option descriptor pointer is invalid,
- * then it is some sort of special request.
- */
- switch ((uintptr_t)pOpts) {
- case (uintptr_t)OPTPROC_EMIT_USAGE:
- /*
- * print the list of enumeration names.
- */
- enum_err(pOpts, pOD, paz_names, (int)name_ct);
- break;
-
- case (uintptr_t)OPTPROC_EMIT_SHELL:
- {
- unsigned int ix = (unsigned int)pOD->optArg.argEnum;
- /*
- * print the name string.
- */
- if (ix >= name_ct)
- printf(INVALID_FMT, ix);
- else
- fputs(paz_names[ ix ], stdout);
-
- break;
- }
-
- case (uintptr_t)OPTPROC_RETURN_VALNAME:
- {
- unsigned int ix = (unsigned int)pOD->optArg.argEnum;
- /*
- * Replace the enumeration value with the name string.
- */
- if (ix >= name_ct)
- return (uintptr_t)INVALID_STR;
-
- pOD->optArg.argString = paz_names[ix];
- break;
- }
-
- default:
- if ((pOD->fOptState & OPTST_RESET) != 0)
- break;
-
- res = find_name(pOD->optArg.argString, pOpts, pOD, paz_names, name_ct);
-
- if (pOD->fOptState & OPTST_ALLOC_ARG) {
- AGFREE(pOD->optArg.argString);
- pOD->fOptState &= ~OPTST_ALLOC_ARG;
- pOD->optArg.argString = NULL;
- }
- }
-
- return res;
-}
-
-static void
-set_memb_shell(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names,
- unsigned int name_ct)
-{
- /*
- * print the name string.
- */
- unsigned int ix = 0;
- uintptr_t bits = (uintptr_t)pOD->optCookie;
- size_t len = 0;
-
- (void)pOpts;
- bits &= ((uintptr_t)1 << (uintptr_t)name_ct) - (uintptr_t)1;
-
- while (bits != 0) {
- if (bits & 1) {
- if (len++ > 0) fputs(OR_STR, stdout);
- fputs(paz_names[ix], stdout);
- }
- if (++ix >= name_ct) break;
- bits >>= 1;
- }
-}
-
-static void
-set_memb_names(tOptions * opts, tOptDesc * od, char const * const * nm_list,
- unsigned int nm_ct)
-{
- char * pz;
- uintptr_t mask = (1UL << (uintptr_t)nm_ct) - 1UL;
- uintptr_t bits = (uintptr_t)od->optCookie & mask;
- unsigned int ix = 0;
- size_t len = 1;
-
- /*
- * Replace the enumeration value with the name string.
- * First, determine the needed length, then allocate and fill in.
- */
- while (bits != 0) {
- if (bits & 1)
- len += strlen(nm_list[ix]) + PLUS_STR_LEN + 1;
- if (++ix >= nm_ct) break;
- bits >>= 1;
- }
-
- od->optArg.argString = pz = AGALOC(len, "enum");
- bits = (uintptr_t)od->optCookie & mask;
- if (bits == 0) {
- *pz = NUL;
- return;
- }
-
- for (ix = 0; ; ix++) {
- size_t nln;
- int doit = bits & 1;
-
- bits >>= 1;
- if (doit == 0)
- continue;
-
- nln = strlen(nm_list[ix]);
- memcpy(pz, nm_list[ix], nln);
- pz += nln;
- if (bits == 0)
- break;
- memcpy(pz, PLUS_STR, PLUS_STR_LEN);
- pz += PLUS_STR_LEN;
- }
- *pz = NUL;
- (void)opts;
-}
-
-/**
- * Check membership start conditions. An equal character (@samp{=}) says to
- * clear the result and not carry over any residual value. A carat
- * (@samp{^}), which may follow the equal character, says to invert the
- * result. The scanning pointer is advanced past these characters and any
- * leading white space. Invalid sequences are indicated by setting the
- * scanning pointer to NULL.
- *
- * @param od the set membership option description
- * @param argp a pointer to the string scanning pointer
- * @param invert a pointer to the boolean inversion indicator
- *
- * @returns either zero or the original value for the optCookie.
- */
-static uintptr_t
-check_membership_start(tOptDesc * od, char const ** argp, bool * invert)
-{
- uintptr_t res = (uintptr_t)od->optCookie;
- char const * arg = SPN_WHITESPACE_CHARS(od->optArg.argString);
- if ((arg == NULL) || (*arg == NUL))
- goto member_start_fail;
-
- *invert = false;
-
- switch (*arg) {
- case '=':
- res = 0UL;
- arg = SPN_WHITESPACE_CHARS(arg + 1);
- switch (*arg) {
- case '=': case ',':
- goto member_start_fail;
- case '^':
- goto inversion;
- default:
- break;
- }
- break;
-
- case '^':
- inversion:
- *invert = true;
- arg = SPN_WHITESPACE_CHARS(arg + 1);
- if (*arg != ',')
- break;
- /* FALLTHROUGH */
-
- case ',':
- goto member_start_fail;
-
- default:
- break;
- }
-
- *argp = arg;
- return res;
-
-member_start_fail:
- *argp = NULL;
- return 0UL;
-}
-
-/**
- * convert a name to a bit. Look up a name string to get a bit number
- * and shift the value "1" left that number of bits.
- *
- * @param opts program options descriptor
- * @param od the set membership option description
- * @param pz address of the start of the bit name
- * @param nm_list the list of names for this option
- * @param nm_ct the number of entries in this list
- *
- * @returns 0UL on error, other an unsigned long with the correct bit set.
- */
-static uintptr_t
-find_member_bit(tOptions * opts, tOptDesc * od, char const * pz, int len,
- char const * const * nm_list, unsigned int nm_ct)
-{
- char nm_buf[ AO_NAME_SIZE ];
-
- memcpy(nm_buf, pz, len);
- nm_buf[len] = NUL;
-
- {
- unsigned int shift_ct = (unsigned int)
- find_name(nm_buf, opts, od, nm_list, nm_ct);
- if (shift_ct >= nm_ct)
- return 0UL;
-
- return 1UL << shift_ct;
- }
-}
-
-/*=export_func optionMemberList
- * what: Get the list of members of a bit mask set
- *
- * arg: tOptDesc *, od, the set membership option description
- *
- * ret_type: char *
- * ret_desc: the names of the set bits
- *
- * doc: This converts the OPT_VALUE_name mask value to a allocated string.
- * It is the caller's responsibility to free the string.
-=*/
-char *
-optionMemberList(tOptDesc * od)
-{
- uintptr_t sv = od->optArg.argIntptr;
- char * res;
- (*(od->pOptProc))(OPTPROC_RETURN_VALNAME, od);
- res = VOIDP(od->optArg.argString);
- od->optArg.argIntptr = sv;
- return res;
-}
-
-/*=export_func optionSetMembers
- * what: Convert between bit flag values and strings
- * private:
- *
- * arg: tOptions *, opts, the program options descriptor
- * arg: tOptDesc *, od, the set membership option description
- * arg: char const * const *,
- * nm_list, list of enumeration names
- * arg: unsigned int, nm_ct, number of names in list
- *
- * doc: This converts the optArg.argString string from the option description
- * into the index corresponding to an entry in the name list.
- * This will match the generated enumeration value.
- * Full matches are always accepted. Partial matches are accepted
- * if there is only one partial match.
-=*/
-void
-optionSetMembers(tOptions * opts, tOptDesc * od,
- char const * const * nm_list, unsigned int nm_ct)
-{
- /*
- * IF the program option descriptor pointer is invalid,
- * then it is some sort of special request.
- */
- switch ((uintptr_t)opts) {
- case (uintptr_t)OPTPROC_EMIT_USAGE:
- enum_err(OPTPROC_EMIT_USAGE, od, nm_list, nm_ct);
- return;
-
- case (uintptr_t)OPTPROC_EMIT_SHELL:
- set_memb_shell(opts, od, nm_list, nm_ct);
- return;
-
- case (uintptr_t)OPTPROC_RETURN_VALNAME:
- set_memb_names(opts, od, nm_list, nm_ct);
- return;
-
- default:
- break;
- }
-
- if ((od->fOptState & OPTST_RESET) != 0)
- return;
-
- {
- char const * arg;
- bool invert;
- uintptr_t res = check_membership_start(od, &arg, &invert);
- if (arg == NULL)
- goto fail_return;
-
- while (*arg != NUL) {
- bool inv_val = false;
- int len;
-
- switch (*arg) {
- case ',':
- arg = SPN_WHITESPACE_CHARS(arg+1);
- if ((*arg == ',') || (*arg == '|'))
- goto fail_return;
- continue;
-
- case '-':
- case '!':
- inv_val = true;
- /* FALLTHROUGH */
-
- case '+':
- case '|':
- arg = SPN_WHITESPACE_CHARS(arg+1);
- }
-
- len = (int)(BRK_SET_SEPARATOR_CHARS(arg) - arg);
- if (len == 0)
- break;
-
- if ((len == 3) && (strncmp(arg, zAll, 3) == 0)) {
- if (inv_val)
- res = 0;
- else res = ~0UL;
- }
- else if ((len == 4) && (strncmp(arg, zNone, 4) == 0)) {
- if (! inv_val)
- res = 0;
- }
- else do {
- char * pz;
- uintptr_t bit = strtoul(arg, &pz, 0);
-
- if (pz != arg + len) {
- bit = find_member_bit(opts, od, pz, len, nm_list, nm_ct);
- if (bit == 0UL)
- goto fail_return;
- }
- if (inv_val)
- res &= ~bit;
- else res |= bit;
- } while (false);
-
- arg = SPN_WHITESPACE_CHARS(arg + len);
- }
-
- if (invert)
- res ^= ~0UL;
-
- if (nm_ct < (8 * sizeof(uintptr_t)))
- res &= (1UL << nm_ct) - 1UL;
-
- od->optCookie = VOIDP(res);
- }
- return;
-
-fail_return:
- od->optCookie = VOIDP(0);
-}
-
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/enum.c */
diff --git a/src/libopts/env.c b/src/libopts/env.c
deleted file mode 100644
index 16f0e9513d..0000000000
--- a/src/libopts/env.c
+++ /dev/null
@@ -1,261 +0,0 @@
-
-/**
- * \file environment.c
- *
- * This file contains all of the routines that must be linked into
- * an executable to use the generated option processing. The optional
- * routines are in separately compiled modules so that they will not
- * necessarily be linked in.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-/*
- * doPrognameEnv - check for preset values from the ${PROGNAME}
- * environment variable. This is accomplished by parsing the text into
- * tokens, temporarily replacing the arg vector and calling
- * immediate_opts and/or regular_opts.
- */
-static void
-doPrognameEnv(tOptions * pOpts, teEnvPresetType type)
-{
- char const * env_opts = getenv(pOpts->pzPROGNAME);
- token_list_t * pTL;
- int sv_argc;
- proc_state_mask_t sv_flag;
- char ** sv_argv;
-
- /*
- * No such beast? Then bail now.
- */
- if (env_opts == NULL)
- return;
-
- /*
- * Tokenize the string. If there's nothing of interest, we'll bail
- * here immediately.
- */
- pTL = ao_string_tokenize(env_opts);
- if (pTL == NULL)
- return;
-
- /*
- * Substitute our $PROGNAME argument list for the real one
- */
- sv_argc = (int)pOpts->origArgCt;
- sv_argv = pOpts->origArgVect;
- sv_flag = pOpts->fOptSet;
-
- /*
- * We add a bogus pointer to the start of the list. The program name
- * has already been pulled from "argv", so it won't get dereferenced.
- * The option scanning code will skip the "program name" at the start
- * of this list of tokens, so we accommodate this way ....
- */
- {
- uintptr_t v = (uintptr_t)(pTL->tkn_list);
- pOpts->origArgVect = VOIDP(v - sizeof(char *));
- }
- pOpts->origArgCt = (unsigned int)pTL->tkn_ct + 1;
- pOpts->fOptSet &= ~OPTPROC_ERRSTOP;
-
- pOpts->curOptIdx = 1;
- pOpts->pzCurOpt = NULL;
-
- switch (type) {
- case ENV_IMM:
- (void)immediate_opts(pOpts);
- break;
-
- case ENV_ALL:
- (void)immediate_opts(pOpts);
- pOpts->curOptIdx = 1;
- pOpts->pzCurOpt = NULL;
- /* FALLTHROUGH */
-
- case ENV_NON_IMM:
- (void)regular_opts(pOpts);
- }
-
- /*
- * Free up the temporary arg vector and restore the original program args.
- */
- free(pTL);
- pOpts->origArgVect = sv_argv;
- pOpts->origArgCt = (unsigned int)sv_argc;
- pOpts->fOptSet = sv_flag;
-}
-
-static void
-do_env_opt(tOptState * os, char * env_name,
- tOptions * pOpts, teEnvPresetType type)
-{
- os->pzOptArg = getenv(env_name);
- if (os->pzOptArg == NULL)
- return;
-
- os->flags = OPTST_PRESET | OPTST_ALLOC_ARG | os->pOD->fOptState;
- os->optType = TOPT_UNDEFINED;
-
- if ( (os->pOD->pz_DisablePfx != NULL)
- && (streqvcmp(os->pzOptArg, os->pOD->pz_DisablePfx) == 0)) {
- os->flags |= OPTST_DISABLED;
- os->pzOptArg = NULL;
- handle_opt(pOpts, os);
- return;
- }
-
- switch (type) {
- case ENV_IMM:
- /*
- * Process only immediate actions
- */
- if (DO_IMMEDIATELY(os->flags))
- break;
- return;
-
- case ENV_NON_IMM:
- /*
- * Process only NON immediate actions
- */
- if (DO_NORMALLY(os->flags) || DO_SECOND_TIME(os->flags))
- break;
- return;
-
- default: /* process everything */
- break;
- }
-
- /*
- * Make sure the option value string is persistent and consistent.
- *
- * The interpretation of the option value depends
- * on the type of value argument the option takes
- */
- if (OPTST_GET_ARGTYPE(os->pOD->fOptState) == OPARG_TYPE_NONE) {
- /*
- * Ignore any value.
- */
- os->pzOptArg = NULL;
-
- } else if (os->pzOptArg[0] == NUL) {
- /*
- * If the argument is the empty string and the argument is
- * optional, then treat it as if the option was not specified.
- */
- if ((os->pOD->fOptState & OPTST_ARG_OPTIONAL) == 0)
- return;
- os->pzOptArg = NULL;
-
- } else {
- AGDUPSTR(os->pzOptArg, os->pzOptArg, "option argument");
- os->flags |= OPTST_ALLOC_ARG;
- }
-
- handle_opt(pOpts, os);
-}
-
-/*
- * env_presets - check for preset values from the envrionment
- * This routine should process in all, immediate or normal modes....
- */
-static void
-env_presets(tOptions * pOpts, teEnvPresetType type)
-{
- int ct;
- tOptState st;
- char * pzFlagName;
- size_t spaceLeft;
- char zEnvName[ AO_NAME_SIZE ];
-
- /*
- * Finally, see if we are to look at the environment
- * variables for initial values.
- */
- if ((pOpts->fOptSet & OPTPROC_ENVIRON) == 0)
- return;
-
- doPrognameEnv(pOpts, type);
-
- ct = pOpts->presetOptCt;
- st.pOD = pOpts->pOptDesc;
-
- pzFlagName = zEnvName
- + snprintf(zEnvName, sizeof(zEnvName), "%s_", pOpts->pzPROGNAME);
- spaceLeft = AO_NAME_SIZE - (unsigned long)(pzFlagName - zEnvName) - 1;
-
- for (;ct-- > 0; st.pOD++) {
- size_t nln;
-
- /*
- * If presetting is disallowed, then skip this entry
- */
- if ( ((st.pOD->fOptState & OPTST_NO_INIT) != 0)
- || (st.pOD->optEquivIndex != NO_EQUIVALENT) )
- continue;
-
- /*
- * IF there is no such environment variable,
- * THEN skip this entry, too.
- */
- nln = strlen(st.pOD->pz_NAME) + 1;
- if (nln <= spaceLeft) {
- /*
- * Set up the option state
- */
- memcpy(pzFlagName, st.pOD->pz_NAME, nln);
- do_env_opt(&st, zEnvName, pOpts, type);
- }
- }
-
- /*
- * Special handling for ${PROGNAME_LOAD_OPTS}
- */
- if ( (pOpts->specOptIdx.save_opts != NO_EQUIVALENT)
- && (pOpts->specOptIdx.save_opts != 0)) {
- size_t nln;
- st.pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts + 1;
-
- if (st.pOD->pz_NAME == NULL)
- return;
-
- nln = strlen(st.pOD->pz_NAME) + 1;
-
- if (nln > spaceLeft)
- return;
-
- memcpy(pzFlagName, st.pOD->pz_NAME, nln);
- do_env_opt(&st, zEnvName, pOpts, type);
- }
-}
-
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/environment.c */
diff --git a/src/libopts/file.c b/src/libopts/file.c
deleted file mode 100644
index 14efe8fe33..0000000000
--- a/src/libopts/file.c
+++ /dev/null
@@ -1,201 +0,0 @@
-
-/**
- * \file file.c
- *
- * Handle options that have file names for arguments.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-/**
- * Make sure the directory containing the subject file exists and that
- * the file exists or does not exist, per the option requirements.
- *
- * @param ftype file existence type flags
- * @param pOpts program option descriptor
- * @param pOD the option descriptor
- */
-static void
-check_existence(teOptFileType ftype, tOptions * pOpts, tOptDesc * pOD)
-{
- char const * fname = pOD->optArg.argString;
- struct stat sb;
-
- errno = 0;
-
- switch (ftype & FTYPE_MODE_EXIST_MASK) {
- case FTYPE_MODE_MUST_NOT_EXIST:
- if ((stat(fname, &sb) == 0) || (errno != ENOENT)) {
- if (errno == 0)
- errno = EINVAL;
- fserr_exit(pOpts->pzProgName, "stat", fname);
- /* NOTREACHED */
- }
- /* FALLTHROUGH */
-
- default:
- case FTYPE_MODE_MAY_EXIST:
- {
- char * p = strrchr(fname, DIRCH);
- size_t l;
-
- if (p == NULL)
- /*
- * The file may or may not exist and its directory is ".".
- * Assume that "." exists.
- */
- break;
-
- l = (size_t)(p - fname);
- p = AGALOC(l + 1, "fname");
- memcpy(p, fname, l);
- p[l] = NUL;
-
- if ((stat(p, &sb) != 0) || (errno = EINVAL, ! S_ISDIR(sb.st_mode)))
- fserr_exit(pOpts->pzProgName, "stat", p);
- /* NOTREACHED */
-
- AGFREE(p);
- break;
- }
-
- case FTYPE_MODE_MUST_EXIST:
- if ( (stat(fname, &sb) != 0)
- || (errno = EINVAL, ! S_ISREG(sb.st_mode)) )
- fserr_exit(pOpts->pzProgName, "stat", fname);
- /* NOTREACHED */
-
- break;
- }
-}
-
-/**
- * Open the specified file with open(2) and save the FD.
- *
- * @param pOpts program option descriptor
- * @param pOD the option descriptor
- * @param mode the open mode (uses int flags value)
- */
-static void
-open_file_fd(tOptions * pOpts, tOptDesc * pOD, tuFileMode mode)
-{
- int fd = open(pOD->optArg.argString, mode.file_flags);
- if (fd < 0)
- fserr_exit(pOpts->pzProgName, "open", pOD->optArg.argString);
- /* NOTREACHED */
-
- if ((pOD->fOptState & OPTST_ALLOC_ARG) != 0)
- pOD->optCookie = VOIDP(pOD->optArg.argString);
- else
- AGDUPSTR(pOD->optCookie, pOD->optArg.argString, "file name");
-
- pOD->optArg.argFd = fd;
- pOD->fOptState &= ~OPTST_ALLOC_ARG;
-}
-
-/**
- * Open the specified file with open(2) and save the FD.
- *
- * @param pOpts program option descriptor
- * @param pOD the option descriptor
- * @param mode the open mode (uses "char *" mode value)
- */
-static void
-fopen_file_fp(tOptions * pOpts, tOptDesc * pOD, tuFileMode mode)
-{
- FILE * fp = fopen(pOD->optArg.argString, mode.file_mode);
- if (fp == NULL)
- fserr_exit(pOpts->pzProgName, "fopen", pOD->optArg.argString);
- /* NOTREACHED */
-
- if ((pOD->fOptState & OPTST_ALLOC_ARG) != 0)
- pOD->optCookie = VOIDP(pOD->optArg.argString);
- else
- AGDUPSTR(pOD->optCookie, pOD->optArg.argString, "file name");
-
- pOD->optArg.argFp = fp;
- pOD->fOptState &= ~OPTST_ALLOC_ARG;
-}
-
-/*=export_func optionFileCheck
- * private:
- *
- * what: Decipher a boolean value
- * arg: + tOptions * + pOpts + program options descriptor +
- * arg: + tOptDesc * + pOptDesc + the descriptor for this arg +
- * arg: + teOptFileType + ftype + File handling type +
- * arg: + tuFileMode + mode + file open mode (if needed) +
- *
- * doc:
- * Make sure the named file conforms with the file type mode.
- * The mode specifies if the file must exist, must not exist or may
- * (or may not) exist. The mode may also specify opening the
- * file: don't, open just the descriptor (fd), or open as a stream
- * (FILE * pointer).
-=*/
-void
-optionFileCheck(tOptions * pOpts, tOptDesc * pOD,
- teOptFileType ftype, tuFileMode mode)
-{
- if (pOpts <= OPTPROC_EMIT_LIMIT) {
- if (pOpts != OPTPROC_EMIT_USAGE)
- return;
-
- switch (ftype & FTYPE_MODE_EXIST_MASK) {
- case FTYPE_MODE_MUST_NOT_EXIST:
- fputs(zFileCannotExist + tab_skip_ct, option_usage_fp);
- break;
-
- case FTYPE_MODE_MUST_EXIST:
- fputs(zFileMustExist + tab_skip_ct, option_usage_fp);
- break;
- }
- return;
- }
-
- if ((pOD->fOptState & OPTST_RESET) != 0) {
- if (pOD->optCookie != NULL)
- AGFREE(pOD->optCookie);
- return;
- }
-
- check_existence(ftype, pOpts, pOD);
-
- switch (ftype & FTYPE_MODE_OPEN_MASK) {
- default:
- case FTYPE_MODE_NO_OPEN: break;
- case FTYPE_MODE_OPEN_FD: open_file_fd( pOpts, pOD, mode); break;
- case FTYPE_MODE_FOPEN_FP: fopen_file_fp(pOpts, pOD, mode); break;
- }
-}
-
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/file.c */
diff --git a/src/libopts/find.c b/src/libopts/find.c
deleted file mode 100644
index 03ae103731..0000000000
--- a/src/libopts/find.c
+++ /dev/null
@@ -1,765 +0,0 @@
-/**
- * @file check.c
- *
- * @brief Hunt for options in the option descriptor list
- *
- * This file contains the routines that deal with processing quoted strings
- * into an internal format.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-/**
- * find the name and name length we are looking for
- */
-static int
-parse_opt(char const ** nm_pp, char ** arg_pp, char * buf, size_t bufsz)
-{
- int res = 0;
- char const * p = *nm_pp;
- *arg_pp = NULL;
-
- for (;;) {
- switch (*(p++)) {
- case NUL: return res;
-
- case '=':
- memcpy(buf, *nm_pp, (size_t)res);
-
- buf[res] = NUL;
- *nm_pp = buf;
- *arg_pp = (char *)p;
- return res;
-
- default:
- if (++res >= (int)bufsz)
- return -1;
- }
- }
-}
-
-/**
- * print out the options that match the given name.
- *
- * @param pOpts option data
- * @param opt_name name of option to look for
- */
-static void
-opt_ambiguities(tOptions * opts, char const * name, int nm_len)
-{
- char const * const hyph =
- NAMED_OPTS(opts) ? "" : LONG_OPT_MARKER;
-
- tOptDesc * pOD = opts->pOptDesc;
- int idx = 0;
-
- fputs(zambig_list_msg, stderr);
- do {
- if (pOD->pz_Name == NULL)
- continue; /* doc option */
-
- if (strneqvcmp(name, pOD->pz_Name, nm_len) == 0)
- fprintf(stderr, zambig_file, hyph, pOD->pz_Name);
-
- else if ( (pOD->pz_DisableName != NULL)
- && (strneqvcmp(name, pOD->pz_DisableName, nm_len) == 0)
- )
- fprintf(stderr, zambig_file, hyph, pOD->pz_DisableName);
- } while (pOD++, (++idx < opts->optCt));
-}
-
-/**
- * Determine the number of options that match the name
- *
- * @param pOpts option data
- * @param opt_name name of option to look for
- * @param nm_len length of provided name
- * @param index pointer to int for option index
- * @param disable pointer to bool to mark disabled option
- * @return count of options that match
- */
-static int
-opt_match_ct(tOptions * opts, char const * name, int nm_len,
- int * ixp, bool * disable)
-{
- int matchCt = 0;
- int idx = 0;
- int idxLim = opts->optCt;
- tOptDesc * pOD = opts->pOptDesc;
-
- do {
- /*
- * If option disabled or a doc option, skip to next
- */
- if (pOD->pz_Name == NULL)
- continue;
-
- if ( SKIP_OPT(pOD)
- && (pOD->fOptState != (OPTST_OMITTED | OPTST_NO_INIT)))
- continue;
-
- if (strneqvcmp(name, pOD->pz_Name, nm_len) == 0) {
- /*
- * IF we have a complete match
- * THEN it takes priority over any already located partial
- */
- if (pOD->pz_Name[ nm_len ] == NUL) {
- *ixp = idx;
- return 1;
- }
- }
-
- /*
- * IF there is a disable name
- * *AND* the option name matches the disable name
- * THEN ...
- */
- else if ( (pOD->pz_DisableName != NULL)
- && (strneqvcmp(name, pOD->pz_DisableName, nm_len) == 0)
- ) {
- *disable = true;
-
- /*
- * IF we have a complete match
- * THEN it takes priority over any already located partial
- */
- if (pOD->pz_DisableName[ nm_len ] == NUL) {
- *ixp = idx;
- return 1;
- }
- }
-
- else
- continue; /* does not match any option */
-
- /*
- * We found a full or partial match, either regular or disabling.
- * Remember the index for later.
- */
- *ixp = idx;
- ++matchCt;
-
- } while (pOD++, (++idx < idxLim));
-
- return matchCt;
-}
-
-/**
- * Set the option to the indicated option number.
- *
- * @param opts option data
- * @param arg option argument (if glued to name)
- * @param idx option index
- * @param disable mark disabled option
- * @param st state about current option
- */
-static tSuccess
-opt_set(tOptions * opts, char * arg, int idx, bool disable, tOptState * st)
-{
- tOptDesc * pOD = opts->pOptDesc + idx;
-
- if (SKIP_OPT(pOD)) {
- if ((opts->fOptSet & OPTPROC_ERRSTOP) == 0)
- return FAILURE;
-
- fprintf(stderr, zDisabledErr, opts->pzProgName, pOD->pz_Name);
- if (pOD->pzText != NULL)
- fprintf(stderr, SET_OFF_FMT, pOD->pzText);
- fputc(NL, stderr);
- (*opts->pUsageProc)(opts, EXIT_FAILURE);
- /* NOTREACHED */
- _exit(EXIT_FAILURE); /* to be certain */
- }
-
- /*
- * IF we found a disablement name,
- * THEN set the bit in the callers' flag word
- */
- if (disable)
- st->flags |= OPTST_DISABLED;
-
- st->pOD = pOD;
- st->pzOptArg = arg;
- st->optType = TOPT_LONG;
-
- return SUCCESS;
-}
-
-/**
- * An option was not found. Check for default option and set it
- * if there is one. Otherwise, handle the error.
- *
- * @param opts option data
- * @param name name of option to look for
- * @param arg option argument
- * @param st state about current option
- *
- * @return success status
- */
-static tSuccess
-opt_unknown(tOptions * opts, char const * name, char * arg, tOptState * st)
-{
- /*
- * IF there is no equal sign
- * *AND* we are using named arguments
- * *AND* there is a default named option,
- * THEN return that option.
- */
- if ( (arg == NULL)
- && NAMED_OPTS(opts)
- && (opts->specOptIdx.default_opt != NO_EQUIVALENT)) {
-
- st->pOD = opts->pOptDesc + opts->specOptIdx.default_opt;
- st->pzOptArg = name;
- st->optType = TOPT_DEFAULT;
- return SUCCESS;
- }
-
- if ((opts->fOptSet & OPTPROC_ERRSTOP) != 0) {
- fprintf(stderr, zIllOptStr, opts->pzProgPath, name);
- (*opts->pUsageProc)(opts, EXIT_FAILURE);
- /* NOTREACHED */
- _exit(EXIT_FAILURE); /* to be certain */
- }
-
- return FAILURE;
-}
-
-/**
- * Several options match the provided name.
- *
- * @param opts option data
- * @param name name of option to look for
- * @param match_ct number of matching options
- *
- * @return success status (always FAILURE, if it returns)
- */
-static tSuccess
-opt_ambiguous(tOptions * opts, char const * name, int match_ct)
-{
- if ((opts->fOptSet & OPTPROC_ERRSTOP) != 0) {
- fprintf(stderr, zambig_opt_fmt, opts->pzProgPath, name, match_ct);
- if (match_ct <= 4)
- opt_ambiguities(opts, name, (int)strlen(name));
- (*opts->pUsageProc)(opts, EXIT_FAILURE);
- /* NOTREACHED */
- _exit(EXIT_FAILURE); /* to be certain */
- }
- return FAILURE;
-}
-
-/*=export_func optionVendorOption
- * private:
- *
- * what: Process a vendor option
- * arg: + tOptions * + pOpts + program options descriptor +
- * arg: + tOptDesc * + pOptDesc + the descriptor for this arg +
- *
- * doc:
- * For POSIX specified utilities, the options are constrained to the options,
- * @xref{config attributes, Program Configuration}. AutoOpts clients should
- * never specify this directly. It gets referenced when the option
- * definitions contain a "vendor-opt" attribute.
-=*/
-void
-optionVendorOption(tOptions * pOpts, tOptDesc * pOD)
-{
- tOptState opt_st = OPTSTATE_INITIALIZER(PRESET);
- char const * vopt_str = pOD->optArg.argString;
-
- if (pOpts <= OPTPROC_EMIT_LIMIT)
- return;
-
- if ((pOD->fOptState & OPTST_RESET) != 0)
- return;
-
- if ((pOD->fOptState & OPTPROC_IMMEDIATE) == 0)
- opt_st.flags = OPTST_DEFINED;
-
- if ( ((pOpts->fOptSet & OPTPROC_VENDOR_OPT) == 0)
- || ! SUCCESSFUL(opt_find_long(pOpts, vopt_str, &opt_st))
- || ! SUCCESSFUL(get_opt_arg(pOpts, &opt_st)) )
- {
- fprintf(stderr, zIllVendOptStr, pOpts->pzProgName, vopt_str);
- (*pOpts->pUsageProc)(pOpts, EXIT_FAILURE);
- /* NOTREACHED */
- _exit(EXIT_FAILURE); /* to be certain */
- }
-
- /*
- * See if we are in immediate handling state.
- */
- if (pOpts->fOptSet & OPTPROC_IMMEDIATE) {
- /*
- * See if the enclosed option is okay with that state.
- */
- if (DO_IMMEDIATELY(opt_st.flags))
- (void)handle_opt(pOpts, &opt_st);
-
- } else {
- /*
- * non-immediate direction.
- * See if the enclosed option is okay with that state.
- */
- if (DO_NORMALLY(opt_st.flags) || DO_SECOND_TIME(opt_st.flags))
- (void)handle_opt(pOpts, &opt_st);
- }
-}
-
-/**
- * Find the option descriptor by full name.
- *
- * @param opts option data
- * @param opt_name name of option to look for
- * @param state state about current option
- *
- * @return success status
- */
-static tSuccess
-opt_find_long(tOptions * opts, char const * opt_name, tOptState * state)
-{
- char name_buf[128];
- char * opt_arg;
- int nm_len = parse_opt(&opt_name, &opt_arg, name_buf, sizeof(name_buf));
-
- int idx = 0;
- bool disable = false;
- int ct;
-
- if (nm_len <= 1) {
- if ((opts->fOptSet & OPTPROC_ERRSTOP) == 0)
- return FAILURE;
-
- fprintf(stderr, zInvalOptName, opts->pzProgName, opt_name);
- (*opts->pUsageProc)(opts, EXIT_FAILURE);
- /* NOTREACHED */
- _exit(EXIT_FAILURE); /* to be certain */
- }
-
- ct = opt_match_ct(opts, opt_name, nm_len, &idx, &disable);
-
- /*
- * See if we found one match, no matches or multiple matches.
- */
- switch (ct) {
- case 1: return opt_set(opts, opt_arg, idx, disable, state);
- case 0: return opt_unknown(opts, opt_name, opt_arg, state);
- default: return opt_ambiguous(opts, opt_name, ct);
- }
-}
-
-
-/**
- * Find the short option descriptor for the current option
- *
- * @param pOpts option data
- * @param optValue option flag character
- * @param pOptState state about current option
- */
-static tSuccess
-opt_find_short(tOptions * pOpts, uint_t optValue, tOptState * pOptState)
-{
- tOptDesc * pRes = pOpts->pOptDesc;
- int ct = pOpts->optCt;
-
- /*
- * Search the option list
- */
- do {
- if (optValue != pRes->optValue)
- continue;
-
- if (SKIP_OPT(pRes)) {
- if ( (pRes->fOptState == (OPTST_OMITTED | OPTST_NO_INIT))
- && (pRes->pz_Name != NULL)) {
- if ((pOpts->fOptSet & OPTPROC_ERRSTOP) == 0)
- return FAILURE;
-
- fprintf(stderr, zDisabledErr, pOpts->pzProgPath, pRes->pz_Name);
- if (pRes->pzText != NULL)
- fprintf(stderr, SET_OFF_FMT, pRes->pzText);
- fputc(NL, stderr);
- (*pOpts->pUsageProc)(pOpts, EXIT_FAILURE);
- /* NOTREACHED */
- _exit(EXIT_FAILURE); /* to be certain */
- }
- goto short_opt_error;
- }
-
- pOptState->pOD = pRes;
- pOptState->optType = TOPT_SHORT;
- return SUCCESS;
-
- } while (pRes++, --ct > 0);
-
- /*
- * IF the character value is a digit
- * AND there is a special number option ("-n")
- * THEN the result is the "option" itself and the
- * option is the specially marked "number" option.
- */
- if ( IS_DEC_DIGIT_CHAR(optValue)
- && (pOpts->specOptIdx.number_option != NO_EQUIVALENT) ) {
- pOptState->pOD = \
- pRes = pOpts->pOptDesc + pOpts->specOptIdx.number_option;
- (pOpts->pzCurOpt)--;
- pOptState->optType = TOPT_SHORT;
- return SUCCESS;
- }
-
- short_opt_error:
-
- /*
- * IF we are to stop on errors (the default, actually)
- * THEN call the usage procedure.
- */
- if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) {
- fprintf(stderr, zIllOptChr, pOpts->pzProgPath, optValue);
- (*pOpts->pUsageProc)(pOpts, EXIT_FAILURE);
- /* NOTREACHED */
- _exit(EXIT_FAILURE); /* to be certain */
- }
-
- return FAILURE;
-}
-
-/**
- * Process option with a required argument. Long options can either have a
- * separate command line argument, or an argument attached by the '='
- * character. Figure out which.
- *
- * @param[in,out] opts the program option descriptor
- * @param[in,out] o_st the option processing state
- * @returns SUCCESS or FAILURE
- */
-static tSuccess
-get_opt_arg_must(tOptions * opts, tOptState * o_st)
-{
- switch (o_st->optType) {
- case TOPT_SHORT:
- /*
- * See if an arg string follows the flag character
- */
- if (*++(opts->pzCurOpt) == NUL)
- opts->pzCurOpt = opts->origArgVect[ opts->curOptIdx++ ];
- o_st->pzOptArg = opts->pzCurOpt;
- break;
-
- case TOPT_LONG:
- /*
- * See if an arg string has already been assigned (glued on
- * with an `=' character)
- */
- if (o_st->pzOptArg == NULL)
- o_st->pzOptArg = opts->origArgVect[ opts->curOptIdx++ ];
- break;
-
- default:
-#ifdef DEBUG
- fputs("AutoOpts lib error: option type not selected\n", stderr);
- option_exits(EXIT_FAILURE);
-#endif
-
- case TOPT_DEFAULT:
- /*
- * The option was selected by default. The current token is
- * the option argument.
- */
- break;
- }
-
- /*
- * Make sure we did not overflow the argument list.
- */
- if (opts->curOptIdx > opts->origArgCt) {
- fprintf(stderr, zMisArg, opts->pzProgPath, o_st->pOD->pz_Name);
- return FAILURE;
- }
-
- opts->pzCurOpt = NULL; /* next time advance to next arg */
- return SUCCESS;
-}
-
-/**
- * Process an option with an optional argument. For short options, it looks
- * at the character after the option character, or it consumes the next full
- * argument. For long options, it looks for an '=' character attachment to
- * the long option name before deciding to take the next command line
- * argument.
- *
- * @param pOpts the option descriptor
- * @param o_st a structure for managing the current processing state
- * @returns SUCCESS or does not return
- */
-static tSuccess
-get_opt_arg_may(tOptions * pOpts, tOptState * o_st)
-{
- /*
- * An option argument is optional.
- */
- switch (o_st->optType) {
- case TOPT_SHORT:
- if (*++pOpts->pzCurOpt != NUL)
- o_st->pzOptArg = pOpts->pzCurOpt;
- else {
- char * pzLA = pOpts->origArgVect[ pOpts->curOptIdx ];
-
- /*
- * BECAUSE it is optional, we must make sure
- * we did not find another flag and that there
- * is such an argument.
- */
- if ((pzLA == NULL) || (*pzLA == '-'))
- o_st->pzOptArg = NULL;
- else {
- pOpts->curOptIdx++; /* argument found */
- o_st->pzOptArg = pzLA;
- }
- }
- break;
-
- case TOPT_LONG:
- /*
- * Look for an argument if we don't already have one (glued on
- * with a `=' character) *AND* we are not in named argument mode
- */
- if ( (o_st->pzOptArg == NULL)
- && (! NAMED_OPTS(pOpts))) {
- char * pzLA = pOpts->origArgVect[ pOpts->curOptIdx ];
-
- /*
- * BECAUSE it is optional, we must make sure
- * we did not find another flag and that there
- * is such an argument.
- */
- if ((pzLA == NULL) || (*pzLA == '-'))
- o_st->pzOptArg = NULL;
- else {
- pOpts->curOptIdx++; /* argument found */
- o_st->pzOptArg = pzLA;
- }
- }
- break;
-
- default:
- case TOPT_DEFAULT:
- ao_bug(zbad_default_msg);
- }
-
- /*
- * After an option with an optional argument, we will
- * *always* start with the next option because if there
- * were any characters following the option name/flag,
- * they would be interpreted as the argument.
- */
- pOpts->pzCurOpt = NULL;
- return SUCCESS;
-}
-
-/**
- * Process option that does not have an argument.
- *
- * @param[in,out] opts the program option descriptor
- * @param[in,out] o_st the option processing state
- * @returns SUCCESS or FAILURE
- */
-static tSuccess
-get_opt_arg_none(tOptions * pOpts, tOptState * o_st)
-{
- /*
- * No option argument. Make sure next time around we find
- * the correct option flag character for short options
- */
- if (o_st->optType == TOPT_SHORT)
- (pOpts->pzCurOpt)++;
-
- /*
- * It is a long option. Make sure there was no ``=xxx'' argument
- */
- else if (o_st->pzOptArg != NULL) {
- fprintf(stderr, zNoArg, pOpts->pzProgPath, o_st->pOD->pz_Name);
- return FAILURE;
- }
-
- /*
- * It is a long option. Advance to next command line argument.
- */
- else
- pOpts->pzCurOpt = NULL;
-
- return SUCCESS;
-}
-
-/**
- * Process option. Figure out whether or not to look for an option argument.
- *
- * @param[in,out] opts the program option descriptor
- * @param[in,out] o_st the option processing state
- * @returns SUCCESS or FAILURE
- */
-static tSuccess
-get_opt_arg(tOptions * opts, tOptState * o_st)
-{
- o_st->flags |= (o_st->pOD->fOptState & OPTST_PERSISTENT_MASK);
-
- /*
- * Disabled options and options specified to not have arguments
- * are handled with the "none" procedure. Otherwise, check the
- * optional flag and call either the "may" or "must" function.
- */
- if ((o_st->flags & OPTST_DISABLED) != 0)
- return get_opt_arg_none(opts, o_st);
-
- switch (OPTST_GET_ARGTYPE(o_st->flags)) {
- case OPARG_TYPE_STATIC:
- {
- /*
- * Propagate the static arg
- */
- tSuccess res = get_opt_arg_none(opts, o_st);
- o_st->pzOptArg = o_st->pOD->optArg.argString;
- return res;
- }
-
- case OPARG_TYPE_NONE:
- return get_opt_arg_none(opts, o_st);
- }
-
- if (o_st->flags & OPTST_ARG_OPTIONAL)
- return get_opt_arg_may( opts, o_st);
-
- return get_opt_arg_must(opts, o_st);
-}
-
-/**
- * Find the option descriptor for the current option.
- *
- * @param[in,out] opts the program option descriptor
- * @param[in,out] o_st the option processing state
- * @returns SUCCESS or FAILURE
- */
-static tSuccess
-find_opt(tOptions * opts, tOptState * o_st)
-{
- /*
- * IF we are continuing a short option list (e.g. -xyz...)
- * THEN continue a single flag option.
- * OTHERWISE see if there is room to advance and then do so.
- */
- if ((opts->pzCurOpt != NULL) && (*opts->pzCurOpt != NUL))
- return opt_find_short(opts, (uint8_t)*(opts->pzCurOpt), o_st);
-
- if (opts->curOptIdx >= opts->origArgCt)
- return PROBLEM; /* NORMAL COMPLETION */
-
- opts->pzCurOpt = opts->origArgVect[ opts->curOptIdx ];
-
- /*
- * IF all arguments must be named options, ...
- */
- if (NAMED_OPTS(opts)) {
- char * pz = opts->pzCurOpt;
- int def;
- tSuccess res;
- uint16_t * def_opt;
-
- opts->curOptIdx++;
-
- if (*pz != '-')
- return opt_find_long(opts, pz, o_st);
-
- /*
- * The name is prefixed with one or more hyphens. Strip them off
- * and disable the "default_opt" setting. Use heavy recasting to
- * strip off the "const" quality of the "default_opt" field.
- */
- while (*(++pz) == '-') ;
- def_opt = VOIDP(&(opts->specOptIdx.default_opt));
- def = *def_opt;
- *def_opt = NO_EQUIVALENT;
- res = opt_find_long(opts, pz, o_st);
- *def_opt = (uint16_t)def;
- return res;
- }
-
- /*
- * Note the kind of flag/option marker
- */
- if (*((opts->pzCurOpt)++) != '-')
- return PROBLEM; /* NORMAL COMPLETION - this + rest are operands */
-
- /*
- * Special hack for a hyphen by itself
- */
- if (*(opts->pzCurOpt) == NUL)
- return PROBLEM; /* NORMAL COMPLETION - this + rest are operands */
-
- /*
- * The current argument is to be processed as an option argument
- */
- opts->curOptIdx++;
-
- /*
- * We have an option marker.
- * Test the next character for long option indication
- */
- if (opts->pzCurOpt[0] == '-') {
- if (*++(opts->pzCurOpt) == NUL)
- /*
- * NORMAL COMPLETION - NOT this arg, but rest are operands
- */
- return PROBLEM;
-
- /*
- * We do not allow the hyphen to be used as a flag value.
- * Therefore, if long options are not to be accepted, we punt.
- */
- if ((opts->fOptSet & OPTPROC_LONGOPT) == 0) {
- fprintf(stderr, zIllOptStr, opts->pzProgPath, opts->pzCurOpt-2);
- return FAILURE;
- }
-
- return opt_find_long(opts, opts->pzCurOpt, o_st);
- }
-
- /*
- * If short options are not allowed, then do long
- * option processing. Otherwise the character must be a
- * short (i.e. single character) option.
- */
- if ((opts->fOptSet & OPTPROC_SHORTOPT) != 0)
- return opt_find_short(opts, (uint8_t)*(opts->pzCurOpt), o_st);
-
- return opt_find_long(opts, opts->pzCurOpt, o_st);
-}
-
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/find.c */
diff --git a/src/libopts/genshell.c b/src/libopts/genshell.c
deleted file mode 100644
index 05182a6014..0000000000
--- a/src/libopts/genshell.c
+++ /dev/null
@@ -1,848 +0,0 @@
-/* -*- buffer-read-only: t -*- vi: set ro:
- *
- * DO NOT EDIT THIS FILE (genshell.c)
- *
- * It has been AutoGen-ed
- * From the definitions genshell.def
- * and the template file options
- *
- * Generated from AutoOpts 42:1:17 templates.
- *
- * AutoOpts is a copyrighted work. This source file is not encumbered
- * by AutoOpts licensing, but is provided under the licensing terms chosen
- * by the genshellopt author or copyright holder. AutoOpts is
- * licensed under the terms of the LGPL. The redistributable library
- * (``libopts'') is licensed under the terms of either the LGPL or, at the
- * users discretion, the BSD license. See the AutoOpts and/or libopts sources
- * for details.
- *
- * The genshellopt program is copyrighted and licensed
- * under the following terms:
- *
- * Copyright (C) 1999-2018 Bruce Korb, all rights reserved.
- * This is free software. It is licensed for use, modification and
- * redistribution under the terms of the GNU Lesser General Public License,
- * version 2 or later <http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>
- *
- * The genshellopt library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, see
- * <http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>
- */
-
-#ifndef __doxygen__
-#define OPTION_CODE_COMPILE 1
-#include "genshell.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <errno.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-extern FILE * option_usage_fp;
-#define zCopyright (genshellopt_opt_strs+0)
-#define zLicenseDescrip (genshellopt_opt_strs+285)
-
-extern tUsageProc genshelloptUsage;
-
-#ifndef NULL
-# define NULL 0
-#endif
-
-/**
- * static const strings for genshellopt options
- */
-static char const genshellopt_opt_strs[1769] =
-/* 0 */ "genshellopt 1\n"
- "Copyright (C) 1999-2018 Bruce Korb, all rights reserved.\n"
- "This is free software. It is licensed for use, modification and\n"
- "redistribution under the terms of the GNU Lesser General Public License,\n"
- "version 2 or later <http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>\n\0"
-/* 285 */ "The genshellopt library is free software; you can redistribute it and/or\n"
- "modify it under the terms of the GNU Library General Public License as\n"
- "published by the Free Software Foundation; either version 2 of the License,\n"
- "or (at your option) any later version.\n\n"
- "This library is distributed in the hope that it will be useful, but WITHOUT\n"
- "ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n"
- "FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public\n"
- "License for more details.\n\n"
- "You should have received a copy of the GNU Library General Public License\n"
- "along with this library; if not, see\n"
- "<http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>\n\0"
-/* 957 */ "Output Script File\0"
-/* 976 */ "SCRIPT\0"
-/* 983 */ "script\0"
-/* 990 */ "Shell name (follows \"#!\" magic)\0"
-/* 1022 */ "SHELL\0"
-/* 1028 */ "no-shell\0"
-/* 1037 */ "no\0"
-/* 1040 */ "display extended usage information and exit\0"
-/* 1084 */ "help\0"
-/* 1089 */ "extended usage information passed thru pager\0"
-/* 1134 */ "more-help\0"
-/* 1144 */ "output version information and exit\0"
-/* 1180 */ "version\0"
-/* 1188 */ "GENSHELLOPT\0"
-/* 1200 */ "genshellopt - Generate Shell Option Processing Script - Ver. 1\n"
- "Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n\0"
-/* 1321 */ "autogen-users@lists.sourceforge.net\0"
-/* 1357 */ "Note that 'shell' is only useful if the output file does not already exist.\n"
- "If it does, then the shell name and optional first argument will be\n"
- "extracted from the script file.\n\0"
-/* 1534 */ "If the script file already exists and contains Automated Option Processing\n"
- "text, the second line of the file through the ending tag will be replaced\n"
- "by the newly generated text. The first '#!' line will be regenerated.\n\0"
-/* 1755 */ "genshellopt 1";
-
-/**
- * script option description:
- */
-/** Descriptive text for the script option */
-#define SCRIPT_DESC (genshellopt_opt_strs+957)
-/** Upper-cased name for the script option */
-#define SCRIPT_NAME (genshellopt_opt_strs+976)
-/** Name string for the script option */
-#define SCRIPT_name (genshellopt_opt_strs+983)
-/** Compiled in flag settings for the script option */
-#define SCRIPT_FLAGS (OPTST_DISABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
-
-/**
- * shell option description:
- */
-/** Descriptive text for the shell option */
-#define SHELL_DESC (genshellopt_opt_strs+990)
-/** Upper-cased name for the shell option */
-#define SHELL_NAME (genshellopt_opt_strs+1022)
-/** disablement name for the shell option */
-#define NOT_SHELL_name (genshellopt_opt_strs+1028)
-/** disablement prefix for the shell option */
-#define NOT_SHELL_PFX (genshellopt_opt_strs+1037)
-/** Name string for the shell option */
-#define SHELL_name (NOT_SHELL_name + 3)
-/** Compiled in flag settings for the shell option */
-#define SHELL_FLAGS (OPTST_INITENABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
-
-/*
- * Help/More_Help/Version option descriptions:
- */
-#define HELP_DESC (genshellopt_opt_strs+1040)
-#define HELP_name (genshellopt_opt_strs+1084)
-#ifdef HAVE_WORKING_FORK
-#define MORE_HELP_DESC (genshellopt_opt_strs+1089)
-#define MORE_HELP_name (genshellopt_opt_strs+1134)
-#define MORE_HELP_FLAGS (OPTST_IMM | OPTST_NO_INIT)
-#else
-#define MORE_HELP_DESC HELP_DESC
-#define MORE_HELP_name HELP_name
-#define MORE_HELP_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
-#endif
-#ifdef NO_OPTIONAL_OPT_ARGS
-# define VER_FLAGS (OPTST_IMM | OPTST_NO_INIT)
-#else
-# define VER_FLAGS (OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
- OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT)
-#endif
-#define VER_DESC (genshellopt_opt_strs+1144)
-#define VER_name (genshellopt_opt_strs+1180)
-/**
- * Declare option callback procedures
- */
-extern tOptProc
- optionBooleanVal, optionNestedVal, optionNumericVal,
- optionPagedUsage, optionPrintVersion, optionResetOpt,
- optionStackArg, optionTimeDate, optionTimeVal,
- optionUnstackArg, optionVendorOption;
-static tOptProc
- doUsageOpt;
-#define VER_PROC optionPrintVersion
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/**
- * Define the genshellopt Option Descriptions.
- * This is an array of GENSHELL_OPTION_CT entries, one for each
- * option that the genshellopt program responds to.
- */
-static tOptDesc optDesc[GENSHELL_OPTION_CT] = {
- { /* entry idx, value */ 0, VALUE_GENSHELL_OPT_SCRIPT,
- /* equiv idx, value */ 0, VALUE_GENSHELL_OPT_SCRIPT,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ SCRIPT_FLAGS, 0,
- /* last opt argumnt */ { NULL }, /* --script */
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ SCRIPT_DESC, SCRIPT_NAME, SCRIPT_name,
- /* disablement strs */ NULL, NULL },
-
- { /* entry idx, value */ 1, VALUE_GENSHELL_OPT_SHELL,
- /* equiv idx, value */ 1, VALUE_GENSHELL_OPT_SHELL,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ SHELL_FLAGS, 0,
- /* last opt argumnt */ { NULL }, /* --shell */
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ SHELL_DESC, SHELL_NAME, SHELL_name,
- /* disablement strs */ NOT_SHELL_name, NOT_SHELL_PFX },
-
- { /* entry idx, value */ INDEX_GENSHELL_OPT_VERSION, VALUE_GENSHELL_OPT_VERSION,
- /* equiv idx value */ NO_EQUIVALENT, VALUE_GENSHELL_OPT_VERSION,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ VER_FLAGS, AOUSE_VERSION,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ VER_PROC,
- /* desc, NAME, name */ VER_DESC, NULL, VER_name,
- /* disablement strs */ NULL, NULL },
-
-
-
- { /* entry idx, value */ INDEX_GENSHELL_OPT_HELP, VALUE_GENSHELL_OPT_HELP,
- /* equiv idx value */ NO_EQUIVALENT, VALUE_GENSHELL_OPT_HELP,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, AOUSE_HELP,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ doUsageOpt,
- /* desc, NAME, name */ HELP_DESC, NULL, HELP_name,
- /* disablement strs */ NULL, NULL },
-
- { /* entry idx, value */ INDEX_GENSHELL_OPT_MORE_HELP, VALUE_GENSHELL_OPT_MORE_HELP,
- /* equiv idx value */ NO_EQUIVALENT, VALUE_GENSHELL_OPT_MORE_HELP,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ MORE_HELP_FLAGS, AOUSE_MORE_HELP,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ optionPagedUsage,
- /* desc, NAME, name */ MORE_HELP_DESC, NULL, MORE_HELP_name,
- /* disablement strs */ NULL, NULL }
-};
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/** Reference to the upper cased version of genshellopt. */
-#define zPROGNAME (genshellopt_opt_strs+1188)
-/** Reference to the title line for genshellopt usage. */
-#define zUsageTitle (genshellopt_opt_strs+1200)
-/** There is no genshellopt configuration file. */
-#define zRcName NULL
-/** There are no directories to search for genshellopt config files. */
-#define apzHomeList NULL
-/** The genshellopt program bug email address. */
-#define zBugsAddr (genshellopt_opt_strs+1321)
-/** Clarification/explanation of what genshellopt does. */
-#define zExplain (genshellopt_opt_strs+1357)
-/** Extra detail explaining what genshellopt does. */
-#define zDetail (genshellopt_opt_strs+1534)
-/** The full version string for genshellopt. */
-#define zFullVersion (genshellopt_opt_strs+1755)
-/* extracted from optcode.tlib near line 342 */
-
-#if defined(ENABLE_NLS)
-# define OPTPROC_BASE OPTPROC_TRANSLATE
- static tOptionXlateProc translate_option_strings;
-#else
-# define OPTPROC_BASE OPTPROC_NONE
-# define translate_option_strings NULL
-#endif /* ENABLE_NLS */
-
-#define genshellopt_full_usage (NULL)
-#define genshellopt_short_usage (NULL)
-
-#endif /* not defined __doxygen__ */
-
-/*
- * Create the static procedure(s) declared above.
- */
-/**
- * The callout function that invokes the genshelloptUsage function.
- *
- * @param[in] opts the AutoOpts option description structure
- * @param[in] od the descriptor for the "help" (usage) option.
- * @noreturn
- */
-static void
-doUsageOpt(tOptions * opts, tOptDesc * od)
-{
- int ex_code;
- ex_code = GENSHELLOPT_EXIT_SUCCESS;
- genshelloptUsage(&genshelloptOptions, ex_code);
- /* NOTREACHED */
- exit(GENSHELLOPT_EXIT_FAILURE);
- (void)opts;
- (void)od;
-}
-/* extracted from optmain.tlib near line 1250 */
-
-/**
- * The directory containing the data associated with genshellopt.
- */
-#ifndef PKGDATADIR
-# define PKGDATADIR ""
-#endif
-
-/**
- * Information about the person or institution that packaged genshellopt
- * for the current distribution.
- */
-#ifndef WITH_PACKAGER
-# define genshellopt_packager_info NULL
-#else
-/** Packager information for genshellopt. */
-static char const genshellopt_packager_info[] =
- "Packaged by " WITH_PACKAGER
-
-# ifdef WITH_PACKAGER_VERSION
- " ("WITH_PACKAGER_VERSION")"
-# endif
-
-# ifdef WITH_PACKAGER_BUG_REPORTS
- "\nReport genshellopt bugs to " WITH_PACKAGER_BUG_REPORTS
-# endif
- "\n";
-#endif
-#ifndef __doxygen__
-
-#endif /* __doxygen__ */
-/**
- * The option definitions for genshellopt. The one structure that
- * binds them all.
- */
-tOptions genshelloptOptions = {
- OPTIONS_STRUCT_VERSION,
- 0, NULL, /* original argc + argv */
- ( OPTPROC_BASE
- + OPTPROC_ERRSTOP
- + OPTPROC_SHORTOPT
- + OPTPROC_LONGOPT
- + OPTPROC_NO_REQ_OPT
- + OPTPROC_NEGATIONS
- + OPTPROC_NO_ARGS ),
- 0, NULL, /* current option index, current option */
- NULL, NULL, zPROGNAME,
- zRcName, zCopyright, zLicenseDescrip,
- zFullVersion, apzHomeList, zUsageTitle,
- zExplain, zDetail, optDesc,
- zBugsAddr, /* address to send bugs to */
- NULL, NULL, /* extensions/saved state */
- genshelloptUsage, /* usage procedure */
- translate_option_strings, /* translation procedure */
- /*
- * Indexes to special options
- */
- { INDEX_GENSHELL_OPT_MORE_HELP, /* more-help option index */
- NO_EQUIVALENT, /* save option index */
- NO_EQUIVALENT, /* '-#' option index */
- NO_EQUIVALENT /* index of default opt */
- },
- 5 /* full option count */, 2 /* user option count */,
- genshellopt_full_usage, genshellopt_short_usage,
- NULL, NULL,
- PKGDATADIR, genshellopt_packager_info
-};
-
-#if ENABLE_NLS
-/**
- * This code is designed to translate translatable option text for the
- * genshellopt program. These translations happen upon entry
- * to optionProcess().
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#ifdef HAVE_DCGETTEXT
-# include <gettext.h>
-#endif
-#include <autoopts/usage-txt.h>
-
-static char * AO_gettext(char const * pz);
-static void coerce_it(void ** s);
-
-/**
- * AutoGen specific wrapper function for gettext. It relies on the macro _()
- * to convert from English to the target language, then strdup-duplicates the
- * result string. It tries the "libopts" domain first, then whatever has been
- * set via the \a textdomain(3) call.
- *
- * @param[in] pz the input text used as a lookup key.
- * @returns the translated text (if there is one),
- * or the original text (if not).
- */
-static char *
-AO_gettext(char const * pz)
-{
- char * res;
- if (pz == NULL)
- return NULL;
-#ifdef HAVE_DCGETTEXT
- /*
- * While processing the option_xlateable_txt data, try to use the
- * "libopts" domain. Once we switch to the option descriptor data,
- * do *not* use that domain.
- */
- if (option_xlateable_txt.field_ct != 0) {
- res = dgettext("libopts", pz);
- if (res == pz)
- res = (char *)VOIDP(_(pz));
- } else
- res = (char *)VOIDP(_(pz));
-#else
- res = (char *)VOIDP(_(pz));
-#endif
- if (res == pz)
- return res;
- res = strdup(res);
- if (res == NULL) {
- fputs(_("No memory for duping translated strings\n"), stderr);
- exit(GENSHELLOPT_EXIT_FAILURE);
- }
- return res;
-}
-
-/**
- * All the pointers we use are marked "* const", but they are stored in
- * writable memory. Coerce the mutability and set the pointer.
- */
-static void coerce_it(void ** s) { *s = AO_gettext(*s);
-}
-
-/**
- * Translate all the translatable strings in the genshelloptOptions
- * structure defined above. This is done only once.
- */
-static void
-translate_option_strings(void)
-{
- tOptions * const opts = &genshelloptOptions;
-
- /*
- * Guard against re-translation. It won't work. The strings will have
- * been changed by the first pass through this code. One shot only.
- */
- if (option_xlateable_txt.field_ct != 0) {
- /*
- * Do the translations. The first pointer follows the field count
- * field. The field count field is the size of a pointer.
- */
- char ** ppz = (char**)VOIDP(&(option_xlateable_txt));
- int ix = option_xlateable_txt.field_ct;
-
- do {
- ppz++; /* skip over field_ct */
- *ppz = AO_gettext(*ppz);
- } while (--ix > 0);
- /* prevent re-translation and disable "libopts" domain lookup */
- option_xlateable_txt.field_ct = 0;
-
- coerce_it(VOIDP(&(opts->pzCopyright)));
- coerce_it(VOIDP(&(opts->pzCopyNotice)));
- coerce_it(VOIDP(&(opts->pzFullVersion)));
- coerce_it(VOIDP(&(opts->pzUsageTitle)));
- coerce_it(VOIDP(&(opts->pzExplain)));
- coerce_it(VOIDP(&(opts->pzDetail)));
- {
- tOptDesc * od = opts->pOptDesc;
- for (ix = opts->optCt; ix > 0; ix--, od++)
- coerce_it(VOIDP(&(od->pzText)));
- }
- }
-}
-#endif /* ENABLE_NLS */
-
-#ifdef DO_NOT_COMPILE_THIS_CODE_IT_IS_FOR_GETTEXT
-/** I18N function strictly for xgettext. Do not compile. */
-static void bogus_function(void) {
- /* TRANSLATORS:
-
- The following dummy function was crated solely so that xgettext can
- extract the correct strings. These strings are actually referenced
- by a field name in the genshelloptOptions structure noted in the
- comments below. The literal text is defined in genshellopt_opt_strs.
-
- NOTE: the strings below are segmented with respect to the source string
- genshellopt_opt_strs. The strings above are handed off for translation
- at run time a paragraph at a time. Consequently, they are presented here
- for translation a paragraph at a time.
-
- ALSO: often the description for an option will reference another option
- by name. These are set off with apostrophe quotes (I hope). Do not
- translate option names.
- */
- /* referenced via genshelloptOptions.pzCopyright */
- puts(_("genshellopt 1\n\
-Copyright (C) 1999-2018 Bruce Korb, all rights reserved.\n\
-This is free software. It is licensed for use, modification and\n\
-redistribution under the terms of the GNU Lesser General Public License,\n\
-version 2 or later <http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>\n"));
-
- /* referenced via genshelloptOptions.pzCopyNotice */
- puts(_("The genshellopt library is free software; you can redistribute it and/or\n\
-modify it under the terms of the GNU Library General Public License as\n\
-published by the Free Software Foundation; either version 2 of the License,\n\
-or (at your option) any later version.\n\n"));
- puts(_("This library is distributed in the hope that it will be useful, but WITHOUT\n\
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n\
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public\n\
-License for more details.\n\n"));
- puts(_("You should have received a copy of the GNU Library General Public License\n\
-along with this library; if not, see\n\
-<http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>\n"));
-
- /* referenced via genshelloptOptions.pOptDesc->pzText */
- puts(_("Output Script File"));
-
- /* referenced via genshelloptOptions.pOptDesc->pzText */
- puts(_("Shell name (follows \"#!\" magic)"));
-
- /* referenced via genshelloptOptions.pOptDesc->pzText */
- puts(_("display extended usage information and exit"));
-
- /* referenced via genshelloptOptions.pOptDesc->pzText */
- puts(_("extended usage information passed thru pager"));
-
- /* referenced via genshelloptOptions.pOptDesc->pzText */
- puts(_("output version information and exit"));
-
- /* referenced via genshelloptOptions.pzUsageTitle */
- puts(_("genshellopt - Generate Shell Option Processing Script - Ver. 1\n\
-Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n"));
-
- /* referenced via genshelloptOptions.pzExplain */
- puts(_("Note that 'shell' is only useful if the output file does not already exist.\n\
-If it does, then the shell name and optional first argument will be\n\
-extracted from the script file.\n"));
-
- /* referenced via genshelloptOptions.pzDetail */
- puts(_("If the script file already exists and contains Automated Option Processing\n\
-text, the second line of the file through the ending tag will be replaced\n\
-by the newly generated text. The first '#!' line will be regenerated.\n"));
-
- /* referenced via genshelloptOptions.pzFullVersion */
- puts(_("genshellopt 1"));
-
- /* referenced via genshelloptOptions.pzFullUsage */
- puts(_("<<<NOT-FOUND>>>"));
-
- /* referenced via genshelloptOptions.pzShortUsage */
- puts(_("<<<NOT-FOUND>>>"));
- /* LIBOPTS-MESSAGES: */
-#line 67 "../autoopts.c"
- puts(_("allocation of %d bytes failed\n"));
-#line 89 "../autoopts.c"
- puts(_("allocation of %d bytes failed\n"));
-#line 48 "../init.c"
- puts(_("AutoOpts function called without option descriptor\n"));
-#line 81 "../init.c"
- puts(_("\tThis exceeds the compiled library version: "));
-#line 79 "../init.c"
- puts(_("Automated Options Processing Error!\n"
- "\t%s called AutoOpts function with structure version %d:%d:%d.\n"));
-#line 78 "../autoopts.c"
- puts(_("realloc of %d bytes at 0x%p failed\n"));
-#line 83 "../init.c"
- puts(_("\tThis is less than the minimum library version: "));
-#line 121 "../version.c"
- puts(_("Automated Options version %s\n"
- "\tCopyright (C) 1999-2017 by Bruce Korb - all rights reserved\n"));
-#line 49 "../makeshell.c"
- puts(_("(AutoOpts bug): %s.\n"));
-#line 90 "../reset.c"
- puts(_("optionResetOpt() called, but reset-option not configured"));
-#line 241 "../usage.c"
- puts(_("could not locate the 'help' option"));
-#line 330 "../autoopts.c"
- puts(_("optionProcess() was called with invalid data"));
-#line 697 "../usage.c"
- puts(_("invalid argument type specified"));
-#line 568 "../find.c"
- puts(_("defaulted to option with optional arg"));
-#line 76 "../alias.c"
- puts(_("aliasing option is out of range."));
-#line 210 "../enum.c"
- puts(_("%s error: the keyword '%s' is ambiguous for %s\n"));
-#line 78 "../find.c"
- puts(_(" The following options match:\n"));
-#line 263 "../find.c"
- puts(_("%s: ambiguous option name: %s (matches %d options)\n"));
-#line 161 "../check.c"
- puts(_("%s: Command line arguments required\n"));
-#line 43 "../alias.c"
- puts(_("%d %s%s options allowed\n"));
-#line 56 "../makeshell.c"
- puts(_("%s error %d (%s) calling %s for '%s'\n"));
-#line 268 "../makeshell.c"
- puts(_("interprocess pipe"));
-#line 171 "../version.c"
- puts(_("error: version option argument '%c' invalid. Use:\n"
- "\t'v' - version only\n"
- "\t'c' - version and copyright\n"
- "\t'n' - version and full copyright notice\n"));
-#line 58 "../check.c"
- puts(_("%s error: the '%s' and '%s' options conflict\n"));
-#line 187 "../find.c"
- puts(_("%s: The '%s' option has been disabled."));
-#line 400 "../find.c"
- puts(_("%s: The '%s' option has been disabled."));
-#line 38 "../alias.c"
- puts(_("-equivalence"));
-#line 439 "../find.c"
- puts(_("%s: illegal option -- %c\n"));
-#line 110 "../reset.c"
- puts(_("%s: illegal option -- %c\n"));
-#line 241 "../find.c"
- puts(_("%s: illegal option -- %s\n"));
-#line 740 "../find.c"
- puts(_("%s: illegal option -- %s\n"));
-#line 118 "../reset.c"
- puts(_("%s: illegal option -- %s\n"));
-#line 305 "../find.c"
- puts(_("%s: unknown vendor extension option -- %s\n"));
-#line 135 "../enum.c"
- puts(_(" or an integer from %d through %d\n"));
-#line 145 "../enum.c"
- puts(_(" or an integer from %d through %d\n"));
-#line 696 "../usage.c"
- puts(_("%s error: invalid option descriptor for %s\n"));
-#line 1030 "../usage.c"
- puts(_("%s error: invalid option descriptor for %s\n"));
-#line 355 "../find.c"
- puts(_("%s: invalid option name: %s\n"));
-#line 497 "../find.c"
- puts(_("%s: The '%s' option requires an argument.\n"));
-#line 150 "../autoopts.c"
- puts(_("(AutoOpts bug): Equivalenced option '%s' was equivalenced to both\n"
- "\t'%s' and '%s'."));
-#line 94 "../check.c"
- puts(_("%s error: The %s option is required\n"));
-#line 602 "../find.c"
- puts(_("%s: The '%s' option cannot have an argument.\n"));
-#line 151 "../check.c"
- puts(_("%s: Command line arguments are not allowed.\n"));
-#line 568 "../save.c"
- puts(_("error %d (%s) creating %s\n"));
-#line 210 "../enum.c"
- puts(_("%s error: '%s' does not match any %s keywords.\n"));
-#line 93 "../reset.c"
- puts(_("%s error: The '%s' option requires an argument.\n"));
-#line 122 "../save.c"
- puts(_("error %d (%s) stat-ing %s\n"));
-#line 175 "../save.c"
- puts(_("error %d (%s) stat-ing %s\n"));
-#line 143 "../restore.c"
- puts(_("%s error: no saved option state\n"));
-#line 225 "../autoopts.c"
- puts(_("'%s' is not a command line option.\n"));
-#line 113 "../time.c"
- puts(_("%s error: '%s' is not a recognizable date/time.\n"));
-#line 50 "../time.c"
- puts(_("%s error: '%s' is not a recognizable time duration.\n"));
-#line 92 "../check.c"
- puts(_("%s error: The %s option must appear %d times.\n"));
-#line 165 "../numeric.c"
- puts(_("%s error: '%s' is not a recognizable number.\n"));
-#line 176 "../enum.c"
- puts(_("%s error: %s exceeds %s keyword count\n"));
-#line 279 "../usage.c"
- puts(_("Try '%s %s' for more information.\n"));
-#line 45 "../alias.c"
- puts(_("one %s%s option allowed\n"));
-#line 170 "../makeshell.c"
- puts(_("standard output"));
-#line 905 "../makeshell.c"
- puts(_("standard output"));
-#line 223 "../usage.c"
- puts(_("standard output"));
-#line 364 "../usage.c"
- puts(_("standard output"));
-#line 574 "../usage.c"
- puts(_("standard output"));
-#line 178 "../version.c"
- puts(_("standard output"));
-#line 223 "../usage.c"
- puts(_("standard error"));
-#line 364 "../usage.c"
- puts(_("standard error"));
-#line 574 "../usage.c"
- puts(_("standard error"));
-#line 178 "../version.c"
- puts(_("standard error"));
-#line 170 "../makeshell.c"
- puts(_("write"));
-#line 905 "../makeshell.c"
- puts(_("write"));
-#line 222 "../usage.c"
- puts(_("write"));
-#line 363 "../usage.c"
- puts(_("write"));
-#line 573 "../usage.c"
- puts(_("write"));
-#line 177 "../version.c"
- puts(_("write"));
-#line 60 "../numeric.c"
- puts(_("%s error: %s option value %ld is out of range.\n"));
-#line 44 "../check.c"
- puts(_("%s error: %s option requires the %s option\n"));
-#line 121 "../save.c"
- puts(_("%s warning: cannot save options - %s not regular file\n"));
-#line 174 "../save.c"
- puts(_("%s warning: cannot save options - %s not regular file\n"));
-#line 193 "../save.c"
- puts(_("%s warning: cannot save options - %s not regular file\n"));
-#line 567 "../save.c"
- puts(_("%s warning: cannot save options - %s not regular file\n"));
- /* END-LIBOPTS-MESSAGES */
-
- /* USAGE-TEXT: */
-#line 822 "../usage.c"
- puts(_("\t\t\t\t- an alternate for '%s'\n"));
-#line 1097 "../usage.c"
- puts(_("Version, usage and configuration options:"));
-#line 873 "../usage.c"
- puts(_("\t\t\t\t- default option for unnamed options\n"));
-#line 786 "../usage.c"
- puts(_("\t\t\t\t- disabled as '--%s'\n"));
-#line 1066 "../usage.c"
- puts(_(" --- %-14s %s\n"));
-#line 1064 "../usage.c"
- puts(_("This option has been disabled"));
-#line 813 "../usage.c"
- puts(_("\t\t\t\t- enabled by default\n"));
-#line 40 "../alias.c"
- puts(_("%s error: only "));
-#line 1143 "../usage.c"
- puts(_(" - examining environment variables named %s_*\n"));
-#line 168 "../file.c"
- puts(_("\t\t\t\t- file must not pre-exist\n"));
-#line 172 "../file.c"
- puts(_("\t\t\t\t- file must pre-exist\n"));
-#line 329 "../usage.c"
- puts(_("Options are specified by doubled hyphens and their name or by a single\n"
- "hyphen and the flag character.\n"));
-#line 882 "../makeshell.c"
- puts(_("\n"
- "= = = = = = = =\n\n"
- "This incarnation of genshell will produce\n"
- "a shell script to parse the options for %s:\n\n"));
-#line 142 "../enum.c"
- puts(_(" or an integer mask with any of the lower %d bits set\n"));
-#line 846 "../usage.c"
- puts(_("\t\t\t\t- is a set membership option\n"));
-#line 867 "../usage.c"
- puts(_("\t\t\t\t- must appear between %d and %d times\n"));
-#line 331 "../usage.c"
- puts(_("Options are specified by single or double hyphens and their name.\n"));
-#line 853 "../usage.c"
- puts(_("\t\t\t\t- may appear multiple times\n"));
-#line 840 "../usage.c"
- puts(_("\t\t\t\t- may not be preset\n"));
-#line 1258 "../usage.c"
- puts(_(" Arg Option-Name Description\n"));
-#line 1194 "../usage.c"
- puts(_(" Flg Arg Option-Name Description\n"));
-#line 1252 "../usage.c"
- puts(_(" Flg Arg Option-Name Description\n"));
-#line 1253 "../usage.c"
- puts(_(" %3s %s"));
-#line 1259 "../usage.c"
- puts(_(" %3s %s"));
-#line 336 "../usage.c"
- puts(_("The '-#<number>' option may omit the hash char\n"));
-#line 332 "../usage.c"
- puts(_("All arguments are named options.\n"));
-#line 920 "../usage.c"
- puts(_(" - reading file %s"));
-#line 358 "../usage.c"
- puts(_("\n"
- "Please send bug reports to: <%s>\n"));
-#line 100 "../version.c"
- puts(_("\n"
- "Please send bug reports to: <%s>\n"));
-#line 129 "../version.c"
- puts(_("\n"
- "Please send bug reports to: <%s>\n"));
-#line 852 "../usage.c"
- puts(_("\t\t\t\t- may NOT appear - preset only\n"));
-#line 893 "../usage.c"
- puts(_("\n"
- "The following option preset mechanisms are supported:\n"));
-#line 1141 "../usage.c"
- puts(_("\n"
- "The following option preset mechanisms are supported:\n"));
-#line 631 "../usage.c"
- puts(_("prohibits these options:\n"));
-#line 626 "../usage.c"
- puts(_("prohibits the option '%s'\n"));
-#line 81 "../numeric.c"
- puts(_("%s%ld to %ld"));
-#line 79 "../numeric.c"
- puts(_("%sgreater than or equal to %ld"));
-#line 75 "../numeric.c"
- puts(_("%s%ld exactly"));
-#line 68 "../numeric.c"
- puts(_("%sit must lie in one of the ranges:\n"));
-#line 68 "../numeric.c"
- puts(_("%sit must be in the range:\n"));
-#line 88 "../numeric.c"
- puts(_(", or\n"));
-#line 66 "../numeric.c"
- puts(_("%sis scalable with a suffix: k/K/m/M/g/G/t/T\n"));
-#line 77 "../numeric.c"
- puts(_("%sless than or equal to %ld"));
-#line 339 "../usage.c"
- puts(_("Operands and options may be intermixed. They will be reordered.\n"));
-#line 601 "../usage.c"
- puts(_("requires the option '%s'\n"));
-#line 604 "../usage.c"
- puts(_("requires these options:\n"));
-#line 1270 "../usage.c"
- puts(_(" Arg Option-Name Req? Description\n"));
-#line 1264 "../usage.c"
- puts(_(" Flg Arg Option-Name Req? Description\n"));
-#line 143 "../enum.c"
- puts(_("or you may use a numeric representation. Preceding these with a '!'\n"
- "will clear the bits, specifying 'none' will clear all bits, and 'all'\n"
- "will set them all. Multiple entries may be passed as an option\n"
- "argument list.\n"));
-#line 859 "../usage.c"
- puts(_("\t\t\t\t- may appear up to %d times\n"));
-#line 52 "../enum.c"
- puts(_("The valid \"%s\" option keywords are:\n"));
-#line 1101 "../usage.c"
- puts(_("The next option supports vendor supported extra options:"));
-#line 722 "../usage.c"
- puts(_("These additional options are:"));
- /* END-USAGE-TEXT */
-}
-#endif /* uncompilable code */
-#ifdef __cplusplus
-}
-#endif
-/* genshell.c ends here */
diff --git a/src/libopts/genshell.h b/src/libopts/genshell.h
deleted file mode 100644
index 994af16909..0000000000
--- a/src/libopts/genshell.h
+++ /dev/null
@@ -1,224 +0,0 @@
-/* -*- buffer-read-only: t -*- vi: set ro:
- *
- * DO NOT EDIT THIS FILE (genshell.h)
- *
- * It has been AutoGen-ed
- * From the definitions genshell.def
- * and the template file options
- *
- * Generated from AutoOpts 42:1:17 templates.
- *
- * AutoOpts is a copyrighted work. This header file is not encumbered
- * by AutoOpts licensing, but is provided under the licensing terms chosen
- * by the genshellopt author or copyright holder. AutoOpts is
- * licensed under the terms of the LGPL. The redistributable library
- * (``libopts'') is licensed under the terms of either the LGPL or, at the
- * users discretion, the BSD license. See the AutoOpts and/or libopts sources
- * for details.
- *
- * The genshellopt program is copyrighted and licensed
- * under the following terms:
- *
- * Copyright (C) 1999-2018 Bruce Korb, all rights reserved.
- * This is free software. It is licensed for use, modification and
- * redistribution under the terms of the GNU Lesser General Public License,
- * version 2 or later <http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>
- *
- * The genshellopt library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, see
- * <http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>
- */
-/**
- * This file contains the programmatic interface to the Automated
- * Options generated for the genshellopt program.
- * These macros are documented in the AutoGen info file in the
- * "AutoOpts" chapter. Please refer to that doc for usage help.
- */
-#ifndef AUTOOPTS_GENSHELL_H_GUARD
-#define AUTOOPTS_GENSHELL_H_GUARD 1
-#include <autoopts/options.h>
-#include <stdarg.h>
-#include <stdnoreturn.h>
-
-/**
- * Ensure that the library used for compiling this generated header is at
- * least as new as the version current when the header template was released
- * (not counting patch version increments). Also ensure that the oldest
- * tolerable version is at least as old as what was current when the header
- * template was released.
- */
-#define AO_TEMPLATE_VERSION 172033
-#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
- || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
-# error option template version mismatches autoopts/options.h header
- Choke Me.
-#endif
-
-#if GCC_VERSION > 40400
-#define NOT_REACHED __builtin_unreachable();
-#else
-#define NOT_REACHED
-#endif
-
-/**
- * Enumeration of each option type for genshellopt
- */
-typedef enum {
- INDEX_GENSHELL_OPT_SCRIPT = 0,
- INDEX_GENSHELL_OPT_SHELL = 1,
- INDEX_GENSHELL_OPT_VERSION = 2,
- INDEX_GENSHELL_OPT_HELP = 3,
- INDEX_GENSHELL_OPT_MORE_HELP = 4
-} teGenshell_OptIndex;
-/** count of all options for genshellopt */
-#define GENSHELL_OPTION_CT 5
-/** genshellopt version */
-#define GENSHELLOPT_VERSION "1"
-/** Full genshellopt version text */
-#define GENSHELLOPT_FULL_VERSION "genshellopt 1"
-
-/**
- * Interface defines for all options. Replace "n" with the UPPER_CASED
- * option name (as in the teGenshell_OptIndex enumeration above).
- * e.g. HAVE_GENSHELL_OPT(SCRIPT)
- */
-#define GENSHELL_DESC(n) (genshelloptOptions.pOptDesc[INDEX_GENSHELL_OPT_## n])
-/** 'true' if an option has been specified in any way */
-#define HAVE_GENSHELL_OPT(n) (! UNUSED_OPT(& GENSHELL_DESC(n)))
-/** The string argument to an option. The argument type must be \"string\". */
-#define GENSHELL_OPT_ARG(n) (GENSHELL_DESC(n).optArg.argString)
-/** Mask the option state revealing how an option was specified.
- * It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
- * \a OPTST_DEFINED, \a OPTST_RESET or zero.
- */
-#define STATE_GENSHELL_OPT(n) (GENSHELL_DESC(n).fOptState & OPTST_SET_MASK)
-/** Count of option's occurrances *on the command line*. */
-#define COUNT_GENSHELL_OPT(n) (GENSHELL_DESC(n).optOccCt)
-/** mask of \a OPTST_SET and \a OPTST_DEFINED. */
-#define ISSEL_GENSHELL_OPT(n) (SELECTED_OPT(&GENSHELL_DESC(n)))
-/** 'true' if \a HAVE_OPT would yield 'false'. */
-#define ISUNUSED_GENSHELL_OPT(n) (UNUSED_OPT(& GENSHELL_DESC(n)))
-/** 'true' if OPTST_DISABLED bit not set. */
-#define ENABLED_GENSHELL_OPT(n) (! DISABLED_OPT(& GENSHELL_DESC(n)))
-/** number of stacked option arguments.
- * Valid only for stacked option arguments. */
-#define STACKCT_GENSHELL_OPT(n) (((tArgList*)(GENSHELL_DESC(n).optCookie))->useCt)
-/** stacked argument vector.
- * Valid only for stacked option arguments. */
-#define STACKLST_GENSHELL_OPT(n) (((tArgList*)(GENSHELL_DESC(n).optCookie))->apzArgs)
-/** Reset an option. */
-#define CLEAR_GENSHELL_OPT(n) STMTS( \
- GENSHELL_DESC(n).fOptState &= OPTST_PERSISTENT_MASK; \
- if ((GENSHELL_DESC(n).fOptState & OPTST_INITENABLED) == 0) \
- GENSHELL_DESC(n).fOptState |= OPTST_DISABLED; \
- GENSHELL_DESC(n).optCookie = NULL )
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/**
- * Enumeration of genshellopt exit codes
- */
-typedef enum {
- GENSHELLOPT_EXIT_SUCCESS = 0,
- GENSHELLOPT_EXIT_FAILURE = 1,
- GENSHELLOPT_EXIT_USAGE_ERROR = 64,
- GENSHELLOPT_EXIT_LIBOPTS_FAILURE = 70
-} genshellopt_exit_code_t;
-/**
- * Interface defines for specific options.
- * @{
- */
-#define VALUE_GENSHELL_OPT_SCRIPT 'o'
-#define VALUE_GENSHELL_OPT_SHELL 's'
-/** option flag (value) for help-value option */
-#define VALUE_GENSHELL_OPT_HELP '?'
-/** option flag (value) for more-help-value option */
-#define VALUE_GENSHELL_OPT_MORE_HELP '!'
-/** option flag (value) for version-value option */
-#define VALUE_GENSHELL_OPT_VERSION 'v'
-/*
- * Interface defines not associated with particular options
- */
-#define ERRSKIP_GENSHELL_OPTERR STMTS(genshelloptOptions.fOptSet &= ~OPTPROC_ERRSTOP)
-#define ERRSTOP_GENSHELL_OPTERR STMTS(genshelloptOptions.fOptSet |= OPTPROC_ERRSTOP)
-#define RESTART_GENSHELL_OPT(n) STMTS( \
- genshelloptOptions.curOptIdx = (n); \
- genshelloptOptions.pzCurOpt = NULL )
-#define START_GENSHELL_OPT RESTART_GENSHELL_OPT(1)
-#define GENSHELL_USAGE(c) (*genshelloptOptions.pUsageProc)(&genshelloptOptions, c)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-/*
- * global exported definitions
- */
-#define ch_t unsigned char
-#define cc_t const unsigned char
-#define cch_t char const
-
-
-/* * * * * *
- *
- * Declare the genshellopt option descriptor.
- */
-extern tOptions genshelloptOptions;
-
-#if defined(ENABLE_NLS)
-# ifndef _
-# include <stdio.h>
-# ifndef HAVE_GETTEXT
- extern char * gettext(char const *);
-# else
-# include <libintl.h>
-# endif
-
-# ifndef ATTRIBUTE_FORMAT_ARG
-# define ATTRIBUTE_FORMAT_ARG(_a)
-# endif
-
-static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
-static inline char* aoGetsText(char const* pz) {
- if (pz == NULL) return NULL;
- return (char*)gettext(pz);
-}
-# define _(s) aoGetsText(s)
-# endif /* _() */
-
-# define OPT_NO_XLAT_CFG_NAMES STMTS(genshelloptOptions.fOptSet |= \
- OPTPROC_NXLAT_OPT_CFG;)
-# define OPT_NO_XLAT_OPT_NAMES STMTS(genshelloptOptions.fOptSet |= \
- OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
-
-# define OPT_XLAT_CFG_NAMES STMTS(genshelloptOptions.fOptSet &= \
- ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
-# define OPT_XLAT_OPT_NAMES STMTS(genshelloptOptions.fOptSet &= \
- ~OPTPROC_NXLAT_OPT;)
-
-#else /* ENABLE_NLS */
-# define OPT_NO_XLAT_CFG_NAMES
-# define OPT_NO_XLAT_OPT_NAMES
-
-# define OPT_XLAT_CFG_NAMES
-# define OPT_XLAT_OPT_NAMES
-
-# ifndef _
-# define _(_s) _s
-# endif
-#endif /* ENABLE_NLS */
-
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* AUTOOPTS_GENSHELL_H_GUARD */
-
-/* genshell.h ends here */
diff --git a/src/libopts/gettext.h b/src/libopts/gettext.h
deleted file mode 100644
index 87ec81930d..0000000000
--- a/src/libopts/gettext.h
+++ /dev/null
@@ -1,294 +0,0 @@
-/* Convenience header for conditional use of GNU <libintl.h>.
- Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2018 Free Software
- Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1, 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License along
- with this program; if not, see <https://www.gnu.org/licenses/>. */
-
-#ifndef _LIBGETTEXT_H
-#define _LIBGETTEXT_H 1
-
-/* NLS can be disabled through the configure --disable-nls option
- or through "#define ENABLE NLS 0" before including this file. */
-#if defined ENABLE_NLS && ENABLE_NLS
-
-/* Get declarations of GNU message catalog functions. */
-# include <libintl.h>
-
-/* You can set the DEFAULT_TEXT_DOMAIN macro to specify the domain used by
- the gettext() and ngettext() macros. This is an alternative to calling
- textdomain(), and is useful for libraries. */
-# ifdef DEFAULT_TEXT_DOMAIN
-# undef gettext
-# define gettext(Msgid) \
- dgettext (DEFAULT_TEXT_DOMAIN, Msgid)
-# undef ngettext
-# define ngettext(Msgid1, Msgid2, N) \
- dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N)
-# endif
-
-#else
-
-/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
- chokes if dcgettext is defined as a macro. So include it now, to make
- later inclusions of <locale.h> a NOP. We don't include <libintl.h>
- as well because people using "gettext.h" will not include <libintl.h>,
- and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
- is OK. */
-#if defined(__sun)
-# include <locale.h>
-#endif
-
-/* Many header files from the libstdc++ coming with g++ 3.3 or newer include
- <libintl.h>, which chokes if dcgettext is defined as a macro. So include
- it now, to make later inclusions of <libintl.h> a NOP. */
-#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
-# include <cstdlib>
-# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H
-# include <libintl.h>
-# endif
-#endif
-
-/* Disabled NLS.
- The casts to 'const char *' serve the purpose of producing warnings
- for invalid uses of the value returned from these functions.
- On pre-ANSI systems without 'const', the config.h file is supposed to
- contain "#define const". */
-# undef gettext
-# define gettext(Msgid) ((const char *) (Msgid))
-# undef dgettext
-# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
-# undef dcgettext
-# define dcgettext(Domainname, Msgid, Category) \
- ((void) (Category), dgettext (Domainname, Msgid))
-# undef ngettext
-# define ngettext(Msgid1, Msgid2, N) \
- ((N) == 1 \
- ? ((void) (Msgid2), (const char *) (Msgid1)) \
- : ((void) (Msgid1), (const char *) (Msgid2)))
-# undef dngettext
-# define dngettext(Domainname, Msgid1, Msgid2, N) \
- ((void) (Domainname), ngettext (Msgid1, Msgid2, N))
-# undef dcngettext
-# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
- ((void) (Category), dngettext (Domainname, Msgid1, Msgid2, N))
-# undef textdomain
-# define textdomain(Domainname) ((const char *) (Domainname))
-# undef bindtextdomain
-# define bindtextdomain(Domainname, Dirname) \
- ((void) (Domainname), (const char *) (Dirname))
-# undef bind_textdomain_codeset
-# define bind_textdomain_codeset(Domainname, Codeset) \
- ((void) (Domainname), (const char *) (Codeset))
-
-#endif
-
-/* Prefer gnulib's setlocale override over libintl's setlocale override. */
-#ifdef GNULIB_defined_setlocale
-# undef setlocale
-# define setlocale rpl_setlocale
-#endif
-
-/* A pseudo function call that serves as a marker for the automated
- extraction of messages, but does not call gettext(). The run-time
- translation is done at a different place in the code.
- The argument, String, should be a literal string. Concatenated strings
- and other string expressions won't work.
- The macro's expansion is not parenthesized, so that it is suitable as
- initializer for static 'char[]' or 'const char[]' variables. */
-#define gettext_noop(String) String
-
-/* The separator between msgctxt and msgid in a .mo file. */
-#define GETTEXT_CONTEXT_GLUE "\004"
-
-/* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a
- MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be
- short and rarely need to change.
- The letter 'p' stands for 'particular' or 'special'. */
-#ifdef DEFAULT_TEXT_DOMAIN
-# define pgettext(Msgctxt, Msgid) \
- pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
-#else
-# define pgettext(Msgctxt, Msgid) \
- pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
-#endif
-#define dpgettext(Domainname, Msgctxt, Msgid) \
- pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
-#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
- pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
-#ifdef DEFAULT_TEXT_DOMAIN
-# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
- npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
-#else
-# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
- npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
-#endif
-#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
- npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
-#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
- npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-static const char *
-pgettext_aux (const char *domain,
- const char *msg_ctxt_id, const char *msgid,
- int category)
-{
- const char *translation = dcgettext (domain, msg_ctxt_id, category);
- if (translation == msg_ctxt_id)
- return msgid;
- else
- return translation;
-}
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-static const char *
-npgettext_aux (const char *domain,
- const char *msg_ctxt_id, const char *msgid,
- const char *msgid_plural, unsigned long int n,
- int category)
-{
- const char *translation =
- dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
- if (translation == msg_ctxt_id || translation == msgid_plural)
- return (n == 1 ? msgid : msgid_plural);
- else
- return translation;
-}
-
-/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID
- can be arbitrary expressions. But for string literals these macros are
- less efficient than those above. */
-
-#include <string.h>
-
-#if (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \
- /* || __STDC_VERSION__ == 199901L
- || (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ )
-# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
-#else
-# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0
-#endif
-
-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
-#include <stdlib.h>
-#endif
-
-#define pgettext_expr(Msgctxt, Msgid) \
- dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
-#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
- dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-static const char *
-dcpgettext_expr (const char *domain,
- const char *msgctxt, const char *msgid,
- int category)
-{
- size_t msgctxt_len = strlen (msgctxt) + 1;
- size_t msgid_len = strlen (msgid) + 1;
- const char *translation;
-#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
- char msg_ctxt_id[msgctxt_len + msgid_len];
-#else
- char buf[1024];
- char *msg_ctxt_id =
- (msgctxt_len + msgid_len <= sizeof (buf)
- ? buf
- : (char *) malloc (msgctxt_len + msgid_len));
- if (msg_ctxt_id != NULL)
-#endif
- {
- int found_translation;
- memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
- msg_ctxt_id[msgctxt_len - 1] = '\004';
- memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
- translation = dcgettext (domain, msg_ctxt_id, category);
- found_translation = (translation != msg_ctxt_id);
-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
- if (msg_ctxt_id != buf)
- free (msg_ctxt_id);
-#endif
- if (found_translation)
- return translation;
- }
- return msgid;
-}
-
-#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
- dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
-#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
- dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-static const char *
-dcnpgettext_expr (const char *domain,
- const char *msgctxt, const char *msgid,
- const char *msgid_plural, unsigned long int n,
- int category)
-{
- size_t msgctxt_len = strlen (msgctxt) + 1;
- size_t msgid_len = strlen (msgid) + 1;
- const char *translation;
-#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
- char msg_ctxt_id[msgctxt_len + msgid_len];
-#else
- char buf[1024];
- char *msg_ctxt_id =
- (msgctxt_len + msgid_len <= sizeof (buf)
- ? buf
- : (char *) malloc (msgctxt_len + msgid_len));
- if (msg_ctxt_id != NULL)
-#endif
- {
- int found_translation;
- memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
- msg_ctxt_id[msgctxt_len - 1] = '\004';
- memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
- translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
- found_translation = !(translation == msg_ctxt_id || translation == msgid_plural);
-#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
- if (msg_ctxt_id != buf)
- free (msg_ctxt_id);
-#endif
- if (found_translation)
- return translation;
- }
- return (n == 1 ? msgid : msgid_plural);
-}
-
-#endif /* _LIBGETTEXT_H */
diff --git a/src/libopts/init.c b/src/libopts/init.c
deleted file mode 100644
index b65e593914..0000000000
--- a/src/libopts/init.c
+++ /dev/null
@@ -1,289 +0,0 @@
-/**
- * \file initialize.c
- *
- * initialize the libopts data structures.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-/**
- * Make sure the option descriptor is there and that we understand it.
- * This should be called from any user entry point where one needs to
- * worry about validity. (Some entry points are free to assume that
- * the call is not the first to the library and, thus, that this has
- * already been called.)
- *
- * Upon successful completion, pzProgName and pzProgPath are set.
- *
- * @param[in,out] opts program options descriptor
- * @param[in] pname name of program, from argv[]
- * @returns SUCCESS or FAILURE
- */
-static tSuccess
-validate_struct(tOptions * opts, char const * pname)
-{
- if (opts == NULL) {
- fputs(zno_opt_arg, stderr);
- return FAILURE;
- }
- print_exit = ((opts->fOptSet & OPTPROC_SHELL_OUTPUT) != 0);
-
- /*
- * IF the client has enabled translation and the translation procedure
- * is available, then go do it.
- */
- if ( ((opts->fOptSet & OPTPROC_TRANSLATE) != 0)
- && (opts->pTransProc != NULL)
- && (option_xlateable_txt.field_ct != 0) ) {
- /*
- * If option names are not to be translated at all, then do not do
- * it for configuration parsing either. (That is the bit that really
- * gets tested anyway.)
- */
- if ((opts->fOptSet & OPTPROC_NO_XLAT_MASK) == OPTPROC_NXLAT_OPT)
- opts->fOptSet |= OPTPROC_NXLAT_OPT_CFG;
- opts->pTransProc();
- }
-
- /*
- * IF the struct version is not the current, and also
- * either too large (?!) or too small,
- * THEN emit error message and fail-exit
- */
- if ( ( opts->structVersion != OPTIONS_STRUCT_VERSION )
- && ( (opts->structVersion > OPTIONS_STRUCT_VERSION )
- || (opts->structVersion < OPTIONS_MINIMUM_VERSION )
- ) ) {
- fprintf(stderr, zwrong_ver, pname, NUM_TO_VER(opts->structVersion));
- if (opts->structVersion > OPTIONS_STRUCT_VERSION )
- fputs(ztoo_new, stderr);
- else
- fputs(ztoo_old, stderr);
-
- fwrite(ao_ver_string, sizeof(ao_ver_string) - 1, 1, stderr);
- return FAILURE;
- }
-
- /*
- * If the program name hasn't been set, then set the name and the path
- * and the set of equivalent characters.
- */
- if (opts->pzProgName == NULL) {
- char const * pz = strrchr(pname, DIRCH);
- char const ** pp =
- (char const **)(void **)&(opts->pzProgName);
-
- if (pz != NULL)
- *pp = pz+1;
- else
- *pp = pname;
-
- pz = pathfind(getenv("PATH"), (char *)pname, "rx");
- if (pz != NULL)
- pname = VOIDP(pz);
-
- pp = (char const **)VOIDP(&(opts->pzProgPath));
- *pp = pname;
-
- /*
- * when comparing long names, these are equivalent
- */
- strequate(zSepChars);
- }
-
- return SUCCESS;
-}
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *
- * DO PRESETS
- *
- * The next several routines do the immediate action pass on the command
- * line options, then the environment variables, then the config files in
- * reverse order. Once done with that, the order is reversed and all
- * the config files and environment variables are processed again, this
- * time only processing the non-immediate action options. do_presets()
- * will then return for optionProcess() to do the final pass on the command
- * line arguments.
- */
-
-/**
- * scan the command line for immediate action options.
- * This is only called the first time through.
- * While this procedure is active, the OPTPROC_IMMEDIATE is true.
- *
- * @param pOpts program options descriptor
- * @returns SUCCESS or FAILURE
- */
-static tSuccess
-immediate_opts(tOptions * opts)
-{
- tSuccess res;
-
- opts->fOptSet |= OPTPROC_IMMEDIATE;
- opts->curOptIdx = 1; /* start by skipping program name */
- opts->pzCurOpt = NULL;
-
- /*
- * Examine all the options from the start. We process any options that
- * are marked for immediate processing.
- */
- for (;;) {
- tOptState opt_st = OPTSTATE_INITIALIZER(PRESET);
-
- res = next_opt(opts, &opt_st);
- switch (res) {
- case FAILURE: goto failed_option;
- case PROBLEM: res = SUCCESS; goto leave;
- case SUCCESS: break;
- }
-
- /*
- * IF this is an immediate-attribute option, then do it.
- */
- if (! DO_IMMEDIATELY(opt_st.flags))
- continue;
-
- if (! SUCCESSFUL(handle_opt(opts, &opt_st)))
- break;
- } failed_option:;
-
- if ((opts->fOptSet & OPTPROC_ERRSTOP) != 0)
- (*opts->pUsageProc)(opts, EXIT_FAILURE);
-
- leave:
-
- opts->fOptSet &= ~OPTPROC_IMMEDIATE;
- return res;
-}
-
-/**
- * check for preset values from a config files or envrionment variables
- *
- * @param[in,out] opts the structure with the option names to check
- */
-static tSuccess
-do_presets(tOptions * opts)
-{
- tOptDesc * od = NULL;
-
- if (! SUCCESSFUL(immediate_opts(opts)))
- return FAILURE;
-
- /*
- * IF this option set has a --save-opts option, then it also
- * has a --load-opts option. See if a command line option has disabled
- * option presetting.
- */
- if ( (opts->specOptIdx.save_opts != NO_EQUIVALENT)
- && (opts->specOptIdx.save_opts != 0)) {
- od = opts->pOptDesc + opts->specOptIdx.save_opts + 1;
- if (DISABLED_OPT(od))
- return SUCCESS;
- }
-
- /*
- * Until we return from this procedure, disable non-presettable opts
- */
- opts->fOptSet |= OPTPROC_PRESETTING;
- /*
- * IF there are no config files,
- * THEN do any environment presets and leave.
- */
- if (opts->papzHomeList == NULL) {
- env_presets(opts, ENV_ALL);
- }
- else {
- env_presets(opts, ENV_IMM);
-
- /*
- * Check to see if environment variables have disabled presetting.
- */
- if ((od != NULL) && ! DISABLED_OPT(od))
- intern_file_load(opts);
-
- /*
- * ${PROGRAM_LOAD_OPTS} value of "no" cannot disable other environment
- * variable options. Only the loading of .rc files.
- */
- env_presets(opts, ENV_NON_IMM);
- }
- opts->fOptSet &= ~OPTPROC_PRESETTING;
-
- return SUCCESS;
-}
-
-/**
- * AutoOpts initialization
- *
- * @param[in,out] opts the structure to initialize
- * @param[in] a_ct program argument count
- * @param[in] a_v program argument vector
- */
-static bool
-ao_initialize(tOptions * opts, int a_ct, char ** a_v)
-{
- if ((opts->fOptSet & OPTPROC_INITDONE) != 0)
- return true;
-
- opts->origArgCt = (unsigned int)a_ct;
- opts->origArgVect = a_v;
- opts->fOptSet |= OPTPROC_INITDONE;
-
- if (HAS_pzPkgDataDir(opts))
- program_pkgdatadir = opts->pzPkgDataDir;
-
- if (! SUCCESSFUL(do_presets(opts)))
- return false;
-
- /*
- * IF option name conversion was suppressed but it is not suppressed
- * for the command line, then it's time to translate option names.
- * Usage text will not get retranslated.
- */
- if ( ((opts->fOptSet & OPTPROC_TRANSLATE) != 0)
- && (opts->pTransProc != NULL)
- && ((opts->fOptSet & OPTPROC_NO_XLAT_MASK) == OPTPROC_NXLAT_OPT_CFG)
- ) {
- opts->fOptSet &= ~OPTPROC_NXLAT_OPT_CFG;
- (*opts->pTransProc)();
- }
-
- if ((opts->fOptSet & OPTPROC_REORDER) != 0)
- optionSort(opts);
-
- opts->curOptIdx = 1;
- opts->pzCurOpt = NULL;
- return true;
-}
-
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/initialize.c */
diff --git a/src/libopts/intprops.h b/src/libopts/intprops.h
deleted file mode 100644
index af456ff589..0000000000
--- a/src/libopts/intprops.h
+++ /dev/null
@@ -1,453 +0,0 @@
-/* intprops.h -- properties of integer types
-
- Copyright (C) 2001-2018 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Paul Eggert. */
-
-#ifndef _GL_INTPROPS_H
-#define _GL_INTPROPS_H
-
-#include <limits.h>
-
-/* Return a value with the common real type of E and V and the value of V. */
-#define _GL_INT_CONVERT(e, v) (0 * (e) + (v))
-
-/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
- <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00406.html>. */
-#define _GL_INT_NEGATE_CONVERT(e, v) (0 * (e) - (v))
-
-/* The extra casts in the following macros work around compiler bugs,
- e.g., in Cray C 5.0.3.0. */
-
-/* True if the arithmetic type T is an integer type. bool counts as
- an integer. */
-#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
-
-/* True if the real type T is signed. */
-#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
-
-/* Return 1 if the real expression E, after promotion, has a
- signed or floating type. */
-#define EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
-
-
-/* Minimum and maximum values for integer types and expressions. */
-
-/* The width in bits of the integer type or expression T.
- Padding bits are not supported; this is checked at compile-time below. */
-#define TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT)
-
-/* The maximum and minimum values for the integer type T. */
-#define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t))
-#define TYPE_MAXIMUM(t) \
- ((t) (! TYPE_SIGNED (t) \
- ? (t) -1 \
- : ((((t) 1 << (TYPE_WIDTH (t) - 2)) - 1) * 2 + 1)))
-
-/* The maximum and minimum values for the type of the expression E,
- after integer promotion. E should not have side effects. */
-#define _GL_INT_MINIMUM(e) \
- (EXPR_SIGNED (e) \
- ? ~ _GL_SIGNED_INT_MAXIMUM (e) \
- : _GL_INT_CONVERT (e, 0))
-#define _GL_INT_MAXIMUM(e) \
- (EXPR_SIGNED (e) \
- ? _GL_SIGNED_INT_MAXIMUM (e) \
- : _GL_INT_NEGATE_CONVERT (e, 1))
-#define _GL_SIGNED_INT_MAXIMUM(e) \
- (((_GL_INT_CONVERT (e, 1) << (TYPE_WIDTH ((e) + 0) - 2)) - 1) * 2 + 1)
-
-/* Work around OpenVMS incompatibility with C99. */
-#if !defined LLONG_MAX && defined __INT64_MAX
-# define LLONG_MAX __INT64_MAX
-# define LLONG_MIN __INT64_MIN
-#endif
-
-/* This include file assumes that signed types are two's complement without
- padding bits; the above macros have undefined behavior otherwise.
- If this is a problem for you, please let us know how to fix it for your host.
- This assumption is tested by the intprops-tests module. */
-
-/* Does the __typeof__ keyword work? This could be done by
- 'configure', but for now it's easier to do it by hand. */
-#if (2 <= __GNUC__ \
- || (1210 <= __IBMC__ && defined __IBM__TYPEOF__) \
- || (0x5110 <= __SUNPRO_C && !__STDC__))
-# define _GL_HAVE___TYPEOF__ 1
-#else
-# define _GL_HAVE___TYPEOF__ 0
-#endif
-
-/* Return 1 if the integer type or expression T might be signed. Return 0
- if it is definitely unsigned. This macro does not evaluate its argument,
- and expands to an integer constant expression. */
-#if _GL_HAVE___TYPEOF__
-# define _GL_SIGNED_TYPE_OR_EXPR(t) TYPE_SIGNED (__typeof__ (t))
-#else
-# define _GL_SIGNED_TYPE_OR_EXPR(t) 1
-#endif
-
-/* Bound on length of the string representing an unsigned integer
- value representable in B bits. log10 (2.0) < 146/485. The
- smallest value of B where this bound is not tight is 2621. */
-#define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485)
-
-/* Bound on length of the string representing an integer type or expression T.
- Subtract 1 for the sign bit if T is signed, and then add 1 more for
- a minus sign if needed.
-
- Because _GL_SIGNED_TYPE_OR_EXPR sometimes returns 0 when its argument is
- signed, this macro may overestimate the true bound by one byte when
- applied to unsigned types of size 2, 4, 16, ... bytes. */
-#define INT_STRLEN_BOUND(t) \
- (INT_BITS_STRLEN_BOUND (TYPE_WIDTH (t) - _GL_SIGNED_TYPE_OR_EXPR (t)) \
- + _GL_SIGNED_TYPE_OR_EXPR (t))
-
-/* Bound on buffer size needed to represent an integer type or expression T,
- including the terminating null. */
-#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
-
-
-/* Range overflow checks.
-
- The INT_<op>_RANGE_OVERFLOW macros return 1 if the corresponding C
- operators might not yield numerically correct answers due to
- arithmetic overflow. They do not rely on undefined or
- implementation-defined behavior. Their implementations are simple
- and straightforward, but they are a bit harder to use than the
- INT_<op>_OVERFLOW macros described below.
-
- Example usage:
-
- long int i = ...;
- long int j = ...;
- if (INT_MULTIPLY_RANGE_OVERFLOW (i, j, LONG_MIN, LONG_MAX))
- printf ("multiply would overflow");
- else
- printf ("product is %ld", i * j);
-
- Restrictions on *_RANGE_OVERFLOW macros:
-
- These macros do not check for all possible numerical problems or
- undefined or unspecified behavior: they do not check for division
- by zero, for bad shift counts, or for shifting negative numbers.
-
- These macros may evaluate their arguments zero or multiple times,
- so the arguments should not have side effects. The arithmetic
- arguments (including the MIN and MAX arguments) must be of the same
- integer type after the usual arithmetic conversions, and the type
- must have minimum value MIN and maximum MAX. Unsigned types should
- use a zero MIN of the proper type.
-
- These macros are tuned for constant MIN and MAX. For commutative
- operations such as A + B, they are also tuned for constant B. */
-
-/* Return 1 if A + B would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. */
-#define INT_ADD_RANGE_OVERFLOW(a, b, min, max) \
- ((b) < 0 \
- ? (a) < (min) - (b) \
- : (max) - (b) < (a))
-
-/* Return 1 if A - B would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. */
-#define INT_SUBTRACT_RANGE_OVERFLOW(a, b, min, max) \
- ((b) < 0 \
- ? (max) + (b) < (a) \
- : (a) < (min) + (b))
-
-/* Return 1 if - A would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. */
-#define INT_NEGATE_RANGE_OVERFLOW(a, min, max) \
- ((min) < 0 \
- ? (a) < - (max) \
- : 0 < (a))
-
-/* Return 1 if A * B would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. Avoid && and || as they tickle
- bugs in Sun C 5.11 2010/08/13 and other compilers; see
- <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00401.html>. */
-#define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max) \
- ((b) < 0 \
- ? ((a) < 0 \
- ? (a) < (max) / (b) \
- : (b) == -1 \
- ? 0 \
- : (min) / (b) < (a)) \
- : (b) == 0 \
- ? 0 \
- : ((a) < 0 \
- ? (a) < (min) / (b) \
- : (max) / (b) < (a)))
-
-/* Return 1 if A / B would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. Do not check for division by zero. */
-#define INT_DIVIDE_RANGE_OVERFLOW(a, b, min, max) \
- ((min) < 0 && (b) == -1 && (a) < - (max))
-
-/* Return 1 if A % B would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. Do not check for division by zero.
- Mathematically, % should never overflow, but on x86-like hosts
- INT_MIN % -1 traps, and the C standard permits this, so treat this
- as an overflow too. */
-#define INT_REMAINDER_RANGE_OVERFLOW(a, b, min, max) \
- INT_DIVIDE_RANGE_OVERFLOW (a, b, min, max)
-
-/* Return 1 if A << B would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. Here, MIN and MAX are for A only, and B need
- not be of the same type as the other arguments. The C standard says that
- behavior is undefined for shifts unless 0 <= B < wordwidth, and that when
- A is negative then A << B has undefined behavior and A >> B has
- implementation-defined behavior, but do not check these other
- restrictions. */
-#define INT_LEFT_SHIFT_RANGE_OVERFLOW(a, b, min, max) \
- ((a) < 0 \
- ? (a) < (min) >> (b) \
- : (max) >> (b) < (a))
-
-/* True if __builtin_add_overflow (A, B, P) works when P is non-null. */
-#if 5 <= __GNUC__ && !defined __ICC
-# define _GL_HAS_BUILTIN_OVERFLOW 1
-#else
-# define _GL_HAS_BUILTIN_OVERFLOW 0
-#endif
-
-/* True if __builtin_add_overflow_p (A, B, C) works. */
-#define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__)
-
-/* The _GL*_OVERFLOW macros have the same restrictions as the
- *_RANGE_OVERFLOW macros, except that they do not assume that operands
- (e.g., A and B) have the same type as MIN and MAX. Instead, they assume
- that the result (e.g., A + B) has that type. */
-#if _GL_HAS_BUILTIN_OVERFLOW_P
-# define _GL_ADD_OVERFLOW(a, b, min, max) \
- __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
-# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
- __builtin_sub_overflow_p (a, b, (__typeof__ ((a) - (b))) 0)
-# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \
- __builtin_mul_overflow_p (a, b, (__typeof__ ((a) * (b))) 0)
-#else
-# define _GL_ADD_OVERFLOW(a, b, min, max) \
- ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \
- : (a) < 0 ? (b) <= (a) + (b) \
- : (b) < 0 ? (a) <= (a) + (b) \
- : (a) + (b) < (b))
-# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
- ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max) \
- : (a) < 0 ? 1 \
- : (b) < 0 ? (a) - (b) <= (a) \
- : (a) < (b))
-# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \
- (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a)))) \
- || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max))
-#endif
-#define _GL_DIVIDE_OVERFLOW(a, b, min, max) \
- ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \
- : (a) < 0 ? (b) <= (a) + (b) - 1 \
- : (b) < 0 && (a) + (b) <= (a))
-#define _GL_REMAINDER_OVERFLOW(a, b, min, max) \
- ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \
- : (a) < 0 ? (a) % (b) != ((max) - (b) + 1) % (b) \
- : (b) < 0 && ! _GL_UNSIGNED_NEG_MULTIPLE (a, b, max))
-
-/* Return a nonzero value if A is a mathematical multiple of B, where
- A is unsigned, B is negative, and MAX is the maximum value of A's
- type. A's type must be the same as (A % B)'s type. Normally (A %
- -B == 0) suffices, but things get tricky if -B would overflow. */
-#define _GL_UNSIGNED_NEG_MULTIPLE(a, b, max) \
- (((b) < -_GL_SIGNED_INT_MAXIMUM (b) \
- ? (_GL_SIGNED_INT_MAXIMUM (b) == (max) \
- ? (a) \
- : (a) % (_GL_INT_CONVERT (a, _GL_SIGNED_INT_MAXIMUM (b)) + 1)) \
- : (a) % - (b)) \
- == 0)
-
-/* Check for integer overflow, and report low order bits of answer.
-
- The INT_<op>_OVERFLOW macros return 1 if the corresponding C operators
- might not yield numerically correct answers due to arithmetic overflow.
- The INT_<op>_WRAPV macros also store the low-order bits of the answer.
- These macros work correctly on all known practical hosts, and do not rely
- on undefined behavior due to signed arithmetic overflow.
-
- Example usage, assuming A and B are long int:
-
- if (INT_MULTIPLY_OVERFLOW (a, b))
- printf ("result would overflow\n");
- else
- printf ("result is %ld (no overflow)\n", a * b);
-
- Example usage with WRAPV flavor:
-
- long int result;
- bool overflow = INT_MULTIPLY_WRAPV (a, b, &result);
- printf ("result is %ld (%s)\n", result,
- overflow ? "after overflow" : "no overflow");
-
- Restrictions on these macros:
-
- These macros do not check for all possible numerical problems or
- undefined or unspecified behavior: they do not check for division
- by zero, for bad shift counts, or for shifting negative numbers.
-
- These macros may evaluate their arguments zero or multiple times, so the
- arguments should not have side effects.
-
- The WRAPV macros are not constant expressions. They support only
- +, binary -, and *. The result type must be signed.
-
- These macros are tuned for their last argument being a constant.
-
- Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B,
- A % B, and A << B would overflow, respectively. */
-
-#define INT_ADD_OVERFLOW(a, b) \
- _GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW)
-#define INT_SUBTRACT_OVERFLOW(a, b) \
- _GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW)
-#if _GL_HAS_BUILTIN_OVERFLOW_P
-# define INT_NEGATE_OVERFLOW(a) INT_SUBTRACT_OVERFLOW (0, a)
-#else
-# define INT_NEGATE_OVERFLOW(a) \
- INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
-#endif
-#define INT_MULTIPLY_OVERFLOW(a, b) \
- _GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW)
-#define INT_DIVIDE_OVERFLOW(a, b) \
- _GL_BINARY_OP_OVERFLOW (a, b, _GL_DIVIDE_OVERFLOW)
-#define INT_REMAINDER_OVERFLOW(a, b) \
- _GL_BINARY_OP_OVERFLOW (a, b, _GL_REMAINDER_OVERFLOW)
-#define INT_LEFT_SHIFT_OVERFLOW(a, b) \
- INT_LEFT_SHIFT_RANGE_OVERFLOW (a, b, \
- _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
-
-/* Return 1 if the expression A <op> B would overflow,
- where OP_RESULT_OVERFLOW (A, B, MIN, MAX) does the actual test,
- assuming MIN and MAX are the minimum and maximum for the result type.
- Arguments should be free of side effects. */
-#define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \
- op_result_overflow (a, b, \
- _GL_INT_MINIMUM (0 * (b) + (a)), \
- _GL_INT_MAXIMUM (0 * (b) + (a)))
-
-/* Store the low-order bits of A + B, A - B, A * B, respectively, into *R.
- Return 1 if the result overflows. See above for restrictions. */
-#define INT_ADD_WRAPV(a, b, r) \
- _GL_INT_OP_WRAPV (a, b, r, +, __builtin_add_overflow, INT_ADD_OVERFLOW)
-#define INT_SUBTRACT_WRAPV(a, b, r) \
- _GL_INT_OP_WRAPV (a, b, r, -, __builtin_sub_overflow, INT_SUBTRACT_OVERFLOW)
-#define INT_MULTIPLY_WRAPV(a, b, r) \
- _GL_INT_OP_WRAPV (a, b, r, *, __builtin_mul_overflow, INT_MULTIPLY_OVERFLOW)
-
-/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See:
- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193
- https://llvm.org/bugs/show_bug.cgi?id=25390
- For now, assume all versions of GCC-like compilers generate bogus
- warnings for _Generic. This matters only for older compilers that
- lack __builtin_add_overflow. */
-#if __GNUC__
-# define _GL__GENERIC_BOGUS 1
-#else
-# define _GL__GENERIC_BOGUS 0
-#endif
-
-/* Store the low-order bits of A <op> B into *R, where OP specifies
- the operation. BUILTIN is the builtin operation, and OVERFLOW the
- overflow predicate. Return 1 if the result overflows. See above
- for restrictions. */
-#if _GL_HAS_BUILTIN_OVERFLOW
-# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) builtin (a, b, r)
-#elif 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS
-# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \
- (_Generic \
- (*(r), \
- signed char: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
- signed char, SCHAR_MIN, SCHAR_MAX), \
- short int: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
- short int, SHRT_MIN, SHRT_MAX), \
- int: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
- int, INT_MIN, INT_MAX), \
- long int: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
- long int, LONG_MIN, LONG_MAX), \
- long long int: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
- long long int, LLONG_MIN, LLONG_MAX)))
-#else
-# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \
- (sizeof *(r) == sizeof (signed char) \
- ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
- signed char, SCHAR_MIN, SCHAR_MAX) \
- : sizeof *(r) == sizeof (short int) \
- ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
- short int, SHRT_MIN, SHRT_MAX) \
- : sizeof *(r) == sizeof (int) \
- ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
- int, INT_MIN, INT_MAX) \
- : _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow))
-# ifdef LLONG_MAX
-# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
- (sizeof *(r) == sizeof (long int) \
- ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
- long int, LONG_MIN, LONG_MAX) \
- : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
- long long int, LLONG_MIN, LLONG_MAX))
-# else
-# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
- long int, LONG_MIN, LONG_MAX)
-# endif
-#endif
-
-/* Store the low-order bits of A <op> B into *R, where the operation
- is given by OP. Use the unsigned type UT for calculation to avoid
- overflow problems. *R's type is T, with extrema TMIN and TMAX.
- T must be a signed integer type. Return 1 if the result overflows. */
-#define _GL_INT_OP_CALC(a, b, r, op, overflow, ut, t, tmin, tmax) \
- (sizeof ((a) op (b)) < sizeof (t) \
- ? _GL_INT_OP_CALC1 ((t) (a), (t) (b), r, op, overflow, ut, t, tmin, tmax) \
- : _GL_INT_OP_CALC1 (a, b, r, op, overflow, ut, t, tmin, tmax))
-#define _GL_INT_OP_CALC1(a, b, r, op, overflow, ut, t, tmin, tmax) \
- ((overflow (a, b) \
- || (EXPR_SIGNED ((a) op (b)) && ((a) op (b)) < (tmin)) \
- || (tmax) < ((a) op (b))) \
- ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 1) \
- : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 0))
-
-/* Return the low-order bits of A <op> B, where the operation is given
- by OP. Use the unsigned type UT for calculation to avoid undefined
- behavior on signed integer overflow, and convert the result to type T.
- UT is at least as wide as T and is no narrower than unsigned int,
- T is two's complement, and there is no padding or trap representations.
- Assume that converting UT to T yields the low-order bits, as is
- done in all known two's-complement C compilers. E.g., see:
- https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html
-
- According to the C standard, converting UT to T yields an
- implementation-defined result or signal for values outside T's
- range. However, code that works around this theoretical problem
- runs afoul of a compiler bug in Oracle Studio 12.3 x86. See:
- https://lists.gnu.org/r/bug-gnulib/2017-04/msg00049.html
- As the compiler bug is real, don't try to work around the
- theoretical problem. */
-
-#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t) \
- ((t) ((ut) (a) op (ut) (b)))
-
-#endif /* _GL_INTPROPS_H */
diff --git a/src/libopts/libopts.c b/src/libopts/libopts.c
deleted file mode 100644
index 457edc433a..0000000000
--- a/src/libopts/libopts.c
+++ /dev/null
@@ -1,50 +0,0 @@
-#define AUTOOPTS_INTERNAL 1
-#include "autoopts/project.h"
-
-#include "ao-strs.h"
-static char const ao_ver_string[] =
- "42:1:17\n";
-#include "autoopts/options.h"
-#include "autoopts/usage-txt.h"
-#include "genshell.h"
-#include "option-xat-attribute.h"
-#include "option-value-type.h"
-#include "ao-strs.h"
-#include "ag-char-map.h"
-#include "save-flags.h"
-#include "autoopts.h"
-#include "proto.h"
-#include "parse-duration.c"
-#include "ao-strs.c"
-#include "option-value-type.c"
-#include "option-xat-attribute.c"
-#include "save-flags.c"
-#include "autoopts.c"
-#include "alias.c"
-#include "boolean.c"
-#include "check.c"
-#include "configfile.c"
-#include "cook.c"
-#include "enum.c"
-#include "env.c"
-#include "file.c"
-#include "find.c"
-#include "genshell.c"
-#include "load.c"
-#include "makeshell.c"
-#include "nested.c"
-#include "numeric.c"
-#include "pgusage.c"
-#include "putshell.c"
-#include "reset.c"
-#include "restore.c"
-#include "save.c"
-#include "sort.c"
-#include "stack.c"
-#include "streqvcmp.c"
-#include "text_mmap.c"
-#include "time.c"
-#include "tokenize.c"
-#include "usage.c"
-#include "version.c"
-#include "init.c"
diff --git a/src/libopts/load.c b/src/libopts/load.c
deleted file mode 100644
index 59d124ebd4..0000000000
--- a/src/libopts/load.c
+++ /dev/null
@@ -1,578 +0,0 @@
-
-/**
- * \file load.c
- *
- * This file contains the routines that deal with processing text strings
- * for options, either from a NUL-terminated string passed in or from an
- * rc/ini file.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-static bool
-get_realpath(char * buf, size_t b_sz)
-{
-#if defined(HAVE_CANONICALIZE_FILE_NAME)
- {
- size_t name_len;
-
- char * pz = canonicalize_file_name(buf);
- if (pz == NULL)
- return false;
-
- name_len = strlen(pz);
- if (name_len >= (size_t)b_sz) {
- free(pz);
- return false;
- }
-
- memcpy(buf, pz, name_len + 1);
- free(pz);
- }
-
-#elif defined(HAVE_REALPATH)
- {
- size_t name_len;
- char z[PATH_MAX+1];
-
- if (realpath(buf, z) == NULL)
- return false;
-
- name_len = strlen(z);
- if (name_len >= b_sz)
- return false;
-
- memcpy(buf, z, name_len + 1);
- }
-#endif
- return true;
-}
-
-/*=export_func optionMakePath
- * private:
- *
- * what: translate and construct a path
- * arg: + char * + p_buf + The result buffer +
- * arg: + int + b_sz + The size of this buffer +
- * arg: + char const * + fname + The input name +
- * arg: + char const * + prg_path + The full path of the current program +
- *
- * ret-type: bool
- * ret-desc: true if the name was handled, otherwise false.
- * If the name does not start with ``$'', then it is handled
- * simply by copying the input name to the output buffer and
- * resolving the name with either
- * @code{canonicalize_file_name(3GLIBC)} or @code{realpath(3C)}.
- *
- * doc:
- *
- * This routine will copy the @code{pzName} input name into the
- * @code{pzBuf} output buffer, not exceeding @code{bufSize} bytes. If the
- * first character of the input name is a @code{'$'} character, then there
- * is special handling:
- * @*
- * @code{$$} is replaced with the directory name of the @code{pzProgPath},
- * searching @code{$PATH} if necessary.
- * @*
- * @code{$@} is replaced with the AutoGen package data installation directory
- * (aka @code{pkgdatadir}).
- * @*
- * @code{$NAME} is replaced by the contents of the @code{NAME} environment
- * variable. If not found, the search fails.
- *
- * Please note: both @code{$$} and @code{$NAME} must be at the start of the
- * @code{pzName} string and must either be the entire string or be followed
- * by the @code{'/'} (backslash on windows) character.
- *
- * err: @code{false} is returned if:
- * @*
- * @bullet{} The input name exceeds @code{bufSize} bytes.
- * @*
- * @bullet{} @code{$$}, @code{$@@} or @code{$NAME} is not the full string
- * and the next character is not '/'.
- * @*
- * @bullet{} libopts was built without PKGDATADIR defined and @code{$@@}
- * was specified.
- * @*
- * @bullet{} @code{NAME} is not a known environment variable
- * @*
- * @bullet{} @code{canonicalize_file_name} or @code{realpath} return
- * errors (cannot resolve the resulting path).
-=*/
-bool
-optionMakePath(char * p_buf, int b_sz, char const * fname, char const * prg_path)
-{
- {
- size_t len = strlen(fname);
-
- if (((size_t)b_sz <= len) || (len == 0))
- return false;
- }
-
- /*
- * IF not an environment variable, just copy the data
- */
- if (*fname != '$') {
- char const * src = fname;
- char * dst = p_buf;
- int ct = b_sz;
-
- for (;;) {
- if ( (*(dst++) = *(src++)) == NUL)
- break;
- if (--ct <= 0)
- return false;
- }
- }
-
- /*
- * IF the name starts with "$$", then it must be "$$" or
- * it must start with "$$/". In either event, replace the "$$"
- * with the path to the executable and append a "/" character.
- */
- else switch (fname[1]) {
- case NUL:
- return false;
-
- case '$':
- if (! add_prog_path(p_buf, b_sz, fname, prg_path))
- return false;
- break;
-
- case '@':
- if (program_pkgdatadir[0] == NUL)
- return false;
-
- if (snprintf(p_buf, (size_t)b_sz, "%s%s",
- program_pkgdatadir, fname + 2) >= b_sz)
- return false;
- break;
-
- default:
- if (! add_env_val(p_buf, b_sz, fname))
- return false;
- }
-
- return get_realpath(p_buf, b_sz);
-}
-
-/**
- * convert a leading "$$" into a path to the executable.
- */
-static bool
-add_prog_path(char * buf, int b_sz, char const * fname, char const * prg_path)
-{
- char const * path;
- char const * pz;
- int skip = 2;
- size_t fname_len;
- size_t dir_len; //!< length of the directory portion of the path to the exe
-
- switch (fname[2]) {
- case DIRCH:
- skip = 3;
- case NUL:
- break;
- default:
- return false;
- }
-
- /*
- * See if the path is included in the program name.
- * If it is, we're done. Otherwise, we have to hunt
- * for the program using "pathfind".
- */
- if (strchr(prg_path, DIRCH) != NULL)
- path = prg_path;
- else {
- path = pathfind(getenv("PATH"), (char *)prg_path, "rx");
-
- if (path == NULL)
- return false;
- }
-
- pz = strrchr(path, DIRCH);
-
- /*
- * IF we cannot find a directory name separator,
- * THEN we do not have a path name to our executable file.
- */
- if (pz == NULL)
- return false;
-
- fname += skip;
- fname_len = strlen(fname) + 1; // + NUL byte
- dir_len = (pz - path) + 1; // + dir sep character
-
- /*
- * Concatenate the file name to the end of the executable path.
- * The result may be either a file or a directory.
- */
- if (dir_len + fname_len > (unsigned)b_sz)
- return false;
-
- memcpy(buf, path, dir_len);
- memcpy(buf + dir_len, fname, fname_len);
-
- /*
- * If the "path" path was gotten from "pathfind()", then it was
- * allocated and we need to deallocate it.
- */
- if (path != prg_path)
- AGFREE(path);
- return true;
-}
-
-/**
- * Add an environment variable value.
- */
-static bool
-add_env_val(char * buf, int buf_sz, char const * name)
-{
- char * dir_part = buf;
-
- for (;;) {
- int ch = (int)*++name;
- if (! IS_VALUE_NAME_CHAR(ch))
- break;
- *(dir_part++) = (char)ch;
- }
-
- if (dir_part == buf)
- return false;
-
- *dir_part = NUL;
-
- dir_part = getenv(buf);
-
- /*
- * Environment value not found -- skip the home list entry
- */
- if (dir_part == NULL)
- return false;
-
- {
- size_t dir_len = strlen(dir_part);
- size_t nm_len = strlen(name) + 1;
-
- if (dir_len + nm_len >= (unsigned)buf_sz)
- return false;
- memcpy(buf, dir_part, dir_len);
- memcpy(buf + dir_len, name, nm_len);
- }
-
- return true;
-}
-
-/**
- * Trim leading and trailing white space.
- * If we are cooking the text and the text is quoted, then "cook"
- * the string. To cook, the string must be quoted.
- *
- * @param[in,out] txt the input and output string
- * @param[in] mode the handling mode (cooking method)
- */
-static void
-munge_str(char * txt, tOptionLoadMode mode)
-{
- char * end;
-
- if (mode == OPTION_LOAD_KEEP)
- return;
-
- if (IS_WHITESPACE_CHAR(*txt)) {
- char * src = SPN_WHITESPACE_CHARS(txt+1);
- size_t l = strlen(src) + 1;
- memmove(txt, src, l);
- end = txt + l - 1;
-
- } else
- end = txt + strlen(txt);
-
- end = SPN_WHITESPACE_BACK(txt, end);
- *end = NUL;
-
- if (mode == OPTION_LOAD_UNCOOKED)
- return;
-
- switch (*txt) {
- default: return;
- case '"':
- case '\'': break;
- }
-
- switch (end[-1]) {
- default: return;
- case '"':
- case '\'': break;
- }
-
- (void)ao_string_cook(txt, NULL);
-}
-
-static char *
-assemble_arg_val(char * txt, tOptionLoadMode mode)
-{
- char * end = strpbrk(txt, ARG_BREAK_STR);
- int space_break;
-
- /*
- * Not having an argument to a configurable name is okay.
- */
- if (end == NULL)
- return txt + strlen(txt);
-
- /*
- * If we are keeping all whitespace, then the modevalue starts with the
- * character that follows the end of the configurable name, regardless
- * of which character caused it.
- */
- if (mode == OPTION_LOAD_KEEP) {
- *(end++) = NUL;
- return end;
- }
-
- /*
- * If the name ended on a white space character, remember that
- * because we'll have to skip over an immediately following ':' or '='
- * (and the white space following *that*).
- */
- space_break = IS_WHITESPACE_CHAR(*end);
- *(end++) = NUL;
-
- end = SPN_WHITESPACE_CHARS(end);
- if (space_break && ((*end == ':') || (*end == '=')))
- end = SPN_WHITESPACE_CHARS(end+1);
-
- return end;
-}
-
-static char *
-trim_quotes(char * arg)
-{
- switch (*arg) {
- case '"':
- case '\'':
- ao_string_cook(arg, NULL);
- }
- return arg;
-}
-
-/**
- * See if the option is to be processed in the current scan direction
- * (-1 or +1).
- */
-static bool
-direction_ok(opt_state_mask_t f, int dir)
-{
- if (dir == 0)
- return true;
-
- switch (f & (OPTST_IMM|OPTST_DISABLE_IMM)) {
- case 0:
- /*
- * The selected option has no immediate action.
- * THEREFORE, if the direction is PRESETTING
- * THEN we skip this option.
- */
- if (PRESETTING(dir))
- return false;
- break;
-
- case OPTST_IMM:
- if (PRESETTING(dir)) {
- /*
- * We are in the presetting direction with an option we handle
- * immediately for enablement, but normally for disablement.
- * Therefore, skip if disabled.
- */
- if ((f & OPTST_DISABLED) == 0)
- return false;
- } else {
- /*
- * We are in the processing direction with an option we handle
- * immediately for enablement, but normally for disablement.
- * Therefore, skip if NOT disabled.
- */
- if ((f & OPTST_DISABLED) != 0)
- return false;
- }
- break;
-
- case OPTST_DISABLE_IMM:
- if (PRESETTING(dir)) {
- /*
- * We are in the presetting direction with an option we handle
- * immediately for disablement, but normally for handling.
- * Therefore, skip if NOT disabled.
- */
- if ((f & OPTST_DISABLED) != 0)
- return false;
- } else {
- /*
- * We are in the processing direction with an option we handle
- * immediately for disablement, but normally for handling.
- * Therefore, skip if disabled.
- */
- if ((f & OPTST_DISABLED) == 0)
- return false;
- }
- break;
-
- case OPTST_IMM|OPTST_DISABLE_IMM:
- /*
- * The selected option is always for immediate action.
- * THEREFORE, if the direction is PROCESSING
- * THEN we skip this option.
- */
- if (PROCESSING(dir))
- return false;
- break;
- }
- return true;
-}
-
-/**
- * Load an option from a block of text. The text must start with the
- * configurable/option name and be followed by its associated value.
- * That value may be processed in any of several ways. See "tOptionLoadMode"
- * in autoopts.h.
- *
- * @param[in,out] opts program options descriptor
- * @param[in,out] opt_state option processing state
- * @param[in,out] line source line with long option name in it
- * @param[in] direction current processing direction (preset or not)
- * @param[in] load_mode option loading mode (OPTION_LOAD_*)
- */
-static void
-load_opt_line(tOptions * opts, tOptState * opt_state, char * line,
- tDirection direction, tOptionLoadMode load_mode )
-{
- /*
- * When parsing a stored line, we only look at the characters after
- * a hyphen. Long names must always be at least two characters and
- * short options are always exactly one character long.
- */
- line = SPN_LOAD_LINE_SKIP_CHARS(line);
-
- {
- char * arg = assemble_arg_val(line, load_mode);
-
- if (IS_OPTION_NAME_CHAR(line[1])) {
-
- if (! SUCCESSFUL(opt_find_long(opts, line, opt_state)))
- return;
-
- } else if (! SUCCESSFUL(opt_find_short(opts, *line, opt_state)))
- return;
-
- if ((! CALLED(direction)) && (opt_state->flags & OPTST_NO_INIT))
- return;
-
- opt_state->pzOptArg = trim_quotes(arg);
- }
-
- if (! direction_ok(opt_state->flags, direction))
- return;
-
- /*
- * Fix up the args.
- */
- if (OPTST_GET_ARGTYPE(opt_state->pOD->fOptState) == OPARG_TYPE_NONE) {
- if (*opt_state->pzOptArg != NUL)
- return;
- opt_state->pzOptArg = NULL;
-
- } else if (opt_state->pOD->fOptState & OPTST_ARG_OPTIONAL) {
- if (*opt_state->pzOptArg == NUL)
- opt_state->pzOptArg = NULL;
- else {
- AGDUPSTR(opt_state->pzOptArg, opt_state->pzOptArg, "opt arg");
- opt_state->flags |= OPTST_ALLOC_ARG;
- }
-
- } else {
- if (*opt_state->pzOptArg == NUL)
- opt_state->pzOptArg = zNil;
- else {
- AGDUPSTR(opt_state->pzOptArg, opt_state->pzOptArg, "opt arg");
- opt_state->flags |= OPTST_ALLOC_ARG;
- }
- }
-
- {
- tOptionLoadMode sv = option_load_mode;
- option_load_mode = load_mode;
- handle_opt(opts, opt_state);
- option_load_mode = sv;
- }
-}
-
-/*=export_func optionLoadLine
- *
- * what: process a string for an option name and value
- *
- * arg: tOptions *, opts, program options descriptor
- * arg: char const *, line, NUL-terminated text
- *
- * doc:
- *
- * This is a client program callable routine for setting options from, for
- * example, the contents of a file that they read in. Only one option may
- * appear in the text. It will be treated as a normal (non-preset) option.
- *
- * When passed a pointer to the option struct and a string, it will find
- * the option named by the first token on the string and set the option
- * argument to the remainder of the string. The caller must NUL terminate
- * the string. The caller need not skip over any introductory hyphens.
- * Any embedded new lines will be included in the option
- * argument. If the input looks like one or more quoted strings, then the
- * input will be "cooked". The "cooking" is identical to the string
- * formation used in AutoGen definition files (@pxref{basic expression}),
- * except that you may not use backquotes.
- *
- * err: Invalid options are silently ignored. Invalid option arguments
- * will cause a warning to print, but the function should return.
-=*/
-void
-optionLoadLine(tOptions * opts, char const * line)
-{
- tOptState st = OPTSTATE_INITIALIZER(SET);
- char * pz;
- proc_state_mask_t sv_flags = opts->fOptSet;
- opts->fOptSet &= ~OPTPROC_ERRSTOP;
- AGDUPSTR(pz, line, "opt line");
- load_opt_line(opts, &st, pz, DIRECTION_CALLED, OPTION_LOAD_COOKED);
- AGFREE(pz);
- opts->fOptSet = sv_flags;
-}
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/load.c */
diff --git a/src/libopts/m4/libopts.m4 b/src/libopts/m4/libopts.m4
deleted file mode 100644
index 23738cab47..0000000000
--- a/src/libopts/m4/libopts.m4
+++ /dev/null
@@ -1,586 +0,0 @@
-
-dnl do always before generated macros:
-dnl
-AC_DEFUN([INVOKE_LIBOPTS_MACROS_FIRST],[
- AC_REQUIRE([AC_HEADER_STDC])
- AC_HEADER_DIRENT
-
- # =================
- # AC_CHECK_HEADERS
- # =================
- AC_CHECK_HEADERS([ \
- sys/mman.h sys/param.h sys/poll.h sys/procset.h \
- sys/select.h sys/socket.h sys/stropts.h sys/time.h \
- sys/un.h sys/wait.h dlfcn.h errno.h \
- fcntl.h libgen.h libintl.h memory.h \
- netinet/in.h setjmp.h stdbool.h sysexits.h \
- unistd.h utime.h])
-
- AC_CHECK_HEADERS([stdarg.h varargs.h],
- [lo_have_arg_hdr=true;break],
- [lo_have_arg_hdr=false])
-
- AC_CHECK_HEADERS([string.h strings.h],
- [lo_have_str_hdr=true;break],
- [lo_have_str_hdr=false])
-
- AC_CHECK_HEADERS([limits.h sys/limits.h values.h],
- [lo_have_lim_hdr=true;break],
- [lo_have_lim_hdr=false])
-
- AC_CHECK_HEADERS([inttypes.h stdint.h],
- [lo_have_typ_hdr=true;break],
- [lo_have_typ_hdr=false])
- gl_STDNORETURN_H
-
- # ----------------------------------------------------------------------
- # check for various programs used during the build.
- # On OS/X, "wchar.h" needs "runetype.h" to work properly.
- # ----------------------------------------------------------------------
- AC_CHECK_HEADERS([runetype.h wchar.h], [], [],[
- AC_INCLUDES_DEFAULT
- #if HAVE_RUNETYPE_H
- # include <runetype.h>
- #endif
- ])
-
- AC_ARG_ENABLE([nls],
- AS_HELP_STRING([--disable-nls],[disable nls support in libopts]))
- AS_IF([test "x$enable_nls" != "xno" && \
- test "X${ac_cv_header_libintl_h}" = Xyes], [
- AC_DEFINE([ENABLE_NLS],[1],[nls support in libopts])])
-
- # --------------------------------------------
- # Verify certain entries from AC_CHECK_HEADERS
- # --------------------------------------------
- [${lo_have_arg_hdr} || \
- ]AC_MSG_ERROR([you must have stdarg.h or varargs.h on your system])[
-
- ${lo_have_str_hdr} || \
- ]AC_MSG_ERROR([you must have string.h or strings.h on your system])[
-
- ${lo_have_lim_hdr} || \
- ]AC_MSG_ERROR(
- [you must have one of limits.h, sys/limits.h or values.h])[
-
- ${lo_have_typ_hdr} || \
- ]AC_MSG_ERROR([you must have inttypes.h or stdint.h on your system])[
-
- for f in sys_types sys_param sys_stat string errno stdlib memory setjmp
- do eval as_ac_var=\${ac_cv_header_${f}_h}
- test "X${as_ac_var}" = Xyes || {
- ]AC_MSG_ERROR([you must have ${f}.h on your system])[
- }
- done
- test "X${ac_cv_header_inttypes_h-no}" = Xyes || \
- echo '#include <stdint.h>' > inttypes.h]
-
- # ----------------------------------------------------------------------
- # Checks for typedefs
- # ----------------------------------------------------------------------
- AC_CHECK_TYPES(wchar_t)
- AC_CHECK_TYPES(wint_t, [], [], [
- AC_INCLUDES_DEFAULT
- #if HAVE_RUNETYPE_H
- # include <runetype.h>
- #endif
- #if HAVE_WCHAR_H
- # include <wchar.h>
- #endif
- ])
- AC_CHECK_TYPES([int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t,
- intptr_t, uintptr_t, uint_t, pid_t, size_t, ptrdiff_t])
- AC_CHECK_SIZEOF(char *, 8)
- AC_CHECK_SIZEOF(int, 4)
- AC_CHECK_SIZEOF(long, 8)
- AC_CHECK_SIZEOF(short, 2)
-
- # ------------
- # AC_CHECK_LIB
- # ------------
- AC_CHECK_LIB(gen, pathfind)
- AC_CHECK_LIB(intl,gettext)
- AC_FUNC_VPRINTF
- AC_FUNC_FORK
- AC_CHECK_FUNCS([mmap canonicalize_file_name snprintf strdup strchr \
- strrchr strsignal fchmod fstat chmod])
- AC_PROG_SED
- [while :
- do
- test -x "$POSIX_SHELL" && break
- POSIX_SHELL=`which bash`
- test -x "$POSIX_SHELL" && break
- POSIX_SHELL=`which dash`
- test -x "$POSIX_SHELL" && break
- POSIX_SHELL=/usr/xpg4/bin/sh
- test -x "$POSIX_SHELL" && break
- POSIX_SHELL=`/bin/sh -c '
- exec 2>/dev/null
- if ! true ; then exit 1 ; fi
- echo /bin/sh'`
- test -x "$POSIX_SHELL" && break
- ]AC_MSG_ERROR([cannot locate a working POSIX shell])[
- done]
- AC_DEFINE_UNQUOTED([POSIX_SHELL], ["${POSIX_SHELL}"],
- [define to a working POSIX compliant shell])
- AC_SUBST([POSIX_SHELL])
-])
-
-dnl
-dnl @synopsis INVOKE_LIBOPTS_MACROS
-dnl
-dnl This macro will invoke the AutoConf macros specified in libopts.def
-dnl that have not been disabled with "omit-invocation".
-dnl
-AC_DEFUN([LIBOPTS_WITH_REGEX_HEADER],[
- AC_ARG_WITH([regex-header],
- AS_HELP_STRING([--with-regex-header], [a reg expr header is specified]),
- [libopts_cv_with_regex_header=${with_regex_header}],
- AC_CACHE_CHECK([whether a reg expr header is specified], libopts_cv_with_regex_header,
- libopts_cv_with_regex_header=no)
- ) # end of AC_ARG_WITH
- if test "X${libopts_cv_with_regex_header}" != Xno
- then
- AC_DEFINE_UNQUOTED([REGEX_HEADER],[<${libopts_cv_with_regex_header}>])
- else
- AC_DEFINE([REGEX_HEADER],[<regex.h>],[name of regex header file])
- fi
-
-]) # end of AC_DEFUN of LIBOPTS_WITH_REGEX_HEADER
-
-
-AC_DEFUN([LIBOPTS_WITHLIB_REGEX],[
- AC_ARG_WITH([libregex],
- AS_HELP_STRING([--with-libregex], [libregex installation prefix]),
- [libopts_cv_with_libregex_root=${with_libregex}],
- AC_CACHE_CHECK([whether with-libregex was specified], libopts_cv_with_libregex_root,
- libopts_cv_with_libregex_root=no)
- ) # end of AC_ARG_WITH libregex
-
- if test "${with_libregex+set}" = set && \
- test "X${withval}" = Xno
- then ## disabled by request
- libopts_cv_with_libregex_root=no
- libopts_cv_with_libregex_cflags=no
- libopts_cv_with_libregex_libs=no
- else
-
- AC_ARG_WITH([libregex-cflags],
- AS_HELP_STRING([--with-libregex-cflags], [libregex compile flags]),
- [libopts_cv_with_libregex_cflags=${with_libregex_cflags}],
- AC_CACHE_CHECK([whether with-libregex-cflags was specified], libopts_cv_with_libregex_cflags,
- libopts_cv_with_libregex_cflags=no)
- ) # end of AC_ARG_WITH libregex-cflags
-
- AC_ARG_WITH([libregex-libs],
- AS_HELP_STRING([--with-libregex-libs], [libregex link command arguments]),
- [libopts_cv_with_libregex_libs=${with_libregex_libs}],
- AC_CACHE_CHECK([whether with-libregex-libs was specified], libopts_cv_with_libregex_libs,
- libopts_cv_with_libregex_libs=no)
- ) # end of AC_ARG_WITH libregex-libs
-
- case "X${libopts_cv_with_libregex_cflags}" in
- Xyes|Xno|X )
- case "X${libopts_cv_with_libregex_root}" in
- Xyes|Xno|X ) libopts_cv_with_libregex_cflags=no ;;
- * ) libopts_cv_with_libregex_cflags=-I${libopts_cv_with_libregex_root}/include ;;
- esac
- esac
- case "X${libopts_cv_with_libregex_libs}" in
- Xyes|Xno|X )
- case "X${libopts_cv_with_libregex_root}" in
- Xyes|Xno|X ) libopts_cv_with_libregex_libs=no ;;
- * ) libopts_cv_with_libregex_libs="-L${libopts_cv_with_libregex_root}/lib -lregex" ;;
- esac
- esac
- libopts_save_CPPFLAGS="${CPPFLAGS}"
- libopts_save_LIBS="${LIBS}"
- case "X${libopts_cv_with_libregex_cflags}" in
- Xyes|Xno|X )
- libopts_cv_with_libregex_cflags="" ;;
- * ) CPPFLAGS="${CPPFLAGS} ${libopts_cv_with_libregex_cflags}" ;;
- esac
- case "X${libopts_cv_with_libregex_libs}" in
- Xyes|Xno|X )
- libopts_cv_with_libregex_libs="" ;;
- * )
- LIBS="${LIBS} ${libopts_cv_with_libregex_libs}" ;;
- esac
- LIBREGEX_CFLAGS=""
- LIBREGEX_LIBS=""
- AC_MSG_CHECKING([whether libregex functions properly])
- AC_CACHE_VAL([libopts_cv_with_libregex],[
- AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <stdio.h>
-@%:@include <stdlib.h>
-@%:@include <sys/types.h>
-@%:@include REGEX_HEADER
-static regex_t re;
-void comp_re(char const * pzPat) {
- int res = regcomp( &re, pzPat, REG_EXTENDED|REG_ICASE|REG_NEWLINE );
- if (res == 0) return;
- exit( res ); }
-int main() {
- regmatch_t m@<:@2@:>@;
- comp_re( "^.*\@S|@" );
- comp_re( "()|no.*" );
- comp_re( "." );
- if (regexec( &re, "X", 2, m, 0 ) != 0) return 1;
- if ((m@<:@0@:>@.rm_so != 0) || (m@<:@0@:>@.rm_eo != 1)) {
- fputs( "error: regex -->.<-- did not match\n", stderr );
- return 1;
- }
- return 0; }] )],
- [libopts_cv_with_libregex=yes], [libopts_cv_with_libregex=no],
- [libopts_cv_with_libregex=no]) # end of AC_RUN_IFELSE
- ]) # end of AC_CACHE_VAL for libopts_cv_with_libregex
- fi ## disabled by request
- AC_MSG_RESULT([${libopts_cv_with_libregex}])
- if test "X${libopts_cv_with_libregex}" != Xno
- then
- AC_DEFINE([WITH_LIBREGEX],[1],
- [Define this if a working libregex can be found])
- else
- CPPFLAGS="${libopts_save_CPPFLAGS}"
- LIBS="${libopts_save_LIBS}"
- libopts_cv_with_libregex_root=no
-libopts_cv_with_libregex_cflags=no
-libopts_cv_with_libregex_libs=no
-libopts_cv_with_libregex=no
- fi
-
-]) # end of AC_DEFUN of LIBOPTS_WITHLIB_REGEX
-
-
-AC_DEFUN([LIBOPTS_RUN_PATHFIND],[
- AC_MSG_CHECKING([whether pathfind(3) works])
- AC_CACHE_VAL([libopts_cv_run_pathfind],[
- AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <string.h>
-@%:@include <stdlib.h>
-int main (int argc, char ** argv) {
- char * pz = pathfind( getenv( "PATH" ), "sh", "x" );
- return (pz == 0) ? 1 : 0;
-}] )],
- [libopts_cv_run_pathfind=yes],[libopts_cv_run_pathfind=no],[libopts_cv_run_pathfind=no]
- ) # end of RUN_IFELSE
- ]) # end of AC_CACHE_VAL for libopts_cv_run_pathfind
- AC_MSG_RESULT([${libopts_cv_run_pathfind}])
- if test "X${libopts_cv_run_pathfind}" != Xno
- then
- AC_DEFINE([HAVE_PATHFIND],[1],
- [Define this if pathfind(3) works])
- fi
-
-]) # end of AC_DEFUN of LIBOPTS_RUN_PATHFIND
-
-
-AC_DEFUN([LIBOPTS_TEST_DEV_ZERO],[
- AC_MSG_CHECKING([whether /dev/zero is readable device])
- AC_CACHE_VAL([libopts_cv_test_dev_zero],[
- libopts_cv_test_dev_zero=`exec 2> /dev/null
-dzero=\`ls -lL /dev/zero | egrep ^c......r\`
-test -z "${dzero}" && exit 1
-echo ${dzero}`
- if test $? -ne 0 || test -z "$libopts_cv_test_dev_zero"
- then libopts_cv_test_dev_zero=no
- fi
- ]) # end of CACHE_VAL of libopts_cv_test_dev_zero
- AC_MSG_RESULT([${libopts_cv_test_dev_zero}])
- if test "X${libopts_cv_test_dev_zero}" != Xno
- then
- AC_DEFINE([HAVE_DEV_ZERO],[1],
- [Define this if /dev/zero is readable device])
- fi
-
-]) # end of AC_DEFUN of LIBOPTS_TEST_DEV_ZERO
-
-
-AC_DEFUN([LIBOPTS_RUN_REALPATH],[
- AC_MSG_CHECKING([whether we have a functional realpath(3C)])
- AC_CACHE_VAL([libopts_cv_run_realpath],[
- AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <limits.h>
-@%:@include <stdlib.h>
-int main (int argc, char ** argv) {
-@%:@ifndef PATH_MAX
-choke me!!
-@%:@else
- char zPath@<:@PATH_MAX+1@:>@;
-@%:@endif
- char *pz = realpath(argv@<:@0@:>@, zPath);
- return (pz == zPath) ? 0 : 1;
-}] )],
- [libopts_cv_run_realpath=yes],[libopts_cv_run_realpath=no],[libopts_cv_run_realpath=no]
- ) # end of RUN_IFELSE
- ]) # end of AC_CACHE_VAL for libopts_cv_run_realpath
- AC_MSG_RESULT([${libopts_cv_run_realpath}])
- if test "X${libopts_cv_run_realpath}" != Xno
- then
- AC_DEFINE([HAVE_REALPATH],[1],
- [Define this if we have a functional realpath(3C)])
- fi
-
-]) # end of AC_DEFUN of LIBOPTS_RUN_REALPATH
-
-
-AC_DEFUN([LIBOPTS_RUN_STRFTIME],[
- AC_MSG_CHECKING([whether strftime() works])
- AC_CACHE_VAL([libopts_cv_run_strftime],[
- AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <time.h>
-@%:@include <string.h>
-char t_buf@<:@ 64 @:>@;
-int main() {
- static char const z@<:@@:>@ = "Thursday Aug 28 240";
- struct tm tm;
- tm.tm_sec = 36; /* seconds after the minute @<:@0, 61@:>@ */
- tm.tm_min = 44; /* minutes after the hour @<:@0, 59@:>@ */
- tm.tm_hour = 12; /* hour since midnight @<:@0, 23@:>@ */
- tm.tm_mday = 28; /* day of the month @<:@1, 31@:>@ */
- tm.tm_mon = 7; /* months since January @<:@0, 11@:>@ */
- tm.tm_year = 86; /* years since 1900 */
- tm.tm_wday = 4; /* days since Sunday @<:@0, 6@:>@ */
- tm.tm_yday = 239; /* days since January 1 @<:@0, 365@:>@ */
- tm.tm_isdst = 1; /* flag for daylight savings time */
- strftime( t_buf, sizeof( t_buf ), "%A %b %d %j", &tm );
- return (strcmp( t_buf, z ) != 0); }] )],
- [libopts_cv_run_strftime=yes],[libopts_cv_run_strftime=no],[libopts_cv_run_strftime=no]
- ) # end of RUN_IFELSE
- ]) # end of AC_CACHE_VAL for libopts_cv_run_strftime
- AC_MSG_RESULT([${libopts_cv_run_strftime}])
- if test "X${libopts_cv_run_strftime}" != Xno
- then
- AC_DEFINE([HAVE_STRFTIME],[1],
- [Define this if strftime() works])
- fi
-
-]) # end of AC_DEFUN of LIBOPTS_RUN_STRFTIME
-
-
-AC_DEFUN([LIBOPTS_RUN_FOPEN_BINARY],[
- AC_MSG_CHECKING([whether fopen accepts "b" mode])
- AC_CACHE_VAL([libopts_cv_run_fopen_binary],[
- AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <stdio.h>
-int main (int argc, char ** argv) {
-FILE * fp = fopen("conftest.@S|@ac_ext", "rb");
-return (fp == NULL) ? 1 : fclose(fp); }] )],
- [libopts_cv_run_fopen_binary=yes],[libopts_cv_run_fopen_binary=no],[libopts_cv_run_fopen_binary=no]
- ) # end of RUN_IFELSE
- ]) # end of AC_CACHE_VAL for libopts_cv_run_fopen_binary
- AC_MSG_RESULT([${libopts_cv_run_fopen_binary}])
- if test "X${libopts_cv_run_fopen_binary}" != Xno
- then
- AC_DEFINE([FOPEN_BINARY_FLAG],"b",
- [fopen(3) accepts a 'b' in the mode flag])
- else
- AC_DEFINE([FOPEN_BINARY_FLAG],"",
- [fopen(3) accepts a 'b' in the mode flag])
- fi
-
-]) # end of AC_DEFUN of LIBOPTS_RUN_FOPEN_BINARY
-
-
-AC_DEFUN([LIBOPTS_RUN_FOPEN_TEXT],[
- AC_MSG_CHECKING([whether fopen accepts "t" mode])
- AC_CACHE_VAL([libopts_cv_run_fopen_text],[
- AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <stdio.h>
-int main (int argc, char ** argv) {
-FILE * fp = fopen("conftest.@S|@ac_ext", "rt");
-return (fp == NULL) ? 1 : fclose(fp); }] )],
- [libopts_cv_run_fopen_text=yes],[libopts_cv_run_fopen_text=no],[libopts_cv_run_fopen_text=no]
- ) # end of RUN_IFELSE
- ]) # end of AC_CACHE_VAL for libopts_cv_run_fopen_text
- AC_MSG_RESULT([${libopts_cv_run_fopen_text}])
- if test "X${libopts_cv_run_fopen_text}" != Xno
- then
- AC_DEFINE([FOPEN_TEXT_FLAG],"t",
- [fopen(3) accepts a 't' in the mode flag])
- else
- AC_DEFINE([FOPEN_TEXT_FLAG],"",
- [fopen(3) accepts a 't' in the mode flag])
- fi
-
-]) # end of AC_DEFUN of LIBOPTS_RUN_FOPEN_TEXT
-
-
-AC_DEFUN([LIBOPTS_DISABLE_OPTIONAL_ARGS],[
- AC_ARG_ENABLE([optional-args],
- AS_HELP_STRING([--disable-optional-args], [not wanting optional option args]),
- [libopts_cv_enable_optional_args=${enable_optional_args}],
- AC_CACHE_CHECK([whether not wanting optional option args], libopts_cv_enable_optional_args,
- libopts_cv_enable_optional_args=yes)
- ) # end of AC_ARG_ENABLE
- if test "X${libopts_cv_enable_optional_args}" = Xno
- then
- AC_DEFINE([NO_OPTIONAL_OPT_ARGS], [1],
- [Define this if optional arguments are disallowed])
- fi
-
-]) # end of AC_DEFUN of LIBOPTS_DISABLE_OPTIONAL_ARGS
-
-
-AC_DEFUN([INVOKE_LIBOPTS_MACROS],[
- AC_REQUIRE([INVOKE_LIBOPTS_MACROS_FIRST])
- # Check to see if a reg expr header is specified.
- LIBOPTS_WITH_REGEX_HEADER
-
- # Check to see if a working libregex can be found.
- LIBOPTS_WITHLIB_REGEX
-
- # Check to see if pathfind(3) works.
- LIBOPTS_RUN_PATHFIND
-
- # Check to see if /dev/zero is readable device.
- LIBOPTS_TEST_DEV_ZERO
-
- # Check to see if we have a functional realpath(3C).
- LIBOPTS_RUN_REALPATH
-
- # Check to see if strftime() works.
- LIBOPTS_RUN_STRFTIME
-
- # Check to see if fopen accepts "b" mode.
- LIBOPTS_RUN_FOPEN_BINARY
-
- # Check to see if fopen accepts "t" mode.
- LIBOPTS_RUN_FOPEN_TEXT
-
- # Check to see if not wanting optional option args.
- LIBOPTS_DISABLE_OPTIONAL_ARGS
-
-]) # end AC_DEFUN of INVOKE_LIBOPTS_MACROS
-
-dnl @synopsis LIBOPTS_CHECK
-dnl
-dnl If autoopts-config works, add the linking information to LIBS.
-dnl Otherwise, add ``libopts-${ao_rev}'' to SUBDIRS and run all
-dnl the config tests that the library needs. Invoke the
-dnl "INVOKE_LIBOPTS_MACROS" macro iff we are building libopts.
-dnl
-dnl This file is part of AutoGen.
-dnl AutoGen Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
-dnl
-dnl AutoGen is free software: you can redistribute it and/or modify it
-dnl under the terms of the GNU General Public License as published by the
-dnl Free Software Foundation, either version 3 of the License, or
-dnl (at your option) any later version.
-dnl
-dnl AutoGen is distributed in the hope that it will be useful, but
-dnl WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-dnl See the GNU General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License along
-dnl with this program. If not, see <http://www.gnu.org/licenses/>.
-dnl
-dnl Default to system libopts
-dnl
-AC_DEFUN([LIBOPTS_CHECK_COMMON],[
- AC_REQUIRE([INVOKE_LIBOPTS_MACROS_FIRST])
- [NEED_LIBOPTS_DIR='']
- m4_pushdef([AO_Libopts_Dir],
- [ifelse($1, , [libopts], [$1])])
- AC_ARG_ENABLE([local-libopts],
- AC_HELP_STRING([--enable-local-libopts],
- [Use the supplied libopts tearoff code]),[
- if test x$enableval = xyes ; then
- AC_MSG_NOTICE([Using supplied libopts tearoff])
- LIBOPTS_CFLAGS='-I$(top_srcdir)/AO_Libopts_Dir'
- NEED_LIBOPTS_DIR=true
- LIBOPTS_LDADD='$(top_builddir)/AO_Libopts_Dir/libopts.la'
- fi])
-
- AC_ARG_ENABLE([libopts-install],
- AC_HELP_STRING([--enable-libopts-install],
- [Install libopts with client installation]))
- AM_CONDITIONAL([INSTALL_LIBOPTS],[test "X${enable_libopts_install}" = Xyes])
-
- [if test -z "${NEED_LIBOPTS_DIR}" ; then]
- AC_MSG_CHECKING([whether autoopts-config can be found])
- AC_ARG_WITH([autoopts-config],
- AC_HELP_STRING([--with-autoopts-config],
- [specify the config-info script]),
- [lo_cv_with_autoopts_config=${with_autoopts_config}],
- AC_CACHE_CHECK([whether autoopts-config is specified],
- [lo_cv_with_autoopts_config],
- [if autoopts-config --help 2>/dev/null 1>&2
- then lo_cv_with_autoopts_config=autoopts-config
- elif libopts-config --help 2>/dev/null 1>&2
- then lo_cv_with_autoopts_config=libopts-config
- else lo_cv_with_autoopts_config=no ; fi])
- ) # end of AC_ARG_WITH
-
- AC_CACHE_VAL([lo_cv_test_autoopts],[
- if test -z "${lo_cv_with_autoopts_config}" \
- -o X"${lo_cv_with_autoopts_config}" = Xno
- then
- if autoopts-config --help 2>/dev/null 1>&2
- then lo_cv_with_autoopts_config=autoopts-config
- elif libopts-config --help 2>/dev/null 1>&2
- then lo_cv_with_autoopts_config=libopts-config
- else lo_cv_with_autoopts_config=false ; fi
- fi
- lo_cv_test_autoopts=`
- ${lo_cv_with_autoopts_config} --libs` 2> /dev/null
- if test $? -ne 0 -o -z "${lo_cv_test_autoopts}"
- then lo_cv_test_autoopts=no ; fi
- ]) # end of CACHE_VAL
- AC_MSG_RESULT([${lo_cv_test_autoopts}])
-
- [if test "X${lo_cv_test_autoopts}" != Xno
- then
- LIBOPTS_LDADD="${lo_cv_test_autoopts}"
- LIBOPTS_CFLAGS="`${lo_cv_with_autoopts_config} --cflags`"
- else
- LIBOPTS_LDADD='$(top_builddir)/]AO_Libopts_Dir[/libopts.la'
- LIBOPTS_CFLAGS='-I$(top_srcdir)/]AO_Libopts_Dir['
- NEED_LIBOPTS_DIR=true
- fi
- fi # end of if test -z "${NEED_LIBOPTS_DIR}"
- if test -n "${LIBOPTS_BUILD_BLOCKED}" ; then
- NEED_LIBOPTS_DIR=''
- fi]
- AM_CONDITIONAL([NEED_LIBOPTS], [test -n "${NEED_LIBOPTS_DIR}"])
- AC_SUBST(LIBOPTS_LDADD)
- AC_SUBST(LIBOPTS_CFLAGS)
- AC_SUBST(LIBOPTS_DIR, AO_Libopts_Dir)
- m4_popdef([AO_Libopts_Dir])
-[# end of AC_DEFUN of LIBOPTS_CHECK_COMMON]
-])
-dnl
-dnl AC_CONFIG_FILES conditionalization requires using AM_COND_IF, however
-dnl AM_COND_IF is new to Automake 1.11. To use it on new Automake without
-dnl requiring same, a fallback implementation for older Automake is provided.
-dnl Note that disabling of AC_CONFIG_FILES requires Automake 1.11, this code
-dnl is correct only in terms of m4sh generated script.
-dnl
-m4_ifndef([AM_COND_IF],
- [AC_DEFUN([AM_COND_IF], [
- if test -z "$$1_TRUE"; then :
- m4_n([$2])[]dnl
- m4_ifval([$3],[
- else
- $3
- ])dnl
- fi[]dnl
- ])dnl
-])
-dnl
-AC_DEFUN([LIBOPTS_CHECK_NOBUILD], [
- m4_pushdef([AO_Libopts_Dir],
- [ifelse($1, , [libopts], [$1])])
- LIBOPTS_BUILD_BLOCKED=true
- LIBOPTS_CHECK_COMMON(AO_Libopts_Dir)
- m4_popdef([AO_Libopts_Dir])dnl
-# end of AC_DEFUN of LIBOPTS_CHECK_NOBUILD
-])
-dnl
-AC_DEFUN([LIBOPTS_CHECK], [
- m4_pushdef([AO_Libopts_Dir],
- [ifelse($1, , [libopts], [$1])])
- LIBOPTS_BUILD_BLOCKED=''
- LIBOPTS_CHECK_COMMON(AO_Libopts_Dir)
- AM_COND_IF([NEED_LIBOPTS], [
- INVOKE_LIBOPTS_MACROS
- ])
- AC_CONFIG_FILES(AO_Libopts_Dir/Makefile)
- m4_popdef([AO_Libopts_Dir])dnl
-# end of AC_DEFUN of LIBOPTS_CHECK
-])
diff --git a/src/libopts/m4/liboptschk.m4 b/src/libopts/m4/liboptschk.m4
deleted file mode 100644
index 9d107d6962..0000000000
--- a/src/libopts/m4/liboptschk.m4
+++ /dev/null
@@ -1,27 +0,0 @@
-# liboptschk.m4 serial 2 (autogen - 5.11.4)
-dnl Copyright (C) 2005-2018 by Bruce Korb - all rights reserved
-dnl
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-dnl
-AC_DEFUN([ag_FIND_LIBOPTS],
- [if test "X${ac_cv_header_autoopts_options_h}" = Xno
- then :
- else
- f=`autoopts-config cflags` 2>/dev/null
- if test X"${f}" = X
- then
- :
- else
- AC_DEFINE([HAVE_LIBOPTS],[1],[define if we can find libopts])
- CFLAGS="${CFLAGS} ${f}"
- ao_CFLAGS="${f}"
- AC_SUBST(ao_CFLAGS)
-
- f=`autoopts-config ldflags` 2>/dev/null
- LIBS="${LIBS} ${f}"
- ao_LIBS="${f}"
- AC_SUBST(ao_LIBS)
- fi
- fi])
diff --git a/src/libopts/m4/stdnoreturn.m4 b/src/libopts/m4/stdnoreturn.m4
deleted file mode 100644
index a7ce376428..0000000000
--- a/src/libopts/m4/stdnoreturn.m4
+++ /dev/null
@@ -1,51 +0,0 @@
-# Check for stdnoreturn.h that conforms to C11.
-
-dnl Copyright 2012-2018 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-# Prepare for substituting <stdnoreturn.h> if it is not supported.
-
-AC_DEFUN([gl_STDNORETURN_H],
-[
- AC_REQUIRE([AC_CANONICAL_HOST])
- case "$host_os" in
- cygwin*)
- dnl Regardless whether a working <stdnoreturn.h> exists or not,
- dnl we need our own <stdnoreturn.h>, because of the definition
- dnl of _Noreturn done by gnulib-common.m4.
- STDNORETURN_H='stdnoreturn.h'
- ;;
- *)
- AC_CACHE_CHECK([for working stdnoreturn.h],
- [gl_cv_header_working_stdnoreturn_h],
- [AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM(
- [[#include <stdlib.h>
- #include <stdnoreturn.h>
- /* Do not check for 'noreturn' after the return type.
- C11 allows it, but it's rarely done that way
- and circa-2012 bleeding-edge GCC rejects it when given
- -Werror=old-style-declaration. */
- noreturn void foo1 (void) { exit (0); }
- _Noreturn void foo2 (void) { exit (0); }
- int testit (int argc, char **argv)
- {
- if (argc & 1)
- return 0;
- (argv[0][0] ? foo1 : foo2) ();
- }
- ]])],
- [gl_cv_header_working_stdnoreturn_h=yes],
- [gl_cv_header_working_stdnoreturn_h=no])])
- if test $gl_cv_header_working_stdnoreturn_h = yes; then
- STDNORETURN_H=''
- else
- STDNORETURN_H='stdnoreturn.h'
- fi
- ;;
- esac
- AC_SUBST([STDNORETURN_H])
- AM_CONDITIONAL([GL_GENERATE_STDNORETURN_H], [test -n "$STDNORETURN_H"])
-])
diff --git a/src/libopts/makeshell.c b/src/libopts/makeshell.c
deleted file mode 100644
index 10ed12005a..0000000000
--- a/src/libopts/makeshell.c
+++ /dev/null
@@ -1,918 +0,0 @@
-
-/**
- * \file makeshell.c
- *
- * This module will interpret the options set in the tOptions
- * structure and create a Bourne shell script capable of parsing them.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
- static inline unsigned char to_uchar (char ch) { return ch; }
-
-#define UPPER(_c) (toupper(to_uchar(_c)))
-#define LOWER(_c) (tolower(to_uchar(_c)))
-
-noreturn static void
-option_exits(int exit_code)
-{
- if (print_exit)
- printf("\nexit %d\n", exit_code);
- exit(exit_code);
-}
-
-noreturn static void
-ao_bug(char const * msg)
-{
- fprintf(stderr, zao_bug_msg, msg);
- option_exits(EX_SOFTWARE);
-}
-
-static void
-fserr_warn(char const * prog, char const * op, char const * fname)
-{
- fprintf(stderr, zfserr_fmt, prog, errno, strerror(errno),
- op, fname);
-}
-
-noreturn static void
-fserr_exit(char const * prog, char const * op, char const * fname)
-{
- fserr_warn(prog, op, fname);
- option_exits(EXIT_FAILURE);
-}
-
-/*=export_func optionParseShell
- * private:
- *
- * what: Decipher a boolean value
- * arg: + tOptions * + pOpts + program options descriptor +
- *
- * doc:
- * Emit a shell script that will parse the command line options.
-=*/
-void
-optionParseShell(tOptions * opts)
-{
- /*
- * Check for our SHELL option now.
- * IF the output file contains the "#!" magic marker,
- * it will override anything we do here.
- */
- if (HAVE_GENSHELL_OPT(SHELL))
- shell_prog = GENSHELL_OPT_ARG(SHELL);
-
- else if (! ENABLED_GENSHELL_OPT(SHELL))
- shell_prog = NULL;
-
- else if ((shell_prog = getenv("SHELL")),
- shell_prog == NULL)
-
- shell_prog = POSIX_SHELL;
-
- /*
- * Check for a specified output file
- */
- if (HAVE_GENSHELL_OPT(SCRIPT))
- open_out(GENSHELL_OPT_ARG(SCRIPT), opts->pzProgName);
-
- emit_usage(opts);
- emit_setup(opts);
-
- /*
- * There are four modes of option processing.
- */
- switch (opts->fOptSet & (OPTPROC_LONGOPT|OPTPROC_SHORTOPT)) {
- case OPTPROC_LONGOPT:
- fputs(LOOP_STR, stdout);
-
- fputs(LONG_OPT_MARK, stdout);
- fputs(INIT_LOPT_STR, stdout);
- emit_long(opts);
- printf(LOPT_ARG_FMT, opts->pzPROGNAME);
- fputs(END_OPT_SEL_STR, stdout);
-
- fputs(NOT_FOUND_STR, stdout);
- break;
-
- case 0:
- fputs(ONLY_OPTS_LOOP, stdout);
- fputs(INIT_LOPT_STR, stdout);
- emit_long(opts);
- printf(LOPT_ARG_FMT, opts->pzPROGNAME);
- break;
-
- case OPTPROC_SHORTOPT:
- fputs(LOOP_STR, stdout);
-
- fputs(FLAG_OPT_MARK, stdout);
- fputs(INIT_OPT_STR, stdout);
- emit_flag(opts);
- printf(OPT_ARG_FMT, opts->pzPROGNAME);
- fputs(END_OPT_SEL_STR, stdout);
-
- fputs(NOT_FOUND_STR, stdout);
- break;
-
- case OPTPROC_LONGOPT|OPTPROC_SHORTOPT:
- fputs(LOOP_STR, stdout);
-
- fputs(LONG_OPT_MARK, stdout);
- fputs(INIT_LOPT_STR, stdout);
- emit_long(opts);
- printf(LOPT_ARG_FMT, opts->pzPROGNAME);
- fputs(END_OPT_SEL_STR, stdout);
-
- fputs(FLAG_OPT_MARK, stdout);
- fputs(INIT_OPT_STR, stdout);
- emit_flag(opts);
- printf(OPT_ARG_FMT, opts->pzPROGNAME);
- fputs(END_OPT_SEL_STR, stdout);
-
- fputs(NOT_FOUND_STR, stdout);
- break;
- }
-
- emit_wrapup(opts);
- if ((script_trailer != NULL) && (*script_trailer != NUL))
- fputs(script_trailer, stdout);
- else if (ENABLED_GENSHELL_OPT(SHELL))
- printf(SHOW_PROG_ENV, opts->pzPROGNAME);
-
-#ifdef HAVE_FCHMOD
- fchmod(STDOUT_FILENO, 0755);
-#endif
- fclose(stdout);
-
- if (ferror(stdout))
- fserr_exit(opts->pzProgName, zwriting, zstdout_name);
-
- AGFREE(script_text);
- script_leader = NULL;
- script_trailer = NULL;
- script_text = NULL;
-}
-
-#ifdef HAVE_WORKING_FORK
-/**
- * Print the value of "var" to a file descriptor.
- * The "fdin" is the read end of a pipe to a forked process that
- * is writing usage text to it. We read that text in and re-emit
- * to standard out, formatting it so that it is assigned to a
- * shell variable.
- *
- * @param[in] prog The capitalized, c-variable-formatted program name
- * @param[in] var a similarly formatted type name
- * (LONGUSAGE, USAGE or VERSION)
- * @param[in] fdin the input end of a pipe
- */
-static void
-emit_var_text(char const * prog, char const * var, int fdin)
-{
- FILE * fp = fdopen(fdin, "r" FOPEN_BINARY_FLAG);
- int nlct = 0; /* defer newlines and skip trailing ones */
-
- printf(SET_TEXT_FMT, prog, var);
- if (fp == NULL)
- goto skip_text;
-
- for (;;) {
- int ch = fgetc(fp);
- switch (ch) {
-
- case NL:
- nlct++;
- break;
-
- case '\'':
- while (nlct > 0) {
- fputc(NL, stdout);
- nlct--;
- }
- fputs(apostrophe, stdout);
- break;
-
- case EOF:
- goto done;
-
- default:
- while (nlct > 0) {
- fputc(NL, stdout);
- nlct--;
- }
- fputc(ch, stdout);
- break;
- }
- } done:;
-
- fclose(fp);
-
- skip_text:
-
- fputs(END_SET_TEXT, stdout);
-}
-#endif
-
-/**
- * The purpose of this function is to assign "long usage", short usage
- * and version information to a shell variable. Rather than wind our
- * way through all the logic necessary to emit the text directly, we
- * fork(), have our child process emit the text the normal way and
- * capture the output in the parent process.
- *
- * @param[in] opts the program options
- * @param[in] which what to print: long usage, usage or version
- * @param[in] od for TT_VERSION, it is the version option
- */
-static void
-text_to_var(tOptions * opts, teTextTo which, tOptDesc * od)
-{
-# define _TT_(n) static char const z ## n [] = #n;
- TEXTTO_TABLE
-# undef _TT_
-# define _TT_(n) z ## n ,
- static char const * ttnames[] = { TEXTTO_TABLE };
-# undef _TT_
-
-#if ! defined(HAVE_WORKING_FORK)
- printf(SET_NO_TEXT_FMT, opts->pzPROGNAME, ttnames[which]);
-#else
- int fdpair[2];
-
- fflush(stdout);
- fflush(stderr);
-
- if (pipe(fdpair) != 0)
- fserr_exit(opts->pzProgName, "pipe", zinter_proc_pipe);
-
- switch (fork()) {
- case -1:
- fserr_exit(opts->pzProgName, "fork", opts->pzProgName);
- /* NOTREACHED */
-
- case 0:
- /*
- * Send both stderr and stdout to the pipe. No matter which
- * descriptor is used, we capture the output on the read end.
- */
- dup2(fdpair[1], STDERR_FILENO);
- dup2(fdpair[1], STDOUT_FILENO);
- close(fdpair[0]);
-
- switch (which) {
- case TT_LONGUSAGE:
- (*(opts->pUsageProc))(opts, EXIT_SUCCESS);
- /* FALLTHROUGH */ /* NOTREACHED */
-
- case TT_USAGE:
- (*(opts->pUsageProc))(opts, EXIT_FAILURE);
- /* FALLTHROUGH */ /* NOTREACHED */
-
- case TT_VERSION:
- if (od->fOptState & OPTST_ALLOC_ARG) {
- AGFREE(od->optArg.argString);
- od->fOptState &= ~OPTST_ALLOC_ARG;
- }
- od->optArg.argString = "c";
- optionPrintVersion(opts, od);
- /* FALLTHROUGH */ /* NOTREACHED */
-
- default:
- option_exits(EXIT_FAILURE);
- /* FALLTHROUGH */ /* NOTREACHED */
- }
- /* FALLTHROUGH */ /* NOTREACHED */
-
- default:
- close(fdpair[1]);
- }
-
- emit_var_text(opts->pzPROGNAME, ttnames[which], fdpair[0]);
-#endif
-}
-
-/**
- * capture usage text in shell variables.
- *
- */
-static void
-emit_usage(tOptions * opts)
-{
- char tm_nm_buf[AO_NAME_SIZE];
-
- /*
- * First, switch stdout to the output file name.
- * Then, change the program name to the one defined
- * by the definitions (rather than the current
- * executable name). Down case the upper cased name.
- */
- if (script_leader != NULL)
- fputs(script_leader, stdout);
-
- {
- char const * out_nm;
-
- {
- time_t c_tim = time(NULL);
- struct tm * ptm = localtime(&c_tim);
- strftime(tm_nm_buf, AO_NAME_SIZE, TIME_FMT, ptm );
- }
-
- if (HAVE_GENSHELL_OPT(SCRIPT))
- out_nm = GENSHELL_OPT_ARG(SCRIPT);
- else out_nm = STDOUT;
-
- if ((script_leader == NULL) && (shell_prog != NULL))
- printf(SHELL_MAGIC, shell_prog);
-
- printf(PREAMBLE_FMT, START_MARK, out_nm, tm_nm_buf);
- }
-
- printf(END_PRE_FMT, opts->pzPROGNAME);
-
- /*
- * Get a copy of the original program name in lower case and
- * fill in an approximation of the program name from it.
- */
- {
- char * pzPN = tm_nm_buf;
- char const * pz = opts->pzPROGNAME;
- char ** pp;
-
- /* Copy the program name into the time/name buffer */
- for (;;) {
- if ((*pzPN++ = (char)tolower(*pz++)) == NUL)
- break;
- }
-
- pp = VOIDP(&(opts->pzProgPath));
- *pp = tm_nm_buf;
- pp = VOIDP(&(opts->pzProgName));
- *pp = tm_nm_buf;
- }
-
- text_to_var(opts, TT_LONGUSAGE, NULL);
- text_to_var(opts, TT_USAGE, NULL);
-
- {
- tOptDesc * pOptDesc = opts->pOptDesc;
- int optionCt = opts->optCt;
-
- for (;;) {
- if (pOptDesc->pOptProc == optionPrintVersion) {
- text_to_var(opts, TT_VERSION, pOptDesc);
- break;
- }
-
- if (--optionCt <= 0)
- break;
- pOptDesc++;
- }
- }
-}
-
-static void
-emit_wrapup(tOptions * opts)
-{
- tOptDesc * od = opts->pOptDesc;
- int opt_ct = opts->presetOptCt;
- char const * fmt;
-
- printf(FINISH_LOOP, opts->pzPROGNAME);
- for (;opt_ct > 0; od++, --opt_ct) {
- /*
- * Options that are either usage documentation or are compiled out
- * are not to be processed.
- */
- if (SKIP_OPT(od) || (od->pz_NAME == NULL))
- continue;
-
- /*
- * do not presence check if there is no minimum/must-set
- */
- if ((od->optMinCt == 0) && ((od->fOptState & OPTST_MUST_SET) == 0))
- continue;
-
- if (od->optMaxCt > 1)
- fmt = CHK_MIN_COUNT;
- else fmt = CHK_ONE_REQUIRED;
-
- {
- int min = (od->optMinCt == 0) ? 1 : od->optMinCt;
- printf(fmt, opts->pzPROGNAME, od->pz_NAME, min);
- }
- }
- fputs(END_MARK, stdout);
-}
-
-static void
-emit_setup(tOptions * opts)
-{
- tOptDesc * od = opts->pOptDesc;
- int opt_ct = opts->presetOptCt;
- char const * fmt;
- char const * def_val;
-
- for (;opt_ct > 0; od++, --opt_ct) {
- char int_val_buf[32];
-
- /*
- * Options that are either usage documentation or are compiled out
- * are not to be processed.
- */
- if (SKIP_OPT(od) || (od->pz_NAME == NULL))
- continue;
-
- if (od->optMaxCt > 1)
- fmt = MULTI_DEF_FMT;
- else fmt = SGL_DEF_FMT;
-
- /*
- * IF this is an enumeration/bitmask option, then convert the value
- * to a string before printing the default value.
- */
- switch (OPTST_GET_ARGTYPE(od->fOptState)) {
- case OPARG_TYPE_ENUMERATION:
- (*(od->pOptProc))(OPTPROC_EMIT_SHELL, od );
- def_val = od->optArg.argString;
- break;
-
- /*
- * Numeric and membership bit options are just printed as a number.
- */
- case OPARG_TYPE_NUMERIC:
- snprintf(int_val_buf, sizeof(int_val_buf), "%d",
- (int)od->optArg.argInt);
- def_val = int_val_buf;
- break;
-
- case OPARG_TYPE_MEMBERSHIP:
- snprintf(int_val_buf, sizeof(int_val_buf), "%lu",
- (unsigned long)od->optArg.argIntptr);
- def_val = int_val_buf;
- break;
-
- case OPARG_TYPE_BOOLEAN:
- def_val = (od->optArg.argBool) ? TRUE_STR : FALSE_STR;
- break;
-
- default:
- if (od->optArg.argString == NULL) {
- if (fmt == SGL_DEF_FMT)
- fmt = SGL_NO_DEF_FMT;
- def_val = NULL;
- }
- else
- def_val = od->optArg.argString;
- }
-
- printf(fmt, opts->pzPROGNAME, od->pz_NAME, def_val);
- }
-}
-
-static void
-emit_action(tOptions * opts, tOptDesc * od)
-{
- if (od->pOptProc == optionPrintVersion)
- printf(ECHO_N_EXIT, opts->pzPROGNAME, VER_STR);
-
- else if (od->pOptProc == optionPagedUsage)
- printf(PAGE_USAGE_TEXT, opts->pzPROGNAME);
-
- else if (od->pOptProc == optionLoadOpt) {
- printf(LVL3_CMD, NO_LOAD_WARN);
- printf(LVL3_CMD, YES_NEED_OPT_ARG);
-
- } else if (od->pz_NAME == NULL) {
-
- if (od->pOptProc == NULL) {
- printf(LVL3_CMD, NO_SAVE_OPTS);
- printf(LVL3_CMD, OK_NEED_OPT_ARG);
- } else
- printf(ECHO_N_EXIT, opts->pzPROGNAME, LONG_USE_STR);
-
- } else {
- if (od->optMaxCt == 1)
- printf(SGL_ARG_FMT, opts->pzPROGNAME, od->pz_NAME);
- else {
- if ((unsigned)od->optMaxCt < NOLIMIT)
- printf(CHK_MAX_COUNT, opts->pzPROGNAME,
- od->pz_NAME, od->optMaxCt);
-
- printf(MULTI_ARG_FMT, opts->pzPROGNAME, od->pz_NAME);
- }
-
- /*
- * Fix up the args.
- */
- if (OPTST_GET_ARGTYPE(od->fOptState) == OPARG_TYPE_NONE) {
- printf(SET_MULTI_ARG, opts->pzPROGNAME, od->pz_NAME);
- printf(LVL3_CMD, NO_ARG_NEEDED);
-
- } else if (od->fOptState & OPTST_ARG_OPTIONAL) {
- printf(SET_MULTI_ARG, opts->pzPROGNAME, od->pz_NAME);
- printf(LVL3_CMD, OK_NEED_OPT_ARG);
-
- } else {
- printf(LVL3_CMD, YES_NEED_OPT_ARG);
- }
- }
- fputs(zOptionEndSelect, stdout);
-}
-
-static void
-emit_inaction(tOptions * opts, tOptDesc * od)
-{
- if (od->pOptProc == optionLoadOpt) {
- printf(LVL3_CMD, NO_SUPPRESS_LOAD);
-
- } else if (od->optMaxCt == 1)
- printf(NO_SGL_ARG_FMT, opts->pzPROGNAME,
- od->pz_NAME, od->pz_DisablePfx);
- else
- printf(NO_MULTI_ARG_FMT, opts->pzPROGNAME,
- od->pz_NAME, od->pz_DisablePfx);
-
- printf(LVL3_CMD, NO_ARG_NEEDED);
- fputs(zOptionEndSelect, stdout);
-}
-
-/**
- * recognize flag options. These go at the end.
- * At the end, emit code to handle options we don't recognize.
- *
- * @param[in] opts the program options
- */
-static void
-emit_flag(tOptions * opts)
-{
- tOptDesc * od = opts->pOptDesc;
- int opt_ct = opts->optCt;
-
- fputs(zOptionCase, stdout);
-
- for (;opt_ct > 0; od++, --opt_ct) {
-
- if (SKIP_OPT(od) || ! IS_GRAPHIC_CHAR(od->optValue))
- continue;
-
- printf(zOptionFlag, od->optValue);
- emit_action(opts, od);
- }
- printf(UNK_OPT_FMT, FLAG_STR, opts->pzPROGNAME);
-}
-
-/**
- * Emit the match text for a long option. The passed in \a name may be
- * either the enablement name or the disablement name.
- *
- * @param[in] name The current name to check.
- * @param[in] cod current option descriptor
- * @param[in] opts the program options
- */
-static void
-emit_match_expr(char const * name, tOptDesc * cod, tOptions * opts)
-{
- char name_bf[32];
- unsigned int min_match_ct = 2;
- unsigned int max_match_ct = strlen(name) - 1;
-
- if (max_match_ct >= sizeof(name_bf) - 1)
- goto leave;
-
- {
- tOptDesc * od = opts->pOptDesc;
- int ct = opts->optCt;
-
- for (; ct-- > 0; od++) {
- unsigned int match_ct = 0;
-
- /*
- * Omit the current option, Doc opts and compiled out opts.
- */
- if ((od == cod) || SKIP_OPT(od))
- continue;
-
- /*
- * Check each character of the name case insensitively.
- * They must not be the same. They cannot be, because it would
- * not compile correctly if they were.
- */
- while (UPPER(od->pz_Name[match_ct]) == UPPER(name[match_ct]))
- match_ct++;
-
- if (match_ct > min_match_ct)
- min_match_ct = match_ct;
-
- /*
- * Check the disablement name, too.
- */
- if (od->pz_DisableName == NULL)
- continue;
-
- match_ct = 0;
- while ( toupper(od->pz_DisableName[match_ct])
- == toupper(name[match_ct]))
- match_ct++;
- if (match_ct > min_match_ct)
- min_match_ct = match_ct;
- }
- }
-
- /*
- * Don't bother emitting partial matches if there is only one possible
- * partial match.
- */
- if (min_match_ct < max_match_ct) {
- char * pz = name_bf + min_match_ct;
- int nm_ix = min_match_ct;
-
- memcpy(name_bf, name, min_match_ct);
-
- for (;;) {
- *pz = NUL;
- printf(zOptionPartName, name_bf);
- *pz++ = name[nm_ix++];
- if (name[nm_ix] == NUL) {
- *pz = NUL;
- break;
- }
- }
- }
-
-leave:
- printf(zOptionFullName, name);
-}
-
-/**
- * Emit GNU-standard long option handling code.
- *
- * @param[in] opts the program options
- */
-static void
-emit_long(tOptions * opts)
-{
- tOptDesc * od = opts->pOptDesc;
- int ct = opts->optCt;
-
- fputs(zOptionCase, stdout);
-
- /*
- * do each option, ...
- */
- do {
- /*
- * Documentation & compiled-out options
- */
- if (SKIP_OPT(od))
- continue;
-
- emit_match_expr(od->pz_Name, od, opts);
- emit_action(opts, od);
-
- /*
- * Now, do the same thing for the disablement version of the option.
- */
- if (od->pz_DisableName != NULL) {
- emit_match_expr(od->pz_DisableName, od, opts);
- emit_inaction(opts, od);
- }
- } while (od++, --ct > 0);
-
- printf(UNK_OPT_FMT, OPTION_STR, opts->pzPROGNAME);
-}
-
-/**
- * Load the previous shell script output file. We need to preserve any
- * hand-edited additions outside of the START_MARK and END_MARKs.
- *
- * @param[in] fname the output file name
- */
-static char *
-load_old_output(char const * fname, char const * pname)
-{
- /*
- * IF we cannot stat the file,
- * THEN assume we are creating a new file.
- * Skip the loading of the old data.
- */
- FILE * fp = fopen(fname, "r" FOPEN_BINARY_FLAG);
- struct stat stbf;
- char * text;
- char * scan;
-
- if (fp == NULL)
- return NULL;
-
- /*
- * If we opened it, we should be able to stat it and it needs
- * to be a regular file
- */
- if ((fstat(fileno(fp), &stbf) != 0) || (! S_ISREG(stbf.st_mode)))
- fserr_exit(pname, "fstat", fname);
-
- scan = text = AGALOC(stbf.st_size + 1, "f data");
-
- /*
- * Read in all the data as fast as our OS will let us.
- */
- for (;;) {
- size_t inct = fread(VOIDP(scan), 1, (size_t)stbf.st_size, fp);
- if (inct == 0)
- break;
-
- stbf.st_size -= (ssize_t)inct;
-
- if (stbf.st_size == 0)
- break;
-
- scan += inct;
- }
-
- *scan = NUL;
- fclose(fp);
-
- return text;
-}
-
-/**
- * Open the specified output file. If it already exists, load its
- * contents and save the non-generated (hand edited) portions.
- * If a "start mark" is found, everything before it is preserved leader.
- * If not, the entire thing is a trailer. Assuming the start is found,
- * then everything after the end marker is the trailer. If the end
- * mark is not found, the file is actually corrupt, but we take the
- * remainder to be the trailer.
- *
- * @param[in] fname the output file name
- */
-static void
-open_out(char const * fname, char const * pname)
-{
-
- do {
- char * txt = script_text = load_old_output(fname, pname);
- char * scn;
-
- if (txt == NULL)
- break;
-
- scn = strstr(txt, START_MARK);
- if (scn == NULL) {
- script_trailer = txt;
- break;
- }
-
- *(scn++) = NUL;
- scn = strstr(scn, END_MARK);
- if (scn == NULL) {
- /*
- * The file is corrupt. Set the trailer to be everything
- * after the start mark. The user will need to fix it up.
- */
- script_trailer = txt + strlen(txt) + START_MARK_LEN + 1;
- break;
- }
-
- /*
- * Check to see if the data contains our marker.
- * If it does, then we will skip over it
- */
- script_trailer = scn + END_MARK_LEN;
- script_leader = txt;
- } while (false);
-
- if (freopen(fname, "w" FOPEN_BINARY_FLAG, stdout) != stdout)
- fserr_exit(pname, "freopen", fname);
-}
-
-/*=export_func genshelloptUsage
- * private:
- * what: The usage function for the genshellopt generated program
- *
- * arg: + tOptions * + opts + program options descriptor +
- * arg: + int + exit_cd + usage text type to produce +
- *
- * doc:
- * This function is used to create the usage strings for the option
- * processing shell script code. Two child processes are spawned
- * each emitting the usage text in either the short (error exit)
- * style or the long style. The generated program will capture this
- * and create shell script variables containing the two types of text.
-=*/
-void
-genshelloptUsage(tOptions * opts, int exit_cd)
-{
-#if ! defined(HAVE_WORKING_FORK)
- optionUsage(opts, exit_cd);
-#else
- /*
- * IF not EXIT_SUCCESS,
- * THEN emit the short form of usage.
- */
- if (exit_cd != EXIT_SUCCESS)
- optionUsage(opts, exit_cd);
- fflush(stderr);
- fflush(stdout);
- if (ferror(stdout) || ferror(stderr))
- option_exits(EXIT_FAILURE);
-
- option_usage_fp = stdout;
-
- /*
- * First, print our usage
- */
- switch (fork()) {
- case -1:
- optionUsage(opts, EXIT_FAILURE);
- /* FALLTHROUGH */ /* NOTREACHED */
-
- case 0:
- pagerState = PAGER_STATE_CHILD;
- optionUsage(opts, EXIT_SUCCESS);
- /* FALLTHROUGH */ /* NOTREACHED */
-
- default:
- {
- int sts;
- wait(&sts);
- }
- }
-
- /*
- * Generate the pzProgName, since optionProcess() normally
- * gets it from the command line
- */
- {
- char * pz;
- char ** pp = VOIDP(&(optionParseShellOptions->pzProgName));
- AGDUPSTR(pz, optionParseShellOptions->pzPROGNAME, "prog name");
- *pp = pz;
- while (*pz != NUL) {
- *pz = (char)LOWER(*pz);
- pz++;
- }
- }
-
- /*
- * Separate the makeshell usage from the client usage
- */
- fprintf(option_usage_fp, zGenshell, optionParseShellOptions->pzProgName);
- fflush(option_usage_fp);
-
- /*
- * Now, print the client usage.
- */
- switch (fork()) {
- case 0:
- pagerState = PAGER_STATE_CHILD;
- /*FALLTHROUGH*/
- case -1:
- optionUsage(optionParseShellOptions, EXIT_FAILURE);
- /* FALLTHROUGH */ /* NOTREACHED */
-
- default:
- {
- int sts;
- wait(&sts);
- }
- }
-
- fflush(stdout);
- if (ferror(stdout))
- fserr_exit(opts->pzProgName, zwriting, zstdout_name);
-
- option_exits(EXIT_SUCCESS);
-#endif
-}
-
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/makeshell.c */
diff --git a/src/libopts/nested.c b/src/libopts/nested.c
deleted file mode 100644
index e760450678..0000000000
--- a/src/libopts/nested.c
+++ /dev/null
@@ -1,905 +0,0 @@
-
-/**
- * \file nested.c
- *
- * Handle options with arguments that contain nested values.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * Automated Options Nested Values module.
- *
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-typedef struct {
- int xml_ch;
- int xml_len;
- char xml_txt[8];
-} xml_xlate_t;
-
- static xml_xlate_t const xml_xlate[] = {
- { '&', 4, "amp;" },
- { '<', 3, "lt;" },
- { '>', 3, "gt;" },
- { '"', 5, "quot;" },
- { '\'',5, "apos;" }
-};
-
-#ifndef ENOMSG
-#define ENOMSG ENOENT
-#endif
-
-/**
- * Backslashes are used for line continuations. We keep the newline
- * characters, but trim out the backslash:
- */
-static void
-remove_continuation(char * src)
-{
- char * pzD;
-
- do {
- while (*src == NL) src++;
- pzD = strchr(src, NL);
- if (pzD == NULL)
- return;
-
- /*
- * pzD has skipped at least one non-newline character and now
- * points to a newline character. It now becomes the source and
- * pzD goes to the previous character.
- */
- src = pzD--;
- if (*pzD != '\\')
- pzD++;
- } while (pzD == src);
-
- /*
- * Start shifting text.
- */
- for (;;) {
- char ch = ((*pzD++) = *(src++));
- switch (ch) {
- case NUL: return;
- case '\\':
- if (*src == NL)
- --pzD; /* rewrite on next iteration */
- }
- }
-}
-
-/**
- * Find the end of a quoted string, skipping escaped quote characters.
- */
-static char const *
-scan_q_str(char const * pzTxt)
-{
- char q = *(pzTxt++); /* remember the type of quote */
-
- for (;;) {
- char ch = *(pzTxt++);
- if (ch == NUL)
- return pzTxt-1;
-
- if (ch == q)
- return pzTxt;
-
- if (ch == '\\') {
- ch = *(pzTxt++);
- /*
- * IF the next character is NUL, drop the backslash, too.
- */
- if (ch == NUL)
- return pzTxt - 2;
-
- /*
- * IF the quote character or the escape character were escaped,
- * then skip both, as long as the string does not end.
- */
- if ((ch == q) || (ch == '\\')) {
- if (*(pzTxt++) == NUL)
- return pzTxt-1;
- }
- }
- }
-}
-
-
-/**
- * Associate a name with either a string or no value.
- *
- * @param[in,out] pp argument list to add to
- * @param[in] name the name of the "suboption"
- * @param[in] nm_len the length of the name
- * @param[in] val the string value for the suboption
- * @param[in] d_len the length of the value
- *
- * @returns the new value structure
- */
-static tOptionValue *
-add_string(void ** pp, char const * name, size_t nm_len,
- char const * val, size_t d_len)
-{
- tOptionValue * pNV;
- size_t sz = nm_len + d_len + sizeof(*pNV);
-
- pNV = AGALOC(sz, "option name/str value pair");
-
- if (val == NULL) {
- pNV->valType = OPARG_TYPE_NONE;
- pNV->pzName = pNV->v.strVal;
-
- } else {
- pNV->valType = OPARG_TYPE_STRING;
- if (d_len > 0) {
- char const * src = val;
- char * pzDst = pNV->v.strVal;
- int ct = (int)d_len;
- do {
- int ch = *(src++) & 0xFF;
- if (ch == NUL) goto data_copy_done;
- if (ch == '&')
- ch = get_special_char(&src, &ct);
- *(pzDst++) = (char)ch;
- } while (--ct > 0);
- data_copy_done:
- *pzDst = NUL;
-
- } else {
- pNV->v.strVal[0] = NUL;
- }
-
- pNV->pzName = pNV->v.strVal + d_len + 1;
- }
-
- memcpy(pNV->pzName, name, nm_len);
- pNV->pzName[ nm_len ] = NUL;
- addArgListEntry(pp, pNV);
- return pNV;
-}
-
-/**
- * Associate a name with a boolean value
- *
- * @param[in,out] pp argument list to add to
- * @param[in] name the name of the "suboption"
- * @param[in] nm_len the length of the name
- * @param[in] val the boolean value for the suboption
- * @param[in] d_len the length of the value
- *
- * @returns the new value structure
- */
-static tOptionValue *
-add_bool(void ** pp, char const * name, size_t nm_len,
- char const * val, size_t d_len)
-{
- size_t sz = nm_len + sizeof(tOptionValue) + 1;
- tOptionValue * new_val = AGALOC(sz, "bool val");
-
- /*
- * Scan over whitespace is constrained by "d_len"
- */
- while (IS_WHITESPACE_CHAR(*val) && (d_len > 0)) {
- d_len--; val++;
- }
-
- if (d_len == 0)
- new_val->v.boolVal = 0;
-
- else if (IS_DEC_DIGIT_CHAR(*val))
- new_val->v.boolVal = (unsigned)atoi(val);
-
- else new_val->v.boolVal = ! IS_FALSE_TYPE_CHAR(*val);
-
- new_val->valType = OPARG_TYPE_BOOLEAN;
- new_val->pzName = (char *)(new_val + 1);
- memcpy(new_val->pzName, name, nm_len);
- new_val->pzName[ nm_len ] = NUL;
- addArgListEntry(pp, new_val);
- return new_val;
-}
-
-/**
- * Associate a name with strtol() value, defaulting to zero.
- *
- * @param[in,out] pp argument list to add to
- * @param[in] name the name of the "suboption"
- * @param[in] nm_len the length of the name
- * @param[in] val the numeric value for the suboption
- * @param[in] d_len the length of the value
- *
- * @returns the new value structure
- */
-static tOptionValue *
-add_number(void ** pp, char const * name, size_t nm_len,
- char const * val, size_t d_len)
-{
- size_t sz = nm_len + sizeof(tOptionValue) + 1;
- tOptionValue * new_val = AGALOC(sz, "int val");
-
- /*
- * Scan over whitespace is constrained by "d_len"
- */
- while (IS_WHITESPACE_CHAR(*val) && (d_len > 0)) {
- d_len--; val++;
- }
- if (d_len == 0)
- new_val->v.longVal = 0;
- else
- new_val->v.longVal = strtol(val, 0, 0);
-
- new_val->valType = OPARG_TYPE_NUMERIC;
- new_val->pzName = (char *)(new_val + 1);
- memcpy(new_val->pzName, name, nm_len);
- new_val->pzName[ nm_len ] = NUL;
- addArgListEntry(pp, new_val);
- return new_val;
-}
-
-/**
- * Associate a name with a nested/hierarchical value.
- *
- * @param[in,out] pp argument list to add to
- * @param[in] name the name of the "suboption"
- * @param[in] nm_len the length of the name
- * @param[in] val the nested values for the suboption
- * @param[in] d_len the length of the value
- *
- * @returns the new value structure
- */
-static tOptionValue *
-add_nested(void ** pp, char const * name, size_t nm_len,
- char * val, size_t d_len)
-{
- tOptionValue * new_val;
-
- if (d_len == 0) {
- size_t sz = nm_len + sizeof(*new_val) + 1;
- new_val = AGALOC(sz, "empty nest");
- new_val->v.nestVal = NULL;
- new_val->valType = OPARG_TYPE_HIERARCHY;
- new_val->pzName = (char *)(new_val + 1);
- memcpy(new_val->pzName, name, nm_len);
- new_val->pzName[ nm_len ] = NUL;
-
- } else {
- new_val = optionLoadNested(val, name, nm_len);
- }
-
- if (new_val != NULL)
- addArgListEntry(pp, new_val);
-
- return new_val;
-}
-
-/**
- * We have an entry that starts with a name. Find the end of it, cook it
- * (if called for) and create the name/value association.
- */
-static char const *
-scan_name(char const * name, tOptionValue * res)
-{
- tOptionValue * new_val;
- char const * pzScan = name+1; /* we know first char is a name char */
- char const * pzVal;
- size_t nm_len = 1;
- size_t d_len = 0;
-
- /*
- * Scan over characters that name a value. These names may not end
- * with a colon, but they may contain colons.
- */
- pzScan = SPN_VALUE_NAME_CHARS(name + 1);
- if (pzScan[-1] == ':')
- pzScan--;
- nm_len = (size_t)(pzScan - name);
-
- pzScan = SPN_HORIZ_WHITE_CHARS(pzScan);
-
- re_switch:
-
- switch (*pzScan) {
- case '=':
- case ':':
- pzScan = SPN_HORIZ_WHITE_CHARS(pzScan + 1);
- if ((*pzScan == '=') || (*pzScan == ':'))
- goto default_char;
- goto re_switch;
-
- case NL:
- case ',':
- pzScan++;
- /* FALLTHROUGH */
-
- case NUL:
- add_string(&(res->v.nestVal), name, nm_len, NULL, (size_t)0);
- break;
-
- case '"':
- case '\'':
- pzVal = pzScan;
- pzScan = scan_q_str(pzScan);
- d_len = (size_t)(pzScan - pzVal);
- new_val = add_string(&(res->v.nestVal), name, nm_len, pzVal,
- d_len);
- if ((new_val != NULL) && (option_load_mode == OPTION_LOAD_COOKED))
- ao_string_cook(new_val->v.strVal, NULL);
- break;
-
- default:
- default_char:
- /*
- * We have found some strange text value. It ends with a newline
- * or a comma.
- */
- pzVal = pzScan;
- for (;;) {
- char ch = *(pzScan++);
- switch (ch) {
- case NUL:
- pzScan--;
- d_len = (size_t)(pzScan - pzVal);
- goto string_done;
- /* FALLTHROUGH */
-
- case NL:
- if ( (pzScan > pzVal + 2)
- && (pzScan[-2] == '\\')
- && (pzScan[ 0] != NUL))
- continue;
- /* FALLTHROUGH */
-
- case ',':
- d_len = (size_t)(pzScan - pzVal) - 1;
- string_done:
- new_val = add_string(&(res->v.nestVal), name, nm_len,
- pzVal, d_len);
- if (new_val != NULL)
- remove_continuation(new_val->v.strVal);
- goto leave_scan_name;
- }
- }
- break;
- } leave_scan_name:;
-
- return pzScan;
-}
-
-/**
- * Some xml element that does not start with a name.
- * The next character must be either '!' (introducing a comment),
- * or '?' (introducing an XML meta-marker of some sort).
- * We ignore these and indicate an error (NULL result) otherwise.
- *
- * @param[in] txt the text within an xml bracket
- * @returns the address of the character after the closing marker, or NULL.
- */
-static char const *
-unnamed_xml(char const * txt)
-{
- switch (*txt) {
- default:
- txt = NULL;
- break;
-
- case '!':
- txt = strstr(txt, "-->");
- if (txt != NULL)
- txt += 3;
- break;
-
- case '?':
- txt = strchr(txt, '>');
- if (txt != NULL)
- txt++;
- break;
- }
- return txt;
-}
-
-/**
- * Scan off the xml element name, and the rest of the header, too.
- * Set the value type to NONE if it ends with "/>".
- *
- * @param[in] name the first name character (alphabetic)
- * @param[out] nm_len the length of the name
- * @param[out] val set valType field to STRING or NONE.
- *
- * @returns the scan resumption point, or NULL on error
- */
-static char const *
-scan_xml_name(char const * name, size_t * nm_len, tOptionValue * val)
-{
- char const * scan = SPN_VALUE_NAME_CHARS(name + 1);
- *nm_len = (size_t)(scan - name);
- if (*nm_len > 64)
- return NULL;
- val->valType = OPARG_TYPE_STRING;
-
- if (IS_WHITESPACE_CHAR(*scan)) {
- /*
- * There are attributes following the name. Parse 'em.
- */
- scan = SPN_WHITESPACE_CHARS(scan);
- scan = parse_attrs(NULL, scan, &option_load_mode, val);
- if (scan == NULL)
- return NULL; /* oops */
- }
-
- if (! IS_END_XML_TOKEN_CHAR(*scan))
- return NULL; /* oops */
-
- if (*scan == '/') {
- /*
- * Single element XML entries get inserted as an empty string.
- */
- if (*++scan != '>')
- return NULL;
- val->valType = OPARG_TYPE_NONE;
- }
- return scan+1;
-}
-
-/**
- * We've found a closing '>' without a preceding '/', thus we must search
- * the text for '<name/>' where "name" is the name of the XML element.
- *
- * @param[in] name the start of the name in the element header
- * @param[in] nm_len the length of that name
- * @param[out] len the length of the value (string between header and
- * the trailer/tail.
- * @returns the character after the trailer, or NULL if not found.
- */
-static char const *
-find_end_xml(char const * src, size_t nm_len, char const * val, size_t * len)
-{
- char z[72] = "</";
- char * dst = z + 2;
-
- do {
- *(dst++) = *(src++);
- } while (--nm_len > 0); /* nm_len is known to be 64 or less */
- *(dst++) = '>';
- *dst = NUL;
-
- {
- char const * res = strstr(val, z);
-
- if (res != NULL) {
- char const * end = (option_load_mode != OPTION_LOAD_KEEP)
- ? SPN_WHITESPACE_BACK(val, res)
- : res;
- *len = (size_t)(end - val); /* includes trailing white space */
- res = SPN_WHITESPACE_CHARS(res + (dst - z));
- }
- return res;
- }
-}
-
-/**
- * We've found a '<' character. We ignore this if it is a comment or a
- * directive. If it is something else, then whatever it is we are looking
- * at is bogus. Returning NULL stops processing.
- *
- * @param[in] xml_name the name of an xml bracket (usually)
- * @param[in,out] res_val the option data derived from the XML element
- *
- * @returns the place to resume scanning input
- */
-static char const *
-scan_xml(char const * xml_name, tOptionValue * res_val)
-{
- size_t nm_len, v_len;
- char const * scan;
- char const * val_str;
- tOptionValue valu;
- tOptionLoadMode save_mode = option_load_mode;
-
- if (! IS_VAR_FIRST_CHAR(*++xml_name))
- return unnamed_xml(xml_name);
-
- /*
- * "scan_xml_name()" may change "option_load_mode".
- */
- val_str = scan_xml_name(xml_name, &nm_len, &valu);
- if (val_str == NULL)
- goto bail_scan_xml;
-
- if (valu.valType == OPARG_TYPE_NONE)
- scan = val_str;
- else {
- if (option_load_mode != OPTION_LOAD_KEEP)
- val_str = SPN_WHITESPACE_CHARS(val_str);
- scan = find_end_xml(xml_name, nm_len, val_str, &v_len);
- if (scan == NULL)
- goto bail_scan_xml;
- }
-
- /*
- * "scan" now points to where the scan is to resume after returning.
- * It either points after "/>" at the end of the XML element header,
- * or it points after the "</name>" tail based on the name in the header.
- */
-
- switch (valu.valType) {
- case OPARG_TYPE_NONE:
- add_string(&(res_val->v.nestVal), xml_name, nm_len, NULL, 0);
- break;
-
- case OPARG_TYPE_STRING:
- {
- tOptionValue * new_val = add_string(
- &(res_val->v.nestVal), xml_name, nm_len, val_str, v_len);
-
- if (option_load_mode != OPTION_LOAD_KEEP)
- munge_str(new_val->v.strVal, option_load_mode);
-
- break;
- }
-
- case OPARG_TYPE_BOOLEAN:
- add_bool(&(res_val->v.nestVal), xml_name, nm_len, val_str, v_len);
- break;
-
- case OPARG_TYPE_NUMERIC:
- add_number(&(res_val->v.nestVal), xml_name, nm_len, val_str, v_len);
- break;
-
- case OPARG_TYPE_HIERARCHY:
- {
- char * pz = AGALOC(v_len+1, "h scan");
- memcpy(pz, val_str, v_len);
- pz[v_len] = NUL;
- add_nested(&(res_val->v.nestVal), xml_name, nm_len, pz, v_len);
- AGFREE(pz);
- break;
- }
-
- case OPARG_TYPE_ENUMERATION:
- case OPARG_TYPE_MEMBERSHIP:
- default:
- break;
- }
-
- option_load_mode = save_mode;
- return scan;
-
-bail_scan_xml:
- option_load_mode = save_mode;
- return NULL;
-}
-
-
-/**
- * Deallocate a list of option arguments. This must have been gotten from
- * a hierarchical option argument, not a stacked list of strings. It is
- * an internal call, so it is not validated. The caller is responsible for
- * knowing what they are doing.
- */
-static void
-unload_arg_list(tArgList * arg_list)
-{
- int ct = arg_list->useCt;
- char const ** pnew_val = arg_list->apzArgs;
-
- while (ct-- > 0) {
- tOptionValue * new_val = (tOptionValue *)VOIDP(*(pnew_val++));
- if (new_val->valType == OPARG_TYPE_HIERARCHY)
- unload_arg_list(new_val->v.nestVal);
- AGFREE(new_val);
- }
-
- AGFREE(arg_list);
-}
-
-/*=export_func optionUnloadNested
- *
- * what: Deallocate the memory for a nested value
- * arg: + tOptionValue const * + pOptVal + the hierarchical value +
- *
- * doc:
- * A nested value needs to be deallocated. The pointer passed in should
- * have been gotten from a call to @code{configFileLoad()} (See
- * @pxref{libopts-configFileLoad}).
-=*/
-void
-optionUnloadNested(tOptionValue const * opt_val)
-{
- if (opt_val == NULL) return;
- if (opt_val->valType != OPARG_TYPE_HIERARCHY) {
- errno = EINVAL;
- return;
- }
-
- unload_arg_list(opt_val->v.nestVal);
-
- AGFREE(opt_val);
-}
-
-/**
- * This is a _stable_ sort. The entries are sorted alphabetically,
- * but within entries of the same name the ordering is unchanged.
- * Typically, we also hope the input is sorted.
- */
-static void
-sort_list(tArgList * arg_list)
-{
- int ix;
- int lm = arg_list->useCt;
-
- /*
- * This loop iterates "useCt" - 1 times.
- */
- for (ix = 0; ++ix < lm;) {
- int iy = ix-1;
- tOptionValue * new_v = C(tOptionValue *, arg_list->apzArgs[ix]);
- tOptionValue * old_v = C(tOptionValue *, arg_list->apzArgs[iy]);
-
- /*
- * For as long as the new entry precedes the "old" entry,
- * move the old pointer. Stop before trying to extract the
- * "-1" entry.
- */
- while (strcmp(old_v->pzName, new_v->pzName) > 0) {
- arg_list->apzArgs[iy+1] = VOIDP(old_v);
- old_v = (tOptionValue *)VOIDP(arg_list->apzArgs[--iy]);
- if (iy < 0)
- break;
- }
-
- /*
- * Always store the pointer. Sometimes it is redundant,
- * but the redundancy is cheaper than a test and branch sequence.
- */
- arg_list->apzArgs[iy+1] = VOIDP(new_v);
- }
-}
-
-/*=
- * private:
- *
- * what: parse a hierarchical option argument
- * arg: + char const * + pzTxt + the text to scan +
- * arg: + char const * + pzName + the name for the text +
- * arg: + size_t + nm_len + the length of "name" +
- *
- * ret_type: tOptionValue *
- * ret_desc: An allocated, compound value structure
- *
- * doc:
- * A block of text represents a series of values. It may be an
- * entire configuration file, or it may be an argument to an
- * option that takes a hierarchical value.
- *
- * If NULL is returned, errno will be set:
- * @itemize @bullet
- * @item
- * @code{EINVAL} the input text was NULL.
- * @item
- * @code{ENOMEM} the storage structures could not be allocated
- * @item
- * @code{ENOMSG} no configuration values were found
- * @end itemize
-=*/
-static tOptionValue *
-optionLoadNested(char const * text, char const * name, size_t nm_len)
-{
- tOptionValue * res_val;
-
- /*
- * Make sure we have some data and we have space to put what we find.
- */
- if (text == NULL) {
- errno = EINVAL;
- return NULL;
- }
- text = SPN_WHITESPACE_CHARS(text);
- if (*text == NUL) {
- errno = ENOMSG;
- return NULL;
- }
- res_val = AGALOC(sizeof(*res_val) + nm_len + 1, "nest args");
- res_val->valType = OPARG_TYPE_HIERARCHY;
- res_val->pzName = (char *)(res_val + 1);
- memcpy(res_val->pzName, name, nm_len);
- res_val->pzName[nm_len] = NUL;
-
- {
- tArgList * arg_list = AGALOC(sizeof(*arg_list), "nest arg l");
-
- res_val->v.nestVal = arg_list;
- arg_list->useCt = 0;
- arg_list->allocCt = MIN_ARG_ALLOC_CT;
- }
-
- /*
- * Scan until we hit a NUL.
- */
- do {
- text = SPN_WHITESPACE_CHARS(text);
- if (IS_VAR_FIRST_CHAR(*text))
- text = scan_name(text, res_val);
-
- else switch (*text) {
- case NUL:
- goto scan_done;
-
- case '<':
- text = scan_xml(text, res_val);
- if (text == NULL)
- goto woops;
- if (*text == ',')
- text++;
- break;
-
- case '#':
- text = strchr(text, NL);
- break;
-
- default:
- goto woops;
- }
- } while (text != NULL); scan_done:;
-
- {
- tArgList * al = res_val->v.nestVal;
- if (al->useCt == 0) {
- errno = ENOMSG;
- goto woops;
- }
- if (al->useCt > 1)
- sort_list(al);
- }
-
- return res_val;
-
- woops:
- AGFREE(res_val->v.nestVal);
- AGFREE(res_val);
- return NULL;
-}
-
-/*=export_func optionNestedVal
- * private:
- *
- * what: parse a hierarchical option argument
- * arg: + tOptions * + opts + program options descriptor +
- * arg: + tOptDesc * + od + the descriptor for this arg +
- *
- * doc:
- * Nested value was found on the command line
-=*/
-void
-optionNestedVal(tOptions * opts, tOptDesc * od)
-{
- if (opts < OPTPROC_EMIT_LIMIT)
- return;
-
- if (od->fOptState & OPTST_RESET) {
- tArgList * arg_list = od->optCookie;
- int ct;
- char const ** av;
-
- if (arg_list == NULL)
- return;
- ct = arg_list->useCt;
- av = arg_list->apzArgs;
-
- while (--ct >= 0) {
- void * p = VOIDP(*(av++));
- optionUnloadNested((tOptionValue const *)p);
- }
-
- AGFREE(od->optCookie);
-
- } else {
- tOptionValue * opt_val = optionLoadNested(
- od->optArg.argString, od->pz_Name, strlen(od->pz_Name));
-
- if (opt_val != NULL)
- addArgListEntry(&(od->optCookie), VOIDP(opt_val));
- }
-}
-
-/**
- * get_special_char
- */
-static int
-get_special_char(char const ** ppz, int * ct)
-{
- char const * pz = *ppz;
-
- if (*ct < 3)
- return '&';
-
- if (*pz == '#') {
- int base = 10;
- int retch;
-
- pz++;
- if (*pz == 'x') {
- base = 16;
- pz++;
- }
- retch = (int)strtoul(pz, (char **)&pz, base);
- if (*pz != ';')
- return '&';
- base = (int)(++pz - *ppz);
- if (base > *ct)
- return '&';
-
- *ct -= base;
- *ppz = pz;
- return retch;
- }
-
- {
- int ctr = sizeof(xml_xlate) / sizeof(xml_xlate[0]);
- xml_xlate_t const * xlatp = xml_xlate;
-
- for (;;) {
- if ( (*ct >= xlatp->xml_len)
- && (strncmp(pz, xlatp->xml_txt, (size_t)xlatp->xml_len) == 0)) {
- *ppz += xlatp->xml_len;
- *ct -= xlatp->xml_len;
- return xlatp->xml_ch;
- }
-
- if (--ctr <= 0)
- break;
- xlatp++;
- }
- }
- return '&';
-}
-
-/**
- * emit_special_char
- */
-static void
-emit_special_char(FILE * fp, int ch)
-{
- int ctr = sizeof(xml_xlate) / sizeof(xml_xlate[0]);
- xml_xlate_t const * xlatp = xml_xlate;
-
- putc('&', fp);
- for (;;) {
- if (ch == xlatp->xml_ch) {
- fputs(xlatp->xml_txt, fp);
- return;
- }
- if (--ctr <= 0)
- break;
- xlatp++;
- }
- fprintf(fp, XML_HEX_BYTE_FMT, (ch & 0xFF));
-}
-
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/nested.c */
diff --git a/src/libopts/numeric.c b/src/libopts/numeric.c
deleted file mode 100644
index bbb43ccdcd..0000000000
--- a/src/libopts/numeric.c
+++ /dev/null
@@ -1,180 +0,0 @@
-
-/**
- * \file numeric.c
- *
- * Handle options with numeric (integer) arguments.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-/*=export_func optionShowRange
- * private:
- *
- * what: Show info about range constraints
- * arg: + tOptions * + pOpts + program options descriptor +
- * arg: + tOptDesc * + pOptDesc + the descriptor for this arg +
- * arg: + void * + rng_table + the value range tables +
- * arg: + int + rng_count + the number of entries +
- *
- * doc:
- * Show information about a numeric option with range constraints.
-=*/
-void
-optionShowRange(tOptions * pOpts, tOptDesc * pOD, void * rng_table, int rng_ct)
-{
- const struct {long const rmin, rmax;} * rng = rng_table;
-
- char const * pz_indent = zTabHyp + tab_skip_ct;
-
- /*
- * The range is shown only for full usage requests and an error
- * in this particular option.
- */
- if (pOpts != OPTPROC_EMIT_USAGE) {
- if (pOpts <= OPTPROC_EMIT_LIMIT)
- return;
- pz_indent = ONE_TAB_STR;
-
- fprintf(option_usage_fp, zRangeErr, pOpts->pzProgName,
- pOD->pz_Name, pOD->optArg.argInt);
- pz_indent = "";
- }
-
- if (pOD->fOptState & OPTST_SCALED_NUM)
- fprintf(option_usage_fp, zRangeScaled, pz_indent);
-
- fprintf(option_usage_fp, (rng_ct > 1) ? zRangeLie : zRangeOnly, pz_indent);
- pz_indent = (pOpts != OPTPROC_EMIT_USAGE)
- ? ONE_TAB_STR
- : (zTabSpace + tab_skip_ct);
-
- for (;;) {
- if (rng->rmax == LONG_MIN)
- fprintf(option_usage_fp, zRangeExact, pz_indent, rng->rmin);
- else if (rng->rmin == LONG_MIN)
- fprintf(option_usage_fp, zRangeUpto, pz_indent, rng->rmax);
- else if (rng->rmax == LONG_MAX)
- fprintf(option_usage_fp, zRangeAbove, pz_indent, rng->rmin);
- else
- fprintf(option_usage_fp, zRange, pz_indent, rng->rmin,
- rng->rmax);
-
- if (--rng_ct <= 0) {
- fputc(NL, option_usage_fp);
- break;
- }
- fputs(zRangeOr, option_usage_fp);
- rng++;
- }
-
- if (pOpts > OPTPROC_EMIT_LIMIT)
- pOpts->pUsageProc(pOpts, EXIT_FAILURE);
-}
-
-/*=export_func optionNumericVal
- * private:
- *
- * what: process an option with a numeric value.
- * arg: + tOptions * + opts + program options descriptor +
- * arg: + tOptDesc * + od + the descriptor for this arg +
- *
- * doc:
- * Decipher a numeric value.
-=*/
-void
-optionNumericVal(tOptions * opts, tOptDesc * od)
-{
- char * pz;
- long val;
-
- /*
- * Guard against all the different ways this procedure might get invoked
- * when there is no string argument provided.
- */
- if (INQUERY_CALL(opts, od) || (od->optArg.argString == NULL))
- return;
-
- /*
- * Numeric options may have a range associated with it.
- * If it does, the usage procedure requests that it be
- * emitted by passing a NULL od pointer. Also bail out
- * if there is no option argument or if we are being reset.
- */
- if ( (od == NULL)
- || (od->optArg.argString == NULL)
- || ((od->fOptState & OPTST_RESET) != 0)
- || (opts <= OPTPROC_EMIT_LIMIT))
- return;
-
- errno = 0;
- val = strtol(od->optArg.argString, &pz, 0);
- if ((pz == od->optArg.argString) || (errno != 0))
- goto bad_number;
-
- if ((od->fOptState & OPTST_SCALED_NUM) != 0)
- switch (*(pz++)) {
- case NUL: pz--; break;
- case 't': val *= 1000; /* FALLTHROUGH */
- case 'g': val *= 1000; /* FALLTHROUGH */
- case 'm': val *= 1000; /* FALLTHROUGH */
- case 'k': val *= 1000; break;
-
- case 'T': val *= 1024; /* FALLTHROUGH */
- case 'G': val *= 1024; /* FALLTHROUGH */
- case 'M': val *= 1024; /* FALLTHROUGH */
- case 'K': val *= 1024; break;
-
- default: goto bad_number;
- }
-
- if (*pz != NUL)
- goto bad_number;
-
- if (od->fOptState & OPTST_ALLOC_ARG) {
- AGFREE(od->optArg.argString);
- od->fOptState &= ~OPTST_ALLOC_ARG;
- }
-
- od->optArg.argInt = val;
- return;
-
- bad_number:
-
- fprintf( stderr, zNotNumber, opts->pzProgName, od->optArg.argString );
- if ((opts->fOptSet & OPTPROC_ERRSTOP) != 0)
- (*(opts->pUsageProc))(opts, EXIT_FAILURE);
-
- errno = EINVAL;
- od->optArg.argInt = ~0;
-}
-
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/numeric.c */
diff --git a/src/libopts/option-value-type.c b/src/libopts/option-value-type.c
deleted file mode 100644
index 2bc8642809..0000000000
--- a/src/libopts/option-value-type.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/* -*- buffer-read-only: t -*- vi: set ro:
- *
- * DO NOT EDIT THIS FILE (stdin.c)
- *
- * It has been AutoGen-ed
- * From the definitions stdin
- * and the template file str2enum
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name ``Bruce Korb'' nor the name of any other
- * contributor may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * str2enum IS PROVIDED BY Bruce Korb ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Bruce Korb OR ANY OTHER CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "option-value-type.h"
-/* ANSI-C code produced by gperf version 3.1 */
-/* Command-line: gperf option-value-type.gp */
-/* Computed positions: -k'1' */
-
-
-
-# if 0 /* gperf build options: */
-// %struct-type
-// %language=ANSI-C
-// %includes
-// %global-table
-// %omit-struct-type
-// %readonly-tables
-// %compare-strncmp
-//
-// %define slot-name vtp_name
-// %define hash-function-name option_value_type_hash
-// %define lookup-function-name find_option_value_type_name
-// %define word-array-name option_value_type_table
-// %define initializer-suffix ,VTP_COUNT_CMD
-//
-# endif
-
-#include "option-value-type.h"
-typedef struct {
- char const * vtp_name;
- option_value_type_enum_t vtp_id;
-} option_value_type_map_t;
-#include <string.h>
-
-/* maximum key range = 15, duplicates = 0 */
-
-static unsigned int
-option_value_type_hash (register const char *str, register size_t len)
-{
- static const unsigned char asso_values[] =
- {
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 0, 18,
- 18, 18, 18, 18, 0, 10, 18, 5, 18, 18,
- 5, 18, 18, 18, 18, 0, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18
- };
- return len + asso_values[(unsigned char)str[0]];
-}
-
-static const option_value_type_map_t option_value_type_table[] =
- {
- {"",VTP_COUNT_CMD}, {"",VTP_COUNT_CMD},
- {"",VTP_COUNT_CMD},
- {"set", VTP_CMD_SET},
- {"bool", VTP_CMD_BOOL},
- {"",VTP_COUNT_CMD},
- {"string", VTP_CMD_STRING},
- {"boolean", VTP_CMD_BOOLEAN},
- {"",VTP_COUNT_CMD},
- {"hierarchy", VTP_CMD_HIERARCHY},
- {"",VTP_COUNT_CMD},
- {"nested", VTP_CMD_NESTED},
- {"keyword", VTP_CMD_KEYWORD},
- {"",VTP_COUNT_CMD},
- {"set-membership", VTP_CMD_SET_MEMBERSHIP},
- {"",VTP_COUNT_CMD}, {"",VTP_COUNT_CMD},
- {"integer", VTP_CMD_INTEGER}
- };
-
-static inline const option_value_type_map_t *
-find_option_value_type_name (register const char *str, register size_t len)
-{
- if (len <= 14 && len >= 3)
- {
- register unsigned int key = (int)option_value_type_hash (str, len);
-
- if (key <= 17)
- {
- register const char *s = option_value_type_table[key].vtp_name;
-
- if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
- return &option_value_type_table[key];
- }
- }
- return 0;
-}
-
-/**
- * Convert a command (keyword) to a option_value_type_enum_t enumeration value.
- *
- * @param[in] str a string that should start with a known key word.
- * @param[in] len the provided length of the keyword at \a str.
- * @returns the enumeration value.
- * If not found, that value is VTP_INVALID_CMD.
- */
-option_value_type_enum_t
-find_option_value_type_cmd(char const * str, size_t len)
-{
- option_value_type_map_t const * map;
-
- map = find_option_value_type_name(str, (unsigned int)len);
- return (map == NULL) ? VTP_INVALID_CMD : map->vtp_id;
-}
-
-/* end of option-value-type.c */
diff --git a/src/libopts/option-value-type.h b/src/libopts/option-value-type.h
deleted file mode 100644
index cf6dcaadb8..0000000000
--- a/src/libopts/option-value-type.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- buffer-read-only: t -*- vi: set ro:
- *
- * DO NOT EDIT THIS FILE (stdin.h)
- *
- * It has been AutoGen-ed
- * From the definitions stdin
- * and the template file str2enum
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name ``Bruce Korb'' nor the name of any other
- * contributor may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * str2enum IS PROVIDED BY Bruce Korb ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Bruce Korb OR ANY OTHER CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Command/Keyword Dispatcher
- */
-#ifndef STR2ENUM_OPTION_VALUE_TYPE_H_GUARD
-#define STR2ENUM_OPTION_VALUE_TYPE_H_GUARD 1
-#include <sys/types.h>
-#ifndef MISSING_INTTYPES_H
-# include <inttypes.h>
-#endif
-
-typedef enum {
- VTP_INVALID_CMD = 0,
- VTP_CMD_STRING = 1,
- VTP_CMD_INTEGER = 2,
- VTP_CMD_BOOL = 3,
- VTP_CMD_BOOLEAN = 4,
- VTP_CMD_KEYWORD = 5,
- VTP_CMD_SET = 6,
- VTP_CMD_SET_MEMBERSHIP = 7,
- VTP_CMD_NESTED = 8,
- VTP_CMD_HIERARCHY = 9,
- VTP_COUNT_CMD
-} option_value_type_enum_t;
-
-extern option_value_type_enum_t
-find_option_value_type_cmd(char const * str, size_t len);
-
-#endif /* STR2ENUM_OPTION_VALUE_TYPE_H_GUARD */
-/* end of option-value-type.h */
diff --git a/src/libopts/option-xat-attribute.c b/src/libopts/option-xat-attribute.c
deleted file mode 100644
index a34ab1b5b2..0000000000
--- a/src/libopts/option-xat-attribute.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/* -*- buffer-read-only: t -*- vi: set ro:
- *
- * DO NOT EDIT THIS FILE (stdin.c)
- *
- * It has been AutoGen-ed
- * From the definitions stdin
- * and the template file str2enum
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name ``Bruce Korb'' nor the name of any other
- * contributor may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * str2enum IS PROVIDED BY Bruce Korb ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Bruce Korb OR ANY OTHER CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "option-xat-attribute.h"
-/* ANSI-C code produced by gperf version 3.1 */
-/* Command-line: gperf option-xat-attribute.gp */
-/* Computed positions: -k'1' */
-
-
-
-# if 0 /* gperf build options: */
-// %struct-type
-// %language=ANSI-C
-// %includes
-// %global-table
-// %omit-struct-type
-// %readonly-tables
-// %compare-strncmp
-//
-// %define slot-name xat_name
-// %define hash-function-name option_xat_attribute_hash
-// %define lookup-function-name find_option_xat_attribute_name
-// %define word-array-name option_xat_attribute_table
-// %define initializer-suffix ,XAT_COUNT_CMD
-//
-# endif
-
-#include "option-xat-attribute.h"
-typedef struct {
- char const * xat_name;
- option_xat_attribute_enum_t xat_id;
-} option_xat_attribute_map_t;
-#include <string.h>
-
-/* maximum key range = 6, duplicates = 0 */
-
-static unsigned int
-option_xat_attribute_hash (register const char *str, register size_t len)
-{
- static const unsigned char asso_values[] =
- {
- 10,10,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,10, 0,
- 10,10,10,10,10,10,10, 5,10, 0,
- 10,10,10,10,10,10, 0, 0,10, 0,
- 10,10,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10
- };
- return len + asso_values[(unsigned char)str[0]];
-}
-
-static const option_xat_attribute_map_t option_xat_attribute_table[] =
- {
- {"",XAT_COUNT_CMD}, {"",XAT_COUNT_CMD},
- {"",XAT_COUNT_CMD}, {"",XAT_COUNT_CMD},
- {"type", XAT_CMD_TYPE},
- {"words", XAT_CMD_WORDS},
- {"cooked", XAT_CMD_COOKED},
- {"members", XAT_CMD_MEMBERS},
- {"uncooked", XAT_CMD_UNCOOKED},
- {"keep", XAT_CMD_KEEP}
- };
-
-static inline const option_xat_attribute_map_t *
-find_option_xat_attribute_name (register const char *str, register size_t len)
-{
- if (len <= 8 && len >= 4)
- {
- register unsigned int key = (int)option_xat_attribute_hash (str, len);
-
- if (key <= 9)
- {
- register const char *s = option_xat_attribute_table[key].xat_name;
-
- if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
- return &option_xat_attribute_table[key];
- }
- }
- return 0;
-}
-
-/**
- * Convert a command (keyword) to a option_xat_attribute_enum_t enumeration value.
- *
- * @param[in] str a string that should start with a known key word.
- * @param[in] len the provided length of the keyword at \a str.
- * @returns the enumeration value.
- * If not found, that value is XAT_INVALID_CMD.
- */
-option_xat_attribute_enum_t
-find_option_xat_attribute_cmd(char const * str, size_t len)
-{
- option_xat_attribute_map_t const * map;
-
- map = find_option_xat_attribute_name(str, (unsigned int)len);
- return (map == NULL) ? XAT_INVALID_CMD : map->xat_id;
-}
-
-/* end of option-xat-attribute.c */
diff --git a/src/libopts/option-xat-attribute.h b/src/libopts/option-xat-attribute.h
deleted file mode 100644
index dde1617a44..0000000000
--- a/src/libopts/option-xat-attribute.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* -*- buffer-read-only: t -*- vi: set ro:
- *
- * DO NOT EDIT THIS FILE (stdin.h)
- *
- * It has been AutoGen-ed
- * From the definitions stdin
- * and the template file str2enum
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name ``Bruce Korb'' nor the name of any other
- * contributor may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * str2enum IS PROVIDED BY Bruce Korb ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Bruce Korb OR ANY OTHER CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Command/Keyword Dispatcher
- */
-#ifndef STR2ENUM_OPTION_XAT_ATTRIBUTE_H_GUARD
-#define STR2ENUM_OPTION_XAT_ATTRIBUTE_H_GUARD 1
-#include <sys/types.h>
-#ifndef MISSING_INTTYPES_H
-# include <inttypes.h>
-#endif
-
-typedef enum {
- XAT_INVALID_CMD = 0,
- XAT_CMD_TYPE = 1,
- XAT_CMD_WORDS = 2,
- XAT_CMD_MEMBERS = 3,
- XAT_CMD_COOKED = 4,
- XAT_CMD_UNCOOKED = 5,
- XAT_CMD_KEEP = 6,
- XAT_COUNT_CMD
-} option_xat_attribute_enum_t;
-
-extern option_xat_attribute_enum_t
-find_option_xat_attribute_cmd(char const * str, size_t len);
-
-#endif /* STR2ENUM_OPTION_XAT_ATTRIBUTE_H_GUARD */
-/* end of option-xat-attribute.h */
diff --git a/src/libopts/parse-duration.c b/src/libopts/parse-duration.c
deleted file mode 100644
index 0f4a05634b..0000000000
--- a/src/libopts/parse-duration.c
+++ /dev/null
@@ -1,604 +0,0 @@
-/* Parse a time duration and return a seconds count
- Copyright (C) 2008-2018 Free Software Foundation, Inc.
- Written by Bruce Korb <bkorb@gnu.org>, 2008.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-/* Specification. */
-#include "parse-duration.h"
-
-#include <ctype.h>
-#include <errno.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "intprops.h"
-
-#ifndef NUL
-#define NUL '\0'
-#endif
-
-#define cch_t char const
-
-typedef enum {
- NOTHING_IS_DONE,
- YEAR_IS_DONE,
- MONTH_IS_DONE,
- WEEK_IS_DONE,
- DAY_IS_DONE,
- HOUR_IS_DONE,
- MINUTE_IS_DONE,
- SECOND_IS_DONE
-} whats_done_t;
-
-#define SEC_PER_MIN 60
-#define SEC_PER_HR (SEC_PER_MIN * 60)
-#define SEC_PER_DAY (SEC_PER_HR * 24)
-#define SEC_PER_WEEK (SEC_PER_DAY * 7)
-#define SEC_PER_MONTH (SEC_PER_DAY * 30)
-#define SEC_PER_YEAR (SEC_PER_DAY * 365)
-
-#undef MAX_DURATION
-#define MAX_DURATION TYPE_MAXIMUM(time_t)
-
-/* Wrapper around strtoul that does not require a cast. */
-static unsigned long
-str_const_to_ul (cch_t * str, cch_t ** ppz, int base)
-{
- return strtoul (str, (char **)ppz, base);
-}
-
-/* Wrapper around strtol that does not require a cast. */
-static long
-str_const_to_l (cch_t * str, cch_t ** ppz, int base)
-{
- return strtol (str, (char **)ppz, base);
-}
-
-/* Returns BASE + VAL * SCALE, interpreting BASE = BAD_TIME
- with errno set as an error situation, and returning BAD_TIME
- with errno set in an error situation. */
-static time_t
-scale_n_add (time_t base, time_t val, int scale)
-{
- if (base == BAD_TIME)
- {
- if (errno == 0)
- errno = EINVAL;
- return BAD_TIME;
- }
-
- if (val > MAX_DURATION / scale)
- {
- errno = ERANGE;
- return BAD_TIME;
- }
-
- val *= scale;
- if (base > MAX_DURATION - val)
- {
- errno = ERANGE;
- return BAD_TIME;
- }
-
- return base + val;
-}
-
-/* After a number HH has been parsed, parse subsequent :MM or :MM:SS. */
-static time_t
-parse_hr_min_sec (time_t start, cch_t * pz)
-{
- int lpct = 0;
-
- errno = 0;
-
- /* For as long as our scanner pointer points to a colon *AND*
- we've not looped before, then keep looping. (two iterations max) */
- while ((*pz == ':') && (lpct++ <= 1))
- {
- unsigned long v = str_const_to_ul (pz+1, &pz, 10);
-
- if (errno != 0)
- return BAD_TIME;
-
- start = scale_n_add (v, start, 60);
-
- if (errno != 0)
- return BAD_TIME;
- }
-
- /* allow for trailing spaces */
- while (isspace ((unsigned char)*pz))
- pz++;
- if (*pz != NUL)
- {
- errno = EINVAL;
- return BAD_TIME;
- }
-
- return start;
-}
-
-/* Parses a value and returns BASE + value * SCALE, interpreting
- BASE = BAD_TIME with errno set as an error situation, and returning
- BAD_TIME with errno set in an error situation. */
-static time_t
-parse_scaled_value (time_t base, cch_t ** ppz, cch_t * endp, int scale)
-{
- cch_t * pz = *ppz;
- time_t val;
-
- if (base == BAD_TIME)
- return base;
-
- errno = 0;
- val = str_const_to_ul (pz, &pz, 10);
- if (errno != 0)
- return BAD_TIME;
- while (isspace ((unsigned char)*pz))
- pz++;
- if (pz != endp)
- {
- errno = EINVAL;
- return BAD_TIME;
- }
-
- *ppz = pz;
- return scale_n_add (base, val, scale);
-}
-
-/* Parses the syntax YEAR-MONTH-DAY.
- PS points into the string, after "YEAR", before "-MONTH-DAY". */
-static time_t
-parse_year_month_day (cch_t * pz, cch_t * ps)
-{
- time_t res = 0;
-
- res = parse_scaled_value (0, &pz, ps, SEC_PER_YEAR);
-
- pz++; /* over the first '-' */
- ps = strchr (pz, '-');
- if (ps == NULL)
- {
- errno = EINVAL;
- return BAD_TIME;
- }
- res = parse_scaled_value (res, &pz, ps, SEC_PER_MONTH);
-
- pz++; /* over the second '-' */
- ps = pz + strlen (pz);
- return parse_scaled_value (res, &pz, ps, SEC_PER_DAY);
-}
-
-/* Parses the syntax YYYYMMDD. */
-static time_t
-parse_yearmonthday (cch_t * in_pz)
-{
- time_t res = 0;
- char buf[8];
- cch_t * pz;
-
- if (strlen (in_pz) != 8)
- {
- errno = EINVAL;
- return BAD_TIME;
- }
-
- memcpy (buf, in_pz, 4);
- buf[4] = NUL;
- pz = buf;
- res = parse_scaled_value (0, &pz, buf + 4, SEC_PER_YEAR);
-
- memcpy (buf, in_pz + 4, 2);
- buf[2] = NUL;
- pz = buf;
- res = parse_scaled_value (res, &pz, buf + 2, SEC_PER_MONTH);
-
- memcpy (buf, in_pz + 6, 2);
- buf[2] = NUL;
- pz = buf;
- return parse_scaled_value (res, &pz, buf + 2, SEC_PER_DAY);
-}
-
-/* Parses the syntax yy Y mm M ww W dd D. */
-static time_t
-parse_YMWD (cch_t * pz)
-{
- time_t res = 0;
- cch_t * ps = strchr (pz, 'Y');
- if (ps != NULL)
- {
- res = parse_scaled_value (0, &pz, ps, SEC_PER_YEAR);
- pz++;
- }
-
- ps = strchr (pz, 'M');
- if (ps != NULL)
- {
- res = parse_scaled_value (res, &pz, ps, SEC_PER_MONTH);
- pz++;
- }
-
- ps = strchr (pz, 'W');
- if (ps != NULL)
- {
- res = parse_scaled_value (res, &pz, ps, SEC_PER_WEEK);
- pz++;
- }
-
- ps = strchr (pz, 'D');
- if (ps != NULL)
- {
- res = parse_scaled_value (res, &pz, ps, SEC_PER_DAY);
- pz++;
- }
-
- while (isspace ((unsigned char)*pz))
- pz++;
- if (*pz != NUL)
- {
- errno = EINVAL;
- return BAD_TIME;
- }
-
- return res;
-}
-
-/* Parses the syntax HH:MM:SS.
- PS points into the string, after "HH", before ":MM:SS". */
-static time_t
-parse_hour_minute_second (cch_t * pz, cch_t * ps)
-{
- time_t res = 0;
-
- res = parse_scaled_value (0, &pz, ps, SEC_PER_HR);
-
- pz++;
- ps = strchr (pz, ':');
- if (ps == NULL)
- {
- errno = EINVAL;
- return BAD_TIME;
- }
-
- res = parse_scaled_value (res, &pz, ps, SEC_PER_MIN);
-
- pz++;
- ps = pz + strlen (pz);
- return parse_scaled_value (res, &pz, ps, 1);
-}
-
-/* Parses the syntax HHMMSS. */
-static time_t
-parse_hourminutesecond (cch_t * in_pz)
-{
- time_t res = 0;
- char buf[4];
- cch_t * pz;
-
- if (strlen (in_pz) != 6)
- {
- errno = EINVAL;
- return BAD_TIME;
- }
-
- memcpy (buf, in_pz, 2);
- buf[2] = NUL;
- pz = buf;
- res = parse_scaled_value (0, &pz, buf + 2, SEC_PER_HR);
-
- memcpy (buf, in_pz + 2, 2);
- buf[2] = NUL;
- pz = buf;
- res = parse_scaled_value (res, &pz, buf + 2, SEC_PER_MIN);
-
- memcpy (buf, in_pz + 4, 2);
- buf[2] = NUL;
- pz = buf;
- return parse_scaled_value (res, &pz, buf + 2, 1);
-}
-
-/* Parses the syntax hh H mm M ss S. */
-static time_t
-parse_HMS (cch_t * pz)
-{
- time_t res = 0;
- cch_t * ps = strchr (pz, 'H');
- if (ps != NULL)
- {
- res = parse_scaled_value (0, &pz, ps, SEC_PER_HR);
- pz++;
- }
-
- ps = strchr (pz, 'M');
- if (ps != NULL)
- {
- res = parse_scaled_value (res, &pz, ps, SEC_PER_MIN);
- pz++;
- }
-
- ps = strchr (pz, 'S');
- if (ps != NULL)
- {
- res = parse_scaled_value (res, &pz, ps, 1);
- pz++;
- }
-
- while (isspace ((unsigned char)*pz))
- pz++;
- if (*pz != NUL)
- {
- errno = EINVAL;
- return BAD_TIME;
- }
-
- return res;
-}
-
-/* Parses a time (hours, minutes, seconds) specification in either syntax. */
-static time_t
-parse_time (cch_t * pz)
-{
- cch_t * ps;
- time_t res = 0;
-
- /*
- * Scan for a hyphen
- */
- ps = strchr (pz, ':');
- if (ps != NULL)
- {
- res = parse_hour_minute_second (pz, ps);
- }
-
- /*
- * Try for a 'H', 'M' or 'S' suffix
- */
- else if (ps = strpbrk (pz, "HMS"),
- ps == NULL)
- {
- /* Its a YYYYMMDD format: */
- res = parse_hourminutesecond (pz);
- }
-
- else
- res = parse_HMS (pz);
-
- return res;
-}
-
-/* Returns a substring of the given string, with spaces at the beginning and at
- the end destructively removed, per SNOBOL. */
-static char *
-trim (char * pz)
-{
- /* trim leading white space */
- while (isspace ((unsigned char)*pz))
- pz++;
-
- /* trim trailing white space */
- {
- char * pe = pz + strlen (pz);
- while ((pe > pz) && isspace ((unsigned char)pe[-1]))
- pe--;
- *pe = NUL;
- }
-
- return pz;
-}
-
-/*
- * Parse the year/months/days of a time period
- */
-static time_t
-parse_period (cch_t * in_pz)
-{
- char * pT;
- char * ps;
- char * pz = strdup (in_pz);
- void * fptr = pz;
- time_t res = 0;
-
- if (pz == NULL)
- {
- errno = ENOMEM;
- return BAD_TIME;
- }
-
- pT = strchr (pz, 'T');
- if (pT != NULL)
- {
- *(pT++) = NUL;
- pz = trim (pz);
- pT = trim (pT);
- }
-
- /*
- * Scan for a hyphen
- */
- ps = strchr (pz, '-');
- if (ps != NULL)
- {
- res = parse_year_month_day (pz, ps);
- }
-
- /*
- * Try for a 'Y', 'M' or 'D' suffix
- */
- else if (ps = strpbrk (pz, "YMWD"),
- ps == NULL)
- {
- /* Its a YYYYMMDD format: */
- res = parse_yearmonthday (pz);
- }
-
- else
- res = parse_YMWD (pz);
-
- if ((errno == 0) && (pT != NULL))
- {
- time_t val = parse_time (pT);
- res = scale_n_add (res, val, 1);
- }
-
- free (fptr);
- return res;
-}
-
-static time_t
-parse_non_iso8601 (cch_t * pz)
-{
- whats_done_t whatd_we_do = NOTHING_IS_DONE;
-
- time_t res = 0;
-
- do {
- time_t val;
-
- errno = 0;
- val = str_const_to_l (pz, &pz, 10);
- if (errno != 0)
- goto bad_time;
-
- /* IF we find a colon, then we're going to have a seconds value.
- We will not loop here any more. We cannot already have parsed
- a minute value and if we've parsed an hour value, then the result
- value has to be less than an hour. */
- if (*pz == ':')
- {
- if (whatd_we_do >= MINUTE_IS_DONE)
- break;
-
- val = parse_hr_min_sec (val, pz);
-
- if ((whatd_we_do == HOUR_IS_DONE) && (val >= SEC_PER_HR))
- break;
-
- return scale_n_add (res, val, 1);
- }
-
- {
- unsigned int mult;
-
- /* Skip over white space following the number we just parsed. */
- while (isspace ((unsigned char)*pz))
- pz++;
-
- switch (*pz)
- {
- default: goto bad_time;
- case NUL:
- return scale_n_add (res, val, 1);
-
- case 'y': case 'Y':
- if (whatd_we_do >= YEAR_IS_DONE)
- goto bad_time;
- mult = SEC_PER_YEAR;
- whatd_we_do = YEAR_IS_DONE;
- break;
-
- case 'M':
- if (whatd_we_do >= MONTH_IS_DONE)
- goto bad_time;
- mult = SEC_PER_MONTH;
- whatd_we_do = MONTH_IS_DONE;
- break;
-
- case 'W':
- if (whatd_we_do >= WEEK_IS_DONE)
- goto bad_time;
- mult = SEC_PER_WEEK;
- whatd_we_do = WEEK_IS_DONE;
- break;
-
- case 'd': case 'D':
- if (whatd_we_do >= DAY_IS_DONE)
- goto bad_time;
- mult = SEC_PER_DAY;
- whatd_we_do = DAY_IS_DONE;
- break;
-
- case 'h':
- if (whatd_we_do >= HOUR_IS_DONE)
- goto bad_time;
- mult = SEC_PER_HR;
- whatd_we_do = HOUR_IS_DONE;
- break;
-
- case 'm':
- if (whatd_we_do >= MINUTE_IS_DONE)
- goto bad_time;
- mult = SEC_PER_MIN;
- whatd_we_do = MINUTE_IS_DONE;
- break;
-
- case 's':
- mult = 1;
- whatd_we_do = SECOND_IS_DONE;
- break;
- }
-
- res = scale_n_add (res, val, mult);
-
- pz++;
- while (isspace ((unsigned char)*pz))
- pz++;
- if (*pz == NUL)
- return res;
-
- if (! isdigit ((unsigned char)*pz))
- break;
- }
-
- } while (whatd_we_do < SECOND_IS_DONE);
-
- bad_time:
- errno = EINVAL;
- return BAD_TIME;
-}
-
-time_t
-parse_duration (char const * pz)
-{
- while (isspace ((unsigned char)*pz))
- pz++;
-
- switch (*pz)
- {
- case 'P':
- return parse_period (pz + 1);
-
- case 'T':
- return parse_time (pz + 1);
-
- default:
- if (isdigit ((unsigned char)*pz))
- return parse_non_iso8601 (pz);
-
- errno = EINVAL;
- return BAD_TIME;
- }
-}
-
-/*
- * Local Variables:
- * mode: C
- * c-file-style: "gnu"
- * indent-tabs-mode: nil
- * End:
- * end of parse-duration.c */
diff --git a/src/libopts/parse-duration.h b/src/libopts/parse-duration.h
deleted file mode 100644
index 9a7bcd5e10..0000000000
--- a/src/libopts/parse-duration.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* Parse a time duration and return a seconds count
- Copyright (C) 2008-2018 Free Software Foundation, Inc.
- Written by Bruce Korb <bkorb@gnu.org>, 2008.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-/*
-
- Readers and users of this function are referred to the ISO-8601
- specification, with particular attention to "Durations".
-
- At the time of writing, this worked:
-
- https://en.wikipedia.org/wiki/ISO_8601#Durations
-
- The string must start with a 'P', 'T' or a digit.
-
- ==== if it is a digit
-
- the string may contain: NNN Y NNN M NNN W NNN d NNN h NNN m NNN s
- This represents NNN years, NNN months, NNN weeks, NNN days, NNN hours,
- NNN minutes and NNN seconds.
- The embedded white space is optional.
- These terms must appear in this order.
- Case is significant: 'M' is months and 'm' is minutes.
- The final "s" is optional.
- All of the terms ("NNN" plus designator) are optional.
- Minutes and seconds may optionally be represented as NNN:NNN.
- Also, hours, minute and seconds may be represented as NNN:NNN:NNN.
- There is no limitation on the value of any of the terms, except
- that the final result must fit in a time_t value.
-
- ==== if it is a 'P' or 'T', please see ISO-8601 for a rigorous definition.
-
- The 'P' term may be followed by any of three formats:
- yyyymmdd
- yy-mm-dd
- yy Y mm M ww W dd D
-
- or it may be empty and followed by a 'T'. The "yyyymmdd" must be eight
- digits long.
-
- NOTE! Months are always 30 days and years are always 365 days long.
- 5 years is always 1825 days, not 1826 or 1827 depending on leap year
- considerations. 3 months is always 90 days. There is no consideration
- for how many days are in the current, next or previous months.
-
- For the final format:
- * Embedded white space is allowed, but it is optional.
- * All of the terms are optional. Any or all-but-one may be omitted.
- * The meanings are yy years, mm months, ww weeks and dd days.
- * The terms must appear in this order.
-
- ==== The 'T' term may be followed by any of these formats:
-
- hhmmss
- hh:mm:ss
- hh H mm M ss S
-
- For the final format:
- * Embedded white space is allowed, but it is optional.
- * All of the terms are optional. Any or all-but-one may be omitted.
- * The terms must appear in this order.
-
- */
-#ifndef GNULIB_PARSE_DURATION_H
-#define GNULIB_PARSE_DURATION_H
-
-#include <time.h>
-
-/* Return value when a valid duration cannot be parsed. */
-#define BAD_TIME ((time_t)~0)
-
-/* Parses the given string. If it has the syntax of a valid duration,
- this duration is returned. Otherwise, the return value is BAD_TIME,
- and errno is set to either EINVAL (bad syntax) or ERANGE (out of range). */
-extern time_t parse_duration (char const * in_pz);
-
-#endif /* GNULIB_PARSE_DURATION_H */
diff --git a/src/libopts/pgusage.c b/src/libopts/pgusage.c
deleted file mode 100644
index f895b3bb56..0000000000
--- a/src/libopts/pgusage.c
+++ /dev/null
@@ -1,187 +0,0 @@
-
-/**
- * \file pgusage.c
- *
- * Automated Options Paged Usage module.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This routine will run run-on options through a pager so the
- * user may examine, print or edit them at their leisure.
- *
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-#if defined(HAVE_WORKING_FORK)
-static inline FILE *
-open_tmp_usage(char ** buf)
-{
- char * bf;
- size_t bfsz;
-
- {
- unsigned int my_pid = (unsigned int)getpid();
- char const * tmpdir = getenv(TMPDIR);
- if (tmpdir == NULL)
- tmpdir = tmp_dir;
- bfsz = TMP_FILE_FMT_LEN + strlen(tmpdir) + 10;
- bf = AGALOC(bfsz, "tmp fil");
- snprintf(bf, bfsz, TMP_FILE_FMT, tmpdir, my_pid);
- }
-
- {
- static mode_t const cmask = S_IRWXO | S_IRWXG;
- mode_t svmsk = umask(cmask);
- int fd = mkstemp(bf);
- (void)umask(svmsk);
-
- if (fd < 0) {
- AGFREE(bf);
- return NULL;
- }
- *buf = bf;
- return fdopen(fd, "w");
- }
-}
-
-static inline char *
-mk_pager_cmd(char const * fname)
-{
- /*
- * Page the file and remove it when done. For shell script processing,
- * we must redirect the output to the current stderr, otherwise stdout.
- */
- fclose(option_usage_fp);
- option_usage_fp = NULL;
-
- {
- char const * pager = (char const *)getenv(PAGER_NAME);
- size_t bfsz;
- char * res;
-
- /*
- * Use the "more(1)" program if "PAGER" has not been defined
- */
- if (pager == NULL)
- pager = MORE_STR;
-
- bfsz = 2 * strlen(fname) + strlen(pager) + PAGE_USAGE_FMT_LEN;
- res = AGALOC(bfsz, "more cmd");
- snprintf(res, bfsz, PAGE_USAGE_FMT, pager, fname);
- AGFREE(fname);
- return res;
- }
-}
-#endif
-
-/*=export_func optionPagedUsage
- * private:
- *
- * what: emit help text and pass through a pager program.
- * arg: + tOptions * + opts + program options descriptor +
- * arg: + tOptDesc * + od + the descriptor for this arg +
- *
- * doc:
- * Run the usage output through a pager.
- * This is very handy if it is very long.
- * This is disabled on platforms without a working fork() function.
-=*/
-void
-optionPagedUsage(tOptions * opts, tOptDesc * od)
-{
-#if ! defined(HAVE_WORKING_FORK)
- if ((od->fOptState & OPTST_RESET) != 0)
- return;
-
- (*opts->pUsageProc)(opts, EXIT_SUCCESS);
-#else
- static bool sv_print_exit = false;
- static char * fil_name = NULL;
-
- /*
- * IF we are being called after the usage proc is done
- * (and thus has called "exit(2)")
- * THEN invoke the pager to page through the usage file we created.
- */
- switch (pagerState) {
- case PAGER_STATE_INITIAL:
- {
- if ((od->fOptState & OPTST_RESET) != 0)
- return;
- option_usage_fp = open_tmp_usage(&fil_name);
- if (option_usage_fp == NULL)
- (*opts->pUsageProc)(opts, EXIT_SUCCESS);
-
- pagerState = PAGER_STATE_READY;
- sv_print_exit = print_exit;
-
- /*
- * Set up so this routine gets called during the exit logic
- */
- atexit((void(*)(void))optionPagedUsage);
-
- /*
- * The usage procedure will now put the usage information into
- * the temporary file we created above. Keep any shell commands
- * out of the result.
- */
- print_exit = false;
- (*opts->pUsageProc)(opts, EXIT_SUCCESS);
-
- /* NOTREACHED */
- _exit(EXIT_FAILURE);
- }
-
- case PAGER_STATE_READY:
- fil_name = mk_pager_cmd(fil_name);
-
- if (sv_print_exit) {
- fputs("\nexit 0\n", stdout);
- fclose(stdout);
- dup2(STDERR_FILENO, STDOUT_FILENO);
-
- } else {
- fclose(stderr);
- dup2(STDOUT_FILENO, STDERR_FILENO);
- }
-
- ignore_val( system( fil_name));
- AGFREE(fil_name);
-
- case PAGER_STATE_CHILD:
- /*
- * This is a child process used in creating shell script usage.
- */
- break;
- }
-#endif
-}
-
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/pgusage.c */
diff --git a/src/libopts/proto.h b/src/libopts/proto.h
deleted file mode 100644
index 437e81ed9b..0000000000
--- a/src/libopts/proto.h
+++ /dev/null
@@ -1,620 +0,0 @@
-/* -*- buffer-read-only: t -*- vi: set ro:
- *
- * Prototypes for autoopts
- * Generated Sun Aug 26 10:44:39 PDT 2018
- */
-#ifndef AUTOOPTS_PROTO_H_GUARD
-#define AUTOOPTS_PROTO_H_GUARD 1
-
-
-/*
- * Static declarations from alias.c
- */
-static tSuccess
-too_many_occurrences(tOptions * opts, tOptDesc * od);
-
-/*
- * Static declarations from autoopts.c
- */
-static void *
-ao_malloc(size_t sz);
-
-static void *
-ao_realloc(void *p, size_t sz);
-
-static char *
-ao_strdup(char const *str);
-
-static tSuccess
-handle_opt(tOptions * opts, tOptState * o_st);
-
-static tSuccess
-next_opt(tOptions * opts, tOptState * o_st);
-
-static tSuccess
-regular_opts(tOptions * opts);
-
-/*
- * Static declarations from check.c
- */
-static bool
-has_conflict(tOptions * pOpts, tOptDesc * od);
-
-static bool
-occurs_enough(tOptions * pOpts, tOptDesc * pOD);
-
-static bool
-is_consistent(tOptions * pOpts);
-
-/*
- * Static declarations from configfile.c
- */
-static void
-file_preset(tOptions * opts, char const * fname, int dir);
-
-static char *
-handle_comment(char * txt);
-
-static char *
-handle_cfg(tOptions * opts, tOptState * ost, char * txt, int dir);
-
-static char *
-handle_directive(tOptions * opts, char * txt);
-
-static char *
-aoflags_directive(tOptions * opts, char * txt);
-
-static char *
-program_directive(tOptions * opts, char * txt);
-
-static char *
-handle_section(tOptions * opts, char * txt);
-
-static int
-parse_xml_encoding(char ** ppz);
-
-static char *
-trim_xml_text(char * intxt, char const * pznm, tOptionLoadMode mode);
-
-static void
-cook_xml_text(char * pzData);
-
-static char *
-handle_struct(tOptions * opts, tOptState * ost, char * txt, int dir);
-
-static void
-intern_file_load(tOptions * opts);
-
-static char const *
-parse_attrs(tOptions * opts, char const * txt, tOptionLoadMode * pMode,
- tOptionValue * pType);
-
-static char const *
-parse_keyword(tOptions * opts, char const * txt, tOptionValue * typ);
-
-static char const *
-parse_set_mem(tOptions * opts, char const * txt, tOptionValue * typ);
-
-static char const *
-parse_value(char const * txt, tOptionValue * typ);
-
-/*
- * Static declarations from cook.c
- */
-static char *
-nl_count(char * start, char * end, int * lnct_p);
-
-static bool
-contiguous_quote(char ** pps, char * pq, int * lnct_p);
-
-/*
- * Static declarations from enum.c
- */
-static void
-enum_err(tOptions * pOpts, tOptDesc * pOD,
- char const * const * paz_names, int name_ct);
-
-static uintptr_t
-find_name(char const * name, tOptions * pOpts, tOptDesc * pOD,
- char const * const * paz_names, unsigned int name_ct);
-
-static void
-set_memb_shell(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names,
- unsigned int name_ct);
-
-static void
-set_memb_names(tOptions * opts, tOptDesc * od, char const * const * nm_list,
- unsigned int nm_ct);
-
-static uintptr_t
-check_membership_start(tOptDesc * od, char const ** argp, bool * invert);
-
-static uintptr_t
-find_member_bit(tOptions * opts, tOptDesc * od, char const * pz, int len,
- char const * const * nm_list, unsigned int nm_ct);
-
-/*
- * Static declarations from env.c
- */
-static void
-doPrognameEnv(tOptions * pOpts, teEnvPresetType type);
-
-static void
-do_env_opt(tOptState * os, char * env_name,
- tOptions * pOpts, teEnvPresetType type);
-
-static void
-env_presets(tOptions * pOpts, teEnvPresetType type);
-
-/*
- * Static declarations from file.c
- */
-static void
-check_existence(teOptFileType ftype, tOptions * pOpts, tOptDesc * pOD);
-
-static void
-open_file_fd(tOptions * pOpts, tOptDesc * pOD, tuFileMode mode);
-
-static void
-fopen_file_fp(tOptions * pOpts, tOptDesc * pOD, tuFileMode mode);
-
-/*
- * Static declarations from find.c
- */
-static int
-parse_opt(char const ** nm_pp, char ** arg_pp, char * buf, size_t bufsz);
-
-static void
-opt_ambiguities(tOptions * opts, char const * name, int nm_len);
-
-static int
-opt_match_ct(tOptions * opts, char const * name, int nm_len,
- int * ixp, bool * disable);
-
-static tSuccess
-opt_set(tOptions * opts, char * arg, int idx, bool disable, tOptState * st);
-
-static tSuccess
-opt_unknown(tOptions * opts, char const * name, char * arg, tOptState * st);
-
-static tSuccess
-opt_ambiguous(tOptions * opts, char const * name, int match_ct);
-
-static tSuccess
-opt_find_long(tOptions * opts, char const * opt_name, tOptState * state);
-
-static tSuccess
-opt_find_short(tOptions * pOpts, uint_t optValue, tOptState * pOptState);
-
-static tSuccess
-get_opt_arg_must(tOptions * opts, tOptState * o_st);
-
-static tSuccess
-get_opt_arg_may(tOptions * pOpts, tOptState * o_st);
-
-static tSuccess
-get_opt_arg_none(tOptions * pOpts, tOptState * o_st);
-
-static tSuccess
-get_opt_arg(tOptions * opts, tOptState * o_st);
-
-static tSuccess
-find_opt(tOptions * opts, tOptState * o_st);
-
-/*
- * Static declarations from init.c
- */
-static tSuccess
-validate_struct(tOptions * opts, char const * pname);
-
-static tSuccess
-immediate_opts(tOptions * opts);
-
-static tSuccess
-do_presets(tOptions * opts);
-
-static bool
-ao_initialize(tOptions * opts, int a_ct, char ** a_v);
-
-/*
- * Static declarations from load.c
- */
-static bool
-get_realpath(char * buf, size_t b_sz);
-
-static bool
-add_prog_path(char * buf, int b_sz, char const * fname, char const * prg_path);
-
-static bool
-add_env_val(char * buf, int buf_sz, char const * name);
-
-static void
-munge_str(char * txt, tOptionLoadMode mode);
-
-static char *
-assemble_arg_val(char * txt, tOptionLoadMode mode);
-
-static char *
-trim_quotes(char * arg);
-
-static bool
-direction_ok(opt_state_mask_t f, int dir);
-
-static void
-load_opt_line(tOptions * opts, tOptState * opt_state, char * line,
- tDirection direction, tOptionLoadMode load_mode );
-
-/*
- * Static declarations from makeshell.c
- */
-noreturn static void
-option_exits(int exit_code);
-
-noreturn static void
-ao_bug(char const * msg);
-
-static void
-fserr_warn(char const * prog, char const * op, char const * fname);
-
-noreturn static void
-fserr_exit(char const * prog, char const * op, char const * fname);
-
-static void
-emit_var_text(char const * prog, char const * var, int fdin);
-
-static void
-text_to_var(tOptions * opts, teTextTo which, tOptDesc * od);
-
-static void
-emit_usage(tOptions * opts);
-
-static void
-emit_wrapup(tOptions * opts);
-
-static void
-emit_setup(tOptions * opts);
-
-static void
-emit_action(tOptions * opts, tOptDesc * od);
-
-static void
-emit_inaction(tOptions * opts, tOptDesc * od);
-
-static void
-emit_flag(tOptions * opts);
-
-static void
-emit_match_expr(char const * name, tOptDesc * cod, tOptions * opts);
-
-static void
-emit_long(tOptions * opts);
-
-static char *
-load_old_output(char const * fname, char const * pname);
-
-static void
-open_out(char const * fname, char const * pname);
-
-/*
- * Static declarations from nested.c
- */
-static void
-remove_continuation(char * src);
-
-static char const *
-scan_q_str(char const * pzTxt);
-
-static tOptionValue *
-add_string(void ** pp, char const * name, size_t nm_len,
- char const * val, size_t d_len);
-
-static tOptionValue *
-add_bool(void ** pp, char const * name, size_t nm_len,
- char const * val, size_t d_len);
-
-static tOptionValue *
-add_number(void ** pp, char const * name, size_t nm_len,
- char const * val, size_t d_len);
-
-static tOptionValue *
-add_nested(void ** pp, char const * name, size_t nm_len,
- char * val, size_t d_len);
-
-static char const *
-scan_name(char const * name, tOptionValue * res);
-
-static char const *
-unnamed_xml(char const * txt);
-
-static char const *
-scan_xml_name(char const * name, size_t * nm_len, tOptionValue * val);
-
-static char const *
-find_end_xml(char const * src, size_t nm_len, char const * val, size_t * len);
-
-static char const *
-scan_xml(char const * xml_name, tOptionValue * res_val);
-
-static void
-unload_arg_list(tArgList * arg_list);
-
-static void
-sort_list(tArgList * arg_list);
-
-static tOptionValue *
-optionLoadNested(char const * text, char const * name, size_t nm_len);
-
-static int
-get_special_char(char const ** ppz, int * ct);
-
-static void
-emit_special_char(FILE * fp, int ch);
-
-/*
- * Static declarations from parse-duration.c
- */
-static unsigned long
-str_const_to_ul (cch_t * str, cch_t ** ppz, int base);
-
-static long
-str_const_to_l (cch_t * str, cch_t ** ppz, int base);
-
-static time_t
-scale_n_add (time_t base, time_t val, int scale);
-
-static time_t
-parse_hr_min_sec (time_t start, cch_t * pz);
-
-static time_t
-parse_scaled_value (time_t base, cch_t ** ppz, cch_t * endp, int scale);
-
-static time_t
-parse_year_month_day (cch_t * pz, cch_t * ps);
-
-static time_t
-parse_yearmonthday (cch_t * in_pz);
-
-static time_t
-parse_YMWD (cch_t * pz);
-
-static time_t
-parse_hour_minute_second (cch_t * pz, cch_t * ps);
-
-static time_t
-parse_hourminutesecond (cch_t * in_pz);
-
-static time_t
-parse_HMS (cch_t * pz);
-
-static time_t
-parse_time (cch_t * pz);
-
-static char *
-trim (char * pz);
-
-static time_t
-parse_period (cch_t * in_pz);
-
-static time_t
-parse_non_iso8601 (cch_t * pz);
-
-/*
- * Static declarations from pgusage.c
- */
-static inline FILE *
-open_tmp_usage(char ** buf);
-
-static inline char *
-mk_pager_cmd(char const * fname);
-
-/*
- * Static declarations from putshell.c
- */
-static size_t
-string_size(char const * scan, size_t nl_len);
-
-static char const *
-print_quoted_apostrophes(char const * str);
-
-static void
-print_quot_str(char const * str);
-
-static void
-print_enumeration(tOptions * pOpts, tOptDesc * pOD);
-
-static void
-print_membership(tOptions * pOpts, tOptDesc * pOD);
-
-static void
-print_stacked_arg(tOptions * pOpts, tOptDesc * pOD);
-
-static void
-print_reordering(tOptions * opts);
-
-/*
- * Static declarations from reset.c
- */
-static void
-optionReset(tOptions * pOpts, tOptDesc * pOD);
-
-static void
-optionResetEverything(tOptions * pOpts);
-
-/*
- * Static declarations from restore.c
- */
-static void
-fixupSavedOptionArgs(tOptions * pOpts);
-
-/*
- * Static declarations from save.c
- */
-static char const *
-find_dir_name(tOptions * opts, int * p_free);
-
-static char const *
-find_file_name(tOptions * opts, int * p_free_name);
-
-static void
-prt_entry(FILE * fp, tOptDesc * od, char const * l_arg, save_flags_mask_t save_fl);
-
-static void
-prt_value(FILE * fp, int depth, tOptDesc * od, tOptionValue const * ovp);
-
-static void
-prt_string(FILE * fp, char const * name, char const * pz);
-
-static void
-prt_val_list(FILE * fp, char const * name, tArgList * al);
-
-static void
-prt_nested(FILE * fp, tOptDesc * od, save_flags_mask_t save_fl);
-
-static void
-remove_settings(tOptions * opts, char const * fname);
-
-static FILE *
-open_sv_file(tOptions * opts, save_flags_mask_t save_fl);
-
-static void
-prt_no_arg_opt(FILE * fp, tOptDesc * vod, tOptDesc * pod, save_flags_mask_t save_fl);
-
-static void
-prt_str_arg(FILE * fp, tOptDesc * od, save_flags_mask_t save_fl);
-
-static void
-prt_enum_arg(FILE * fp, tOptDesc * od, save_flags_mask_t save_fl);
-
-static void
-prt_set_arg(FILE * fp, tOptDesc * od, save_flags_mask_t save_fl);
-
-static void
-prt_file_arg(FILE * fp, tOptDesc * od, tOptions * opts, save_flags_mask_t save_fl);
-
-/*
- * Static declarations from sort.c
- */
-static tSuccess
-must_arg(tOptions * opts, char * arg_txt, tOptState * pOS,
- char ** opt_txt, uint32_t * opt_idx);
-
-static tSuccess
-maybe_arg(tOptions * opts, char * arg_txt, tOptState * pOS,
- char ** opt_txt, uint32_t * opt_idx);
-
-static tSuccess
-short_opt_ck(tOptions * opts, char * arg_txt, tOptState * pOS,
- char ** opt_txt, uint32_t * opt_idx);
-
-static void
-optionSort(tOptions * opts);
-
-/*
- * Static declarations from stack.c
- */
-static void
-addArgListEntry(void ** ppAL, void * entry);
-
-/*
- * Static declarations from text_mmap.c
- */
-static void
-load_text_file(tmap_info_t * mapinfo, char const * pzFile);
-
-static void
-validate_mmap(char const * fname, int prot, int flags, tmap_info_t * mapinfo);
-
-static void
-close_mmap_files(tmap_info_t * mi);
-
-/*
- * Static declarations from tokenize.c
- */
-static void
-copy_cooked(ch_t ** ppDest, char const ** ppSrc);
-
-static void
-copy_raw(ch_t ** ppDest, char const ** ppSrc);
-
-static token_list_t *
-alloc_token_list(char const * str);
-
-/*
- * Static declarations from usage.c
- */
-static unsigned int
-parse_usage_flags(ao_flag_names_t const * fnt, char const * txt);
-
-static void
-set_usage_flags(tOptions * opts, char const * flg_txt);
-
-static inline bool
-do_gnu_usage(tOptions * pOpts);
-
-static inline bool
-skip_misuse_usage(tOptions * pOpts);
-
-static void
-print_offer_usage(tOptions * opts);
-
-static void
-print_usage_details(tOptions * opts, int exit_code);
-
-static void
-print_one_paragraph(char const * text, bool plain, FILE * fp);
-
-static void
-prt_conflicts(tOptions * opts, tOptDesc * od);
-
-static void
-prt_one_vendor(tOptions * opts, tOptDesc * od,
- arg_types_t * argtp, char const * usefmt);
-
-static void
-prt_vendor_opts(tOptions * opts, char const * title);
-
-static void
-prt_extd_usage(tOptions * opts, tOptDesc * od, char const * title);
-
-static void
-prt_ini_list(char const * const * papz, char const * ini_file,
- char const * path_nm);
-
-static void
-prt_preamble(tOptions * opts, tOptDesc * od, arg_types_t * at);
-
-static void
-prt_one_usage(tOptions * opts, tOptDesc * od, arg_types_t * at);
-
-static void
-prt_opt_usage(tOptions * opts, int ex_code, char const * title);
-
-static void
-prt_prog_detail(tOptions * opts);
-
-static int
-setGnuOptFmts(tOptions * opts, char const ** ptxt);
-
-static int
-setStdOptFmts(tOptions * opts, char const ** ptxt);
-
-/*
- * Static declarations from version.c
- */
-static void
-emit_first_line(
- FILE * fp, char const * alt1, char const * alt2, char const * alt3);
-
-static void
-emit_simple_ver(tOptions * o, FILE * fp);
-
-static void
-emit_copy_full(tOptions * o, FILE * fp);
-
-static void
-emit_copy_note(tOptions * opts, FILE * fp);
-
-static void
-print_ver(tOptions * opts, tOptDesc * od, FILE * fp, bool call_exit);
-
-#endif /* AUTOOPTS_PROTO_H_GUARD */
diff --git a/src/libopts/putshell.c b/src/libopts/putshell.c
deleted file mode 100644
index 84463dd40b..0000000000
--- a/src/libopts/putshell.c
+++ /dev/null
@@ -1,495 +0,0 @@
-
-/**
- * \file putshell.c
- *
- * This module will interpret the options set in the tOptions
- * structure and print them to standard out in a fashion that
- * will allow them to be interpreted by the Bourne or Korn shells.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-/**
- * Count the number of bytes required to represent a string as a
- * compilable string.
- *
- * @param[in] scan the text to be rewritten as a C program text string.
- * @param[in] nl_len the number of bytes used for each embedded newline.
- *
- * @returns the count, including the terminating NUL byte.
- */
-static size_t
-string_size(char const * scan, size_t nl_len)
-{
- /*
- * Start by counting the start and end quotes, plus the NUL.
- */
- size_t res_ln = 3;
-
- for (;;) {
- char ch = *(scan++);
- if ((ch >= ' ') && (ch <= '~')) {
-
- /*
- * a backslash allowance for double quotes and baskslashes
- */
- res_ln += ((ch == '"') || (ch == '\\')) ? 2 : 1;
- }
-
- /*
- * When not a normal character, then count the characters
- * required to represent whatever it is.
- */
- else switch (ch) {
- case NUL:
- return res_ln;
-
- case NL:
- res_ln += nl_len;
- break;
-
- case HT:
- case BEL:
- case BS:
- case FF:
- case CR:
- case VT:
- res_ln += 2;
- break;
-
- default:
- res_ln += 4; /* text len for \xNN */
- }
- }
-}
-
-/*=export_func optionQuoteString
- * private:
- *
- * what: Print a string as quoted text suitable for a C compiler.
- * arg: + char const * + text + a block of text to quote +
- * arg: + char const * + nl + line splice text +
- *
- * ret_type: char const *
- * ret_desc: the allocated input string as a quoted string
- *
- * doc:
- * This is for internal use by autogen and autoopts.
- * It takes an input string and produces text the C compiler can process
- * to produce an exact copy of the original string.
- * The caller must deallocate the result. Standard C strings and
- * K&R strings are distinguished by the "nl" string.
-=*/
-char const *
-optionQuoteString(char const * text, char const * nl)
-{
- size_t nl_len = strlen(nl);
- size_t out_sz = string_size(text, nl_len);
- char * out;
- char * res = out = AGALOC(out_sz, "quot str");
-
- *(out++) = '"';
-
- for (;;) {
- unsigned char ch = (unsigned char)*text;
- if ((ch >= ' ') && (ch <= '~')) {
- if ((ch == '"') || (ch == '\\'))
- /*
- * We must escape these characters in the output string
- */
- *(out++) = '\\';
- *(out++) = (char)ch;
-
- } else switch (ch) {
-# define add_esc_ch(_ch) { *(out++) = '\\'; *(out++) = (_ch); }
- case BEL: add_esc_ch('a'); break;
- case BS: add_esc_ch('b'); break;
- case HT: add_esc_ch('t'); break;
- case VT: add_esc_ch('v'); break;
- case FF: add_esc_ch('f'); break;
- case CR: add_esc_ch('r'); break;
-
- case LF:
- /*
- * Place contiguous new-lines on a single line.
- * The current character is a NL, check the next one.
- */
- while (*++text == NL)
- add_esc_ch('n');
-
- /*
- * Insert a splice before starting next line
- */
- if (*text != NUL) {
- memcpy(out, nl, nl_len);
- out += nl_len;
-
- continue; /* text is already at the next character */
- }
-
- add_esc_ch('n');
- /* FALLTHROUGH */
-
- case NUL:
- /*
- * End of string. Terminate the quoted output. If necessary,
- * deallocate the text string. Return the scan resumption point.
- */
- *(out++) = '"';
- *(out++) = NUL;
-#ifndef NDEBUG
- if ((size_t)(out - res) > out_sz) {
- fputs(misguess_len, stderr);
- option_exits(EXIT_FAILURE);
- }
-#endif
- return res;
-
- default:
- /*
- * sprintf is safe here, because we already computed
- * the amount of space we will be using. Assertion is above.
- */
- out += sprintf(out, MK_STR_OCT_FMT, ch);
- }
-
- text++;
-# undef add_esc_ch
- }
-}
-
-/**
- * Print out escaped apostorophes.
- *
- * @param[in] str the apostrophies to print
- */
-static char const *
-print_quoted_apostrophes(char const * str)
-{
- while (*str == APOSTROPHE) {
- fputs(QUOT_APOS, stdout);
- str++;
- }
- return str;
-}
-
-/**
- * Print a single quote (apostrophe quoted) string.
- * Other than somersaults for apostrophes, nothing else needs quoting.
- *
- * @param[in] str the string to print
- */
-static void
-print_quot_str(char const * str)
-{
- /*
- * Handle empty strings to make the rest of the logic simpler.
- */
- if ((str == NULL) || (*str == NUL)) {
- fputs(EMPTY_ARG, stdout);
- return;
- }
-
- /*
- * Emit any single quotes/apostrophes at the start of the string and
- * bail if that is all we need to do.
- */
- str = print_quoted_apostrophes(str);
- if (*str == NUL)
- return;
-
- /*
- * Start the single quote string
- */
- fputc(APOSTROPHE, stdout);
- for (;;) {
- char const * pz = strchr(str, APOSTROPHE);
- if (pz == NULL)
- break;
-
- /*
- * Emit the string up to the single quote (apostrophe) we just found.
- */
- (void)fwrite(str, (size_t)(pz - str), (size_t)1, stdout);
-
- /*
- * Close the current string, emit the apostrophes and re-open the
- * string (IFF there is more text to print).
- */
- fputc(APOSTROPHE, stdout);
- str = print_quoted_apostrophes(pz);
- if (*str == NUL)
- return;
-
- fputc(APOSTROPHE, stdout);
- }
-
- /*
- * If we broke out of the loop, we must still emit the remaining text
- * and then close the single quote string.
- */
- fputs(str, stdout);
- fputc(APOSTROPHE, stdout);
-}
-
-static void
-print_enumeration(tOptions * pOpts, tOptDesc * pOD)
-{
- uintptr_t e_val = pOD->optArg.argEnum;
- printf(OPT_VAL_FMT, pOpts->pzPROGNAME, pOD->pz_NAME);
-
- /*
- * Convert value to string, print that and restore numeric value.
- */
- (*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD);
- printf(QUOT_ARG_FMT, pOD->optArg.argString);
- if (pOD->fOptState & OPTST_ALLOC_ARG)
- AGFREE(pOD->optArg.argString);
- pOD->optArg.argEnum = e_val;
-
- printf(OPT_END_FMT, pOpts->pzPROGNAME, pOD->pz_NAME);
-}
-
-static void
-print_membership(tOptions * pOpts, tOptDesc * pOD)
-{
- char const * svstr = pOD->optArg.argString;
- char const * pz;
- uintptr_t val = 1;
- printf(zOptNumFmt, pOpts->pzPROGNAME, pOD->pz_NAME,
- (int)(uintptr_t)(pOD->optCookie));
- pOD->optCookie = VOIDP(~0UL);
- (*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD);
-
- pz = pOD->optArg.argString;
- while (*pz != NUL) {
- printf("readonly %s_", pOD->pz_NAME);
- pz = SPN_PLUS_N_SPACE_CHARS(pz);
-
- for (;;) {
- int ch = *(pz++);
- if (IS_LOWER_CASE_CHAR(ch)) fputc(toupper(ch), stdout);
- else if (IS_UPPER_CASE_CHAR(ch)) fputc(ch, stdout);
- else if (IS_PLUS_N_SPACE_CHAR(ch)) goto name_done;
- else if (ch == NUL) { pz--; goto name_done; }
- else fputc('_', stdout);
- } name_done:;
- printf(SHOW_VAL_FMT, (unsigned long)val);
- val <<= 1;
- }
-
- AGFREE(pOD->optArg.argString);
- pOD->optArg.argString = svstr;
-}
-
-static void
-print_stacked_arg(tOptions * pOpts, tOptDesc * pOD)
-{
- tArgList * pAL = (tArgList *)pOD->optCookie;
- char const ** ppz = pAL->apzArgs;
- int ct = pAL->useCt;
-
- printf(zOptCookieCt, pOpts->pzPROGNAME, pOD->pz_NAME, ct);
-
- while (--ct >= 0) {
- printf(ARG_BY_NUM_FMT, pOpts->pzPROGNAME, pOD->pz_NAME,
- pAL->useCt - ct);
- print_quot_str(*(ppz++));
- printf(EXPORT_ARG_FMT, pOpts->pzPROGNAME, pOD->pz_NAME,
- pAL->useCt - ct);
- }
-}
-
-/**
- * emit the arguments as readily parsed text.
- * The program options are set by emitting the shell "set" command.
- *
- * @param[in] opts the program options structure
- */
-static void
-print_reordering(tOptions * opts)
-{
- unsigned int ix;
-
- fputs(set_dash, stdout);
-
- for (ix = opts->curOptIdx;
- ix < opts->origArgCt;
- ix++) {
- fputc(' ', stdout);
- print_quot_str(opts->origArgVect[ ix ]);
- }
- fputs(init_optct, stdout);
-}
-
-/*=export_func optionPutShell
- * what: write a portable shell script to parse options
- * private:
- * arg: tOptions *, pOpts, the program options descriptor
- * doc: This routine will emit portable shell script text for parsing
- * the options described in the option definitions.
-=*/
-void
-optionPutShell(tOptions * pOpts)
-{
- int optIx = 0;
-
- printf(zOptCtFmt, pOpts->curOptIdx-1);
-
- do {
- tOptDesc * pOD = pOpts->pOptDesc + optIx;
-
- if ((pOD->fOptState & OPTST_NO_OUTPUT_MASK) != 0)
- continue;
-
- /*
- * Equivalence classes are hard to deal with. Where the
- * option data wind up kind of squishes around. For the purposes
- * of emitting shell state, they are not recommended, but we'll
- * do something. I guess we'll emit the equivalenced-to option
- * at the point in time when the base option is found.
- */
- if (pOD->optEquivIndex != NO_EQUIVALENT)
- continue; /* equivalence to a different option */
-
- /*
- * Equivalenced to a different option. Process the current option
- * as the equivalenced-to option. Keep the persistent state bits,
- * but copy over the set-state bits.
- */
- if (pOD->optActualIndex != optIx) {
- tOptDesc * p = pOpts->pOptDesc + pOD->optActualIndex;
- p->optArg = pOD->optArg;
- p->fOptState &= OPTST_PERSISTENT_MASK;
- p->fOptState |= pOD->fOptState & ~OPTST_PERSISTENT_MASK;
- printf(zEquivMode, pOpts->pzPROGNAME, pOD->pz_NAME, p->pz_NAME);
- pOD = p;
- }
-
- /*
- * If the argument type is a set membership bitmask, then we always
- * emit the thing. We do this because it will always have some sort
- * of bitmask value and we need to emit the bit values.
- */
- if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_MEMBERSHIP) {
- print_membership(pOpts, pOD);
- continue;
- }
-
- /*
- * IF the option was either specified or it wakes up enabled,
- * then we will emit information. Otherwise, skip it.
- * The idea is that if someone defines an option to initialize
- * enabled, we should tell our shell script that it is enabled.
- */
- if (UNUSED_OPT(pOD) && DISABLED_OPT(pOD))
- continue;
-
- /*
- * Handle stacked arguments
- */
- if ( (pOD->fOptState & OPTST_STACKED)
- && (pOD->optCookie != NULL) ) {
- print_stacked_arg(pOpts, pOD);
- continue;
- }
-
- /*
- * If the argument has been disabled,
- * Then set its value to the disablement string
- */
- if ((pOD->fOptState & OPTST_DISABLED) != 0) {
- printf(zOptDisabl, pOpts->pzPROGNAME, pOD->pz_NAME,
- (pOD->pz_DisablePfx != NULL)
- ? pOD->pz_DisablePfx : "false");
- continue;
- }
-
- /*
- * If the argument type is numeric, the last arg pointer
- * is really the VALUE of the string that was pointed to.
- */
- if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_NUMERIC) {
- printf(zOptNumFmt, pOpts->pzPROGNAME, pOD->pz_NAME,
- (int)pOD->optArg.argInt);
- continue;
- }
-
- /*
- * If the argument type is an enumeration, then it is much
- * like a text value, except we call the callback function
- * to emit the value corresponding to the "optArg" number.
- */
- if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_ENUMERATION) {
- print_enumeration(pOpts, pOD);
- continue;
- }
-
- /*
- * If the argument type is numeric, the last arg pointer
- * is really the VALUE of the string that was pointed to.
- */
- if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_BOOLEAN) {
- printf(zFullOptFmt, pOpts->pzPROGNAME, pOD->pz_NAME,
- (pOD->optArg.argBool == 0) ? "false" : "true");
- continue;
- }
-
- /*
- * IF the option has an empty value,
- * THEN we set the argument to the occurrence count.
- */
- if ( (pOD->optArg.argString == NULL)
- || (pOD->optArg.argString[0] == NUL) ) {
-
- printf(zOptNumFmt, pOpts->pzPROGNAME, pOD->pz_NAME,
- pOD->optOccCt);
- continue;
- }
-
- /*
- * This option has a text value
- */
- printf(OPT_VAL_FMT, pOpts->pzPROGNAME, pOD->pz_NAME);
- print_quot_str(pOD->optArg.argString);
- printf(OPT_END_FMT, pOpts->pzPROGNAME, pOD->pz_NAME);
-
- } while (++optIx < pOpts->presetOptCt );
-
- if ( ((pOpts->fOptSet & OPTPROC_REORDER) != 0)
- && (pOpts->curOptIdx < pOpts->origArgCt))
- print_reordering(pOpts);
-
- fflush(stdout);
-}
-
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/putshell.c */
diff --git a/src/libopts/reset.c b/src/libopts/reset.c
deleted file mode 100644
index f7b58e8d1a..0000000000
--- a/src/libopts/reset.c
+++ /dev/null
@@ -1,141 +0,0 @@
-
-/**
- * \file reset.c
- *
- * Reset the option state to the compiled state.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-static void
-optionReset(tOptions * pOpts, tOptDesc * pOD)
-{
- pOD->fOptState &= OPTST_PERSISTENT_MASK;
- pOD->fOptState |= OPTST_RESET;
- if (pOD->pOptProc != NULL)
- pOD->pOptProc(pOpts, pOD);
- pOD->optArg.argString =
- pOpts->originalOptArgArray[ pOD->optIndex ].argString;
- pOD->optCookie = pOpts->originalOptArgCookie[ pOD->optIndex ];
- pOD->fOptState &= OPTST_PERSISTENT_MASK;
-}
-
-
-static void
-optionResetEverything(tOptions * pOpts)
-{
- tOptDesc * pOD = pOpts->pOptDesc;
- int ct = pOpts->presetOptCt;
-
- for (;;) {
- optionReset(pOpts, pOD);
-
- if (--ct <= 0)
- break;
- pOD++;
- }
-}
-
-
-/*=export_func optionResetOpt
- * private:
- *
- * what: Reset the value of an option
- * arg: + tOptions * + pOpts + program options descriptor +
- * arg: + tOptDesc * + pOptDesc + the descriptor for this arg +
- *
- * doc:
- * This code will cause another option to be reset to its initial state.
- * For example, --reset=foo will cause the --foo option to be reset.
-=*/
-void
-optionResetOpt(tOptions * pOpts, tOptDesc * pOD)
-{
- static bool reset_active = false;
-
- tOptState opt_state = OPTSTATE_INITIALIZER(DEFINED);
- char const * pzArg = pOD->optArg.argString;
- tSuccess succ;
-
- if (pOpts <= OPTPROC_EMIT_LIMIT)
- return;
-
- if (reset_active)
- return;
-
- if ( (! HAS_originalOptArgArray(pOpts))
- || (pOpts->originalOptArgCookie == NULL))
- ao_bug(zno_reset);
-
- if ((pzArg == NULL) || (*pzArg == NUL)) {
- fprintf(stderr, zreset_arg, pOpts->pzProgName, pOD->pz_Name);
- pOpts->pUsageProc(pOpts, EXIT_FAILURE);
- /* NOTREACHED */
- assert(0 == 1);
- }
-
- reset_active = true;
-
- if (pzArg[1] == NUL) {
- if (*pzArg == '*') {
- optionResetEverything(pOpts);
- reset_active = false;
- return;
- }
-
- succ = opt_find_short(pOpts, (uint8_t)*pzArg, &opt_state);
- if (! SUCCESSFUL(succ)) {
- fprintf(stderr, zIllOptChr, pOpts->pzProgPath, *pzArg);
- pOpts->pUsageProc(pOpts, EXIT_FAILURE);
- /* NOTREACHED */
- assert(0 == 1);
- }
- } else {
- succ = opt_find_long(pOpts, (char *)pzArg, &opt_state);
- if (! SUCCESSFUL(succ)) {
- fprintf(stderr, zIllOptStr, pOpts->pzProgPath, pzArg);
- pOpts->pUsageProc(pOpts, EXIT_FAILURE);
- /* NOTREACHED */
- assert(0 == 1);
- }
- }
-
- /*
- * We've found the indicated option. Turn off all non-persistent
- * flags because we're forcing the option back to its initialized state.
- * Call any callout procedure to handle whatever it needs to.
- * Finally, clear the reset flag, too.
- */
- optionReset(pOpts, opt_state.pOD);
- reset_active = false;
-}
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/reset.c */
diff --git a/src/libopts/restore.c b/src/libopts/restore.c
deleted file mode 100644
index 36ebbce1a7..0000000000
--- a/src/libopts/restore.c
+++ /dev/null
@@ -1,223 +0,0 @@
-
-/*
- * \file restore.c
- *
- * This module's routines will save the current option state to memory
- * and restore it. If saved prior to the initial optionProcess call,
- * then the initial state will be restored.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-/*
- * optionFixupSavedOpts Really, it just wipes out option state for
- * options that are troublesome to copy. viz., stacked strings and
- * hierarcicaly valued option args. We do duplicate string args that
- * have been marked as allocated though.
- */
-static void
-fixupSavedOptionArgs(tOptions * pOpts)
-{
- tOptions * p = pOpts->pSavedState;
- tOptDesc * pOD = pOpts->pOptDesc;
- int ct = pOpts->optCt;
-
- /*
- * Make sure that allocated stuff is only referenced in the
- * archived copy of the data.
- */
- for (; ct-- > 0; pOD++) {
- switch (OPTST_GET_ARGTYPE(pOD->fOptState)) {
- case OPARG_TYPE_STRING:
- if (pOD->fOptState & OPTST_STACKED) {
- tOptDesc * q = p->pOptDesc + (pOD - pOpts->pOptDesc);
- q->optCookie = NULL;
- }
- if (pOD->fOptState & OPTST_ALLOC_ARG) {
- tOptDesc * q = p->pOptDesc + (pOD - pOpts->pOptDesc);
- AGDUPSTR(q->optArg.argString, pOD->optArg.argString, "arg");
- }
- break;
-
- case OPARG_TYPE_HIERARCHY:
- {
- tOptDesc * q = p->pOptDesc + (pOD - pOpts->pOptDesc);
- q->optCookie = NULL;
- }
- }
- }
-}
-
-/*=export_func optionSaveState
- *
- * what: saves the option state to memory
- * arg: tOptions *, pOpts, program options descriptor
- *
- * doc:
- *
- * This routine will allocate enough memory to save the current option
- * processing state. If this routine has been called before, that memory
- * will be reused. You may only save one copy of the option state. This
- * routine may be called before optionProcess(3AO). If you do call it
- * before the first call to optionProcess, then you may also change the
- * contents of argc/argv after you call optionRestore(3AO)
- *
- * In fact, more strongly put: it is safest to only use this function
- * before having processed any options. In particular, the saving and
- * restoring of stacked string arguments and hierarchical values is
- * disabled. The values are not saved.
- *
- * err: If it fails to allocate the memory,
- * it will print a message to stderr and exit.
- * Otherwise, it will always succeed.
-=*/
-void
-optionSaveState(tOptions * pOpts)
-{
- tOptions * p = (tOptions *)pOpts->pSavedState;
-
- if (p == NULL) {
- size_t sz = sizeof(*pOpts)
- + ((size_t)pOpts->optCt * sizeof(tOptDesc));
- p = AGALOC(sz, "saved option state");
-
- pOpts->pSavedState = p;
- }
-
- memcpy(p, pOpts, sizeof(*p));
- memcpy(p + 1, pOpts->pOptDesc, (size_t)p->optCt * sizeof(tOptDesc));
-
- fixupSavedOptionArgs(pOpts);
-}
-
-
-/*=export_func optionRestore
- *
- * what: restore option state from memory copy
- * arg: tOptions *, pOpts, program options descriptor
- *
- * doc: Copy back the option state from saved memory.
- * The allocated memory is left intact, so this routine can be
- * called repeatedly without having to call optionSaveState again.
- * If you are restoring a state that was saved before the first call
- * to optionProcess(3AO), then you may change the contents of the
- * argc/argv parameters to optionProcess.
- *
- * err: If you have not called @code{optionSaveState} before, a diagnostic is
- * printed to @code{stderr} and exit is called.
-=*/
-void
-optionRestore(tOptions * pOpts)
-{
- tOptions * p = (tOptions *)pOpts->pSavedState;
-
- if (p == NULL) {
- char const * pzName = pOpts->pzProgName;
- if (pzName == NULL) {
- pzName = pOpts->pzPROGNAME;
- if (pzName == NULL)
- pzName = zNil;
- }
- fprintf(stderr, zNoState, pzName);
- option_exits(EXIT_FAILURE);
- }
-
- pOpts->pSavedState = NULL;
- optionFree(pOpts);
-
- memcpy(pOpts, p, sizeof(*p));
- memcpy(pOpts->pOptDesc, p+1, (size_t)p->optCt * sizeof(tOptDesc));
- pOpts->pSavedState = p;
-
- fixupSavedOptionArgs(pOpts);
-}
-
-/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
-
-/*=export_func optionFree
- *
- * what: free allocated option processing memory
- * arg: tOptions *, pOpts, program options descriptor
- *
- * doc: AutoOpts sometimes allocates memory and puts pointers to it in the
- * option state structures. This routine deallocates all such memory.
- *
- * err: As long as memory has not been corrupted,
- * this routine is always successful.
-=*/
-void
-optionFree(tOptions * pOpts)
-{
- free_saved_state:
- {
- tOptDesc * p = pOpts->pOptDesc;
- int ct = pOpts->optCt;
- do {
- if (p->fOptState & OPTST_ALLOC_ARG) {
- AGFREE(p->optArg.argString);
- p->optArg.argString = NULL;
- p->fOptState &= ~OPTST_ALLOC_ARG;
- }
-
- switch (OPTST_GET_ARGTYPE(p->fOptState)) {
- case OPARG_TYPE_STRING:
-#ifdef WITH_LIBREGEX
- if ( (p->fOptState & OPTST_STACKED)
- && (p->optCookie != NULL)) {
- p->optArg.argString = ".*";
- optionUnstackArg(pOpts, p);
- }
-#else
- /* leak memory */;
-#endif
- break;
-
- case OPARG_TYPE_HIERARCHY:
- if (p->optCookie != NULL)
- unload_arg_list(p->optCookie);
- break;
- }
-
- p->optCookie = NULL;
- } while (p++, --ct > 0);
- }
- if (pOpts->pSavedState != NULL) {
- tOptions * p = (tOptions *)pOpts->pSavedState;
- memcpy(pOpts, p, sizeof(*p));
- memcpy(pOpts->pOptDesc, p+1, (size_t)p->optCt * sizeof(tOptDesc));
- AGFREE(pOpts->pSavedState);
- pOpts->pSavedState = NULL;
- goto free_saved_state;
- }
-}
-
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/restore.c */
diff --git a/src/libopts/save-flags.c b/src/libopts/save-flags.c
deleted file mode 100644
index d295170edb..0000000000
--- a/src/libopts/save-flags.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/* -*- buffer-read-only: t -*- vi: set ro:
- *
- * DO NOT EDIT THIS FILE (save-flags.c)
- *
- * It has been AutoGen-ed
- * From the definitions /tmp/.ag-ufBbQe/save-flags.def
- * and the template file str2enum
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name ``Bruce Korb'' nor the name of any other
- * contributor may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * str2enum IS PROVIDED BY Bruce Korb ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Bruce Korb OR ANY OTHER CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "save-flags.h"
-#include <sys/types.h>
-#ifndef MISSING_INTTYPES_H
-# include <inttypes.h>
-#endif
-
-typedef enum {
- SVFL_BNM_DEFAULT = 0,
- SVFL_BNM_USAGE = 1,
- SVFL_BNM_UPDATE = 2,
- SVFL_COUNT_BNM
-} save_flags_enum_t;
-
-static save_flags_enum_t
-find_save_flags_bnm(char const * str, size_t len);
-
-
-#include <sys/types.h>
-#include <string.h>
-#ifndef NUL
-#define NUL '\0'
-#endif
-
-/* ANSI-C code produced by gperf version 3.1 */
-/* Command-line: gperf save-flags.gp */
-/* Computed positions: -k'' */
-
-
-# if 0 /* gperf build options: */
-// %struct-type
-// %language=ANSI-C
-// %includes
-// %global-table
-// %omit-struct-type
-// %readonly-tables
-// %compare-strncmp
-//
-// %define slot-name svfl_name
-// %define hash-function-name save_flags_hash
-// %define lookup-function-name find_save_flags_name
-// %define word-array-name save_flags_table
-// %define initializer-suffix ,SVFL_COUNT_BNM
-//
-# endif
-
-#include "save-flags.h"
-typedef struct {
- char const * svfl_name;
- save_flags_enum_t svfl_id;
-} save_flags_map_t;
-#include <string.h>
-
-/* maximum key range = 3, duplicates = 0 */
-
-static unsigned int
-save_flags_hash (register const char *str, register size_t len)
-{
- (void)str;
- (void)len;
- return len;
-}
-
-static const save_flags_map_t save_flags_table[] =
- {
- {"",SVFL_COUNT_BNM}, {"",SVFL_COUNT_BNM},
- {"",SVFL_COUNT_BNM}, {"",SVFL_COUNT_BNM},
- {"",SVFL_COUNT_BNM},
- {"usage", SVFL_BNM_USAGE},
- {"update", SVFL_BNM_UPDATE},
- {"default", SVFL_BNM_DEFAULT}
- };
-
-static inline const save_flags_map_t *
-find_save_flags_name (register const char *str, register size_t len)
-{
- if (len <= 7 && len >= 5)
- {
- register unsigned int key = (int)save_flags_hash (str, len);
-
- if (key <= 7)
- {
- register const char *s = save_flags_table[key].svfl_name;
-
- if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
- return &save_flags_table[key];
- }
- }
- return 0;
-}
-
-/**
- * Convert a command (keyword) to a save_flags_enum_t enumeration value.
- *
- * @param[in] str a string that should start with a known key word.
- * @param[in] len the provided length of the keyword at \a str.
- * @returns the enumeration value.
- * If not found, that value is SVFL_COUNT_BNM.
- */
-static save_flags_enum_t
-find_save_flags_bnm(char const * str, size_t len)
-{
- save_flags_map_t const * map;
-
- map = find_save_flags_name(str, (unsigned int)len);
- if (map != NULL)
- return map->svfl_id;
- /* Check for a partial match */
- {
- /*
- * Indexes of valid save_flags_table entries in sorted order:
- */
- static unsigned int const ix_map[] = {
- 7, 6, 5 };
- save_flags_enum_t res = SVFL_COUNT_BNM;
- static int const HI = (sizeof(ix_map) / sizeof(ix_map[0])) - 1;
- int lo = 0;
- int hi = HI;
- int av;
- int cmp;
-
- for (;;) {
- av = (hi + lo) / 2;
- map = save_flags_table + ix_map[av];
- cmp = strncmp(map->svfl_name, str, len);
- if (cmp == 0) break;
- if (cmp > 0)
- hi = av - 1;
- else lo = av + 1;
- if (lo > hi)
- return SVFL_COUNT_BNM;
- }
- res = map->svfl_id;
- /*
- * If we have an exact match, accept it.
- */
- if (map->svfl_name[len] == NUL)
- return res;
- /*
- * Check for a duplicate partial match (a partial match
- * with a higher or lower index than "av".
- */
- if (av < HI) {
- map = save_flags_table + ix_map[av + 1];
- if (strncmp(map->svfl_name, str, len) == 0)
- return SVFL_COUNT_BNM;
- }
- if (av > 0) {
- map = save_flags_table + ix_map[av - 1];
- if (strncmp(map->svfl_name, str, len) == 0)
- return SVFL_COUNT_BNM;
- }
- return res;
- }
-}
-
-/**
- * Convert a string to a save_flags_mask_t mask.
- * Bit names prefixed with a hyphen have the bit removed from the mask.
- * If the string starts with a '-', '+' or '|' character, then
- * the old value is used as a base, otherwise the result mask
- * is initialized to zero. Separating bit names with '+' or '|'
- * characters is optional. By default, the bits are "or"-ed into the
- * result.
- *
- * @param[in] str string with a list of bit names
- * @param[in] old previous value, used if \a str starts with a '+' or '-'.
- *
- * @returns an unsigned integer with the bits set.
- */
-save_flags_mask_t
-save_flags_str2mask(char const * str, save_flags_mask_t old)
-{
- static char const white[] = ", \t\f";
- static char const name_chars[] =
- "adefglpstu"
- "ADEFGLPSTU";
-
- save_flags_mask_t res = 0;
- int have_data = 0;
-
- for (;;) {
- save_flags_enum_t val;
- unsigned int val_len;
- unsigned int invert = 0;
-
- str += strspn(str, white);
- switch (*str) {
- case NUL: return res;
- case '-': case '~':
- invert = 1;
- /* FALLTHROUGH */
-
- case '+': case '|':
- if (have_data == 0)
- res = old;
-
- str += 1 + strspn(str + 1, white);
- if (*str == NUL)
- return 0;
- }
-
- val_len = strspn(str, name_chars);
- if (val_len == 0)
- return 0;
- val = find_save_flags_bnm(str, val_len);
- if (val == SVFL_COUNT_BNM)
- return 0;
- if (invert)
- res &= ~((save_flags_mask_t)1 << val);
- else
- res |= (save_flags_mask_t)1 << val;
- have_data = 1;
- str += val_len;
- }
-}
-/* end of save-flags.c */
diff --git a/src/libopts/save-flags.h b/src/libopts/save-flags.h
deleted file mode 100644
index dcfe0c9ae5..0000000000
--- a/src/libopts/save-flags.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- buffer-read-only: t -*- vi: set ro:
- *
- * DO NOT EDIT THIS FILE (save-flags.h)
- *
- * It has been AutoGen-ed
- * From the definitions /tmp/.ag-ufBbQe/save-flags.def
- * and the template file str2enum
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name ``Bruce Korb'' nor the name of any other
- * contributor may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * str2enum IS PROVIDED BY Bruce Korb ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Bruce Korb OR ANY OTHER CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Command/Keyword Dispatcher
- */
-#ifndef STR2ENUM_SAVE_FLAGS_H_GUARD
-#define STR2ENUM_SAVE_FLAGS_H_GUARD 1
-#include <sys/types.h>
-#include <inttypes.h>
-
-/** integral type for holding save_flags masks */
-typedef uint32_t save_flags_mask_t;
-
-/** bits defined for save_flags_mask_t */
-/** include default values in commentary */
-#define SVFL_DEFAULT 0x0001U
-/** include usage text in commentary */
-#define SVFL_USAGE 0x0002U
-/** replace or append state */
-#define SVFL_UPDATE 0x0004U
-
-/** bits in USAGE_DEFAULT mask:
- * usage default */
-#define SVFL_USAGE_DEFAULT_MASK 0x0003U
-
-/** all bits in save_flags_mask_t masks */
-#define SVFL_MASK_ALL 0x0007U
-
-/** no bits in save_flags_mask_t */
-#define SVFL_NONE 0x0000U
-
-/** buffer size needed to hold all bit names for save_flags_mask_t masks */
-#define MAX_SAVE_FLAGS_NAME_SIZE 21
-
-extern save_flags_mask_t
-save_flags_str2mask(char const * str, save_flags_mask_t old);
-
-#endif /* STR2ENUM_SAVE_FLAGS_H_GUARD */
-/* end of save-flags.h */
diff --git a/src/libopts/save.c b/src/libopts/save.c
deleted file mode 100644
index 8b1fba9d62..0000000000
--- a/src/libopts/save.c
+++ /dev/null
@@ -1,916 +0,0 @@
-
-/*
- * \file save.c
- *
- * This module's routines will take the currently set options and
- * store them into an ".rc" file for re-interpretation the next
- * time the invoking program is run.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-#include "save-flags.h"
-
-/**
- * find the config file directory name
- *
- * @param opts the options descriptor
- * @param p_free tell caller if name was allocated or not
- */
-static char const *
-find_dir_name(tOptions * opts, int * p_free)
-{
- char const * dir;
-
- if ( (opts->specOptIdx.save_opts == NO_EQUIVALENT)
- || (opts->specOptIdx.save_opts == 0))
- return NULL;
-
- dir = opts->pOptDesc[ opts->specOptIdx.save_opts ].optArg.argString;
- if ((dir != NULL) && (*dir != NUL)) {
- char const * pz = strchr(dir, '>');
- if (pz == NULL)
- return dir;
- while (*(++pz) == '>') ;
- pz += strspn(pz, " \t");
- dir = pz;
- if (*dir != NUL)
- return dir;
- }
-
- if (opts->papzHomeList == NULL)
- return NULL;
-
- /*
- * This function only works if there is a directory where
- * we can stash the RC (INI) file.
- */
- for (int idx = 0;; idx++) {
- char f_name[ AG_PATH_MAX+1 ];
-
- dir = opts->papzHomeList[idx];
-
- switch (*dir) {
- case '$':
- break;
- case NUL:
- continue;
- default:
- return dir;
- }
- if (optionMakePath(f_name, (int)sizeof(f_name), dir, opts->pzProgPath)) {
- *p_free = true;
- AGDUPSTR(dir, f_name, "homerc");
- return dir;
- }
- }
- return NULL;
-}
-
-/**
- * Find the name of the save-the-options file
- *
- * @param opts the options descriptor
- * @param p_free_name tell caller if name was allocated or not
- */
-static char const *
-find_file_name(tOptions * opts, int * p_free_name)
-{
- struct stat stBuf;
- int free_dir_name = 0;
-
- char const * res = find_dir_name(opts, &free_dir_name);
- if (res == NULL)
- return res;
-
- /*
- * See if we can find the specified directory. We use a once-only loop
- * structure so we can bail out early.
- */
- if (stat(res, &stBuf) != 0) do {
- char z[AG_PATH_MAX];
- char * dirchp;
-
- /*
- * IF we could not, check to see if we got a full
- * path to a file name that has not been created yet.
- */
- if (errno != ENOENT) {
- bogus_name:
- fprintf(stderr, zsave_warn, opts->pzProgName, res);
- fprintf(stderr, zNoStat, errno, strerror(errno), res);
- if (free_dir_name)
- AGFREE(res);
- return NULL;
- }
-
- /*
- * Strip off the last component, stat the remaining string and
- * that string must name a directory
- */
- dirchp = strrchr(res, DIRCH);
- if (dirchp == NULL) {
- stBuf.st_mode = S_IFREG;
- break; /* found directory -- viz., "." */
- }
-
- if ((size_t)(dirchp - res) >= sizeof(z))
- goto bogus_name;
-
- memcpy(z, res, (size_t)(dirchp - res));
- z[dirchp - res] = NUL;
-
- if ((stat(z, &stBuf) != 0) || ! S_ISDIR(stBuf.st_mode))
- goto bogus_name;
- stBuf.st_mode = S_IFREG; /* file within this directory */
- } while (false);
-
- /*
- * IF what we found was a directory,
- * THEN tack on the config file name
- */
- if (S_ISDIR(stBuf.st_mode)) {
-
- {
- size_t sz = strlen(res) + strlen(opts->pzRcName) + 2;
- char * pzPath = (char *)AGALOC(sz, "file name");
- if ( snprintf(pzPath, sz, "%s/%s", res, opts->pzRcName)
- >= (int)sz)
- option_exits(EXIT_FAILURE);
-
- if (free_dir_name)
- AGFREE(res);
- res = pzPath;
- free_dir_name = 1;
- }
-
- /*
- * IF we cannot stat the object for any reason other than
- * it does not exist, then we bail out
- */
- if (stat(res, &stBuf) != 0) {
- if (errno != ENOENT) {
- fprintf(stderr, zsave_warn, opts->pzProgName, res);
- fprintf(stderr, zNoStat, errno, strerror(errno),
- res);
- AGFREE(res);
- return NULL;
- }
-
- /*
- * It does not exist yet, but it will be a regular file
- */
- stBuf.st_mode = S_IFREG;
- }
- }
-
- /*
- * Make sure that whatever we ultimately found, that it either is
- * or will soon be a file.
- */
- if (! S_ISREG(stBuf.st_mode)) {
- fprintf(stderr, zsave_warn, opts->pzProgName, res);
- if (free_dir_name)
- AGFREE(res);
- return NULL;
- }
-
- /*
- * Get rid of the old file
- */
- *p_free_name = free_dir_name;
- return res;
-}
-
-/**
- * print one option entry to the save file.
- *
- * @param[in] fp the file pointer for the save file
- * @param[in] od the option descriptor to print
- * @param[in] l_arg the last argument for the option
- * @param[in] save_fl include usage in comments
- */
-static void
-prt_entry(FILE * fp, tOptDesc * od, char const * l_arg, save_flags_mask_t save_fl)
-{
- int space_ct;
-
- if (save_fl & SVFL_USAGE)
- fprintf(fp, ao_name_use_fmt, od->pz_Name, od->pzText);
- if (UNUSED_OPT(od) && (save_fl & SVFL_DEFAULT))
- fputs(ao_default_use, fp);
-
- /*
- * There is an argument. Pad the name so values line up.
- * Not disabled *OR* this got equivalenced to another opt,
- * then use current option name.
- * Otherwise, there must be a disablement name.
- */
- {
- char const * pz =
- (od->pz_DisableName == NULL)
- ? od->pz_Name
- : (DISABLED_OPT(od)
- ? od->pz_DisableName
- : ((od->optEquivIndex == NO_EQUIVALENT)
- ? od->pz_Name : od->pz_DisableName)
- );
-
- space_ct = 17 - strlen(pz);
- fputs(pz, fp);
- }
-
- if ( (l_arg == NULL)
- && (OPTST_GET_ARGTYPE(od->fOptState) != OPARG_TYPE_NUMERIC))
- goto end_entry;
-
- fputs(" = ", fp);
- while (space_ct-- > 0) fputc(' ', fp);
-
- /*
- * IF the option is numeric only,
- * THEN the char pointer is really the number
- */
- if (OPTST_GET_ARGTYPE(od->fOptState) == OPARG_TYPE_NUMERIC)
- fprintf(fp, "%d", (int)(intptr_t)l_arg);
-
- else {
- for (;;) {
- char const * eol = strchr(l_arg, NL);
-
- /*
- * IF this is the last line
- * THEN bail and print it
- */
- if (eol == NULL)
- break;
-
- /*
- * Print the continuation and the text from the current line
- */
- (void)fwrite(l_arg, (size_t)(eol - l_arg), (size_t)1, fp);
- l_arg = eol+1; /* advance the Last Arg pointer */
- fputs("\\\n", fp);
- }
-
- /*
- * Terminate the entry
- */
- fputs(l_arg, fp);
- }
-
-end_entry:
- fputc(NL, fp);
-}
-
-/**
- * print an option's value
- *
- * @param[in] fp the file pointer for the save file
- * @param[in] od the option descriptor to print
- */
-static void
-prt_value(FILE * fp, int depth, tOptDesc * od, tOptionValue const * ovp)
-{
- while (--depth >= 0)
- putc(' ', fp), putc(' ', fp);
-
- switch (ovp->valType) {
- default:
- case OPARG_TYPE_NONE:
- fprintf(fp, NULL_ATR_FMT, ovp->pzName);
- break;
-
- case OPARG_TYPE_STRING:
- prt_string(fp, ovp->pzName, ovp->v.strVal);
- break;
-
- case OPARG_TYPE_ENUMERATION:
- case OPARG_TYPE_MEMBERSHIP:
- if (od != NULL) {
- uint32_t opt_state = od->fOptState;
- uintptr_t val = od->optArg.argEnum;
- char const * typ = (ovp->valType == OPARG_TYPE_ENUMERATION)
- ? "keyword" : "set-membership";
-
- fprintf(fp, TYPE_ATR_FMT, ovp->pzName, typ);
-
- /*
- * This is a magic incantation that will convert the
- * bit flag values back into a string suitable for printing.
- */
- (*(od->pOptProc))(OPTPROC_RETURN_VALNAME, od );
- if (od->optArg.argString != NULL) {
- fputs(od->optArg.argString, fp);
-
- if (ovp->valType != OPARG_TYPE_ENUMERATION) {
- /*
- * set membership strings get allocated
- */
- AGFREE(od->optArg.argString);
- }
- }
-
- od->optArg.argEnum = val;
- od->fOptState = opt_state;
- fprintf(fp, END_XML_FMT, ovp->pzName);
- break;
- }
- /* FALLTHROUGH */
-
- case OPARG_TYPE_NUMERIC:
- fprintf(fp, NUMB_ATR_FMT, ovp->pzName, ovp->v.longVal);
- break;
-
- case OPARG_TYPE_BOOLEAN:
- fprintf(fp, BOOL_ATR_FMT, ovp->pzName,
- ovp->v.boolVal ? "true" : "false");
- break;
-
- case OPARG_TYPE_HIERARCHY:
- prt_val_list(fp, ovp->pzName, ovp->v.nestVal);
- break;
- }
-}
-
-/**
- * Print a string value in XML format
- *
- * @param[in] fp the file pointer for the save file
- */
-static void
-prt_string(FILE * fp, char const * name, char const * pz)
-{
- fprintf(fp, OPEN_XML_FMT, name);
- for (;;) {
- int ch = ((int)*(pz++)) & 0xFF;
-
- switch (ch) {
- case NUL: goto string_done;
-
- case '&':
- case '<':
- case '>':
-#if __GNUC__ >= 4
- case 1 ... (' ' - 1):
- case ('~' + 1) ... 0xFF:
-#endif
- emit_special_char(fp, ch);
- break;
-
- default:
-#if __GNUC__ < 4
- if ( ((ch >= 1) && (ch <= (' ' - 1)))
- || ((ch >= ('~' + 1)) && (ch <= 0xFF)) ) {
- emit_special_char(fp, ch);
- break;
- }
-#endif
- putc(ch, fp);
- }
- } string_done:;
- fprintf(fp, END_XML_FMT, name);
-}
-
-/**
- * Print an option that can have multiple values in XML format
- *
- * @param[in] fp file pointer
- */
-static void
-prt_val_list(FILE * fp, char const * name, tArgList * al)
-{
- static int depth = 1;
-
- int sp_ct;
- int opt_ct;
- void ** opt_list;
-
- if (al == NULL)
- return;
- opt_ct = al->useCt;
- opt_list = (void **)al->apzArgs;
-
- if (opt_ct <= 0) {
- fprintf(fp, OPEN_CLOSE_FMT, name);
- return;
- }
-
- fprintf(fp, NESTED_OPT_FMT, name);
-
- depth++;
- while (--opt_ct >= 0) {
- tOptionValue const * ovp = *(opt_list++);
-
- prt_value(fp, depth, NULL, ovp);
- }
- depth--;
-
- for (sp_ct = depth; --sp_ct >= 0;)
- putc(' ', fp), putc(' ', fp);
- fprintf(fp, "</%s>\n", name);
-}
-
-/**
- * printed a nested/hierarchical value
- *
- * @param[in] fp file pointer
- * @param[in] od option descriptor
- * @param[in] save_fl include usage in comments
- */
-static void
-prt_nested(FILE * fp, tOptDesc * od, save_flags_mask_t save_fl)
-{
- int opt_ct;
- tArgList * al = od->optCookie;
- void ** opt_list;
-
- if (save_fl & SVFL_USAGE)
- fprintf(fp, ao_name_use_fmt, od->pz_Name, od->pzText);
-
- /*
- * Never show a default value if a hierarchical value is empty.
- */
- if (UNUSED_OPT(od) || (al == NULL))
- return;
-
- opt_ct = al->useCt;
- opt_list = (void **)al->apzArgs;
-
- if (opt_ct <= 0)
- return;
-
- do {
- tOptionValue const * base = *(opt_list++);
- tOptionValue const * ovp = optionGetValue(base, NULL);
-
- if (ovp == NULL)
- continue;
-
- fprintf(fp, NESTED_OPT_FMT, od->pz_Name);
-
- do {
- prt_value(fp, 1, od, ovp);
-
- } while (ovp = optionNextValue(base, ovp),
- ovp != NULL);
-
- fprintf(fp, "</%s>\n", od->pz_Name);
- } while (--opt_ct > 0);
-}
-
-/**
- * remove the current program settings
- *
- * @param[in] opts the program options structure
- * @param[in] fname the save file name
- */
-static void
-remove_settings(tOptions * opts, char const * fname)
-{
- size_t const name_len = strlen(opts->pzProgName);
- tmap_info_t map_info;
- char * text = text_mmap(fname, PROT_READ|PROT_WRITE, MAP_PRIVATE, &map_info);
- char * scan = text;
-
- for (;;) {
- char * next = scan = strstr(scan, zCfgProg);
- if (scan == NULL)
- goto leave;
-
- scan = SPN_WHITESPACE_CHARS(scan + zCfgProg_LEN);
- if ( (strneqvcmp(scan, opts->pzProgName, (int)name_len) == 0)
- && (IS_END_XML_TOKEN_CHAR(scan[name_len])) ) {
-
- scan = next;
- break;
- }
- }
-
- /*
- * If not NULL, "scan" points to the "<?program" string introducing
- * the program segment we are to remove. See if another segment follows.
- * If so, copy text. If not se trim off this segment.
- */
- {
- char * next = strstr(scan + zCfgProg_LEN, zCfgProg);
- size_t new_sz;
-
- if (next == NULL)
- new_sz = map_info.txt_size - strlen(scan);
- else {
- int fd = open(fname, O_RDWR);
- if (fd < 0) return;
- if (lseek(fd, (scan - text), SEEK_SET) < 0)
- scan = next;
- else if (write(fd, next, strlen(next)) < 0)
- scan = next;
- if (close(fd) < 0)
- scan = next;
- new_sz = map_info.txt_size - (next - scan);
- }
- if (new_sz != map_info.txt_size)
- if (truncate(fname, new_sz) < 0)
- scan = next; // we removed it, so shorten file
- }
-
- leave:
- text_munmap(&map_info);
-}
-
-/**
- * open the file for saving option state.
- *
- * @param[in] opts the program options structure
- * @param[in] save_fl flags for saving data
- * @returns the open file pointer. It may be NULL.
- */
-static FILE *
-open_sv_file(tOptions * opts, save_flags_mask_t save_fl)
-{
- FILE * fp;
-
- {
- int free_name = 0;
- char const * fname = find_file_name(opts, &free_name);
- if (fname == NULL)
- return NULL;
-
- if (save_fl == 0)
- unlink(fname);
- else
- remove_settings(opts, fname);
-
- fp = fopen(fname, "a" FOPEN_BINARY_FLAG);
- if (fp == NULL) {
- fprintf(stderr, zsave_warn, opts->pzProgName, fname);
- fprintf(stderr, zNoCreat, errno, strerror(errno), fname);
- if (free_name)
- AGFREE(fname);
- return fp;
- }
-
- if (free_name)
- AGFREE(fname);
- }
-
- do {
- struct stat sbuf;
- if (fstat(fileno(fp), &sbuf) < 0)
- break;
-
- if (sbuf.st_size > zPresetFile_LEN) {
- /* non-zero size implies save_fl is non-zero */
- fprintf(fp, zFmtProg, opts->pzProgName);
- return fp;
- }
- } while (false);
-
- /*
- * We have a new file. Insert a header
- */
- fputs("# ", fp);
- {
- char const * e = strchr(opts->pzUsageTitle, NL);
- if (e++ != NULL)
- fwrite(opts->pzUsageTitle, 1, e - opts->pzUsageTitle, fp);
- }
-
- {
- time_t cur_time = time(NULL);
- char * time_str = ctime(&cur_time);
-
- fprintf(fp, zPresetFile, time_str);
-#ifdef HAVE_ALLOCATED_CTIME
- /*
- * The return values for ctime(), localtime(), and gmtime()
- * normally point to static data that is overwritten by each call.
- * The test to detect allocated ctime, so we leak the memory.
- */
- AGFREE(time_str);
-#endif
- }
- if (save_fl != 0)
- fprintf(fp, zFmtProg, opts->pzProgName);
- return fp;
-}
-
-/**
- * print option without an arg
- *
- * @param[in] fp file pointer
- * @param[in] vod value option descriptor
- * @param[in] pod primary option descriptor
- * @param[in] save_fl include usage in comments
- */
-static void
-prt_no_arg_opt(FILE * fp, tOptDesc * vod, tOptDesc * pod, save_flags_mask_t save_fl)
-{
- /*
- * The aliased to argument indicates whether or not the option
- * is "disabled". However, the original option has the name
- * string, so we get that there, not with "vod".
- */
- char const * pznm =
- (DISABLED_OPT(vod)) ? pod->pz_DisableName : pod->pz_Name;
- /*
- * If the option was disabled and the disablement name is NULL,
- * then the disablement was caused by aliasing.
- * Use the name as the string to emit.
- */
- if (pznm == NULL)
- pznm = pod->pz_Name;
-
- if (save_fl & SVFL_USAGE)
- fprintf(fp, ao_name_use_fmt, pod->pz_Name, pod->pzText);
- if (UNUSED_OPT(pod) && (save_fl & SVFL_DEFAULT))
- fputs(ao_default_use, fp);
-
- fprintf(fp, "%s\n", pznm);
-}
-
-/**
- * print the string valued argument(s).
- *
- * @param[in] fp file pointer
- * @param[in] od value option descriptor
- * @param[in] save_fl include usage in comments
- */
-static void
-prt_str_arg(FILE * fp, tOptDesc * od, save_flags_mask_t save_fl)
-{
- if (UNUSED_OPT(od) || ((od->fOptState & OPTST_STACKED) == 0)) {
- char const * arg = od->optArg.argString;
- if (arg == NULL)
- arg = "''";
- prt_entry(fp, od, arg, save_fl);
-
- } else {
- tArgList * pAL = (tArgList *)od->optCookie;
- int uct = pAL->useCt;
- char const ** ppz = pAL->apzArgs;
-
- /*
- * un-disable multiple copies of disabled options.
- */
- if (uct > 1)
- od->fOptState &= ~OPTST_DISABLED;
-
- while (uct-- > 0) {
- prt_entry(fp, od, *(ppz++), save_fl);
- save_fl &= ~SVFL_USAGE;
- }
- }
-}
-
-/**
- * print the string value of an enumeration.
- *
- * @param[in] fp the file pointer to write to
- * @param[in] od the option descriptor with the enumerated value
- * @param[in] save_fl include usage in comments
- */
-static void
-prt_enum_arg(FILE * fp, tOptDesc * od, save_flags_mask_t save_fl)
-{
- uintptr_t val = od->optArg.argEnum;
-
- /*
- * This is a magic incantation that will convert the
- * bit flag values back into a string suitable for printing.
- */
- (*(od->pOptProc))(OPTPROC_RETURN_VALNAME, od);
- prt_entry(fp, od, VOIDP(od->optArg.argString), save_fl);
-
- od->optArg.argEnum = val;
-}
-
-/**
- * Print the bits set in a bit mask option.
- *
- * We call the option handling function with a magic value for
- * the options pointer and it allocates and fills in the string.
- * We print that with a call to prt_entry().
- *
- * @param[in] fp the file pointer to write to
- * @param[in] od the option descriptor with a bit mask value type
- * @param[in] save_fl include usage in comments
- */
-static void
-prt_set_arg(FILE * fp, tOptDesc * od, save_flags_mask_t save_fl)
-{
- char * list = optionMemberList(od);
- size_t len = strlen(list);
- char * buf = (char *)AGALOC(len + 3, "dir name");
- *buf= '=';
- memcpy(buf+1, list, len + 1);
- prt_entry(fp, od, buf, save_fl);
- AGFREE(buf);
- AGFREE(list);
-}
-
-/**
- * figure out what the option file name argument is.
- * If one can be found, call prt_entry() to emit it.
- *
- * @param[in] fp the file pointer to write to.
- * @param[in] od the option descriptor with a bit mask value type
- * @param[in] opts the program options descriptor
- * @param[in] save_fl include usage in comments
- */
-static void
-prt_file_arg(FILE * fp, tOptDesc * od, tOptions * opts, save_flags_mask_t save_fl)
-{
- /*
- * If the cookie is not NULL, then it has the file name, period.
- * Otherwise, if we have a non-NULL string argument, then....
- */
- if (od->optCookie != NULL)
- prt_entry(fp, od, od->optCookie, save_fl);
-
- else if (HAS_originalOptArgArray(opts)) {
- char const * orig =
- opts->originalOptArgArray[od->optIndex].argString;
-
- if (od->optArg.argString == orig) {
- if (save_fl)
- fprintf(fp, ao_name_use_fmt, od->pz_Name, od->pzText);
- return;
- }
-
- prt_entry(fp, od, od->optArg.argString, save_fl);
-
- } else if (save_fl)
- fprintf(fp, ao_name_use_fmt, od->pz_Name, od->pzText);
-}
-
-/*=export_func optionSaveFile
- *
- * what: saves the option state to a file
- *
- * arg: tOptions *, opts, program options descriptor
- *
- * doc:
- *
- * This routine will save the state of option processing to a file. The name
- * of that file can be specified with the argument to the @code{--save-opts}
- * option, or by appending the @code{rcfile} attribute to the last
- * @code{homerc} attribute. If no @code{rcfile} attribute was specified, it
- * will default to @code{.@i{programname}rc}. If you wish to specify another
- * file, you should invoke the @code{SET_OPT_SAVE_OPTS(@i{filename})} macro.
- *
- * The recommend usage is as follows:
- * @example
- * optionProcess(&progOptions, argc, argv);
- * if (i_want_a_non_standard_place_for_this)
- * SET_OPT_SAVE_OPTS("myfilename");
- * optionSaveFile(&progOptions);
- * @end example
- *
- * err:
- *
- * If no @code{homerc} file was specified, this routine will silently return
- * and do nothing. If the output file cannot be created or updated, a message
- * will be printed to @code{stderr} and the routine will return.
-=*/
-void
-optionSaveFile(tOptions * opts)
-{
- tOptDesc * od;
- int ct;
- FILE * fp;
- save_flags_mask_t save_flags = SVFL_NONE;
-
- do {
- char * temp_str;
- char const * dir = opts->pOptDesc[ opts->specOptIdx.save_opts ].optArg.argString;
- size_t flen;
-
- if (dir == NULL)
- break;
- temp_str = strchr(dir, '>');
- if (temp_str == NULL)
- break;
- if (temp_str[1] == '>')
- save_flags = SVFL_UPDATE;
- flen = (temp_str - dir);
- if (flen == 0)
- break;
- temp_str = AGALOC(flen + 1, "flag search str");
- memcpy(temp_str, dir, flen);
- temp_str[flen] = NUL;
- save_flags |= save_flags_str2mask(temp_str, SVFL_NONE);
- AGFREE(temp_str);
- } while (false);
-
- fp = open_sv_file(opts, save_flags & SVFL_UPDATE);
- if (fp == NULL)
- return;
-
- /*
- * FOR each of the defined options, ...
- */
- ct = opts->presetOptCt;
- od = opts->pOptDesc;
- do {
- tOptDesc * vod;
-
- /*
- * Equivalenced options get picked up when the equivalenced-to
- * option is processed. And do not save options with any state
- * bits in the DO_NOT_SAVE collection
- *
- * ** option cannot be preset
- * #define OPTST_NO_INIT 0x0000100U
- * ** disable from cmd line
- * #define OPTST_NO_COMMAND 0x2000000U
- * ** alias for other option
- * #define OPTST_ALIAS 0x8000000U
- */
- if ((od->fOptState & OPTST_DO_NOT_SAVE_MASK) != 0)
- continue;
-
- if ( (od->optEquivIndex != NO_EQUIVALENT)
- && (od->optEquivIndex != od->optIndex))
- continue;
-
- if (UNUSED_OPT(od) && ((save_flags & SVFL_USAGE_DEFAULT_MASK) == SVFL_NONE))
- continue;
-
- /*
- * The option argument data are found at the equivalenced-to option,
- * but the actual option argument type comes from the original
- * option descriptor. Be careful!
- */
- vod = ((od->fOptState & OPTST_EQUIVALENCE) != 0)
- ? (opts->pOptDesc + od->optActualIndex) : od;
-
- switch (OPTST_GET_ARGTYPE(od->fOptState)) {
- case OPARG_TYPE_NONE:
- prt_no_arg_opt(fp, vod, od, save_flags);
- break;
-
- case OPARG_TYPE_NUMERIC:
- prt_entry(fp, vod, VOIDP(vod->optArg.argInt), save_flags);
- break;
-
- case OPARG_TYPE_STRING:
- prt_str_arg(fp, vod, save_flags);
- break;
-
- case OPARG_TYPE_ENUMERATION:
- prt_enum_arg(fp, vod, save_flags);
- break;
-
- case OPARG_TYPE_MEMBERSHIP:
- prt_set_arg(fp, vod, save_flags);
- break;
-
- case OPARG_TYPE_BOOLEAN:
- prt_entry(fp, vod, vod->optArg.argBool ? "true" : "false", save_flags);
- break;
-
- case OPARG_TYPE_HIERARCHY:
- prt_nested(fp, vod, save_flags);
- break;
-
- case OPARG_TYPE_FILE:
- prt_file_arg(fp, vod, opts, save_flags);
- break;
-
- default:
- break; /* cannot handle - skip it */
- }
- } while (od++, (--ct > 0));
-
- fclose(fp);
-}
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/save.c */
diff --git a/src/libopts/sort.c b/src/libopts/sort.c
deleted file mode 100644
index b4bd5cb7e2..0000000000
--- a/src/libopts/sort.c
+++ /dev/null
@@ -1,326 +0,0 @@
-
-/*
- * \file sort.c
- *
- * This module implements argument sorting.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-/*
- * "must_arg" and "maybe_arg" are really similar. The biggest
- * difference is that "may" will consume the next argument only if it
- * does not start with a hyphen and "must" will consume it, hyphen or not.
- */
-static tSuccess
-must_arg(tOptions * opts, char * arg_txt, tOptState * pOS,
- char ** opt_txt, uint32_t * opt_idx)
-{
- /*
- * An option argument is required. Long options can either have
- * a separate command line argument, or an argument attached by
- * the '=' character. Figure out which.
- */
- switch (pOS->optType) {
- case TOPT_SHORT:
- /*
- * See if an arg string follows the flag character. If not,
- * the next arg must be the option argument.
- */
- if (*arg_txt != NUL)
- return SUCCESS;
- break;
-
- case TOPT_LONG:
- /*
- * See if an arg string has already been assigned (glued on
- * with an `=' character). If not, the next is the opt arg.
- */
- if (pOS->pzOptArg != NULL)
- return SUCCESS;
- break;
-
- default:
- return FAILURE;
- }
- if (opts->curOptIdx >= opts->origArgCt)
- return FAILURE;
-
- opt_txt[ (*opt_idx)++ ] = opts->origArgVect[ (opts->curOptIdx)++ ];
- return SUCCESS;
-}
-
-static tSuccess
-maybe_arg(tOptions * opts, char * arg_txt, tOptState * pOS,
- char ** opt_txt, uint32_t * opt_idx)
-{
- /*
- * An option argument is optional.
- */
- switch (pOS->optType) {
- case TOPT_SHORT:
- /*
- * IF nothing is glued on after the current flag character,
- * THEN see if there is another argument. If so and if it
- * does *NOT* start with a hyphen, then it is the option arg.
- */
- if (*arg_txt != NUL)
- return SUCCESS;
- break;
-
- case TOPT_LONG:
- /*
- * Look for an argument if we don't already have one (glued on
- * with a `=' character)
- */
- if (pOS->pzOptArg != NULL)
- return SUCCESS;
- break;
-
- default:
- return FAILURE;
- }
- if (opts->curOptIdx >= opts->origArgCt)
- return PROBLEM;
-
- arg_txt = opts->origArgVect[ opts->curOptIdx ];
- if (*arg_txt != '-')
- opt_txt[ (*opt_idx)++ ] = opts->origArgVect[ (opts->curOptIdx)++ ];
- return SUCCESS;
-}
-
-/*
- * Process a string of short options glued together. If the last one
- * does or may take an argument, the do the argument processing and leave.
- */
-static tSuccess
-short_opt_ck(tOptions * opts, char * arg_txt, tOptState * pOS,
- char ** opt_txt, uint32_t * opt_idx)
-{
- while (*arg_txt != NUL) {
- if (FAILED(opt_find_short(opts, (uint8_t)*arg_txt, pOS)))
- return FAILURE;
-
- /*
- * See if we can have an arg.
- */
- if (OPTST_GET_ARGTYPE(pOS->pOD->fOptState) == OPARG_TYPE_NONE) {
- arg_txt++;
-
- } else if (pOS->pOD->fOptState & OPTST_ARG_OPTIONAL) {
- /*
- * Take an argument if it is not attached and it does not
- * start with a hyphen.
- */
- if (arg_txt[1] != NUL)
- return SUCCESS;
-
- arg_txt = opts->origArgVect[ opts->curOptIdx ];
- if (*arg_txt != '-')
- opt_txt[ (*opt_idx)++ ] =
- opts->origArgVect[ (opts->curOptIdx)++ ];
- return SUCCESS;
-
- } else {
- /*
- * IF we need another argument, be sure it is there and
- * take it.
- */
- if (arg_txt[1] == NUL) {
- if (opts->curOptIdx >= opts->origArgCt)
- return FAILURE;
- opt_txt[ (*opt_idx)++ ] =
- opts->origArgVect[ (opts->curOptIdx)++ ];
- }
- return SUCCESS;
- }
- }
- return SUCCESS;
-}
-
-/*
- * If the program wants sorted options (separated operands and options),
- * then this routine will to the trick.
- */
-static void
-optionSort(tOptions * opts)
-{
- char ** opt_txt;
- char ** ppzOpds;
- uint32_t optsIdx = 0;
- uint32_t opdsIdx = 0;
-
- tOptState os = OPTSTATE_INITIALIZER(DEFINED);
-
- /*
- * Disable for POSIX conformance, or if there are no operands.
- */
- if ( (getenv("POSIXLY_CORRECT") != NULL)
- || NAMED_OPTS(opts))
- return;
-
- /*
- * Make sure we can allocate two full-sized arg vectors.
- */
- opt_txt = malloc(opts->origArgCt * sizeof(char *));
- if (opt_txt == NULL)
- goto exit_no_mem;
-
- ppzOpds = malloc(opts->origArgCt * sizeof(char *));
- if (ppzOpds == NULL) {
- free(opt_txt);
- goto exit_no_mem;
- }
-
- opts->curOptIdx = 1;
- opts->pzCurOpt = NULL;
-
- /*
- * Now, process all the options from our current position onward.
- * (This allows interspersed options and arguments for the few
- * non-standard programs that require it.)
- */
- for (;;) {
- char * arg_txt;
- tSuccess res;
-
- /*
- * If we're out of arguments, we're done. Join the option and
- * operand lists into the original argument vector.
- */
- if (opts->curOptIdx >= opts->origArgCt) {
- errno = 0;
- goto joinLists;
- }
-
- arg_txt = opts->origArgVect[ opts->curOptIdx ];
- if (*arg_txt != '-') {
- ppzOpds[ opdsIdx++ ] = opts->origArgVect[ (opts->curOptIdx)++ ];
- continue;
- }
-
- switch (arg_txt[1]) {
- case NUL:
- /*
- * A single hyphen is an operand.
- */
- ppzOpds[ opdsIdx++ ] = opts->origArgVect[ (opts->curOptIdx)++ ];
- continue;
-
- case '-':
- /*
- * Two consecutive hypens. Put them on the options list and then
- * _always_ force the remainder of the arguments to be operands.
- */
- if (arg_txt[2] == NUL) {
- opt_txt[ optsIdx++ ] =
- opts->origArgVect[ (opts->curOptIdx)++ ];
- goto restOperands;
- }
- res = opt_find_long(opts, arg_txt+2, &os);
- break;
-
- default:
- /*
- * If short options are not allowed, then do long
- * option processing. Otherwise the character must be a
- * short (i.e. single character) option.
- */
- if ((opts->fOptSet & OPTPROC_SHORTOPT) == 0) {
- res = opt_find_long(opts, arg_txt+1, &os);
- } else {
- res = opt_find_short(opts, (uint8_t)arg_txt[1], &os);
- }
- break;
- }
- if (FAILED(res)) {
- errno = EINVAL;
- goto freeTemps;
- }
-
- /*
- * We've found an option. Add the argument to the option list.
- * Next, we have to see if we need to pull another argument to be
- * used as the option argument.
- */
- opt_txt[ optsIdx++ ] = opts->origArgVect[ (opts->curOptIdx)++ ];
-
- if (OPTST_GET_ARGTYPE(os.pOD->fOptState) == OPARG_TYPE_NONE) {
- /*
- * No option argument. If we have a short option here,
- * then scan for short options until we get to the end
- * of the argument string.
- */
- if ( (os.optType == TOPT_SHORT)
- && FAILED(short_opt_ck(opts, arg_txt+2, &os, opt_txt,
- &optsIdx)) ) {
- errno = EINVAL;
- goto freeTemps;
- }
-
- } else if (os.pOD->fOptState & OPTST_ARG_OPTIONAL) {
- switch (maybe_arg(opts, arg_txt+2, &os, opt_txt, &optsIdx)) {
- case FAILURE: errno = EIO; goto freeTemps;
- case PROBLEM: errno = 0; goto joinLists;
- }
-
- } else {
- switch (must_arg(opts, arg_txt+2, &os, opt_txt, &optsIdx)) {
- case PROBLEM:
- case FAILURE: errno = EIO; goto freeTemps;
- }
- }
- } /* for (;;) */
-
- restOperands:
- while (opts->curOptIdx < opts->origArgCt)
- ppzOpds[ opdsIdx++ ] = opts->origArgVect[ (opts->curOptIdx)++ ];
-
- joinLists:
- if (optsIdx > 0)
- memcpy(opts->origArgVect + 1, opt_txt,
- (size_t)optsIdx * sizeof(char *));
- if (opdsIdx > 0)
- memcpy(opts->origArgVect + 1 + optsIdx, ppzOpds,
- (size_t)opdsIdx * sizeof(char *));
-
- freeTemps:
- free(opt_txt);
- free(ppzOpds);
- return;
-
- exit_no_mem:
- errno = ENOMEM;
- return;
-}
-
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/sort.c */
diff --git a/src/libopts/stack.c b/src/libopts/stack.c
deleted file mode 100644
index 39a328a85b..0000000000
--- a/src/libopts/stack.c
+++ /dev/null
@@ -1,267 +0,0 @@
-
-/**
- * \file stack.c
- *
- * This is a special option processing routine that will save the
- * argument to an option in a FIFO queue.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-#ifdef WITH_LIBREGEX
-# include REGEX_HEADER
-#endif
-
-/*=export_func optionUnstackArg
- * private:
- *
- * what: Remove option args from a stack
- * arg: + tOptions * + opts + program options descriptor +
- * arg: + tOptDesc * + od + the descriptor for this arg +
- *
- * doc:
- * Invoked for options that are equivalenced to stacked options.
-=*/
-void
-optionUnstackArg(tOptions * opts, tOptDesc * od)
-{
- tArgList * arg_list;
-
- if (INQUERY_CALL(opts, od))
- return;
-
- arg_list = (tArgList *)od->optCookie;
-
- /*
- * IF we don't have any stacked options,
- * THEN indicate that we don't have any of these options
- */
- if (arg_list == NULL) {
- od->fOptState &= OPTST_PERSISTENT_MASK;
- if ((od->fOptState & OPTST_INITENABLED) == 0)
- od->fOptState |= OPTST_DISABLED;
- return;
- }
-
-#ifdef WITH_LIBREGEX
- {
- regex_t re;
- int i, ct, dIdx;
-
- if (regcomp(&re, od->optArg.argString, REG_NOSUB) != 0)
- return;
-
- /*
- * search the list for the entry(s) to remove. Entries that
- * are removed are *not* copied into the result. The source
- * index is incremented every time. The destination only when
- * we are keeping a define.
- */
- for (i = 0, dIdx = 0, ct = arg_list->useCt; --ct >= 0; i++) {
- char const * pzSrc = arg_list->apzArgs[ i ];
- char * pzEq = strchr(pzSrc, '=');
- int res;
-
-
- if (pzEq != NULL)
- *pzEq = NUL;
-
- res = regexec(&re, pzSrc, (size_t)0, NULL, 0);
- switch (res) {
- case 0:
- /*
- * Remove this entry by reducing the in-use count
- * and *not* putting the string pointer back into
- * the list.
- */
- AGFREE(pzSrc);
- arg_list->useCt--;
- break;
-
- default:
- case REG_NOMATCH:
- if (pzEq != NULL)
- *pzEq = '=';
-
- /*
- * IF we have dropped an entry
- * THEN we have to move the current one.
- */
- if (dIdx != i)
- arg_list->apzArgs[ dIdx ] = pzSrc;
- dIdx++;
- }
- }
-
- regfree(&re);
- }
-#else /* not WITH_LIBREGEX */
- {
- int i, ct, dIdx;
-
- /*
- * search the list for the entry(s) to remove. Entries that
- * are removed are *not* copied into the result. The source
- * index is incremented every time. The destination only when
- * we are keeping a define.
- */
- for (i = 0, dIdx = 0, ct = arg_list->useCt; --ct >= 0; i++) {
- const char * pzSrc = arg_list->apzArgs[ i ];
- char * pzEq = strchr(pzSrc, '=');
-
- if (pzEq != NULL)
- *pzEq = NUL;
-
- if (strcmp(pzSrc, od->optArg.argString) == 0) {
- /*
- * Remove this entry by reducing the in-use count
- * and *not* putting the string pointer back into
- * the list.
- */
- AGFREE(pzSrc);
- arg_list->useCt--;
- } else {
- if (pzEq != NULL)
- *pzEq = '=';
-
- /*
- * IF we have dropped an entry
- * THEN we have to move the current one.
- */
- if (dIdx != i)
- arg_list->apzArgs[ dIdx ] = pzSrc;
- dIdx++;
- }
- }
- }
-#endif /* WITH_LIBREGEX */
- /*
- * IF we have unstacked everything,
- * THEN indicate that we don't have any of these options
- */
- if (arg_list->useCt == 0) {
- od->fOptState &= OPTST_PERSISTENT_MASK;
- if ((od->fOptState & OPTST_INITENABLED) == 0)
- od->fOptState |= OPTST_DISABLED;
- AGFREE(arg_list);
- od->optCookie = NULL;
- }
-}
-
-
-/*
- * Put an entry into an argument list. The first argument points to
- * a pointer to the argument list structure. It gets passed around
- * as an opaque address.
- */
-static void
-addArgListEntry(void ** ppAL, void * entry)
-{
- tArgList * pAL = *(void **)ppAL;
-
- /*
- * IF we have never allocated one of these,
- * THEN allocate one now
- */
- if (pAL == NULL) {
- pAL = (tArgList *)AGALOC(sizeof(*pAL), "new option arg stack");
- if (pAL == NULL)
- return;
- pAL->useCt = 0;
- pAL->allocCt = MIN_ARG_ALLOC_CT;
- *ppAL = VOIDP(pAL);
- }
-
- /*
- * ELSE if we are out of room
- * THEN make it bigger
- */
- else if (pAL->useCt >= pAL->allocCt) {
- size_t sz = sizeof(*pAL);
- pAL->allocCt += INCR_ARG_ALLOC_CT;
-
- /*
- * The base structure contains space for MIN_ARG_ALLOC_CT
- * pointers. We subtract it off to find our augment size.
- */
- sz += sizeof(char *) * ((size_t)pAL->allocCt - MIN_ARG_ALLOC_CT);
- pAL = (tArgList *)AGREALOC(VOIDP(pAL), sz, "expanded opt arg stack");
- if (pAL == NULL)
- return;
- *ppAL = VOIDP(pAL);
- }
-
- /*
- * Insert the new argument into the list
- */
- pAL->apzArgs[ (pAL->useCt)++ ] = entry;
-}
-
-
-/*=export_func optionStackArg
- * private:
- *
- * what: put option args on a stack
- * arg: + tOptions * + opts + program options descriptor +
- * arg: + tOptDesc * + od + the descriptor for this arg +
- *
- * doc:
- * Keep an entry-ordered list of option arguments.
-=*/
-void
-optionStackArg(tOptions * opts, tOptDesc * od)
-{
- char * pz;
-
- if (INQUERY_CALL(opts, od))
- return;
-
- if ((od->fOptState & OPTST_RESET) != 0) {
- tArgList * arg_list = od->optCookie;
- int ix;
- if (arg_list == NULL)
- return;
-
- ix = arg_list->useCt;
- while (--ix >= 0)
- AGFREE(arg_list->apzArgs[ix]);
- AGFREE(arg_list);
-
- } else {
- if (od->optArg.argString == NULL)
- return;
-
- AGDUPSTR(pz, od->optArg.argString, "stack arg");
- addArgListEntry(&(od->optCookie), VOIDP(pz));
- }
-}
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/stack.c */
diff --git a/src/libopts/stdnoreturn.in.h b/src/libopts/stdnoreturn.in.h
deleted file mode 100644
index bf46c0883e..0000000000
--- a/src/libopts/stdnoreturn.in.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* A substitute for ISO C11 <stdnoreturn.h>.
-
- Copyright 2012-2018 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1, 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Paul Eggert. */
-
-#ifndef noreturn
-
-/* ISO C11 <stdnoreturn.h> for platforms that lack it.
-
- References:
- ISO C11 (latest free draft
- <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf>)
- section 7.23 */
-
-/* The definition of _Noreturn is copied here. */
-
-#if 1200 <= _MSC_VER || defined __CYGWIN__
-/* On MSVC, standard include files contain declarations like
- __declspec (noreturn) void abort (void);
- "#define noreturn _Noreturn" would cause this declaration to be rewritten
- to the invalid
- __declspec (__declspec (noreturn)) void abort (void);
-
- Similarly, on Cygwin, standard include files contain declarations like
- void __cdecl abort (void) __attribute__ ((noreturn));
- "#define noreturn _Noreturn" would cause this declaration to be rewritten
- to the invalid
- void __cdecl abort (void) __attribute__ ((__attribute__ ((__noreturn__))));
-
- Instead, define noreturn to empty, so that such declarations are rewritten to
- __declspec () void abort (void);
- or
- void __cdecl abort (void) __attribute__ (());
- respectively. This gives up on noreturn's advice to the compiler but at
- least it is valid code. */
-# define noreturn /*empty*/
-#else
-# define noreturn _Noreturn
-#endif
-
-/* Did he ever return?
- No he never returned
- And his fate is still unlearn'd ...
- -- Steiner J, Hawes BL. M.T.A. (1949) */
-
-#endif /* noreturn */
diff --git a/src/libopts/streqvcmp.c b/src/libopts/streqvcmp.c
deleted file mode 100644
index 53477d65f9..0000000000
--- a/src/libopts/streqvcmp.c
+++ /dev/null
@@ -1,284 +0,0 @@
-
-/**
- * \file streqvcmp.c
- *
- * String Equivalence Comparison
- *
- * These routines allow any character to be mapped to any other
- * character before comparison. In processing long option names,
- * the characters "-", "_" and "^" all need to be equivalent
- * (because they are treated so by different development environments).
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- *
- * This array is designed for mapping upper and lower case letter
- * together for a case independent comparison. The mappings are
- * based upon ascii character sequences.
- */
- static unsigned char charmap[] = {
- NUL, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, '\a',
- '\b', '\t', NL, '\v', '\f', '\r', 0x0E, 0x0F,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
-
- ' ', '!', '"', '#', '$', '%', '&', '\'',
- '(', ')', '*', '+', ',', '-', '.', '/',
- '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', ':', ';', '<', '=', '>', '?',
-
- '@', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
- 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
- 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
- 'x', 'y', 'z', '[', '\\', ']', '^', '_',
- '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
- 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
- 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
- 'x', 'y', 'z', '{', '|', '}', '~', 0x7f,
-
- 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
- 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
- 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
- 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
- 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
- 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
- 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7,
- 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
-
- 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
- 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
- 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,
- 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
- 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
- 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
- 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
- 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF,
-};
-
-
-/*=export_func strneqvcmp
- *
- * what: compare two strings with an equivalence mapping
- *
- * arg: + char const * + str1 + first string +
- * arg: + char const * + str2 + second string +
- * arg: + int + ct + compare length +
- *
- * ret_type: int
- * ret_desc: the difference between two differing characters
- *
- * doc:
- *
- * Using a character mapping, two strings are compared for "equivalence".
- * Each input character is mapped to a comparison character and the
- * mapped-to characters are compared for the two NUL terminated input strings.
- * The comparison is limited to @code{ct} bytes.
- * This function name is mapped to option_strneqvcmp so as to not conflict
- * with the POSIX name space.
- *
- * err: none checked. Caller responsible for seg faults.
-=*/
-int
-strneqvcmp(char const * s1, char const * s2, int ct)
-{
- for (; ct > 0; --ct) {
- unsigned char u1 = (unsigned char) *s1++;
- unsigned char u2 = (unsigned char) *s2++;
- int dif;
- if (u1 == u2) {
- if (u1 == NUL)
- return 0;
- continue;
- }
-
- dif = charmap[ u1 ] - charmap[ u2 ];
-
- if (dif != 0)
- return dif;
-
- if (u1 == NUL)
- return 0;
- }
-
- return 0;
-}
-
-
-/*=export_func streqvcmp
- *
- * what: compare two strings with an equivalence mapping
- *
- * arg: + char const * + str1 + first string +
- * arg: + char const * + str2 + second string +
- *
- * ret_type: int
- * ret_desc: the difference between two differing characters
- *
- * doc:
- *
- * Using a character mapping, two strings are compared for "equivalence".
- * Each input character is mapped to a comparison character and the
- * mapped-to characters are compared for the two NUL terminated input strings.
- * This function name is mapped to option_streqvcmp so as to not conflict
- * with the POSIX name space.
- *
- * err: none checked. Caller responsible for seg faults.
-=*/
-int
-streqvcmp(char const * s1, char const * s2)
-{
- for (;;) {
- unsigned char u1 = (unsigned char) *s1++;
- unsigned char u2 = (unsigned char) *s2++;
- int dif;
- if (u1 == u2) {
- if (u1 == NUL)
- return 0;
- continue;
- }
-
- dif = charmap[ u1 ] - charmap[ u2 ];
-
- if (dif != 0)
- return dif;
-
- if (u1 == NUL)
- return 0;
- }
-}
-
-
-/*=export_func streqvmap
- *
- * what: Set the character mappings for the streqv functions
- *
- * arg: + char + from + Input character +
- * arg: + char + to + Mapped-to character +
- * arg: + int + ct + compare length +
- *
- * doc:
- *
- * Set the character mapping. If the count (@code{ct}) is set to zero, then
- * the map is cleared by setting all entries in the map to their index
- * value. Otherwise, the "@code{From}" character is mapped to the "@code{To}"
- * character. If @code{ct} is greater than 1, then @code{From} and @code{To}
- * are incremented and the process repeated until @code{ct} entries have been
- * set. For example,
- * @example
- * streqvmap('a', 'A', 26);
- * @end example
- * @noindent
- * will alter the mapping so that all English lower case letters
- * will map to upper case.
- *
- * This function name is mapped to option_streqvmap so as to not conflict
- * with the POSIX name space.
- *
- * err: none.
-=*/
-void
-streqvmap(char from, char to, int ct)
-{
- if (ct == 0) {
- ct = sizeof(charmap) - 1;
- do {
- charmap[ct] = (unsigned char)ct;
- } while (--ct >= 0);
- }
-
- else {
- unsigned int i_to = (int)to & 0xFF;
- unsigned int i_from = (int)from & 0xFF;
-
- do {
- charmap[i_from] = (unsigned char)i_to;
- i_from++;
- i_to++;
- if ((i_from >= sizeof(charmap)) || (i_to >= sizeof(charmap)))
- break;
- } while (--ct > 0);
- }
-}
-
-
-/*=export_func strequate
- *
- * what: map a list of characters to the same value
- *
- * arg: + char const * + ch_list + characters to equivalence +
- *
- * doc:
- *
- * Each character in the input string get mapped to the first character
- * in the string.
- * This function name is mapped to option_strequate so as to not conflict
- * with the POSIX name space.
- *
- * err: none.
-=*/
-void
-strequate(char const * s)
-{
- if ((s != NULL) && (*s != NUL)) {
- unsigned char equiv = (unsigned char)*s;
- while (*s != NUL)
- charmap[(unsigned char)*(s++)] = equiv;
- }
-}
-
-
-/*=export_func strtransform
- *
- * what: convert a string into its mapped-to value
- *
- * arg: + char * + dest + output string +
- * arg: + char const * + src + input string +
- *
- * doc:
- *
- * Each character in the input string is mapped and the mapped-to
- * character is put into the output.
- * This function name is mapped to option_strtransform so as to not conflict
- * with the POSIX name space.
- *
- * The source and destination may be the same.
- *
- * err: none.
-=*/
-void
-strtransform(char * d, char const * s)
-{
- do {
- *(d++) = (char)charmap[(unsigned char)*s];
- } while (*(s++) != NUL);
-}
-
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/streqvcmp.c */
diff --git a/src/libopts/text_mmap.c b/src/libopts/text_mmap.c
deleted file mode 100644
index 11093082e3..0000000000
--- a/src/libopts/text_mmap.c
+++ /dev/null
@@ -1,382 +0,0 @@
-/**
- * @file text_mmap.c
- *
- * Map a text file, ensuring the text always has an ending NUL byte.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-#if defined(HAVE_MMAP)
-# ifndef MAP_ANONYMOUS
-# ifdef MAP_ANON
-# define MAP_ANONYMOUS MAP_ANON
-# endif
-# endif
-
-# if ! defined(MAP_ANONYMOUS) && ! defined(HAVE_DEV_ZERO)
- /*
- * We must have either /dev/zero or anonymous mapping for
- * this to work.
- */
-# undef HAVE_MMAP
-
-# else
-# ifdef _SC_PAGESIZE
-# define GETPAGESIZE() sysconf(_SC_PAGESIZE)
-# else
-# define GETPAGESIZE() getpagesize()
-# endif
-# endif
-#endif
-
-/*
- * Some weird systems require that a specifically invalid FD number
- * get passed in as an argument value. Which value is that? Well,
- * as everybody knows, if open(2) fails, it returns -1, so that must
- * be the value. :)
- */
-#define AO_INVALID_FD -1
-
-#define FILE_WRITABLE(_prt,_flg) \
- ( (_prt & PROT_WRITE) \
- && ((_flg & (MAP_SHARED|MAP_PRIVATE)) == MAP_SHARED))
-#define MAP_FAILED_PTR (VOIDP(MAP_FAILED))
-
-/**
- * Load the contents of a text file. There are two separate implementations,
- * depending up on whether mmap(3) is available.
- *
- * If not available, malloc the file length plus one byte. Read it in
- * and NUL terminate.
- *
- * If available, first check to see if the text file size is a multiple of a
- * page size. If it is, map the file size plus an extra page from either
- * anonymous memory or from /dev/zero. Then map the file text on top of the
- * first pages of the anonymous/zero pages. Otherwise, just map the file
- * because there will be NUL bytes provided at the end.
- *
- * @param mapinfo a structure holding everything we need to know
- * about the mapping.
- *
- * @param pzFile name of the file, for error reporting.
- */
-static void
-load_text_file(tmap_info_t * mapinfo, char const * pzFile)
-{
-#if ! defined(HAVE_MMAP)
- mapinfo->txt_data = AGALOC(mapinfo->txt_size+1, "file text");
- if (mapinfo->txt_data == NULL) {
- mapinfo->txt_errno = ENOMEM;
- return;
- }
-
- {
- size_t sz = mapinfo->txt_size;
- char * pz = mapinfo->txt_data;
-
- while (sz > 0) {
- ssize_t rdct = read(mapinfo->txt_fd, pz, sz);
- if (rdct <= 0) {
- mapinfo->txt_errno = errno;
- fserr_warn("libopts", "read", pzFile);
- free(mapinfo->txt_data);
- return;
- }
-
- pz += rdct;
- sz -= rdct;
- }
-
- *pz = NUL;
- }
-
- mapinfo->txt_errno = 0;
-
-#else /* HAVE mmap */
- size_t const pgsz = (size_t)GETPAGESIZE();
- void * map_addr = NULL;
-
- (void)pzFile;
-
- mapinfo->txt_full_size = (mapinfo->txt_size + pgsz) & ~(pgsz - 1);
- if (mapinfo->txt_full_size == (mapinfo->txt_size + pgsz)) {
- /*
- * The text is a multiple of a page boundary. We must map an
- * extra page so the text ends with a NUL.
- */
-#if defined(MAP_ANONYMOUS)
- map_addr = mmap(NULL, mapinfo->txt_full_size, PROT_READ|PROT_WRITE,
- MAP_ANONYMOUS|MAP_PRIVATE, AO_INVALID_FD, 0);
-#else
- mapinfo->txt_zero_fd = open("/dev/zero", O_RDONLY);
-
- if (mapinfo->txt_zero_fd == AO_INVALID_FD) {
- mapinfo->txt_errno = errno;
- return;
- }
- map_addr = mmap(NULL, mapinfo->txt_full_size, PROT_READ|PROT_WRITE,
- MAP_PRIVATE, mapinfo->txt_zero_fd, 0);
-#endif
- if (map_addr == MAP_FAILED_PTR) {
- mapinfo->txt_errno = errno;
- return;
- }
- mapinfo->txt_flags |= MAP_FIXED;
- }
-
- mapinfo->txt_data =
- mmap(map_addr, mapinfo->txt_size, mapinfo->txt_prot,
- mapinfo->txt_flags, mapinfo->txt_fd, 0);
-
- if (mapinfo->txt_data == MAP_FAILED_PTR)
- mapinfo->txt_errno = errno;
-#endif /* HAVE_MMAP */
-}
-
-/**
- * Make sure all the parameters are correct: we have a file name that
- * is a text file that we can read.
- *
- * @param fname the text file to map
- * @param prot the memory protections requested (read/write/etc.)
- * @param flags mmap flags
- * @param mapinfo a structure holding everything we need to know
- * about the mapping.
- */
-static void
-validate_mmap(char const * fname, int prot, int flags, tmap_info_t * mapinfo)
-{
- memset(mapinfo, 0, sizeof(*mapinfo));
-#if defined(HAVE_MMAP) && ! defined(MAP_ANONYMOUS)
- mapinfo->txt_zero_fd = AO_INVALID_FD;
-#endif
- mapinfo->txt_fd = AO_INVALID_FD;
- mapinfo->txt_prot = prot;
- mapinfo->txt_flags = flags;
-
- /*
- * Map mmap flags and protections into open flags and do the open.
- */
- {
- /*
- * See if we will be updating the file. If we can alter the memory
- * and if we share the data and we are *not* copy-on-writing the data,
- * then our updates will show in the file, so we must open with
- * write access.
- */
- int o_flag =
-#ifdef _WIN32
- O_BINARY |
-#endif
- FILE_WRITABLE(prot, flags) ? O_RDWR : O_RDONLY;
-
- /*
- * If you're not sharing the file and you are writing to it,
- * then don't let anyone else have access to the file.
- */
- if (((flags & MAP_SHARED) == 0) && (prot & PROT_WRITE))
- o_flag |= O_EXCL;
-
- mapinfo->txt_fd = open(fname, o_flag);
- if (mapinfo->txt_fd < 0) {
- mapinfo->txt_errno = errno;
- mapinfo->txt_fd = AO_INVALID_FD;
- return;
- }
- }
-
- /*
- * Make sure we can stat the regular file. Save the file size.
- */
- {
- struct stat sb;
- if (fstat(mapinfo->txt_fd, &sb) != 0) {
- mapinfo->txt_errno = errno;
- close(mapinfo->txt_fd);
- return;
- }
-
- if (! S_ISREG(sb.st_mode)) {
- mapinfo->txt_errno = errno = EINVAL;
- close(mapinfo->txt_fd);
- return;
- }
-
- mapinfo->txt_size = (size_t)sb.st_size;
- }
-
- if (mapinfo->txt_fd == AO_INVALID_FD)
- mapinfo->txt_errno = errno;
-}
-
-/**
- * Close any files opened by the mapping.
- *
- * @param mi a structure holding everything we need to know about the map.
- */
-static void
-close_mmap_files(tmap_info_t * mi)
-{
- if (mi->txt_fd == AO_INVALID_FD)
- return;
-
- close(mi->txt_fd);
- mi->txt_fd = AO_INVALID_FD;
-
-#if defined(HAVE_MMAP) && ! defined(MAP_ANONYMOUS)
- if (mi->txt_zero_fd == AO_INVALID_FD)
- return;
-
- close(mi->txt_zero_fd);
- mi->txt_zero_fd = AO_INVALID_FD;
-#endif
-}
-
-/*=export_func text_mmap
- * private:
- *
- * what: map a text file with terminating NUL
- *
- * arg: char const *, pzFile, name of the file to map
- * arg: int, prot, mmap protections (see mmap(2))
- * arg: int, flags, mmap flags (see mmap(2))
- * arg: tmap_info_t *, mapinfo, returned info about the mapping
- *
- * ret-type: void *
- * ret-desc: The mmaped data address
- *
- * doc:
- *
- * This routine will mmap a file into memory ensuring that there is at least
- * one @file{NUL} character following the file data. It will return the
- * address where the file contents have been mapped into memory. If there is a
- * problem, then it will return @code{MAP_FAILED} and set @code{errno}
- * appropriately.
- *
- * The named file does not exist, @code{stat(2)} will set @code{errno} as it
- * will. If the file is not a regular file, @code{errno} will be
- * @code{EINVAL}. At that point, @code{open(2)} is attempted with the access
- * bits set appropriately for the requested @code{mmap(2)} protections and flag
- * bits. On failure, @code{errno} will be set according to the documentation
- * for @code{open(2)}. If @code{mmap(2)} fails, @code{errno} will be set as
- * that routine sets it. If @code{text_mmap} works to this point, a valid
- * address will be returned, but there may still be ``issues''.
- *
- * If the file size is not an even multiple of the system page size, then
- * @code{text_map} will return at this point and @code{errno} will be zero.
- * Otherwise, an anonymous map is attempted. If not available, then an attempt
- * is made to @code{mmap(2)} @file{/dev/zero}. If any of these fail, the
- * address of the file's data is returned, bug @code{no} @file{NUL} characters
- * are mapped after the end of the data.
- *
- * see: mmap(2), open(2), stat(2)
- *
- * err: Any error code issued by mmap(2), open(2), stat(2) is possible.
- * Additionally, if the specified file is not a regular file, then
- * errno will be set to @code{EINVAL}.
- *
- * example:
- * #include <mylib.h>
- * tmap_info_t mi;
- * int no_nul;
- * void * data = text_mmap("file", PROT_WRITE, MAP_PRIVATE, &mi);
- * if (data == MAP_FAILED) return;
- * no_nul = (mi.txt_size == mi.txt_full_size);
- * << use the data >>
- * text_munmap(&mi);
-=*/
-void *
-text_mmap(char const * pzFile, int prot, int flags, tmap_info_t * mi)
-{
- validate_mmap(pzFile, prot, flags, mi);
- if (mi->txt_errno != 0)
- return MAP_FAILED_PTR;
-
- load_text_file(mi, pzFile);
-
- if (mi->txt_errno == 0)
- return mi->txt_data;
-
- close_mmap_files(mi);
-
- errno = mi->txt_errno;
- mi->txt_data = MAP_FAILED_PTR;
- return mi->txt_data;
-}
-
-
-/*=export_func text_munmap
- * private:
- *
- * what: unmap the data mapped in by text_mmap
- *
- * arg: tmap_info_t *, mapinfo, info about the mapping
- *
- * ret-type: int
- * ret-desc: -1 or 0. @code{errno} will have the error code.
- *
- * doc:
- *
- * This routine will unmap the data mapped in with @code{text_mmap} and close
- * the associated file descriptors opened by that function.
- *
- * see: munmap(2), close(2)
- *
- * err: Any error code issued by munmap(2) or close(2) is possible.
-=*/
-int
-text_munmap(tmap_info_t * mi)
-{
- errno = 0;
-
-#ifdef HAVE_MMAP
- (void)munmap(mi->txt_data, mi->txt_full_size);
-
-#else // don't HAVE_MMAP
- /*
- * IF the memory is writable *AND* it is not private (copy-on-write)
- * *AND* the memory is "sharable" (seen by other processes)
- * THEN rewrite the data. Emulate mmap visibility.
- */
- if ( FILE_WRITABLE(mi->txt_prot, mi->txt_flags)
- && (lseek(mi->txt_fd, 0, SEEK_SET) >= 0) )
- write(mi->txt_fd, mi->txt_data, mi->txt_size);
-
- free(mi->txt_data);
-#endif /* HAVE_MMAP */
-
- mi->txt_errno = errno;
- close_mmap_files(mi);
-
- return mi->txt_errno;
-}
-
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/text_mmap.c */
diff --git a/src/libopts/time.c b/src/libopts/time.c
deleted file mode 100644
index debaa7aed3..0000000000
--- a/src/libopts/time.c
+++ /dev/null
@@ -1,145 +0,0 @@
-
-/**
- * \file time.c
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-/*=export_func optionTimeVal
- * private:
- *
- * what: process an option with a time duration.
- * arg: + tOptions * + opts + program options descriptor +
- * arg: + tOptDesc * + od + the descriptor for this arg +
- *
- * doc:
- * Decipher a time duration value.
-=*/
-void
-optionTimeVal(tOptions * opts, tOptDesc * od)
-{
- time_t val;
-
- if (INQUERY_CALL(opts, od))
- return;
-
- val = parse_duration(od->optArg.argString);
- if (val == BAD_TIME) {
- fprintf(stderr, zNotDuration, opts->pzProgName, od->optArg.argString);
- if ((opts->fOptSet & OPTPROC_ERRSTOP) != 0)
- (*(opts->pUsageProc))(opts, EXIT_FAILURE);
- }
-
- if (od->fOptState & OPTST_ALLOC_ARG) {
- AGFREE(od->optArg.argString);
- od->fOptState &= ~OPTST_ALLOC_ARG;
- }
-
- od->optArg.argInt = (long)val;
-}
-
-/*=export_func optionTimeDate
- * private:
- *
- * what: process an option with a time and date.
- * arg: + tOptions * + opts + program options descriptor +
- * arg: + tOptDesc * + od + the descriptor for this arg +
- *
- * doc:
- * Decipher a time and date value.
-=*/
-void
-optionTimeDate(tOptions * opts, tOptDesc * od)
-{
-#if defined(HAVE_GETDATE_R) && defined(HAVE_PUTENV)
- if (INQUERY_CALL(opts, od))
- return;
-
- if ((! HAS_pzPkgDataDir(opts)) || (opts->pzPkgDataDir == NULL))
- goto default_action;
-
- /*
- * Export the DATEMSK environment variable. getdate_r() uses it to
- * find the file with the strptime formats. If we cannot find the file
- * we need ($PKGDATADIR/datemsk), then fall back to just a time duration.
- */
- {
- static char * envptr = NULL;
-
- if (envptr == NULL) {
- static char const fmt[] = "DATEMSK=%s/datemsk";
- size_t sz = sizeof(fmt) + strlen(opts->pzPkgDataDir);
- envptr = AGALOC(sz, fmt);
- if (snprintf(envptr, sz, fmt, opts->pzPkgDataDir) >= (int)sz)
- option_exits(EXIT_FAILURE);
-
- putenv(envptr);
- }
-
- if (access(envptr+8, R_OK) != 0)
- goto default_action;
- }
-
- /*
- * Convert the date to a time since the epoch and stash it in a long int.
- */
- {
- struct tm stm;
- time_t tm;
-
- if (getdate_r(od->optArg.argString, &stm) != 0) {
- fprintf(stderr, zNotDate, opts->pzProgName,
- od->optArg.argString);
- if ((opts->fOptSet & OPTPROC_ERRSTOP) != 0)
- (*(opts->pUsageProc))(opts, EXIT_FAILURE);
- return;
- }
-
- tm = mktime(&stm);
-
- if (od->fOptState & OPTST_ALLOC_ARG) {
- AGFREE(od->optArg.argString);
- od->fOptState &= ~OPTST_ALLOC_ARG;
- }
-
- od->optArg.argInt = tm;
- }
- return;
-
- default_action:
-
-#endif
- optionTimeVal(opts, od);
- if (od->optArg.argInt != BAD_TIME)
- od->optArg.argInt += (long)time(NULL);
-}
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/time.c */
diff --git a/src/libopts/tokenize.c b/src/libopts/tokenize.c
deleted file mode 100644
index 7489e3d526..0000000000
--- a/src/libopts/tokenize.c
+++ /dev/null
@@ -1,322 +0,0 @@
-/** \file tokenize.c
- *
- * Tokenize a string, accommodating quoted strings.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This file defines the string_tokenize interface
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-static void
-copy_cooked(ch_t ** ppDest, char const ** ppSrc)
-{
- ch_t * pDest = (ch_t *)*ppDest;
- const ch_t * pSrc = (const ch_t *)(*ppSrc + 1);
-
- for (;;) {
- ch_t ch = *(pSrc++);
- switch (ch) {
- case NUL: *ppSrc = NULL; return;
- case '"': goto done;
- case '\\':
- pSrc += ao_string_cook_escape_char((char *)pSrc, (char *)&ch, 0x7F);
- if (ch == 0x7F)
- break;
- /* FALLTHROUGH */
-
- default:
- *(pDest++) = ch;
- }
- }
-
- done:
- *ppDest = (ch_t *)pDest; /* next spot for storing character */
- *ppSrc = (char const *)pSrc; /* char following closing quote */
-}
-
-
-static void
-copy_raw(ch_t ** ppDest, char const ** ppSrc)
-{
- ch_t * pDest = *ppDest;
- cc_t * pSrc = (cc_t *) (*ppSrc + 1);
-
- for (;;) {
- ch_t ch = *(pSrc++);
- switch (ch) {
- case NUL: *ppSrc = NULL; return;
- case '\'': goto done;
- case '\\':
- /*
- * *Four* escapes are handled: newline removal, escape char
- * quoting and apostrophe quoting
- */
- switch (*pSrc) {
- case NUL: *ppSrc = NULL; return;
- case '\r':
- if (*(++pSrc) == NL)
- ++pSrc;
- continue;
-
- case NL:
- ++pSrc;
- continue;
-
- case '\'':
- ch = '\'';
- /* FALLTHROUGH */
-
- case '\\':
- ++pSrc;
- break;
- }
- /* FALLTHROUGH */
-
- default:
- *(pDest++) = ch;
- }
- }
-
- done:
- *ppDest = pDest; /* next spot for storing character */
- *ppSrc = (char const *) pSrc; /* char following closing quote */
-}
-
-static token_list_t *
-alloc_token_list(char const * str)
-{
- token_list_t * res;
-
- int max_token_ct = 2; /* allow for trailing NULL pointer & NUL on string */
-
- if (str == NULL) goto enoent_res;
-
- /*
- * Trim leading white space. Use "ENOENT" and a NULL return to indicate
- * an empty string was passed.
- */
- str = SPN_WHITESPACE_CHARS(str);
- if (*str == NUL) goto enoent_res;
-
- /*
- * Take an approximate count of tokens. If no quoted strings are used,
- * it will be accurate. If quoted strings are used, it will be a little
- * high and we'll squander the space for a few extra pointers.
- */
- {
- char const * pz = str;
-
- do {
- max_token_ct++;
- pz = BRK_WHITESPACE_CHARS(pz+1);
- pz = SPN_WHITESPACE_CHARS(pz);
- } while (*pz != NUL);
-
- res = malloc(sizeof(*res) + (size_t)(pz - str)
- + ((size_t)max_token_ct * sizeof(ch_t *)));
- }
-
- if (res == NULL)
- errno = ENOMEM;
- else res->tkn_list[0] = (ch_t *)(res->tkn_list + (max_token_ct - 1));
-
- return res;
-
- enoent_res:
-
- errno = ENOENT;
- return NULL;
-}
-
-/*=export_func ao_string_tokenize
- *
- * what: tokenize an input string
- *
- * arg: + char const * + string + string to be tokenized +
- *
- * ret_type: token_list_t *
- * ret_desc: pointer to a structure that lists each token
- *
- * doc:
- *
- * This function will convert one input string into a list of strings.
- * The list of strings is derived by separating the input based on
- * white space separation. However, if the input contains either single
- * or double quote characters, then the text after that character up to
- * a matching quote will become the string in the list.
- *
- * The returned pointer should be deallocated with @code{free(3C)} when
- * are done using the data. The data are placed in a single block of
- * allocated memory. Do not deallocate individual token/strings.
- *
- * The structure pointed to will contain at least these two fields:
- * @table @samp
- * @item tkn_ct
- * The number of tokens found in the input string.
- * @item tok_list
- * An array of @code{tkn_ct + 1} pointers to substring tokens, with
- * the last pointer set to NULL.
- * @end table
- *
- * There are two types of quoted strings: single quoted (@code{'}) and
- * double quoted (@code{"}). Singly quoted strings are fairly raw in that
- * escape characters (@code{\\}) are simply another character, except when
- * preceding the following characters:
- * @example
- * @code{\\} double backslashes reduce to one
- * @code{'} incorporates the single quote into the string
- * @code{\n} suppresses both the backslash and newline character
- * @end example
- *
- * Double quote strings are formed according to the rules of string
- * constants in ANSI-C programs.
- *
- * example:
- * @example
- * #include <stdlib.h>
- * int ix;
- * token_list_t * ptl = ao_string_tokenize(some_string)
- * for (ix = 0; ix < ptl->tkn_ct; ix++)
- * do_something_with_tkn(ptl->tkn_list[ix]);
- * free(ptl);
- * @end example
- * Note that everything is freed with the one call to @code{free(3C)}.
- *
- * err:
- * NULL is returned and @code{errno} will be set to indicate the problem:
- * @itemize @bullet
- * @item
- * @code{EINVAL} - There was an unterminated quoted string.
- * @item
- * @code{ENOENT} - The input string was empty.
- * @item
- * @code{ENOMEM} - There is not enough memory.
- * @end itemize
-=*/
-token_list_t *
-ao_string_tokenize(char const * str)
-{
- token_list_t * res = alloc_token_list(str);
- ch_t * pzDest;
-
- /*
- * Now copy each token into the output buffer.
- */
- if (res == NULL)
- return res;
-
- pzDest = (ch_t *)(res->tkn_list[0]);
- res->tkn_ct = 0;
-
- do {
- res->tkn_list[ res->tkn_ct++ ] = pzDest;
- for (;;) {
- int ch = (ch_t)*str;
- if (IS_WHITESPACE_CHAR(ch)) {
- found_white_space:
- str = SPN_WHITESPACE_CHARS(str+1);
- break;
- }
-
- switch (ch) {
- case '"':
- copy_cooked(&pzDest, &str);
- if (str == NULL) {
- free(res);
- errno = EINVAL;
- return NULL;
- }
- if (IS_WHITESPACE_CHAR(*str))
- goto found_white_space;
- break;
-
- case '\'':
- copy_raw(&pzDest, &str);
- if (str == NULL) {
- free(res);
- errno = EINVAL;
- return NULL;
- }
- if (IS_WHITESPACE_CHAR(*str))
- goto found_white_space;
- break;
-
- case NUL:
- goto copy_done;
-
- default:
- str++;
- *(pzDest++) = (unsigned char)ch;
- }
- } copy_done:;
-
- /*
- * NUL terminate the last token and see if we have any more tokens.
- */
- *(pzDest++) = NUL;
- } while (*str != NUL);
-
- res->tkn_list[ res->tkn_ct ] = NULL;
-
- return res;
-}
-
-#ifdef TEST
-#include <stdio.h>
-#include <string.h>
-
-int
-main(int argc, char ** argv)
-{
- if (argc == 1) {
- printf("USAGE: %s arg [ ... ]\n", *argv);
- return 1;
- }
- while (--argc > 0) {
- char * arg = *(++argv);
- token_list_t * p = ao_string_tokenize(arg);
- if (p == NULL) {
- printf("Parsing string ``%s'' failed:\n\terrno %d (%s)\n",
- arg, errno, strerror(errno));
- } else {
- int ix = 0;
- printf("Parsed string ``%s''\ninto %d tokens:\n", arg, p->tkn_ct);
- do {
- printf(" %3d: ``%s''\n", ix+1, p->tkn_list[ix]);
- } while (++ix < p->tkn_ct);
- free(p);
- }
- }
- return 0;
-}
-#endif
-
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/tokenize.c */
diff --git a/src/libopts/usage.c b/src/libopts/usage.c
deleted file mode 100644
index 8df3591e66..0000000000
--- a/src/libopts/usage.c
+++ /dev/null
@@ -1,1285 +0,0 @@
-
-/*
- * \file usage.c
- *
- * This module implements the default usage procedure for
- * Automated Options. It may be overridden, of course.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * Sort options:
- --start=END-[S]TATIC-FORWARD --patt='^/\*($|[^:])' \
- --out=xx.c key='^[a-zA-Z0-9_]+\(' --trail='^/\*:' \
- --spac=2 --input=usage.c
- */
-
-/*
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-#define GRAPH_CH(_ch) \
- ((((unsigned)_ch) <= 0x7E) && (((unsigned)_ch) > ' '))
-
-/**
- * Parse the option usage flags string. Any parsing problems yield
- * a zero (no flags set) result. This function is internal to
- * set_usage_flags().
- *
- * @param[in] fnt Flag Name Table - maps a name to a mask
- * @param[in] txt the text to process. If NULL, then
- * getenv("AUTOOPTS_USAGE") is used.
- * @returns a bit mask indicating which \a fnt entries were found.
- */
-static unsigned int
-parse_usage_flags(ao_flag_names_t const * fnt, char const * txt)
-{
- unsigned int res = 0;
-
- /*
- * The text may be passed in. If not, use the environment variable.
- */
- if (txt == NULL) {
- txt = getenv("AUTOOPTS_USAGE");
- if (txt == NULL)
- return 0;
- }
-
- txt = SPN_WHITESPACE_CHARS(txt);
- if (*txt == NUL)
- return 0;
-
- /*
- * search the string for table entries. We must understand everything
- * we see in the string, or we give up on it.
- */
- for (;;) {
- int ix = 0;
-
- for (;;) {
- if (strneqvcmp(txt, fnt[ix].fnm_name, (int)fnt[ix].fnm_len) == 0)
- break;
- if (++ix >= AOUF_COUNT)
- return 0;
- }
-
- /*
- * Make sure we have a full match. Look for whitespace,
- * a comma, or a NUL byte.
- */
- if (! IS_END_LIST_ENTRY_CHAR(txt[fnt[ix].fnm_len]))
- return 0;
-
- res |= 1U << ix;
- txt = SPN_WHITESPACE_CHARS(txt + fnt[ix].fnm_len);
-
- switch (*txt) {
- case NUL:
- return res;
-
- case ',':
- txt = SPN_WHITESPACE_CHARS(txt + 1);
- /* Something must follow the comma */
- /* FALLTHROUGH */
-
- default:
- continue;
- }
- }
-}
-
-/**
- * Set option usage flags. Any parsing problems yield no changes to options.
- * Three different bits may be fiddled: \a OPTPROC_GNUUSAGE, \a OPTPROC_MISUSE
- * and \a OPTPROC_COMPUTE.
- *
- * @param[in] flg_txt text to parse. If NULL, then the AUTOOPTS_USAGE
- * environment variable is parsed.
- * @param[in,out] opts the program option descriptor
- */
-static void
-set_usage_flags(tOptions * opts, char const * flg_txt)
-{
-# define _aof_(_n, _f) { sizeof(#_n)-1, _f, #_n },
- static ao_flag_names_t const fn_table[AOUF_COUNT] = {
- AOFLAG_TABLE
- };
-# undef _aof_
-
- /*
- * the flag word holds a bit for each selected table entry.
- */
- unsigned int flg = parse_usage_flags(fn_table, flg_txt);
- if (flg == 0) return;
-
- /*
- * Ensure we do not have conflicting selections
- */
- {
- static unsigned int const form_mask =
- AOUF_gnu | AOUF_autoopts;
- static unsigned int const misuse_mask =
- AOUF_no_misuse_usage | AOUF_misuse_usage;
- if ( ((flg & form_mask) == form_mask)
- || ((flg & misuse_mask) == misuse_mask) )
- return;
- }
-
- /*
- * Now fiddle the fOptSet bits, based on settings.
- * The OPTPROC_LONGOPT bit is immutable, thus if it is set,
- * then fnm points to a mask off mask.
- */
- {
- ao_flag_names_t const * fnm = fn_table;
- for (;;) {
- if ((flg & 1) != 0) {
- if ((fnm->fnm_mask & OPTPROC_LONGOPT) != 0)
- opts->fOptSet &= fnm->fnm_mask;
- else opts->fOptSet |= fnm->fnm_mask;
- }
- flg >>= 1;
- if (flg == 0)
- break;
- fnm++;
- }
- }
-}
-
-/*
- * Figure out if we should try to format usage text sort-of like
- * the way many GNU programs do.
- */
-static inline bool
-do_gnu_usage(tOptions * pOpts)
-{
- return (pOpts->fOptSet & OPTPROC_GNUUSAGE) ? true : false;
-}
-
-/*
- * Figure out if we should try to format usage text sort-of like
- * the way many GNU programs do.
- */
-static inline bool
-skip_misuse_usage(tOptions * pOpts)
-{
- return (pOpts->fOptSet & OPTPROC_MISUSE) ? true : false;
-}
-
-
-/*=export_func optionOnlyUsage
- *
- * what: Print usage text for just the options
- * arg: + tOptions * + pOpts + program options descriptor +
- * arg: + int + ex_code + exit code for calling exit(3) +
- *
- * doc:
- * This routine will print only the usage for each option.
- * This function may be used when the emitted usage must incorporate
- * information not available to AutoOpts.
-=*/
-void
-optionOnlyUsage(tOptions * pOpts, int ex_code)
-{
- char const * pOptTitle = NULL;
-
- set_usage_flags(pOpts, NULL);
- if ((ex_code != EXIT_SUCCESS) &&
- skip_misuse_usage(pOpts))
- return;
-
- /*
- * Determine which header and which option formatting strings to use
- */
- if (do_gnu_usage(pOpts))
- (void)setGnuOptFmts(pOpts, &pOptTitle);
- else
- (void)setStdOptFmts(pOpts, &pOptTitle);
-
- prt_opt_usage(pOpts, ex_code, pOptTitle);
-
- fflush(option_usage_fp);
- if (ferror(option_usage_fp) != 0)
- fserr_exit(pOpts->pzProgName, zwriting, (option_usage_fp == stderr)
- ? zstderr_name : zstdout_name);
-}
-
-/**
- * Print a message suggesting how to get help.
- *
- * @param[in] opts the program options
- */
-static void
-print_offer_usage(tOptions * opts)
-{
- char help[24];
-
- if (HAS_opt_usage_t(opts)) {
- int ix = opts->presetOptCt;
- tOptDesc * od = opts->pOptDesc + ix;
- while (od->optUsage != AOUSE_HELP) {
- if (++ix >= opts->optCt)
- ao_bug(zmissing_help_msg);
- od++;
- }
- switch (opts->fOptSet & (OPTPROC_LONGOPT | OPTPROC_SHORTOPT)) {
- case OPTPROC_SHORTOPT:
- help[0] = '-';
- help[1] = od->optValue;
- help[2] = NUL;
- break;
-
- case OPTPROC_LONGOPT:
- case (OPTPROC_LONGOPT | OPTPROC_SHORTOPT):
- help[0] = help[1] = '-';
- strncpy(help + 2, od->pz_Name, 20);
- break;
-
- case 0:
- strncpy(help, od->pz_Name, 20);
- break;
- }
-
- } else {
- switch (opts->fOptSet & (OPTPROC_LONGOPT | OPTPROC_SHORTOPT)) {
- case OPTPROC_SHORTOPT:
- strcpy(help, "-h");
- break;
-
- case OPTPROC_LONGOPT:
- case (OPTPROC_LONGOPT | OPTPROC_SHORTOPT):
- strcpy(help, "--help");
- break;
-
- case 0:
- strcpy(help, "help");
- break;
- }
- }
-
- fprintf(option_usage_fp, zoffer_usage_fmt, opts->pzProgName, help);
-}
-
-/**
- * Print information about each option.
- *
- * @param[in] opts the program options
- * @param[in] exit_code whether or not there was a usage error reported.
- * used to select full usage versus abbreviated.
- */
-static void
-print_usage_details(tOptions * opts, int exit_code)
-{
- {
- char const * pOptTitle = NULL;
- int flen;
-
- /*
- * Determine which header and which option formatting strings to use
- */
- if (do_gnu_usage(opts)) {
- flen = setGnuOptFmts(opts, &pOptTitle);
- sprintf(line_fmt_buf, zFmtFmt, flen);
- fputc(NL, option_usage_fp);
-
- } else {
- flen = setStdOptFmts(opts, &pOptTitle);
- sprintf(line_fmt_buf, zFmtFmt, flen);
-
- /*
- * When we exit with EXIT_SUCCESS and the first option is a doc
- * option, we do *NOT* want to emit the column headers.
- * Otherwise, we do.
- */
- if ( (exit_code != EXIT_SUCCESS)
- || ((opts->pOptDesc->fOptState & OPTST_DOCUMENT) == 0) )
-
- fputs(pOptTitle, option_usage_fp);
- }
-
- flen = 4 - ((flen + 15) / 8);
- if (flen > 0)
- tab_skip_ct = flen;
- prt_opt_usage(opts, exit_code, pOptTitle);
- }
-
- /*
- * Describe the mechanics of denoting the options
- */
- switch (opts->fOptSet & OPTPROC_L_N_S) {
- case OPTPROC_L_N_S: fputs(zFlagOkay, option_usage_fp); break;
- case OPTPROC_SHORTOPT: break;
- case OPTPROC_LONGOPT: fputs(zNoFlags, option_usage_fp); break;
- case 0: fputs(zOptsOnly, option_usage_fp); break;
- }
-
- if ((opts->fOptSet & OPTPROC_NUM_OPT) != 0)
- fputs(zNumberOpt, option_usage_fp);
-
- if ((opts->fOptSet & OPTPROC_REORDER) != 0)
- fputs(zReorder, option_usage_fp);
-
- if (opts->pzExplain != NULL)
- fputs(opts->pzExplain, option_usage_fp);
-
- /*
- * IF the user is asking for help (thus exiting with SUCCESS),
- * THEN see what additional information we can provide.
- */
- if (exit_code == EXIT_SUCCESS)
- prt_prog_detail(opts);
-
- /*
- * Give bug notification preference to the packager information
- */
- if (HAS_pzPkgDataDir(opts) && (opts->pzPackager != NULL))
- fputs(opts->pzPackager, option_usage_fp);
-
- else if (opts->pzBugAddr != NULL)
- fprintf(option_usage_fp, zPlsSendBugs, opts->pzBugAddr);
-
- fflush(option_usage_fp);
-
- if (ferror(option_usage_fp) != 0)
- fserr_exit(opts->pzProgName, zwriting, (option_usage_fp == stderr)
- ? zstderr_name : zstdout_name);
-}
-
-static void
-print_one_paragraph(char const * text, bool plain, FILE * fp)
-{
- if (plain) {
-#ifdef ENABLE_NLS
-#ifdef HAVE_LIBINTL_H
-#ifdef DEBUG_ENABLED
-#undef gettext
-#endif
- char * buf = dgettext("libopts", text);
- if (buf == text)
- text = gettext(text);
-#endif /* HAVE_LIBINTL_H */
-#endif /* ENABLE_NLS */
- fputs(text, fp);
- }
-
- else {
- char const * t = optionQuoteString(text, LINE_SPLICE);
- fprintf(fp, PUTS_FMT, t);
- AGFREE(t);
- }
-}
-
-/*=export_func optionPrintParagraphs
- * private:
- *
- * what: Print a paragraph of usage text
- * arg: + char const * + text + a block of text that has bee i18n-ed +
- * arg: + bool + plain + false -> wrap text in fputs() +
- * arg: + FILE * + fp + the stream file pointer for output +
- *
- * doc:
- * This procedure is called in two contexts: when a full or short usage text
- * has been provided for display, and when autogen is assembling a list of
- * translatable texts in the optmain.tlib template. In the former case, \a
- * plain is set to \a true, otherwise \a false.
- *
- * Anything less than 256 characters in size is printed as a single unit.
- * Otherwise, paragraphs are detected. A paragraph break is defined as just
- * before a non-empty line preceded by two newlines or a line that starts
- * with at least one space character but fewer than 8 space characters.
- * Lines indented with tabs or more than 7 spaces are considered continuation
- * lines.
- *
- * If 'plain' is true, we are emitting text for a user to see. So, if it is
- * true and NLS is not enabled, then just write the whole thing at once.
-=*/
-void
-optionPrintParagraphs(char const * text, bool plain, FILE * fp)
-{
- size_t len = strlen(text);
- char * buf;
-#ifndef ENABLE_NLS
- if (plain || (len < 256))
-#else
- if (len < 256)
-#endif
- {
- print_one_paragraph(text, plain, fp);
- return;
- }
-
- AGDUPSTR(buf, text, "ppara");
- text = buf;
-
- for (;;) {
- char * scan;
-
- if (len < 256) {
- done:
- print_one_paragraph(buf, plain, fp);
- break;
- }
- scan = buf;
-
- try_longer:
- scan = strchr(scan, NL);
- if (scan == NULL)
- goto done;
-
- if ((scan - buf) < 40) {
- scan++;
- goto try_longer;
- }
-
- scan++;
- if ((! isspace((int)*scan)) || (*scan == HT))
- /*
- * line starts with tab or non-whitespace --> continuation
- */
- goto try_longer;
-
- if (*scan == NL) {
- /*
- * Double newline -> paragraph break
- * Include all newlines in current paragraph.
- */
- while (*++scan == NL) /*continue*/;
-
- } else {
- char * p = scan;
- int sp_ct = 0;
-
- while (*p == ' ') {
- if (++sp_ct >= 8) {
- /*
- * Too many spaces --> continuation line
- */
- scan = p;
- goto try_longer;
- }
- p++;
- }
- }
-
- /*
- * "scan" points to the first character of a paragraph or the
- * terminating NUL byte.
- */
- {
- char svch = *scan;
- *scan = NUL;
- print_one_paragraph(buf, plain, fp);
- len -= scan - buf;
- if (len <= 0)
- break;
- *scan = svch;
- buf = scan;
- }
- }
- AGFREE(text);
-}
-
-/*=export_func optionUsage
- * private:
- *
- * what: Print usage text
- * arg: + tOptions * + opts + program options descriptor +
- * arg: + int + exitCode + exit code for calling exit(3) +
- *
- * doc:
- * This routine will print usage in both GNU-standard and AutoOpts-expanded
- * formats. The descriptor specifies the default, but AUTOOPTS_USAGE will
- * over-ride this, providing the value of it is set to either "gnu" or
- * "autoopts". This routine will @strong{not} return.
- *
- * If "exitCode" is "AO_EXIT_REQ_USAGE" (normally 64), then output will to
- * to stdout and the actual exit code will be "EXIT_SUCCESS".
-=*/
-noreturn void
-optionUsage(tOptions * opts, int usage_exit_code)
-{
- int exit_code = (usage_exit_code == AO_EXIT_REQ_USAGE)
- ? EXIT_SUCCESS : usage_exit_code;
-
- displayEnum = false;
- set_usage_flags(opts, NULL);
-
- /*
- * Paged usage will preset option_usage_fp to an output file.
- * If it hasn't already been set, then set it to standard output
- * on successful exit (help was requested), otherwise error out.
- *
- * Test the version before obtaining pzFullUsage or pzShortUsage.
- * These fields do not exist before revision 30.
- */
- {
- char const * pz;
-
- if (exit_code == EXIT_SUCCESS) {
- pz = (opts->structVersion >= 30 * 4096)
- ? opts->pzFullUsage : NULL;
-
- if (option_usage_fp == NULL)
- option_usage_fp = print_exit ? stderr : stdout;
-
- } else {
- pz = (opts->structVersion >= 30 * 4096)
- ? opts->pzShortUsage : NULL;
-
- if (option_usage_fp == NULL)
- option_usage_fp = stderr;
- }
-
- if (((opts->fOptSet & OPTPROC_COMPUTE) == 0) && (pz != NULL)) {
- if ((opts->fOptSet & OPTPROC_TRANSLATE) != 0)
- optionPrintParagraphs(pz, true, option_usage_fp);
- else
- fputs(pz, option_usage_fp);
- goto flush_and_exit;
- }
- }
-
- fprintf(option_usage_fp, opts->pzUsageTitle, opts->pzProgName);
-
- if ((exit_code == EXIT_SUCCESS) ||
- (! skip_misuse_usage(opts)))
-
- print_usage_details(opts, usage_exit_code);
- else
- print_offer_usage(opts);
-
- flush_and_exit:
- fflush(option_usage_fp);
- if (ferror(option_usage_fp) != 0)
- fserr_exit(opts->pzProgName, zwriting, (option_usage_fp == stdout)
- ? zstdout_name : zstderr_name);
-
- option_exits(exit_code);
-}
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * PER OPTION TYPE USAGE INFORMATION
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/**
- * print option conflicts.
- *
- * @param opts the program option descriptor
- * @param od the option descriptor
- */
-static void
-prt_conflicts(tOptions * opts, tOptDesc * od)
-{
- const int * opt_no;
- fputs(zTabHyp + tab_skip_ct, option_usage_fp);
-
- /*
- * REQUIRED:
- */
- if (od->pOptMust != NULL) {
- opt_no = od->pOptMust;
-
- if (opt_no[1] == NO_EQUIVALENT) {
- fprintf(option_usage_fp, zReqOne,
- opts->pOptDesc[*opt_no].pz_Name);
- } else {
- fputs(zReqThese, option_usage_fp);
- for (;;) {
- fprintf(option_usage_fp, zTabout + tab_skip_ct,
- opts->pOptDesc[*opt_no].pz_Name);
- if (*++opt_no == NO_EQUIVALENT)
- break;
- }
- }
-
- if (od->pOptCant != NULL)
- fputs(zTabHypAnd + tab_skip_ct, option_usage_fp);
- }
-
- /*
- * CONFLICTS:
- */
- if (od->pOptCant == NULL)
- return;
-
- opt_no = od->pOptCant;
-
- if (opt_no[1] == NO_EQUIVALENT) {
- fprintf(option_usage_fp, zProhibOne,
- opts->pOptDesc[*opt_no].pz_Name);
- return;
- }
-
- fputs(zProhib, option_usage_fp);
- for (;;) {
- fprintf(option_usage_fp, zTabout + tab_skip_ct,
- opts->pOptDesc[*opt_no].pz_Name);
- if (*++opt_no == NO_EQUIVALENT)
- break;
- }
-}
-
-/**
- * Print the usage information for a single vendor option.
- *
- * @param[in] opts the program option descriptor
- * @param[in] od the option descriptor
- * @param[in] argtp names of the option argument types
- * @param[in] usefmt format for primary usage line
- */
-static void
-prt_one_vendor(tOptions * opts, tOptDesc * od,
- arg_types_t * argtp, char const * usefmt)
-{
- prt_preamble(opts, od, argtp);
-
- {
- char z[ 80 ];
- char const * pzArgType;
-
- /*
- * Determine the argument type string first on its usage, then,
- * when the option argument is required, base the type string on the
- * argument type.
- */
- if (od->fOptState & OPTST_ARG_OPTIONAL) {
- pzArgType = argtp->pzOpt;
-
- } else switch (OPTST_GET_ARGTYPE(od->fOptState)) {
- case OPARG_TYPE_NONE: pzArgType = argtp->pzNo; break;
- case OPARG_TYPE_ENUMERATION: pzArgType = argtp->pzKey; break;
- case OPARG_TYPE_FILE: pzArgType = argtp->pzFile; break;
- case OPARG_TYPE_MEMBERSHIP: pzArgType = argtp->pzKeyL; break;
- case OPARG_TYPE_BOOLEAN: pzArgType = argtp->pzBool; break;
- case OPARG_TYPE_NUMERIC: pzArgType = argtp->pzNum; break;
- case OPARG_TYPE_HIERARCHY: pzArgType = argtp->pzNest; break;
- case OPARG_TYPE_STRING: pzArgType = argtp->pzStr; break;
- case OPARG_TYPE_TIME: pzArgType = argtp->pzTime; break;
- default: goto bogus_desc;
- }
-
- pzArgType = SPN_WHITESPACE_CHARS(pzArgType);
- if (*pzArgType == NUL)
- snprintf(z, sizeof(z), "%s", od->pz_Name);
- else
- snprintf(z, sizeof(z), "%s=%s", od->pz_Name, pzArgType);
- fprintf(option_usage_fp, usefmt, z, od->pzText);
-
- switch (OPTST_GET_ARGTYPE(od->fOptState)) {
- case OPARG_TYPE_ENUMERATION:
- case OPARG_TYPE_MEMBERSHIP:
- displayEnum = (od->pOptProc != NULL) ? true : displayEnum;
- }
- }
-
- return;
-
- bogus_desc:
- fprintf(stderr, zbad_od, opts->pzProgName, od->pz_Name);
- ao_bug(zbad_arg_type_msg);
-}
-
-/**
- * Print the long options processed with "-W". These options will be the
- * ones that do *not* have flag characters.
- *
- * @param opts the program option descriptor
- * @param title the title for the options
- */
-static void
-prt_vendor_opts(tOptions * opts, char const * title)
-{
- static unsigned int const not_vended_mask =
- OPTST_NO_USAGE_MASK | OPTST_DOCUMENT;
-
- static char const vfmtfmt[] = "%%-%us %%s\n";
- char vfmt[sizeof(vfmtfmt)];
-
- /*
- * Only handle client specified options. The "vendor option" follows
- * "presetOptCt", so we won't loop/recurse indefinitely.
- */
- int ct = opts->presetOptCt;
- tOptDesc * od = opts->pOptDesc;
- fprintf(option_usage_fp, zTabout + tab_skip_ct, zVendOptsAre);
-
- {
- size_t nmlen = 0;
- do {
- size_t l;
- if ( ((od->fOptState & not_vended_mask) != 0)
- || GRAPH_CH(od->optValue))
- continue;
-
- l = strlen(od->pz_Name);
- if (l > nmlen) nmlen = l;
- } while (od++, (--ct > 0));
-
- snprintf(vfmt, sizeof(vfmt), vfmtfmt, (unsigned int)nmlen + 4);
- }
-
- if (tab_skip_ct > 0)
- tab_skip_ct--;
-
- ct = opts->presetOptCt;
- od = opts->pOptDesc;
-
- do {
- if ( ((od->fOptState & not_vended_mask) != 0)
- || GRAPH_CH(od->optValue))
- continue;
-
- prt_one_vendor(opts, od, &argTypes, vfmt);
- prt_extd_usage(opts, od, title);
-
- } while (od++, (--ct > 0));
-
- /* no need to restore "tab_skip_ct" - options are done now */
-}
-
-/**
- * Print extended usage. Usage/help was requested.
- *
- * @param opts the program option descriptor
- * @param od the option descriptor
- * @param title the title for the options
- */
-static void
-prt_extd_usage(tOptions * opts, tOptDesc * od, char const * title)
-{
- if ( ((opts->fOptSet & OPTPROC_VENDOR_OPT) != 0)
- && (od->optActualValue == VENDOR_OPTION_VALUE)) {
- prt_vendor_opts(opts, title);
- return;
- }
-
- /*
- * IF there are option conflicts or dependencies,
- * THEN print them here.
- */
- if ((od->pOptMust != NULL) || (od->pOptCant != NULL))
- prt_conflicts(opts, od);
-
- /*
- * IF there is a disablement string
- * THEN print the disablement info
- */
- if (od->pz_DisableName != NULL )
- fprintf(option_usage_fp, zDis + tab_skip_ct, od->pz_DisableName);
-
- /*
- * Check for argument types that have callbacks with magical properties
- */
- switch (OPTST_GET_ARGTYPE(od->fOptState)) {
- case OPARG_TYPE_NUMERIC:
- /*
- * IF the numeric option has a special callback,
- * THEN call it, requesting the range or other special info
- */
- if ( (od->pOptProc != NULL)
- && (od->pOptProc != optionNumericVal) ) {
- (*(od->pOptProc))(OPTPROC_EMIT_USAGE, od);
- }
- break;
-
- case OPARG_TYPE_FILE:
- (*(od->pOptProc))(OPTPROC_EMIT_USAGE, od);
- break;
- }
-
- /*
- * IF the option defaults to being enabled,
- * THEN print that out
- */
- if (od->fOptState & OPTST_INITENABLED)
- fputs(zEnab + tab_skip_ct, option_usage_fp);
-
- /*
- * IF the option is in an equivalence class
- * AND not the designated lead
- * THEN print equivalence and leave it at that.
- */
- if ( (od->optEquivIndex != NO_EQUIVALENT)
- && (od->optEquivIndex != od->optActualIndex ) ) {
- fprintf(option_usage_fp, zalt_opt + tab_skip_ct,
- opts->pOptDesc[ od->optEquivIndex ].pz_Name);
- return;
- }
-
- /*
- * IF this particular option can NOT be preset
- * AND some form of presetting IS allowed,
- * AND it is not an auto-managed option (e.g. --help, et al.)
- * THEN advise that this option may not be preset.
- */
- if ( ((od->fOptState & OPTST_NO_INIT) != 0)
- && ( (opts->papzHomeList != NULL)
- || (opts->pzPROGNAME != NULL)
- )
- && (od->optIndex < opts->presetOptCt)
- )
-
- fputs(zNoPreset + tab_skip_ct, option_usage_fp);
-
- /*
- * Print the appearance requirements.
- */
- if (OPTST_GET_ARGTYPE(od->fOptState) == OPARG_TYPE_MEMBERSHIP)
- fputs(zMembers + tab_skip_ct, option_usage_fp);
-
- else switch (od->optMinCt) {
- case 1:
- case 0:
- switch (od->optMaxCt) {
- case 0: fputs(zPreset + tab_skip_ct, option_usage_fp); break;
- case NOLIMIT: fputs(zNoLim + tab_skip_ct, option_usage_fp); break;
- case 1: break;
- /*
- * IF the max is more than one but limited, print "UP TO" message
- */
- default:
- fprintf(option_usage_fp, zUpTo + tab_skip_ct, od->optMaxCt); break;
- }
- break;
-
- default:
- /*
- * More than one is required. Print the range.
- */
- fprintf(option_usage_fp, zMust + tab_skip_ct,
- od->optMinCt, od->optMaxCt);
- }
-
- if ( NAMED_OPTS(opts)
- && (opts->specOptIdx.default_opt == od->optIndex))
- fputs(zDefaultOpt + tab_skip_ct, option_usage_fp);
-}
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/**
- * Figure out where all the initialization files might live. This requires
- * translating some environment variables and testing to see if a name is a
- * directory or a file. It's squishy, but important to tell users how to
- * find these files.
- *
- * @param[in] papz search path
- * @param[out] ini_file an output buffer of AG_PATH_MAX+1 bytes
- * @param[in] path_nm the name of the file we're hunting for
- */
-static void
-prt_ini_list(char const * const * papz, char const * ini_file,
- char const * path_nm)
-{
- char pth_buf[AG_PATH_MAX+1];
-
- fputs(zPresetIntro, option_usage_fp);
-
- for (;;) {
- char const * path = *(papz++);
- char const * nm_buf = pth_buf;
-
- if (path == NULL)
- break;
-
- /*
- * Ignore any invalid paths
- */
- if (! optionMakePath(pth_buf, (int)sizeof(pth_buf), path, path_nm))
- nm_buf = path;
-
- /*
- * Expand paths that are relative to the executable or installation
- * directories. Leave alone paths that use environment variables.
- */
- else if ((*path == '$')
- && ((path[1] == '$') || (path[1] == '@')))
- path = nm_buf;
-
- /*
- * Print the name of the "homerc" file. If the "rcfile" name is
- * not empty, we may or may not print that, too...
- */
- fprintf(option_usage_fp, zPathFmt, path);
- if (*ini_file != NUL) {
- struct stat sb;
-
- /*
- * IF the "homerc" file is a directory,
- * then append the "rcfile" name.
- */
- if ((stat(nm_buf, &sb) == 0) && S_ISDIR(sb.st_mode)) {
- fputc(DIRCH, option_usage_fp);
- fputs(ini_file, option_usage_fp);
- }
- }
-
- fputc(NL, option_usage_fp);
- }
-}
-
-/**
- * Print the usage line preamble text
- *
- * @param opts the program option descriptor
- * @param od the option descriptor
- * @param at names of the option argument types
- */
-static void
-prt_preamble(tOptions * opts, tOptDesc * od, arg_types_t * at)
-{
- /*
- * Flag prefix: IF no flags at all, then omit it. If not printable
- * (not allowed for this option), then blank, else print it.
- * Follow it with a comma if we are doing GNU usage and long
- * opts are to be printed too.
- */
- if ((opts->fOptSet & OPTPROC_SHORTOPT) == 0)
- fputs(at->pzSpc, option_usage_fp);
-
- else if (! GRAPH_CH(od->optValue)) {
- if ( (opts->fOptSet & (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT))
- == (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT))
- fputc(' ', option_usage_fp);
- fputs(at->pzNoF, option_usage_fp);
-
- } else {
- fprintf(option_usage_fp, " -%c", od->optValue);
- if ( (opts->fOptSet & (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT))
- == (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT))
- fputs(", ", option_usage_fp);
- }
-}
-
-/**
- * Print the usage information for a single option.
- *
- * @param opts the program option descriptor
- * @param od the option descriptor
- * @param at names of the option argument types
- */
-static void
-prt_one_usage(tOptions * opts, tOptDesc * od, arg_types_t * at)
-{
- prt_preamble(opts, od, at);
-
- {
- char z[80];
- char const * atyp;
-
- /*
- * Determine the argument type string first on its usage, then,
- * when the option argument is required, base the type string on the
- * argument type.
- */
- if (od->fOptState & OPTST_ARG_OPTIONAL) {
- atyp = at->pzOpt;
-
- } else switch (OPTST_GET_ARGTYPE(od->fOptState)) {
- case OPARG_TYPE_NONE: atyp = at->pzNo; break;
- case OPARG_TYPE_ENUMERATION: atyp = at->pzKey; break;
- case OPARG_TYPE_FILE: atyp = at->pzFile; break;
- case OPARG_TYPE_MEMBERSHIP: atyp = at->pzKeyL; break;
- case OPARG_TYPE_BOOLEAN: atyp = at->pzBool; break;
- case OPARG_TYPE_NUMERIC: atyp = at->pzNum; break;
- case OPARG_TYPE_HIERARCHY: atyp = at->pzNest; break;
- case OPARG_TYPE_STRING: atyp = at->pzStr; break;
- case OPARG_TYPE_TIME: atyp = at->pzTime; break;
- default: goto bogus_desc;
- }
-
-#ifdef _WIN32
- if (at->pzOptFmt == zGnuOptFmt)
- snprintf(z, sizeof(z), "--%s%s", od->pz_Name, atyp);
- else if (at->pzOptFmt == zGnuOptFmt + 2)
- snprintf(z, sizeof(z), "%s%s", od->pz_Name, atyp);
- else
-#endif
- snprintf(z, sizeof(z), at->pzOptFmt, atyp, od->pz_Name,
- (od->optMinCt != 0) ? at->pzReq : at->pzOpt);
-
- fprintf(option_usage_fp, line_fmt_buf, z, od->pzText);
-
- switch (OPTST_GET_ARGTYPE(od->fOptState)) {
- case OPARG_TYPE_ENUMERATION:
- case OPARG_TYPE_MEMBERSHIP:
- displayEnum = (od->pOptProc != NULL) ? true : displayEnum;
- }
- }
-
- return;
-
- bogus_desc:
- fprintf(stderr, zbad_od, opts->pzProgName, od->pz_Name);
- option_exits(EX_SOFTWARE);
-}
-
-/**
- * Print out the usage information for just the options.
- */
-static void
-prt_opt_usage(tOptions * opts, int ex_code, char const * title)
-{
- int ct = opts->optCt;
- int optNo = 0;
- tOptDesc * od = opts->pOptDesc;
- int docCt = 0;
-
- do {
- /*
- * no usage --> disallowed on command line (OPTST_NO_COMMAND), or
- * deprecated -- strongly discouraged (OPTST_DEPRECATED), or
- * compiled out of current object code (OPTST_OMITTED)
- */
- if ((od->fOptState & OPTST_NO_USAGE_MASK) != 0) {
-
- /*
- * IF this is a compiled-out option
- * *AND* usage was requested with "omitted-usage"
- * *AND* this is NOT abbreviated usage
- * THEN display this option.
- */
- if ( (od->fOptState == (OPTST_OMITTED | OPTST_NO_INIT))
- && (od->pz_Name != NULL)
- && (ex_code == EXIT_SUCCESS)) {
-
- char const * why_pz =
- (od->pzText == NULL) ? zDisabledWhy : od->pzText;
- prt_preamble(opts, od, &argTypes);
- fprintf(option_usage_fp, zDisabledOpt, od->pz_Name, why_pz);
- }
-
- continue;
- }
-
- if ((od->fOptState & OPTST_DOCUMENT) != 0) {
- if (ex_code == EXIT_SUCCESS) {
- fprintf(option_usage_fp, argTypes.pzBrk, od->pzText,
- title);
- docCt++;
- }
-
- continue;
- }
-
- /* Skip name only options when we have a vendor option */
- if ( ((opts->fOptSet & OPTPROC_VENDOR_OPT) != 0)
- && (! GRAPH_CH(od->optValue)))
- continue;
-
- /*
- * IF this is the first auto-opt maintained option
- * *AND* we are doing a full help
- * *AND* there are documentation options
- * *AND* the last one was not a doc option,
- * THEN document that the remaining options are not user opts
- */
- if ((docCt > 0) && (ex_code == EXIT_SUCCESS)) {
- if (opts->presetOptCt == optNo) {
- if ((od[-1].fOptState & OPTST_DOCUMENT) == 0)
- fprintf(option_usage_fp, argTypes.pzBrk, zAuto, title);
-
- } else if ((ct == 1) &&
- (opts->fOptSet & OPTPROC_VENDOR_OPT))
- fprintf(option_usage_fp, argTypes.pzBrk, zVendIntro, title);
- }
-
- prt_one_usage(opts, od, &argTypes);
-
- /*
- * IF we were invoked because of the --help option,
- * THEN print all the extra info
- */
- if (ex_code == EXIT_SUCCESS)
- prt_extd_usage(opts, od, title);
-
- } while (od++, optNo++, (--ct > 0));
-
- fputc(NL, option_usage_fp);
-}
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/**
- * Print program details.
- * @param[in] opts the program option descriptor
- */
-static void
-prt_prog_detail(tOptions * opts)
-{
- bool need_intro = (opts->papzHomeList == NULL);
-
- /*
- * Display all the places we look for config files, if we have
- * a list of directories to search.
- */
- if (! need_intro)
- prt_ini_list(opts->papzHomeList, opts->pzRcName, opts->pzProgPath);
-
- /*
- * Let the user know about environment variable settings
- */
- if ((opts->fOptSet & OPTPROC_ENVIRON) != 0) {
- if (need_intro)
- fputs(zPresetIntro, option_usage_fp);
-
- fprintf(option_usage_fp, zExamineFmt, opts->pzPROGNAME);
- }
-
- /*
- * IF we found an enumeration,
- * THEN hunt for it again. Call the handler proc with a NULL
- * option struct pointer. That tells it to display the keywords.
- */
- if (displayEnum) {
- int ct = opts->optCt;
- int optNo = 0;
- tOptDesc * od = opts->pOptDesc;
-
- fputc(NL, option_usage_fp);
- fflush(option_usage_fp);
- do {
- switch (OPTST_GET_ARGTYPE(od->fOptState)) {
- case OPARG_TYPE_ENUMERATION:
- case OPARG_TYPE_MEMBERSHIP:
- (*(od->pOptProc))(OPTPROC_EMIT_USAGE, od);
- }
- } while (od++, optNo++, (--ct > 0));
- }
-
- /*
- * If there is a detail string, now is the time for that.
- */
- if (opts->pzDetail != NULL)
- fputs(opts->pzDetail, option_usage_fp);
-}
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *
- * OPTION LINE FORMATTING SETUP
- *
- * The "OptFmt" formats receive three arguments:
- * 1. the type of the option's argument
- * 2. the long name of the option
- * 3. "YES" or "no ", depending on whether or not the option must appear
- * on the command line.
- * These formats are used immediately after the option flag (if used) has
- * been printed.
- *
- * Set up the formatting for GNU-style output
- */
-static int
-setGnuOptFmts(tOptions * opts, char const ** ptxt)
-{
- static char const zOneSpace[] = " ";
- int flen = 22;
- *ptxt = zNoRq_ShrtTtl;
-
- argTypes.pzStr = zGnuStrArg;
- argTypes.pzReq = zOneSpace;
- argTypes.pzNum = zGnuNumArg;
- argTypes.pzKey = zGnuKeyArg;
- argTypes.pzKeyL = zGnuKeyLArg;
- argTypes.pzTime = zGnuTimeArg;
- argTypes.pzFile = zGnuFileArg;
- argTypes.pzBool = zGnuBoolArg;
- argTypes.pzNest = zGnuNestArg;
- argTypes.pzOpt = zGnuOptArg;
- argTypes.pzNo = zOneSpace;
- argTypes.pzBrk = zGnuBreak;
- argTypes.pzNoF = zSixSpaces;
- argTypes.pzSpc = zThreeSpaces;
-
- switch (opts->fOptSet & OPTPROC_L_N_S) {
- case OPTPROC_L_N_S: argTypes.pzOptFmt = zGnuOptFmt; break;
- case OPTPROC_LONGOPT: argTypes.pzOptFmt = zGnuOptFmt; break;
- case 0: argTypes.pzOptFmt = zGnuOptFmt + 2; break;
- case OPTPROC_SHORTOPT:
- argTypes.pzOptFmt = zShrtGnuOptFmt;
- zGnuStrArg[0] = zGnuNumArg[0] = zGnuKeyArg[0] = zGnuBoolArg[0] = ' ';
- argTypes.pzOpt = " [arg]";
- flen = 8;
- break;
- }
-
- return flen;
-}
-
-
-/*
- * Standard (AutoOpts normal) option line formatting
- */
-static int
-setStdOptFmts(tOptions * opts, char const ** ptxt)
-{
- int flen = 0;
-
- argTypes.pzStr = zStdStrArg;
- argTypes.pzReq = zStdReqArg;
- argTypes.pzNum = zStdNumArg;
- argTypes.pzKey = zStdKeyArg;
- argTypes.pzKeyL = zStdKeyLArg;
- argTypes.pzTime = zStdTimeArg;
- argTypes.pzFile = zStdFileArg;
- argTypes.pzBool = zStdBoolArg;
- argTypes.pzNest = zStdNestArg;
- argTypes.pzOpt = zStdOptArg;
- argTypes.pzNo = zStdNoArg;
- argTypes.pzBrk = zStdBreak;
- argTypes.pzNoF = zFiveSpaces;
- argTypes.pzSpc = zTwoSpaces;
-
- switch (opts->fOptSet & (OPTPROC_NO_REQ_OPT | OPTPROC_SHORTOPT)) {
- case (OPTPROC_NO_REQ_OPT | OPTPROC_SHORTOPT):
- *ptxt = zNoRq_ShrtTtl;
- argTypes.pzOptFmt = zNrmOptFmt;
- flen = 19;
- break;
-
- case OPTPROC_NO_REQ_OPT:
- *ptxt = zNoRq_NoShrtTtl;
- argTypes.pzOptFmt = zNrmOptFmt;
- flen = 19;
- break;
-
- case OPTPROC_SHORTOPT:
- *ptxt = zReq_ShrtTtl;
- argTypes.pzOptFmt = zReqOptFmt;
- flen = 24;
- break;
-
- case 0:
- *ptxt = zReq_NoShrtTtl;
- argTypes.pzOptFmt = zReqOptFmt;
- flen = 24;
- }
-
- return flen;
-}
-
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/usage.c */
diff --git a/src/libopts/value-type.c b/src/libopts/value-type.c
deleted file mode 100644
index ff98c0a1ed..0000000000
--- a/src/libopts/value-type.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/* ANSI-C code produced by gperf version 3.0.4 */
-
-
-#if 0 /* gperf build options: */
-// %struct-type
-// %language=ANSI-C
-// %includes
-// %global-table
-// %omit-struct-type
-// %readonly-tables
-// %compare-strncmp
-//
-// %define slot-name vtp_name
-// %define hash-function-name value_type_hash
-// %define lookup-function-name find_value_type_name
-// %define word-array-name value_type_table
-// %define initializer-suffix ,VTP_COUNT_KWD
-#endif /* gperf build options: */
-
-#include "value-type.h"
-
-typedef struct {
- char const * vtp_name;
- value_type_enum_t vtp_id;
-} value_type_map_t;
-#include <string.h>
-
-/* maximum key range = 20, duplicates = 0 */
-
-#ifdef __GNUC__
-#else
-#ifdef __cplusplus
-#endif
-#endif
-inline static unsigned int
-value_type_hash (register const char *str, register unsigned int len)
-{
- static const unsigned char asso_values[] =
- {
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 10, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 5, 23, 23, 5, 0, 0, 23, 15, 23,
- 23, 10, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23
- };
- return len + asso_values[(unsigned char)str[2]];
-}
-
-static const value_type_map_t value_type_table[] =
- {
- {"",VTP_COUNT_KWD}, {"",VTP_COUNT_KWD},
- {"",VTP_COUNT_KWD},
- {"set", VTP_KWD_SET},
- {"",VTP_COUNT_KWD}, {"",VTP_COUNT_KWD},
- {"nested", VTP_KWD_NESTED},
- {"integer", VTP_KWD_INTEGER},
- {"",VTP_COUNT_KWD},
- {"bool", VTP_KWD_BOOL},
- {"",VTP_COUNT_KWD},
- {"string", VTP_KWD_STRING},
- {"boolean", VTP_KWD_BOOLEAN},
- {"",VTP_COUNT_KWD},
- {"set-membership", VTP_KWD_SET_MEMBERSHIP},
- {"",VTP_COUNT_KWD}, {"",VTP_COUNT_KWD},
- {"keyword", VTP_KWD_KEYWORD},
- {"",VTP_COUNT_KWD},
- {"hierarchy", VTP_KWD_HIERARCHY},
- {"",VTP_COUNT_KWD}, {"",VTP_COUNT_KWD},
- {"invalid", VTP_KWD_INVALID}
- };
-
-#ifdef __GNUC__
-#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
-__attribute__ ((__gnu_inline__))
-#endif
-#endif
-static inline const value_type_map_t *
-find_value_type_name (register const char *str, register unsigned int len)
-{
- if (len <= 14 && len >= 3)
- {
- register int key = value_type_hash (str, len);
-
- if (key <= 22 && key >= 0)
- {
- register const char *s = value_type_table[key].vtp_name;
-
- if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
- return &value_type_table[key];
- }
- }
- return 0;
-}
-
-
-value_type_enum_t
-find_value_type_id(char const * str, unsigned int len)
-{
- const value_type_map_t * p =
- find_value_type_name(str, len);
- return (p == 0) ? VTP_KWD_INVALID : p->vtp_id;
-}
diff --git a/src/libopts/value-type.h b/src/libopts/value-type.h
deleted file mode 100644
index d91b0fe616..0000000000
--- a/src/libopts/value-type.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Generated header for gperf generated source Sun May 6 16:20:59 PDT 2012
- * This file enumerates the list of names and declares the
- * procedure for mapping string names to the enum value.
- */
-#ifndef AUTOOPTS_VALUE_TYPE_H_GUARD
-#define AUTOOPTS_VALUE_TYPE_H_GUARD 1
-
-typedef enum {
- VTP_KWD_INVALID,
- VTP_KWD_STRING,
- VTP_KWD_INTEGER,
- VTP_KWD_BOOLEAN,
- VTP_KWD_BOOL,
- VTP_KWD_KEYWORD,
- VTP_KWD_SET,
- VTP_KWD_SET_MEMBERSHIP,
- VTP_KWD_NESTED,
- VTP_KWD_HIERARCHY,
- VTP_COUNT_KWD
-} value_type_enum_t;
-
-extern value_type_enum_t
-find_value_type_id(char const * str, unsigned int len);
-#endif /* AUTOOPTS_VALUE_TYPE_H_GUARD */
diff --git a/src/libopts/version.c b/src/libopts/version.c
deleted file mode 100644
index cd46be3a4d..0000000000
--- a/src/libopts/version.c
+++ /dev/null
@@ -1,240 +0,0 @@
-
-/** \file version.c
- *
- * This module implements the default usage procedure for
- * Automated Options. It may be overridden, of course.
- *
- * @addtogroup autoopts
- * @{
- */
-/*
- * This file is part of AutoOpts, a companion to AutoGen.
- * AutoOpts is free software.
- * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
- *
- * AutoOpts is available under any one of two licenses. The license
- * in use must be one of these two and the choice is under the control
- * of the user of the license.
- *
- * The GNU Lesser General Public License, version 3 or later
- * See the files "COPYING.lgplv3" and "COPYING.gplv3"
- *
- * The Modified Berkeley Software Distribution License
- * See the file "COPYING.mbsd"
- *
- * These files have the following sha256 sums:
- *
- * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
- * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
- * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
- */
-
-/*=export_func optionVersion
- *
- * what: return the compiled AutoOpts version number
- * ret_type: char const *
- * ret_desc: the version string in constant memory
- * doc:
- * Returns the full version string compiled into the library.
- * The returned string cannot be modified.
-=*/
-char const *
-optionVersion(void)
-{
- static char const ver[] = OPTIONS_DOTTED_VERSION;
- return ver;
-}
-
-static void
-emit_first_line(
- FILE * fp, char const * alt1, char const * alt2, char const * alt3)
-{
- char const * p = (alt1 != NULL) ? alt1 : ((alt2 != NULL) ? alt2 : alt3);
- char const * e;
- if (p == NULL)
- return;
- e = strchr(p, NL);
- if (e == NULL)
- fputs(p, fp);
- else
- fwrite(p, 1, (e - p), fp);
- fputc(NL, fp);
-}
-
-/**
- * Select among various ways to emit version information.
- *
- * @param[in] o the option descriptor
- * @param[in] fp the output stream
- */
-static void
-emit_simple_ver(tOptions * o, FILE * fp)
-{
- emit_first_line(fp, o->pzFullVersion, o->pzCopyright, o->pzUsageTitle);
-}
-
-/**
- * print the version with a copyright notice.
- *
- * @param[in] o the option descriptor
- * @param[in] fp the output stream
- */
-static void
-emit_copy_full(tOptions * o, FILE * fp)
-{
- if (o->pzCopyright != NULL)
- fputs(o->pzCopyright, fp);
-
- else if (o->pzFullVersion != NULL)
- fputs(o->pzFullVersion, fp);
-
- else
- emit_first_line(fp, o->pzUsageTitle, NULL, NULL);
-
- if (HAS_pzPkgDataDir(o) && (o->pzPackager != NULL)) {
- fputc(NL, fp);
- fputs(o->pzPackager, fp);
-
- } else if (o->pzBugAddr != NULL) {
- fputc(NL, fp);
- fprintf(fp, zPlsSendBugs, o->pzBugAddr);
- }
-}
-
-/**
- * print the version and any copyright notice.
- * The version with a full copyright and additional notes.
- *
- * @param[in] opts the option descriptor
- * @param[in] fp the output stream
- */
-static void
-emit_copy_note(tOptions * opts, FILE * fp)
-{
- if (opts->pzCopyright != NULL)
- fputs(opts->pzCopyright, fp);
-
- if (opts->pzCopyNotice != NULL)
- fputs(opts->pzCopyNotice, fp);
-
- fputc(NL, fp);
- fprintf(fp, zao_ver_fmt, optionVersion());
-
- if (HAS_pzPkgDataDir(opts) && (opts->pzPackager != NULL)) {
- fputc(NL, fp);
- fputs(opts->pzPackager, fp);
-
- } else if (opts->pzBugAddr != NULL) {
- fputc(NL, fp);
- fprintf(fp, zPlsSendBugs, opts->pzBugAddr);
- }
-}
-
-/**
- * Handle the version printing. We must see how much information
- * is being requested and select the correct printing routine.
- */
-static void
-print_ver(tOptions * opts, tOptDesc * od, FILE * fp, bool call_exit)
-{
- char ch;
-
- if (opts <= OPTPROC_EMIT_LIMIT)
- return;
-
- /*
- * IF we have an argument for this option, use it
- * Otherwise, default to version only or copyright note,
- * depending on whether the layout is GNU standard form or not.
- */
- if ( (od->fOptState & OPTST_ARG_OPTIONAL)
- && (od->optArg.argString != NULL)
- && (od->optArg.argString[0] != NUL))
-
- ch = od->optArg.argString[0];
-
- else if (OPTST_GET_ARGTYPE(od->fOptState) == OPARG_TYPE_STATIC) {
- ch = od->optArg.argString[0];
-
- } else {
- set_usage_flags(opts, NULL);
- ch = (opts->fOptSet & OPTPROC_GNUUSAGE) ? 'c' : 'v';
- }
-
- switch (ch) {
- case NUL: /* arg provided, but empty */
- case 'v': case 'V': emit_simple_ver(opts, fp); break;
- case 'c': case 'C': emit_copy_full( opts, fp); break;
- case 'n': case 'N': emit_copy_note( opts, fp); break;
-
- default:
- fprintf(stderr, zBadVerArg, ch);
- option_exits(EXIT_FAILURE);
- }
-
- fflush(fp);
- if (ferror(fp))
- fserr_exit(opts->pzProgName, zwriting,
- (fp == stdout) ? zstdout_name : zstderr_name);
-
- if (call_exit)
- option_exits(EXIT_SUCCESS);
-}
-
-/*=export_func optionPrintVersion
- *
- * what: Print the program version
- * arg: + tOptions * + opts + program options descriptor +
- * arg: + tOptDesc * + od + the descriptor for this arg +
- *
- * doc:
- * This routine will print the version to stdout.
-=*/
-void
-optionPrintVersion(tOptions * opts, tOptDesc * od)
-{
- print_ver(opts, od, print_exit ? stderr : stdout, true);
-}
-
-/*=export_func optionPrintVersionAndReturn
- *
- * what: Print the program version
- * arg: + tOptions * + opts + program options descriptor +
- * arg: + tOptDesc * + od + the descriptor for this arg +
- *
- * doc:
- * This routine will print the version to stdout and return
- * instead of exiting. Please see the source for the
- * @code{print_ver} funtion for details on selecting how
- * verbose to be after this function returns.
-=*/
-void
-optionPrintVersionAndReturn(tOptions * opts, tOptDesc * od)
-{
- print_ver(opts, od, print_exit ? stderr : stdout, false);
-}
-
-/*=export_func optionVersionStderr
- * private:
- *
- * what: Print the program version to stderr
- * arg: + tOptions * + opts + program options descriptor +
- * arg: + tOptDesc * + od + the descriptor for this arg +
- *
- * doc:
- * This routine will print the version to stderr.
-=*/
-void
-optionVersionStderr(tOptions * opts, tOptDesc * od)
-{
- print_ver(opts, od, stderr, true);
-}
-
-/** @}
- *
- * Local Variables:
- * mode: C
- * c-file-style: "stroustrup"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/version.c */
diff --git a/src/libopts/xat-attribute.c b/src/libopts/xat-attribute.c
deleted file mode 100644
index db47531240..0000000000
--- a/src/libopts/xat-attribute.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/* ANSI-C code produced by gperf version 3.0.4 */
-
-
-#if 0 /* gperf build options: */
-// %struct-type
-// %language=ANSI-C
-// %includes
-// %global-table
-// %omit-struct-type
-// %readonly-tables
-// %compare-strncmp
-//
-// %define slot-name xat_name
-// %define hash-function-name xat_attribute_hash
-// %define lookup-function-name find_xat_attribute_name
-// %define word-array-name xat_attribute_table
-// %define initializer-suffix ,XAT_COUNT_KWD
-#endif /* gperf build options: */
-
-#include "xat-attribute.h"
-
-typedef struct {
- char const * xat_name;
- xat_attribute_enum_t xat_id;
-} xat_attribute_map_t;
-#include <string.h>
-
-/* maximum key range = 9, duplicates = 0 */
-
-#ifdef __GNUC__
-#else
-#ifdef __cplusplus
-#endif
-#endif
-inline static unsigned int
-xat_attribute_hash (register const char *str, register unsigned int len)
-{
- static const unsigned char asso_values[] =
- {
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 0,
- 13, 13, 13, 13, 13, 5, 13, 5, 13, 0,
- 13, 13, 13, 13, 13, 13, 0, 0, 13, 0,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13
- };
- return len + asso_values[(unsigned char)str[0]];
-}
-
-static const xat_attribute_map_t xat_attribute_table[] =
- {
- {"",XAT_COUNT_KWD}, {"",XAT_COUNT_KWD},
- {"",XAT_COUNT_KWD}, {"",XAT_COUNT_KWD},
- {"type", XAT_KWD_TYPE},
- {"words", XAT_KWD_WORDS},
- {"cooked", XAT_KWD_COOKED},
- {"members", XAT_KWD_MEMBERS},
- {"uncooked", XAT_KWD_UNCOOKED},
- {"keep", XAT_KWD_KEEP},
- {"",XAT_COUNT_KWD}, {"",XAT_COUNT_KWD},
- {"invalid", XAT_KWD_INVALID}
- };
-
-#ifdef __GNUC__
-#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
-__attribute__ ((__gnu_inline__))
-#endif
-#endif
-static inline const xat_attribute_map_t *
-find_xat_attribute_name (register const char *str, register unsigned int len)
-{
- if (len <= 8 && len >= 4)
- {
- register int key = xat_attribute_hash (str, len);
-
- if (key <= 12 && key >= 0)
- {
- register const char *s = xat_attribute_table[key].xat_name;
-
- if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
- return &xat_attribute_table[key];
- }
- }
- return 0;
-}
-
-
-xat_attribute_enum_t
-find_xat_attribute_id(char const * str, unsigned int len)
-{
- const xat_attribute_map_t * p =
- find_xat_attribute_name(str, len);
- return (p == 0) ? XAT_KWD_INVALID : p->xat_id;
-}
diff --git a/src/libopts/xat-attribute.h b/src/libopts/xat-attribute.h
deleted file mode 100644
index e12bd4a323..0000000000
--- a/src/libopts/xat-attribute.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Generated header for gperf generated source Sun May 6 16:20:59 PDT 2012
- * This file enumerates the list of names and declares the
- * procedure for mapping string names to the enum value.
- */
-#ifndef AUTOOPTS_XAT_ATTRIBUTE_H_GUARD
-#define AUTOOPTS_XAT_ATTRIBUTE_H_GUARD 1
-
-typedef enum {
- XAT_KWD_INVALID,
- XAT_KWD_TYPE,
- XAT_KWD_WORDS,
- XAT_KWD_MEMBERS,
- XAT_KWD_COOKED,
- XAT_KWD_UNCOOKED,
- XAT_KWD_KEEP,
- XAT_COUNT_KWD
-} xat_attribute_enum_t;
-
-extern xat_attribute_enum_t
-find_xat_attribute_id(char const * str, unsigned int len);
-#endif /* AUTOOPTS_XAT_ATTRIBUTE_H_GUARD */
diff --git a/src/ocsptool-args.def b/src/ocsptool-args.def
deleted file mode 100644
index c0d54e5c07..0000000000
--- a/src/ocsptool-args.def
+++ /dev/null
@@ -1,317 +0,0 @@
-AutoGen Definitions options;
-prog-name = ocsptool;
-prog-title = "GnuTLS OCSP tool";
-prog-desc = "Program to handle OCSP request/responses.";
-detail = "ocsptool is a program that can parse and print information about
-OCSP requests/responses, generate requests and verify responses. Unlike
-other GnuTLS applications it outputs DER encoded structures by default
-unless the '--outpem' option is specified.";
-short-usage = "ocsptool [options]\nocsptool --help for usage instructions.\n";
-explain = "";
-
-doc-section = {
- ds-type = 'DESCRIPTION';
- ds-format = 'texi';
- ds-text = <<-_EOT_
-@subheading On verification
-Responses are typically signed/issued by designated certificates or
-certificate authorities and thus this tool requires on verification
-the certificate of the issuer or the full certificate chain in order to
-determine the appropriate signing authority. The specified certificate
-of the issuer is assumed trusted.
-_EOT_;
-};
-
-#define INFILE_OPT 1
-#define OUTFILE_OPT 1
-#define VERBOSE_OPT 1
-#include args-std.def
-
-flag = {
- name = ask;
- arg-type = string;
- arg-name = "server name|url";
- arg-optional;
- descrip = "Ask an OCSP/HTTP server on a certificate validity";
- doc = "Connects to the specified HTTP OCSP server and queries on the validity of the loaded certificate.
-Its argument can be a URL or a plain server name. It can be combined with --load-chain, where it checks
-all certificates in the provided chain, or with --load-cert and
---load-issuer options. The latter checks the provided certificate
-against its specified issuer certificate.";
-};
-
-flag = {
- name = verify-response;
- value = e;
- descrip = "Verify response";
- doc = "Verifies the provided OCSP response against the system trust
-anchors (unless --load-trust is provided). It requires the --load-signer
-or --load-chain options to obtain the signer of the OCSP response.";
-};
-
-flag = {
- name = request-info;
- value = i;
- descrip = "Print information on a OCSP request";
- doc = "Display detailed information on the provided OCSP request.";
-};
-
-flag = {
- name = response-info;
- value = j;
- descrip = "Print information on a OCSP response";
- doc = "Display detailed information on the provided OCSP response.";
-};
-
-flag = {
- name = generate-request;
- value = q;
- descrip = "Generates an OCSP request";
- doc = "";
-};
-
-flag = {
- name = nonce;
- disabled = yes;
- disable = "no";
- descrip = "Use (or not) a nonce to OCSP request";
- doc = "";
-};
-
-flag = {
- name = load-chain;
- arg-type = file;
- file-exists = yes;
- descrip = "Reads a set of certificates forming a chain from file";
- doc = "";
-};
-
-flag = {
- name = load-issuer;
- arg-type = file;
- file-exists = yes;
- descrip = "Reads issuer's certificate from file";
- doc = "";
-};
-
-flag = {
- name = load-cert;
- arg-type = file;
- file-exists = yes;
- descrip = "Reads the certificate to check from file";
- doc = "";
-};
-
-flag = {
- name = load-trust;
- arg-type = file;
- file-exists = yes;
- descrip = "Read OCSP trust anchors from file";
- flags-cant = load-signer;
- doc = "When verifying an OCSP response read the trust anchors from the
-provided file. When this is not provided, the system's trust anchors will be
-used.";
-};
-
-flag = {
- name = load-signer;
- arg-type = file;
- file-exists = yes;
- descrip = "Reads the OCSP response signer from file";
- flags-cant = load-trust;
- doc = "";
-};
-
-flag = {
- name = inder;
- disabled;
- disable = "no";
- descrip = "Use DER format for input certificates and private keys";
- doc = "";
-};
-
-flag = {
- name = outder;
- descrip = "Use DER format for output of responses (this is the default)";
- doc = "The output will be in DER encoded format. Unlike other GnuTLS tools, this is the default for this tool";
-};
-
-flag = {
- name = outpem;
- descrip = "Use PEM format for output of responses";
- doc = "The output will be in PEM format.";
-};
-
-flag = {
- name = load-request;
- value = Q;
- arg-type = file;
- file-exists = yes;
- descrip = "Reads the DER encoded OCSP request from file";
- doc = "";
-};
-
-flag = {
- name = load-response;
- value = S;
- arg-type = file;
- file-exists = yes;
- descrip = "Reads the DER encoded OCSP response from file";
- doc = "";
-};
-
-flag = {
- name = ignore-errors;
- descrip = "Ignore any verification errors";
- doc = "";
-};
-
-flag = {
- name = verify-allow-broken;
- descrip = "Allow broken algorithms, such as MD5 for verification";
- doc = "This can be combined with --verify-response.";
-};
-
-doc-section = {
- ds-type = 'SEE ALSO';
- ds-format = 'texi';
- ds-text = <<-_EOT_
- certtool (1)
-_EOT_;
-};
-
-doc-section = {
- ds-type = 'EXAMPLES';
- ds-format = 'texi';
- ds-text = <<-_EOF_
-@subheading Print information about an OCSP request
-
-To parse an OCSP request and print information about the content, the
-@code{-i} or @code{--request-info} parameter may be used as follows.
-The @code{-Q} parameter specify the name of the file containing the
-OCSP request, and it should contain the OCSP request in binary DER
-format.
-
-@example
-$ ocsptool -i -Q ocsp-request.der
-@end example
-
-The input file may also be sent to standard input like this:
-
-@example
-$ cat ocsp-request.der | ocsptool --request-info
-@end example
-
-@subheading Print information about an OCSP response
-
-Similar to parsing OCSP requests, OCSP responses can be parsed using
-the @code{-j} or @code{--response-info} as follows.
-
-@example
-$ ocsptool -j -Q ocsp-response.der
-$ cat ocsp-response.der | ocsptool --response-info
-@end example
-
-@subheading Generate an OCSP request
-
-The @code{-q} or @code{--generate-request} parameters are used to
-generate an OCSP request. By default the OCSP request is written to
-standard output in binary DER format, but can be stored in a file
-using @code{--outfile}. To generate an OCSP request the issuer of the
-certificate to check needs to be specified with @code{--load-issuer}
-and the certificate to check with @code{--load-cert}. By default PEM
-format is used for these files, although @code{--inder} can be used to
-specify that the input files are in DER format.
-
-@example
-$ ocsptool -q --load-issuer issuer.pem --load-cert client.pem \
- --outfile ocsp-request.der
-@end example
-
-When generating OCSP requests, the tool will add an OCSP extension
-containing a nonce. This behaviour can be disabled by specifying
-@code{--no-nonce}.
-
-@subheading Verify signature in OCSP response
-
-To verify the signature in an OCSP response the @code{-e} or
-@code{--verify-response} parameter is used. The tool will read an
-OCSP response in DER format from standard input, or from the file
-specified by @code{--load-response}. The OCSP response is verified
-against a set of trust anchors, which are specified using
-@code{--load-trust}. The trust anchors are concatenated certificates
-in PEM format. The certificate that signed the OCSP response needs to
-be in the set of trust anchors, or the issuer of the signer
-certificate needs to be in the set of trust anchors and the OCSP
-Extended Key Usage bit has to be asserted in the signer certificate.
-
-@example
-$ ocsptool -e --load-trust issuer.pem \
- --load-response ocsp-response.der
-@end example
-
-The tool will print status of verification.
-
-@subheading Verify signature in OCSP response against given certificate
-
-It is possible to override the normal trust logic if you know that a
-certain certificate is supposed to have signed the OCSP response, and
-you want to use it to check the signature. This is achieved using
-@code{--load-signer} instead of @code{--load-trust}. This will load
-one certificate and it will be used to verify the signature in the
-OCSP response. It will not check the Extended Key Usage bit.
-
-@example
-$ ocsptool -e --load-signer ocsp-signer.pem \
- --load-response ocsp-response.der
-@end example
-
-This approach is normally only relevant in two situations. The first
-is when the OCSP response does not contain a copy of the signer
-certificate, so the @code{--load-trust} code would fail. The second
-is if you want to avoid the indirect mode where the OCSP response
-signer certificate is signed by a trust anchor.
-
-@subheading Real-world example
-
-Here is an example of how to generate an OCSP request for a
-certificate and to verify the response. For illustration we'll use
-the @code{blog.josefsson.org} host, which (as of writing) uses a
-certificate from CACert. First we'll use @code{gnutls-cli} to get a
-copy of the server certificate chain. The server is not required to
-send this information, but this particular one is configured to do so.
-
-@example
-$ echo | gnutls-cli -p 443 blog.josefsson.org --save-cert chain.pem
-@end example
-
-The saved certificates normally contain a pointer to where the OCSP
-responder is located, in the Authority Information Access Information
-extension. For example, from @code{certtool -i < chain.pem} there is
-this information:
-
-@example
- Authority Information Access Information (not critical):
- Access Method: 1.3.6.1.5.5.7.48.1 (id-ad-ocsp)
- Access Location URI: https://ocsp.CAcert.org/
-@end example
-
-This means that ocsptool can discover the servers to contact over HTTP.
-We can now request information on the chain certificates.
-
-@example
-$ ocsptool --ask --load-chain chain.pem
-@end example
-
-The request is sent via HTTP to the OCSP server address found in
-the certificates. It is possible to override the address of the
-OCSP server as well as ask information on a particular certificate
-using --load-cert and --load-issuer.
-
-@example
-$ ocsptool --ask https://ocsp.CAcert.org/ --load-chain chain.pem
-@end example
-
-_EOF_;
-};
-
diff --git a/src/ocsptool-options.json b/src/ocsptool-options.json
new file mode 100644
index 0000000000..f3b4116190
--- /dev/null
+++ b/src/ocsptool-options.json
@@ -0,0 +1,164 @@
+[
+ {
+ "meta": {
+ "explain": "",
+ "prog-title": "GnuTLS OCSP tool",
+ "desc": "",
+ "prog-name": "ocsptool",
+ "detail": "ocsptool is a program that can parse and print information about\nOCSP requests/responses, generate requests and verify responses. Unlike\nother GnuTLS applications it outputs DER encoded structures by default\nunless the '--outpem' option is specified.",
+ "short-usage": "ocsptool [options]\nocsptool --help for usage instructions.\n",
+ "prog-desc": "Program to handle OCSP request/responses."
+ },
+ "options": [
+ {
+ "arg-type": "number",
+ "arg-min": "0 ",
+ "desc": "Enable debugging",
+ "detail": "Specifies the debug level.",
+ "short-option": "d",
+ "arg-max": " 9999",
+ "long-option": "debug"
+ },
+ {
+ "desc": "More verbose output",
+ "detail": "",
+ "short-option": "V",
+ "long-option": "verbose",
+ "disabled": "",
+ "max": "NOLIMIT"
+ },
+ {
+ "long-option": "infile",
+ "arg-type": "file",
+ "desc": "Input file",
+ "file-exists": "yes",
+ "detail": ""
+ },
+ {
+ "arg-type": "string",
+ "long-option": "outfile",
+ "desc": "Output file",
+ "detail": ""
+ },
+ {
+ "arg-type": "string",
+ "detail": "Connects to the specified HTTP OCSP server and queries on the validity of the loaded certificate.\nIts argument can be a URL or a plain server name. It can be combined with --load-chain, where it checks\nall certificates in the provided chain, or with --load-cert and\n--load-issuer options. The latter checks the provided certificate\nagainst its specified issuer certificate.",
+ "long-option": "ask",
+ "arg-name": "server name|url",
+ "arg-optional": "",
+ "desc": "Ask an OCSP/HTTP server on a certificate validity"
+ },
+ {
+ "long-option": "verify-response",
+ "desc": "Verify response",
+ "detail": "Verifies the provided OCSP response against the system trust\nanchors (unless --load-trust is provided). It requires the --load-signer\nor --load-chain options to obtain the signer of the OCSP response.",
+ "short-option": "e"
+ },
+ {
+ "long-option": "request-info",
+ "short-option": "i",
+ "desc": "Print information on a OCSP request",
+ "detail": "Display detailed information on the provided OCSP request."
+ },
+ {
+ "desc": "Print information on a OCSP response",
+ "detail": "Display detailed information on the provided OCSP response.",
+ "short-option": "j",
+ "long-option": "response-info"
+ },
+ {
+ "detail": "",
+ "desc": "Generates an OCSP request",
+ "short-option": "q",
+ "long-option": "generate-request"
+ },
+ {
+ "disabled": "yes",
+ "detail": "",
+ "long-option": "nonce",
+ "disable-prefix": "no-",
+ "desc": "Use (or not) a nonce to OCSP request"
+ },
+ {
+ "file-exists": "yes",
+ "desc": "Reads a set of certificates forming a chain from file",
+ "detail": "",
+ "arg-type": "file",
+ "long-option": "load-chain"
+ },
+ {
+ "desc": "Reads issuer's certificate from file",
+ "long-option": "load-issuer",
+ "detail": "",
+ "file-exists": "yes",
+ "arg-type": "file"
+ },
+ {
+ "desc": "Reads the certificate to check from file",
+ "file-exists": "yes",
+ "arg-type": "file",
+ "detail": "",
+ "long-option": "load-cert"
+ },
+ {
+ "long-option": "load-trust",
+ "detail": "When verifying an OCSP response read the trust anchors from the\nprovided file. When this is not provided, the system's trust anchors will be\nused.",
+ "arg-type": "file",
+ "file-exists": "yes",
+ "desc": "Read OCSP trust anchors from file",
+ "conflicts": "load-signer"
+ },
+ {
+ "long-option": "load-signer",
+ "arg-type": "file",
+ "file-exists": "yes",
+ "conflicts": "load-trust",
+ "detail": "",
+ "desc": "Reads the OCSP response signer from file"
+ },
+ {
+ "long-option": "inder",
+ "disable-prefix": "no-",
+ "detail": "",
+ "desc": "Use DER format for input certificates and private keys",
+ "disabled": ""
+ },
+ {
+ "detail": "The output will be in DER encoded format. Unlike other GnuTLS tools, this is the default for this tool",
+ "long-option": "outder",
+ "desc": "Use DER format for output of responses (this is the default)"
+ },
+ {
+ "long-option": "outpem",
+ "desc": "Use PEM format for output of responses",
+ "detail": "The output will be in PEM format."
+ },
+ {
+ "file-exists": "yes",
+ "detail": "",
+ "short-option": "Q",
+ "arg-type": "file",
+ "long-option": "load-request",
+ "desc": "Reads the DER encoded OCSP request from file"
+ },
+ {
+ "detail": "",
+ "file-exists": "yes",
+ "long-option": "load-response",
+ "arg-type": "file",
+ "short-option": "S",
+ "desc": "Reads the DER encoded OCSP response from file"
+ },
+ {
+ "desc": "Ignore any verification errors",
+ "long-option": "ignore-errors",
+ "detail": ""
+ },
+ {
+ "detail": "This can be combined with --verify-response.",
+ "long-option": "verify-allow-broken",
+ "desc": "Allow broken algorithms, such as MD5 for verification"
+ }
+ ]
+ }
+] \ No newline at end of file
diff --git a/src/ocsptool.c b/src/ocsptool.c
index a963de039a..8e558dfb83 100644
--- a/src/ocsptool.c
+++ b/src/ocsptool.c
@@ -39,7 +39,7 @@
#include <minmax.h>
#include <ocsptool-common.h>
-#include <ocsptool-args.h>
+#include "ocsptool-options.h"
#include "certtool-common.h"
FILE *outfile;
diff --git a/src/p11tool-args.def b/src/p11tool-args.def
deleted file mode 100644
index 65ed3411f5..0000000000
--- a/src/p11tool-args.def
+++ /dev/null
@@ -1,580 +0,0 @@
-AutoGen Definitions options;
-prog-name = p11tool;
-prog-title = "GnuTLS PKCS #11 tool";
-prog-desc = "Program to handle PKCS #11 smart cards and security modules.\n";
-detail = "Program that allows operations on PKCS #11 smart cards
-and security modules.
-
-To use PKCS #11 tokens with GnuTLS the p11-kit configuration files need to be setup.
-That is create a .module file in /etc/pkcs11/modules with the contents 'module: /path/to/pkcs11.so'.
-Alternatively the configuration file /etc/gnutls/pkcs11.conf has to exist and contain a number
-of lines of the form 'load=/usr/lib/opensc-pkcs11.so'.
-
-You can provide the PIN to be used for the PKCS #11 operations with the environment variables
-GNUTLS_PIN and GNUTLS_SO_PIN.
-";
-
-short-usage = "p11tool [options] [url]\np11tool --help for usage instructions.\n";
-explain = "";
-reorder-args;
-argument = "[url]";
-
-flag = {
- name = token_related_options;
- documentation;
- descrip = "Tokens";
-};
-
-flag = {
- name = list-tokens;
- descrip = "List all available tokens";
- doc = "";
-};
-
-flag = {
- name = list-token-urls;
- descrip = "List the URLs available tokens";
- doc = "This is a more compact version of --list-tokens.";
-};
-
-flag = {
- name = list-mechanisms;
- descrip = "List all available mechanisms in a token";
- doc = "";
-};
-
-flag = {
- name = initialize;
- descrip = "Initializes a PKCS #11 token";
- doc = "";
-};
-
-flag = {
- name = initialize-pin;
- descrip = "Initializes/Resets a PKCS #11 token user PIN";
- doc = "";
-};
-
-flag = {
- name = initialize-so-pin;
- descrip = "Initializes/Resets a PKCS #11 token security officer PIN.";
- doc = "This initializes the security officer's PIN. When used non-interactively use the GNUTLS_NEW_SO_PIN
-environment variables to initialize SO's PIN.";
-};
-
-flag = {
- name = set-pin;
- arg-type = string;
- descrip = "Specify the PIN to use on token operations";
- doc = "Alternatively the GNUTLS_PIN environment variable may be used.";
-};
-
-flag = {
- name = set-so-pin;
- arg-type = string;
- descrip = "Specify the Security Officer's PIN to use on token initialization";
- doc = "Alternatively the GNUTLS_SO_PIN environment variable may be used.";
-};
-
-flag = {
- name = object_list_related_options;
- documentation;
- descrip = "Object listing";
-};
-
-flag = {
- name = list-all;
- descrip = "List all available objects in a token";
- doc = "All objects available in the token will be listed. That includes
-objects which are potentially unaccessible using this tool.";
-};
-
-flag = {
- name = list-all-certs;
- descrip = "List all available certificates in a token";
- doc = "That option will also provide more information on the
-certificates, for example, expand the attached extensions in a trust
-token (like p11-kit-trust).";
-};
-
-flag = {
- name = list-certs;
- descrip = "List all certificates that have an associated private key";
- doc = "That option will only display certificates which have a private
-key associated with them (share the same ID).";
-};
-
-flag = {
- name = list-all-privkeys;
- descrip = "List all available private keys in a token";
- doc = "Lists all the private keys in a token that match the specified URL.";
-};
-
-flag = {
- name = list-privkeys;
- aliases = list-all-privkeys;
-};
-
-flag = {
- name = list-keys;
- aliases = list-all-privkeys;
-};
-
-flag = {
- name = list-all-trusted;
- descrip = "List all available certificates marked as trusted";
- doc = "";
-};
-
-flag = {
- name = export;
- descrip = "Export the object specified by the URL";
- doc = "";
- flags-cant = export-stapled;
- flags-cant = export-chain;
- flags-cant = export-pubkey;
-};
-
-flag = {
- name = export-stapled;
- descrip = "Export the certificate object specified by the URL";
- doc = "Exports the certificate specified by the URL while including any attached extensions to it.
-Since attached extensions are a p11-kit extension, this option is only
-available on p11-kit registered trust modules.";
- flags-cant = export;
- flags-cant = export-chain;
- flags-cant = export-pubkey;
-};
-
-flag = {
- name = export-chain;
- descrip = "Export the certificate specified by the URL and its chain of trust";
- doc = "Exports the certificate specified by the URL and generates its chain of trust based on the stored certificates in the module.";
- flags-cant = export-stapled;
- flags-cant = export;
- flags-cant = export-pubkey;
-};
-
-flag = {
- name = export-pubkey;
- descrip = "Export the public key for a private key";
- doc = "Exports the public key for the specified private key";
- flags-cant = export-stapled;
- flags-cant = export;
- flags-cant = export-chain;
-};
-
-flag = {
- name = info;
- descrip = "List information on an available object in a token";
- doc = "";
-};
-
-flag = {
- name = trusted;
- aliases = mark-trusted;
-};
-
-flag = {
- name = distrusted;
- aliases = mark-distrusted;
-};
-
-flag = {
- name = keygen_related_options;
- documentation;
- descrip = "Key generation";
-};
-
-flag = {
- name = generate-privkey;
- arg-type = string;
- descrip = "Generate private-public key pair of given type";
- doc = "Generates a private-public key pair in the specified token.
-Acceptable types are RSA, ECDSA, Ed25519, and DSA. Should be combined with --sec-param or --bits.";
-};
-
-flag = {
- name = generate-rsa;
- descrip = "Generate an RSA private-public key pair";
- doc = "Generates an RSA private-public key pair on the specified token.
-Should be combined with --sec-param or --bits.";
- deprecated;
-};
-
-flag = {
- name = generate-dsa;
- descrip = "Generate a DSA private-public key pair";
- doc = "Generates a DSA private-public key pair on the specified token.
-Should be combined with --sec-param or --bits.";
- deprecated;
-};
-
-flag = {
- name = generate-ecc;
- descrip = "Generate an ECDSA private-public key pair";
- doc = "Generates an ECDSA private-public key pair on the specified token.
-Should be combined with --curve, --sec-param or --bits.";
- deprecated;
-};
-
-flag = {
- name = bits;
- arg-type = number;
- descrip = "Specify the number of bits for the key generate";
- doc = "For applications which have no key-size restrictions the
---sec-param option is recommended, as the sec-param levels will adapt
-to the acceptable security levels with the new versions of gnutls.";
-};
-
-flag = {
- name = curve;
- arg-type = string;
- descrip = "Specify the curve used for EC key generation";
- doc = "Supported values are secp192r1, secp224r1, secp256r1, secp384r1 and secp521r1.";
-};
-
-flag = {
- name = sec-param;
- arg-type = string;
- arg-name = "Security parameter";
- descrip = "Specify the security level";
- doc = "This is alternative to the bits option. Available options are [low, legacy, medium, high, ultra].";
-};
-
-flag = {
- name = write_object_related_options;
- documentation;
- descrip = "Writing objects";
-};
-
-flag = {
- name = set-id;
- descrip = "Set the CKA_ID (in hex) for the specified by the URL object";
- doc = "Modifies or sets the CKA_ID in the specified by the URL object. The ID should be specified in hexadecimal format without a '0x' prefix.";
- arg-type = string;
- flags_cant = write;
-};
-
-flag = {
- name = set-label;
- descrip = "Set the CKA_LABEL for the specified by the URL object";
- doc = "Modifies or sets the CKA_LABEL in the specified by the URL object";
- arg-type = string;
- flags_cant = write;
- flags_cant = set-id;
-};
-
-flag = {
- name = write;
- descrip = "Writes the loaded objects to a PKCS #11 token";
- doc = "It can be used to write private, public keys, certificates or secret keys to a token. Must be combined with one of --load-privkey, --load-pubkey, --load-certificate option.
-
-When writing a certificate object, its CKA_ID is set to the same CKA_ID of the corresponding public key, if it exists on the token; otherwise it will be derived from the X.509 Subject Key Identifier of the certificate. If this behavior is undesired, write the public key to the token beforehand.";
-};
-
-flag = {
- name = delete;
- descrip = "Deletes the objects matching the given PKCS #11 URL";
- doc = "";
-};
-
-flag = {
- name = label;
- arg-type = string;
- descrip = "Sets a label for the write operation";
- doc = "";
-};
-
-flag = {
- name = id;
- arg-type = string;
- descrip = "Sets an ID for the write operation";
- doc = "Sets the CKA_ID to be set by the write operation. The ID should be specified in hexadecimal format without a '0x' prefix.";
-};
-
-flag = {
- name = mark-wrap;
- disable = "no";
- disabled;
- descrip = "Marks the generated key to be a wrapping key";
- doc = "Marks the generated key with the CKA_WRAP flag.";
-};
-
-flag = {
- name = mark-trusted;
- disable = "no";
- disabled;
- descrip = "Marks the object to be written as trusted";
- doc = "Marks the object to be generated/written with the CKA_TRUST flag.";
- flags_cant = mark-distrusted;
-};
-
-flag = {
- name = mark-distrusted;
- descrip = "When retrieving objects, it requires the objects to be distrusted (blacklisted)";
- doc = "Ensures that the objects retrieved have the CKA_X_TRUST flag.
-This is p11-kit trust module extension, thus this flag is only valid with
-p11-kit registered trust modules.";
- flags_cant = mark-trusted;
-};
-
-flag = {
- name = mark-decrypt;
- disable = "no";
- disabled;
- descrip = "Marks the object to be written for decryption";
- doc = "Marks the object to be generated/written with the CKA_DECRYPT flag set to true.";
-};
-
-flag = {
- name = mark-sign;
- disable = "no";
- disabled;
- descrip = "Marks the object to be written for signature generation";
- doc = "Marks the object to be generated/written with the CKA_SIGN flag set to true.";
-};
-
-flag = {
- name = mark-ca;
- disable = "no";
- disabled;
- descrip = "Marks the object to be written as a CA";
- doc = "Marks the object to be generated/written with the CKA_CERTIFICATE_CATEGORY as CA.";
-};
-
-flag = {
- name = mark-private;
- disable = "no";
- descrip = "Marks the object to be written as private";
- doc = "Marks the object to be generated/written with the CKA_PRIVATE flag. The written object will require a PIN to be used.";
-};
-
-flag = {
- name = ca;
- aliases = mark-ca;
-};
-
-flag = {
- name = private;
- aliases = mark-private;
-};
-
-flag = {
- name = mark-always-authenticate;
- disable = "no";
- descrip = "Marks the object to be written as always authenticate";
- doc = "Marks the object to be generated/written with the CKA_ALWAYS_AUTHENTICATE flag. The written object will Mark the object as requiring authentication (pin entry) before every operation.";
-};
-
-flag = {
- name = secret-key;
- arg-type = string;
- descrip = "Provide a hex encoded secret key";
- doc = "This secret key will be written to the module if --write is specified.";
-};
-
-flag = {
- name = load-privkey;
- arg-type = file;
- file-exists = yes;
- descrip = "Private key file to use";
- doc = "";
-};
-
-flag = {
- name = load-pubkey;
- arg-type = file;
- file-exists = yes;
- descrip = "Public key file to use";
- doc = "";
-};
-
-flag = {
- name = load-certificate;
- arg-type = file;
- file-exists = yes;
- descrip = "Certificate file to use";
- doc = "";
-};
-
-flag = {
- name = other_options;
- documentation;
- descrip = "Other options";
-};
-
-#define OUTFILE_OPT 1
-#include args-std.def
-
-flag = {
- name = login;
- descrip = "Force (user) login to token";
- disabled;
- disable = "no";
- doc = "";
-};
-
-flag = {
- name = so-login;
- descrip = "Force security officer login to token";
- disabled;
- disable = "no";
- doc = "Forces login to the token as security officer (admin).";
-};
-
-flag = {
- name = admin-login;
- aliases = so-login;
-};
-
-flag = {
- name = test-sign;
- descrip = "Tests the signature operation of the provided object";
- doc = "It can be used to test the correct operation of the signature operation.
-If both a private and a public key are available this operation will sign and verify
-the signed data.";
-};
-
-flag = {
- name = sign-params;
- arg-type = string;
- descrip = "Sign with a specific signature algorithm";
- doc = "This option can be combined with --test-sign, to sign with
-a specific signature algorithm variant. The only option supported is 'RSA-PSS', and should be
-specified in order to use RSA-PSS signature on RSA keys.";
-};
-
-flag = {
- name = hash;
- arg-type = string;
- descrip = "Hash algorithm to use for signing";
- doc = "This option can be combined with test-sign. Available hash functions are SHA1, RMD160, SHA256, SHA384, SHA512, SHA3-224, SHA3-256, SHA3-384, SHA3-512.";
-};
-
-flag = {
- name = generate-random;
- descrip = "Generate random data";
- arg-type = number;
- doc = "Asks the token to generate a number of bytes of random bytes.";
-};
-
-flag = {
- name = pkcs8;
- value = 8;
- descrip = "Use PKCS #8 format for private keys";
- doc = "";
-};
-
-flag = {
- name = inder;
- descrip = "Use DER/RAW format for input";
- disabled;
- disable = "no";
- doc = "Use DER/RAW format for input certificates and private keys.";
-};
-
-flag = {
- name = inraw;
- aliases = inder;
-};
-
-flag = {
- name = outder;
- descrip = "Use DER format for output certificates, private keys, and DH parameters";
- disabled;
- disable = "no";
- doc = "The output will be in DER or RAW format.";
-};
-
-flag = {
- name = outraw;
- aliases = outder;
-};
-
-flag = {
- name = provider;
- arg-type = file;
- descrip = "Specify the PKCS #11 provider library";
- doc = "This will override the default options in /etc/gnutls/pkcs11.conf";
-};
-
-flag = {
- name = provider-opts;
- arg-type = string;
- descrip = "Specify parameters for the PKCS #11 provider library";
- doc = "This is a PKCS#11 internal option used by few modules.
- Mainly for testing PKCS#11 modules.";
- deprecated;
-};
-
-flag = {
- name = detailed-url;
- descrip = "Print detailed URLs";
- disabled;
- disable = "no";
- doc = "";
-};
-
-flag = {
- name = only-urls;
- descrip = "Print a compact listing using only the URLs";
- doc = "";
-};
-
-flag = {
- name = batch;
- descrip = "Disable all interaction with the tool";
- doc = "In batch mode there will be no prompts, all parameters need to be specified on command line.";
-};
-
-
-doc-section = {
- ds-type = 'SEE ALSO';
- ds-format = 'texi';
- ds-text = <<-_EOT_
- certtool (1)
-_EOT_;
-};
-
-doc-section = {
- ds-type = 'EXAMPLES';
- ds-format = 'texi';
- ds-text = <<-_EOT_
-To view all tokens in your system use:
-@example
-$ p11tool --list-tokens
-@end example
-
-To view all objects in a token use:
-@example
-$ p11tool --login --list-all "pkcs11:TOKEN-URL"
-@end example
-
-To store a private key and a certificate in a token run:
-@example
-$ p11tool --login --write "pkcs11:URL" --load-privkey key.pem \
- --label "Mykey"
-$ p11tool --login --write "pkcs11:URL" --load-certificate cert.pem \
- --label "Mykey"
-@end example
-Note that some tokens require the same label to be used for the certificate
-and its corresponding private key.
-
-To generate an RSA private key inside the token use:
-@example
-$ p11tool --login --generate-privkey rsa --bits 1024 --label "MyNewKey" \
- --outfile MyNewKey.pub "pkcs11:TOKEN-URL"
-@end example
-The bits parameter in the above example is explicitly set because some
-tokens only support limited choices in the bit length. The output file is the
-corresponding public key. This key can be used to general a certificate
-request with certtool.
-@example
-certtool --generate-request --load-privkey "pkcs11:KEY-URL" \
- --load-pubkey MyNewKey.pub --outfile request.pem
-@end example
-
-_EOT_;
-};
-
diff --git a/src/p11tool-options.json b/src/p11tool-options.json
new file mode 100644
index 0000000000..22be3edde0
--- /dev/null
+++ b/src/p11tool-options.json
@@ -0,0 +1,452 @@
+[
+ {
+ "meta": {
+ "explain": "",
+ "short-usage": "p11tool [options] [url]\np11tool --help for usage instructions.\n",
+ "desc": "",
+ "prog-name": "p11tool",
+ "prog-desc": "Program to handle PKCS #11 smart cards and security modules.\n",
+ "detail": "Program that allows operations on PKCS #11 smart cards\nand security modules. \n\nTo use PKCS #11 tokens with GnuTLS the p11-kit configuration files need to be setup.\nThat is create a .module file in /etc/pkcs11/modules with the contents 'module: /path/to/pkcs11.so'.\nAlternatively the configuration file /etc/gnutls/pkcs11.conf has to exist and contain a number\nof lines of the form 'load=/usr/lib/opensc-pkcs11.so'.\n\nYou can provide the PIN to be used for the PKCS #11 operations with the environment variables\nGNUTLS_PIN and GNUTLS_SO_PIN.\n",
+ "reorder-args": "",
+ "argument": "[url]",
+ "prog-title": "GnuTLS PKCS #11 tool"
+ },
+ "options": []
+ },
+ {
+ "meta": {
+ "desc": "Tokens",
+ "id": "token-related-options"
+ },
+ "options": [
+ {
+ "long-option": "list-tokens",
+ "detail": "",
+ "desc": "List all available tokens"
+ },
+ {
+ "desc": "List the URLs available tokens",
+ "detail": "This is a more compact version of --list-tokens.",
+ "long-option": "list-token-urls"
+ },
+ {
+ "detail": "",
+ "desc": "List all available mechanisms in a token",
+ "long-option": "list-mechanisms"
+ },
+ {
+ "long-option": "initialize",
+ "desc": "Initializes a PKCS #11 token",
+ "detail": ""
+ },
+ {
+ "desc": "Initializes/Resets a PKCS #11 token user PIN",
+ "detail": "",
+ "long-option": "initialize-pin"
+ },
+ {
+ "long-option": "initialize-so-pin",
+ "detail": "This initializes the security officer's PIN. When used non-interactively use the GNUTLS_NEW_SO_PIN\nenvironment variables to initialize SO's PIN.",
+ "desc": "Initializes/Resets a PKCS #11 token security officer PIN."
+ },
+ {
+ "arg-type": "string",
+ "detail": "Alternatively the GNUTLS_PIN environment variable may be used.",
+ "desc": "Specify the PIN to use on token operations",
+ "long-option": "set-pin"
+ },
+ {
+ "desc": "Specify the Security Officer's PIN to use on token initialization",
+ "detail": "Alternatively the GNUTLS_SO_PIN environment variable may be used.",
+ "long-option": "set-so-pin",
+ "arg-type": "string"
+ }
+ ]
+ },
+ {
+ "meta": {
+ "desc": "Object listing",
+ "id": "object-list-related-options"
+ },
+ "options": [
+ {
+ "long-option": "list-all",
+ "detail": "All objects available in the token will be listed. That includes\nobjects which are potentially unaccessible using this tool.",
+ "desc": "List all available objects in a token"
+ },
+ {
+ "detail": "That option will also provide more information on the\ncertificates, for example, expand the attached extensions in a trust\ntoken (like p11-kit-trust).",
+ "desc": "List all available certificates in a token",
+ "long-option": "list-all-certs"
+ },
+ {
+ "detail": "That option will only display certificates which have a private\nkey associated with them (share the same ID).",
+ "long-option": "list-certs",
+ "desc": "List all certificates that have an associated private key"
+ },
+ {
+ "long-option": "list-all-privkeys",
+ "detail": "Lists all the private keys in a token that match the specified URL.",
+ "desc": "List all available private keys in a token"
+ },
+ {
+ "aliases": "list-all-privkeys",
+ "long-option": "list-privkeys"
+ },
+ {
+ "aliases": "list-all-privkeys",
+ "long-option": "list-keys"
+ },
+ {
+ "detail": "",
+ "desc": "List all available certificates marked as trusted",
+ "long-option": "list-all-trusted"
+ },
+ {
+ "detail": "",
+ "conflicts": "export-stapled export-chain export-pubkey",
+ "long-option": "export",
+ "desc": "Export the object specified by the URL"
+ },
+ {
+ "desc": "Export the certificate object specified by the URL",
+ "detail": "Exports the certificate specified by the URL while including any attached extensions to it.\nSince attached extensions are a p11-kit extension, this option is only\navailable on p11-kit registered trust modules.",
+ "conflicts": "export export-chain export-pubkey",
+ "long-option": "export-stapled"
+ },
+ {
+ "conflicts": "export-stapled export export-pubkey",
+ "desc": "Export the certificate specified by the URL and its chain of trust",
+ "detail": "Exports the certificate specified by the URL and generates its chain of trust based on the stored certificates in the module.",
+ "long-option": "export-chain"
+ },
+ {
+ "desc": "Export the public key for a private key",
+ "conflicts": "export-stapled export export-chain",
+ "long-option": "export-pubkey",
+ "detail": "Exports the public key for the specified private key"
+ },
+ {
+ "long-option": "info",
+ "detail": "",
+ "desc": "List information on an available object in a token"
+ },
+ {
+ "aliases": "mark-trusted",
+ "long-option": "trusted"
+ },
+ {
+ "aliases": "mark-distrusted",
+ "long-option": "distrusted"
+ }
+ ]
+ },
+ {
+ "meta": {
+ "desc": "Key generation",
+ "id": "keygen-related-options"
+ },
+ "options": [
+ {
+ "desc": "Generate private-public key pair of given type",
+ "arg-type": "string",
+ "detail": "Generates a private-public key pair in the specified token.\nAcceptable types are RSA, ECDSA, Ed25519, and DSA. Should be combined with --sec-param or --bits.",
+ "long-option": "generate-privkey"
+ },
+ {
+ "desc": "Generate an RSA private-public key pair",
+ "long-option": "generate-rsa",
+ "detail": "Generates an RSA private-public key pair on the specified token.\nShould be combined with --sec-param or --bits.",
+ "deprecated": ""
+ },
+ {
+ "deprecated": "",
+ "desc": "Generate a DSA private-public key pair",
+ "detail": "Generates a DSA private-public key pair on the specified token.\nShould be combined with --sec-param or --bits.",
+ "long-option": "generate-dsa"
+ },
+ {
+ "deprecated": "",
+ "desc": "Generate an ECDSA private-public key pair",
+ "long-option": "generate-ecc",
+ "detail": "Generates an ECDSA private-public key pair on the specified token.\nShould be combined with --curve, --sec-param or --bits."
+ },
+ {
+ "desc": "Specify the number of bits for the key generate",
+ "detail": "For applications which have no key-size restrictions the\n--sec-param option is recommended, as the sec-param levels will adapt\nto the acceptable security levels with the new versions of gnutls.",
+ "long-option": "bits",
+ "arg-type": "number"
+ },
+ {
+ "detail": "Supported values are secp192r1, secp224r1, secp256r1, secp384r1 and secp521r1.",
+ "long-option": "curve",
+ "arg-type": "string",
+ "desc": "Specify the curve used for EC key generation"
+ },
+ {
+ "long-option": "sec-param",
+ "desc": "Specify the security level",
+ "detail": "This is alternative to the bits option. Available options are [low, legacy, medium, high, ultra].",
+ "arg-name": "Security parameter",
+ "arg-type": "string"
+ }
+ ]
+ },
+ {
+ "meta": {
+ "desc": "Writing objects",
+ "id": "write-object-related-options"
+ },
+ "options": [
+ {
+ "conflicts": "write",
+ "arg-type": "string",
+ "long-option": "set-id",
+ "desc": "Set the CKA_ID (in hex) for the specified by the URL object",
+ "detail": "Modifies or sets the CKA_ID in the specified by the URL object. The ID should be specified in hexadecimal format without a '0x' prefix."
+ },
+ {
+ "long-option": "set-label",
+ "desc": "Set the CKA_LABEL for the specified by the URL object",
+ "detail": "Modifies or sets the CKA_LABEL in the specified by the URL object",
+ "conflicts": "write set-id",
+ "arg-type": "string"
+ },
+ {
+ "long-option": "write",
+ "desc": "Writes the loaded objects to a PKCS #11 token",
+ "detail": "It can be used to write private, public keys, certificates or secret keys to a token. Must be combined with one of --load-privkey, --load-pubkey, --load-certificate option.\n\nWhen writing a certificate object, its CKA_ID is set to the same CKA_ID of the corresponding public key, if it exists on the token; otherwise it will be derived from the X.509 Subject Key Identifier of the certificate. If this behavior is undesired, write the public key to the token beforehand."
+ },
+ {
+ "long-option": "delete",
+ "desc": "Deletes the objects matching the given PKCS #11 URL",
+ "detail": ""
+ },
+ {
+ "arg-type": "string",
+ "detail": "",
+ "long-option": "label",
+ "desc": "Sets a label for the write operation"
+ },
+ {
+ "desc": "Sets an ID for the write operation",
+ "detail": "Sets the CKA_ID to be set by the write operation. The ID should be specified in hexadecimal format without a '0x' prefix.",
+ "arg-type": "string",
+ "long-option": "id"
+ },
+ {
+ "detail": "Marks the generated key with the CKA_WRAP flag.",
+ "long-option": "mark-wrap",
+ "disabled": "",
+ "disable-prefix": "no-",
+ "desc": "Marks the generated key to be a wrapping key"
+ },
+ {
+ "disabled": "",
+ "long-option": "mark-trusted",
+ "disable-prefix": "no-",
+ "conflicts": "mark-distrusted",
+ "desc": "Marks the object to be written as trusted",
+ "detail": "Marks the object to be generated/written with the CKA_TRUST flag."
+ },
+ {
+ "detail": "Ensures that the objects retrieved have the CKA_X_TRUST flag.\nThis is p11-kit trust module extension, thus this flag is only valid with\np11-kit registered trust modules.",
+ "desc": "When retrieving objects, it requires the objects to be distrusted (blacklisted)",
+ "conflicts": "mark-trusted",
+ "long-option": "mark-distrusted"
+ },
+ {
+ "disable-prefix": "no-",
+ "desc": "Marks the object to be written for decryption",
+ "detail": "Marks the object to be generated/written with the CKA_DECRYPT flag set to true.",
+ "disabled": "",
+ "long-option": "mark-decrypt"
+ },
+ {
+ "disable-prefix": "no-",
+ "detail": "Marks the object to be generated/written with the CKA_SIGN flag set to true.",
+ "disabled": "",
+ "long-option": "mark-sign",
+ "desc": "Marks the object to be written for signature generation"
+ },
+ {
+ "disable-prefix": "no-",
+ "desc": "Marks the object to be written as a CA",
+ "long-option": "mark-ca",
+ "disabled": "",
+ "detail": "Marks the object to be generated/written with the CKA_CERTIFICATE_CATEGORY as CA."
+ },
+ {
+ "disable-prefix": "no-",
+ "long-option": "mark-private",
+ "desc": "Marks the object to be written as private",
+ "detail": "Marks the object to be generated/written with the CKA_PRIVATE flag. The written object will require a PIN to be used.",
+ "disabled": ""
+ },
+ {
+ "long-option": "ca",
+ "aliases": "mark-ca"
+ },
+ {
+ "aliases": "mark-private",
+ "long-option": "private"
+ },
+ {
+ "disabled": "",
+ "desc": "Marks the object to be written as always authenticate",
+ "long-option": "mark-always-authenticate",
+ "disable-prefix": "no-",
+ "detail": "Marks the object to be generated/written with the CKA_ALWAYS_AUTHENTICATE flag. The written object will Mark the object as requiring authentication (pin entry) before every operation."
+ },
+ {
+ "detail": "This secret key will be written to the module if --write is specified.",
+ "arg-type": "string",
+ "desc": "Provide a hex encoded secret key",
+ "long-option": "secret-key"
+ },
+ {
+ "arg-type": "file",
+ "file-exists": "yes",
+ "long-option": "load-privkey",
+ "desc": "Private key file to use",
+ "detail": ""
+ },
+ {
+ "arg-type": "file",
+ "file-exists": "yes",
+ "desc": "Public key file to use",
+ "long-option": "load-pubkey",
+ "detail": ""
+ },
+ {
+ "arg-type": "file",
+ "desc": "Certificate file to use",
+ "detail": "",
+ "long-option": "load-certificate",
+ "file-exists": "yes"
+ }
+ ]
+ },
+ {
+ "meta": {
+ "desc": "Other options",
+ "id": "other-options"
+ },
+ "options": [
+ {
+ "desc": "Enable debugging",
+ "arg-max": " 9999",
+ "short-option": "d",
+ "arg-type": "number",
+ "detail": "Specifies the debug level.",
+ "arg-min": "0 ",
+ "long-option": "debug"
+ },
+ {
+ "arg-type": "string",
+ "detail": "",
+ "long-option": "outfile",
+ "desc": "Output file"
+ },
+ {
+ "desc": "Force (user) login to token",
+ "detail": "",
+ "long-option": "login",
+ "disable-prefix": "no-",
+ "disabled": ""
+ },
+ {
+ "long-option": "so-login",
+ "disabled": "",
+ "disable-prefix": "no-",
+ "desc": "Force security officer login to token",
+ "detail": "Forces login to the token as security officer (admin)."
+ },
+ {
+ "long-option": "admin-login",
+ "aliases": "so-login"
+ },
+ {
+ "desc": "Tests the signature operation of the provided object",
+ "long-option": "test-sign",
+ "detail": "It can be used to test the correct operation of the signature operation.\nIf both a private and a public key are available this operation will sign and verify\nthe signed data."
+ },
+ {
+ "detail": "This option can be combined with --test-sign, to sign with\na specific signature algorithm variant. The only option supported is 'RSA-PSS', and should be\nspecified in order to use RSA-PSS signature on RSA keys.",
+ "arg-type": "string",
+ "long-option": "sign-params",
+ "desc": "Sign with a specific signature algorithm"
+ },
+ {
+ "long-option": "hash",
+ "detail": "This option can be combined with test-sign. Available hash functions are SHA1, RMD160, SHA256, SHA384, SHA512, SHA3-224, SHA3-256, SHA3-384, SHA3-512.",
+ "desc": "Hash algorithm to use for signing",
+ "arg-type": "string"
+ },
+ {
+ "desc": "Generate random data",
+ "detail": "Asks the token to generate a number of bytes of random bytes.",
+ "arg-type": "number",
+ "long-option": "generate-random"
+ },
+ {
+ "detail": "",
+ "short-option": "8",
+ "long-option": "pkcs8",
+ "desc": "Use PKCS #8 format for private keys"
+ },
+ {
+ "long-option": "inder",
+ "desc": "Use DER/RAW format for input",
+ "disable-prefix": "no-",
+ "detail": "Use DER/RAW format for input certificates and private keys.",
+ "disabled": ""
+ },
+ {
+ "long-option": "inraw",
+ "aliases": "inder"
+ },
+ {
+ "disable-prefix": "no-",
+ "detail": "The output will be in DER or RAW format.",
+ "long-option": "outder",
+ "desc": "Use DER format for output certificates, private keys, and DH parameters",
+ "disabled": ""
+ },
+ {
+ "long-option": "outraw",
+ "aliases": "outder"
+ },
+ {
+ "long-option": "provider",
+ "arg-type": "file",
+ "desc": "Specify the PKCS #11 provider library",
+ "detail": "This will override the default options in /etc/gnutls/pkcs11.conf"
+ },
+ {
+ "arg-type": "string",
+ "desc": "Specify parameters for the PKCS #11 provider library",
+ "deprecated": "",
+ "detail": "This is a PKCS#11 internal option used by few modules.\n Mainly for testing PKCS#11 modules.",
+ "long-option": "provider-opts"
+ },
+ {
+ "disable-prefix": "no-",
+ "long-option": "detailed-url",
+ "disabled": "",
+ "desc": "Print detailed URLs",
+ "detail": ""
+ },
+ {
+ "desc": "Print a compact listing using only the URLs",
+ "long-option": "only-urls",
+ "detail": ""
+ },
+ {
+ "detail": "In batch mode there will be no prompts, all parameters need to be specified on command line.",
+ "long-option": "batch",
+ "desc": "Disable all interaction with the tool"
+ }
+ ]
+ }
+] \ No newline at end of file
diff --git a/src/p11tool.c b/src/p11tool.c
index 693828fcc2..e60f74a9f1 100644
--- a/src/p11tool.c
+++ b/src/p11tool.c
@@ -44,7 +44,7 @@
/* Gnulib portability files. */
#include <read-file.h>
-#include "p11tool-args.h"
+#include "p11tool-options.h"
#include "p11tool.h"
#include "certtool-common.h"
@@ -234,12 +234,12 @@ static void cmd_parser(int argc, char **argv)
cinfo.only_urls = 1;
}
- if (ENABLED_OPT(INDER) || ENABLED_OPT(INRAW))
+ if (ENABLED_OPT(INDER))
cinfo.incert_format = GNUTLS_X509_FMT_DER;
else
cinfo.incert_format = GNUTLS_X509_FMT_PEM;
- if (HAVE_OPT(OUTDER) || HAVE_OPT(OUTRAW))
+ if (HAVE_OPT(OUTDER))
cinfo.outcert_format = GNUTLS_X509_FMT_DER;
else
cinfo.outcert_format = GNUTLS_X509_FMT_PEM;
diff --git a/src/psk.c b/src/psk.c
index 58499bd087..17cc076b8a 100644
--- a/src/psk.c
+++ b/src/psk.c
@@ -39,7 +39,7 @@ int main(int argc, char **argv)
#include <stdlib.h>
#include <errno.h>
#include <gnutls/gnutls.h>
-#include <psktool-args.h>
+#include "psktool-options.h"
#include <gnutls/crypto.h> /* for random */
diff --git a/src/psktool-args.def b/src/psktool-args.def
deleted file mode 100644
index 74e1c0a57a..0000000000
--- a/src/psktool-args.def
+++ /dev/null
@@ -1,70 +0,0 @@
-AutoGen Definitions options;
-prog-name = psktool;
-prog-title = "GnuTLS PSK tool";
-prog-desc = "Program to create PSK parameters.\n";
-detail = "Program that generates random keys for use with TLS-PSK. The
-keys are stored in hexadecimal format in a key file.";
-short-usage = "psktool [options]\npsktool --help for usage instructions.\n";
-explain = "";
-
-#include args-std.def
-
-flag = {
- name = keysize;
- value = s;
- arg-type = number;
- arg-range = "0 -> 512";
- descrip = "Specify the key size in bytes (default is 32-bytes or 256-bits)";
- doc = "";
-};
-
-flag = {
- name = username;
- value = u;
- arg-type = string;
- descrip = "Specify the username to use";
- doc = "";
-};
-
-flag = {
- name = pskfile;
- value = p;
- arg-type = string;
- descrip = "Specify a pre-shared key file";
- doc = "This option will specify the pre-shared key file to store the generated keys.";
-};
-
-flag = {
- name = passwd;
- aliases = pskfile;
- descrip = "Specify a pre-shared key file";
- deprecated;
-};
-
-doc-section = {
- ds-type = 'SEE ALSO';
- ds-format = 'texi';
- ds-text = <<-_EOT_
- gnutls-cli-debug (1), gnutls-serv (1), srptool (1), certtool (1)
-_EOT_;
-};
-
-doc-section = {
- ds-type = 'EXAMPLES';
- ds-format = 'texi';
- ds-text = <<-_EOT_
-To add a user 'psk_identity' in @file{keys.psk} for use with GnuTLS run:
-@example
-$ ./psktool -u psk_identity -p keys.psk
-Generating a random key for user 'psk_identity'
-Key stored to keys.psk
-$ cat keys.psk
-psk_identity:88f3824b3e5659f52d00e959bacab954b6540344
-$
-@end example
-
-This command will create @file{keys.psk} if it does not exist
-and will add user 'psk_identity'.
-_EOT_;
-};
-
diff --git a/src/psktool-options.json b/src/psktool-options.json
new file mode 100644
index 0000000000..22771fa236
--- /dev/null
+++ b/src/psktool-options.json
@@ -0,0 +1,53 @@
+[
+ {
+ "meta": {
+ "explain": "",
+ "desc": "",
+ "prog-name": "psktool",
+ "prog-desc": "Program to create PSK parameters.\n",
+ "detail": "Program that generates random keys for use with TLS-PSK. The\nkeys are stored in hexadecimal format in a key file.",
+ "prog-title": "GnuTLS PSK tool",
+ "short-usage": "psktool [options]\npsktool --help for usage instructions.\n"
+ },
+ "options": [
+ {
+ "desc": "Enable debugging",
+ "detail": "Specifies the debug level.",
+ "arg-min": "0 ",
+ "arg-max": " 9999",
+ "arg-type": "number",
+ "short-option": "d",
+ "long-option": "debug"
+ },
+ {
+ "long-option": "keysize",
+ "desc": "Specify the key size in bytes (default is 32-bytes or 256-bits)",
+ "short-option": "s",
+ "arg-type": "number",
+ "detail": "",
+ "arg-min": "0 ",
+ "arg-max": " 512"
+ },
+ {
+ "long-option": "username",
+ "desc": "Specify the username to use",
+ "arg-type": "string",
+ "detail": "",
+ "short-option": "u"
+ },
+ {
+ "long-option": "pskfile",
+ "detail": "This option will specify the pre-shared key file to store the generated keys.",
+ "short-option": "p",
+ "arg-type": "string",
+ "desc": "Specify a pre-shared key file"
+ },
+ {
+ "deprecated": "",
+ "desc": "Specify a pre-shared key file",
+ "aliases": "pskfile",
+ "long-option": "passwd"
+ }
+ ]
+ }
+] \ No newline at end of file
diff --git a/src/serv-args.def b/src/serv-args.def
deleted file mode 100644
index ca61801c1e..0000000000
--- a/src/serv-args.def
+++ /dev/null
@@ -1,557 +0,0 @@
-AutoGen Definitions options;
-prog-name = gnutls-serv;
-prog-title = "GnuTLS server";
-prog-desc = "Simple server program to act as an HTTPS or TLS echo service.";
-short-usage = "Usage: gnutls-serv [options]\ngnutls-serv --help for usage instructions.\n";
-explain = "";
-detail = "Server program that listens to incoming TLS connections.";
-
-#include args-std.def
-
-flag = {
- name = sni-hostname;
- descrip = "Server's hostname for server name extension";
- arg-type = string;
- doc = "Server name of type host_name that the server will recognise as its own. If the server receives client hello with different name, it will send a warning-level unrecognized_name alert.";
-};
-
-flag = {
- name = sni-hostname-fatal;
- descrip = "Send fatal alert on sni-hostname mismatch";
- doc = "";
-};
-
-flag = {
- name = alpn;
- arg-type = string;
- descrip = "Specify ALPN protocol to be enabled by the server";
- doc = "Specify the (textual) ALPN protocol for the server to use.";
- stack-arg;
- max = NOLIMIT;
-};
-
-flag = {
- name = alpn-fatal;
- descrip = "Send fatal alert on non-matching ALPN name";
- doc = "";
-};
-
-flag = {
- name = noticket;
- descrip = "Don't accept session tickets";
- doc = "";
-};
-
-flag = {
- name = earlydata;
- descrip = "Accept early data";
- doc = "";
-};
-
-flag = {
- name = maxearlydata;
- arg-type = number;
- arg-range = "1->";
- descrip = "The maximum early data size to accept";
- doc = "";
-};
-
-flag = {
- name = nocookie;
- descrip = "Don't require cookie on DTLS sessions";
- doc = "";
-};
-
-flag = {
- name = generate;
- value = g;
- descrip = "Generate Diffie-Hellman parameters";
- doc = "";
-};
-
-flag = {
- name = quiet;
- value = q;
- descrip = "Suppress some messages";
- doc = "";
-};
-
-flag = {
- name = nodb;
- descrip = "Do not use a resumption database";
- doc = "";
-};
-
-flag = {
- name = http;
- descrip = "Act as an HTTP server";
- doc = "";
-};
-
-flag = {
- name = echo;
- descrip = "Act as an Echo server";
- doc = "";
-};
-
-flag = {
- name = crlf;
- descrip = "Do not replace CRLF by LF in Echo server mode";
- doc = "";
-};
-
-flag = {
- name = udp;
- value = u;
- descrip = "Use DTLS (datagram TLS) over UDP";
- doc = "";
-};
-
-flag = {
- name = mtu;
- arg-type = number;
- arg-range = "0->17000";
- descrip = "Set MTU for datagram TLS";
- doc = "";
-};
-
-flag = {
- name = srtp_profiles;
- arg-type = string;
- descrip = "Offer SRTP profiles";
- doc = "";
-};
-
-flag = {
- name = disable-client-cert;
- value = a;
- descrip = "Do not request a client certificate";
- doc = "";
- flags-cant = require-client-cert;
-};
-
-flag = {
- name = require-client-cert;
- value = r;
- descrip = "Require a client certificate";
- doc = "This option before 3.6.0 used to imply --verify-client-cert.
-Since 3.6.0 it will no longer verify the certificate by default.";
-};
-
-flag = {
- name = verify-client-cert;
- disabled;
- descrip = "If a client certificate is sent then verify it.";
- doc = "Do not require, but if a client certificate is sent then verify it and close the connection if invalid.";
-};
-
-flag = {
- name = heartbeat;
- value = b;
- descrip = "Activate heartbeat support";
- doc = "Regularly ping client via heartbeat extension messages";
-};
-
-flag = {
- name = x509fmtder;
- descrip = "Use DER format for certificates to read from";
- doc = "";
-};
-
-flag = {
- name = priority;
- arg-type = string;
- descrip = "Priorities string";
- doc = "TLS algorithms and protocols to enable. You can
-use predefined sets of ciphersuites such as PERFORMANCE,
-NORMAL, SECURE128, SECURE256. The default is NORMAL.
-
-Check the GnuTLS manual on section ``Priority strings'' for more
-information on allowed keywords";
-};
-
-flag = {
- name = dhparams;
- arg-type = file;
- file-exists = yes;
- descrip = "DH params file to use";
- doc = "";
-};
-
-flag = {
- name = x509cafile;
- arg-type = string;
- descrip = "Certificate file or PKCS #11 URL to use";
- doc = "";
-};
-
-flag = {
- name = x509crlfile;
- arg-type = file;
- file-exists = yes;
- descrip = "CRL file to use";
- doc = "";
-};
-
-flag = {
- name = pgpkeyfile;
- arg-type = file;
- file-exists = yes;
- descrip = "PGP Key file to use";
- doc = "";
- deprecated;
-};
-
-
-flag = {
- name = x509keyfile;
- arg-type = string;
- descrip = "X.509 key file or PKCS #11 URL to use";
- doc = "Specify the private key file or URI to use; it must correspond to
-the certificate specified in --x509certfile. Multiple keys and certificates
-can be specified with this option and in that case each occurrence of keyfile
-must be followed by the corresponding x509certfile or vice-versa.";
- stack-arg;
- max = NOLIMIT;
-};
-
-flag = {
- name = x509certfile;
- arg-type = string;
- descrip = "X.509 Certificate file or PKCS #11 URL to use";
- doc = "Specify the certificate file or URI to use; it must correspond to
-the key specified in --x509keyfile. Multiple keys and certificates
-can be specified with this option and in that case each occurrence of keyfile
-must be followed by the corresponding x509certfile or vice-versa.";
- stack-arg;
- max = NOLIMIT;
-};
-
-flag = {
- name = x509dsakeyfile;
- aliases = x509keyfile;
- descrip = "Alternative X.509 key file or PKCS #11 URL to use";
- deprecated;
-};
-
-flag = {
- name = x509dsacertfile;
- aliases = x509certfile;
- descrip = "Alternative X.509 Certificate file or PKCS #11 URL to use";
- deprecated;
-};
-
-flag = {
- name = x509ecckeyfile;
- aliases = x509keyfile;
- descrip = "Alternative X.509 key file or PKCS #11 URL to use";
- deprecated;
-};
-
-flag = {
- name = x509ecccertfile;
- aliases = x509certfile;
- descrip = "Alternative X.509 Certificate file or PKCS #11 URL to use";
- deprecated;
-};
-
-flag = {
- name = rawpkkeyfile;
- arg-type = string;
- descrip = "Private key file (PKCS #8 or PKCS #12) or PKCS #11 URL to use";
- doc = "Specify the private key file or URI to use; it must correspond to
-the raw public-key specified in --rawpkfile. Multiple key pairs
-can be specified with this option and in that case each occurrence of keyfile
-must be followed by the corresponding rawpkfile or vice-versa.
-
-In order to instruct the application to negotiate raw public keys one
-must enable the respective certificate types via the priority strings (i.e. CTYPE-CLI-*
-and CTYPE-SRV-* flags).
-
-Check the GnuTLS manual on section ``Priority strings'' for more
-information on how to set certificate types.";
- stack-arg;
- max = NOLIMIT;
-};
-
-flag = {
- name = rawpkfile;
- arg-type = string;
- descrip = "Raw public-key file to use";
- doc = "Specify the raw public-key file to use; it must correspond to
-the private key specified in --rawpkkeyfile. Multiple key pairs
-can be specified with this option and in that case each occurrence of keyfile
-must be followed by the corresponding rawpkfile or vice-versa.
-
-In order to instruct the application to negotiate raw public keys one
-must enable the respective certificate types via the priority strings (i.e. CTYPE-CLI-*
-and CTYPE-SRV-* flags).
-
-Check the GnuTLS manual on section ``Priority strings'' for more
-information on how to set certificate types.";
- stack-arg;
- max = NOLIMIT;
- flags-must = rawpkkeyfile;
-};
-
-flag = {
- name = srppasswd;
- arg-type = file;
- file-exists = yes;
- descrip = "SRP password file to use";
- doc = "";
-};
-
-flag = {
- name = srppasswdconf;
- arg-type = file;
- file-exists = yes;
- descrip = "SRP password configuration file to use";
- doc = "";
-};
-
-flag = {
- name = pskpasswd;
- arg-type = file;
- file-exists = yes;
- descrip = "PSK password file to use";
- doc = "";
-};
-
-flag = {
- name = pskhint;
- arg-type = string;
- descrip = "PSK identity hint to use";
- doc = "";
-};
-
-flag = {
- name = ocsp-response;
- arg-type = string;
- descrip = "The OCSP response to send to client";
- doc = "If the client requested an OCSP response, return data from this file to the client.";
- stack-arg;
- max = NOLIMIT;
-};
-
-flag = {
- name = ignore-ocsp-response-errors;
- descrip = "Ignore any errors when setting the OCSP response";
- doc = "That option instructs gnutls to not attempt to match the provided OCSP responses with the certificates.";
-};
-
-flag = {
- name = port;
- value = p;
- arg-type = number;
- descrip = "The port to connect to";
- doc = "";
-};
-
-flag = {
- name = list;
- value = l;
- descrip = "Print a list of the supported algorithms and modes";
- doc = "Print a list of the supported algorithms and modes. If a priority string is given then only the enabled ciphersuites are shown.";
-};
-
-flag = {
- name = provider;
- arg-type = file;
- file-exists = yes;
- descrip = "Specify the PKCS #11 provider library";
- doc = "This will override the default options in /etc/gnutls/pkcs11.conf";
-};
-
-flag = {
- name = keymatexport;
- arg-type = string;
- descrip = "Label used for exporting keying material";
- doc = "";
-};
-
-flag = {
- name = keymatexportsize;
- arg-type = number;
- descrip = "Size of the exported keying material";
- doc = "";
-};
-
-flag = {
- name = recordsize;
- arg-type = number;
- arg-range = "0->16384";
- descrip = "The maximum record size to advertise";
- doc = "";
-};
-
-flag = {
- name = httpdata;
- arg-type = file;
- file-exists = yes;
- descrip = "The data used as HTTP response";
- doc = "";
-};
-
-doc-section = {
- ds-type = 'SEE ALSO'; // or anything else
- ds-format = 'texi'; // or texi or mdoc format
- ds-text = <<-_EOText_
-gnutls-cli-debug(1), gnutls-cli(1)
-_EOText_;
-};
-
-doc-section = {
- ds-type = 'EXAMPLES';
- ds-format = 'texi';
- ds-text = <<-_EOF_
-Running your own TLS server based on GnuTLS can be useful when
-debugging clients and/or GnuTLS itself. This section describes how to
-use @code{gnutls-serv} as a simple HTTPS server.
-
-The most basic server can be started as:
-
-@example
-gnutls-serv --http --priority "NORMAL:+ANON-ECDH:+ANON-DH"
-@end example
-
-It will only support anonymous ciphersuites, which many TLS clients
-refuse to use.
-
-The next step is to add support for X.509. First we generate a CA:
-
-@example
-$ certtool --generate-privkey > x509-ca-key.pem
-$ echo 'cn = GnuTLS test CA' > ca.tmpl
-$ echo 'ca' >> ca.tmpl
-$ echo 'cert_signing_key' >> ca.tmpl
-$ certtool --generate-self-signed --load-privkey x509-ca-key.pem \
- --template ca.tmpl --outfile x509-ca.pem
-@end example
-
-Then generate a server certificate. Remember to change the dns_name
-value to the name of your server host, or skip that command to avoid
-the field.
-
-@example
-$ certtool --generate-privkey > x509-server-key.pem
-$ echo 'organization = GnuTLS test server' > server.tmpl
-$ echo 'cn = test.gnutls.org' >> server.tmpl
-$ echo 'tls_www_server' >> server.tmpl
-$ echo 'encryption_key' >> server.tmpl
-$ echo 'signing_key' >> server.tmpl
-$ echo 'dns_name = test.gnutls.org' >> server.tmpl
-$ certtool --generate-certificate --load-privkey x509-server-key.pem \
- --load-ca-certificate x509-ca.pem --load-ca-privkey x509-ca-key.pem \
- --template server.tmpl --outfile x509-server.pem
-@end example
-
-For use in the client, you may want to generate a client certificate
-as well.
-
-@example
-$ certtool --generate-privkey > x509-client-key.pem
-$ echo 'cn = GnuTLS test client' > client.tmpl
-$ echo 'tls_www_client' >> client.tmpl
-$ echo 'encryption_key' >> client.tmpl
-$ echo 'signing_key' >> client.tmpl
-$ certtool --generate-certificate --load-privkey x509-client-key.pem \
- --load-ca-certificate x509-ca.pem --load-ca-privkey x509-ca-key.pem \
- --template client.tmpl --outfile x509-client.pem
-@end example
-
-To be able to import the client key/certificate into some
-applications, you will need to convert them into a PKCS#12 structure.
-This also encrypts the security sensitive key with a password.
-
-@example
-$ certtool --to-p12 --load-ca-certificate x509-ca.pem \
- --load-privkey x509-client-key.pem --load-certificate x509-client.pem \
- --outder --outfile x509-client.p12
-@end example
-
-For icing, we'll create a proxy certificate for the client too.
-
-@example
-$ certtool --generate-privkey > x509-proxy-key.pem
-$ echo 'cn = GnuTLS test client proxy' > proxy.tmpl
-$ certtool --generate-proxy --load-privkey x509-proxy-key.pem \
- --load-ca-certificate x509-client.pem --load-ca-privkey x509-client-key.pem \
- --load-certificate x509-client.pem --template proxy.tmpl \
- --outfile x509-proxy.pem
-@end example
-
-Then start the server again:
-
-@example
-$ gnutls-serv --http \
- --x509cafile x509-ca.pem \
- --x509keyfile x509-server-key.pem \
- --x509certfile x509-server.pem
-@end example
-
-Try connecting to the server using your web browser. Note that the
-server listens to port 5556 by default.
-
-While you are at it, to allow connections using ECDSA, you can also
-create a ECDSA key and certificate for the server. These credentials
-will be used in the final example below.
-
-@example
-$ certtool --generate-privkey --ecdsa > x509-server-key-ecc.pem
-$ certtool --generate-certificate --load-privkey x509-server-key-ecc.pem \
- --load-ca-certificate x509-ca.pem --load-ca-privkey x509-ca-key.pem \
- --template server.tmpl --outfile x509-server-ecc.pem
-@end example
-
-
-The next step is to add support for SRP authentication. This requires
-an SRP password file created with @code{srptool}.
-To start the server with SRP support:
-
-@example
-gnutls-serv --http --priority NORMAL:+SRP-RSA:+SRP \
- --srppasswdconf srp-tpasswd.conf \
- --srppasswd srp-passwd.txt
-@end example
-
-Let's also start a server with support for PSK. This would require
-a password file created with @code{psktool}.
-
-@example
-gnutls-serv --http --priority NORMAL:+ECDHE-PSK:+PSK \
- --pskpasswd psk-passwd.txt
-@end example
-
-If you want a server with support for raw public-keys we can also add these
-credentials. Note however that there is no identity information linked to these
-keys as is the case with regular x509 certificates. Authentication must be done
-via different means. Also we need to explicitly enable raw public-key certificates
-via the priority strings.
-
-@example
-gnutls-serv --http --priority NORMAL:+CTYPE-CLI-RAWPK:+CTYPE-SRV-RAWPK \
- --rawpkfile srv.rawpk.pem \
- --rawpkkeyfile srv.key.pem
-@end example
-
-
-Finally, we start the server with all the earlier parameters and you
-get this command:
-
-@example
-gnutls-serv --http --priority NORMAL:+PSK:+SRP:+CTYPE-CLI-RAWPK:+CTYPE-SRV-RAWPK \
- --x509cafile x509-ca.pem \
- --x509keyfile x509-server-key.pem \
- --x509certfile x509-server.pem \
- --x509keyfile x509-server-key-ecc.pem \
- --x509certfile x509-server-ecc.pem \
- --srppasswdconf srp-tpasswd.conf \
- --srppasswd srp-passwd.txt \
- --pskpasswd psk-passwd.txt \
- --rawpkfile srv.rawpk.pem \
- --rawpkkeyfile srv.key.pem
-@end example
-_EOF_;
-};
-
diff --git a/src/serv.c b/src/serv.c
index cde7c1645f..85e94cd5e6 100644
--- a/src/serv.c
+++ b/src/serv.c
@@ -27,7 +27,7 @@
#include <config.h>
#include "common.h"
-#include "serv-args.h"
+#include "gnutls-serv-options.h"
#include "udp-serv.h"
#include <stdio.h>
#include <stdlib.h>
diff --git a/src/srptool-args.def b/src/srptool-args.def
deleted file mode 100644
index 67e3a8c9d2..0000000000
--- a/src/srptool-args.def
+++ /dev/null
@@ -1,106 +0,0 @@
-AutoGen Definitions options;
-prog-name = srptool;
-prog-title = "GnuTLS SRP tool";
-prog-desc = "Simple program to create SRP parameters.\n";
-explain = "";
-detail = "Simple program that emulates the programs in the Stanford SRP (Secure
-Remote Password) libraries using GnuTLS. It is intended for use in places
-where you don't expect SRP authentication to be the used for system users.
-
-In brief, to use SRP you need to create two files. These are the password
-file that holds the users and the verifiers associated with them and the
-configuration file to hold the group parameters (called tpasswd.conf).";
-
-short-usage = "srptool [options]\nsrptool --help for usage instructions.\n";
-
-#include args-std.def
-
-flag = {
- name = index;
- value = i;
- arg-type = number;
- arg-default = 3;
- descrip = "specify the index of the group parameters in tpasswd.conf to use";
- doc = "";
-};
-
-flag = {
- name = username;
- value = u;
- arg-type = string;
- descrip = "specify a username";
- doc = "";
-};
-
-flag = {
- name = passwd;
- value = p;
- arg-type = string;
- descrip = "specify a password file";
- doc = "";
-};
-
-flag = {
- name = salt;
- value = s;
- arg-type = number;
- descrip = "specify salt size";
- doc = "";
-};
-
-flag = {
- name = verify;
- descrip = "just verify the password.";
- doc = "Verifies the password provided against the password file.";
-};
-
-flag = {
- name = passwd-conf;
- value = v;
- arg-type = string;
- descrip = "specify a password conf file.";
- doc = "Specify a filename or a PKCS #11 URL to read the CAs from.";
-};
-
-flag = {
- name = create-conf;
- arg-type = string;
- descrip = "Generate a password configuration file.";
- doc = "This generates a password configuration file (tpasswd.conf)
-containing the required for TLS parameters.";
-};
-
-doc-section = {
- ds-type = 'SEE ALSO';
- ds-format = 'texi';
- ds-text = <<-_EOT_
- gnutls-cli-debug (1), gnutls-serv (1), srptool (1), psktool (1), certtool (1)
-_EOT_;
-};
-
-doc-section = {
- ds-type = 'EXAMPLES';
- ds-format = 'texi';
- ds-text = <<-_EOT_
-To create @file{tpasswd.conf} which holds the g and n values for SRP protocol
-(generator and a large prime), run:
-@example
-$ srptool --create-conf /etc/tpasswd.conf
-@end example
-
-This command will create @file{/etc/tpasswd} and will add user 'test' (you
-will also be prompted for a password). Verifiers are stored by default
-in the way libsrp expects.
-@example
-$ srptool --passwd /etc/tpasswd --passwd-conf /etc/tpasswd.conf -u test
-@end example
-
-
-This command will check against a password. If the password matches
-the one in @file{/etc/tpasswd} you will get an ok.
-@example
-$ srptool --passwd /etc/tpasswd --passwd\-conf /etc/tpasswd.conf --verify -u test
-@end example
-_EOT_;
-};
-
diff --git a/src/srptool-options.json b/src/srptool-options.json
new file mode 100644
index 0000000000..489eb7a73b
--- /dev/null
+++ b/src/srptool-options.json
@@ -0,0 +1,71 @@
+[
+ {
+ "meta": {
+ "prog-desc": "Simple program to create SRP parameters.\n",
+ "explain": "",
+ "short-usage": "srptool [options]\nsrptool --help for usage instructions.\n",
+ "detail": "Simple program that emulates the programs in the Stanford SRP (Secure\nRemote Password) libraries using GnuTLS. It is intended for use in places\nwhere you don't expect SRP authentication to be the used for system users.\n\nIn brief, to use SRP you need to create two files. These are the password\nfile that holds the users and the verifiers associated with them and the\nconfiguration file to hold the group parameters (called tpasswd.conf).",
+ "desc": "",
+ "prog-name": "srptool",
+ "prog-title": "GnuTLS SRP tool"
+ },
+ "options": [
+ {
+ "short-option": "d",
+ "arg-min": "0 ",
+ "detail": "Specifies the debug level.",
+ "desc": "Enable debugging",
+ "long-option": "debug",
+ "arg-type": "number",
+ "arg-max": " 9999"
+ },
+ {
+ "desc": "specify the index of the group parameters in tpasswd.conf to use",
+ "detail": "",
+ "short-option": "i",
+ "arg-type": "number",
+ "arg-default": "3",
+ "long-option": "index"
+ },
+ {
+ "arg-type": "string",
+ "long-option": "username",
+ "detail": "",
+ "desc": "specify a username",
+ "short-option": "u"
+ },
+ {
+ "long-option": "passwd",
+ "desc": "specify a password file",
+ "arg-type": "string",
+ "detail": "",
+ "short-option": "p"
+ },
+ {
+ "long-option": "salt",
+ "short-option": "s",
+ "desc": "specify salt size",
+ "detail": "",
+ "arg-type": "number"
+ },
+ {
+ "desc": "just verify the password.",
+ "long-option": "verify",
+ "detail": "Verifies the password provided against the password file."
+ },
+ {
+ "detail": "Specify a filename or a PKCS #11 URL to read the CAs from.",
+ "short-option": "v",
+ "long-option": "passwd-conf",
+ "desc": "specify a password conf file.",
+ "arg-type": "string"
+ },
+ {
+ "arg-type": "string",
+ "detail": "This generates a password configuration file (tpasswd.conf)\ncontaining the required for TLS parameters.",
+ "desc": "Generate a password configuration file.",
+ "long-option": "create-conf"
+ }
+ ]
+ }
+] \ No newline at end of file
diff --git a/src/srptool.c b/src/srptool.c
index b4bc08b189..a050de09db 100644
--- a/src/srptool.c
+++ b/src/srptool.c
@@ -40,7 +40,7 @@
#include <getpass.h>
#include <minmax.h>
-#include <srptool-args.h>
+#include "srptool-options.h"
/* This may need some rewrite. A lot of stuff which should be here
* are in the library, which is not good.
diff --git a/src/systemkey-args.def b/src/systemkey-args.def
deleted file mode 100644
index f13c12704b..0000000000
--- a/src/systemkey-args.def
+++ /dev/null
@@ -1,43 +0,0 @@
-AutoGen Definitions options;
-prog-name = systemkey-tool;
-prog-title = "GnuTLS system key tool";
-prog-desc = "Program to handle system keys.\n";
-detail = "Program that allows handling user keys as stored in the system in a uniform way.";
-short-usage = "systemkey-tool [options]\nsystemkey-tool --help for usage instructions.\n";
-explain = "";
-
-#define OUTFILE_OPT 1
-#define INFILE_OPT 0
-#include args-std.def
-
-flag = {
- name = list;
- descrip = "Lists all stored keys.";
- doc = "";
-};
-
-flag = {
- name = delete;
- arg-type = string;
- arg-name = "url";
- descrip = "Delete the key identified by the given URL.";
- doc = "";
-};
-
-flag = {
- name = outder;
- descrip = "Use DER format for output keys";
- disabled;
- disable = "no";
- doc = "The output will be in DER format.";
-};
-
-doc-section = {
- ds-type = 'SEE ALSO';
- ds-format = 'texi';
- ds-text = <<-_EOT_
- p11tool (1), certtool (1)
-_EOT_;
-};
-
-
diff --git a/src/systemkey-tool-options.json b/src/systemkey-tool-options.json
new file mode 100644
index 0000000000..835ffb9c1c
--- /dev/null
+++ b/src/systemkey-tool-options.json
@@ -0,0 +1,49 @@
+[
+ {
+ "meta": {
+ "detail": "Program that allows handling user keys as stored in the system in a uniform way.",
+ "short-usage": "systemkey-tool [options]\nsystemkey-tool --help for usage instructions.\n",
+ "prog-desc": "Program to handle system keys.\n",
+ "explain": "",
+ "prog-name": "systemkey-tool",
+ "desc": "",
+ "prog-title": "GnuTLS system key tool"
+ },
+ "options": [
+ {
+ "desc": "Enable debugging",
+ "arg-type": "number",
+ "short-option": "d",
+ "arg-min": "0 ",
+ "arg-max": " 9999",
+ "long-option": "debug",
+ "detail": "Specifies the debug level."
+ },
+ {
+ "arg-type": "string",
+ "long-option": "outfile",
+ "detail": "",
+ "desc": "Output file"
+ },
+ {
+ "desc": "Lists all stored keys.",
+ "detail": "",
+ "long-option": "list"
+ },
+ {
+ "arg-name": "url",
+ "detail": "",
+ "long-option": "delete",
+ "desc": "Delete the key identified by the given URL.",
+ "arg-type": "string"
+ },
+ {
+ "long-option": "outder",
+ "desc": "Use DER format for output keys",
+ "disabled": "",
+ "detail": "The output will be in DER format.",
+ "disable-prefix": "no-"
+ }
+ ]
+ }
+] \ No newline at end of file
diff --git a/src/systemkey.c b/src/systemkey.c
index d1186c59a0..11fe3cd8f4 100644
--- a/src/systemkey.c
+++ b/src/systemkey.c
@@ -44,7 +44,7 @@
#include <read-file.h>
#include "certtool-common.h"
-#include "systemkey-args.h"
+#include "systemkey-tool-options.h"
static void cmd_parser(int argc, char **argv);
static void systemkey_delete(const char *url, FILE * outfile);
diff --git a/src/tpmtool-args.def b/src/tpmtool-args.def
deleted file mode 100644
index 85ec9e6f07..0000000000
--- a/src/tpmtool-args.def
+++ /dev/null
@@ -1,170 +0,0 @@
-AutoGen Definitions options;
-prog-name = tpmtool;
-prog-title = "GnuTLS TPM tool";
-prog-desc = "Program to handle TPM as a cryptographic device.\n";
-detail = "Program that allows handling cryptographic data from the TPM chip.";
-short-usage = "tpmtool [options]\ntpmtool --help for usage instructions.\n";
-explain = "";
-
-#define OUTFILE_OPT 1
-#define INFILE_OPT 1
-#include args-std.def
-
-flag = {
- name = generate-rsa;
- descrip = "Generate an RSA private-public key pair";
- doc = "Generates an RSA private-public key pair in the TPM chip.
-The key may be stored in file system and protected by a PIN, or stored (registered)
-in the TPM chip flash.";
-};
-
-flag = {
- name = register;
- descrip = "Any generated key will be registered in the TPM";
- flags_must = generate-rsa;
- doc = "";
-};
-
-flag = {
- name = signing;
- descrip = "Any generated key will be a signing key";
- flags_must = generate-rsa;
- flags_cant = legacy;
- doc = "";
-};
-
-flag = {
- name = legacy;
- descrip = "Any generated key will be a legacy key";
- flags_must = generate-rsa;
- flags_cant = signing;
- doc = "";
-};
-
-flag = {
- name = user;
- descrip = "Any registered key will be a user key";
- flags_must = register;
- flags_cant = system;
- doc = "The generated key will be stored in a user specific persistent storage.";
-};
-
-flag = {
- name = system;
- descrip = "Any registered key will be a system key";
- flags_must = register;
- flags_cant = user;
- doc = "The generated key will be stored in system persistent storage.";
-};
-
-
-flag = {
- name = pubkey;
- arg-type = string;
- arg-name = "url";
- descrip = "Prints the public key of the provided key";
- doc = "";
-};
-
-flag = {
- name = list;
- descrip = "Lists all stored keys in the TPM";
- doc = "";
-};
-
-flag = {
- name = delete;
- arg-type = string;
- arg-name = "url";
- descrip = "Delete the key identified by the given URL (UUID).";
- doc = "";
-};
-
-flag = {
- name = test-sign;
- arg-type = string;
- arg-name = "url";
- descrip = "Tests the signature operation of the provided object";
- doc = "It can be used to test the correct operation of the signature operation.
-This operation will sign and verify the signed data.";
-};
-
-flag = {
- name = sec-param;
- arg-type = string;
- arg-name = "Security parameter";
- descrip = "Specify the security level [low, legacy, medium, high, ultra].";
- doc = "This is alternative to the bits option. Note however that the
-values allowed by the TPM chip are quantized and given values may be rounded up.";
-};
-
-flag = {
- name = bits;
- arg-type = number;
- descrip = "Specify the number of bits for key generate";
- doc = "";
-};
-
-flag = {
- name = inder;
- descrip = "Use the DER format for keys.";
- disabled;
- disable = "no";
- doc = "The input files will be assumed to be in the portable
-DER format of TPM. The default format is a custom format used by various
-TPM tools";
-};
-
-flag = {
- name = outder;
- descrip = "Use DER format for output keys";
- disabled;
- disable = "no";
- doc = "The output will be in the TPM portable DER format.";
-};
-
-flag = {
- name = srk-well-known;
- descrip = "SRK has well known password (20 bytes of zeros)";
-};
-
-doc-section = {
- ds-type = 'SEE ALSO';
- ds-format = 'texi';
- ds-text = <<-_EOT_
- p11tool (1), certtool (1)
-_EOT_;
-};
-
-doc-section = {
- ds-type = 'EXAMPLES';
- ds-format = 'texi';
- ds-text = <<-_EOT_
-To generate a key that is to be stored in file system use:
-@example
-$ tpmtool --generate-rsa --bits 2048 --outfile tpmkey.pem
-@end example
-
-To generate a key that is to be stored in TPM's flash use:
-@example
-$ tpmtool --generate-rsa --bits 2048 --register --user
-@end example
-
-To get the public key of a TPM key use:
-@example
-$ tpmtool --pubkey tpmkey:uuid=58ad734b-bde6-45c7-89d8-756a55ad1891;storage=user \
- --outfile pubkey.pem
-@end example
-
-or if the key is stored in the file system:
-@example
-$ tpmtool --pubkey tpmkey:file=tmpkey.pem --outfile pubkey.pem
-@end example
-
-To list all keys stored in TPM use:
-@example
-$ tpmtool --list
-@end example
-_EOT_;
-};
-
diff --git a/src/tpmtool-options.json b/src/tpmtool-options.json
new file mode 100644
index 0000000000..22b07a0a6e
--- /dev/null
+++ b/src/tpmtool-options.json
@@ -0,0 +1,133 @@
+[
+ {
+ "meta": {
+ "prog-name": "tpmtool",
+ "desc": "",
+ "short-usage": "tpmtool [options]\ntpmtool --help for usage instructions.\n",
+ "prog-desc": "Program to handle TPM as a cryptographic device.\n",
+ "detail": "Program that allows handling cryptographic data from the TPM chip.",
+ "explain": "",
+ "prog-title": "GnuTLS TPM tool"
+ },
+ "options": [
+ {
+ "short-option": "d",
+ "arg-max": " 9999",
+ "desc": "Enable debugging",
+ "arg-min": "0 ",
+ "long-option": "debug",
+ "arg-type": "number",
+ "detail": "Specifies the debug level."
+ },
+ {
+ "long-option": "infile",
+ "arg-type": "file",
+ "file-exists": "yes",
+ "desc": "Input file",
+ "detail": ""
+ },
+ {
+ "detail": "",
+ "desc": "Output file",
+ "long-option": "outfile",
+ "arg-type": "string"
+ },
+ {
+ "desc": "Generate an RSA private-public key pair",
+ "detail": "Generates an RSA private-public key pair in the TPM chip. \nThe key may be stored in file system and protected by a PIN, or stored (registered)\nin the TPM chip flash.",
+ "long-option": "generate-rsa"
+ },
+ {
+ "requires": "generate-rsa",
+ "desc": "Any generated key will be registered in the TPM",
+ "long-option": "register",
+ "detail": ""
+ },
+ {
+ "conflicts": "legacy",
+ "requires": "generate-rsa",
+ "long-option": "signing",
+ "desc": "Any generated key will be a signing key",
+ "detail": ""
+ },
+ {
+ "desc": "Any generated key will be a legacy key",
+ "conflicts": "signing",
+ "detail": "",
+ "requires": "generate-rsa",
+ "long-option": "legacy"
+ },
+ {
+ "requires": "register",
+ "desc": "Any registered key will be a user key",
+ "long-option": "user",
+ "detail": "The generated key will be stored in a user specific persistent storage.",
+ "conflicts": "system"
+ },
+ {
+ "detail": "The generated key will be stored in system persistent storage.",
+ "long-option": "system",
+ "desc": "Any registered key will be a system key",
+ "conflicts": "user",
+ "requires": "register"
+ },
+ {
+ "detail": "",
+ "arg-type": "string",
+ "arg-name": "url",
+ "long-option": "pubkey",
+ "desc": "Prints the public key of the provided key"
+ },
+ {
+ "detail": "",
+ "long-option": "list",
+ "desc": "Lists all stored keys in the TPM"
+ },
+ {
+ "arg-type": "string",
+ "desc": "Delete the key identified by the given URL (UUID).",
+ "arg-name": "url",
+ "long-option": "delete",
+ "detail": ""
+ },
+ {
+ "arg-name": "url",
+ "long-option": "test-sign",
+ "arg-type": "string",
+ "desc": "Tests the signature operation of the provided object",
+ "detail": "It can be used to test the correct operation of the signature operation.\nThis operation will sign and verify the signed data."
+ },
+ {
+ "arg-name": "Security parameter",
+ "arg-type": "string",
+ "detail": "This is alternative to the bits option. Note however that the\nvalues allowed by the TPM chip are quantized and given values may be rounded up.",
+ "long-option": "sec-param",
+ "desc": "Specify the security level [low, legacy, medium, high, ultra]."
+ },
+ {
+ "desc": "Specify the number of bits for key generate",
+ "arg-type": "number",
+ "detail": "",
+ "long-option": "bits"
+ },
+ {
+ "long-option": "inder",
+ "disable-prefix": "no-",
+ "detail": "The input files will be assumed to be in the portable\nDER format of TPM. The default format is a custom format used by various\nTPM tools",
+ "desc": "Use the DER format for keys.",
+ "disabled": ""
+ },
+ {
+ "disabled": "",
+ "long-option": "outder",
+ "desc": "Use DER format for output keys",
+ "detail": "The output will be in the TPM portable DER format.",
+ "disable-prefix": "no-"
+ },
+ {
+ "desc": "SRK has well known password (20 bytes of zeros)",
+ "long-option": "srk-well-known"
+ }
+ ]
+ }
+] \ No newline at end of file
diff --git a/src/tpmtool.c b/src/tpmtool.c
index c8862f0c4d..171b7fd416 100644
--- a/src/tpmtool.c
+++ b/src/tpmtool.c
@@ -44,7 +44,7 @@
#include <read-file.h>
#include "certtool-common.h"
-#include "tpmtool-args.h"
+#include "tpmtool-options.h"
#include "common.h"
static void cmd_parser(int argc, char **argv);
diff --git a/src/udp-serv.c b/src/udp-serv.c
index 814d698fbf..ca19cbebaa 100644
--- a/src/udp-serv.c
+++ b/src/udp-serv.c
@@ -36,7 +36,7 @@
#include <errno.h>
#include <common.h>
#include "udp-serv.h"
-#include "serv-args.h"
+#include "gnutls-serv-options.h"
extern int disable_client_cert;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index fb7cc84c8b..3f9f4bcd56 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -515,7 +515,7 @@ dist_check_SCRIPTS += fastopen.sh pkgconfig.sh starttls.sh starttls-ftp.sh start
psktool.sh ocsp-tests/ocsp-load-chain.sh gnutls-cli-save-data.sh gnutls-cli-debug.sh \
sni-resume.sh ocsp-tests/ocsptool.sh cert-reencoding.sh pkcs7-cat.sh long-crl.sh \
serv-udp.sh logfile-option.sh gnutls-cli-resume.sh profile-tests.sh \
- server-weak-keys.sh ocsp-tests/ocsp-signer-verify.sh
+ server-weak-keys.sh ocsp-tests/ocsp-signer-verify.sh cfg-test.sh
if !DISABLE_SYSTEM_CONFIG
dist_check_SCRIPTS += system-override-sig.sh system-override-hash.sh \
@@ -635,3 +635,31 @@ LOG_COMPILER = $(LOG_VALGRIND)
distclean-local:
rm -rf softhsm-*.db softhsm-*.config *.tmp tmp-* x509-crt-list-import-url.config.db port.lock.d
+
+EXTRA_DIST += \
+ fixtures/templates/arb-extensions.tmpl.exp \
+ fixtures/templates/crit-extensions.tmpl.exp \
+ fixtures/templates/inhibit-anypolicy.tmpl.exp \
+ fixtures/templates/simple-policy.tmpl.exp \
+ fixtures/templates/template-crq.tmpl.exp \
+ fixtures/templates/template-dates-after2038.tmpl.exp \
+ fixtures/templates/template-date.tmpl.exp \
+ fixtures/templates/template-dn-err.tmpl.exp \
+ fixtures/templates/template-dn.tmpl.exp \
+ fixtures/templates/template-generalized.tmpl.exp \
+ fixtures/templates/template-krb5name.tmpl.exp \
+ fixtures/templates/template-long-dns.tmpl.exp \
+ fixtures/templates/template-long-serial.tmpl.exp \
+ fixtures/templates/template-nc.tmpl.exp \
+ fixtures/templates/template-no-ca-explicit.tmpl.exp \
+ fixtures/templates/template-no-ca-honor.tmpl.exp \
+ fixtures/templates/template-no-ca.tmpl.exp \
+ fixtures/templates/template-othername.tmpl.exp \
+ fixtures/templates/template-othername-xmpp.tmpl.exp \
+ fixtures/templates/template-overflow2.tmpl.exp \
+ fixtures/templates/template-overflow.tmpl.exp \
+ fixtures/templates/template-test.tmpl.exp \
+ fixtures/templates/template-tlsfeature-crq.tmpl.exp \
+ fixtures/templates/template-tlsfeature.tmpl.exp \
+ fixtures/templates/template-unique.tmpl.exp \
+ fixtures/templates/template-utf8.tmpl.exp
diff --git a/tests/cert-tests/pkcs12-encode.sh b/tests/cert-tests/pkcs12-encode.sh
index 2f719f3044..f3e7ade3b9 100755
--- a/tests/cert-tests/pkcs12-encode.sh
+++ b/tests/cert-tests/pkcs12-encode.sh
@@ -47,14 +47,14 @@ TMPFILE_PEM=pkcs12.$$.pem.tmp
${VALGRIND} "${CERTTOOL}" --to-p12 --password 123456 --p12-name "my-key" --load-certificate "${srcdir}/../certs/cert-ecc256.pem" --load-privkey "${srcdir}/../certs/ecc256.pem" --load-ca-certificate "${srcdir}/../certs/ca-cert-ecc.pem" --outder --outfile $TMPFILE >/dev/null
rc=$?
if test ${rc} != 0; then
- echo "PKCS12 FATAL encoding 2"
+ echo "PKCS12 FATAL encoding 2 (--outder)"
exit 1
fi
${VALGRIND} "${CERTTOOL}" --p12-info --inder --password 123456 --infile $TMPFILE >${TMPFILE_PEM} 2>/dev/null
rc=$?
if test ${rc} != 0; then
- echo "PKCS12 FATAL decrypting/decoding 2"
+ echo "PKCS12 FATAL decrypting/decoding 2 (--inder)"
exit 1
fi
@@ -73,18 +73,18 @@ if test "$count" != "2"; then
fi
# Check whether we can encode a PKCS#12 file with cert / key and CRL
-${VALGRIND} "${CERTTOOL}" --to-p12 --password 123456 --pkcs-cipher aes-128 --p12-name "my-combo-key" --load-crl "${srcdir}/data/crl-demo1.pem" --load-certificate "${srcdir}/../certs/cert-ecc256.pem" --load-privkey "${srcdir}/../certs/ecc256.pem" --load-ca-certificate "${srcdir}/../certs/ca-cert-ecc.pem" --outder --outfile $TMPFILE >/dev/null
+${VALGRIND} "${CERTTOOL}" --to-p12 --password 123456 --pkcs-cipher aes-128 --p12-name "my-combo-key" --load-crl "${srcdir}/data/crl-demo1.pem" --load-certificate "${srcdir}/../certs/cert-ecc256.pem" --load-privkey "${srcdir}/../certs/ecc256.pem" --load-ca-certificate "${srcdir}/../certs/ca-cert-ecc.pem" --outraw --outfile $TMPFILE >/dev/null
rc=$?
if test ${rc} != 0; then
- echo "PKCS12 FATAL encoding 3"
+ echo "PKCS12 FATAL encoding 3 (--outraw)"
exit 1
fi
# Check whether the contents are the expected ones
-${VALGRIND} "${CERTTOOL}" --p12-info --inder --password 123456 --infile $TMPFILE >${TMPFILE_PEM} 2>/dev/null
+${VALGRIND} "${CERTTOOL}" --p12-info --inraw --password 123456 --infile $TMPFILE >${TMPFILE_PEM} 2>/dev/null
rc=$?
if test ${rc} != 0; then
- echo "PKCS12 FATAL decrypting/decoding 3"
+ echo "PKCS12 FATAL decrypting/decoding 3 (--inraw)"
exit 1
fi
diff --git a/tests/cfg-test.sh b/tests/cfg-test.sh
new file mode 100644
index 0000000000..75b7e68cdd
--- /dev/null
+++ b/tests/cfg-test.sh
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+# Copyright (C) 2021 Daiki Ueno
+#
+# This file is part of GnuTLS.
+#
+# GnuTLS 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.
+#
+# GnuTLS 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 Lesser General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>
+
+: ${top_builddir=..}
+: ${srcdir=.}
+
+: ${DUMPCFG=$top_builddir/src/dumpcfg${EXEEXT}}
+
+if ! test -x "${DUMPCFG}"; then
+ exit 77
+fi
+
+if test -n "$VALGRIND"; then
+ VALGRIND="${LIBTOOL:-libtool} --mode=execute ${VALGRIND} --error-exitcode=1"
+fi
+
+: ${DIFF=diff}
+
+. "$srcdir/scripts/common.sh"
+testdir=`create_testdir cfg`
+
+
+TEMPLATES="
+arb-extensions.tmpl
+crit-extensions.tmpl
+inhibit-anypolicy.tmpl
+template-crq.tmpl
+template-date.tmpl
+template-dates-after2038.tmpl
+template-dn-err.tmpl
+template-dn.tmpl
+template-generalized.tmpl
+template-krb5name.tmpl
+template-long-dns.tmpl
+template-long-serial.tmpl
+template-nc.tmpl
+template-no-ca-explicit.tmpl
+template-no-ca-honor.tmpl
+template-no-ca.tmpl
+template-othername-xmpp.tmpl
+template-othername.tmpl
+template-overflow.tmpl
+template-overflow2.tmpl
+template-test.tmpl
+template-tlsfeature-crq.tmpl
+template-tlsfeature.tmpl
+template-unique.tmpl
+template-utf8.tmpl
+simple-policy.tmpl
+"
+
+for template in $TEMPLATES; do
+ "$DUMPCFG" "$srcdir/cert-tests/templates/$template" > "$testdir/$template.out"
+ "$DIFF" "$srcdir/fixtures/templates/$template.exp" "$testdir/$template.out" || exit 1
+done
+
+rm -rf "$testdir"
diff --git a/tests/fixtures/templates/arb-extensions.tmpl.exp b/tests/fixtures/templates/arb-extensions.tmpl.exp
new file mode 100644
index 0000000000..852b77a904
--- /dev/null
+++ b/tests/fixtures/templates/arb-extensions.tmpl.exp
@@ -0,0 +1,17 @@
+organization: Koko inc.
+unit: sleeping dept.
+state: Attiki
+country: GR
+cn: Cindy Lauper
+uid: clauper
+serial: 9
+expiration_days: 2590
+email_protection_key:
+add_extension: 1.2.3.4 0001020304050607AAABCD
+add_extension: 1.6.7.8 0x0001020304050607AAABCD
+add_extension: 1.2.3.4.5.6.7 1d34cd5ad065dc27c17e9447b0aaaca7
+add_extension: 1.2.3.4294967295.7 178f0e413f041cc9d64af64bf3b66c7ceac6fa34a4d77ed64c968b26c761709445f40d9ca0a00091af7d212789c00b7387b1d0d7ab623dd4029d4b86db3653621d34cd5ad065dc27c17e9447b0aaaca7
+add_critical_extension: 1.10.11.12.13.14.15.16.17.1.5 CAFE
+add_extension: 1.2.6710656.7 d64af64bf3b66c7ceac6fa34a4d77ed64c968b26c761709445f40d9ca0a00091af7d212789c00b7387b1d0d7ab623dd4029d4b86db3653621d34cd5ad065dc27c17e9447b0aaaca7
+add_extension: 1.0.1.5 octet_string(CAFEBEAF)
+add_critical_extension: 1.0.1.5.1 octet_string(BEAFCAFEFAFA)
diff --git a/tests/fixtures/templates/crit-extensions.tmpl.exp b/tests/fixtures/templates/crit-extensions.tmpl.exp
new file mode 100644
index 0000000000..cfb46a010f
--- /dev/null
+++ b/tests/fixtures/templates/crit-extensions.tmpl.exp
@@ -0,0 +1,10 @@
+organization: Koko inc.
+unit: sleeping dept.
+state: Attiki
+country: GR
+cn: Cindy Lauper
+uid: clauper
+serial: 9
+expiration_days: 2590
+add_critical_extension: 1.10.11.12.13.14.15.16.17.1.5 CAFE
+add_critical_extension: 1.2.1.5.1 octet_string(BEAFCAFEFAFA)
diff --git a/tests/fixtures/templates/inhibit-anypolicy.tmpl.exp b/tests/fixtures/templates/inhibit-anypolicy.tmpl.exp
new file mode 100644
index 0000000000..23d962de02
--- /dev/null
+++ b/tests/fixtures/templates/inhibit-anypolicy.tmpl.exp
@@ -0,0 +1,25 @@
+organization: Koko inc.
+unit: sleeping dept.
+state: Attiki
+country: GR
+cn: Cindy Lauper
+uid: clauper
+dn_oid: 2.5.4.12 Dr.
+dn_oid: 2.5.4.65 jackal
+pkcs9_email: none@none.org
+serial: 7
+inhibit_anypolicy_skip_certs: 3
+expiration_days: 2590
+dns_name: www.none.org
+dns_name: www.morethanone.org
+ip_address: 192.168.1.1
+dns_name: www.evenmorethanone.org
+email: none@none.org
+crl_dist_points: http://www.getcrl.crl/getcrl1/
+crl_dist_points: http://www.getcrl.crl/getcrl2/
+crl_dist_points: http://www.getcrl.crl/getcrl3/
+email: where@none.org
+ca:
+signing_key:
+cert_signing_key:
+ocsp_signing_key:
diff --git a/tests/fixtures/templates/simple-policy.tmpl.exp b/tests/fixtures/templates/simple-policy.tmpl.exp
new file mode 100644
index 0000000000..c197d525fd
--- /dev/null
+++ b/tests/fixtures/templates/simple-policy.tmpl.exp
@@ -0,0 +1,9 @@
+organization: Koko inc.
+unit: sleeping dept.
+state: Attiki
+country: GR
+cn: Cindy Lauper
+uid: clauper
+serial: 10
+expiration_days: 2590
+policy1: 2.16.840.1.101.3.2.1.48.1
diff --git a/tests/fixtures/templates/template-crq.tmpl.exp b/tests/fixtures/templates/template-crq.tmpl.exp
new file mode 100644
index 0000000000..1ec355d227
--- /dev/null
+++ b/tests/fixtures/templates/template-crq.tmpl.exp
@@ -0,0 +1,3 @@
+serial: 567
+honor_crq_ext: 2.5.29.15
+honor_crq_ext: 2.5.29.37
diff --git a/tests/fixtures/templates/template-date.tmpl.exp b/tests/fixtures/templates/template-date.tmpl.exp
new file mode 100644
index 0000000000..28485a2b1e
--- /dev/null
+++ b/tests/fixtures/templates/template-date.tmpl.exp
@@ -0,0 +1,23 @@
+organization: Koko inc.
+unit: sleeping dept.
+state: Attiki
+country: GR
+cn: Cindy Lauper
+uid: clauper
+dn_oid: 2.5.4.12 Dr.
+dn_oid: 2.5.4.65 jackal
+pkcs9_email: none@none.org
+serial: 7
+expiration_date: 2015-05-24 14:29:12
+activation_date: 2029-01-12 11:36:11
+dns_name: www.none.org
+dns_name: www.morethanone.org
+ip_address: 192.168.1.1
+dns_name: www.evenmorethanone.org
+email: none@none.org
+crl_dist_points: http://www.getcrl.crl/getcrl/
+email: where@none.org
+ca:
+signing_key:
+cert_signing_key:
+ocsp_signing_key:
diff --git a/tests/fixtures/templates/template-dates-after2038.tmpl.exp b/tests/fixtures/templates/template-dates-after2038.tmpl.exp
new file mode 100644
index 0000000000..d53ad5a16f
--- /dev/null
+++ b/tests/fixtures/templates/template-dates-after2038.tmpl.exp
@@ -0,0 +1,23 @@
+organization: Koko inc.
+unit: sleeping dept.
+state: Attiki
+country: GR
+cn: Cindy Lauper
+uid: clauper
+dn_oid: 2.5.4.12 Dr.
+dn_oid: 2.5.4.65 jackal
+pkcs9_email: none@none.org
+serial: 7
+expiration_date: 2043-05-24 14:29:12
+activation_date: 2039-01-12 11:36:11
+dns_name: www.none.org
+dns_name: www.morethanone.org
+ip_address: 192.168.1.1
+dns_name: www.evenmorethanone.org
+email: none@none.org
+crl_dist_points: http://www.getcrl.crl/getcrl/
+email: where@none.org
+ca:
+signing_key:
+cert_signing_key:
+ocsp_signing_key:
diff --git a/tests/fixtures/templates/template-dn-err.tmpl.exp b/tests/fixtures/templates/template-dn-err.tmpl.exp
new file mode 100644
index 0000000000..5353e24346
--- /dev/null
+++ b/tests/fixtures/templates/template-dn-err.tmpl.exp
@@ -0,0 +1,14 @@
+dn: acn=Nik,st=Attiki,C=GR,surNameO=Mavrogiannopoulos,2.5.4.9=Arkadias
+serial: 7
+expiration_days: 2590
+dns_name: www.none.org
+dns_name: www.morethanone.org
+ip_address: 192.168.1.1
+dns_name: www.evenmorethanone.org
+email: none@none.org
+crl_dist_points: http://www.getcrl.crl/getcrl/
+email: where@none.org
+ca:
+signing_key:
+cert_signing_key:
+ocsp_signing_key:
diff --git a/tests/fixtures/templates/template-dn.tmpl.exp b/tests/fixtures/templates/template-dn.tmpl.exp
new file mode 100644
index 0000000000..173eb94a20
--- /dev/null
+++ b/tests/fixtures/templates/template-dn.tmpl.exp
@@ -0,0 +1,14 @@
+dn: 2.5.4.9=Arkadias,surName=Mavrogiannopoulos,C=GR,st=Attiki,cn=Nik
+serial: 7
+expiration_days: 2590
+dns_name: www.none.org
+dns_name: www.morethanone.org
+ip_address: 192.168.1.1
+dns_name: www.evenmorethanone.org
+email: none@none.org
+crl_dist_points: http://www.getcrl.crl/getcrl/
+email: where@none.org
+ca:
+signing_key:
+cert_signing_key:
+ocsp_signing_key:
diff --git a/tests/fixtures/templates/template-generalized.tmpl.exp b/tests/fixtures/templates/template-generalized.tmpl.exp
new file mode 100644
index 0000000000..997eb24c63
--- /dev/null
+++ b/tests/fixtures/templates/template-generalized.tmpl.exp
@@ -0,0 +1,23 @@
+organization: Koko inc.
+unit: sleeping dept.
+state: Attiki
+country: GR
+cn: Cindy Lauper
+uid: clauper
+dn_oid: 2.5.4.12 Dr.
+dn_oid: 2.5.4.65 jackal
+pkcs9_email: none@none.org
+serial: 7
+expiration_date: 2055-05-24 14:29:12
+activation_date: 2051-01-12 11:36:11
+dns_name: www.none.org
+dns_name: www.morethanone.org
+ip_address: 192.168.1.1
+dns_name: www.evenmorethanone.org
+email: none@none.org
+crl_dist_points: http://www.getcrl.crl/getcrl/
+email: where@none.org
+ca:
+signing_key:
+cert_signing_key:
+ocsp_signing_key:
diff --git a/tests/fixtures/templates/template-krb5name.tmpl.exp b/tests/fixtures/templates/template-krb5name.tmpl.exp
new file mode 100644
index 0000000000..c4284245d7
--- /dev/null
+++ b/tests/fixtures/templates/template-krb5name.tmpl.exp
@@ -0,0 +1,16 @@
+dn: 2.5.4.9=Arkadias,surName=Mavrogiannopoulos,C=GR,st=Attiki,cn=Nik
+serial: 7
+expiration_days: 2590
+krb5_principal: user@email.domain@KERBEROS.REALM
+krb5_principal: user@REALM.COM
+krb5_principal: HTTP/user@REALM.COM
+krb5_principal: comp1/comp2/user@REALM.COM
+ip_address: 192.168.1.1
+dns_name: www.evenmorethanone.org
+email: none@none.org
+crl_dist_points: http://www.getcrl.crl/getcrl/
+email: where@none.org
+ca:
+signing_key:
+cert_signing_key:
+ocsp_signing_key:
diff --git a/tests/fixtures/templates/template-long-dns.tmpl.exp b/tests/fixtures/templates/template-long-dns.tmpl.exp
new file mode 100644
index 0000000000..c3e02a103a
--- /dev/null
+++ b/tests/fixtures/templates/template-long-dns.tmpl.exp
@@ -0,0 +1,14 @@
+dn: cn=super-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-long.com
+serial: 7
+expiration_days: 2590
+o: super-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-long org
+ou: super-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-long dept
+dns_name: super-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-long.com
+dns_name: www.morethanone.org
+ip_address: 192.168.1.1
+dns_name: www.evenmorethanone.org
+email: none@none.org
+crl_dist_points: http://www.getcrl.crl/getcrl/
+email: where@none.org
+tls_www_server:
+signing_key:
diff --git a/tests/fixtures/templates/template-long-serial.tmpl.exp b/tests/fixtures/templates/template-long-serial.tmpl.exp
new file mode 100644
index 0000000000..4650f7cf43
--- /dev/null
+++ b/tests/fixtures/templates/template-long-serial.tmpl.exp
@@ -0,0 +1,24 @@
+organization: Koko inc.
+unit: sleeping dept.
+state: Attiki
+country: GR
+cn: Cindy Lauper
+uid: clauper
+dn_oid: 2.5.4.12 Dr.
+dn_oid: 2.5.4.65 jackal
+pkcs9_email: none@none.org
+serial: 0x1234567890abcdeffedcba0987654321abcdef12
+expiration_days: 2590
+dns_name: www.none.org
+dns_name: www.morethanone.org
+ip_address: 192.168.1.1
+dns_name: www.evenmorethanone.org
+email: none@none.org
+crl_dist_points: http://www.getcrl.crl/getcrl1/
+crl_dist_points: http://www.getcrl.crl/getcrl2/
+crl_dist_points: http://www.getcrl.crl/getcrl3/
+email: where@none.org
+ca:
+signing_key:
+cert_signing_key:
+ocsp_signing_key:
diff --git a/tests/fixtures/templates/template-nc.tmpl.exp b/tests/fixtures/templates/template-nc.tmpl.exp
new file mode 100644
index 0000000000..5dc8b9e058
--- /dev/null
+++ b/tests/fixtures/templates/template-nc.tmpl.exp
@@ -0,0 +1,27 @@
+dn: 2.5.4.9=Arkadias,surName=Mavrogiannopoulos,C=GR,st=Attiki,cn=Nik
+serial: 7
+expiration_days: 2590
+dns_name: www.none.org
+dns_name: www.morethanone.org
+dns_name: www.evenmorethanone.org
+email: none@none.org
+crl_dist_points: http://www.getcrl.crl/getcrl/
+email: where@none.org
+ca:
+signing_key:
+nc_permit_dns: example.com
+nc_exclude_dns: net
+nc_exclude_dns: org
+nc_exclude_dns:
+nc_permit_email: nmav@example.com
+nc_exclude_email: example.net
+nc_exclude_email: example.li
+nc_permit_ip: 192.168.5.0/24
+nc_permit_ip: 10.10.10.0/16
+nc_permit_ip: 172.23.122.0/23
+nc_exclude_ip: 10.10.100.0/24
+nc_exclude_ip: 10.10.101.5/24
+nc_permit_ip: fc4c:fe8f:7ffa:18bd::/64
+nc_exclude_ip: fc4c:fe8f:7ffa:18bd:72c8:64b9::/96
+cert_signing_key:
+ocsp_signing_key:
diff --git a/tests/fixtures/templates/template-no-ca-explicit.tmpl.exp b/tests/fixtures/templates/template-no-ca-explicit.tmpl.exp
new file mode 100644
index 0000000000..935a6a87bf
--- /dev/null
+++ b/tests/fixtures/templates/template-no-ca-explicit.tmpl.exp
@@ -0,0 +1,11 @@
+cn: No CA
+serial: 02
+email_protection_key:
+add_extension: 1.2.3.4 0001020304050607AAABCD
+add_extension: 1.6.7.8 0x0001020304050607AAABCD
+add_extension: 1.2.3.4.5.6.7 1d34cd5ad065dc27c17e9447b0aaaca7
+add_extension: 1.2.3.4294967295.7 178f0e413f041cc9d64af64bf3b66c7ceac6fa34a4d77ed64c968b26c761709445f40d9ca0a00091af7d212789c00b7387b1d0d7ab623dd4029d4b86db3653621d34cd5ad065dc27c17e9447b0aaaca7
+add_critical_extension: 1.10.11.12.13.14.15.16.17.1.5 CAFE
+add_extension: 1.2.6710656.7 d64af64bf3b66c7ceac6fa34a4d77ed64c968b26c761709445f40d9ca0a00091af7d212789c00b7387b1d0d7ab623dd4029d4b86db3653621d34cd5ad065dc27c17e9447b0aaaca7
+add_extension: 1.0.1.5 octet_string(CAFEBEAF)
+add_critical_extension: 1.0.1.5.1 octet_string(BEAFCAFEFAFA)
diff --git a/tests/fixtures/templates/template-no-ca-honor.tmpl.exp b/tests/fixtures/templates/template-no-ca-honor.tmpl.exp
new file mode 100644
index 0000000000..4da60e4be8
--- /dev/null
+++ b/tests/fixtures/templates/template-no-ca-honor.tmpl.exp
@@ -0,0 +1,3 @@
+cn: No CA
+serial: 02
+honor_crq_extensions:
diff --git a/tests/fixtures/templates/template-no-ca.tmpl.exp b/tests/fixtures/templates/template-no-ca.tmpl.exp
new file mode 100644
index 0000000000..06e845b4b5
--- /dev/null
+++ b/tests/fixtures/templates/template-no-ca.tmpl.exp
@@ -0,0 +1,2 @@
+cn: No CA
+serial: 02
diff --git a/tests/fixtures/templates/template-othername-xmpp.tmpl.exp b/tests/fixtures/templates/template-othername-xmpp.tmpl.exp
new file mode 100644
index 0000000000..9e6c37b978
--- /dev/null
+++ b/tests/fixtures/templates/template-othername-xmpp.tmpl.exp
@@ -0,0 +1,15 @@
+dn: 2.5.4.9=Arkadias,surName=Mavrogiannopoulos,C=GR,st=Attiki,cn=Nik
+serial: 7
+expiration_days: 2590
+dns_name: www.none.org
+dns_name: www.morethanone.org
+xmpp_name: juliet@im.example.com
+xmpp_name: hello@hello.org
+ip_address: 192.168.1.1
+dns_name: www.evenmorethanone.org
+email: none@none.org
+crl_dist_points: http://www.getcrl.crl/getcrl/
+email: where@none.org
+signing_key:
+cert_signing_key:
+ocsp_signing_key:
diff --git a/tests/fixtures/templates/template-othername.tmpl.exp b/tests/fixtures/templates/template-othername.tmpl.exp
new file mode 100644
index 0000000000..a022590122
--- /dev/null
+++ b/tests/fixtures/templates/template-othername.tmpl.exp
@@ -0,0 +1,18 @@
+dn: 2.5.4.9=Arkadias,surName=Mavrogiannopoulos,C=GR,st=Attiki,cn=Nik
+serial: 7
+expiration_days: 2590
+dns_name: www.none.org
+dns_name: www.morethanone.org
+other_name: 1.3.6.1.5.2.2 302ca00d1b0b56414e5245494e2e4f5247a11b3019a006020400000002a10f300d1b047269636b1b0561646d696e
+other_name_utf8: 1.3.6.1.5.5.7.8.7 nmav@gnutls.org
+other_name_utf8: 1.3.6.1.5.5.7.8.5 nmav@gnutls.org
+other_name_octet: 1.2.4.5.6 a test string
+ip_address: 192.168.1.1
+dns_name: www.evenmorethanone.org
+email: none@none.org
+crl_dist_points: http://www.getcrl.crl/getcrl/
+email: where@none.org
+ca:
+signing_key:
+cert_signing_key:
+ocsp_signing_key:
diff --git a/tests/fixtures/templates/template-overflow.tmpl.exp b/tests/fixtures/templates/template-overflow.tmpl.exp
new file mode 100644
index 0000000000..2753b00258
--- /dev/null
+++ b/tests/fixtures/templates/template-overflow.tmpl.exp
@@ -0,0 +1,22 @@
+organization: Koko inc.
+unit: sleeping dept.
+state: Attiki
+country: GR
+cn: Cindy Lauper
+uid: clauper
+dn_oid: 2.5.4.12 Dr.
+dn_oid: 2.5.4.65 jackal
+pkcs9_email: none@none.org
+serial: 7
+expiration_days: -1
+dns_name: www.none.org
+dns_name: www.morethanone.org
+ip_address: 192.168.1.1
+dns_name: www.evenmorethanone.org
+email: none@none.org
+crl_dist_points: http://www.getcrl.crl/getcrl/
+email: where@none.org
+ca:
+signing_key:
+cert_signing_key:
+ocsp_signing_key:
diff --git a/tests/fixtures/templates/template-overflow2.tmpl.exp b/tests/fixtures/templates/template-overflow2.tmpl.exp
new file mode 100644
index 0000000000..8e6ac7b3a9
--- /dev/null
+++ b/tests/fixtures/templates/template-overflow2.tmpl.exp
@@ -0,0 +1,22 @@
+organization: Koko inc.
+unit: sleeping dept.
+state: Attiki
+country: GR
+cn: Cindy Lauper
+uid: clauper
+dn_oid: 2.5.4.12 Dr.
+dn_oid: 2.5.4.65 jackal
+pkcs9_email: none@none.org
+serial: 7
+expiration_days: 99999
+dns_name: www.none.org
+dns_name: www.morethanone.org
+ip_address: 192.168.1.1
+dns_name: www.evenmorethanone.org
+email: none@none.org
+crl_dist_points: http://www.getcrl.crl/getcrl/
+email: where@none.org
+ca:
+signing_key:
+cert_signing_key:
+ocsp_signing_key:
diff --git a/tests/fixtures/templates/template-test.tmpl.exp b/tests/fixtures/templates/template-test.tmpl.exp
new file mode 100644
index 0000000000..b4a8d2d89a
--- /dev/null
+++ b/tests/fixtures/templates/template-test.tmpl.exp
@@ -0,0 +1,24 @@
+organization: Koko inc.
+unit: sleeping dept.
+state: Attiki
+country: GR
+cn: Cindy Lauper
+uid: clauper
+dn_oid: 2.5.4.12 Dr.
+dn_oid: 2.5.4.65 jackal
+pkcs9_email: none@none.org
+serial: 7
+expiration_days: 2590
+dns_name: www.none.org
+dns_name: www.morethanone.org
+ip_address: 192.168.1.1
+dns_name: www.evenmorethanone.org
+email: none@none.org
+crl_dist_points: http://www.getcrl.crl/getcrl1/
+crl_dist_points: http://www.getcrl.crl/getcrl2/
+crl_dist_points: http://www.getcrl.crl/getcrl3/
+email: where@none.org
+ca:
+signing_key:
+cert_signing_key:
+ocsp_signing_key:
diff --git a/tests/fixtures/templates/template-tlsfeature-crq.tmpl.exp b/tests/fixtures/templates/template-tlsfeature-crq.tmpl.exp
new file mode 100644
index 0000000000..7323cf7a09
--- /dev/null
+++ b/tests/fixtures/templates/template-tlsfeature-crq.tmpl.exp
@@ -0,0 +1,6 @@
+organization: Koko inc.
+unit: sleeping dept.
+state: Attiki
+country: GR
+cn: Cindy Lauper
+honor_crq_extensions:
diff --git a/tests/fixtures/templates/template-tlsfeature.tmpl.exp b/tests/fixtures/templates/template-tlsfeature.tmpl.exp
new file mode 100644
index 0000000000..a204db98d0
--- /dev/null
+++ b/tests/fixtures/templates/template-tlsfeature.tmpl.exp
@@ -0,0 +1,25 @@
+organization: Koko inc.
+unit: sleeping dept.
+state: Attiki
+country: GR
+cn: Cindy Lauper
+uid: clauper
+tls_feature: 5
+tls_feature: 17
+dn_oid: 2.5.4.12 Dr.
+dn_oid: 2.5.4.65 jackal
+pkcs9_email: none@none.org
+serial: 7
+expiration_days: 2590
+dns_name: www.none.org
+dns_name: www.morethanone.org
+ip_address: 192.168.1.1
+dns_name: www.evenmorethanone.org
+email: none@none.org
+crl_dist_points: http://www.getcrl.crl/getcrl1/
+crl_dist_points: http://www.getcrl.crl/getcrl2/
+crl_dist_points: http://www.getcrl.crl/getcrl3/
+email: where@none.org
+signing_key:
+cert_signing_key:
+ocsp_signing_key:
diff --git a/tests/fixtures/templates/template-unique.tmpl.exp b/tests/fixtures/templates/template-unique.tmpl.exp
new file mode 100644
index 0000000000..55ae48c816
--- /dev/null
+++ b/tests/fixtures/templates/template-unique.tmpl.exp
@@ -0,0 +1,16 @@
+dn: 2.5.4.9=Arkadias,surName=Mavrogiannopoulos,C=GR,st=Attiki,cn=Nik
+serial: 7
+expiration_days: 2590
+dns_name: www.none.org
+dns_name: www.morethanone.org
+ip_address: 192.168.1.1
+dns_name: www.evenmorethanone.org
+email: none@none.org
+subject_unique_id: 0015232425
+issuer_unique_id: 11142324251224
+crl_dist_points: http://www.getcrl.crl/getcrl/
+email: where@none.org
+ca:
+signing_key:
+cert_signing_key:
+ocsp_signing_key:
diff --git a/tests/fixtures/templates/template-utf8.tmpl.exp b/tests/fixtures/templates/template-utf8.tmpl.exp
new file mode 100644
index 0000000000..4cd7ffa174
--- /dev/null
+++ b/tests/fixtures/templates/template-utf8.tmpl.exp
@@ -0,0 +1,14 @@
+organization: Μεγάλη εταιρία
+cn: 🐨
+state: Αττική
+country: GR
+serial: 009
+policy1: 1.3.6.1.4.1.5484.1.10.99.1.0
+policy1_txt: Μια πολιτική που θέλει διάβασμα
+policy1_url: http://www.example.com/a-policy-to-read
+policy2: 1.3.6.1.4.1.5484.1.10.99.1.1
+policy2_txt: Another policy
+policy2_url: http://www.example.com/another-policy-to-read
+policy3: 1.3.6.1.4.1.5484.1.10.99.1.2
+policy3_txt: More policies
+policy3_url: http://example.com/a-policy-to-read
diff --git a/tests/server-multi-keys.sh b/tests/server-multi-keys.sh
index 9dd6a6adfe..26ebee03d3 100755
--- a/tests/server-multi-keys.sh
+++ b/tests/server-multi-keys.sh
@@ -61,7 +61,7 @@ TMPFILE=outcert.$$.tmp
eval "${GETPORT}"
launch_server --echo --priority "NORMAL:+ECDHE-RSA:+ECDHE-ECDSA" --x509keyfile ${KEY1} --x509certfile ${CERT1} \
- --x509keyfile ${KEY2} --x509certfile ${CERT2} --x509keyfile ${KEY3} --x509certfile ${CERT3}
+ --x509keyfile ${KEY2} --x509ecccertfile ${CERT2} --x509keyfile ${KEY3} --x509certfile ${CERT3}
PID=$!
wait_server ${PID}