callinterf.c

Go to the documentation of this file.
00001 /**************************************
00002  * Copyright Jean-Philippe Chancelier 
00003  * ENPC 
00004  **************************************/
00005 #include <setjmp.h>
00006 #include <stdio.h>
00007 #include <ctype.h>
00008 #include <signal.h>
00009 
00010 #include "machine.h"
00011 #include "sciprint.h"
00012 #include "Scierror.h"
00013 #include "csignal.h"
00014 
00015 #include "addinter.h" /* for DynInterfStart */
00016 #include "Os_specific.h" /* for DynInterfStart */
00017 
00018 
00019 static  jmp_buf jmp_env; 
00020 
00021 extern int  C2F(error) __PARAMS((int *));
00022 
00023 void errjump(int n);
00024 void C2F(no_gw_tclsci)(void);
00025 void C2F(NoPvm)(void);
00026 void C2F(Nogw_scicos)(void);
00027 void C2F(Nogw_cscicos)(void);
00028 void C2F(Nogw_slicot)(void);
00029 int ForceLink(void);
00030 
00031 static void  sci_sigint_addinter(int n);
00032 
00033 /***********************************************************
00034  * interface function 
00035  ***********************************************************/
00036 
00037 static int c_local_interf = 9999;
00038 
00039 void C2F(no_gw_tclsci)(void)
00040 {
00041   sciprint("TclSci interface not loaded \n");
00042   C2F(error)(&c_local_interf);
00043   return;
00044 }
00045 
00046 void C2F(NoPvm)(void)
00047 {
00048   sciprint("pvm interface not loaded \n");
00049   C2F(error)(&c_local_interf);
00050   return;
00051 }
00052 
00053 void C2F(Nogw_scicos)(void)
00054 {
00055         sciprint("scicos interfaces not loaded \n");
00056         C2F(error)(&c_local_interf);
00057         return;
00058 }
00059 
00060 void C2F(Nogw_cscicos)(void)
00061 {
00062         sciprint("scicos interfaces not loaded \n");
00063         C2F(error)(&c_local_interf);
00064         return;
00065 }
00066 
00067 
00068 void C2F(Nogw_slicot)(void)
00069 {
00070         sciprint("Slicot interfaces not loaded \n");
00071         C2F(error)(&c_local_interf);
00072         return;
00073 }
00074 
00077 typedef  struct  {
00078   void  (*fonc)();} OpTab ;
00079 
00080 #include "callinterf.h"
00081 
00082 
00083 /***********************************************************
00084  * call the apropriate interface according to the value of k 
00085  * iflagint is no more used here ....
00086  ***********************************************************/
00087 
00088 
00089 static int sig_ok = 0;
00090 
00091 int C2F(callinterf) ( int *k, int * iflagint)
00092 {
00093   int returned_from_longjump ;
00094   static int count = 0;
00095   if ( count == 0) 
00096     {
00097       if (sig_ok) signal(SIGINT,sci_sigint_addinter);
00098       if (( returned_from_longjump = setjmp(jmp_env)) != 0 )
00099         {
00100           if (sig_ok) signal(SIGINT, controlC_handler);
00101           Scierror(999,"SIGSTP: aborting current computation\r\n");
00102           count = 0;
00103           return 0;
00104         }
00105     }
00106   count++;
00107   if (*k > DynInterfStart) 
00108     C2F(userlk)(k);
00109   else
00110     (*(Interfaces[*k-1].fonc))();
00111   count--;
00112   if (count == 0) { 
00113     if (sig_ok) signal(SIGINT, controlC_handler);
00114   }
00115   return 0;
00116 }
00117 
00118 static void sci_sigint_addinter(int n)
00119 {
00120   int c;
00121   sciprint("Trying to stop scilab in the middle of an interface\n");
00122   sciprint("Do you really want to abort computation (y n  ?) ");
00123   c = getchar();
00124   if ( c == 'y' ) errjump(n);
00125 }
00126 
00127 
00128 /***********************************************************
00129  * Unused function just here to force linker to load some 
00130  * functions 
00131  ***********************************************************/
00132 
00133 extern int   Blas_contents __PARAMS((int));
00134 extern int   Lapack_contents __PARAMS((int));
00135 extern int   Calelm_contents __PARAMS((int));
00136 extern int   Sun_contents __PARAMS((int));
00137 extern int   System2_contents __PARAMS((int));
00138 extern int   System_contents __PARAMS((int));
00139 extern int   Intersci_contents __PARAMS((int));
00140 extern int   Sparse_contents __PARAMS((int));
00141 
00142 #ifndef _MSC_VER
00143 int ForceLink(void)
00144 {
00145         /*  
00146                 commented for test purpose by Sylvestre (no sure it is mandatory
00147 Blas_contents(0);
00148   Lapack_contents(0);
00149   Calelm_contents(0);
00150   Sun_contents(0);
00151   System2_contents(0);
00152   System_contents(0);
00153   Intersci_contents(0);
00154   Sparse_contents(0);*/
00155   return 0;
00156 }
00157 #endif
00158 
00159 /*-------------------------------------
00160  * long jump to stop interface computation 
00161  *-------------------------------------*/
00162 
00163 void errjump(int n)
00164 {
00165   longjmp(jmp_env,-1); 
00166 }

Generated on Sun Mar 4 15:03:45 2007 for Scilab [trunk] by  doxygen 1.5.1