[BACK]Return to sample_kanlib.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / kxx

Annotation of OpenXM/src/kxx/sample_kanlib.c, Revision 1.2

1.2     ! takayama    1: /* $OpenXM: OpenXM/src/kxx/sample_kanlib.c,v 1.1 2004/02/29 03:00:37 takayama Exp $ */
1.1       takayama    2: /*
                      3: This is a sample program to use kanlib.a
                      4: gcc -g -O2 -g -D_BSD_SOURCE sample_kanlib.c -o sample_kanlib  -ldl   ../kan96xx/Kan/kanlib.a -L../../lib -lgmp -lgc
                      5: */
                      6:
                      7: #include <stdio.h>
                      8: #include <setjmp.h>
                      9: #include <signal.h>
                     10:
                     11: #if defined(__CYGWIN__)
                     12: #define JMP_BUF sigjmp_buf
                     13: #define SETJMP(env)  sigsetjmp(env,1)
                     14: #define LONGJMP(env,p)  siglongjmp(env,p)
                     15: #else
                     16: #define JMP_BUF jmp_buf
                     17: #define SETJMP(env)  setjmp(env)
                     18: #define LONGJMP(env,p)  longjmp(env,p)
                     19: #endif
                     20:
                     21:
                     22: extern int Quiet;
                     23: extern JMP_BUF EnvOfStackMachine;
1.2     ! takayama   24: extern Calling_ctrlC_hook;
1.1       takayama   25:
                     26: void ctrlC();
                     27:
                     28: main() {
                     29:   char s[1024];
                     30:   Quiet = 0;
                     31:   KSstart();
                     32:
                     33:   if (signal(SIGINT,SIG_IGN) != SIG_IGN) {
                     34:        signal(SIGINT,ctrlC);
                     35:   }
                     36:   while( fgets(s,1023,stdin) != NULL) {
                     37:        if (SETJMP(EnvOfStackMachine)) {
1.2     ! takayama   38:       if (!Calling_ctrlC_hook) {
        !            39:         Calling_ctrlC_hook = 1;
        !            40:         KSexecuteString(" ctrlC-hook "); /* Execute User Defined functions. */
        !            41:       }
        !            42:       Calling_ctrlC_hook = 0;
1.1       takayama   43:       KSexecuteString(" (Computation is interrupted.) ");
                     44:          continue;
                     45:        } else {  }
                     46:        KSexecuteString(s);
                     47:   }
                     48: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>