client: Remove the now obsolete command parsing functions
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Wed, 20 Feb 2013 11:53:36 +0000 (13:53 +0200)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Thu, 21 Feb 2013 14:23:16 +0000 (16:23 +0200)
client/commands.c
client/interactive.c
client/main.c

index d38b858..8d0a6a9 100644 (file)
@@ -548,34 +548,9 @@ int commands(DBusConnection *connection, char *argv[], int argc)
                        if (result < 0)
                                printf("Error '%s': %s\n", argv[0],
                                                strerror(-result));
-                       return 0;
+                       return result;
                }
        }
 
        return -1;
 }
-
-int commands_no_options(DBusConnection *connection, char *argv[], int argc)
-{
-       DBusMessage *message = NULL;
-       int error = 0;
-
-       if (strcmp(argv[0], "--help") == 0 || strcmp(argv[0], "help") == 0  ||
-                                               strcmp(argv[0], "h") == 0) {
-               printf("Usage: connmanctl [[command] [args]]\n");
-               cmd_help(NULL, 0, NULL);
-               printf("\nNote: arguments and output are considered "
-                               "EXPERIMENTAL for now.\n\n");
-       } else
-               return -1;
-
-       if (message != NULL)
-               dbus_message_unref(message);
-
-       return error;
-}
-
-int commands_options(DBusConnection *connection, char *argv[], int argc)
-{
-       return 0;
-}
index 200f3dc..49952b9 100644 (file)
@@ -71,15 +71,6 @@ static gboolean rl_handler(char *input)
        for (num_args = 0; long_args[num_args] != NULL; num_args++);
 
        error = commands(interactive_conn, long_args, num_args);
-       if (error == -1) {
-               error = commands_no_options(interactive_conn, long_args,
-                               num_args);
-               if (error == -1)
-                       error = commands_options(interactive_conn, long_args,
-                                       num_args);
-               else
-                       return error;
-       }
 
        if ((strcmp(long_args[0], "quit") == 0)
                                        || (strcmp(long_args[0], "exit") == 0)
index f913534..31d5a37 100644 (file)
@@ -96,23 +96,20 @@ int main(int argc, char *argv[])
                show_interactive(connection, main_loop);
 
        error = commands(connection, argv + 1, argc -1);
-       if (error == -1) {
-               error = commands_no_options(connection, argv + 1, argc - 1);
-               if (error == -1) {
-                       error = commands_options(connection, argv + 1,
-                                       argc - 1);
-                       if (strcmp(argv[1], "monitor") != 0)
-                               return error;
-               } else {
-                       return error;
-               }
-       }
 
        if (error == -1) {
-               fprintf(stderr, "%s is not a valid command, check help.\n",
-                                                       argv[1]);
+               char *help = "help";
+
+               printf("Usage: connmanctl [[command] [args]]\n");
+               commands(connection, &help, 1);
+               printf("\nNote: arguments and output are considered "
+                               "EXPERIMENTAL for now.\n\n");
                return -EINVAL;
        }
+
+       if (error < 0)
+               return error;
+
        gchan = g_io_channel_unix_new(fileno(stdin));
        events = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL;
        g_io_add_watch(gchan, events, readmonitor, NULL);