summaryrefslogtreecommitdiff
path: root/client/commands.c
diff options
context:
space:
mode:
authorPatrik Flykt <patrik.flykt@linux.intel.com>2013-02-19 22:00:08 +0200
committerPatrik Flykt <patrik.flykt@linux.intel.com>2013-02-21 16:23:02 +0200
commit820cab40ae4203fc590de66a2666bffb82614136 (patch)
tree06d99d6086a1568187dc0c121159c7951d4e907d /client/commands.c
parent8e9d752f92e7320f5e36536efe367d26dc00cbdb (diff)
downloadconnman-820cab40ae4203fc590de66a2666bffb82614136.tar.gz
connman-820cab40ae4203fc590de66a2666bffb82614136.tar.bz2
connman-820cab40ae4203fc590de66a2666bffb82614136.zip
client: Factor out disconnect command
Diffstat (limited to 'client/commands.c')
-rw-r--r--client/commands.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/client/commands.c b/client/commands.c
index 20a05071..758c0faa 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -224,7 +224,19 @@ static int cmd_connect(char *args[], int num, struct option *options)
static int cmd_disconnect(char *args[], int num, struct option *options)
{
- return -1;
+ int err;
+
+ if (num > 2)
+ return -E2BIG;
+
+ if (num < 2)
+ return -EINVAL;
+
+ err = disconnect_service(connection, args[1]);
+ if (err == 0)
+ printf("Disconnected\n");
+
+ return 0;
}
static int cmd_config(char *args[], int num, struct option *options)
@@ -516,17 +528,6 @@ int commands_no_options(DBusConnection *connection, char *argv[], int argc)
cmd_help(NULL, 0, NULL);
printf("\nNote: arguments and output are considered "
"EXPERIMENTAL for now.\n\n");
- } else if (strcmp(argv[0], "disconnect") == 0) {
- if (argc != 2) {
- fprintf(stderr, "Disconnect requires a service name or "
- "path, see help\n");
- error = -EINVAL;
- } else
- error = disconnect_service(connection,
- strip_service_path(argv[1]));
- if (error == 0)
- printf("Disconnected from: %s\n",
- strip_service_path(argv[1]));
} else if (strcmp(argv[0], "scan") == 0) {
if (argc != 2) {
fprintf(stderr, "Scan requires a service name or path, "