diff options
| author | Werner Koch <[email protected]> | 2018-03-21 18:26:03 +0000 | 
|---|---|---|
| committer | Werner Koch <[email protected]> | 2018-03-21 18:26:03 +0000 | 
| commit | e14f1f687ff618716ed17e309a0475df95e1c0aa (patch) | |
| tree | bd34212967c8e18c576e1892b9846d23a9e7499f /src/gpgme-json.c | |
| parent | json: Implement op:encrypt (diff) | |
| download | gpgme-e14f1f687ff618716ed17e309a0475df95e1c0aa.tar.gz gpgme-e14f1f687ff618716ed17e309a0475df95e1c0aa.zip  | |
json: Use gpgrt_argparse instead of argsparse.c
* src/gpgme-json.c: Remove header argparse.h.  Define
GPGRT_ENABLE_ARGPARSE_MACROS.
(interactive_repl): Replace strusage by gpgrt_strusage.
(my_strusage): Add SPDX level.
(main): Switch to gpgrt_argparse stuff but keep very limited
functionality when building with an older libgpg-error.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to '')
| -rw-r--r-- | src/gpgme-json.c | 25 | 
1 files changed, 18 insertions, 7 deletions
diff --git a/src/gpgme-json.c b/src/gpgme-json.c index 00d81105..75f1a095 100644 --- a/src/gpgme-json.c +++ b/src/gpgme-json.c @@ -36,8 +36,8 @@  #define GPGRT_ENABLE_ES_MACROS 1  #define GPGRT_ENABLE_LOG_MACROS 1 +#define GPGRT_ENABLE_ARGPARSE_MACROS 1  #include "gpgme.h" -#include "argparse.h"  #include "cJSON.h" @@ -828,8 +828,10 @@ interactive_repl (void)    int first;    es_setvbuf (es_stdin, NULL, _IONBF, 0); +#if GPGRT_VERSION_NUMBER >= 0x011d00 /* 1.29 */    es_fprintf (es_stderr, "%s %s ready (enter \",help\" for help)\n", -              strusage (11), strusage (13)); +              gpgrt_strusage (11), gpgrt_strusage (13)); +#endif    do      {        es_fputs ("> ", es_stderr); @@ -1064,6 +1066,7 @@ my_strusage( int level )    switch (level)      { +    case  9: p = "LGPL-2.1-or-later"; break;      case 11: p = "gpgme-json"; break;      case 13: p = PACKAGE_VERSION; break;      case 14: p = "Copyright (C) 2018 g10 Code GmbH"; break; @@ -1083,24 +1086,30 @@ my_strusage( int level )    return p;  } -  int  main (int argc, char *argv[])  { +#if GPGRT_VERSION_NUMBER < 0x011d00 /* 1.29 */ + +  fprintf (stderr, "WARNING: Old libgpg-error - using limited mode\n"); +  native_messaging_repl (); + +#else /* This is a modern libgp-error.  */ +    enum { CMD_DEFAULT     = 0,           CMD_INTERACTIVE = 'i',           CMD_SINGLE      = 's',           CMD_LIBVERSION  = 501    } cmd = CMD_DEFAULT; -  static ARGPARSE_OPTS opts[] = { +  static gpgrt_opt_t opts[] = {      ARGPARSE_c  (CMD_INTERACTIVE, "interactive", "Interactive REPL"),      ARGPARSE_c  (CMD_SINGLE,      "single",      "Single request mode"),      ARGPARSE_c  (CMD_LIBVERSION,  "lib-version", "Show library version"),      ARGPARSE_end()    }; -  ARGPARSE_ARGS pargs = { &argc, &argv, 0 }; +  gpgrt_argparse_t pargs = { &argc, &argv}; -  set_strusage (my_strusage); +  gpgrt_set_strusage (my_strusage);  #ifdef HAVE_SETLOCALE    setlocale (LC_ALL, ""); @@ -1113,7 +1122,7 @@ main (int argc, char *argv[])    gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL));  #endif -  while (arg_parse  (&pargs, opts)) +  while (gpgrt_argparse (NULL, &pargs, opts))      {        switch (pargs.r_opt)          { @@ -1130,6 +1139,7 @@ main (int argc, char *argv[])  	  break;          }      } +  gpgrt_argparse (NULL, &pargs, NULL);    switch (cmd)      { @@ -1153,5 +1163,6 @@ main (int argc, char *argv[])        break;      } +#endif /* This is a modern libgp-error.  */    return 0;  }  | 
