Separation Console Dos - Windows
Allan Cornet [Sun, 8 Feb 2004 17:48:35 +0000 (17:48 +0000)]
17 files changed:
scilab/Makefile.mak
scilab/config/Makefile.mak
scilab/routines/Makefile.mak
scilab/routines/Makesubdirs.bat
scilab/routines/wsci/CScilex/CScilex.c [new file with mode: 0644]
scilab/routines/wsci/CScilex/CScilex.vcproj [new file with mode: 0644]
scilab/routines/wsci/CScilex/Makefile.mak [new file with mode: 0644]
scilab/routines/wsci/WINMAIN.H
scilab/routines/wsci/WMENU.H
scilab/routines/wsci/WScilex/Makefile.mak [new file with mode: 0644]
scilab/routines/wsci/WScilex/WScilex.c [new file with mode: 0644]
scilab/routines/wsci/WScilex/WScilex.rc [new file with mode: 0644]
scilab/routines/wsci/WScilex/WScilex.vcproj [new file with mode: 0644]
scilab/routines/wsci/WScilex/resource.h [new file with mode: 0644]
scilab/routines/wsci/winmain.c
scilab/routines/wsci/wmenu.c
scilab/routines/wsci/wtext.c

index ee4d99c..9b4c17c 100644 (file)
@@ -4,7 +4,7 @@ SCIDIR1=.
 
 include Makefile.incl.mak 
 
-all ::  routines-pvm  bin/scilex.exe macros  imp intersci tcl
+all ::  routines-pvm  bin/scilex.exe bin/Wscilex.exe macros  imp intersci tcl
 
 !IF "$(DLPVM)" == "YES"
 routines-pvm :: routines pvm 
index 3106020..ab2fb1d 100644 (file)
@@ -8,7 +8,10 @@ bin/LibScilab.dll: $(DEFAULTS) $(LIBRSCI)
        @$(LINKER) -subsystem:windows $(LINKER_FLAGS) $(RESOURCES) $(DEFAULTS) $(LIBR) $(XLIBS) \
         /dll /out:"$*.dll" /implib:"$*.lib" /def:"$*.def" 
 
-bin/scilex.exe : bin/LibScilab.dll
+bin/WScilex.exe : bin/LibScilab.dll
        @$(LINKER)  $(LINKER_FLAGS) -OUT:"$*.exe"  $(RESOURCES) \
-       routines/f2c/libf2c/main.obj bin/LibScilab.lib $(XLIBS) 
+       routines/wsci/WScilex/WScilex.obj bin/LibScilab.lib $(XLIBS) 
 
+bin/scilex.exe : bin/LibScilab.dll
+       @$(LINKER)  $(LINKER_FLAGS) -OUT:"$*.exe"  $(RESOURCES) \
+       routines/wsci/CScilex/CScilex.obj bin/LibScilab.lib $(XLIBS) 
index 85de4c3..c81754e 100644 (file)
@@ -5,7 +5,7 @@ include ../Makefile.incl.mak
 SCIDIRS = graphics calelm control default integ interf intersci lapack \
        metanet optim poly signal sparse sun system system2 \
        slicot  \
-       menusX scicos sound wsci xdr  gd int
+       menusX scicos sound wsci xdr  gd int wsci/WScilex wsci/CScilex
 
 SUBDIRS = $(XAW_LOCAL_SUBDIR) $(DLD_SUBDIR) $(SCIDIRS)
 
index 561789c..b9523c6 100755 (executable)
@@ -123,6 +123,14 @@ cd wsci
 echo Making %1 in directory  wsci
  nmake /C /f Makefile.mak %1
 cd ..
+cd wsci/Wscilex
+echo Making %1 in directory  wsci/WScilex
+ nmake /C /f Makefile.mak %1
+cd ../..
+cd wsci/CScilex
+echo Making %1 in directory  wsci/CScilex
+ nmake /C /f Makefile.mak %1
+cd ../..
 cd gd
 echo Making %1 in directory  gd
  nmake /C /f Makefile.mak %1
