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;
-}
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)
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);