diff --git a/assuan/ChangeLog b/assuan/ChangeLog index e5145063a..6f7f59e4d 100644 --- a/assuan/ChangeLog +++ b/assuan/ChangeLog @@ -1,3 +1,10 @@ +2001-11-25 Werner Koch + + * assuan-handler.c (assuan_register_bye_notify) + (assuan_register_reset_notify) + (assuan_register_cancel_notify): New and call them from the + standard handlers. + 2001-11-24 Werner Koch * assuan-connect.c (assuan_get_pid): New. diff --git a/assuan/assuan-defs.h b/assuan/assuan-defs.h index 05e548cb6..2bbc9b8ac 100644 --- a/assuan/assuan-defs.h +++ b/assuan/assuan-defs.h @@ -69,6 +69,10 @@ struct assuan_context_s { size_t cmdtbl_used; /* used entries */ size_t cmdtbl_size; /* allocated size of table */ + void (*bye_notify_fnc)(ASSUAN_CONTEXT); + void (*cancel_notify_fnc)(ASSUAN_CONTEXT); + void (*reset_notify_fnc)(ASSUAN_CONTEXT); + int input_fd; /* set by INPUT command */ int output_fd; /* set by OUTPUT command */ diff --git a/assuan/assuan-handler.c b/assuan/assuan-handler.c index 472206b05..d4de8526b 100644 --- a/assuan/assuan-handler.c +++ b/assuan/assuan-handler.c @@ -44,12 +44,16 @@ std_handler_nop (ASSUAN_CONTEXT ctx, char *line) static int std_handler_cancel (ASSUAN_CONTEXT ctx, char *line) { + if (ctx->cancel_notify_fnc) + ctx->cancel_notify_fnc (ctx); return set_error (ctx, Not_Implemented, NULL); } static int std_handler_bye (ASSUAN_CONTEXT ctx, char *line) { + if (ctx->bye_notify_fnc) + ctx->bye_notify_fnc (ctx); return -1; /* pretty simple :-) */ } @@ -62,7 +66,9 @@ std_handler_auth (ASSUAN_CONTEXT ctx, char *line) static int std_handler_reset (ASSUAN_CONTEXT ctx, char *line) { - return set_error (ctx, Not_Implemented, NULL); + if (ctx->reset_notify_fnc) + ctx->reset_notify_fnc (ctx); + return 0; } static int @@ -128,7 +134,7 @@ static struct { const char *name; int cmd_id; int (*handler)(ASSUAN_CONTEXT, char *line); - int always; /* always initializethis command */ + int always; /* always initialize this command */ } std_cmd_table[] = { { "NOP", ASSUAN_CMD_NOP, std_handler_nop, 1 }, { "CANCEL", ASSUAN_CMD_CANCEL, std_handler_cancel, 1 }, @@ -220,6 +226,34 @@ assuan_register_command (ASSUAN_CONTEXT ctx, return 0; } +int +assuan_register_bye_notify (ASSUAN_CONTEXT ctx, void (*fnc)(ASSUAN_CONTEXT)) +{ + if (!ctx) + return ASSUAN_Invalid_Value; + ctx->bye_notify_fnc = fnc; + return 0; +} + +int +assuan_register_reset_notify (ASSUAN_CONTEXT ctx, void (*fnc)(ASSUAN_CONTEXT)) +{ + if (!ctx) + return ASSUAN_Invalid_Value; + ctx->reset_notify_fnc = fnc; + return 0; +} + +int +assuan_register_cancel_notify (ASSUAN_CONTEXT ctx, void (*fnc)(ASSUAN_CONTEXT)) +{ + if (!ctx) + return ASSUAN_Invalid_Value; + ctx->cancel_notify_fnc = fnc; + return 0; +} + + /* Helper to register the standards commands */ int _assuan_register_std_commands (ASSUAN_CONTEXT ctx) diff --git a/assuan/assuan.h b/assuan/assuan.h index a5ae8ae06..a858dc7e5 100644 --- a/assuan/assuan.h +++ b/assuan/assuan.h @@ -39,6 +39,7 @@ typedef enum { ASSUAN_Timeout = 4, ASSUAN_Read_Error = 5, ASSUAN_Write_Error = 6, + ASSUAN_Problem_Starting_Server = 7, /* error codes above 99 are meant as status codes */ ASSUAN_Not_Implemented = 100, @@ -53,6 +54,7 @@ typedef enum { ASSUAN_No_Input = 109, ASSUAN_No_Output = 110, ASSUAN_Canceled = 111, + ASSUAN_Unsupported_Algorithm = 112, ASSUAN_Cert_Revoked = 301, ASSUAN_No_CRL_For_Cert = 302, @@ -83,6 +85,12 @@ typedef struct assuan_context_s *ASSUAN_CONTEXT; int assuan_register_command (ASSUAN_CONTEXT ctx, int cmd_id, const char *cmd_string, int (*handler)(ASSUAN_CONTEXT, char *)); +int assuan_register_bye_notify (ASSUAN_CONTEXT ctx, + void (*fnc)(ASSUAN_CONTEXT)); +int assuan_register_reset_notify (ASSUAN_CONTEXT ctx, + void (*fnc)(ASSUAN_CONTEXT)); +int assuan_register_cancel_notify (ASSUAN_CONTEXT ctx, + void (*fnc)(ASSUAN_CONTEXT)); int assuan_process (ASSUAN_CONTEXT ctx); FILE *assuan_get_data_fp (ASSUAN_CONTEXT ctx); void assuan_write_status (ASSUAN_CONTEXT ctx,