diff options
author | Patrik Flykt <patrik.flykt@linux.intel.com> | 2013-02-19 22:20:01 +0200 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2013-02-21 16:23:07 +0200 |
commit | 6f80c4d3a0d24d1f6319596b48c7874f9ddddc54 (patch) | |
tree | 4ba104072b00c9acf162136db71dea5ce2a030ca /client | |
parent | a1fd752bd86668e2500d3ebda815672ae81c171a (diff) | |
download | connman-6f80c4d3a0d24d1f6319596b48c7874f9ddddc54.tar.gz connman-6f80c4d3a0d24d1f6319596b48c7874f9ddddc54.tar.bz2 connman-6f80c4d3a0d24d1f6319596b48c7874f9ddddc54.zip |
client: Factor out scan command
Diffstat (limited to 'client')
-rw-r--r-- | client/commands.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/client/commands.c b/client/commands.c index 758c0faa..4b3d01e1 100644 --- a/client/commands.c +++ b/client/commands.c @@ -202,7 +202,25 @@ static int cmd_technologies(char *args[], int num, struct option *options) static int cmd_scan(char *args[], int num, struct option *options) { - return -1; + DBusMessage *message; + int err; + + if (num > 2) + return -E2BIG; + + if (num < 2) + return -EINVAL; + + message = get_message(connection, "GetTechnologies"); + if (message == NULL) + err = -ENOMEM; + else { + err = scan_technology(connection, message, args[1]); + if (err == 0) + printf("Scan completed\n"); + } + + return 0; } static int cmd_connect(char *args[], int num, struct option *options) @@ -528,17 +546,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], "scan") == 0) { - if (argc != 2) { - fprintf(stderr, "Scan requires a service name or path, " - "see help\n"); - error = -EINVAL; - } - message = get_message(connection, "GetTechnologies"); - if (message == NULL) - error = -ENOMEM; - else - error = scan_technology(connection, message, argv[1]); } else if (strcmp(argv[0], "enable") == 0) { if (argc != 2) { fprintf(stderr, "Enable requires a technology name or " |