diff --git a/scilab/routines/wsci/CScilex/CScilex.c b/scilab/routines/wsci/CScilex/CScilex.c
new file mode 100644 (file)
index 0000000..d424707
--- /dev/null
@@ -0,0 +1,178 @@
+
+/* STARTUP PROCEDURE FOR UNIX FORTRAN PROGRAMS */
+
+#include <Windows.h>
+#include "stdio.h"
+#include "signal.h"
+
+extern int Console_Main(int argc, char **argv);
+
+#ifndef SIGIOT
+#ifdef SIGABRT
+#define SIGIOT SIGABRT
+#endif
+#endif
+
+#ifndef KR_headers
+#undef VOID
+#include "stdlib.h"
+#endif
+
+#ifndef VOID
+#define VOID void
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef NO__STDC
+#define ONEXIT onexit
+  extern VOID f_exit();
+#else
+#ifndef KR_headers
+  extern void f_exit(void);
+#ifndef NO_ONEXIT
+#define ONEXIT atexit
+  extern int atexit(void (*)(void));
+#endif
+#else
+#ifndef NO_ONEXIT
+#define ONEXIT onexit
+  extern VOID f_exit();
+#endif
+#endif
+#endif
+
+#ifdef KR_headers
+  extern VOID f_init(), sig_die();
+  extern int MAIN__();
+#define Int /* int */
+#else
+  extern void f_init(void), sig_die(char*, int);
+  extern int MAIN__(void);
+#define Int int
+#endif
+
+  static VOID sigfdie(Int n)
+  {
+    sig_die("Floating Exception", 1);
+  }
+
+
+  static VOID sigidie(Int n)
+  {
+    sig_die("IOT Trap", 1);
+  }
+
+#ifdef SIGQUIT
+  static VOID sigqdie(Int n)
+  {
+    sig_die("Quit signal", 1);
+  }
+#endif
+
+
+  static VOID sigindie(Int n)
+  {
+    sig_die("Interrupt", 0);
+  }
+
+  static VOID sigtdie(Int n)
+  {
+    sig_die("Killed", 0);
+  }
+
+#ifdef SIGTRAP
+  static VOID sigtrdie(Int n)
+  {
+    sig_die("Trace trap", 1);
+  }
+#endif
+
+
+#ifdef KR_headers
+  VOID send_xarg(xxargc,xxargv);
+#else
+  void send_xarg(int xxargc, char **xxargv);
+#endif
+
+int main (int argc, char **argv)
+{
+    /** JPC : 1998 pour fair un dll **/
+       #define MAXCMDTOKENS 128
+       int argcbis=-1;
+       LPSTR argvbis[MAXCMDTOKENS];
+       int i=0;
+       int FindNW=0;
+
+       for (i=0;i<argc;i++)
+       {
+               if ( (strcmp(argv[i],"-nw")==0) || (strcmp(argv[i],"-NW")==0) ) FindNW=1;
+               if ( (strcmp(argv[i],"-nwni")==0) || (strcmp(argv[i],"-NWNI")==0) ) FindNW=1;
+       }
+
+       if (FindNW==0)
+       {
+               char *nwparam=NULL;
+               nwparam=(char*)malloc((strlen("-nw")+1)*sizeof(char));
+               strcpy(nwparam,"-nw");
+               for (i=0;i<argc;i++)
+               {
+                       argvbis[i]=argv[i];
+               }
+               argvbis[argc]=nwparam;
+               argcbis=argc+1;
+               send_xarg(argcbis,argvbis);
+
+       }
+       else
+       {
+               for (i=0;i<argc;i++)
+               {
+                       argvbis[i]=argv[i];
+               }
+               argcbis=argc;
+       
+       }
+       send_xarg(argcbis,argvbis);
+
+
+
+    signal(SIGFPE, sigfdie);   /* ignore underflow, enable overflow */
+#ifdef SIGIOT
+    signal(SIGIOT, sigidie);
+#endif
+#ifdef SIGTRAP
+    signal(SIGTRAP, sigtrdie);
+#endif
+#ifdef SIGQUIT
+    if(signal(SIGQUIT,sigqdie) == SIG_IGN)
+      signal(SIGQUIT, SIG_IGN);
+#endif
+    if(signal(SIGINT, sigindie) == SIG_IGN)
+      signal(SIGINT, SIG_IGN);
+    signal(SIGTERM,sigtdie);
+
+#ifdef pdp11
+    ldfps(01200); /* detect overflow as an exception */
+#endif
+
+    f_init();
+#ifndef NO_ONEXIT
+    ONEXIT(f_exit);
+#endif
+    Console_Main(argcbis,argvbis);
+#ifdef NO_ONEXIT
+    f_exit();
+#endif
+    exit(0);   /* exit(0) rather than return(0) to bypass Cray bug */
+    return 0;  /* For compilers that complain of missing return values; */
+               /* others will complain that this is unreachable code. */
+  }
+#ifdef __cplusplus
+}
+#endif
+
+
+
diff --git a/scilab/routines/wsci/CScilex/CScilex.vcproj b/scilab/routines/wsci/CScilex/CScilex.vcproj
new file mode 100644 (file)
index 0000000..3a7aea3
--- /dev/null
@@ -0,0 +1,233 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="7.10"
+       Name="CScilex"
+       ProjectGUID="{9BA6F7E4-AE64-4FD9-A5A7-0996A8B73B77}"
+       Keyword="Win32Proj">
+       <Platforms>
+               <Platform
+                       Name="Win32"/>
+       </Platforms>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory="Debug"
+                       IntermediateDirectory="Debug"
+                       ConfigurationType="1"
+                       CharacterSet="2">
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+                               MinimalRebuild="TRUE"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="5"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="TRUE"
+                               DebugInformationFormat="4"/>
+                       <Tool
+                               Name="VCCustomBuildTool"/>
+                       <Tool
+                               Name="VCLinkerTool"
+                               OutputFile="../../../bin/Scilex.exe"
+                               LinkIncremental="2"
+                               GenerateDebugInformation="TRUE"
+                               ProgramDatabaseFile="$(OutDir)/CScilex.pdb"
+                               SubSystem="1"
+                               TargetMachine="1"/>
+                       <Tool
+                               Name="VCMIDLTool"/>
+                       <Tool
+                               Name="VCPostBuildEventTool"/>
+                       <Tool
+                               Name="VCPreBuildEventTool"/>
+                       <Tool
+                               Name="VCPreLinkEventTool"/>
+                       <Tool
+                               Name="VCResourceCompilerTool"/>
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"/>
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"/>
+                       <Tool
+                               Name="VCWebDeploymentTool"/>
+                       <Tool
+                               Name="VCManagedWrapperGeneratorTool"/>
+                       <Tool
+                               Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory="Release"
+                       IntermediateDirectory="Release"
+                       ConfigurationType="1"
+                       CharacterSet="2">
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               FavorSizeOrSpeed="1"
+                               OptimizeForProcessor="1"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+                               RuntimeLibrary="4"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="TRUE"
+                               DebugInformationFormat="3"/>
+                       <Tool
+                               Name="VCCustomBuildTool"/>
+                       <Tool
+                               Name="VCLinkerTool"
+                               OutputFile="../../../bin/Scilex.exe"
+                               LinkIncremental="1"
+                               GenerateDebugInformation="TRUE"
+                               SubSystem="1"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               TargetMachine="1"/>
+                       <Tool
+                               Name="VCMIDLTool"/>
+                       <Tool
+                               Name="VCPostBuildEventTool"/>
+                       <Tool
+                               Name="VCPreBuildEventTool"/>
+                       <Tool
+                               Name="VCPreLinkEventTool"/>
+                       <Tool
+                               Name="VCResourceCompilerTool"/>
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"/>
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"/>
+                       <Tool
+                               Name="VCWebDeploymentTool"/>
+                       <Tool
+                               Name="VCManagedWrapperGeneratorTool"/>
+                       <Tool
+                               Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+               </Configuration>
+               <Configuration
+                       Name="PIV_Release|Win32"
+                       OutputDirectory="$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="1"
+                       CharacterSet="2">
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               FavorSizeOrSpeed="1"
+                               OptimizeForProcessor="3"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+                               RuntimeLibrary="4"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="TRUE"
+                               DebugInformationFormat="3"/>
+                       <Tool
+                               Name="VCCustomBuildTool"/>
+                       <Tool
+                               Name="VCLinkerTool"
+                               OutputFile="../../../bin/Scilex.exe"
+                               LinkIncremental="1"
+                               GenerateDebugInformation="TRUE"
+                               SubSystem="1"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               TargetMachine="1"/>
+                       <Tool
+                               Name="VCMIDLTool"/>
+                       <Tool
+                               Name="VCPostBuildEventTool"/>
+                       <Tool
+                               Name="VCPreBuildEventTool"/>
+                       <Tool
+                               Name="VCPreLinkEventTool"/>
+                       <Tool
+                               Name="VCResourceCompilerTool"/>
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"/>
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"/>
+                       <Tool
+                               Name="VCWebDeploymentTool"/>
+                       <Tool
+                               Name="VCManagedWrapperGeneratorTool"/>
+                       <Tool
+                               Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+               </Configuration>
+               <Configuration
+                       Name="Pentium_Release|Win32"
+                       OutputDirectory="$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="1"
+                       CharacterSet="2">
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               FavorSizeOrSpeed="1"
+                               OptimizeForProcessor="1"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+                               RuntimeLibrary="4"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="TRUE"
+                               DebugInformationFormat="3"/>
+                       <Tool
+                               Name="VCCustomBuildTool"/>
+                       <Tool
+                               Name="VCLinkerTool"
+                               OutputFile="../../../bin/Scilex.exe"
+                               LinkIncremental="1"
+                               GenerateDebugInformation="TRUE"
+                               SubSystem="1"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               TargetMachine="1"/>
+                       <Tool
+                               Name="VCMIDLTool"/>
+                       <Tool
+                               Name="VCPostBuildEventTool"/>
+                       <Tool
+                               Name="VCPreBuildEventTool"/>
+                       <Tool
+                               Name="VCPreLinkEventTool"/>
+                       <Tool
+                               Name="VCResourceCompilerTool"/>
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"/>
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"/>
+                       <Tool
+                               Name="VCWebDeploymentTool"/>
+                       <Tool
+                               Name="VCManagedWrapperGeneratorTool"/>
+                       <Tool
+                               Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+                       <File
+                               RelativePath=".\CScilex.c">
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Header Files"
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+               </Filter>
+               <Filter
+                       Name="Resource Files"
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+                       <File
+                               RelativePath="..\Rscilab.rc">
+                       </File>
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/scilab/routines/wsci/CScilex/Makefile.mak b/scilab/routines/wsci/CScilex/Makefile.mak
new file mode 100644 (file)
index 0000000..a38be82
--- /dev/null
@@ -0,0 +1,28 @@
+SHELL = /bin/sh
+SCIDIR=../../..
+SCIDIR1=..\..\..
+LIBRARY = $(SCIDIR)/libs/wsci.lib
+
+
+OBJSC = CScilex.obj
+
+OBJSF = 
+
+include ../../../Makefile.incl.mak
+CFLAGS = $(CC_OPTIONS) 
+FFLAGS = $(FC_OPTIONS)
+
+
+
+
+
+
+#=================== Console Scilex ===========================
+
+all:: ../../../bin/CScilex.exe
+
+../../../bin/CScilex.exe       : CScilex.obj
+        
+
+
+CScilex.obj : CScilex.c 
index c16ac1c..774acdf 100644 (file)
@@ -111,7 +111,6 @@ int Pause (LPSTR str);
 int SciWinGetPlatformId ();
 
 
-int MyWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR szCmdLine, int iCmdShow);
 
 void add_sci_argv(char *p);
 int sci_iargc();
@@ -148,9 +147,11 @@ int WriteStr (char *s, FILE * file);
 int WriteKey (char c, FILE * file);
 
 
+int WINAPI Windows_Main (HINSTANCE hInstance, HINSTANCE hPrevInstance,PSTR szCmdLine, int iCmdShow);
+int Console_Main(int argc, char **argv);
+int MAIN__ ();
 
 void WinExit (void);
-void CreateProcessScilex(char *cmdline,int NumberScilex,int CodeActionWin98);
 void CreateThreadSplashscreen(void);
 DWORD WINAPI ThreadSplashscreen(LPVOID lpParam );
 
@@ -178,23 +179,9 @@ BOOL IsAScicosFileCOSF(char *chainefichier);
 /* Retourne un numéro valide pour nommer les fenetres associées à ce process */
 int FindFreeScilexNumber(void);
 
-/* Sauvegarde des parametres eventuels de la ligne de commandes */
-int SaveArgs(LPSTR saveargv);
-
-/* Teste si la chaine de caracteres line correspond à un fichier existant */
-/* retourne le nom du fichier au format 8.3 pour Scipad dans filename*/
-/* retourne le code option */
-/*-1 rien ou invalide */
-/* 0 -o open with scipad*/
-/* 1 execute */
-/* 2 print file */
-/* retourne TRUE si OK */
-int CleanFileName(char *line,char *filename,int *option);
-
-
 
 /* Suivant la commande Via menu ouvre, edit, imprime ...*/
-extern void DoubleDoubleSlash(char *pathout,char *pathin);
+extern void ReplaceSlash(char *pathout,char *pathin);
 int CommandByFileExtension(char *fichier,int OpenCode,char *Cmd);
 /* Imprime le fichier sur l'imprimante par défaut */
 void PrintFileText(char *fichier);
index 3ede73e..cd0f0d7 100644 (file)
@@ -221,8 +221,8 @@ void CloseMacros (LPTW lptw);
 
 /*Boite de dialogue Load ou Save */
 BOOL OpenSaveSCIFile(HWND hWndParent,char *titre,BOOL read,char *FileExt,char *file);
-/* Double le caractere \ dans un chemin */
-void DoubleDoubleSlash(char *pathout,char *pathin);
+/* Remplace \ par / dans un chemin */
+void ReplaceSlash(char *pathout,char *pathin);
 /* WTEXT.C*/
 /* extern void PasteFunction(LPTW lptw); */
 extern void SwitchConsole(void);
