diff --git a/server/commands/client_commands.c b/server/commands/client_commands.c index 2af9181..b766b67 100644 --- a/server/commands/client_commands.c +++ b/server/commands/client_commands.c @@ -56,7 +56,7 @@ test_func_func (Client * c, int argc, char **argv) * * It returns a string of info about the server to the client * - * usage: hello + * Usage: hello */ int hello_func (Client * c, int argc, char **argv) @@ -72,13 +72,10 @@ hello_func (Client * c, int argc, char **argv) debug(RPT_INFO, "Hello!"); memset(str, '\0', sizeof(str)); - snprintf (str, sizeof(str), "connect LCDproc %s protocol %s lcd wid %i hgt %i cellwid %i cellhgt %i\n", - VERSION, PROTOCOL_VERSION, display_props->width, display_props->height, display_props->cellwidth, display_props->cellheight); - -/* lcdproc (client) depends on the above format... - * snprintf (str, sizeof(str), "connect LCDproc %s protocol %s LCD %ix%i with cells %ix%i\n", - * version, protocol_version, lcd.wid, lcd.hgt, lcd.cellwid, lcd.cellhgt); - */ + snprintf(str, sizeof(str), "connect LCDproc %s protocol %s lcd wid %i hgt %i cellwid %i cellhgt %i\n", + VERSION, PROTOCOL_VERSION, + display_props->width, display_props->height, + display_props->cellwidth, display_props->cellheight); sock_send_string (c->sock, str); @@ -87,10 +84,28 @@ hello_func (Client * c, int argc, char **argv) return 0; } +/***************************************************************************** + * The client should say "bye" before disconnecting + * + * The function does not respond to the client: it simply cuts connection + * + * Usage: bye + */ +int +bye_func (Client * c, int argc, char **argv) +{ + if (c != NULL) { + debug(RPT_INFO, "Bye, %s!", (c->name != NULL) ? c->name : "unknown client"); + + sock_send_error(c->sock, "\"bye\" is currently ignored\n"); + } + return 0; +} + /*************************************************** * sets info about the client, such as its name * - * usage: client_set -name + * Usage: client_set -name */ int client_set_func (Client * c, int argc, char **argv) @@ -103,17 +118,7 @@ client_set_func (Client * c, int argc, char **argv) return 1; if (argc != 3) { - switch (argc) { - case 1: - sock_send_error(c->sock, "usage: client_set -name \n"); - break; - case 2: - sock_send_error(c->sock, "Not enough parameters\n"); - break; - default: - sock_send_error(c->sock, "Too many parameters\n"); - break; - } + sock_send_error(c->sock, "Usage: client_set -name \n"); return 0; } @@ -164,7 +169,7 @@ client_set_func (Client * c, int argc, char **argv) * Tells the server the client would like to accept keypresses * of a particular type * - * usage: client_add_key [-exclusively|-shared] {}+ + * Usage: client_add_key [-exclusively|-shared] {}+ */ #define BUFLEN 80 int @@ -177,11 +182,7 @@ client_add_key_func (Client * c, int argc, char **argv) return 1; if (argc < 2) { - switch (argc) { - case 1: - sock_send_error(c->sock, "Usage: client_add_key [-exclusively|-shared] {}+\n"); - break; - } + sock_send_error(c->sock, "Usage: client_add_key [-exclusively|-shared] {}+\n"); return 0; } @@ -212,7 +213,7 @@ client_add_key_func (Client * c, int argc, char **argv) * Tells the server the client would NOT like to accept keypresses * of a particular type * - * usage: client_del_key {}+ + * Usage: client_del_key {}+ */ int client_del_key_func (Client * c, int argc, char **argv) @@ -238,7 +239,7 @@ client_del_key_func (Client * c, int argc, char **argv) /*************************************************************************** * Toggles the backlight, if enabled. * - * usage: backlight + * Usage: backlight {on|off|toggle|blink|flash} */ int backlight_func (Client * c, int argc, char **argv) @@ -247,14 +248,7 @@ backlight_func (Client * c, int argc, char **argv) return 1; if (argc != 2) { - switch (argc) { - case 1: - sock_send_error(c->sock, "usage: backlight \n"); - break; - default: - sock_send_error(c->sock, "Too many parameters...\n"); - break; - } + sock_send_error(c->sock, "Usage: backlight {on|off|toggle|blink|flash}\n"); return 0; } @@ -291,7 +285,7 @@ backlight_func (Client * c, int argc, char **argv) /**************************************************************************** * info_func * - * usage: info + * Usage: info */ int info_func (Client * c, int argc, char **argv) diff --git a/server/commands/client_commands.h b/server/commands/client_commands.h index 03abcce..dd8d742 100644 --- a/server/commands/client_commands.h +++ b/server/commands/client_commands.h @@ -14,6 +14,7 @@ #define COMMANDS_CLIENT_H int hello_func (Client * c, int argc, char **argv); +int bye_func (Client * c, int argc, char **argv); int client_set_func (Client * c, int argc, char **argv); int client_add_key_func (Client * c, int argc, char **argv); int client_del_key_func (Client * c, int argc, char **argv); diff --git a/server/commands/command_list.c b/server/commands/command_list.c index 3f5e9f0..1d3f97e 100644 --- a/server/commands/command_list.c +++ b/server/commands/command_list.c @@ -52,6 +52,7 @@ static client_function commands[] = { { "noop", noop_func }, { "info", info_func }, { "sleep", sleep_func }, + { "bye", bye_func }, { NULL, NULL}, }; diff --git a/server/commands/menu_commands.c b/server/commands/menu_commands.c index ec9ef6d..ed390c9 100644 --- a/server/commands/menu_commands.c +++ b/server/commands/menu_commands.c @@ -242,7 +242,7 @@ menu_del_item_func (Client * c, int argc, char **argv) if (!c->ack) return 1; - if ((argc < 3 )) { + if (argc != 3 ) { sock_send_error(c->sock, "Usage: menu_del_item \n"); return 0; } @@ -451,7 +451,7 @@ menu_set_item_func (Client * c, int argc, char **argv) if (!c->ack) return 1; - if ((argc < 4 )) { + if (argc < 4 ) { sock_send_error(c->sock, "Usage: menu_set_item {