summaryrefslogtreecommitdiffstats
path: root/cli/src/registry.c
diff options
context:
space:
mode:
authorKaushik BV <kaushikbv@gluster.com>2011-04-21 06:55:44 +0000
committerAnand Avati <avati@gluster.com>2011-04-22 03:52:24 -0700
commit49603aec03e98a2a38fad66627593b69b6269cbf (patch)
treec779d7f8be2e4477d057f17d49713fdb007639f6 /cli/src/registry.c
parentb5848ed21b9e718011a8f3f3870c4ed978ff17a5 (diff)
cli: changes in struct cli_cmd to disable gluster command at run-time
Signed-off-by: Kaushik BV <kaushikbv@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2744 (make geo-replication package friendly) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2744
Diffstat (limited to 'cli/src/registry.c')
-rw-r--r--cli/src/registry.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/cli/src/registry.c b/cli/src/registry.c
index a65e26ecaee..8fa116a48c7 100644
--- a/cli/src/registry.c
+++ b/cli/src/registry.c
@@ -362,31 +362,40 @@ cli_cmd_ingest (struct cli_cmd_tree *tree, char **tokens, cli_cmd_cbk_t *cbkfn,
int
-cli_cmd_register (struct cli_cmd_tree *tree, const char *template,
- cli_cmd_cbk_t cbk, const char *desc)
+cli_cmd_register (struct cli_cmd_tree *tree, struct cli_cmd *cmd)
{
char **tokens = NULL;
int ret = 0;
- if (!template)
- return -1;
+ GF_ASSERT (cmd)
- tokens = cli_cmd_tokenize (template);
- if (!tokens)
- return -1;
+ if (cmd->reg_cbk)
+ cmd->reg_cbk (cmd);
- ret = cli_cmd_ingest (tree, tokens, cbk, desc, template);
- if (ret)
- goto err;
+ if (cmd->disable) {
+ ret = 0;
+ goto out;
+ }
- if (tokens)
- cli_cmd_tokens_destroy (tokens);
+ tokens = cli_cmd_tokenize (cmd->pattern);
+ if (!tokens) {
+ ret = -1;
+ goto out;
+ }
- return 0;
-err:
+ ret = cli_cmd_ingest (tree, tokens, cmd->cbk, cmd->desc, cmd->pattern);
+ if (ret) {
+ ret = -1;
+ goto out;
+ }
+
+ ret = 0;
+
+out:
if (tokens)
cli_cmd_tokens_destroy (tokens);
+ gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}