From e3feb067a503b53da253e4ed877d212d6d73842c Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Sun, 11 Jan 2009 00:48:42 +0000 Subject: Server locking. set-password and lock-server commands, plus automatic locking. --- cmd-command-prompt.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'cmd-command-prompt.c') diff --git a/cmd-command-prompt.c b/cmd-command-prompt.c index 752ec7e8..0bf3c084 100644 --- a/cmd-command-prompt.c +++ b/cmd-command-prompt.c @@ -1,4 +1,4 @@ -/* $Id: cmd-command-prompt.c,v 1.6 2008-09-26 06:45:25 nicm Exp $ */ +/* $Id: cmd-command-prompt.c,v 1.7 2009-01-11 00:48:42 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -28,7 +28,7 @@ void cmd_command_prompt_exec(struct cmd *, struct cmd_ctx *); -void cmd_command_prompt_callback(void *, char *); +int cmd_command_prompt_callback(void *, const char *); const struct cmd_entry cmd_command_prompt_entry = { "command-prompt", NULL, @@ -55,14 +55,14 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx) if (c->prompt_string != NULL) return; - server_set_client_prompt(c, ":", cmd_command_prompt_callback, c); + server_set_client_prompt(c, ":", cmd_command_prompt_callback, c, 0); if (ctx->cmdclient != NULL) server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0); } -void -cmd_command_prompt_callback(void *data, char *s) +int +cmd_command_prompt_callback(void *data, const char *s) { struct client *c = data; struct cmd *cmd; @@ -70,18 +70,18 @@ cmd_command_prompt_callback(void *data, char *s) char *cause; if (s == NULL) - return; + return (0); if (cmd_string_parse(s, &cmd, &cause) != 0) { if (cause == NULL) - return; + return (0); *cause = toupper((u_char) *cause); server_set_client_message(c, cause); xfree(cause); - return; + return (0); } if (cmd == NULL) - return; + return (0); ctx.msgdata = NULL; ctx.cursession = c->session; @@ -94,4 +94,8 @@ cmd_command_prompt_callback(void *data, char *s) ctx.cmdclient = NULL; cmd_exec(cmd, &ctx); + + if (c->prompt_callback != (void *) &cmd_command_prompt_callback) + return (1); + return (0); } -- cgit