#include <mex.h> 
#include <sci_gateway.h>
#include <api_scilab.h>
#include <MALLOC.h>
static int direct_gateway(char *fname,void F(void)) { F();return 0;};
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_gf_scilab;
extern Gatefunc sci_spluinc;
extern Gatefunc sci_splu;
extern Gatefunc sci_splusolve;
extern Gatefunc sci_spcholinc;
extern Gatefunc sci_spchol;
extern Gatefunc sci_spchsolve;
extern Gatefunc sci_spcgne;
extern Gatefunc sci_spcgs;
extern Gatefunc sci_spgmres;
extern Gatefunc sci_spmgcr;
static GenericTable Tab[]={
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_workspace"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_delete"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_undelete"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_eltm"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_geotrans"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_geotrans_get"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_integ"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_integ_get"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_global_function"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_global_function_get"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_fem"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_fem_get"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_cvstruct_get"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_mesher_object"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_mesher_object_get"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_mesh"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_mesh_get"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_mesh_set"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_mesh_fem"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_mesh_fem_get"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_mesh_fem_set"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_mesh_im"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_mesh_im_get"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_mesh_im_set"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_mdbrick"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_mdbrick_get"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_mdbrick_set"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_mdstate"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_mdstate_get"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_mdstate_set"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_model"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_model_get"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_model_set"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_slice"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_slice_get"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_slice_set"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_levelset"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_levelset_get"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_levelset_set"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_mesh_levelset"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_mesh_levelset_get"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_mesh_levelset_set"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_asm"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_compute"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_precond"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_precond_get"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_spmat"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_spmat_get"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_spmat_set"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_linsolve"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_util"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_exit"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_cont_struct_get"},
  {(Myinterfun)sci_gateway,sci_gf_scilab,"gf_cont_struct"},
  {(Myinterfun)sci_gateway,sci_spluinc,"sp_luinc"},
  {(Myinterfun)sci_gateway,sci_splu,"sp_lu"},
  {(Myinterfun)sci_gateway,sci_splusolve,"sp_lusolve"},
  {(Myinterfun)sci_gateway,sci_spcholinc,"sp_cholinc"},
  {(Myinterfun)sci_gateway,sci_spchol,"sp_chol"},
  {(Myinterfun)sci_gateway,sci_spchsolve,"sp_chsolve"},
  {(Myinterfun)sci_gateway,sci_spcgne,"sp_cgne"},
  {(Myinterfun)sci_gateway,sci_spcgs,"sp_cgs"},
  {(Myinterfun)sci_gateway,sci_spgmres,"sp_gmres"},
  {(Myinterfun)sci_gateway,sci_spmgcr,"sp_mgcr"},
};
 
int C2F(libscigetfem_c)()
{
  Rhs = Max(0, Rhs);
  if (*(Tab[Fin-1].f) != NULL) 
  {
     if(pvApiCtx == NULL)
     {
       pvApiCtx = (StrCtx*)MALLOC(sizeof(StrCtx));
     }
     pvApiCtx->pstName = (char*)Tab[Fin-1].name;
    (*(Tab[Fin-1].f))(Tab[Fin-1].name,Tab[Fin-1].F);
  }
  return 0;
}
