aboutsummaryrefslogtreecommitdiffstats
path: root/dirmngr/server.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2011-02-09 16:48:00 +0000
committerWerner Koch <[email protected]>2011-02-09 17:20:05 +0000
commit1cdcab68924a58623c3ea75eb47544973f24420c (patch)
tree96b0e3e873e2510d6b958ed6d3c42e8c4f61d6d5 /dirmngr/server.c
parentSupport key fetching using HTTP. (diff)
downloadgnupg-1cdcab68924a58623c3ea75eb47544973f24420c.tar.gz
gnupg-1cdcab68924a58623c3ea75eb47544973f24420c.zip
Add framework to print keyserver engine information
Diffstat (limited to 'dirmngr/server.c')
-rw-r--r--dirmngr/server.c45
1 files changed, 41 insertions, 4 deletions
diff --git a/dirmngr/server.c b/dirmngr/server.c
index 403a13692..1a244c896 100644
--- a/dirmngr/server.c
+++ b/dirmngr/server.c
@@ -1359,7 +1359,7 @@ cmd_validate (assuan_context_t ctx, char *line)
static const char hlp_keyserver[] =
- "KEYSERVER [--clear] [<uri>]\n"
+ "KEYSERVER [--clear|--help] [<uri>]\n"
"\n"
"If called without arguments list all configured keyserver URLs.\n"
"If called with option \"--clear\" remove all configured keyservers\n"
@@ -1374,14 +1374,21 @@ cmd_keyserver (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
gpg_error_t err;
- int clear_flag, add_flag;
+ int clear_flag, add_flag, help_flag;
uri_item_t item = NULL; /* gcc 4.4.5 is not able to detect that it
is always initialized. */
clear_flag = has_option (line, "--clear");
+ help_flag = has_option (line, "--help");
line = skip_options (line);
add_flag = !!*line;
+ if (help_flag)
+ {
+ err = ks_action_help (ctrl, line);
+ goto leave;
+ }
+
if (add_flag)
{
item = xtrymalloc (sizeof *item + strlen (line));
@@ -1409,7 +1416,7 @@ cmd_keyserver (assuan_context_t ctx, char *line)
ctrl->keyservers = item;
}
- if (!add_flag && !clear_flag) /* List configured keyservers. */
+ if (!add_flag && !clear_flag && !help_flag) /* List configured keyservers. */
{
uri_item_t u;
@@ -1947,7 +1954,7 @@ start_command_handler (assuan_fd_t fd)
/* Send a status line back to the client. KEYWORD is the status
- keyword, the optioal string argumenst are blank separated added to
+ keyword, the optional string arguments are blank separated added to
the line, the last argument must be a NULL. */
gpg_error_t
dirmngr_status (ctrl_t ctrl, const char *keyword, ...)
@@ -1985,6 +1992,36 @@ dirmngr_status (ctrl_t ctrl, const char *keyword, ...)
}
+/* Print a help status line. TEXTLEN gives the length of the text
+ from TEXT to be printed. The function splits text at LFs. */
+gpg_error_t
+dirmngr_status_help (ctrl_t ctrl, const char *text)
+{
+ gpg_error_t err = 0;
+
+ if (ctrl->server_local)
+ {
+ assuan_context_t ctx = ctrl->server_local->assuan_ctx;
+ char buf[950], *p;
+ size_t n;
+
+ do
+ {
+ p = buf;
+ n = 0;
+ for ( ; *text && *text != '\n' && n < DIM (buf)-2; n++)
+ *p++ = *text++;
+ if (*text == '\n')
+ text++;
+ *p = 0;
+ err = assuan_write_status (ctx, "#", buf);
+ }
+ while (!err && *text);
+ }
+
+ return err;
+}
+
/* Send a tick progress indicator back. Fixme: This is only does for
the currently active channel. */
gpg_error_t