X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=gacela.c;h=45c83a114e0770c02a82e4d998d76b199dfe65e2;hb=7a52896af08038135aab3a8a2dc29f526bbf55db;hp=0493d8fd63621c90534f89946970c574eceb17e4;hpb=a807d13b26724e7219b3e7e82915a43ff9d327cc;p=gacela.git diff --git a/gacela.c b/gacela.c index 0493d8f..45c83a1 100644 --- a/gacela.c +++ b/gacela.c @@ -1,63 +1,21 @@ -#include -#include -#include -#include +#include #include +#include "gacela_SDL.h" -/* Read-Send-Print-Loop */ -void rspl(int pin, int pout) +static void* +register_functions (void* data) { - static char *line = (char *)NULL; - int exit = 0; - - while (!exit) { - if (line) { - free(line); - line = (char *)NULL; - } - - line = readline("gacela>"); - - if (line && *line) { - add_history(line); - if (strcmp(line, "(quit)") == 0) - exit = 1; - else { - write(pout, line, strlen(line)); - write(pout, "\n", 1); - } - } - } + SDL_register_functions (NULL); + return NULL; } -int main (int argc, char *argv[]) +int +main (int argc, char *argv[]) { - pid_t cpid; - int pfd[2]; - - pipe(pfd); - cpid = fork(); - if (cpid != 0) { - rspl(pfd[0], pfd[1]); - return 0; - } - else { - char buf; - static char *line = (char *)NULL; - - dup2(pfd[0], 0); - close(pfd[0]); - - while (1) { - if (line) { - free(line); - line = (char *)NULL; - } - - line = readline(""); - if (line && *line) { - printf("%s-\n", line); - } - } - } + scm_with_guile (®ister_functions, NULL); + scm_init_guile (); + scm_c_eval_string ("(set-repl-prompt! \"gacela>\")"); + scm_c_eval_string ("(use-modules (ice-9 readline))"); + scm_c_eval_string ("(activate-readline)"); + scm_shell (argc, argv); }