X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=src%2Fgacela.c;h=6891d4b9f1180e661f256703cd07fde8b68c1c18;hb=e82142f2231e5aacf47e3f0cf5e82679d4291af2;hp=d1a15fb96d4fd94cca9d1ae3eba9f0c97f686d9b;hpb=b9e6fa296fff96cca34819510b411e12be0bdbe0;p=gacela.git diff --git a/src/gacela.c b/src/gacela.c index d1a15fb..6891d4b 100644 --- a/src/gacela.c +++ b/src/gacela.c @@ -165,7 +165,8 @@ gacela_client (SCM rec_channel, SCM send_channel) ctrl_c = 0; else { buffer = scm_read (rec_channel); - printf ("%s\n", scm_to_locale_string (buffer)); + if (strlen (scm_to_locale_string (buffer)) > 0) + printf ("%s\n", scm_to_locale_string (buffer)); } } free (line); @@ -176,7 +177,7 @@ gacela_client (SCM rec_channel, SCM send_channel) } static void* -init_gacela (void *data, int argc, char **argv) +init_scheme (void *data, int argc, char **argv) { // Guile configuration scm_c_eval_string ("(set-repl-prompt! \"gacela> \")"); @@ -204,11 +205,11 @@ load_scheme_files (char *path) } void -start_single () +init_gacela (char *path) { - char *argv = "guile"; - - scm_shell (1, &argv); + scm_with_guile (&init_scheme, NULL); + load_scheme_files (path); + scm_c_eval_string ("(init-video-mode)"); } void @@ -244,7 +245,7 @@ int main (int argc, char *argv[]) { char *arg; - int mode = 0; // shell: 1, server: 2, client: 3 + int mode = 0; // dev: 1, server: 2, client: 3 char *host; int port = 0; int i; @@ -253,7 +254,7 @@ main (int argc, char *argv[]) // Checking arguments for (i = 1; i < argc; i++) { - if (strcmp (argv[i], "--shell-mode") == 0) + if (strcmp (argv[i], "--dev") == 0) mode = 1; else if (strncmp (argv[i], "--server", 8) == 0) { mode = 2; @@ -278,18 +279,6 @@ main (int argc, char *argv[]) scm_init_guile (); if (mode == 1) { - scm_with_guile (&init_gacela, NULL); - load_scheme_files (dirname (argv[0])); - start_single (); - } - else if (mode == 2 && port != 0) { - scm_with_guile (&init_gacela, NULL); - load_scheme_files (dirname (argv[0])); - start_server (port); - } - else if (mode == 3 && port != 0) - start_remote_client (host, port); - else { fd1 = scm_pipe (); fd2 = scm_pipe (); pid = fork (); @@ -297,8 +286,7 @@ main (int argc, char *argv[]) if (pid == 0) { scm_close (SCM_CAR (fd1)); scm_close (SCM_CDR (fd2)); - scm_with_guile (&init_gacela, NULL); - load_scheme_files (dirname (argv[0])); + init_gacela (dirname (argv[0])); start_local_server (scm_cons (SCM_CAR (fd2), SCM_CDR (fd1))); } else { @@ -308,4 +296,15 @@ main (int argc, char *argv[]) kill (pid, SIGKILL); } } + else if (mode == 2 && port != 0) { + init_gacela (dirname (argv[0])); + start_server (port); + } + else if (mode == 3 && port != 0) + start_remote_client (host, port); + else { + init_gacela (dirname (argv[0])); + scm_shell (argc, argv); + SDL_Quit (); + } }