Updated the example.
This commit is contained in:
parent
5a19f6d421
commit
b0a5687a16
@ -20,6 +20,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
||||||
#include <gpgme.h>
|
#include <gpgme.h>
|
||||||
@ -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
|
static void
|
||||||
print_gpgconf_string (const char *cname, const char *name)
|
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)
|
for (value = opt->value; value; value = value->next)
|
||||||
{
|
{
|
||||||
if (opt->alt_type == GPGME_CONF_STRING)
|
if (opt->type == GPGME_CONF_ALIAS_LIST)
|
||||||
printf ("%s/%s -> `%s'\n",
|
print_one_alias (value->value.string);
|
||||||
cname,name, value->value.string);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user