1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
#include "javasci_globals.h"
/********************************************************************************************************/
/* Allan CORNET */
/* INRIA 2005 */
/********************************************************************************************************/
static int init = 0;
/********************************************************************************************************/
void EnableInterf()
{
init = 1;
}
/********************************************************************************************************/
void DisableInterf()
{
init = 0;
}
/********************************************************************************************************/
int GetInterfState()
{
return init;
}
/********************************************************************************************************/
/* Initialisation de Scilab */
/********************************************************************************************************/
void Initialize()
{
static char env[1024];
static char initstr[]="exec(\"SCI/scilab.star\",-1);quit;";
static int iflag=-1, stacksize = 1000000, ierr=0;
#if _MSC_VER
static char JavaSciInterf[]="javasci";
static char nw[]="-nw";
static char nb[]="-nb";
#endif
char *p1 = (char*)getenv ("SCI");
#if _MSC_VER
/* Supprime le mode windows et la baniere */
add_sci_argv(JavaSciInterf);
add_sci_argv(nb);
#endif
#if _MSC_VER
if ( p1== NULL )
{
/* Detection Scilab path */
char modname[MAX_PATH+1];
if (!GetModuleFileName (GetModuleHandle("javasci.dll"), modname, MAX_PATH))
{
MessageBox(NULL,"javasci.dll not found","Warning",MB_ICONWARNING);
}
else
{
char *p;
if ((p = strrchr (modname, '\\')) == NULL) exit(1); /* remove \javasci.dll from modname */
else
{
*p='\0';
if ((p = strrchr (modname, '\\')) == NULL) exit(1); /* remove \bin from modname */
else
{
*p='\0';
set_sci_env(modname);
}
}
}
}
else
{
char *pathSCI=(char*)MALLOC((strlen(p1)+1)*sizeof(char));
sprintf(pathSCI,"%s",p1);
set_sci_env(pathSCI);
if (pathSCI) {FREE(pathSCI);pathSCI=NULL;}
}
#else
if (p1==NULL)
{
fprintf(stderr,"Please define SCI environment variable\n");
sprintf (env, "%s=%s", "SCI",SCI);
putenv (env);
}
#endif
/* Scilab Initialization */
C2F(inisci)(&iflag,&stacksize,&ierr);
if ( ierr > 0 )
{
fprintf(stderr,"Scilab initialization failed !\n");
exit(1);
}
/* running the startup */
C2F(settmpdir)();
/* Initialisation fenetre graphique */
#if _MSC_VER
InitWindowGraphDll();
#endif
/* pour initialisation de la primitive scilab : fromjava() */
SetFromJavaToON();
/* Chargement de Scilab.star */
C2F(scirun)(initstr,(int)strlen(initstr));
}
/********************************************************************************************************/
int send_scilab_job(char *job)
{
return (int) SendScilabJob(job);
}
/********************************************************************************************************/
#ifndef _MSC_VER
int MAIN__()
{
return 0;
}
#endif
/********************************************************************************************************/
|