Annotation of OpenXM/src/kxx/sample_kanlib.c, Revision 1.3
1.3 ! takayama 1: /* $OpenXM: OpenXM/src/kxx/sample_kanlib.c,v 1.2 2004/09/05 00:51:18 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.3 ! takayama 25: extern int RestrictedMode, RestrictedMode_saved;
1.1 takayama 26:
27: void ctrlC();
28:
29: main() {
30: char s[1024];
31: Quiet = 0;
32: KSstart();
33:
34: if (signal(SIGINT,SIG_IGN) != SIG_IGN) {
35: signal(SIGINT,ctrlC);
36: }
37: while( fgets(s,1023,stdin) != NULL) {
38: if (SETJMP(EnvOfStackMachine)) {
1.2 takayama 39: if (!Calling_ctrlC_hook) {
1.3 ! takayama 40: Calling_ctrlC_hook = 1; RestrictedMode = 0;
1.2 takayama 41: KSexecuteString(" ctrlC-hook "); /* Execute User Defined functions. */
1.3 ! takayama 42: RestrictedMode = RestrictedMode_saved;
1.2 takayama 43: }
44: Calling_ctrlC_hook = 0;
1.1 takayama 45: KSexecuteString(" (Computation is interrupted.) ");
46: continue;
47: } else { }
48: KSexecuteString(s);
49: }
50: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>