diff --git a/scilab/routines/wsci/WScilex/Makefile.mak b/scilab/routines/wsci/WScilex/Makefile.mak
new file mode 100644 (file)
index 0000000..23a39cd
--- /dev/null
@@ -0,0 +1,28 @@
+SHELL = /bin/sh
+SCIDIR=../../..
+SCIDIR1=..\..\..
+LIBRARY = $(SCIDIR)/libs/wsci.lib
+
+
+OBJSC = WScilex.obj
+
+OBJSF = 
+
+include ../../../Makefile.incl.mak
+CFLAGS = $(CC_OPTIONS) 
+FFLAGS = $(FC_OPTIONS)
+
+
+
+
+
+
+#=================== Windows Scilex ===========================
+
+all:: ../../../bin/WScilex.exe
+
+../../../bin/WScilex.exe       : WScilex.obj
+        
+
+
+WScilex.obj : WScilex.c 
diff --git a/scilab/routines/wsci/WScilex/WScilex.c b/scilab/routines/wsci/WScilex/WScilex.c
new file mode 100644 (file)
index 0000000..4c0a75e
--- /dev/null
@@ -0,0 +1,159 @@
+
+/* STARTUP PROCEDURE FOR UNIX FORTRAN PROGRAMS */
+
+#include <Windows.h>
+#include "stdio.h"
+#include "signal.h"
+
+
+extern int WINAPI Windows_Main(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR szCmdLine, int iCmdShow);
+
+
+#ifndef SIGIOT
+#ifdef SIGABRT
+#define SIGIOT SIGABRT
+#endif
+#endif
+
+#ifndef KR_headers
+#undef VOID
+#include "stdlib.h"
+#endif
+
+#ifndef VOID
+#define VOID void
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef NO__STDC
+#define ONEXIT onexit
+  extern VOID f_exit();
+#else
+#ifndef KR_headers
+  extern void f_exit(void);
+#ifndef NO_ONEXIT
+#define ONEXIT atexit
+  extern int atexit(void (*)(void));
+#endif
+#else
+#ifndef NO_ONEXIT
+#define ONEXIT onexit
+  extern VOID f_exit();
+#endif
+#endif
+#endif
+
+#ifdef KR_headers
+  extern VOID f_init(), sig_die();
+  extern int MAIN__();
+#define Int /* int */
+#else
+  extern void f_init(void), sig_die(char*, int);
+  extern int MAIN__(void);
+#define Int int
+#endif
+
+  static VOID sigfdie(Int n)
+  {
+    sig_die("Floating Exception", 1);
+  }
+
+
+  static VOID sigidie(Int n)
+  {
+    sig_die("IOT Trap", 1);
+  }
+
+#ifdef SIGQUIT
+  static VOID sigqdie(Int n)
+  {
+    sig_die("Quit signal", 1);
+  }
+#endif
+
+
+  static VOID sigindie(Int n)
+  {
+    sig_die("Interrupt", 0);
+  }
+
+  static VOID sigtdie(Int n)
+  {
+    sig_die("Killed", 0);
+  }
+
+#ifdef SIGTRAP
+  static VOID sigtrdie(Int n)
+  {
+    sig_die("Trace trap", 1);
+  }
+#endif
+
+
+#ifdef KR_headers
+  VOID send_xarg(xxargc,xxargv);
+#else
+  void send_xarg(int xxargc, char **xxargv);
+#endif
+
+int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR szCmdLine, int iCmdShow)
+{
+    /** JPC : 1998 pour fair un dll **/
+       #define MAXCMDTOKENS 128
+       int argc=-1;
+       static LPSTR argv[MAXCMDTOKENS];
+       char *pFullCmdLine=NULL;
+       char *pFullCmdLineTmp=NULL;
+
+
+       pFullCmdLine=GetCommandLine();
+       pFullCmdLineTmp=(char *) malloc( sizeof(char)*( strlen(pFullCmdLine)+1 ) );
+       strcpy(pFullCmdLineTmp,pFullCmdLine);
+
+       argv[++argc] = strtok (pFullCmdLineTmp, " ");
+       
+       while (argv[argc] != NULL)
+       {
+               argv[++argc] = strtok(NULL, " ");
+       }
+
+    send_xarg(argc,argv);
+    signal(SIGFPE, sigfdie);   /* ignore underflow, enable overflow */
+#ifdef SIGIOT
+    signal(SIGIOT, sigidie);
+#endif
+#ifdef SIGTRAP
+    signal(SIGTRAP, sigtrdie);
+#endif
+#ifdef SIGQUIT
+    if(signal(SIGQUIT,sigqdie) == SIG_IGN)
+      signal(SIGQUIT, SIG_IGN);
+#endif
+    if(signal(SIGINT, sigindie) == SIG_IGN)
+      signal(SIGINT, SIG_IGN);
+    signal(SIGTERM,sigtdie);
+
+#ifdef pdp11
+    ldfps(01200); /* detect overflow as an exception */
+#endif
+
+    f_init();
+#ifndef NO_ONEXIT
+    ONEXIT(f_exit);
+#endif
+    Windows_Main(hInstance,hPrevInstance,szCmdLine, iCmdShow);
+#ifdef NO_ONEXIT
+    f_exit();
+#endif
+    exit(0);   /* exit(0) rather than return(0) to bypass Cray bug */
+    return 0;  /* For compilers that complain of missing return values; */
+               /* others will complain that this is unreachable code. */
+  }
+#ifdef __cplusplus
+}
+#endif
+
+
diff --git a/scilab/routines/wsci/WScilex/WScilex.rc b/scilab/routines/wsci/WScilex/WScilex.rc
new file mode 100644 (file)
index 0000000..3eee795
--- /dev/null
@@ -0,0 +1,61 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+LANGUAGE 9, 1
+#pragma code_page(1252)
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE  
+BEGIN
+    "resource.h\0"
+END
+
+2 TEXTINCLUDE  
+BEGIN
+    "#include ""afxres.h""\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE  
+BEGIN
+    "\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+#endif    // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
+
diff --git a/scilab/routines/wsci/WScilex/WScilex.vcproj b/scilab/routines/wsci/WScilex/WScilex.vcproj
new file mode 100644 (file)
index 0000000..cc7bb8e
--- /dev/null
@@ -0,0 +1,236 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="7.10"
+       Name="WScilex"
+       ProjectGUID="{CCD80549-EB9C-42AA-9B86-D687377E94F6}"
+       Keyword="Win32Proj">
+       <Platforms>
+               <Platform
+                       Name="Win32"/>
+       </Platforms>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory="Debug"
+                       IntermediateDirectory="Debug"
+                       ConfigurationType="1"
+                       CharacterSet="2">
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
+                               MinimalRebuild="TRUE"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="5"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="TRUE"
+                               DebugInformationFormat="4"/>
+                       <Tool
+                               Name="VCCustomBuildTool"/>
+                       <Tool
+                               Name="VCLinkerTool"
+                               OutputFile="../../../bin/WScilex.exe"
+                               LinkIncremental="2"
+                               GenerateDebugInformation="TRUE"
+                               ProgramDatabaseFile="$(OutDir)/WScilex.pdb"
+                               SubSystem="2"
+                               TargetMachine="1"/>
+                       <Tool
+                               Name="VCMIDLTool"/>
+                       <Tool
+                               Name="VCPostBuildEventTool"/>
+                       <Tool
+                               Name="VCPreBuildEventTool"/>
+                       <Tool
+                               Name="VCPreLinkEventTool"/>
+                       <Tool
+                               Name="VCResourceCompilerTool"/>
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"/>
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"/>
+                       <Tool
+                               Name="VCWebDeploymentTool"/>
+                       <Tool
+                               Name="VCManagedWrapperGeneratorTool"/>
+                       <Tool
+                               Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory="Release"
+                       IntermediateDirectory="Release"
+                       ConfigurationType="1"
+                       CharacterSet="2">
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               FavorSizeOrSpeed="1"
+                               OptimizeForProcessor="1"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
+                               RuntimeLibrary="4"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="TRUE"
+                               DebugInformationFormat="3"/>
+                       <Tool
+                               Name="VCCustomBuildTool"/>
+                       <Tool
+                               Name="VCLinkerTool"
+                               OutputFile="../../../bin/WScilex.exe"
+                               LinkIncremental="1"
+                               GenerateDebugInformation="TRUE"
+                               SubSystem="2"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               TargetMachine="1"/>
+                       <Tool
+                               Name="VCMIDLTool"/>
+                       <Tool
+                               Name="VCPostBuildEventTool"/>
+                       <Tool
+                               Name="VCPreBuildEventTool"/>
+                       <Tool
+                               Name="VCPreLinkEventTool"/>
+                       <Tool
+                               Name="VCResourceCompilerTool"/>
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"/>
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"/>
+                       <Tool
+                               Name="VCWebDeploymentTool"/>
+                       <Tool
+                               Name="VCManagedWrapperGeneratorTool"/>
+                       <Tool
+                               Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+               </Configuration>
+               <Configuration
+                       Name="PIV_Release|Win32"
+                       OutputDirectory="$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="1"
+                       CharacterSet="2">
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               FavorSizeOrSpeed="1"
+                               OptimizeForProcessor="3"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
+                               RuntimeLibrary="4"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="TRUE"
+                               DebugInformationFormat="3"/>
+                       <Tool
+                               Name="VCCustomBuildTool"/>
+                       <Tool
+                               Name="VCLinkerTool"
+                               OutputFile="../../../bin/WScilex.exe"
+                               LinkIncremental="1"
+                               GenerateDebugInformation="TRUE"
+                               SubSystem="2"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               TargetMachine="1"/>
+                       <Tool
+                               Name="VCMIDLTool"/>
+                       <Tool
+                               Name="VCPostBuildEventTool"/>
+                       <Tool
+                               Name="VCPreBuildEventTool"/>
+                       <Tool
+                               Name="VCPreLinkEventTool"/>
+                       <Tool
+                               Name="VCResourceCompilerTool"/>
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"/>
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"/>
+                       <Tool
+                               Name="VCWebDeploymentTool"/>
+                       <Tool
+                               Name="VCManagedWrapperGeneratorTool"/>
+                       <Tool
+                               Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+               </Configuration>
+               <Configuration
+                       Name="Pentium_Release|Win32"
+                       OutputDirectory="$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="1"
+                       CharacterSet="2">
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               FavorSizeOrSpeed="1"
+                               OptimizeForProcessor="1"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
+                               RuntimeLibrary="4"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="TRUE"
+                               DebugInformationFormat="3"/>
+                       <Tool
+                               Name="VCCustomBuildTool"/>
+                       <Tool
+                               Name="VCLinkerTool"
+                               OutputFile="../../../bin/WScilex.exe"
+                               LinkIncremental="1"
+                               GenerateDebugInformation="TRUE"
+                               SubSystem="2"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               TargetMachine="1"/>
+                       <Tool
+                               Name="VCMIDLTool"/>
+                       <Tool
+                               Name="VCPostBuildEventTool"/>
+                       <Tool
+                               Name="VCPreBuildEventTool"/>
+                       <Tool
+                               Name="VCPreLinkEventTool"/>
+                       <Tool
+                               Name="VCResourceCompilerTool"/>
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"/>
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"/>
+                       <Tool
+                               Name="VCWebDeploymentTool"/>
+                       <Tool
+                               Name="VCManagedWrapperGeneratorTool"/>
+                       <Tool
+                               Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+                       <File
+                               RelativePath=".\WScilex.c">
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Header Files"
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+                       <File
+                               RelativePath=".\resource.h">
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Resource Files"
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+                       <File
+                               RelativePath="..\Rscilab.rc">
+                       </File>
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/scilab/routines/wsci/WScilex/resource.h b/scilab/routines/wsci/WScilex/resource.h
new file mode 100644 (file)
index 0000000..6c6aa2a
--- /dev/null
@@ -0,0 +1,14 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by WScilex.rc
+
+// Next default values for new objects
+// 
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE        101
+#define _APS_NEXT_COMMAND_VALUE         40001
+#define _APS_NEXT_CONTROL_VALUE         1001
+#define _APS_NEXT_SYMED_VALUE           101
+#endif
+#endif
index bf3ca43..837cdc5 100644 (file)
@@ -1,3 +1,4 @@
+#define NameConsole "Console Scilab"
 /*******************************************
 * Original source : GNUPLOT - winmain.c
 * modified for Scilab
@@ -37,116 +38,177 @@ extern int getdiary();
 void C2F(diary) __PARAMS((char *str,int *n));
 void diary_nnl __PARAMS((char *str,int *n));
 
-
 /*-----------------------------------------------------------------------------------*/
