12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #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_from_file(shell, argv[i++]);
- }
- } else {
-
- result = clish_shell_loop(shell);
- }
-
- clish_shell_delete(shell);
- return result ? 0 : -1;
- }
|