Return to sample_kanlib.c CVS log | Up to [local] / OpenXM / src / kxx |
File: [local] / OpenXM / src / kxx / sample_kanlib.c (download)
Revision 1.3, Fri Sep 17 02:42:58 2004 UTC (20 years ago) by takayama
RestrictedMode is introduced. If it is set, only functions with the ATTR_EXPORT bit are allowed to be executed. It is mainly designed for anonymous services in OpenXM-grid. A sample code for the RestricedMode. /hoge { (hello) message (hello2) message } def /foo {hoge} def [(parse) (cohom.sm1) pushfile] extension [(parse) (ox.sm1) pushfile] extension [(or_attr) 8 /gb] extension [(or_attr) 8 /pmat] extension [(or_attr) 8 /foo] extension [(or_attr) 8 /fctr] extension [(RestrictedMode) 1] system_variable foo hoge % stopped by the RestrictedMode flag. [ [( (x Dx)^2 + (y Dy)^2 -1) ( x y Dx Dy -1)] (x,y) [ [ (Dx) 1 ] ] ] gb pmat asirconnectr % stopped by the RestrictionMode flag [(x^2-1) (x)] fctr pmat |
/* $OpenXM: OpenXM/src/kxx/sample_kanlib.c,v 1.3 2004/09/17 02:42:58 takayama Exp $ */ /* This is a sample program to use kanlib.a gcc -g -O2 -g -D_BSD_SOURCE sample_kanlib.c -o sample_kanlib -ldl ../kan96xx/Kan/kanlib.a -L../../lib -lgmp -lgc */ #include <stdio.h> #include <setjmp.h> #include <signal.h> #if defined(__CYGWIN__) #define JMP_BUF sigjmp_buf #define SETJMP(env) sigsetjmp(env,1) #define LONGJMP(env,p) siglongjmp(env,p) #else #define JMP_BUF jmp_buf #define SETJMP(env) setjmp(env) #define LONGJMP(env,p) longjmp(env,p) #endif extern int Quiet; extern JMP_BUF EnvOfStackMachine; extern Calling_ctrlC_hook; extern int RestrictedMode, RestrictedMode_saved; void ctrlC(); main() { char s[1024]; Quiet = 0; KSstart(); if (signal(SIGINT,SIG_IGN) != SIG_IGN) { signal(SIGINT,ctrlC); } while( fgets(s,1023,stdin) != NULL) { if (SETJMP(EnvOfStackMachine)) { if (!Calling_ctrlC_hook) { Calling_ctrlC_hook = 1; RestrictedMode = 0; KSexecuteString(" ctrlC-hook "); /* Execute User Defined functions. */ RestrictedMode = RestrictedMode_saved; } Calling_ctrlC_hook = 0; KSexecuteString(" (Computation is interrupted.) "); continue; } else { } KSexecuteString(s); } }