-void InitWindowGraphDll(void)
-/* Modification Allan CORNET*/
-/* Novembre 2003 */
-/* Permet l'affichage des menus graphiques lors d'un appel de la DLL Scilab*/
+int MAIN__ ()
 {
-  
-  HINSTANCE hdllInstanceTmp=NULL;
-  char *p1 = (char*)getenv ("SCI");
-  hdllInstanceTmp=(HINSTANCE)GetModuleHandle("libScilab");
+       #ifndef __ABSC__
+       HANDLE x = GetModuleHandleA (0);
+       Windows_Main  (x, 0, GetCommandLineA (), 1);
+       #else
+       HMODULE x = GetModuleHandle (0);
+       Windows_Main (x, 0, GetCommandLine (), 1);
+       #endif
+       return (0);
+}
+/*-----------------------------------------------------------------------------------*/
+int Console_Main(int argc, char **argv)
+{
+  LPSTR tail;
+  int nowin = 0, argcount = 0, lpath = 0, pathtype=0;
+  char *path = NULL;
+  OSVERSIONINFO os;
+  int i=0;
+  my_argc = -1;
 
-  if (hdllInstanceTmp==NULL) 
+  WindowMode=FALSE;
+  
+  
+  for (i=0;i<argc;i++)
   {
-       MessageBox(NULL,"Do not find LibScilab.dll","Error",MB_ICONWARNING|MB_OK);
-       exit(1);
+         my_argv[i] = argv[i];
   }
-  hdllInstance=hdllInstanceTmp;
+  my_argc =argc;
+
+  //wsprintf(ScilexConsoleName,"%s",NameConsole);
+  //SetConsoleTitle(ScilexConsoleName);
+
+  os.dwOSVersionInfoSize = sizeof (os);
+  GetVersionEx (&os);
+  SciPlatformId = os.dwPlatformId;
+
+  szModuleName = (LPSTR) malloc (MAXSTR + 1);
+  CheckMemory (szModuleName);
   szModuleName = (LPSTR) malloc (MAXSTR + 1);
   CheckMemory (szModuleName);
 
-  strcpy(szModuleName,p1);
-  strcat(szModuleName,"\\bin\\");
-
+  /* get path to EXE */
+  GetModuleFileName (GetModuleHandle (0), (LPSTR) szModuleName, MAXSTR);
   if (CheckWScilabVersion (WSCILABVERSION))
     {
       MessageBox (NULL, "Wrong version of WSCILAB.DLL", szModuleName, MB_ICONSTOP | MB_OK);
       exit (1);
     }
 
-   szGraphMenuName = (LPSTR) malloc (strlen (szModuleName) + strlen (GRAPHMENUNAME) + 1);
-   CheckMemory (szGraphMenuName);
-   strcpy (szGraphMenuName, szModuleName);
-   strcat (szGraphMenuName, GRAPHMENUNAME);
-    
-   InitCommonControls ();
-  
-   graphwin.hInstance = hdllInstance;
-   graphwin.hPrevInstance = NULL;
-   graphwin.Title = "Scilab Graph";
-   graphwin.szMenuName = szGraphMenuName;
-   graphwin.lptw = &textwin;
-   graphwin.IniFile = "scilab.ini";
-   graphwin.IniSection = "SCILAB";
-    
-}
-/*-----------------------------------------------------------------------------------*/
-/*---------------------------------------------------
-* The WinMain function
-*---------------------------------------------------*/
+  if ((tail = strrchr (szModuleName, '\\')) != (LPSTR) NULL)
+    {
+      tail++;
+      *tail = '\0';
+    }
+  szModuleName = realloc (szModuleName, strlen (szModuleName) + 1);
+  CheckMemory (szModuleName);
 
-int MyWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
-LPSTR szCmdLine, int iCmdShow)
-{
-       WinMain (hInstance,hPrevInstance, szCmdLine,iCmdShow);
-       return 0;
+  szMenuName = (LPSTR) malloc (strlen (szModuleName) + strlen (MENUNAME) + 1);
+  CheckMemory (szMenuName);
+  strcpy (szMenuName, szModuleName);
+  strcat (szMenuName, MENUNAME);
+
+  szGraphMenuName = (LPSTR) malloc (strlen (szModuleName) + strlen (GRAPHMENUNAME) + 1);
+  CheckMemory (szGraphMenuName);
+  strcpy (szGraphMenuName, szModuleName);
+  strcat (szGraphMenuName, GRAPHMENUNAME);
+
+  /* Load common control library * */
+  InitCommonControls ();
+
+  textwin.hInstance = GetModuleHandle (0);
+  textwin.hPrevInstance = 0;
+  textwin.nCmdShow = 1;
+  textwin.Title = "Scilab";
+  textwin.IniFile = "scilab.ini";
+  textwin.IniSection = "SCILAB";
+  textwin.DragPre = "gl_name='";
+  textwin.DragPost = "';exec('SCI/util/GLoad.sce');\n";
+  textwin.lpmw = &menuwin;
+  textwin.ScreenSize.x = 120;
+  textwin.ScreenSize.y = 80;
+  textwin.KeyBufSize = 2048;
+  textwin.CursorFlag = 1;      /* scroll to cursor after \n & \r */
+  textwin.shutdown = (DLGPROC) ShutDown;
+  textwin.AboutText = (LPSTR) malloc (1024);
+  CheckMemory (textwin.AboutText);
+  strcat (textwin.AboutText, "Scilab is a free copyrighted software.\n\t");
+  strcpy (textwin.AboutText, "developed by Scilab Group (Inria/Enpc)\n\t");
+  strcat (textwin.AboutText, "\n\t email: scilab@inria.fr\n\t");
+  textwin.AboutText = realloc (textwin.AboutText, strlen (textwin.AboutText) + 1);
+  CheckMemory (textwin.AboutText);
+
+  menuwin.szMenuName = szMenuName;
+
+  pausewin.hInstance = GetModuleHandle (0);
+  pausewin.hPrevInstance = 0;
+  pausewin.Title = "Scilab pause";
+
+  graphwin.hInstance = GetModuleHandle (0);
+  graphwin.hPrevInstance = 0;
+  graphwin.Title = "Scilab Graph";
+  graphwin.szMenuName = szGraphMenuName;
+  graphwin.lptw = &textwin;
+  graphwin.IniFile = textwin.IniFile;
+  graphwin.IniSection = textwin.IniSection;
+  argcount = my_argc;
+  while (argcount > 0)
+    {
+      argcount--;
+      if (strcmp (my_argv[argcount], "-nw") == 0) nowin = 1;
+      else if (strcmp (my_argv[argcount], "-ns") == 0) startupf = 1;
+      else if ( strcmp(my_argv[argcount],"-nb") == 0) { sci_show_banner = 0; }
+      else if (strcmp (my_argv[argcount], "-nwni") == 0)
+               {
+                       nowin = 1;
+                       nointeractive = 1;
+               }
+      else if (strcmp (my_argv[argcount], "-f") == 0 && argcount + 1 < my_argc)
+               {
+                       path = my_argv[argcount + 1];
+                       lpath = strlen (my_argv[argcount + 1]);
+               }
+      else if (strcmp (my_argv[argcount], "-e") == 0 && argcount + 1 < my_argc)
+               {
+                       path = my_argv[argcount + 1];
+                       lpath = strlen (my_argv[argcount + 1]);
+                       pathtype=1;
+               }
+      else if ( strcmp(my_argv[argcount],"-mem") == 0 && argcount + 1 < my_argc)
+               {
+                       memory = Max(atoi( my_argv[argcount + 1]),MIN_STACKSIZE );} 
+               }
+#ifndef __DLL__
+  /** when we don't use a dll version of the graphic library 
+    which is the case up to now **/
+  NoDll (GetModuleHandle (0));
+#endif
+  atexit (WinExit);
+  SciEnv ();
+  if (nowin == 1)
+    {
+      sci_windows_main (nowin, &startupf,path,pathtype, &lpath,memory);
+    }
+  else
+    {
+        MessageBox(NULL,"-nw or -nwni not found","Error",MB_ICONWARNING);
+    }
+  return 0;
 }
 /*-----------------------------------------------------------------------------------*/
