From c591ed2ec21fbd13b1fba7d5b941b19e40dcb7d1 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 20 Jun 2008 10:40:52 +0000 Subject: [PATCH] Updated the example. --- trunk/doc/examples/show-group-options.c | 55 +++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/trunk/doc/examples/show-group-options.c b/trunk/doc/examples/show-group-options.c index aee962d..92c3754 100644 --- a/trunk/doc/examples/show-group-options.c +++ b/trunk/doc/examples/show-group-options.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -40,6 +41,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) { @@ -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; } -- 2.26.2