diff options
author | Patrik Flykt <patrik.flykt@linux.intel.com> | 2013-02-12 13:55:34 +0200 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2013-02-21 16:22:18 +0200 |
commit | 6a07479b9eac213c707e04cdf090f1fdb14e16a0 (patch) | |
tree | 2c6d7583148ad047c511d205e7080b8bb9f0d857 /client/commands.c | |
parent | 56687906c9ac83c0480175b0354f7582a03a685d (diff) | |
download | connman-6a07479b9eac213c707e04cdf090f1fdb14e16a0.tar.gz connman-6a07479b9eac213c707e04cdf090f1fdb14e16a0.tar.bz2 connman-6a07479b9eac213c707e04cdf090f1fdb14e16a0.zip |
client: Create prototypes for all commands
Provide the infrastructure to factor out the commands.
Diffstat (limited to 'client/commands.c')
-rw-r--r-- | client/commands.c | 114 |
1 files changed, 114 insertions, 0 deletions
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 <command> [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", "<technology>|offline", NULL, NULL, + cmd_enable, "Enables given technology or offline mode" }, + { "disable", "<technology>|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", "<technology>", NULL, NULL, + cmd_scan, "Scans for new services for given technology" }, + { "connect", "<service>", NULL, NULL, + cmd_connect, "Connect a given service" }, + { "disconnect", "<service>", NULL, NULL, + cmd_disconnect, "Disconnect a given service" }, + { "config", "<service>", 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; |