-#ifndef __ABSC__
-int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,PSTR szCmdLine, int iCmdShow)
-#else
-int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR szCmdLine, int iCmdShow)
-#endif
+int WINAPI Windows_Main (HINSTANCE hInstance, HINSTANCE hPrevInstance,PSTR szCmdLine, int iCmdShow)
 {
-       char *pFullCmdLine=NULL;
-       char CmdlineToTransmit[MAX_PATH];
-       char CmdlineToTransmitTmp[MAX_PATH];
-       int Current_Number_of_Scilex=-1;
-       LPSTR tail;
-       int nowin = 0, argcount = 0, lpath = 0, pathtype=0;
        int i=0;
-       int nbarg=0;
-       char FileToEdit[MAX_PATH];
-       char *path = NULL;
-       OSVERSIONINFO os;
-        int CodeAction=-1;
-
-       WindowMode=TRUE;
-       my_argc = -1;
-       
-       pFullCmdLine=GetCommandLine();
-       //strcpy(CmdlineToTransmit,pFullCmdLine);
-       strcpy(CmdlineToTransmit,szCmdLine);
-       strcpy(CmdlineToTransmitTmp,szCmdLine);
-       
-       my_argv[++my_argc] = strtok (szCmdLine, " ");
-       while (my_argv[my_argc] != NULL)
-       {
-               my_argv[++my_argc] = strtok(NULL, " ");
-               
-       }
-       
-       /* Sauvegarde la ligne de commande */
-       if ( ! SaveArgs(CmdlineToTransmit) ) strcpy(CmdlineToTransmit,CmdlineToTransmitTmp);
-       
+       LPSTR tail;
        
-       /* Teste et prepare la ligne de commande*/
-       /* Donne leChoix utilisateur dans CodeAction "Open , Execute , Print" */
-       if ( CleanFileName(CmdlineToTransmit,FileToEdit,&CodeAction) == TRUE )
-       {
-               strcpy(CmdlineToTransmit,FileToEdit);
        
-               nbarg=1;
-       }
+       char FileName[MAX_PATH];
+       int nowin = 0, argcount = 0, lpath = 0, pathtype=0;
+       char *path = NULL;
        
+       HANDLE hOut = NULL;
+       int Current_Number_of_Scilex=-1; 
 
-       os.dwOSVersionInfoSize = sizeof (os);
-       GetVersionEx (&os);
-       SciPlatformId = os.dwPlatformId;
+       char *pFullCmdLine=NULL;
+
+       WindowMode=TRUE;
+       strcpy(FileName,"Empty");
 
+       
        szModuleName = (LPSTR) malloc (MAXSTR + 1);
        CheckMemory (szModuleName);
        szModuleName = (LPSTR) malloc (MAXSTR + 1);
@@ -178,6 +240,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR szCmdLine
        strcpy (szGraphMenuName, szModuleName);
        strcat (szGraphMenuName, GRAPHMENUNAME);
 
+
        /* Load common control library * */
        InitCommonControls ();
 
@@ -198,7 +261,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR szCmdLine
        textwin.AboutText = (LPSTR) malloc (1024);
        CheckMemory (textwin.AboutText);
        strcat (textwin.AboutText, "Scilab is a free copyrighted software.\n\t");
-       strcpy (textwin.AboutText, "developed by Scilab Group (Inria/Enpc)\n\t");
+       strcpy (textwin.AboutText, "developed by Scilab Consortium (Inria/Enpc)\n\t");
        strcat (textwin.AboutText, "\n\t email: scilab@inria.fr\n\t");
        textwin.AboutText = realloc (textwin.AboutText, strlen (textwin.AboutText) + 1);
        CheckMemory (textwin.AboutText);
@@ -216,50 +279,89 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR szCmdLine
        graphwin.lptw = &textwin;
        graphwin.IniFile = textwin.IniFile;
        graphwin.IniSection = textwin.IniSection;
-       argcount = my_argc;
-       /* Modification Allan CORNET le 22 Juillet 2003 */
-       /* Permet l'association pour ouverture directement avec scipad */
 
-       if ( (nbarg== 1)&& (IsAFile(FileToEdit) == TRUE) )
+       pFullCmdLine=GetCommandLine();
+       
+       
+       my_argv[++my_argc] = strtok (pFullCmdLine, " ");
+       while (my_argv[my_argc] != NULL)
        {
-               char Commande[MAX_PATH];
-               
-               CommandByFileExtension(FileToEdit,CodeAction,Commande);
-               if (CodeAction==2) exit(1); /*Sortie apres impression */
+               my_argv[++my_argc] = strtok(NULL, " ");
                
-               path = Commande;
-               lpath = strlen (Commande);
-               pathtype=1;
        }
-       else
+
+       for (i=1;i<my_argc;i++)
+       {
+               char ArgTmp[MAX_PATH];
+               strcpy(ArgTmp,my_argv[i]);
+               if  ( (strcmp (strupr(ArgTmp), "-NW") == 0) || (strcmp (strupr(ArgTmp), "-NWI") == 0) )
+               {
+                       MessageBox(NULL,"Not with Windows Console","Error",MB_ICONINFORMATION);
+                       exit(1);
+               }
+
+               if ( (strcmp (strupr(ArgTmp), "-H") == 0) ||
+                        (strcmp (strupr(ArgTmp), "-?") == 0) ||
+                        (strcmp (strupr(ArgTmp), "-HELP") == 0) )
+               {
+                       char Msg[1024];
+                       strcpy(Msg,"Wscilex <Options> : run Scilab.\n");
+                       strcat(Msg,"-ns:if this option is present the startup file SCI/scilab.star is not executed.\n"); 
+                       strcat(Msg,"-nb:if this option is present then the scilab welcome banner is not displayed.\n"); 
+                       strcat(Msg,"-l lang: it fixes the user language.\nThe possible lang values are 'fr' for french and 'eng' for english.\nThe default language is english. This default value is fixed the scilab.star file.\n"); 
+                       strcat(Msg,"-f file: Scilab script file is executed first into Scilab.\n"); 
+                       strcat(Msg,"-e instruction: Scilab instruction instruction is executed first into Scilab.");
+                       MessageBox(NULL,Msg,"Help",MB_ICONINFORMATION);
+                       exit(1);
+               }
+       }
+
+       argcount = my_argc;
+
+       if (argcount >= 2)
        {
+               if ( (strcmp (my_argv[1], "-X") == 0) ||
+                    (strcmp (my_argv[1], "-O") == 0) ||        
+                    (strcmp (my_argv[1], "-P") == 0) )
+               {
+                       char *Commande=NULL;
+                       int CodeAction=-1;
+                       int j=0;
+
+                       strcpy(FileName,my_argv[2]);
+                       for (j=3;j<argcount;j++)
+                       {
+                               strcat(FileName," ");
+                               strcat(FileName,my_argv[j]);
+                       }
+                       if (strcmp (my_argv[1], "-O") == 0) CodeAction=0;
+                       if (strcmp (my_argv[1], "-X") == 0) CodeAction=1; 
+                       if (strcmp (my_argv[1], "-P") == 0) CodeAction=2;
+
+                       Commande=(char*)malloc(MAX_PATH*sizeof(char));
+                       strcpy(Commande,"empty");
+                       CommandByFileExtension(FileName,CodeAction,Commande);
+                       
+                       
+                       my_argc=-1;
+                       my_argv[++my_argc] = strtok (Commande, " ");
+                       while (my_argv[my_argc] != NULL)
+                       {
+                               my_argv[++my_argc] = strtok(NULL, " ");
+                       }
+                       argcount = my_argc;
+               }
+       }       
        
        while (argcount > 0)
        {
-                char ArgTmp[MAX_PATH];
+        char ArgTmp[MAX_PATH];
                 
                argcount--;
                strcpy(ArgTmp,my_argv[argcount]);
-               if ( (strcmp (strupr(ArgTmp), "-H") == 0) || (strcmp (ArgTmp, "-?") == 0) || (strcmp (strupr(ArgTmp), "-HELP") == 0) )
-               {
-
-                       MessageBox(NULL,"-h help\n-f <script> Execute script file\n-nwni Console Mode\n-nb no banner\n-e\n-mem\n-nw\n-ns","Help",MB_ICONINFORMATION);
-
-                       exit(1);
-               }
                
-               if (strcmp (strupr(ArgTmp), "-NW") == 0)
-               {
-                       nowin = 1;
-               }
-               else if (strcmp (strupr(ArgTmp), "-NS") == 0)
-               startupf = 1;
+               if (strcmp (strupr(ArgTmp), "-NS") == 0) startupf = 1;
                else if ( strcmp(strupr(ArgTmp),"-NB") == 0) { sci_show_banner = 0; }
-               else if (strcmp (strupr(ArgTmp), "-NWNI") == 0)
-               {
-                       nowin = 1;
-                       nointeractive = 1;
-               }
                else if (strcmp (strupr(ArgTmp), "-F") == 0 && argcount + 1 < my_argc)
                {
                        path = my_argv[argcount + 1];
@@ -276,86 +378,118 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR szCmdLine
 
                        memory = Max(atoi( my_argv[argcount + 1]),MIN_STACKSIZE );
                }
-       }
-       }
+       }               
+
+       
        #ifndef __DLL__
-       /** when we don't use a dll version of the graphic library
-       which is the case up to now **/
-       NoDll (hInstance);
+               /** when we don't use a dll version of the graphic library
+               which is the case up to now **/
+               NoDll (hInstance);
        #endif
        atexit (WinExit);
        SciEnv ();
