diff options
author | Patrik Flykt <patrik.flykt@linux.intel.com> | 2013-03-27 13:53:52 +0200 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2013-04-04 10:23:45 +0300 |
commit | 497769cbdb3e1883a51ea237c46664a26d72b42f (patch) | |
tree | 5426d8da7a03c7ad8b29c7cda039e056f1bad4ef /client | |
parent | 484ea1d95f9ae2203386bd5e3838603f44f90a50 (diff) | |
download | connman-497769cbdb3e1883a51ea237c46664a26d72b42f.tar.gz connman-497769cbdb3e1883a51ea237c46664a26d72b42f.tar.bz2 connman-497769cbdb3e1883a51ea237c46664a26d72b42f.zip |
client: Handle exit and inprogress values
When exiting, return 1, when D-Bus method call is in progress return
-EINPROGRESS. When exiting successfully return 0, when an error is
encountered return the error value.
Diffstat (limited to 'client')
-rw-r--r-- | client/commands.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/client/commands.c b/client/commands.c index f4f332f0..6e124f9d 100644 --- a/client/commands.c +++ b/client/commands.c @@ -37,13 +37,15 @@ #include "services.h" #include "technology.h" #include "data_manager.h" -#include "interactive.h" +#include "commands.h" #include "dbus_helpers.h" #include "input.h" #define MANDATORY_ARGS 3 +static DBusConnection *connection; + static char *ipv4[] = { "Method", "Address", @@ -575,7 +577,7 @@ static int cmd_monitor(char *args[], int num, struct option *options) static int cmd_exit(char *args[], int num, struct option *options) { - return 0; + return 1; } static struct option service_options[] = { @@ -694,21 +696,24 @@ static int cmd_help(char *args[], int num, struct option *options) return 0; } -int commands(DBusConnection *connection, char *argv[], int argc) +int commands(DBusConnection *dbus_conn, char *argv[], int argc) { int i, result; + connection = dbus_conn; + for (i = 0; cmd_table[i].cmd != NULL; i++) { if (g_strcmp0(cmd_table[i].cmd, argv[0]) == 0 && cmd_table[i].func != NULL) { result = cmd_table[i].func(argv, argc, cmd_table[i].options); - if (result < 0) - printf("Error '%s': %s\n", argv[0], + if (result < 0 && result != -EINPROGRESS) + fprintf(stderr, "Error '%s': %s\n", argv[0], strerror(-result)); return result; } } - return -1; + fprintf(stderr, "Error '%s': Unknown command\n", argv[0]); + return -EINVAL; } |