update projects (examples) for Visual Studio 2008
Allan Cornet [Tue, 29 Apr 2008 14:08:51 +0000 (14:08 +0000)]
+ fix some warning (windows)

scilab/modules/core/examples/call_scilab/c/visual_studio/CallSciVC.sln
scilab/modules/core/examples/call_scilab/c/visual_studio/CallSciVC.vcproj
scilab/modules/core/examples/call_scilab/c/visual_studio/CallsciC.c
scilab/modules/core/examples/call_scilab/fortran/example.sln
scilab/modules/core/includes/CallScilab.h
scilab/modules/core/src/c/SendScilabJobs.c

index 3382af5..d8804ca 100644 (file)
@@ -1,18 +1,24 @@
 
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual Studio 2005
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Callsci Example ", "CallSciVC.vcproj", "{0A05EAA1-BB0E-4221-A475-8A4DAD003CCA}"
 EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Win32 = Debug|Win32
+               Debug|x64 = Debug|x64
                Release|Win32 = Release|Win32
+               Release|x64 = Release|x64
        EndGlobalSection
        GlobalSection(ProjectConfigurationPlatforms) = postSolution
                {0A05EAA1-BB0E-4221-A475-8A4DAD003CCA}.Debug|Win32.ActiveCfg = Debug|Win32
                {0A05EAA1-BB0E-4221-A475-8A4DAD003CCA}.Debug|Win32.Build.0 = Debug|Win32
+               {0A05EAA1-BB0E-4221-A475-8A4DAD003CCA}.Debug|x64.ActiveCfg = Debug|x64
+               {0A05EAA1-BB0E-4221-A475-8A4DAD003CCA}.Debug|x64.Build.0 = Debug|x64
                {0A05EAA1-BB0E-4221-A475-8A4DAD003CCA}.Release|Win32.ActiveCfg = Release|Win32
                {0A05EAA1-BB0E-4221-A475-8A4DAD003CCA}.Release|Win32.Build.0 = Release|Win32
+               {0A05EAA1-BB0E-4221-A475-8A4DAD003CCA}.Release|x64.ActiveCfg = Release|x64
+               {0A05EAA1-BB0E-4221-A475-8A4DAD003CCA}.Release|x64.Build.0 = Release|x64
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
index 318f843..be469ab 100644 (file)
@@ -1,15 +1,20 @@
 <?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
        ProjectType="Visual C++"
-       Version="8,00"
+       Version="9,00"
        Name="Callsci Example "
        ProjectGUID="{0A05EAA1-BB0E-4221-A475-8A4DAD003CCA}"
+       RootNamespace="Callsci Example "
        Keyword="Win32Proj"
+       TargetFrameworkVersion="131072"
        >
        <Platforms>
                <Platform
                        Name="Win32"
                />
+               <Platform
+                       Name="x64"
+               />
        </Platforms>
        <ToolFiles>
        </ToolFiles>
@@ -40,6 +45,7 @@
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
+                               AdditionalIncludeDirectories="../../../../../core/includes"
                                PreprocessorDefinitions="_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
                                MinimalRebuild="true"
                                BasicRuntimeChecks="3"
@@ -65,6 +71,8 @@
                                GenerateDebugInformation="true"
                                ProgramDatabaseFile="$(OutDir)/CallSciVC.pdb"
                                SubSystem="1"
+                               RandomizedBaseAddress="1"
+                               DataExecutionPrevention="0"
                                TargetMachine="1"
                        />
                        <Tool
@@ -86,9 +94,6 @@
                                Name="VCAppVerifierTool"
                        />
                        <Tool
-                               Name="VCWebDeploymentTool"
-                       />
-                       <Tool
                                Name="VCPostBuildEventTool"
                        />
                </Configuration>
                        />
                        <Tool
                                Name="VCCLCompilerTool"
+                               AdditionalIncludeDirectories="../../../../../core/includes"
                                PreprocessorDefinitions="NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
                                RuntimeLibrary="0"
                                UsePrecompiledHeader="0"
                                SubSystem="1"
                                OptimizeReferences="2"
                                EnableCOMDATFolding="2"
+                               RandomizedBaseAddress="1"
+                               DataExecutionPrevention="0"
                                TargetMachine="1"
                        />
                        <Tool
                                Name="VCAppVerifierTool"
                        />
                        <Tool
