예제 #1
0
void
react_to_terminal_signal (int sig)
{
  enum { EXPLEN = 25 };
  char exp[EXPLEN];
  snprintf (exp, EXPLEN, "(handle-signal %d)", sig);
  scm_eval_string (scm_from_locale_string (exp));
  exit (1);
}
예제 #2
0
파일: module.c 프로젝트: rlutz/geda-gaf
static PyObject *eval_string_wrapper(PyObject *string_arg)
{
	const char *s = PyString_AsString(string_arg);
	SCM string = scm_from_utf8_stringn(s, PyString_Size(string_arg));
	return scm2py(scm_eval_string(string));
}
예제 #3
0
int main() {
    printf("Variante %d: %s\n", VARIANTE, VARIANTE_STRING);

#ifdef USE_GUILE
    scm_init_guile();
    /* register "executer" function in scheme */
    scm_c_define_gsubr("executer", 1, 0, 0, executer_wrapper);
#endif

    while (1) {
        //struct cmdline *l;
        char *line=0;
        //int i, j;
        char *prompt = "ensishell>";

        /* Readline use some internal memory structure that
           can not be cleaned at the end of the program. Thus
           one memory leak per command seems unavoidable yet */
        line = readline(prompt);
        if (line == 0 || ! strncmp(line,"exit", 4)) {
            terminate(line);
        }

        if(!strncmp(line,"jobs",4)) {
            print_bg(liste_children_bg);
        }

#ifdef USE_GNU_READLINE
        add_history(line);
#endif


#ifdef USE_GUILE
        /* The line is a scheme command */
        if (line[0] == '(') {
            char catchligne[strlen(line) + 256];
            sprintf(catchligne, "(catch #t (lambda () %s) (lambda (key . parameters) (display \"mauvaise expression/bug en scheme\n\")))", line);
            scm_eval_string(scm_from_locale_string(catchligne));
            free(line);
            continue;
        }
#endif
        update_bg(&liste_children_bg);
        executer(line);

        /* parsecmd free line and set it up to 0 */
        //l = parsecmd( & line);

        ///* If input stream closed, normal termination */
        //if (!l) {

        //    terminate(0);
        //}



        //if (l->err) {
        //    /* Syntax error, read another command */
        //    printf("error: %s\n", l->err);
        //    continue;
        //}

        //if (l->in) printf("in: %s\n", l->in);
        //if (l->out) printf("out: %s\n", l->out);
        //if (l->bg) printf("background (&)\n");

        ///* Display each command of the pipe */
        //for (i=0; l->seq[i]!=0; i++) {
        //    char **cmd = l->seq[i];
        //    printf("seq[%d]: ", i);
        //    for (j=0; cmd[j]!=0; j++) {
        //        printf("'%s' ", cmd[j]);
        //    }
        //    printf("\n");
        //}
    }

}