[Pkg-gnupg-commit] [libassuan] 354/437: Let an existing command previously registered with assuan_register_command() be updated with new values. This fixes overriding the HELP command for example.
Eric Dorland
eric at moszumanska.debian.org
Fri May 22 05:34:03 UTC 2015
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to branch master
in repository libassuan.
commit 79bb873edd4696fc56a0aaf91c9d11c3791691c0
Author: bjk at luxsci.net <bjk at luxsci.net>
Date: Sat Mar 5 20:06:57 2011 -0500
Let an existing command previously registered with assuan_register_command() be updated with new values. This fixes overriding the HELP command for example.
---
src/ChangeLog | 5 +++++
src/assuan-handler.c | 21 ++++++++++++++++-----
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index a12b9cb..5568549 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2011-03-05 Ben Kibbey <bjk at luxsci.net>
+
+ * assuan-handler.c (assuan_register_command): Let an existing command
+ be updated to the new values.
+
2011-02-28 Werner Koch <wk at g10code.com>
* libassuan.vers: Fold LIBASSUAN_1.1 block into LIBASSUAN_1.0.
diff --git a/src/assuan-handler.c b/src/assuan-handler.c
index cb271fa..799d058 100644
--- a/src/assuan-handler.c
+++ b/src/assuan-handler.c
@@ -365,7 +365,7 @@ gpg_error_t
assuan_register_command (assuan_context_t ctx, const char *cmd_name,
assuan_handler_t handler, const char *help_string)
{
- int i;
+ int i, cmd_index = -1;
const char *s;
if (cmd_name && !*cmd_name)
@@ -409,10 +409,21 @@ assuan_register_command (assuan_context_t ctx, const char *cmd_name,
ctx->cmdtbl_size += 50;
}
- ctx->cmdtbl[ctx->cmdtbl_used].name = cmd_name;
- ctx->cmdtbl[ctx->cmdtbl_used].handler = handler;
- ctx->cmdtbl[ctx->cmdtbl_used].helpstr = help_string;
- ctx->cmdtbl_used++;
+ for (i=0; i<ctx->cmdtbl_used; i++)
+ {
+ if (!strcasecmp(ctx->cmdtbl[i].name, cmd_name))
+ {
+ cmd_index = i;
+ break;
+ }
+ }
+
+ if (cmd_index == -1)
+ cmd_index = ctx->cmdtbl_used++;
+
+ ctx->cmdtbl[cmd_index].name = cmd_name;
+ ctx->cmdtbl[cmd_index].handler = handler;
+ ctx->cmdtbl[cmd_index].helpstr = help_string;
return 0;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/libassuan.git
More information about the Pkg-gnupg-commit
mailing list