-       if (nowin == 1)
-       {
-               WindowMode=FALSE;
-               /** XXXX AllocConsole(); **/
-               sci_windows_main (nowin, &startupf,path,pathtype, &lpath,memory);
-       }
-       else
-       {
-
-               /* Mode Interface Windows */
-               STARTUPINFO InfoCurrentProcess; /* Utiliser pour récuperer le nom de la Console Courante sous W9x*/
 
-               Current_Number_of_Scilex=FindFreeScilexNumber();
+       Current_Number_of_Scilex=FindFreeScilexNumber();
+       wsprintf(ScilexConsoleName,"%s (%d)",NameConsole,Current_Number_of_Scilex);
+       Windows_Console_State=0; /* Console DOS Cachée par défaut */
 
-               /* Cree un process independant si Scilex est lancé depuis le shell */
-               /* Permet d'eviter d'avoir à utiliser runscilab cf. Version 2.7 */
-               
-               CreateProcessScilex(CmdlineToTransmit,Current_Number_of_Scilex,CodeAction);
+       
+       if (TextInit (&textwin))        exit (1);
 
-               /* Retrouve le nom de la fenetre Console pour Windows 9x */
-               if (SciWinGetPlatformId () == VER_PLATFORM_WIN32_WINDOWS)
-               {
-                       GetStartupInfo(&InfoCurrentProcess); /* Recupere le nom de la Console Courante */
-                       strcpy(ScilexConsoleName,InfoCurrentProcess.lpTitle); /* Sauvegarde du nom de la console */
-               }
+       AllocConsole();
+       SetConsoleTitle(ScilexConsoleName);
+       HideScilex(); /* Cache la fenetre Console Scilex (x) */
 
-               if (TextInit (&textwin))        exit (1);
+       /* Modification Allan CORNET 18/07/03 */
+       /* Splashscreen*/
+       if (sci_show_banner)    CreateThreadSplashscreen();
+       
+       
+       textwin.hIcon = LoadIcon (hInstance, "texticon");
+       SetClassLong (textwin.hWndParent, GCL_HICON, (DWORD) textwin.hIcon);
 
-               /* Modification Allan CORNET 18/07/03 */
-               /* Splashscreen*/
-               if (sci_show_banner) CreateThreadSplashscreen();
+       SetXsciOn ();
 
-               textwin.hIcon = LoadIcon (hInstance, "texticon");
-               SetClassLong (textwin.hWndParent, GCL_HICON, (DWORD) textwin.hIcon);
+       
+       ShowWindow (textwin.hWndParent, SW_SHOW);
+       
+       CreateConsoleScreenBuffer(GENERIC_READ|GENERIC_WRITE,FILE_SHARE_WRITE,NULL,CONSOLE_TEXTMODE_BUFFER,NULL);
+    freopen("CONOUT$", "wb", stdout); /* redirect stdout --> CONOUT$*/
+       freopen("CONOUT$", "wb", stderr); /* redirect stderr --> CONOUT$*/
 
-               SetXsciOn ();
-               
-               ShowWindow (textwin.hWndParent, SW_SHOW);
-               
-               sci_windows_main (nowin, &startupf, path,pathtype, &lpath,memory);
+       
+       if (sci_show_banner)
+       {
+               char line[80];
+               strcpy(line,"        __________________________________________\r\n");
+               printf(line);
+               wsprintf(line,"                       %s\r\n\n",VERSION);
+               printf(line);
+               strcpy(line,"              Copyright (C) 1989-2004 INRIA ENPC \r\n");
+               printf(line);
+               strcpy(line,"        __________________________________________\r\n");
+               printf(line);
+       }
 
-               /* Tue ce process pour fermeture correcte sous Windows 98 */
-               Kill_Scilex_Win98();
+       
+       sci_windows_main (nowin, &startupf, path,pathtype, &lpath,memory);
 
-       }
+       fclose(stdout);
+       fclose(stderr);
+       FreeConsole();
+       /* Tue ce process pour fermeture correcte sous Windows 98 */
+       Kill_Scilex_Win98();
+       
        return 0;
+
+       
 }
 /*-----------------------------------------------------------------------------------*/
-#define __MSC_NOC__
-#ifdef __MSC_NOC__
-/*
-we want Scilab to work in two mode
-as a console application or as a window
-application
-for a console application
-we do not directly use main for scilab
-since main is in libf2c which in truns call our MAIN__
-* */
-
-int MAIN__ ()
+void InitWindowGraphDll(void)
+/* Modification Allan CORNET*/
+/* November 2003 */
+/* Display graphic menus with a call of the DLL Scilab*/
+/* for Interface with Java */
 {
-       #ifndef __ABSC__
-       HANDLE x = GetModuleHandleA (0);
-       WinMain (x, 0, GetCommandLineA (), 1);
-       #else
-       HMODULE x = GetModuleHandle (0);
-       WinMain (x, 0, GetCommandLine (), 1);
-       #endif
-       return (0);
+  
+  HINSTANCE hdllInstanceTmp=NULL;
+  char *p1 = (char*)getenv ("SCI");
+  hdllInstanceTmp=(HINSTANCE)GetModuleHandle("libScilab");
+
+  if (hdllInstanceTmp==NULL) 
+  {
+       MessageBox(NULL,"Do not find LibScilab.dll","Error",MB_ICONWARNING|MB_OK);
+       exit(1);
+  }
+  hdllInstance=hdllInstanceTmp;
+  szModuleName = (LPSTR) malloc (MAXSTR + 1);
+  CheckMemory (szModuleName);
+
+  strcpy(szModuleName,p1);
+  strcat(szModuleName,"\\bin\\");
+
+  if (CheckWScilabVersion (WSCILABVERSION))
+    {
+      MessageBox (NULL, "Wrong version of WSCILAB.DLL", szModuleName, MB_ICONSTOP | MB_OK);
+      exit (1);
+    }
+
+   szGraphMenuName = (LPSTR) malloc (strlen (szModuleName) + strlen (GRAPHMENUNAME) + 1);
+   CheckMemory (szGraphMenuName);
+   strcpy (szGraphMenuName, szModuleName);
+   strcat (szGraphMenuName, GRAPHMENUNAME);
+    
+   InitCommonControls ();
+  
+   graphwin.hInstance = hdllInstance;
+   graphwin.hPrevInstance = NULL;
+   graphwin.Title = "Scilab Graph";
+   graphwin.szMenuName = szGraphMenuName;
+   graphwin.lptw = &textwin;
+   graphwin.IniFile = "scilab.ini";
+   graphwin.IniSection = "SCILAB";
+    
 }
-#endif
 /*-----------------------------------------------------------------------------------*/
 /* to simulate argv */
 void add_sci_argv(char *p)
@@ -364,7 +498,6 @@ void add_sci_argv(char *p)
 }
 /*-----------------------------------------------------------------------------------*/
 /* Fortran iargc and fgetarg implemented here */
-
 int sci_iargc()
 {
        #ifdef TEST
@@ -388,6 +521,8 @@ int sci_getarg(int *n,char *s,long int ls)
        t = my_argv[*n];
        else
        t = "";
+
+
        for(i = 0; i < ls && *t!='\0' ; ++i)
        *s++ = *t++;
        for( ; i<ls ; ++i)
@@ -812,11 +947,13 @@ int WriteKey (char c, FILE * file)
 /*-----------------------------------------------------------------------------------*/
 static void CheckMemory (LPSTR str)
 {
+#ifndef _DEBUG
        if (str == (LPSTR) NULL)
        {
                MessageBox (NULL, "out of memory", "Scilab", MB_ICONSTOP | MB_OK);
                exit (1);
        }
+#endif
 }
 /*-----------------------------------------------------------------------------------*/
 int Pause (LPSTR str)
@@ -876,7 +1013,6 @@ EXPORT int CALLBACK  ShutDown (void)
 /* Les variables d'environnements SCI,TCL_LIBRARY,TK_LIBRARY */
 /* sont définies directement dans scilex */
 /* scilex peut donc etre executé seul */
-
 static void SciEnv ()
 {
        char *p, *p1;
@@ -915,7 +1051,6 @@ static void SciEnv ()
        }
 }
 /********************************************************************************************************/
-
 /*----------------------------------------------------
 * set env variables (used when calling scilab from
 * other programs)
@@ -959,7 +1094,9 @@ void set_sci_env(char *p, char *wsci)
        {
                if ((p1 = getenv ("TEMP")) == (char *) 0)
                {
-                       sprintf (env, "PVM_TMP=c:\\tmp");
+                       char PathTmp[MAX_PATH];
+                       GetTempPath(MAX_PATH,PathTmp);
+                       sprintf (env, "PVM_TMP=%s",PathTmp);
                        putenv (env);
                }
                else
@@ -1035,137 +1172,6 @@ void Kill_Scilex(void)
 
 }
 /*-----------------------------------------------------------------------------------*/
