diff options
author | Werner Koch <[email protected]> | 2008-06-20 10:40:52 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2008-06-20 10:40:52 +0000 |
commit | b0a5687a1657e5da1cf484f0dfc145bbef748b2c (patch) | |
tree | 190aa1388f952a202d2734afd8d820e281086c28 | |
parent | Fix parsing of long lines. (diff) | |
download | gpgme-b0a5687a1657e5da1cf484f0dfc145bbef748b2c.tar.gz gpgme-b0a5687a1657e5da1cf484f0dfc145bbef748b2c.zip |
Updated the example.
-rw-r--r-- | doc/examples/show-group-options.c | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/doc/examples/show-group-options.c b/doc/examples/show-group-options.c index aee962de..92c37549 100644 --- a/doc/examples/show-group-options.c +++ b/doc/examples/show-group-options.c @@ -20,6 +20,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <ctype.h> #include <locale.h> #include <gpgme.h> @@ -41,6 +42,55 @@ static void +print_one_alias (const char *string) +{ + const char *value, *s; + size_t namelen; + int first = 1; + int any = 0; + + while (isascii (*string) && isspace (*string)) + string++; + + value = strchr (string, '='); + if (value) + { + for (s=value-1; s > string ; s--) + if (!isascii (*s) || !isspace (*s)) + break; + } + if (!value || s == value ) + { + printf ("# error: invalid group definition!\n"); + return; + } + value++; + namelen = (s + 1 - string); + printf ("%.*s: ", (int)namelen, string); + + for (;;) + { + while (isascii (*value) && isspace (*value)) + value++; + if (!*value) + break; + for (s = value; *s && !(isascii (*s) && isspace (*s)); s++) + ; + printf ("%s%*s%.*s", + first? "":",\n", + any? (int)namelen+2:0, "", + (int)(s-value), value); + first = 0; + any = 1; + value = s; + } + putchar ('\n'); +} + + + + +static void print_gpgconf_string (const char *cname, const char *name) { gpg_error_t err; @@ -65,9 +115,8 @@ print_gpgconf_string (const char *cname, const char *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); + if (opt->type == GPGME_CONF_ALIAS_LIST) + print_one_alias (value->value.string); } break; } |