[svn] assuan - r313 - in trunk: . src
svn author marcus
cvs at cvs.gnupg.org
Mon Nov 2 18:33:53 CET 2009
Author: marcus
Date: 2009-11-02 18:33:53 +0100 (Mon, 02 Nov 2009)
New Revision: 313
Modified:
trunk/NEWS
trunk/src/ChangeLog
trunk/src/assuan-defs.h
trunk/src/assuan-handler.c
trunk/src/assuan.h
Log:
2009-11-02 Marcus Brinkmann <marcus at g10code.de>
* assuan.h (assuan_handler_t): New type.
(assuan_register_bye_notify, assuan_register_reset_notify)
(assuan_register_cancel_notify, assuan_register_input_notify)
(assuan_register_output_notify, assuan_register_command): Use it.
* assuan-handler.c (std_handler_cancel, std_handler_bye): Pass
LINE argument to user handler.
(std_handler_reset): Likewise, and also abort RESET if error is
returned from user handler.
(std_handler_input, std_handler_output): Check return value from
user handler before assigning FD.
* assuan-defs.h (struct cmdtbl_s): Change type of member HANDLER
to assuan_handler_t.
(struct assuan_context_s): Change type of members
RESET_NOTIFY_FNC, CANCEL_NOTIFY_FNC, BYE_NOTIFY_FNC,
INPUT_NOTIFY_FNC and OUTPUT_NOTIFY_FNC to assuan_handler_t.
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2009-10-30 14:13:22 UTC (rev 312)
+++ trunk/src/ChangeLog 2009-11-02 17:33:53 UTC (rev 313)
@@ -1,3 +1,21 @@
+2009-11-02 Marcus Brinkmann <marcus at g10code.de>
+
+ * assuan.h (assuan_handler_t): New type.
+ (assuan_register_bye_notify, assuan_register_reset_notify)
+ (assuan_register_cancel_notify, assuan_register_input_notify)
+ (assuan_register_output_notify, assuan_register_command): Use it.
+ * assuan-handler.c (std_handler_cancel, std_handler_bye): Pass
+ LINE argument to user handler.
+ (std_handler_reset): Likewise, and also abort RESET if error is
+ returned from user handler.
+ (std_handler_input, std_handler_output): Check return value from
+ user handler before assigning FD.
+ * assuan-defs.h (struct cmdtbl_s): Change type of member HANDLER
+ to assuan_handler_t.
+ (struct assuan_context_s): Change type of members
+ RESET_NOTIFY_FNC, CANCEL_NOTIFY_FNC, BYE_NOTIFY_FNC,
+ INPUT_NOTIFY_FNC and OUTPUT_NOTIFY_FNC to assuan_handler_t.
+
2009-10-30 Marcus Brinkmann <marcus at g10code.de>
* system.c (_assuan_spawn): Check fd_child_list before dumping it.
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2009-10-30 14:13:22 UTC (rev 312)
+++ trunk/NEWS 2009-11-02 17:33:53 UTC (rev 313)
@@ -67,6 +67,12 @@
ASSUAN_SYSTEM_PTH NEW
assuan_sock_init NEW
assuan_sock_deinit NEW
+assuan_handler_t NEW
+assuan_register_bye_notify CHANGED: Handler gets line and returns err now.
+assuan_register_reset_notify CHANGED: Handler gets line and returns err now.
+assuan_register_cancel_notify CHANGED: Handler gets line and returns err now.
+assuan_register_input_notify CHANGED: Handler returns error now.
+assuan_register_output_notify CHANGED: Handler returns error now.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Modified: trunk/src/assuan-defs.h
===================================================================
--- trunk/src/assuan-defs.h 2009-10-30 14:13:22 UTC (rev 312)
+++ trunk/src/assuan-defs.h 2009-11-02 17:33:53 UTC (rev 313)
@@ -52,7 +52,7 @@
struct cmdtbl_s
{
const char *name;
- gpg_error_t (*handler)(assuan_context_t, char *line);
+ assuan_handler_t handler;
};
@@ -206,12 +206,12 @@
handler. */
const char *current_cmd_name;
- void (*bye_notify_fnc)(assuan_context_t);
- void (*reset_notify_fnc)(assuan_context_t);
- void (*cancel_notify_fnc)(assuan_context_t);
+ assuan_handler_t bye_notify_fnc;
+ assuan_handler_t reset_notify_fnc;
+ assuan_handler_t cancel_notify_fnc;
gpg_error_t (*option_handler_fnc)(assuan_context_t,const char*, const char*);
- void (*input_notify_fnc)(assuan_context_t, const char *);
- void (*output_notify_fnc)(assuan_context_t, const char *);
+ assuan_handler_t input_notify_fnc;
+ assuan_handler_t output_notify_fnc;
/* This function is called right after a command has been processed.
It may be used to command related cleanup. */
Modified: trunk/src/assuan-handler.c
===================================================================
--- trunk/src/assuan-handler.c 2009-10-30 14:13:22 UTC (rev 312)
+++ trunk/src/assuan-handler.c 2009-11-02 17:33:53 UTC (rev 313)
@@ -58,7 +58,8 @@
std_handler_cancel (assuan_context_t ctx, char *line)
{
if (ctx->cancel_notify_fnc)
- ctx->cancel_notify_fnc (ctx);
+ /* Return value ignored. */
+ ctx->cancel_notify_fnc (ctx, line);
return PROCESS_DONE (ctx, set_error (ctx, GPG_ERR_NOT_IMPLEMENTED, NULL));
}
@@ -119,7 +120,8 @@
std_handler_bye (assuan_context_t ctx, char *line)
{
if (ctx->bye_notify_fnc)
- ctx->bye_notify_fnc (ctx);
+ /* Return value ignored. */
+ ctx->bye_notify_fnc (ctx, line);
assuan_close_input_fd (ctx);
assuan_close_output_fd (ctx);
/* pretty simple :-) */
@@ -135,12 +137,17 @@
static gpg_error_t
std_handler_reset (assuan_context_t ctx, char *line)
{
+ gpg_error_t err = 0;
+
if (ctx->reset_notify_fnc)
- ctx->reset_notify_fnc (ctx);
- assuan_close_input_fd (ctx);
- assuan_close_output_fd (ctx);
- _assuan_uds_close_fds (ctx);
- return PROCESS_DONE (ctx, 0);
+ err = ctx->reset_notify_fnc (ctx, line);
+ if (! err)
+ {
+ assuan_close_input_fd (ctx);
+ assuan_close_output_fd (ctx);
+ _assuan_uds_close_fds (ctx);
+ }
+ return PROCESS_DONE (ctx, err);
}
static gpg_error_t
@@ -213,10 +220,11 @@
rc = assuan_command_parse_fd (ctx, line, &fd);
if (rc)
return PROCESS_DONE (ctx, rc);
- ctx->input_fd = fd;
if (ctx->input_notify_fnc)
- ctx->input_notify_fnc (ctx, line);
- return PROCESS_DONE (ctx, 0);
+ rc = ctx->input_notify_fnc (ctx, line);
+ if (! rc)
+ ctx->input_fd = fd;
+ return PROCESS_DONE (ctx, rc);
}
@@ -230,10 +238,11 @@
rc = assuan_command_parse_fd (ctx, line, &fd);
if (rc)
return PROCESS_DONE (ctx, rc);
- ctx->output_fd = fd;
if (ctx->output_notify_fnc)
- ctx->output_notify_fnc (ctx, line);
- return PROCESS_DONE (ctx, 0);
+ rc = ctx->output_notify_fnc (ctx, line);
+ if (!rc)
+ ctx->output_fd = fd;
+ return PROCESS_DONE (ctx, rc);
}
@@ -274,9 +283,8 @@
* Return value: 0 on success or an error code
**/
gpg_error_t
-assuan_register_command (assuan_context_t ctx,
- const char *cmd_name,
- gpg_error_t (*handler)(assuan_context_t, char *))
+assuan_register_command (assuan_context_t ctx, const char *cmd_name,
+ assuan_handler_t handler)
{
int i;
const char *s;
@@ -349,8 +357,7 @@
}
gpg_error_t
-assuan_register_bye_notify (assuan_context_t ctx,
- void (*fnc)(assuan_context_t))
+assuan_register_bye_notify (assuan_context_t ctx, assuan_handler_t fnc)
{
if (!ctx)
return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE);
@@ -359,8 +366,7 @@
}
gpg_error_t
-assuan_register_reset_notify (assuan_context_t ctx,
- void (*fnc)(assuan_context_t))
+assuan_register_reset_notify (assuan_context_t ctx, assuan_handler_t fnc)
{
if (!ctx)
return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE);
@@ -369,8 +375,7 @@
}
gpg_error_t
-assuan_register_cancel_notify (assuan_context_t ctx,
- void (*fnc)(assuan_context_t))
+assuan_register_cancel_notify (assuan_context_t ctx, assuan_handler_t fnc)
{
if (!ctx)
return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE);
@@ -390,8 +395,7 @@
}
gpg_error_t
-assuan_register_input_notify (assuan_context_t ctx,
- void (*fnc)(assuan_context_t, const char *))
+assuan_register_input_notify (assuan_context_t ctx, assuan_handler_t fnc)
{
if (!ctx)
return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE);
@@ -400,8 +404,7 @@
}
gpg_error_t
-assuan_register_output_notify (assuan_context_t ctx,
- void (*fnc)(assuan_context_t, const char *))
+assuan_register_output_notify (assuan_context_t ctx, assuan_handler_t fnc)
{
if (!ctx)
return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE);
Modified: trunk/src/assuan.h
===================================================================
--- trunk/src/assuan.h 2009-10-30 14:13:22 UTC (rev 312)
+++ trunk/src/assuan.h 2009-11-02 17:33:53 UTC (rev 313)
@@ -300,22 +300,24 @@
void assuan_set_log_stream (assuan_context_t ctx, FILE *fp);
+typedef gpg_error_t (*assuan_handler_t) (assuan_context_t, char *);
+
/*-- assuan-handler.c --*/
gpg_error_t assuan_register_command (assuan_context_t ctx,
const char *cmd_string,
- gpg_error_t (*handler)(assuan_context_t, char *));
+ assuan_handler_t handler);
gpg_error_t assuan_register_post_cmd_notify (assuan_context_t ctx,
void (*fnc)(assuan_context_t, gpg_error_t));
gpg_error_t assuan_register_bye_notify (assuan_context_t ctx,
- void (*fnc)(assuan_context_t));
+ assuan_handler_t handler);
gpg_error_t assuan_register_reset_notify (assuan_context_t ctx,
- void (*fnc)(assuan_context_t));
+ assuan_handler_t handler);
gpg_error_t assuan_register_cancel_notify (assuan_context_t ctx,
- void (*fnc)(assuan_context_t));
+ assuan_handler_t handler);
gpg_error_t assuan_register_input_notify (assuan_context_t ctx,
- void (*fnc)(assuan_context_t, const char *));
+ assuan_handler_t handler);
gpg_error_t assuan_register_output_notify (assuan_context_t ctx,
- void (*fnc)(assuan_context_t, const char *));
+ assuan_handler_t handler);
gpg_error_t assuan_register_option_handler (assuan_context_t ctx,
gpg_error_t (*fnc)(assuan_context_t,
More information about the Gnupg-commits
mailing list