From 6a07479b9eac213c707e04cdf090f1fdb14e16a0 Mon Sep 17 00:00:00 2001 From: Patrik Flykt Date: Tue, 12 Feb 2013 13:55:34 +0200 Subject: client: Create prototypes for all commands Provide the infrastructure to factor out the commands. --- client/commands.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) (limited to 'client/commands.c') diff --git a/client/commands.c b/client/commands.c index 75856cd2..cbc440fc 100644 --- a/client/commands.c +++ b/client/commands.c @@ -64,6 +64,8 @@ static char *proxy_simple[] = { NULL }; +static int cmd_help(char *args[], int num, struct option *options); + void show_help(void) { printf("Usage: connmanctl [args]\n" @@ -278,6 +280,118 @@ int monitor_switch(int argc, char *argv[], int c, DBusConnection *conn) return 0; } +static int cmd_enable(char *args[], int num, struct option *options) +{ + return -1; +} + +static int cmd_disable(char *args[], int num, struct option *options) +{ + return -1; +} + +static int cmd_state(char *args[], int num, struct option *options) +{ + return -1; +} + +static int cmd_services(char *args[], int num, struct option *options) +{ + return -1; +} + +static int cmd_technologies(char *args[], int num, struct option *options) +{ + return -1; +} + +static int cmd_scan(char *args[], int num, struct option *options) +{ + return -1; +} + +static int cmd_connect(char *args[], int num, struct option *options) +{ + return -1; +} + +static int cmd_disconnect(char *args[], int num, struct option *options) +{ + return -1; +} + +static int cmd_config(char *args[], int num, struct option *options) +{ + return -1; +} + +static int cmd_monitor(char *args[], int num, struct option *options) +{ + return -1; +} + +static int cmd_exit(char *args[], int num, struct option *options) +{ + return 0; +} + +static const struct { + const char *cmd; + const char *argument; + struct option *options; + const char **options_desc; + int (*func) (char *args[], int num, struct option *options); + const char *desc; +} cmd_table[] = { + { "enable", "|offline", NULL, NULL, + cmd_enable, "Enables given technology or offline mode" }, + { "disable", "|offline", NULL, NULL, + cmd_disable, "Disables given technology or offline mode"}, + { "state", NULL, NULL, NULL, + cmd_state, "Shows if the system is online or offline" }, + { "services", NULL, NULL, NULL, + cmd_services, "Display services" }, + { "technologies", NULL, NULL, NULL, + cmd_technologies, "Display technologies" }, + { "scan", "", NULL, NULL, + cmd_scan, "Scans for new services for given technology" }, + { "connect", "", NULL, NULL, + cmd_connect, "Connect a given service" }, + { "disconnect", "", NULL, NULL, + cmd_disconnect, "Disconnect a given service" }, + { "config", "", NULL, NULL, + cmd_config, "Set service configuration options" }, + { "monitor", NULL, NULL, NULL, + cmd_monitor, "Monitor signals from interfaces" }, + { "help", NULL, NULL, NULL, + cmd_help, "Show help" }, + { "exit", NULL, NULL, NULL, + cmd_exit, "Exit" }, + { "quit", NULL, NULL, NULL, + cmd_exit, "Quit" }, + { NULL, }, +}; + +static int cmd_help(char *args[], int num, struct option *options) +{ + return -1; +} + +int commands(DBusConnection *connection, char *argv[], int argc) +{ + int i; + + for (i = 0; cmd_table[i].cmd != NULL; i++) { + if (g_strcmp0(cmd_table[i].cmd, argv[0]) == 0 && + cmd_table[i].func != NULL) { + return cmd_table[i].func(argv, argc, + cmd_table[i].options); + } + } + + return -1; +} + int commands_no_options(DBusConnection *connection, char *argv[], int argc) { DBusMessage *message = NULL; -- cgit v1.2.3