1. 08 Jun, 2020 9 commits
  2. 29 May, 2020 8 commits
  3. 19 May, 2020 1 commit
  4. 09 Apr, 2020 2 commits
  5. 03 Apr, 2020 3 commits
    • Werner Koch's avatar
      core: Improve the echo and info meta commands of the arg parser · 98d11eff
      Werner Koch authored
      
      
      * src/argparse.c (handle_meta_echo): Substitue some vars.
      (handle_meta_user): Factor some code out to ...
      (assure_username): new.
      --
      
      Yeah, that is not really needed but might sometimes be helpful.
      
      Signed-off-by: default avatarWerner Koch <wk@gnupg.org>
      98d11eff
    • Werner Koch's avatar
      core: Implement meta command [user] also for Windows · ef07aedc
      Werner Koch authored
      
      
      * src/argparse.c (initialize): Clear username.
      * src/sysutils.c (_gpgrt_getusername): Implement for Windows.
      --
      
      This also fixes a missing intialization
      
      Signed-off-by: default avatarWerner Koch <wk@gnupg.org>
      ef07aedc
    • Werner Koch's avatar
      core: Implement meta command [user] for the arg parser. · d843d260
      Werner Koch authored
      
      
      * src/sysutils.c (_gpgrt_getusername): New.
      * src/argparse.c (struct _gpgrt_argparse_internal_s): New flags user_*
      and store the current user.
      (initialize): Free new malloced field.  Clear new flags.
      (handle_meta_user): Implement.
      (handle_metacmd): Implement user sections.  Remove "group" meta
      command.
      (_gpgrt_argparse): Implement user sections.
      (finish_read_sys): Reset new vars.
      --
      
      Implementing group would be somewhat complicated and it is doubtful
      whether this really makes sense and is manageable for the admin.
      
      Note that we have not yet implemented this for Windows.
      
      Signed-off-by: default avatarWerner Koch <wk@gnupg.org>
      d843d260
  6. 06 Mar, 2020 2 commits
    • Werner Koch's avatar
      core: Tweak the printing of headers in the --help output. · 85b5006d
      Werner Koch authored
      
      
      * src/argparse.c (show_help): Do not print empty sections between
      headers.
      
      Signed-off-by: default avatarWerner Koch <wk@gnupg.org>
      85b5006d
    • Werner Koch's avatar
      core: Add features for pretty printing the help · c59bf582
      Werner Koch authored
      
      
      * src/gpg-error.h.in (ARGPARSE_OPT_HEADER): New.
      (ARGPARSE_OPT_VERBATIM): New.
      (ARGPARSE_verbatim): New.
      (ARGPARSE_header): New.
      * src/argparse.c (show_help): Implement them.
      --
      
      These two macros are useful for custom help screens.  In contrast to
      the ARGPARSE_group hack they do not need a short option number (we use
      1 here as a surrogate) and not the "@" hack.  Thus already translated
      strings can be used.  ARGPARSE_header further allows to specify a
      symbolic name for the group and does some minor formatting.  If such a
      symbolic name is given --dump-option-table also emits this as a pseudo
      option for consumption by GUIs which for example use tabs to group
      options.
      
      Signed-off-by: default avatarWerner Koch <wk@gnupg.org>
      c59bf582
  7. 03 Mar, 2020 2 commits
    • Werner Koch's avatar
      core: New function gpgrt_reallocarray. · 969abd30
      Werner Koch authored
      
      
      * src/init.c (_gpgrt_reallocarray): New.
      * src/visibility.c (gpgrt_reallocarray): New.
      * src/gpg-error.vers, src/gpg-error.def.in: Add new function.
      * src/gpg-error.h.in: Add new interface.
      * tests/t-malloc.c: New.
      * tests/Makefile.am (TESTS): Add new test.
      --
      
      Note that this function is different from the glibc function because
      it has an extra parameter which allows to clear the new elements.  A
      realloc after a calloc with forgotten memset after it is a common
      source of error, thus we introduce this slightly different function.
      
      Signed-off-by: default avatarWerner Koch <wk@gnupg.org>
      969abd30
    • Werner Koch's avatar
      core: Fix allocation bug introduced with last commit. · 72a15bad
      Werner Koch authored
      * src/argparse.c (initialize): Increase number of extra slots.
      --
      
      I should really buy the valgrind authors a beer.
      
      Fixes-commit: db95feab
      
      
      Signed-off-by: default avatarWerner Koch <wk@gnupg.org>
      72a15bad
  8. 02 Mar, 2020 3 commits
  9. 27 Feb, 2020 2 commits
    • Werner Koch's avatar
      core: Implement meta commands for the argparser. · 2d1969ab
      Werner Koch authored
      
      
      * src/argparse.c (opttable_t): Add new flags forced, ignore, and
      explicit_ignore.
      (struct _gpgrt_argparse_internal_s): Change flags to bitflags.  Add
      several flags to support meta commands.
      (initialize): Clear them.
      (handle_meta_user): Use the new verbose flag.
      (handle_meta_force): Implement.
      (handle_meta_ignore): Implement.
      (handle_meta_echo): Support "-echo".
      (handle_meta_verbose): New.
      (handle_metacmd): New meta command verbose.  Add always flag and move
      the detection of unexpected meta commands to here.
      (_gpgrt_argparse): Make use of the ignore and forced meta commands.
      (finish_read_sys): New.
      (_gpgrt_argparser): Support the verbose flag.  Call finish_read_sys.
      (arg_parse): Ignore non-explicit ignored and all forced options.
      
      * tests/t-argparse.c (main): Fix printing of the ARGPARSE_CONFFILE
      case.  New option 'M'.
      * tests/t-argparse.conf, tests/etc/t-argparse.conf: Various changes to
      test the new meta commands.
      --
      
      For the command line we print a diagnostic if an ignored or forced
      options is used.  However, we do not ignore options which are only set
      via [ignore-all].  The rationale for the latter is that an
      administrator can't be be required to unignore all options used by all
      modes, of say gpgme.
      
      Documentation of the meta commands will for now be added to GnuPG.
      
      GnuPG-bug-id: 4788
      Signed-off-by: default avatarWerner Koch <wk@gnupg.org>
      2d1969ab
    • Werner Koch's avatar
      indent: Fix indentation in an argparse.c function · ffa21bf5
      Werner Koch authored
      * src/argparse.c (arg_parse): Fix it here.
      ffa21bf5
  10. 26 Feb, 2020 2 commits
    • Werner Koch's avatar
      core: Add meta command handler stubs to argparse.c. · 2f169b34
      Werner Koch authored
      
      
      * src/argparse.c (handle_meta_user): New stub.
      (handle_meta_force): New stub.
      (handle_meta_ignore): New stub.
      (handle_meta_echo): New.
      (handle_metacmd): New.
      (_gpgrt_argparse): Call meta command handler.
      --
      
      GnuPG-bug-id: 4788
      Signed-off-by: default avatarWerner Koch <wk@gnupg.org>
      2f169b34
    • Werner Koch's avatar
      core: Prepare argparse.c to track additional info for options. · 9d268891
      Werner Koch authored
      
      
      * src/argparse.c (opttable_t): New.
      (struct _gpgrt_argparse_internal_s): Use this instead of a ppointer to
      gpgrt_opt_t.
      (initialize): Copy options to the new tableand keep an original ordinal.
      (_gpgrt_argparse): Adjust for changes.
      (any_opt_conffile): Ditto.
      (find_long_option): Ditto.
      (arg_parse): Ditto.
      (long_opt_strlen): Adjust args.
      (cmp_ordtbl): New.
      (show_help): Print using the ordinal numbers.
      --
      
      We will need to keep extra information along with the options.  This
      changes prepares this by using a copy of the user provided option
      table.  The only new info is the original ordinal number which will
      allow us to eventually do a binary search on the options but still be
      able to print the help in the user defined way.
      
      GnuPG-bug-id: 4788
      Signed-off-by: default avatarWerner Koch <wk@gnupg.org>
      9d268891
  11. 25 Feb, 2020 6 commits