-/* Allan CORNET 17/07/03 */
-/* Cree un process independant si Scilex est lancé depuis le shell */
-/* Permet d'eviter d'avoir à utiliser runscilab cf. Version 2.7 */
-void CreateProcessScilex(char *cmdline,int NumberScilex,int CodeActionWin98)
-{
-       char modname[MAX_PATH + 1];
-       
-       if ( ! GetModuleFileName (NULL, modname, MAX_PATH) ) exit (1);
-       else
-       {
-               if (SciWinGetPlatformId () == VER_PLATFORM_WIN32_WINDOWS)
-               {
-                       HWND hConsole;
-
-                       char TitleConsole[MAX_PATH];
-
-                       hConsole=FindWindow(NULL,"scilex");
-
-                       if (hConsole)
-                       {
-
-                               STARTUPINFO start;
-                               SECURITY_ATTRIBUTES sec_attrs;
-                               PROCESS_INFORMATION child;
-
-                               SetWindowText(hConsole,"");
-                               memset (&start, 0, sizeof (start));
-                               start.cb = sizeof (start);
-
-                               wsprintf(TitleConsole,"%s (%d)","Scilex", NumberScilex);
-                               start.lpTitle=TitleConsole;
-                               
-                               if ( IsAFile(cmdline) )
-                               {
-                                       char bufftemp[MAX_PATH];
-                                       wsprintf(bufftemp,"\"%s\"",cmdline);
-                                       strcpy(cmdline,bufftemp);
-                               }
-                                       
-
-                               strcat(modname," ");
-                               
-                               strcat(modname,cmdline);
-                               
-                               switch (CodeActionWin98)
-                               {
-                                       case 0:
-                                               strcat(modname," -o");
-                                       break;
-                                       case 1:
-                                               strcat(modname," -x");
-                                       break;
-                                       case 2:
-                                               strcat(modname," -p");
-                                       break;
-                                       default:
-                                       break;
-                               }
-                               strcat(modname," &\0");
-
-                               start.dwFlags = STARTF_USESHOWWINDOW;
-
-                               start.wShowWindow = SW_NORMAL;
-
-
-                               sec_attrs.nLength = sizeof (sec_attrs);
-                               sec_attrs.lpSecurityDescriptor = NULL;
-                               sec_attrs.bInheritHandle = FALSE;
-
-                               if (CreateProcess (NULL,modname, &sec_attrs, NULL, FALSE, CREATE_NEW_CONSOLE,  NULL, NULL, &start, &child))
-                               {
-                                       CloseHandle (child.hThread);
-                                       CloseHandle (child.hProcess);
-                               }
-                               exit (1);
-                       }
-
-               }
-               else
-               {
-                       char ConsoleName[MAX_PATH];
-                       GetConsoleTitle(ConsoleName,MAX_PATH);
-
-                       if (strcmp(ConsoleName,modname)==0)
-                       {
-                               /* Execution directe*/
-                               HWND hConsole;
-                               char TitleConsole[MAX_PATH];
-
-                               hConsole=FindWindow(NULL,ConsoleName);
-                               wsprintf(TitleConsole,"%s (%d)","Scilex", NumberScilex);
-                               strcpy(ScilexConsoleName,TitleConsole);
-                               SetWindowText(hConsole,TitleConsole);
-                       }
-                       else
-                       {
-
-                               /* Ligne de commandes ou raccourci */
-                               /* Creation d'un process separé */
-
-                               STARTUPINFO start;
-                               SECURITY_ATTRIBUTES sec_attrs;
-                               PROCESS_INFORMATION child;
-
-                               memset (&start, 0, sizeof (start));
-                               start.cb = sizeof (start);
-                               start.dwFlags = STARTF_USESHOWWINDOW;
-
-                               start.wShowWindow = SW_SHOWMINIMIZED;
-
-                               sec_attrs.nLength = sizeof (sec_attrs);
-                               sec_attrs.lpSecurityDescriptor = NULL;
-                               sec_attrs.bInheritHandle = FALSE;
-       
-                               /* Creation d'un nouveau process scilex independant du shell */
-                               if (CreateProcess (modname,cmdline, &sec_attrs, NULL, FALSE, CREATE_NEW_CONSOLE,  NULL, NULL, &start, &child))
-                               {
-                                       CloseHandle (child.hThread);
-                                       CloseHandle (child.hProcess);
-                               }
-
-                               /* Fermeture du process scilex courant*/
-                               /* pour laisser place a celui qui est autonome de la ligne de commande */
-                               exit (1);
-
-                       }
-               }
-       }
-
-}
-/*-----------------------------------------------------------------------------------*/
 void CreateThreadSplashscreen(void)
 {
        HANDLE hThread;
@@ -1199,11 +1205,11 @@ int FindFreeScilexNumber(void)
        int Number_of_Scilex=0;
        char NameScilex[MAX_PATH];
 
-       wsprintf(NameScilex,"%s (%d)","Scilex",Number_of_Scilex);
+       wsprintf(NameScilex,"%s (%d)",NameConsole,Number_of_Scilex);
        while ( FindWindow(NULL,NameScilex) )
        {
                Number_of_Scilex++;
-               wsprintf(NameScilex,"%s (%d)","Scilex",Number_of_Scilex);
+               wsprintf(NameScilex,"%s (%d)",NameConsole,Number_of_Scilex);
        }
 
        return Number_of_Scilex;
@@ -1261,7 +1267,7 @@ BOOL IsAGraphFilegraph(char *chainefichier)
        char ChaineTemp[MAX_PATH];
        char *buffer=NULL;
        char *lastdot=NULL;
-       int i=0;
+       unsigned int i=0;
        BOOL retour=FALSE;
 
        strcpy(ChaineTemp,chainefichier);
@@ -1277,7 +1283,7 @@ BOOL IsAGraphFilegraph(char *chainefichier)
                lastdot[i]=toupper(lastdot[i]);
        }
        /* Comparaison avec l'extension Graph */
-       if ( strcmp(lastdot,"GRAPH")==0) retour=TRUE;
+               if ( strcmp(lastdot,"GRAPH")==0) retour=TRUE;
 
        return retour;
 
@@ -1349,6 +1355,7 @@ BOOL IsAScicosFileCOS(char *chainefichier)
                lastdot[i]=toupper(lastdot[i]);
        }
        /* Comparaison avec l'extension COS */
+       
        if ( strcmp(lastdot,"COS")==0 ) retour=TRUE;
 
        return retour;
@@ -1380,200 +1387,88 @@ BOOL IsAScicosFileCOSF(char *chainefichier)
        return retour;
 }
 /*-----------------------------------------------------------------------------------*/
