void cli_context_execute_command (cli_context_t *ctx, gchar *input) { while (input && *input == ' ') ++input; if (input == NULL) { if (!cli_context_in_status (ctx, CLI_ACTION_STATUS_ALIAS)) { /* End of stream, quit */ cli_context_loop_stop (ctx); g_printf ("\n"); } } else if (*input != 0) { gint argc; gchar **argv, *listop; GError *error = NULL; if ((listop = strchr (input, ';'))) { *listop++ = '\0'; } if (g_shell_parse_argv (input, &argc, &argv, &error)) { if (!cli_context_in_status (ctx, CLI_ACTION_STATUS_ALIAS)) { add_history (input); } cli_context_command_dispatch (ctx, argc, argv); g_strfreev (argv); if (listop && *listop) { g_printf ("\n"); cli_context_execute_command (ctx, listop); } } else { g_printf (_("Error: %s\n"), error->message); g_error_free (error); } } }
static void readline_callback (gchar *input) { cli_context_execute_command (readline_cli_ctx, input); }