-                               Name="VCWebDeploymentTool"
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Debug|x64"
+                       OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+                       ConfigurationType="1"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TargetEnvironment="3"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               AdditionalIncludeDirectories="../../../../../core/includes"
+                               PreprocessorDefinitions="_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
+                               MinimalRebuild="true"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="1"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="false"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               OutputFile="../../../../../../bin/CallSciVC.exe"
+                               LinkIncremental="2"
+                               GenerateDebugInformation="true"
+                               ProgramDatabaseFile="$(OutDir)/CallSciVC.pdb"
+                               SubSystem="1"
+                               RandomizedBaseAddress="1"
+                               DataExecutionPrevention="0"
+                               TargetMachine="17"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|x64"
+                       OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+                       ConfigurationType="1"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TargetEnvironment="3"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               AdditionalIncludeDirectories="../../../../../core/includes"
+                               PreprocessorDefinitions="NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
+                               RuntimeLibrary="0"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="false"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               OutputFile="../../../../../../bin/CallSciVC.exe"
+                               LinkIncremental="1"
+                               GenerateDebugInformation="true"
+                               SubSystem="1"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               RandomizedBaseAddress="1"
+                               DataExecutionPrevention="0"
+                               TargetMachine="17"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
                        />
                        <Tool
                                Name="VCPostBuildEventTool"
index 10f2736..be5d762 100644 (file)
@@ -5,17 +5,11 @@
 #pragma comment(lib, "../../../../../../bin/libScilab.lib")
 #pragma comment(lib, "../../../../../../bin/MALLOC.lib")
 /*--------------------------------------------------------------------------*/
-#include <windows.h>
-#include <math.h>
+#include <stdlib.h> 
 #include <stdio.h> 
-#include <string.h> 
-#include <conio.h> 
-
-#include "../../../../../../modules/core/includes/machine.h"
-#include "../../../../../../modules/core/includes/stack-c.h"
-#include "../../../../../../modules/core/includes/CallScilab.h"
-#define TRUE 1
-#define FALSE 0
+#include <string.h>
+#include "CallScilab.h"
+#include "stack-c.h"
 /*--------------------------------------------------------------------------*/
 /* See SCI/modules/core/includes/CallScilab.h */
 /*--------------------------------------------------------------------------*/
@@ -72,7 +66,6 @@ static int example2(void)
        while( ScilabHaveAGraph() )
        {
                ScilabDoOneEvent();
-               Sleep(1);
        }
        return 1; 
 }
@@ -95,10 +88,9 @@ static int example3(void)
        strcpy(JOBS[0],"A=1 ..");
        strcpy(JOBS[1],"+3;");
        strcpy(JOBS[2],"B = 8;");
-       /* strcpy(JOBS[2],"b = V_NOT_EXIST;"); */
        strcpy(JOBS[3],"+3;");
        strcpy(JOBS[4],"disp('C=');");
-       strcpy(JOBS[5],"C=A+B;disp(C);"); /* C = 12 */
+    strcpy(JOBS[5],"C=A+B;disp(C);"); /* C = 12 */
 
        code=SendScilabJobs(JOBS,SizeJOBS);
 
