Home GnuPG

core: Add the group of argparse functions.

Description

core: Add the group of argparse functions.

* src/visibility.c (gpgrt_argparse): New.
(gpgrt_strusage): New.
(gpgrt_set_strusage): New.
(gpgrt_set_usage_outfnc): New.
(gpgrt_set_fixed_string_mapper): New.
* src/gpg-error.def.in, src/gpg-error.vers: Add new functions.
* src/gpg-error.h.in: Add ARGPARSE macros from the former argparse.h.
(gpgrt_argparse_t): New.
(gpgrt_opt_t): New.
* configure.ac (AH_BOTTOM): Request argparse macros.
* src/Makefile.am (libgpg_error_la_SOURCES): Add argparse.c.
* src/argparse.h: Remove.
* src/argparse.c: Revamp to fit into libgpg-error.
(_gpgrt_argparse): New.
(_gpgrt_usage): Rename from usage.
(_gpgrt_strusage): Rename from strusage.  Define two new levels and
templates for three common licenses.
(_gpgrt_set_strusage): Rename from set_strusage.
(_gpgrt_set_usage_outfnc): New.
(_gpgrt_set_fixed_string_mapper): New.
* tests/t-argparse.c: New.

These functions are in use by GnuPG and other software for 20 years
and it makes sense to have them always available instead of copying
and maintaing the source in several projects. Note that there are
minor changes in the API compared to GnuPG.

  • Signed-off-by: Werner Koch <wk@gnupg.org>

Details

Provenance
wernerAuthored on Mar 21 2018, 4:23 PM
Parents
rE1beb22fc25f6: core: Import argparse code from gnupg master
Branches
Unknown
Tags
Unknown