/** \file server/commands/menu_commands.c * Implements handlers for client commands concerning menus. * * This contains definitions for all the functions which clients can run. * The functions here are to be called only from parse.c's interpreter. * * The client's available function set is defined here, as is the syntax * for each command. */ /* This file is part of LCDd, the lcdproc server. * * This file is released under the GNU General Public License. * Refer to the COPYING file distributed with this package. * * Copyright (c) 1999, William Ferrell, Selene Scriven * 2002, Joris Robijn * 2004, F5 Networks, Inc. - IP-address input * 2005, Peter Marschall - error checks, ... */ #include #include #include #include #include #include #include #include #include "shared/report.h" #include "shared/sockets.h" #include "client.h" #include "menuitem.h" #include "menu.h" #include "menuscreens.h" #include "menu_commands.h" /* Local functions */ MenuEventFunc(menu_commands_handler); int set_predecessor(MenuItem *item, char *itemid, Client *client); int set_successor(MenuItem *item, char *itemid, Client *client); /** small utility for debug output of command line. */ static char *argv2string(int argc, char **argv) { char *rtn = NULL; unsigned int len; unsigned int i; for (i = len = 0; i < argc; i++) len += strlen(argv[i]) + 1; rtn = malloc(len + 1); if (rtn != NULL) { rtn[0] = '\0'; for (i = 0; i < argc; i++) { strcat(rtn, argv[i]); strcat(rtn, " "); } } return rtn; } /** * Adds an item to a menu. * *\verbatim * Usage: menu_add_item [] {