@@ -122,7 +114,6 @@ int main(void)
 /* int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR szCmdLine, int iCmdShow) */
 {
        if ( StartScilab(NULL,NULL,NULL) == FALSE ) printf("Error : StartScilab\n");
-
        printf("\nexample 1\n");
        example1();
        system("pause");
index d44e891..0f7080b 100644 (file)
@@ -1,6 +1,6 @@
 
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual Studio 2005
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
 Project("{6989167D-11E4-40FE-8C1A-2192A86A7E90}") = "example", "example.vfproj", "{B6C96508-D326-4691-A49D-FD9D8A369A44}"
 EndProject
 Global
index f978636..ae61ea6 100644 (file)
 
 #ifndef __CALLSCILAB__
 #define __CALLSCILAB__
+
 /*--------------------------------------------------------------------------*/
-#ifdef _MSC_VER
-  #include <windows.h>
-#endif
-#include <stdio.h>
-#include <string.h>
-#include "machine.h"
-#include "stack-c.h"
-#include "version.h"
+#include "BOOL.h"
 /*--------------------------------------------------------------------------*/
 /**
  * Disable TCL/TK and graphic interfaces 
@@ -86,7 +80,7 @@ int SendScilabJobs(char **jobs,int numberjobs);
 BOOL GetLastJob(char *JOB,int nbcharsJOB);
 
 /**
- * This procedure is the entry point to Scilab's event loop 
+* This procedure is the entry point to Scilab's event loop 
 */
 void ScilabDoOneEvent(void);
 
index 8119025..ff2890f 100644 (file)
@@ -9,10 +9,13 @@
  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  */
+#include <stdio.h>
 #include "CallScilab.h"
 #include "MALLOC.h"
 #include "scirun.h"
 #include "localization.h"
+#include "stack-c.h"
+#include "freeArrayOfString.h"
 #ifdef _MSC_VER
 #include "strdup_windows.h"
 #endif
@@ -29,20 +32,19 @@ int SendScilabJob(char *job)
 {
        int retCode = -1;
        int lencommand=0;
-       static char *command=NULL;
+       char *command=NULL;
        
-       char ScirunCommand[]="Err=execstr(TMP_EXEC_STRING,\"errcatch\",\"n\");quit;";
-       char ClearTmpVariables[]="clear TMP_EXEC_STRING;clear Err;quit;";
+       static char ScirunCommand[]="Err=execstr(TMP_EXEC_STRING,\"errcatch\",\"n\");quit;";
+       static char ClearTmpVariables[]="clear TMP_EXEC_STRING;clear Err;quit;";
        
-       lencommand=(int)strlen(job);
-       command=MALLOC(sizeof(char)*(lencommand+1));
+       command = strdup(job);
+       lencommand = (int)strlen(command);
 
        if (command)
        {
                /* clear prev. Err , TMP_EXEC_STRING scilab variables */
                C2F(scirun)(ClearTmpVariables,(long int)strlen(ClearTmpVariables));
 
-               strcpy(command,job);
                SetLastJob(command);
 
                /* Creation of a temp variable in Scilab */
@@ -131,30 +133,27 @@ int SendScilabJobs(char **jobs,int numberjobs)
 {
        #define BUFFERSECURITYSIZE 64
 
+       char *bufCommands = NULL;
        int retcode=-10;
 
        if (jobs)
        {
-               int i=0;
-               int nbcharsjobs=0;
-               char *bufCommands=NULL;
-               char **LOCALJOBS=NULL;
-
-               int jobsloop=0;
-
-               LOCALJOBS=(char**)MALLOC(sizeof(char*)*numberjobs);
+               char **LOCALJOBS = (char**)MALLOC(sizeof(char*)*numberjobs);
 
                if (LOCALJOBS)
                {
-                       for (i=0;i<numberjobs;i++)
+                       int i = 0;
+                       int nbcharsjobs = 0;
+
+                       for (i = 0; i < numberjobs ;i++)
                        {
                                if (jobs[i])
                                {
-                                       nbcharsjobs = nbcharsjobs+(int)strlen(jobs[i]);
+                                       nbcharsjobs = nbcharsjobs + (int)strlen(jobs[i]);
                                        LOCALJOBS[i] = strdup(jobs[i]);
                                        if (LOCALJOBS[i] == NULL)
                                        {
-                                               CleanBuffers(bufCommands,LOCALJOBS,numberjobs);
+                                               CleanBuffers(bufCommands,LOCALJOBS,i);
                                                fprintf(stderr,"Error : SendScilabJobs (1) 'LOCALJOBS[%d] MALLOC'.\n",i);       
                                                return retcode;
                                        }
@@ -170,20 +169,21 @@ int SendScilabJobs(char **jobs,int numberjobs)
 
                        if (bufCommands)
                        {
+                               int jobsloop = 0;
                                strcpy(bufCommands,"");
 
-                               for (jobsloop=0;jobsloop<numberjobs;jobsloop++)
+                               for (jobsloop = 0; jobsloop < numberjobs ; jobsloop++)
                                {
                                        if (jobs[jobsloop])
                                        {
-                                               char *currentline=NULL;
+                                               char *currentline = NULL;
                                                BOOL AddSemiColon;
 
                                                if (jobsloop == 0) AddSemiColon=FALSE;
                                                else  AddSemiColon=TRUE;
 
                                DOTDOTLOOP:
-                                               currentline=LOCALJOBS[jobsloop];
+                                               currentline = strdup(LOCALJOBS[jobsloop]);
 
                                                RemoveCharsFromEOL(currentline,'\n');
                                                RemoveComments(currentline);
@@ -194,14 +194,14 @@ int SendScilabJobs(char **jobs,int numberjobs)
                                                        RemoveCharsFromEOL(currentline,' ');
                                                        strcat(bufCommands,currentline);
                                                        jobsloop++;
-                                                       AddSemiColon=FALSE;
+                                                       AddSemiColon = FALSE;
                                                        goto DOTDOTLOOP;
                                                }
                                                else
                                                {
                                                        if (!AddSemiColon)
                                                        {
-                                                               AddSemiColon=TRUE;
+                                                               AddSemiColon = TRUE;
                                                                strcat(currentline,";");
                                                        }
                                                        else
@@ -210,11 +210,12 @@ int SendScilabJobs(char **jobs,int numberjobs)
                                                        }
                                                        
                                                        strcat(bufCommands,currentline);
+                                                       
                                                }
                                        }
                                }
 
-                               retcode=SendScilabJob(bufCommands);
+                               retcode = SendScilabJob(bufCommands);
 
                                CleanBuffers(bufCommands,LOCALJOBS,numberjobs);
                        }
@@ -291,18 +292,7 @@ static BOOL CleanBuffers(char *bufCommands,char **LOCALJOBS,int numberjobs)
 {
 
        if (bufCommands) {FREE(bufCommands);bufCommands=NULL;}
-
-       if (LOCALJOBS)
-       {
-               int i=0;
-               for (i=0; i < numberjobs;i++)
-               {
-                       if (LOCALJOBS[i]) {FREE(LOCALJOBS[i]);LOCALJOBS[i]=NULL;}
-               }
-               LOCALJOBS=NULL;
-       }
-
-       
+       freeArrayOfString(LOCALJOBS,numberjobs);
        return TRUE;
 
 }