From 499d0573f96511e72d1d217402d42b924de05e78 Mon Sep 17 00:00:00 2001 From: Patrik Flykt Date: Wed, 20 Feb 2013 13:53:36 +0200 Subject: [PATCH] client: Remove the now obsolete command parsing functions --- client/commands.c | 27 +-------------------------- client/interactive.c | 9 --------- client/main.c | 23 ++++++++++------------- 3 files changed, 11 insertions(+), 48 deletions(-) diff --git a/client/commands.c b/client/commands.c index d38b8581..8d0a6a99 100644 --- a/client/commands.c +++ b/client/commands.c @@ -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; -} diff --git a/client/interactive.c b/client/interactive.c index 200f3dcb..49952b94 100644 --- a/client/interactive.c +++ b/client/interactive.c @@ -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) diff --git a/client/main.c b/client/main.c index f913534a..31d5a373 100644 --- a/client/main.c +++ b/client/main.c @@ -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); -- 2.34.1