File: command_list.c

package info (click to toggle)
lcdproc 0.5.7-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,012 kB
  • ctags: 6,532
  • sloc: ansic: 58,028; sh: 2,005; perl: 681; makefile: 482
file content (75 lines) | stat: -rw-r--r-- 2,297 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/** \file server/commands/command_list.c
 * Implements the dispatcher for handlers dealing with the client commands.
 *
 * This contains definitions for all the functions which clients can run.
 * The functions here are to be called only from parse.c's interpreter.
 */

/* 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
 *		 2003, Joris Robijn
 */

#include <stdlib.h>
#include <string.h>

#include "command_list.h"
#include "server_commands.h"
#include "client_commands.h"
#include "screen_commands.h"
#include "widget_commands.h"
#include "menu_commands.h"

static client_function commands[] = {
	{ "test_func",      test_func_func      },
	{ "hello",          hello_func          },
	{ "client_set",     client_set_func     },
	{ "client_add_key", client_add_key_func },
	{ "client_del_key", client_del_key_func },
/*	{ "screen_add_key", screen_add_key_func }, */
/*	{ "screen_del_key", screen_del_key_func }, */
	{ "screen_add",     screen_add_func     },
	{ "screen_del",     screen_del_func     },
	{ "screen_set",     screen_set_func     },
	{ "widget_add",     widget_add_func     },
	{ "widget_del",     widget_del_func     },
	{ "widget_set",     widget_set_func     },
	{ "menu_add_item",  menu_add_item_func  },
	{ "menu_del_item",  menu_del_item_func  },
	{ "menu_set_item",  menu_set_item_func  },
	{ "menu_goto",      menu_goto_func      },
	{ "menu_set_main",  menu_set_main_func  },
	/* Misc stuff...*/
	{ "backlight",      backlight_func      },
	{ "output",         output_func         },
	{ "noop",           noop_func           },
	{ "info",           info_func           },
	{ "sleep",          sleep_func          },
	{ "bye",            bye_func            },
	{ NULL,             NULL},
};

/**
 * Looks up a function for a command sent by the client.
 * \param cmd  Command to look up as string.
 * \return  Pointer to the implementing function.
 */
CommandFunc get_command_function(char *cmd)
{
	int i;

	if (cmd == NULL)
		return NULL;

	for (i = 0; commands[i].keyword != NULL; i++) {
		if (0 == strcmp(cmd, commands[i].keyword))
			return commands[i].function;
	}

	return NULL;
}