diff options
| author | Werner Koch <[email protected]> | 2008-06-19 18:38:28 +0000 | 
|---|---|---|
| committer | Werner Koch <[email protected]> | 2008-06-19 18:38:28 +0000 | 
| commit | 63ea0d66630d2d790f82d744ee88b51b7e3c3b59 (patch) | |
| tree | 5d0b344a8812c3aee65bfd8091698570820ea120 | |
| parent | Add new types to the gpgconf interface. (diff) | |
| download | gpgme-63ea0d66630d2d790f82d744ee88b51b7e3c3b59.tar.gz gpgme-63ea0d66630d2d790f82d744ee88b51b7e3c3b59.zip | |
Add example.
Update gpgconf test.
Diffstat (limited to '')
| -rw-r--r-- | doc/examples/show-group-options.c | 104 | ||||
| -rw-r--r-- | tests/ChangeLog | 5 | ||||
| -rw-r--r-- | tests/gpg/t-gpgconf.c | 6 | 
3 files changed, 114 insertions, 1 deletions
| diff --git a/doc/examples/show-group-options.c b/doc/examples/show-group-options.c new file mode 100644 index 00000000..aee962de --- /dev/null +++ b/doc/examples/show-group-options.c @@ -0,0 +1,104 @@ +/* show-group-options.c - Example code to retriev the group option. +   Copyright (C) 2008 g10 Code GmbH + +   This file is part of GPGME. +  +   GPGME 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. +    +   GPGME 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 <http://www.gnu.org/licenses/>. + */ + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <locale.h> + +#include <gpgme.h> + + +#define fail_if_err(err)					\ +  do								\ +    {								\ +      if (err)							\ +        {							\ +          fprintf (stderr, "%s:%d: gpgme_error_t %s\n",		\ +                   __FILE__, __LINE__, gpgme_strerror (err));   \ +          exit (1);						\ +        }							\ +    }								\ +  while (0) + + + + +static void +print_gpgconf_string (const char *cname, const char *name) +{ +  gpg_error_t err; +  gpgme_ctx_t ctx; +  gpgme_conf_comp_t conf_list, conf; +  gpgme_conf_opt_t opt; +  gpgme_conf_arg_t value; + +  err = gpgme_new (&ctx); +  fail_if_err (err); + +  err = gpgme_op_conf_load (ctx, &conf_list); +  fail_if_err (err); +       +  for (conf = conf_list; conf; conf = conf->next) +    { +      if ( !strcmp (conf->name, cname) ) +        { +          for (opt = conf->options; opt; opt = opt->next) +            if ( !(opt->flags & GPGME_CONF_GROUP) +                 && !strcmp (opt->name, name)) +              { +                for (value = opt->value; value; value = value->next) +                  { +                    if (opt->alt_type == GPGME_CONF_STRING) +                      printf ("%s/%s -> `%s'\n", +                              cname,name, value->value.string); +                  } +                break; +              } +          break; +        }  +    } +   +  gpgme_conf_release (conf_list); +  gpgme_release (ctx); +} + + + +int  +main (int argc, char **argv ) +{ +  gpgme_check_version (NULL); +  setlocale (LC_ALL, ""); +  gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL)); +#ifndef HAVE_W32_SYSTEM +  gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL)); +#endif + +  print_gpgconf_string ("gpg", "group"); + +  return 0; +} + + +/* +Local Variables: +compile-command: "cc -o show-group-options show-group-options.c -lgpgme" +End: +*/ diff --git a/tests/ChangeLog b/tests/ChangeLog index 2815c680..060c12ff 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,8 @@ +2008-06-19  Werner Koch  <[email protected]> + +	* gpg/t-gpgconf.c (dump_arg): Add new types.  Print strings in +	quotes. +  2008-01-28  Marcus Brinkmann  <[email protected]>  	* gpg/Makefile.am (DISTCLEANFILES): Add pubring.kbx~. diff --git a/tests/gpg/t-gpgconf.c b/tests/gpg/t-gpgconf.c index 8d9fb200..8e487b7a 100644 --- a/tests/gpg/t-gpgconf.c +++ b/tests/gpg/t-gpgconf.c @@ -104,7 +104,11 @@ dump_arg (int type, gpgme_conf_arg_t arg)  	case GPGME_CONF_STRING:  	case GPGME_CONF_PATHNAME:  	case GPGME_CONF_LDAP_SERVER: -	  printf ("%s", arg->value.string); +        case GPGME_CONF_KEY_FPR: +        case GPGME_CONF_PUB_KEY: +        case GPGME_CONF_SEC_KEY: +        case GPGME_CONF_ALIAS_LIST: +	  printf ("`%s'", arg->value.string);  	  break;  	case GPGME_CONF_UINT32: | 
