[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.6

1.6     ! takayama    1: /* $OpenXM: OpenXM/src/kxx/sample_kanlib.c,v 1.5 2016/03/31 05:27:34 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>
1.5       takayama   10: #include "mysig.h"
1.1       takayama   11:
1.4       takayama   12: // serversm.h is not included.
                     13: #if defined(__CYGWIN__) || defined(__MSYS__)
1.1       takayama   14: #define JMP_BUF sigjmp_buf
1.4       takayama   15: #define SETJMP(env)  _setjmp(env)
                     16: #define LONGJMP(env,p)  _longjmp(env,p)
1.1       takayama   17: #else
                     18: #define JMP_BUF jmp_buf
                     19: #define SETJMP(env)  setjmp(env)
                     20: #define LONGJMP(env,p)  longjmp(env,p)
                     21: #endif
                     22:
                     23:
                     24: extern int Quiet;
                     25: extern JMP_BUF EnvOfStackMachine;
1.2       takayama   26: extern Calling_ctrlC_hook;
1.3       takayama   27: extern int RestrictedMode, RestrictedMode_saved;
1.1       takayama   28:
                     29: void ctrlC();
                     30:
                     31: main() {
                     32:   char s[1024];
1.6     ! takayama   33:   int r;
1.1       takayama   34:   Quiet = 0;
                     35:   KSstart();
                     36:
1.5       takayama   37:   if (mysignal(SIGINT,SIG_IGN) != SIG_IGN) {
                     38:        mysignal(SIGINT,ctrlC);
1.1       takayama   39:   }
                     40:   while( fgets(s,1023,stdin) != NULL) {
                     41:        if (SETJMP(EnvOfStackMachine)) {
1.2       takayama   42:       if (!Calling_ctrlC_hook) {
1.3       takayama   43:         Calling_ctrlC_hook = 1; RestrictedMode = 0;
1.2       takayama   44:         KSexecuteString(" ctrlC-hook "); /* Execute User Defined functions. */
1.3       takayama   45:         RestrictedMode = RestrictedMode_saved;
1.2       takayama   46:       }
                     47:       Calling_ctrlC_hook = 0;
1.1       takayama   48:       KSexecuteString(" (Computation is interrupted.) ");
                     49:          continue;
                     50:        } else {  }
1.6     ! takayama   51:        r=KSexecuteString(s);
        !            52:        fprintf(stderr,"result code=%d\n",r);
1.1       takayama   53:   }
                     54: }

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