aboutsummaryrefslogtreecommitdiffstats
path: root/src/visibility.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2018-03-21 15:23:29 +0000
committerWerner Koch <[email protected]>2018-03-21 15:23:29 +0000
commit13d6fbfd4360cb74588556a3a0058c4057d0bcf0 (patch)
treef8cecb6515b9056826f95a272560af1fcf68bb9b /src/visibility.c
parentcore: Import argparse code from gnupg master (diff)
downloadlibgpg-error-13d6fbfd4360cb74588556a3a0058c4057d0bcf0.tar.gz
libgpg-error-13d6fbfd4360cb74588556a3a0058c4057d0bcf0.zip
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 <[email protected]>
Diffstat (limited to 'src/visibility.c')
-rw-r--r--src/visibility.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/visibility.c b/src/visibility.c
index 9358163..7058c91 100644
--- a/src/visibility.c
+++ b/src/visibility.c
@@ -1066,6 +1066,38 @@ gpgrt_release_process (pid_t pid)
}
#endif /*0*/
+
+int
+gpgrt_argparse (estream_t fp, gpgrt_argparse_t *arg, gpgrt_opt_t *opts)
+{
+ return _gpgrt_argparse (fp, arg, opts);
+}
+
+const char *
+gpgrt_strusage (int level)
+{
+ return _gpgrt_strusage (level);
+}
+
+void
+gpgrt_set_strusage (const char *(*f)(int))
+{
+ _gpgrt_set_strusage (f);
+}
+
+void
+gpgrt_set_usage_outfnc (int (*f)(int, const char *))
+{
+ _gpgrt_set_usage_outfnc (f);
+}
+
+void
+gpgrt_set_fixed_string_mapper (const char *(*f)(const char*))
+{
+ _gpgrt_set_fixed_string_mapper (f);
+}
+
+
/* For consistency reasons we use function wrappers also for Windows
* specific function despite that they are technically not needed. */