summaryrefslogtreecommitdiffstats
path: root/g10/cpr.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2015-08-25 09:03:31 +0200
committerWerner Koch <wk@gnupg.org>2015-08-25 15:26:33 +0200
commit9cdff09743c473a12359bfdb914578ede0e4e3e2 (patch)
treeecad07063ec0abab01e9e29eca601d7ee33ef5ee /g10/cpr.c
parentagent: Raise the maximum password length. Don't hard code it. (diff)
downloadgnupg2-9cdff09743c473a12359bfdb914578ede0e4e3e2.tar.xz
gnupg2-9cdff09743c473a12359bfdb914578ede0e4e3e2.zip
gpg: Print a new FAILURE status after most commands.
* common/status.h (STATUS_FAILURE): New. * g10/cpr.c (write_status_failure): New. * g10/gpg.c (main): Call write_status_failure for all commands which print an error message here. * g10/call-agent.c (start_agent): Print an STATUS_ERROR if we can't set the pinentry mode. -- This status line can be used similar to the error code returned by commands send over the Assuan interface in gpgsm. We don't emit them in gpgsm because there we already have that Assuan interface to return proper error code. This change helps GPGME to return better error codes. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'g10/cpr.c')
-rw-r--r--g10/cpr.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/g10/cpr.c b/g10/cpr.c
index 9fc9e0995..9d8fec994 100644
--- a/g10/cpr.c
+++ b/g10/cpr.c
@@ -183,7 +183,7 @@ write_status_text (int no, const char *text)
write_status_strings (no, text, NULL);
}
-/* Wrte an ERROR status line using a full gpg-error error value. */
+/* Write an ERROR status line using a full gpg-error error value. */
void
write_status_error (const char *where, gpg_error_t err)
{
@@ -211,6 +211,20 @@ write_status_errcode (const char *where, int errcode)
}
+/* Write a FAILURE status line. */
+void
+write_status_failure (const char *where, gpg_error_t err)
+{
+ if (!statusfp || !status_currently_allowed (STATUS_FAILURE))
+ return; /* Not enabled or allowed. */
+
+ es_fprintf (statusfp, "[GNUPG:] %s %s %u\n",
+ get_status_string (STATUS_FAILURE), where, err);
+ if (es_fflush (statusfp) && opt.exit_on_status_write_error)
+ g10_exit (0);
+}
+
+
/*
* Write a status line with a buffer using %XX escapes. If WRAP is >
* 0 wrap the line after this length. If STRING is not NULL it will