diff options
author | Patrik Flykt <patrik.flykt@linux.intel.com> | 2013-02-19 21:57:24 +0200 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2013-02-21 16:23:01 +0200 |
commit | 8e9d752f92e7320f5e36536efe367d26dc00cbdb (patch) | |
tree | 769a141f3df150a988bb1a734a2521b2b83d32ef /client/commands.c | |
parent | 4c12b0f73059514d32c97c02c1c55b8c43e19197 (diff) | |
download | connman-8e9d752f92e7320f5e36536efe367d26dc00cbdb.tar.gz connman-8e9d752f92e7320f5e36536efe367d26dc00cbdb.tar.bz2 connman-8e9d752f92e7320f5e36536efe367d26dc00cbdb.zip |
client: Factor out connect command
Diffstat (limited to 'client/commands.c')
-rw-r--r-- | client/commands.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/client/commands.c b/client/commands.c index dd24d106..20a05071 100644 --- a/client/commands.c +++ b/client/commands.c @@ -207,7 +207,19 @@ static int cmd_scan(char *args[], int num, struct option *options) static int cmd_connect(char *args[], int num, struct option *options) { - return -1; + int err; + + if (num > 2) + return -E2BIG; + + if (num < 2) + return -EINVAL; + + err = connect_service(connection, args[1]); + if (err == 0) + printf("Connected\n"); + + return 0; } static int cmd_disconnect(char *args[], int num, struct option *options) @@ -504,17 +516,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], "connect") == 0) { - if (argc != 2) { - fprintf(stderr, "Connect requires a service name or " - "path, see help\n"); - error = -EINVAL; - } else - error = connect_service(connection, - strip_service_path(argv[1])); - if (error == 0) - printf("Connected to: %s\n", - strip_service_path(argv[1])); } else if (strcmp(argv[0], "disconnect") == 0) { if (argc != 2) { fprintf(stderr, "Disconnect requires a service name or " |