-/* Sauvegarde des parametres eventuels de la ligne de commandes */
-int SaveArgs(LPSTR saveargv)
+int CommandByFileExtension(char *fichier,int OpenCode,char *Cmd)
 {
-       int CodeRetour=TRUE;
-       char tmpsaveargv[MAX_PATH];
-       char params[MAX_PATH];
-       char *ScilexName=NULL;
-       char *Strfind=NULL;
-       /*char ScilexName[11];*/
-       int i=0;
-       int pos=0;
-       
+       int Retour=FALSE;
+       char FinalFileName[MAX_PATH];
+       char ShortPath[MAX_PATH];
+       char PathWScilex[MAX_PATH];
 
-       strcpy(tmpsaveargv,saveargv);
-       
-       ScilexName=strupr(tmpsaveargv);
-       /* recherche scilex.exe  dans la ligne passée*/
-       /* Strfind chaine en majuscule */
-       Strfind=strstr(ScilexName,ExecutableNameOfScilab);
        
-       if (Strfind) /* Nom de l'executable trouvé */
+       if (fichier[0]=='\"')
        {
-               pos=10; /*nombre de caracteres composants "scilex.exe" avec \0 à la fin */
-               strcpy(tmpsaveargv,Strfind);
+               char buffertemp[MAX_PATH];
+               int i=1;
                
-               if (strlen(tmpsaveargv)>10) /* il y a des parametres */
+               while (fichier[i] != '"')
                {
-                       if (tmpsaveargv[pos] == '\"') pos++;
-                       if (tmpsaveargv[pos] == ' ') pos++;
-                       for (i=pos;i<strlen(tmpsaveargv);i++)
+                       buffertemp[i-1]=fichier[i];
+                       i++;
+                       if (i>strlen(fichier))
                        {
-                               params[i-pos]=tmpsaveargv[i];
+                               i=strlen(fichier);
+                               break;
                        }
-                       params[i-pos]='\0';
-               
-               }
-               else strcpy(params,""); /* Pas de Parametres */
-       
-       }
-       else
-       {
-               strcpy(params,"");
-               CodeRetour=FALSE;
-       }
-       strcpy(saveargv,params);
-
-       return CodeRetour;
-}
-/*-----------------------------------------------------------------------------------*/
-/* Teste si la chaine de caracteres line correspond à un fichier existant */
-/* retourne le nom du fichier au format 8.3 pour Scipad */
-/* retourne TRUE si OK */
-int CleanFileName(char *line,char *filename,int *option)
-{
-       int Retour=FALSE;
-       char buffertemp[MAX_PATH];
-       int i=0;
-       
-       *option=-1;
-       
-       strcpy(buffertemp,line); /* Copie de line pour modification */
-       
-       /* Windows passe le nom des fichiers entre "" lorsque l'extension a été associé 
-       dans la base de registres */
-       if (buffertemp[0] == '"') /* On enleve les " au debut et à la fin */
-       {
-               
-               char stroption[3];
-               
-               i=1;
-               
-               while (line[i] != '"')
-               {
-                       buffertemp[i-1]=line[i];
-                       i++;
                }
                buffertemp[i-1]='\0';
-               
-               stroption[0]=line[i+2];
-               stroption[1]=line[i+3];
-               stroption[2]='\0';
-               
-               
-               if  ( (strcmp(stroption,"-o") == 0) || (strcmp(stroption,"-O") == 0) )
-               {
-                       *option=0; /* Code pour Open */
-               }
-               else
-               if ( (strcmp(stroption,"-x") == 0) || (strcmp(stroption,"-X") == 0) )
-               {
-                       *option=1; /* Code pour Execute */
-               }
-               else
-               if ( (strcmp(stroption,"-p") == 0) || (strcmp(stroption,"-P") == 0) )
-               {
-                       *option=2; /* Code pour Print */
-               }
-               else *option=-1; /* Code pour le reste */
-
-               strcpy(line,buffertemp); 
-               
-               
-               if  ( (IsAGraphFile(line) == TRUE) || (IsAScicosFile(line) == TRUE) )
-               {
-                       strcpy(filename,line); 
-                       Retour=IsAFile(line);
-               }
-               else
-               {
-                       GetShortPathName(line,filename,MAX_PATH); /* Recuperation du nom du fichier au format 8.3 */
-                       Retour=IsAFile(filename);
-               }
-               
-               
-               
-       }
-       else /* pas de " */
-       {
-               /*GetShortPathName(line,filename,MAX_PATH); /* Recuperation du nom du fichier au format 8.3 */
-               /*Retour=IsAFile(filename);*/
-               
-               Retour=FALSE;
+               strcpy(fichier,buffertemp);
        }
+       if (fichier[strlen(fichier)-1]=='\"') fichier[strlen(fichier)-1]='\0';
 
-       return Retour;
-       
-       
-       
-}
-/*-----------------------------------------------------------------------------------*/
-int CommandByFileExtension(char *fichier,int OpenCode,char *Cmd)
-{
-       int Retour=FALSE;
-       char chemin[MAX_PATH];
-       
-
-       /* Il faut doubler les \ pour transmettre chemin correctement à Scipad*/
-       DoubleDoubleSlash(chemin,fichier);
-               
-       if ( IsABinOrSavFile(fichier)== TRUE )
+       if (IsAFile(fichier))
        {
+               GetShortPathName(fichier,ShortPath,MAX_PATH); /* Recuperation du nom du fichier au format 8.3 */
+               ReplaceSlash(FinalFileName,ShortPath);
+               GetModuleFileName ((HINSTANCE)GetModuleHandle(NULL), PathWScilex, MAX_PATH);
+               Retour=TRUE;
 
-               /* C'est un fichier .BIN ou .SAV d'ou load */
-               wsprintf(Cmd,"load('%s');disp('%s loaded');",fichier,fichier);
-       }
-       else
-          {
-               /* Autre fichier .SCE ou .SCI d'ou Ouverture suivant code */
                switch (OpenCode)
                   {
-                       
-                       case 1: /* Execute */
-                       {
-                               if  ( IsAScicosFile(fichier)== TRUE )
+                       case 1: /* Execute -X*/
                                {
-                                       ExtensionFileIntoLowerCase(fichier);    
-                                       wsprintf(Cmd,"scicos('%s');disp('%s loaded');",fichier,fichier);
+                                       if ( IsABinOrSavFile(FinalFileName)== TRUE )
+                                       {
+                                               /* C'est un fichier .BIN ou .SAV d'ou load */
+                                               wsprintf(Cmd,"%s -e load('%s');disp('%s loaded'); ",PathWScilex,FinalFileName,FinalFileName);
+                                       }
+                                       else
+                                       if  ( IsAScicosFile(FinalFileName)== TRUE )
+                                       {
+                                               ExtensionFileIntoLowerCase(FinalFileName);      
+                                               wsprintf(Cmd,"%s -e scicos('%s');disp('%s loaded'); ",PathWScilex,FinalFileName,FinalFileName);
+                                       }
+                                       else
+                                       if ( IsAGraphFile(FinalFileName)== TRUE )
+                                       {
+                                               ExtensionFileIntoLowerCase(FinalFileName);      
+                                               wsprintf(Cmd,"%s -e edit_graph('%s');disp('%s loaded'); ",PathWScilex,FinalFileName,fichier);
+                                       }
+                                       else wsprintf(Cmd,"%s -e exec('%s'); ",PathWScilex,FinalFileName);
                                }
-                               else
-                               if ( IsAGraphFile(fichier)== TRUE )
-                               {
-                       
-                                       ExtensionFileIntoLowerCase(fichier);    
-                                       wsprintf(Cmd,"edit_graph('%s');disp('%s loaded');",fichier,fichier);
-                       
-                               }
-                               else
-                               wsprintf(Cmd,"exec('%s');",fichier);
-                       }
                        break;
-                       
-                       case 2: /* Print */
-                       /* A mettre en place plus precisément*/
-                       /* Pour le moment l'impression a lieu par l'editeur de fichier .txt défini par défaut */
-                       /* c-a-d notepad ou autre */
-                       {
+                       case 2: /* Print -P*/
+                               {
+                                       /* A mettre en place plus precisément*/
+                                       /* Pour le moment l'impression a lieu par l'editeur de fichier .txt défini par défaut */
+                                       /* c-a-d notepad ou autre */
+
                                MessageBox(NULL,"En cours de Dév.","Impression fichier",MB_OK);
-                               
-                                       
-                               /*
-                               PrintFileText(fichier);*/
-                               strcpy(Cmd,"");
-                       }
-                       break;
-                       case 0: case -1: /* Edit pour toute autre association*/
-                       wsprintf(Cmd,"scipad('%s')",chemin);
+                                                                       
+                               /*      PrintFileText(fichier);*/
+                               strcpy(Cmd," ");
+                               }
                        break;
-                       default: /* Probleme */
+                       case 0:default: /* Open -O*/
+                               {
+                                       wsprintf(Cmd,"%s -e scipad('%s'); ",PathWScilex,FinalFileName);
+                               }
                        break;
-                  }
-               
                
        }
        
+       }       
+       
+       
        return Retour;
 }
 /*-----------------------------------------------------------------------------------*/
index 19884c9..2315b12 100644 (file)
@@ -1418,29 +1418,24 @@ BOOL OpenSaveSCIFile(HWND hWndParent,char *titre,BOOL read,char *FileExt,char *f
        return Retour;
 }
 /*-----------------------------------------------------------------------------------*/
-/* Double le caractere \ dans un chemin */
-void DoubleDoubleSlash(char *pathout,char *pathin)
+/* Remplace \ par / dans un chemin */
+void ReplaceSlash(char *pathout,char *pathin)
 {
-       int l=0;
        int i=0;
        for (i=0;i < strlen(pathin);i++)
                {
 
                        if (pathin[i]=='\\')
                        {
-                               pathout[l]=pathin[i];
-                               pathout[l+1]='\\';
-                               l=l+2;
-
+                               pathout[i]='/';
                        }
                        else
                        {
-                               pathout[l]=pathin[i];
-                               l++;
+                               pathout[i]=pathin[i];
                        }
 
                }
-               pathout[l]='\0';
+       pathout[i]='\0';
 }
 /*-----------------------------------------------------------------------------------*/
 /****************************************
@@ -1923,7 +1918,9 @@ void UpdateFileNameMenu(LPTW lptw,int LangCode)
        LPSTR szModuleName;
        LPSTR tail;
        
-       HINSTANCE hInstance=(HINSTANCE) GetModuleHandle(NULL);                  
+       HINSTANCE hInstance=NULL;
+
+       hInstance=(HINSTANCE) GetModuleHandle(NULL);            
        szModuleName = (LPSTR) malloc (MAXSTR + 1);
        
        GetModuleFileName (hInstance, (LPSTR) szModuleName, MAXSTR);
index 89acd18..68c925d 100644 (file)
@@ -1166,8 +1166,7 @@ EXPORT LRESULT CALLBACK WndParentProc (HWND hwnd, UINT message, WPARAM wParam, L
        
        /* Modification Allan CORNET 15/07/03 */
        
-       Windows_Console_State=0; /* Console DOS Cachée par défaut */
-       HideScilex(); /* Cache la fenetre Console Scilex (x) */
+       
        /* Renomme la fenetre avec VERSION et numero x associé à la console*/  
        {
                char CopyNameConsole[MAX_PATH];
@@ -1177,9 +1176,9 @@ EXPORT LRESULT CALLBACK WndParentProc (HWND hwnd, UINT message, WPARAM wParam, L
                strcpy(CopyNameConsole,ScilexConsoleName);
                FirstOccurence = strtok(CopyNameConsole,"("); 
                SecondOccurence= strtok(NULL,"("); 
-               wsprintf(ScilexWindowName,"%s (%s",VERSION,SecondOccurence);
+       wsprintf(ScilexWindowName,"%s (%s",VERSION,SecondOccurence);
                
-               SetWindowText(hwnd,ScilexWindowName);  
+       SetWindowText(hwnd,ScilexWindowName);  
        
        }
 
@@ -2686,7 +2685,7 @@ void OpenSelection(LPTW lptw)
        {
                char Fichier[MAX_PATH];
                GetShortPathName(FileNameSCI,Fichier,MAX_PATH);
-               DoubleDoubleSlash(FileNameSCI,Fichier);
+               ReplaceSlash(FileNameSCI,Fichier);
                wsprintf(Command,"scipad('%s')",FileNameSCI);
                
                StoreCommand1 (Command, 2);
@@ -2697,7 +2696,7 @@ void OpenSelection(LPTW lptw)
        {
                char Fichier[MAX_PATH];
                GetShortPathName(FileNameSCE,Fichier,MAX_PATH);
-               DoubleDoubleSlash(FileNameSCE,Fichier);
+               ReplaceSlash(FileNameSCE,Fichier);
                wsprintf(Command,"scipad('%s')",FileNameSCE);
                StoreCommand1 (Command, 2);
                return ;                        
@@ -2707,7 +2706,7 @@ void OpenSelection(LPTW lptw)
        {
                char Fichier[MAX_PATH];
                GetShortPathName(FileName,Fichier,MAX_PATH);
-               DoubleDoubleSlash(FileName,Fichier);
+               ReplaceSlash(FileName,Fichier);
                //MessageBox(NULL,FileName,Fichier,MB_OK);
                wsprintf(Command,"scipad('%s')",FileName);
                StoreCommand1 (Command, 2);
@@ -2729,7 +2728,7 @@ void OpenSelection(LPTW lptw)
                        {
                                fclose(fp);
                                GetShortPathName(FileNameSCI,Fichier,MAX_PATH);
-                               DoubleDoubleSlash(FileNameSCI,Fichier);
+                               ReplaceSlash(FileNameSCI,Fichier);
                                wsprintf(Command,"scipad('%s')",FileNameSCI);
                                StoreCommand1 (Command, 2);                     
                        }