1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #include "clish/private.h"
- static
- clish_shell_hooks_t my_hooks =
- {
- NULL,
- clish_access_callback,
- NULL,
- clish_script_callback,
- NULL,
- clish_config_callback,
- NULL
- };
- int main(int argc, const char **argv)
- {
- bool_t running;
- int result = -1;
- clish_shell_t * shell;
- shell = clish_shell_new(&my_hooks, NULL, stdin, stdout);
- if (!shell) {
- fprintf(stderr, "Cannot run clish.\n");
- return -1;
- }
-
- clish_shell_load_files(shell);
-
- running = clish_shell_startup(shell);
- if (!running) {
- fprintf(stderr, "Cannot startup clish.\n");
- clish_shell_delete(shell);
- return -1;
- }
- if(argc > 1) {
- int i = 1;
- while(argc--) {
-
- result = clish_shell_spawn_from_file(shell,
- NULL, argv[i++]);
- }
- } else {
-
- result = clish_shell_spawn_and_wait(shell, NULL);
- }
-
- clish_shell_delete(shell);
- return result ? 0 : -1;
- }
|