rewrite dynlib management and addinter function 30/4330/1
Antoine ELIAS [Mon, 27 Jun 2011 09:57:32 +0000 (11:57 +0200)]
Change-Id: Iad16877633132bf71cbd8c4fd772800fff991417

31 files changed:
scilab/libs/dynamiclibrary/dynamiclibrary.vcxproj
scilab/libs/dynamiclibrary/includes/dynamiclibrary_windows.h
scilab/libs/dynamiclibrary/src/dynamiclibrary_windows.c
scilab/modules/dynamic_link/Makefile.am
scilab/modules/dynamic_link/Makefile.in
scilab/modules/dynamic_link/includes/addinter.h
scilab/modules/dynamic_link/includes/dynamic_link.h
scilab/modules/dynamic_link/includes/dynamic_link_gw.hxx
scilab/modules/dynamic_link/includes/gw_dynamic_link.h
scilab/modules/dynamic_link/macros/ilib_compile.sci
scilab/modules/dynamic_link/macros/ilib_gen_gateway.sci
scilab/modules/dynamic_link/macros/ilib_gen_loader.sci
scilab/modules/dynamic_link/sci_gateway/c/gw_dynamic_link.c
scilab/modules/dynamic_link/sci_gateway/cpp/dynamic_link_gw.cpp
scilab/modules/dynamic_link/sci_gateway/cpp/dynamic_link_gw.vcxproj
scilab/modules/dynamic_link/sci_gateway/cpp/dynamic_link_gw.vcxproj.filters
scilab/modules/dynamic_link/sci_gateway/cpp/sci_addinter.cpp [moved from scilab/modules/dynamic_link/sci_gateway/c/sci_addinter.c with 55% similarity]
scilab/modules/dynamic_link/sci_gateway/cpp/sci_c_link.cpp
scilab/modules/dynamic_link/sci_gateway/cpp/sci_link.cpp
scilab/modules/dynamic_link/sci_gateway/cpp/sci_ulink.cpp
scilab/modules/dynamic_link/src/c/dl_genErrorMessage.c
scilab/modules/dynamic_link/src/c/dl_genErrorMessage.h
scilab/modules/dynamic_link/src/c/dllinfo.h
scilab/modules/dynamic_link/src/c/dynamic_link.vcxproj
scilab/modules/dynamic_link/src/c/dynamic_link.vcxproj.filters
scilab/modules/dynamic_link/src/cpp/addinter.cpp [moved from scilab/modules/dynamic_link/src/c/addinter.c with 69% similarity]
scilab/modules/dynamic_link/src/cpp/dynamic_link.cpp [moved from scilab/modules/dynamic_link/src/c/dynamic_link.c with 52% similarity]
scilab/modules/dynamic_link/src/scripts/Makefile.incl.mak
scilab/modules/dynamic_link/tests/unit_tests/addinter.c
scilab/modules/system_env/includes/configvariable.hxx
scilab/modules/system_env/src/cpp/configvariable.cpp

index 258b255..e5eb111 100644 (file)
@@ -77,7 +77,7 @@
     <ClCompile>
       <AdditionalOptions>%(AdditionalOptions)</AdditionalOptions>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>includes;../../modules/core/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>includes;../../modules/core/includes;../../modules/localization/includes;../../libs/MALLOC/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>EXPORT_DYNAMICLIBRARY_DLL;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>Default</BasicRuntimeChecks>
     </Midl>
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>includes;../../modules/core/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>includes;../../modules/core/includes;../../modules/localization/includes;../../libs/MALLOC/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>EXPORT_DYNAMICLIBRARY_DLL;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>Default</BasicRuntimeChecks>
       <AdditionalOptions>%(AdditionalOptions)</AdditionalOptions>
       <Optimization>MaxSpeed</Optimization>
       <WholeProgramOptimization>false</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>includes;../../modules/core/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>includes;../../modules/core/includes;../../modules/localization/includes;../../libs/MALLOC/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>EXPORT_DYNAMICLIBRARY_DLL;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
       <TargetEnvironment>X64</TargetEnvironment>
     </Midl>
     <ClCompile>
-   <Optimization>MaxSpeed</Optimization>
+      <Optimization>MaxSpeed</Optimization>
       <WholeProgramOptimization>false</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>includes;../../modules/core/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>includes;../../modules/core/includes;../../modules/localization/includes;../../libs/MALLOC/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>EXPORT_DYNAMICLIBRARY_DLL;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
   <ItemGroup>
     <None Include="Makefile.am" />
   </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\modules\localization\src\localization.vcxproj">
+      <Project>{ecffeb0c-1eda-45ee-9a10-b18143852e17}</Project>
+    </ProjectReference>
+  </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
index d610661..2488f86 100644 (file)
@@ -53,13 +53,14 @@ IMPORT_EXPORT_DYNAMICLIBRARY_DLL BOOL FreeDynLibrary(DynLibHandle hInstance);
 * @param string that specifies the function
 * @return
 */
-IMPORT_EXPORT_DYNAMICLIBRARY_DLL DynLibFuncPtr GetDynLibFuncPtr(DynLibHandle hInstance,char *funcName);
+IMPORT_EXPORT_DYNAMICLIBRARY_DLL DynLibFuncPtr GetDynLibFuncPtr(DynLibHandle _hLib, char* _pstEntryPointName);
+IMPORT_EXPORT_DYNAMICLIBRARY_DLL DynLibFuncPtr GetDynLibFuncPtrW(DynLibHandle _hLib, wchar_t* _pwstEntryPointName);
 
 /**
 * return last dynamic linking error 
 * @return a string
 */
-IMPORT_EXPORT_DYNAMICLIBRARY_DLL char * GetLastDynLibError(void);
+IMPORT_EXPORT_DYNAMICLIBRARY_DLL  wchar_t* GetLastDynLibError(void);
 
 #endif /* __DYNAMICLIBRARY_WINDOWS_H__ */
 
index fa6a270..90a216e 100644 (file)
@@ -11,6 +11,8 @@
  */
 #include <string.h>
 #include "dynamiclibrary_windows.h"
+#include "charEncoding.h"
+#include "MALLOC.h"
 /*---------------------------------------------------------------------------*/
 IMPORT_EXPORT_DYNAMICLIBRARY_DLL DynLibHandle LoadDynLibraryW(wchar_t *libname)
 {
@@ -27,33 +29,44 @@ IMPORT_EXPORT_DYNAMICLIBRARY_DLL BOOL FreeDynLibrary(DynLibHandle hInstance)
        return (BOOL) FreeLibrary((HMODULE) hInstance);
 }
 /*---------------------------------------------------------------------------*/
-IMPORT_EXPORT_DYNAMICLIBRARY_DLL DynLibFuncPtr GetDynLibFuncPtr(DynLibHandle hInstance,char *funcName)
+IMPORT_EXPORT_DYNAMICLIBRARY_DLL DynLibFuncPtr GetDynLibFuncPtr(DynLibHandle _hLib, char* _pstEntryPointName)
 {
-       DynLibFuncPtr retFuncPtr = NULL ;
-       
-       if (hInstance)
+       DynLibFuncPtr retFuncPtr = NULL;
+       if (_hLib)
        {
-               retFuncPtr = GetProcAddress(hInstance, funcName);
+               retFuncPtr = GetProcAddress(_hLib, _pstEntryPointName);
        }
        
        return retFuncPtr;
 }
 /*---------------------------------------------------------------------------*/
-IMPORT_EXPORT_DYNAMICLIBRARY_DLL char * GetLastDynLibError(void)
+IMPORT_EXPORT_DYNAMICLIBRARY_DLL DynLibFuncPtr GetDynLibFuncPtrW(DynLibHandle _hLib, wchar_t* _pwstEntryPointName)
+{
+    DynLibFuncPtr retFuncPtr = NULL;
+    if (_hLib)
+    {
+        char* pstEntryPoint = wide_string_to_UTF8(_pwstEntryPointName);
+        retFuncPtr = GetProcAddress(_hLib, pstEntryPoint);
+        FREE(pstEntryPoint);
+    }
+    return retFuncPtr;
+}
+/*---------------------------------------------------------------------------*/
+IMPORT_EXPORT_DYNAMICLIBRARY_DLL wchar_t* GetLastDynLibError(void)
 {
-       static char buffer[512];
+       static wchar_t buffer[512];
        DWORD dw = GetLastError(); 
        DWORD source = 0;
 
        if (dw == 0)
        {
-               strcpy(buffer, "Unknown Error");
+               wcscpy(buffer, L"Unknown Error");
        }
-       else if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
+    else if (FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |
                        FORMAT_MESSAGE_IGNORE_INSERTS, &source, dw, 0,
                        buffer, 512, NULL) == 0) 
        {
-                       strcpy(buffer, "Unknown Error");
+                       wcscpy(buffer, L"Unknown Error");
        }
 
        return buffer;
index 12566d6..3e3159b 100644 (file)
@@ -5,15 +5,16 @@
 
 
 DYNAMIC_LINK_C_SOURCES = \
-    src/c/addinter.c \
-    src/c/dynamic_link.c \
     src/c/dl_genErrorMessage.c \
     src/c/GetFunctionByName.c \
     src/c/ilib_verbose.c
 
+DYNAMIC_LINK_CPP_SOURCES = \
+    src/cpp/dynamic_link.cpp \
+    src/cpp/addinter.cpp
+
 GATEWAY_C_SOURCES = \
     sci_gateway/c/gw_dynamic_link.c \
-    sci_gateway/c/sci_addinter.c \
     sci_gateway/c/sci_call.c
 
 GATEWAY_CPP_SOURCES = \
@@ -22,7 +23,8 @@ GATEWAY_CPP_SOURCES = \
     sci_gateway/cpp/sci_c_link.cpp \
     sci_gateway/cpp/sci_ulink.cpp \
     sci_gateway/cpp/sci_ilib_verbose.cpp \
-    sci_gateway/cpp/sci_getdynlibext.cpp
+    sci_gateway/cpp/sci_getdynlibext.cpp \
+    sci_gateway/cpp/sci_addinter.cpp
 
 
 GATEWAY_FORTRAN_SOURCES = \
@@ -45,20 +47,25 @@ libscidynamic_link_la_CFLAGS = \
 libscidynamic_link_la_CPPFLAGS = \
        -I$(srcdir)/includes/ \
        -I$(srcdir)/src/c/ \
+    -I$(top_srcdir)/libs/dynamiclibrary/includes \
+    -I$(top_srcdir)/modules/io/includes \
     -I$(top_srcdir)/modules/api_scilab/includes \
        -I$(top_srcdir)/modules/operations/includes \
        -I$(top_srcdir)/modules/symbol/includes \
        -I$(top_srcdir)/modules/types/includes \
        -I$(top_srcdir)/modules/output_stream/includes \
        -I$(top_srcdir)/modules/functions_manager/includes \
-       -I$(top_srcdir)/modules/abstractSyntaxTree/includes
+       -I$(top_srcdir)/modules/abstractSyntaxTree/includes \
+    -I$(top_srcdir)/modules/string/includes \
+    -I$(top_srcdir)/modules/fileio/includes \
+    -I$(top_srcdir)/modules/system_env/includes
 
 pkglib_LTLIBRARIES = libscidynamic_link.la
 noinst_LTLIBRARIES = libscidynamic_link-algo.la
 
 
 libscidynamic_link_la_LDFLAGS = -version-info $(SCILAB_LIBRARY_VERSION)
-libscidynamic_link_algo_la_SOURCES = $(DYNAMIC_LINK_C_SOURCES)
+libscidynamic_link_algo_la_SOURCES = $(DYNAMIC_LINK_C_SOURCES) $(DYNAMIC_LINK_CPP_SOURCES)
 libscidynamic_link_la_SOURCES = $(GATEWAY_C_SOURCES) $(GATEWAY_FORTRAN_SOURCES) $(GATEWAY_CPP_SOURCES)
 libscidynamic_link_algo_la_CFLAGS = $(libscidynamic_link_la_CFLAGS)
 libscidynamic_link_algo_la_CPPFLAGS = $(libscidynamic_link_la_CPPFLAGS)
index 25bc325..6b32474 100644 (file)
@@ -112,18 +112,15 @@ am__installdirs = "$(DESTDIR)$(pkglibdir)" \
        "$(DESTDIR)$(libscidynamic_link_la_scriptdir)"
 LTLIBRARIES = $(noinst_LTLIBRARIES) $(pkglib_LTLIBRARIES)
 libscidynamic_link_algo_la_LIBADD =
-am__objects_1 = libscidynamic_link_algo_la-addinter.lo \
-       libscidynamic_link_algo_la-dynamic_link.lo \
-       libscidynamic_link_algo_la-dl_genErrorMessage.lo \
+am__objects_1 = libscidynamic_link_algo_la-dl_genErrorMessage.lo \
        libscidynamic_link_algo_la-GetFunctionByName.lo \
        libscidynamic_link_algo_la-ilib_verbose.lo
-am_libscidynamic_link_algo_la_OBJECTS = $(am__objects_1)
+am__objects_2 = libscidynamic_link_algo_la-dynamic_link.lo \
+       libscidynamic_link_algo_la-addinter.lo
+am_libscidynamic_link_algo_la_OBJECTS = $(am__objects_1) \
+       $(am__objects_2)
 libscidynamic_link_algo_la_OBJECTS =  \
        $(am_libscidynamic_link_algo_la_OBJECTS)
-libscidynamic_link_algo_la_LINK = $(LIBTOOL) --tag=CC \
-       $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
-       $(libscidynamic_link_algo_la_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
-       $(LDFLAGS) -o $@
 libscidynamic_link_la_DEPENDENCIES = libscidynamic_link-algo.la \
        $(top_builddir)/modules/arnoldi/libsciarnoldi.la \
        $(top_builddir)/modules/elementary_functions/libscielementary_functions.la \
@@ -131,18 +128,18 @@ libscidynamic_link_la_DEPENDENCIES = libscidynamic_link-algo.la \
        $(top_builddir)/modules/string/libscistring.la \
        $(top_builddir)/libs/MALLOC/libscimalloc.la \
        $(top_builddir)/modules/output_stream/libscioutput_stream.la
-am__objects_2 = libscidynamic_link_la-gw_dynamic_link.lo \
-       libscidynamic_link_la-sci_addinter.lo \
+am__objects_3 = libscidynamic_link_la-gw_dynamic_link.lo \
        libscidynamic_link_la-sci_call.lo
-am__objects_3 = sci_fort.lo
-am__objects_4 = libscidynamic_link_la-dynamic_link_gw.lo \
+am__objects_4 = sci_fort.lo
+am__objects_5 = libscidynamic_link_la-dynamic_link_gw.lo \
        libscidynamic_link_la-sci_link.lo \
        libscidynamic_link_la-sci_c_link.lo \
        libscidynamic_link_la-sci_ulink.lo \
        libscidynamic_link_la-sci_ilib_verbose.lo \
-       libscidynamic_link_la-sci_getdynlibext.lo
-am_libscidynamic_link_la_OBJECTS = $(am__objects_2) $(am__objects_3) \
-       $(am__objects_4)
+       libscidynamic_link_la-sci_getdynlibext.lo \
+       libscidynamic_link_la-sci_addinter.lo
+am_libscidynamic_link_la_OBJECTS = $(am__objects_3) $(am__objects_4) \
+       $(am__objects_5)
 libscidynamic_link_la_OBJECTS = $(am_libscidynamic_link_la_OBJECTS)
 libscidynamic_link_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
        $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
@@ -446,15 +443,16 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 yacc_present = @yacc_present@
 DYNAMIC_LINK_C_SOURCES = \
-    src/c/addinter.c \
-    src/c/dynamic_link.c \
     src/c/dl_genErrorMessage.c \
     src/c/GetFunctionByName.c \
     src/c/ilib_verbose.c
 
+DYNAMIC_LINK_CPP_SOURCES = \
+    src/cpp/dynamic_link.cpp \
+    src/cpp/addinter.cpp
+
 GATEWAY_C_SOURCES = \
     sci_gateway/c/gw_dynamic_link.c \
-    sci_gateway/c/sci_addinter.c \
     sci_gateway/c/sci_call.c
 
 GATEWAY_CPP_SOURCES = \
@@ -463,7 +461,8 @@ GATEWAY_CPP_SOURCES = \
     sci_gateway/cpp/sci_c_link.cpp \
     sci_gateway/cpp/sci_ulink.cpp \
     sci_gateway/cpp/sci_ilib_verbose.cpp \
-    sci_gateway/cpp/sci_getdynlibext.cpp
+    sci_gateway/cpp/sci_getdynlibext.cpp \
+    sci_gateway/cpp/sci_addinter.cpp
 
 GATEWAY_FORTRAN_SOURCES = \
     sci_gateway/fortran/sci_fort.f
@@ -485,18 +484,23 @@ libscidynamic_link_la_CFLAGS = \
 libscidynamic_link_la_CPPFLAGS = \
        -I$(srcdir)/includes/ \
        -I$(srcdir)/src/c/ \
+    -I$(top_srcdir)/libs/dynamiclibrary/includes \
+    -I$(top_srcdir)/modules/io/includes \
     -I$(top_srcdir)/modules/api_scilab/includes \
        -I$(top_srcdir)/modules/operations/includes \
        -I$(top_srcdir)/modules/symbol/includes \
        -I$(top_srcdir)/modules/types/includes \
        -I$(top_srcdir)/modules/output_stream/includes \
        -I$(top_srcdir)/modules/functions_manager/includes \
-       -I$(top_srcdir)/modules/abstractSyntaxTree/includes
+       -I$(top_srcdir)/modules/abstractSyntaxTree/includes \
+    -I$(top_srcdir)/modules/string/includes \
+    -I$(top_srcdir)/modules/fileio/includes \
+    -I$(top_srcdir)/modules/system_env/includes
 
 pkglib_LTLIBRARIES = libscidynamic_link.la
 noinst_LTLIBRARIES = libscidynamic_link-algo.la
 libscidynamic_link_la_LDFLAGS = -version-info $(SCILAB_LIBRARY_VERSION)
-libscidynamic_link_algo_la_SOURCES = $(DYNAMIC_LINK_C_SOURCES)
+libscidynamic_link_algo_la_SOURCES = $(DYNAMIC_LINK_C_SOURCES) $(DYNAMIC_LINK_CPP_SOURCES)
 libscidynamic_link_la_SOURCES = $(GATEWAY_C_SOURCES) $(GATEWAY_FORTRAN_SOURCES) $(GATEWAY_CPP_SOURCES)
 libscidynamic_link_algo_la_CFLAGS = $(libscidynamic_link_la_CFLAGS)
 libscidynamic_link_algo_la_CPPFLAGS = $(libscidynamic_link_la_CPPFLAGS)
@@ -680,7 +684,7 @@ clean-pkglibLTLIBRARIES:
          rm -f "$${dir}/so_locations"; \
        done
 libscidynamic_link-algo.la: $(libscidynamic_link_algo_la_OBJECTS) $(libscidynamic_link_algo_la_DEPENDENCIES) 
-       $(libscidynamic_link_algo_la_LINK)  $(libscidynamic_link_algo_la_OBJECTS) $(libscidynamic_link_algo_la_LIBADD) $(LIBS)
+       $(CXXLINK)  $(libscidynamic_link_algo_la_OBJECTS) $(libscidynamic_link_algo_la_LIBADD) $(LIBS)
 libscidynamic_link.la: $(libscidynamic_link_la_OBJECTS) $(libscidynamic_link_la_DEPENDENCIES) 
        $(libscidynamic_link_la_LINK) -rpath $(pkglibdir) $(libscidynamic_link_la_OBJECTS) $(libscidynamic_link_la_LIBADD) $(LIBS)
 install-libscidynamic_link_la_scriptSCRIPTS: $(libscidynamic_link_la_script_SCRIPTS)
@@ -760,20 +764,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(LTCOMPILE) -c -o $@ $<
 
-libscidynamic_link_algo_la-addinter.lo: src/c/addinter.c
-@am__fastdepCC_TRUE@   $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscidynamic_link_algo_la_CPPFLAGS) $(CPPFLAGS) $(libscidynamic_link_algo_la_CFLAGS) $(CFLAGS) -MT libscidynamic_link_algo_la-addinter.lo -MD -MP -MF $(DEPDIR)/libscidynamic_link_algo_la-addinter.Tpo -c -o libscidynamic_link_algo_la-addinter.lo `test -f 'src/c/addinter.c' || echo '$(srcdir)/'`src/c/addinter.c
-@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscidynamic_link_algo_la-addinter.Tpo $(DEPDIR)/libscidynamic_link_algo_la-addinter.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='src/c/addinter.c' object='libscidynamic_link_algo_la-addinter.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscidynamic_link_algo_la_CPPFLAGS) $(CPPFLAGS) $(libscidynamic_link_algo_la_CFLAGS) $(CFLAGS) -c -o libscidynamic_link_algo_la-addinter.lo `test -f 'src/c/addinter.c' || echo '$(srcdir)/'`src/c/addinter.c
-
-libscidynamic_link_algo_la-dynamic_link.lo: src/c/dynamic_link.c
-@am__fastdepCC_TRUE@   $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscidynamic_link_algo_la_CPPFLAGS) $(CPPFLAGS) $(libscidynamic_link_algo_la_CFLAGS) $(CFLAGS) -MT libscidynamic_link_algo_la-dynamic_link.lo -MD -MP -MF $(DEPDIR)/libscidynamic_link_algo_la-dynamic_link.Tpo -c -o libscidynamic_link_algo_la-dynamic_link.lo `test -f 'src/c/dynamic_link.c' || echo '$(srcdir)/'`src/c/dynamic_link.c
-@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscidynamic_link_algo_la-dynamic_link.Tpo $(DEPDIR)/libscidynamic_link_algo_la-dynamic_link.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='src/c/dynamic_link.c' object='libscidynamic_link_algo_la-dynamic_link.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscidynamic_link_algo_la_CPPFLAGS) $(CPPFLAGS) $(libscidynamic_link_algo_la_CFLAGS) $(CFLAGS) -c -o libscidynamic_link_algo_la-dynamic_link.lo `test -f 'src/c/dynamic_link.c' || echo '$(srcdir)/'`src/c/dynamic_link.c
-
 libscidynamic_link_algo_la-dl_genErrorMessage.lo: src/c/dl_genErrorMessage.c
 @am__fastdepCC_TRUE@   $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscidynamic_link_algo_la_CPPFLAGS) $(CPPFLAGS) $(libscidynamic_link_algo_la_CFLAGS) $(CFLAGS) -MT libscidynamic_link_algo_la-dl_genErrorMessage.lo -MD -MP -MF $(DEPDIR)/libscidynamic_link_algo_la-dl_genErrorMessage.Tpo -c -o libscidynamic_link_algo_la-dl_genErrorMessage.lo `test -f 'src/c/dl_genErrorMessage.c' || echo '$(srcdir)/'`src/c/dl_genErrorMessage.c
 @am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscidynamic_link_algo_la-dl_genErrorMessage.Tpo $(DEPDIR)/libscidynamic_link_algo_la-dl_genErrorMessage.Plo
@@ -802,13 +792,6 @@ libscidynamic_link_la-gw_dynamic_link.lo: sci_gateway/c/gw_dynamic_link.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscidynamic_link_la_CPPFLAGS) $(CPPFLAGS) $(libscidynamic_link_la_CFLAGS) $(CFLAGS) -c -o libscidynamic_link_la-gw_dynamic_link.lo `test -f 'sci_gateway/c/gw_dynamic_link.c' || echo '$(srcdir)/'`sci_gateway/c/gw_dynamic_link.c
 
-libscidynamic_link_la-sci_addinter.lo: sci_gateway/c/sci_addinter.c
-@am__fastdepCC_TRUE@   $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscidynamic_link_la_CPPFLAGS) $(CPPFLAGS) $(libscidynamic_link_la_CFLAGS) $(CFLAGS) -MT libscidynamic_link_la-sci_addinter.lo -MD -MP -MF $(DEPDIR)/libscidynamic_link_la-sci_addinter.Tpo -c -o libscidynamic_link_la-sci_addinter.lo `test -f 'sci_gateway/c/sci_addinter.c' || echo '$(srcdir)/'`sci_gateway/c/sci_addinter.c
-@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscidynamic_link_la-sci_addinter.Tpo $(DEPDIR)/libscidynamic_link_la-sci_addinter.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='sci_gateway/c/sci_addinter.c' object='libscidynamic_link_la-sci_addinter.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscidynamic_link_la_CPPFLAGS) $(CPPFLAGS) $(libscidynamic_link_la_CFLAGS) $(CFLAGS) -c -o libscidynamic_link_la-sci_addinter.lo `test -f 'sci_gateway/c/sci_addinter.c' || echo '$(srcdir)/'`sci_gateway/c/sci_addinter.c
-
 libscidynamic_link_la-sci_call.lo: sci_gateway/c/sci_call.c
 @am__fastdepCC_TRUE@   $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscidynamic_link_la_CPPFLAGS) $(CPPFLAGS) $(libscidynamic_link_la_CFLAGS) $(CFLAGS) -MT libscidynamic_link_la-sci_call.lo -MD -MP -MF $(DEPDIR)/libscidynamic_link_la-sci_call.Tpo -c -o libscidynamic_link_la-sci_call.lo `test -f 'sci_gateway/c/sci_call.c' || echo '$(srcdir)/'`sci_gateway/c/sci_call.c
 @am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscidynamic_link_la-sci_call.Tpo $(DEPDIR)/libscidynamic_link_la-sci_call.Plo
@@ -837,6 +820,20 @@ libscidynamic_link_la-sci_call.lo: sci_gateway/c/sci_call.c
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
 
+libscidynamic_link_algo_la-dynamic_link.lo: src/cpp/dynamic_link.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscidynamic_link_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscidynamic_link_algo_la-dynamic_link.lo -MD -MP -MF $(DEPDIR)/libscidynamic_link_algo_la-dynamic_link.Tpo -c -o libscidynamic_link_algo_la-dynamic_link.lo `test -f 'src/cpp/dynamic_link.cpp' || echo '$(srcdir)/'`src/cpp/dynamic_link.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscidynamic_link_algo_la-dynamic_link.Tpo $(DEPDIR)/libscidynamic_link_algo_la-dynamic_link.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/dynamic_link.cpp' object='libscidynamic_link_algo_la-dynamic_link.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscidynamic_link_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscidynamic_link_algo_la-dynamic_link.lo `test -f 'src/cpp/dynamic_link.cpp' || echo '$(srcdir)/'`src/cpp/dynamic_link.cpp
+
+libscidynamic_link_algo_la-addinter.lo: src/cpp/addinter.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscidynamic_link_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscidynamic_link_algo_la-addinter.lo -MD -MP -MF $(DEPDIR)/libscidynamic_link_algo_la-addinter.Tpo -c -o libscidynamic_link_algo_la-addinter.lo `test -f 'src/cpp/addinter.cpp' || echo '$(srcdir)/'`src/cpp/addinter.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscidynamic_link_algo_la-addinter.Tpo $(DEPDIR)/libscidynamic_link_algo_la-addinter.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/addinter.cpp' object='libscidynamic_link_algo_la-addinter.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscidynamic_link_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscidynamic_link_algo_la-addinter.lo `test -f 'src/cpp/addinter.cpp' || echo '$(srcdir)/'`src/cpp/addinter.cpp
+
 libscidynamic_link_la-dynamic_link_gw.lo: sci_gateway/cpp/dynamic_link_gw.cpp
 @am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscidynamic_link_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscidynamic_link_la-dynamic_link_gw.lo -MD -MP -MF $(DEPDIR)/libscidynamic_link_la-dynamic_link_gw.Tpo -c -o libscidynamic_link_la-dynamic_link_gw.lo `test -f 'sci_gateway/cpp/dynamic_link_gw.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/dynamic_link_gw.cpp
 @am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscidynamic_link_la-dynamic_link_gw.Tpo $(DEPDIR)/libscidynamic_link_la-dynamic_link_gw.Plo
@@ -879,6 +876,13 @@ libscidynamic_link_la-sci_getdynlibext.lo: sci_gateway/cpp/sci_getdynlibext.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscidynamic_link_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscidynamic_link_la-sci_getdynlibext.lo `test -f 'sci_gateway/cpp/sci_getdynlibext.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_getdynlibext.cpp
 
+libscidynamic_link_la-sci_addinter.lo: sci_gateway/cpp/sci_addinter.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscidynamic_link_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscidynamic_link_la-sci_addinter.lo -MD -MP -MF $(DEPDIR)/libscidynamic_link_la-sci_addinter.Tpo -c -o libscidynamic_link_la-sci_addinter.lo `test -f 'sci_gateway/cpp/sci_addinter.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_addinter.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscidynamic_link_la-sci_addinter.Tpo $(DEPDIR)/libscidynamic_link_la-sci_addinter.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_addinter.cpp' object='libscidynamic_link_la-sci_addinter.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscidynamic_link_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscidynamic_link_la-sci_addinter.lo `test -f 'sci_gateway/cpp/sci_addinter.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_addinter.cpp
+
 .f.o:
        $(F77COMPILE) -c -o $@ $<
 
index 658efc4..cc940bf 100644 (file)
@@ -13,6 +13,7 @@
 #ifndef __ADDINTER_H__
 #define  __ADDINTER_H__
 
+#include <wchar.h>
 #include "dynlib_dynamic_link.h"
 #include "machine.h"
 
@@ -45,7 +46,7 @@ DYNAMIC_LINK_IMPEXP void RemoveInterf(int id);
 * @param[in] sizefcts size of fcts array
 * @return a int id of interface (-1 failed)
 */
-DYNAMIC_LINK_IMPEXP int AddInterfaceToScilab(char *filenamelib,char *spname,char **fcts,int sizefcts);
+DYNAMIC_LINK_IMPEXP int AddInterfaceToScilab(wchar_t* _pwstDynamicLibraryName, wchar_t* _pwstModuleName, wchar_t** _pwstEntryPointName, int _iEntryPointSize);
 
 /**
 * TO DO: comments 
index d61981a..00dedaf 100644 (file)
@@ -1,11 +1,12 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) INRIA - Allan CORNET
- * 
+ * Copyright (C) 2011 - DIGITEO - Antoine ELIAS
+ *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
  * you should have received as part of this distribution.  The terms
- * are also available at    
+ * are also available at
  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  */
@@ -14,6 +15,7 @@
 #ifndef __DYNAMIC_LINK_H__
 #define __DYNAMIC_LINK_H__
 
+#include <wchar.h> /* wchar_t */
 #include "dynlib_dynamic_link.h"
 #include "BOOL.h"
 #include "machine.h" /* C2F */
 #define ENTRYMAX 500
 
 /**
-* Initialize tables 
-*/
-DYNAMIC_LINK_IMPEXP void initializeLink(void);
-
-/**
-* check that a routine name is a loaded
-* if *ilib == -1 
-*    checks if routinename is a loaded
-*    entry point 
-*    the result is -1 if false 
-*    or the number in the function table 
-* 
-* @param[in] routinename
-* @param[in/out] ilib number in the function table (-1 if FALSE)
-* @return a BOOL
-*/
-DYNAMIC_LINK_IMPEXP BOOL c_link(char *routinename,int *ilib);
-
-/**
 * OBSOLETE 
 * if *ilib == -1 
 *    checks if routinename is a loaded
@@ -57,7 +40,7 @@ DYNAMIC_LINK_IMPEXP void C2F(iislink)(char *routinename, int *ilib);
 * @param ii
 * @param ptr on functions
 */
-DYNAMIC_LINK_IMPEXP void GetDynFunc(int ii, void (**realop) ());
+DYNAMIC_LINK_IMPEXP void GetDynFunc(int ii, void (**realop)());
 
 /**
 * Search a function in the table 
@@ -68,11 +51,6 @@ DYNAMIC_LINK_IMPEXP void GetDynFunc(int ii, void (**realop) ());
 DYNAMIC_LINK_IMPEXP int SearchInDynLinks(char *op, void (**realop) ());
 
 /**
-* Show the linked files 
-*/
-DYNAMIC_LINK_IMPEXP void ShowDynLinks(void);
-
-/**
 * unlink all linked files 
 */
 DYNAMIC_LINK_IMPEXP void unlinkallsharedlib(void);
@@ -90,14 +68,21 @@ DYNAMIC_LINK_IMPEXP void unlinksharedlib(int *i);
 * return value is == -1 if the LoadDynLibrary failed 
 * @param loaded_file
 */
-DYNAMIC_LINK_IMPEXP int Sci_dlopen( char *loaded_file);
+DYNAMIC_LINK_IMPEXP int Sci_dlopen(wchar_t* _pwstDynLibPath);
+
+/**
+* unload a shared library by calling FreeDynLibrary
+* return value is == 0 if the FreeDynLibrary failed 
+* @param loaded_file
+*/
+DYNAMIC_LINK_IMPEXP int Sci_dlclose(unsigned long _hLib);
 
 /**
 * This routine load the entryname ename 
 * from shared lib ishared 
 * @return TRUE or FALSE
 */
-DYNAMIC_LINK_IMPEXP BOOL Sci_dlsym(char *ename,int ishared,char *strf);
+DYNAMIC_LINK_IMPEXP BOOL Sci_dlsym(wchar_t* _pwstEntryPointName, int _iLibID, BOOL _bFortran);
 
 /**
 * Delete entry points associated with shared lib ishared
@@ -114,25 +99,15 @@ DYNAMIC_LINK_IMPEXP char **getNamesOfFunctionsInSharedLibraries(int *sizearray);
 
 /**
 * call link for scilab
-* @param idsharedlibrary
-* @param filename (dynamic library name)
-* @param subnamesarray (list of functions name in dynamic library)
-* @param sizesubnamesarray
-* @param fflag
-* @param ierr (last error)
-* @return id 
-*/
-DYNAMIC_LINK_IMPEXP int scilabLink(int idsharedlibrary,
-                          char *filename,
-                          char **subnamesarray,int sizesubnamesarray,
-                          BOOL fflag,int *ierr);
-
-/**
-* get list of all Id of shared lib
-* @param size of returned list
-* @return list of Id
+* @param _iLibID                : Id of an existing shared lib otherwise -1
+* @param _pwstLibraryName       : Dynamic library name
+* @param _pwstEntryPointName    : List of functions name in dynamic library
+* @param _iEntryPointSize       : Size of _pwstEntryPointName
+* @param _bFortran              : Is a link on a fortran function
+* @param _piErr                 : Error Id
+* @return id                    : Dynamic Library ID
 */
-DYNAMIC_LINK_IMPEXP int *getAllIdSharedLib(int *sizeList);
+DYNAMIC_LINK_IMPEXP int scilabLink(int _iLibID, wchar_t* _pwstLibraryName, wchar_t** _pwstEntryPointName, int _iEntryPointSize, BOOL _bFortran ,int *_piErr);
 
 #endif /* __DYNAMIC_LINK_H__ */
 /*-----------------------------------------------------------------------------------*/
index 52ad90d..8d03191 100644 (file)
@@ -24,7 +24,7 @@ private:
     ~DynamicLinkModule() {};
 
 public:
-    DYNAMIC_LINK_GW_IMPEXP static bool Load();
+    DYNAMIC_LINK_GW_IMPEXP static int Load();
 };
 
 CPP_GATEWAY_PROTOTYPE(sci_getdynlibext);
@@ -32,5 +32,6 @@ CPP_GATEWAY_PROTOTYPE(sci_link);
 CPP_GATEWAY_PROTOTYPE(sci_ilib_verbose);
 CPP_GATEWAY_PROTOTYPE(sci_c_link);
 CPP_GATEWAY_PROTOTYPE(sci_ulink);
+CPP_GATEWAY_PROTOTYPE(sci_addinter);
 
 #endif /* !__DYNAMIC_LINK_GW_HXX__ */
index 8d531b3..8b237ba 100644 (file)
@@ -23,7 +23,6 @@ DYNAMIC_LINK_IMPEXP int gw_dynamic_link(void);
 /* Declaration of all the profile function declared and */
 /* used in sci_gateway */
 /*--------------------------------------------------------------------------*/
-DYNAMIC_LINK_IMPEXP int sci_addinter(char *fname,unsigned long fname_len);
 DYNAMIC_LINK_IMPEXP int sci_fort(char *fname,unsigned long fname_len);
 DYNAMIC_LINK_IMPEXP int sci_call(char *fname,unsigned long fname_len);
 
index 8f56af9..97fceb5 100644 (file)
@@ -96,7 +96,7 @@ function libn = ilib_compile(lib_name, ..
     // Source tree version
     // Headers are dispatched in the source tree
     if isdir(SCI+"/modules/core/includes/") then
-      defaultModulesCHeader=[ "core", "mexlib","api_scilab","output_stream","localization" ];
+      defaultModulesCHeader=[ "core", "mexlib","api_scilab","output_stream","localization", "operations", "symbol", "types" ];
       defaultModulesFHeader=[ "core" ];
       ScilabTreeFound=%t
 
@@ -160,7 +160,6 @@ function libn = ilib_compile(lib_name, ..
 
     if ierr <> 0 then
       mprintf(gettext("%s: An error occurred during the compilation:\n"),"ilib_compile");
-      lines(0);
       disp(stderr);
       mprintf("\n");
       mprintf(gettext("%s: The command was:\n"),"ilib_compile");
index 83fea10..090e226 100644 (file)
@@ -67,30 +67,43 @@ function gateway_filename = ilib_gen_gateway(name,tables)
       error(msprintf(gettext("%s: Wrong size for input argument #%d: %d expected.\n"),"ilib_gen_gateway",2,3));
     end
     [gate,names] = new_names(table);
-    t = [ '#include <mex.h> ';
-          '#include <sci_gateway.h>';
-          '#include <api_scilab.h>';
-          '#include <MALLOC.h>';
-          'static int direct_gateway(char *fname,void F(void)) { F();return 0;};';
-          'extern Gatefunc ' + names(:) + ';';
-          'static GenericTable Tab[]={';
-          '  {'+ gate(:)+','+ names(:)+',""'+table(:,1)+'""},';
-          '};';
-          ' ';
-          'int C2F(' + tname + ')()';
-          '{';
-          '  Rhs = Max(0, Rhs);';
-          '  if (*(Tab[Fin-1].f) != NULL) '
-          '  {';
-          '     if(pvApiCtx == NULL)';
-          '     {'
-          '       pvApiCtx = (StrCtx*)MALLOC(sizeof(StrCtx));';
-          '     }';
-          '     pvApiCtx->pstName = (char*)Tab[Fin-1].name;';
-          '    (*(Tab[Fin-1].f))(Tab[Fin-1].name,Tab[Fin-1].F);';
-          '  }';
-          '  return 0;';
-          '}'];
+    t = [   '#include <wchar.h> ';   
+            '#include ""mex.h"" ';
+            '#include ""sci_gateway.h""';
+            '#include ""api_scilab.h""';
+            '#include ""api_oldstack.h""';
+            '#include ""MALLOC.h""';
+            '#include ""addGatewayInContext.h""';
+            '';
+            '#define MODULE_NAME L""' + tname + '""';
+            '';
+            'extern int ' + names(:) + '(char* fname, int* _piKey);';
+            '';
+            'int ' + tname + '(wchar_t* _pwstName)';
+            '{';
+            '   if(wcscmp(_pwstName, L""' + table(:,1) + '"") == 0){addGatewayInContext(L""' + table(:,1) + '"", &' + names(:) + ', MODULE_NAME);}';
+            '}'];
+        
+    old = [ 'static int direct_gateway(char *fname,void F(void)) { F();return 0;};';
+            'extern Gatefunc ' + names(:) + ';';
+            'static GenericTable Tab[]={';
+            '  {'+ gate(:)+','+ names(:)+',""'+table(:,1)+'""},';
+            '};';
+            ' ';
+            'int C2F(' + tname + ')()';
+            '{';
+            '  Rhs = Max(0, Rhs);';
+            '  if (*(Tab[Fin-1].f) != NULL) '
+            '  {';
+            '     if(pvApiCtx == NULL)';
+            '     {'
+            '       pvApiCtx = (StrCtx*)MALLOC(sizeof(StrCtx));';
+            '     }';
+            '     pvApiCtx->pstName = (char*)Tab[Fin-1].name;';
+            '    (*(Tab[Fin-1].f))(Tab[Fin-1].name,Tab[Fin-1].F);';
+            '  }';
+            '  return 0;';
+            '}'];
 
     gateway_filename = path + tname + '.c';
     // first check if we have already a gateway
index d895d85..f636aa4 100644 (file)
@@ -188,7 +188,7 @@ function bOK = generateLoader(name, tables, libs, libname, flag, loadername)
       mfprintf(fd, "list_functions = [ ");
       withoutSpace = %T;
       for x = table(1:$,1)'
-        if withoutSpace then
+        if withoutSpace == %t then
           withoutSpace = %F;
           mfprintf(fd, "''%s'';\n", x);
         else
index a361eaa..292bd3f 100644 (file)
@@ -19,7 +19,7 @@
 static gw_generic_table Tab[] =
 {
        {NULL, ""}, //getdynlibext
-       {sci_addinter,"addinter"},
+       {NULL, ""}, //addinter
        {sci_fort,"fort"},
        {sci_call,"call"},
        {NULL ,""}, //link
index f7cce97..689cff6 100644 (file)
@@ -20,12 +20,13 @@ extern "C"
    #include "gw_dynamic_link.h"
 }
 
-bool DynamicLinkModule::Load()
+int DynamicLinkModule::Load()
 {
     symbol::Context::getInstance()->AddFunction(types::Function::createFunction(L"getdynlibext", &sci_getdynlibext, MODULE_NAME));
     symbol::Context::getInstance()->AddFunction(types::Function::createFunction(L"link", &sci_link, MODULE_NAME));
     symbol::Context::getInstance()->AddFunction(types::Function::createFunction(L"ulink", &sci_ulink, MODULE_NAME));
     symbol::Context::getInstance()->AddFunction(types::Function::createFunction(L"c_link", &sci_c_link, MODULE_NAME));
     symbol::Context::getInstance()->AddFunction(types::Function::createFunction(L"ilib_verbose", &sci_ilib_verbose, MODULE_NAME));
-    return true;
+    symbol::Context::getInstance()->AddFunction(types::Function::createFunction(L"addinter", &sci_addinter, MODULE_NAME));
+    return 1;
 }
index 6620b78..069804c 100644 (file)
@@ -77,7 +77,7 @@
     <ClCompile>
       <AdditionalOptions>%(AdditionalOptions)</AdditionalOptions>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>../../includes;../../src/c;../../../api_scilab/includes;../../../symbol/includes;../../../types/includes;../../../core/includes;../../../abstractSyntaxTree/includes;../../../localization/includes;../../../operations/includes;../../../output_stream/includes;../../../../libs/intl;../../../string/includes;../../../../libs/MALLOC/includes;../../../functions_manager/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>../../includes;../../src/c;../../../api_scilab/includes;../../../symbol/includes;../../../types/includes;../../../core/includes;../../../abstractSyntaxTree/includes;../../../localization/includes;../../../operations/includes;../../../output_stream/includes;../../../../libs/intl;../../../string/includes;../../../../libs/MALLOC/includes;../../../functions_manager/includes;../../../system_env/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;DYNAMIC_LINK_GW_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>Default</BasicRuntimeChecks>
     </Midl>
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>../../includes;../../src/c;../../../api_scilab/includes;../../../symbol/includes;../../../types/includes;../../../core/includes;../../../abstractSyntaxTree/includes;../../../localization/includes;../../../operations/includes;../../../output_stream/includes;../../../../libs/intl;../../../string/includes;../../../../libs/MALLOC/includes;../../../functions_manager/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>../../includes;../../src/c;../../../api_scilab/includes;../../../symbol/includes;../../../types/includes;../../../core/includes;../../../abstractSyntaxTree/includes;../../../localization/includes;../../../operations/includes;../../../output_stream/includes;../../../../libs/intl;../../../string/includes;../../../../libs/MALLOC/includes;../../../functions_manager/includes;../../../system_env/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;DYNAMIC_LINK_GW_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>Default</BasicRuntimeChecks>
       <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
       <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
       <WholeProgramOptimization>false</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>../../includes;../../src/c;../../../api_scilab/includes;../../../symbol/includes;../../../types/includes;../../../core/includes;../../../abstractSyntaxTree/includes;../../../localization/includes;../../../operations/includes;../../../output_stream/includes;../../../../libs/intl;../../../string/includes;../../../../libs/MALLOC/includes;../../../functions_manager/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>../../includes;../../src/c;../../../api_scilab/includes;../../../symbol/includes;../../../types/includes;../../../core/includes;../../../abstractSyntaxTree/includes;../../../localization/includes;../../../operations/includes;../../../output_stream/includes;../../../../libs/intl;../../../string/includes;../../../../libs/MALLOC/includes;../../../functions_manager/includes;../../../system_env/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;DYNAMIC_LINK_GW_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
       <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
       <WholeProgramOptimization>false</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>../../includes;../../src/c;../../../api_scilab/includes;../../../symbol/includes;../../../types/includes;../../../core/includes;../../../abstractSyntaxTree/includes;../../../localization/includes;../../../operations/includes;../../../output_stream/includes;../../../../libs/intl;../../../string/includes;../../../../libs/MALLOC/includes;../../../functions_manager/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>../../includes;../../src/c;../../../api_scilab/includes;../../../symbol/includes;../../../types/includes;../../../core/includes;../../../abstractSyntaxTree/includes;../../../localization/includes;../../../operations/includes;../../../output_stream/includes;../../../../libs/intl;../../../string/includes;../../../../libs/MALLOC/includes;../../../functions_manager/includes;../../../system_env/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;DYNAMIC_LINK_GW_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
   </ItemDefinitionGroup>
   <ItemGroup>
     <ClCompile Include="dynamic_link_gw.cpp" />
+    <ClCompile Include="sci_addinter.cpp" />
     <ClCompile Include="sci_c_link.cpp" />
     <ClCompile Include="sci_getdynlibext.cpp" />
     <ClCompile Include="sci_ilib_verbose.cpp" />
     <ProjectReference Include="..\..\..\symbol\symbol.vcxproj">
       <Project>{2c60033b-0dbd-4ca4-80d3-176c9be9ce2f}</Project>
     </ProjectReference>
+    <ProjectReference Include="..\..\..\system_env\system_env.vcxproj">
+      <Project>{7ca60aef-9afa-4d06-af28-613c0aa27640}</Project>
+    </ProjectReference>
     <ProjectReference Include="..\..\..\types\types.vcxproj">
       <Project>{64e090da-dcb5-4f4d-93d7-e88ddec9c2ef}</Project>
     </ProjectReference>
index 6c360ad..0f74aeb 100644 (file)
@@ -32,6 +32,9 @@
     <ClCompile Include="sci_ulink.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="sci_addinter.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\includes\dynamic_link_gw.hxx">
  */
 
 /*---------------------------------------------------------------------------*/ 
-#include "gw_dynamic_link.h"
-#include "stack-c.h"
+#include "dynamic_link_gw.hxx"
+#include "function.hxx"
+#include "double.hxx"
+#include "string.hxx"
+
+extern "C"
+{
 #include "addinter.h"
 #include "localization.h"
-#include "dl_genErrorMessage.h"
 #include "Scierror.h"
-#include "freeArrayOfString.h"
+#include "dl_genErrorMessage.h"
+}
 /*-----------------------------------------------------------------------------------*/
-int sci_addinter(char *fname,unsigned long fname_len)
+types::Function::ReturnValue sci_addinter(types::typed_list &in, int _iRetCount, types::typed_list &out)
 {
+    int iErr = 0;
+    if(in.size() != 3)
+    {
+        ScierrorW(77, _W("%ls: Wrong number of input argument(s): %d expected.\n"), L"addinter", 3);
+        return types::Function::Error;
+    }
+
+    //1st parameter
+    if(in[0]->isString() == false)
+    {
+        ScierrorW(999 ,_W("%ls : Wrong type for input argument #%d: A string expected.\n"), L"addinter", 1);
+        return types::Function::Error;
+    }
+
+    types::String* pSLibName = in[0]->getAs<types::String>();
+    if(pSLibName->isScalar() == false)
+    {
+        ScierrorW(999 ,_W("%ls : Wrong type for input argument #%d: A string expected.\n"), L"addinter", 1);
+        return types::Function::Error;
+    }
+
+
+    //2nd parameter
+    if(in[1]->isString() == false)
+    {
+        ScierrorW(999 ,_W("%ls : Wrong type for input argument #%d: A string expected.\n"), L"addinter", 2);
+        return types::Function::Error;
+    }
+
+    types::String* pSModuleName = in[1]->getAs<types::String>();
+    if(pSModuleName->isScalar() == false)
+    {
+        ScierrorW(999 ,_W("%ls : Wrong type for input argument #%d: A string expected.\n"), L"addinter", 2);
+        return types::Function::Error;
+    }
+
+    //3rd parameter
+    if(in[2]->isString() == false)
+    {
+        ScierrorW(999 ,_W("%ls : Wrong type for input argument #%d: A string expected.\n"), L"addinter", 3);
+        return types::Function::Error;
+    }
+
+    types::String* pSFunctionList = in[2]->getAs<types::String>();
+    if(pSFunctionList->isVector() == false)
+    {
+        ScierrorW(999 ,_W("%ls : Wrong type for input argument #%d: String vector expected.\n"), L"addinter", 3);
+        return types::Function::Error;
+    }
+
+    iErr = AddInterfaceToScilab(pSLibName->get(0), pSModuleName->get(0), pSFunctionList->get(), pSFunctionList->getSize());
+    if(iErr)
+    {
+        dl_genErrorMessage(L"addinter", iErr, pSLibName->get(0));
+        return types::Function::Error;
+    }
+
+    return types::Function::OK;
+/*
        CheckRhs(3,3);
        CheckLhs(1,1);
 
@@ -59,7 +123,7 @@ int sci_addinter(char *fname,unsigned long fname_len)
                        return 0;
                }
 
-               if ( (m3 > 1) &&  (n3 > 1) ) /* check vector string */
+               if ( (m3 > 1) &&  (n3 > 1) ) // check vector string
                {
                        freeArrayOfString(sharedlibname, m1*n1);
                        freeArrayOfString(spname, m2*n2);
@@ -90,7 +154,7 @@ int sci_addinter(char *fname,unsigned long fname_len)
                if (ierr == 0)
                {
                        LhsVar(1) = 0;
-                       C2F(putlhsvar)();
+            PutLhsVar();
                }
                else
                {
@@ -106,5 +170,6 @@ int sci_addinter(char *fname,unsigned long fname_len)
                Scierror(999,_("%s: Wrong type for input arguments: Strings expected.\n"),fname); 
        }
        return 0;
+*/
 }
 /*---------------------------------------------------------------------------*/
index f867aa6..e00c969 100644 (file)
@@ -18,6 +18,7 @@
 #include "double.hxx"
 #include "string.hxx"
 #include "bool.hxx"
+#include "configvariable.hxx"
 
 extern "C"
 {
@@ -25,6 +26,8 @@ extern "C"
 #include "localization.h"
 #include "Scierror.h"
 }
+
+bool isLink(wchar_t* _pwstEntryPoint, int* _piLib);
 /*--------------------------------------------------------------------------*/
 types::Function::ReturnValue sci_c_link(types::typed_list &in, int _iRetCount, types::typed_list &out)
 {
@@ -63,9 +66,7 @@ types::Function::ReturnValue sci_c_link(types::typed_list &in, int _iRetCount, t
         return types::Function::Error;
     }
 
-    pstFunctionName = wide_string_to_UTF8(pSLibName->get(0));
-    BOOL bFind = c_link(pstFunctionName, &iLib);
-    FREE(pstFunctionName);
+    BOOL bFind = isLink(pSLibName->get(0), &iLib);
 
     out.push_back(new types::Bool(bFind));
     if(_iRetCount == 2)
@@ -76,3 +77,16 @@ types::Function::ReturnValue sci_c_link(types::typed_list &in, int _iRetCount, t
     return types::Function::OK;
 }
 /*--------------------------------------------------------------------------*/
+bool isLink(wchar_t* _pwstEntryPoint, int* _piLib)
+{
+    ConfigVariable::EntryPointStr* pEP = ConfigVariable::getEntryPoint(_pwstEntryPoint, *_piLib);
+
+    if(pEP == NULL)
+    {
+        return false;
+    }
+
+    *_piLib = pEP->iLibIndex;
+    return true;
+}
+/*--------------------------------------------------------------------------*/
index ea90ac4..a700a7c 100644 (file)
@@ -13,6 +13,7 @@
 
 /*-----------------------------------------------------------------------------------*/
 #include "dynamic_link_gw.hxx"
+#include "configvariable.hxx"
 #include "function.hxx"
 #include "double.hxx"
 #include "string.hxx"
@@ -21,19 +22,24 @@ extern "C"
 {
 #include "Scierror.h"
 #include "dynamic_link.h"
+#include "ilib_verbose.h"
 #include "MALLOC.h"
 #include "localization.h"
 #include "dl_genErrorMessage.h"
 #include "freeArrayOfString.h"
+#include "sciprint.h"
 }
+
+void displayDynLibInfo(void);
+types::Double* getLibraryIDs(void);
 /*-----------------------------------------------------------------------------------*/
 types::Function::ReturnValue sci_link(types::typed_list &in, int _iRetCount, types::typed_list &out)
 {
-    int iSizeSubNames   = 0;
-    char** pstSubNames  = NULL;
-    char* pstLibName    = NULL;
-    BOOL bFortran       = TRUE;
-    int iIDSharedLib    = -1;
+    int iSizeSubNames       = 0;
+    wchar_t** pwstSubNames  = NULL;
+    wchar_t* pwstLibName    = NULL;
+    BOOL bFortran           = TRUE;
+    int iIDSharedLib        = -1;
 
     if(in.size() > 3)
     {
@@ -43,22 +49,17 @@ types::Function::ReturnValue sci_link(types::typed_list &in, int _iRetCount, typ
 
     if(in.size() == 0)
     {
-        int sizeFunctionsList = 0;
-        char ** FunctionsList = NULL;
-
-        FunctionsList = getNamesOfFunctionsInSharedLibraries(&sizeFunctionsList);
-        if(sizeFunctionsList == 0 || FunctionsList == NULL)
+        std::vector<std::wstring> FunctionsList = ConfigVariable::getEntryPointNameList();
+        if(FunctionsList.size() == 0)
         {
             out.push_back(types::Double::Empty());
             return types::Function::OK;
         }
 
-        types::String* pSFunctionNames = new types::String(1 ,sizeFunctionsList);
-        for(int i = 0 ; i < sizeFunctionsList ; i++)
+        types::String* pSFunctionNames = new types::String(1, (int)FunctionsList.size());
+        for(int i = 0 ; i < FunctionsList.size() ; i++)
         {
-            wchar_t* pwstFunc = to_wide_string(FunctionsList[i]);
-            pSFunctionNames->set(i, pwstFunc);
-            FREE(pwstFunc);
+            pSFunctionNames->set(i, FunctionsList[i].c_str());
         }
 
         out.push_back(pSFunctionNames);
@@ -100,11 +101,7 @@ types::Function::ReturnValue sci_link(types::typed_list &in, int _iRetCount, typ
         }
 
         iSizeSubNames = pSSubNames->getSize();
-        pstSubNames = (char**)MALLOC(iSizeSubNames * sizeof(char*));
-        for(int i = 0 ; i < iSizeSubNames ; i++)
-        {
-            pstSubNames[i] = wide_string_to_UTF8(pSSubNames->get(i));
-        }
+        pwstSubNames = pSSubNames->get();
     }
 
     if(in.size() >= 1)
@@ -131,29 +128,13 @@ types::Function::ReturnValue sci_link(types::typed_list &in, int _iRetCount, typ
             
             if(wcscmp(pS->get(0), L"show") == 0)
             {//show option
-                int *piIds      = NULL;
-                int iSizeIds    = 0;
-
-                ShowDynLinks();
-                piIds = getAllIdSharedLib(&iSizeIds);
-                if(iSizeIds == 0 || piIds == NULL)
-                {
-                    out.push_back(types::Double::Empty());
-                    return types::Function::OK;
-                }
-
-                types::Double* pDIds = new types::Double(1, iSizeIds);
-                for(int i = 0 ; i < iSizeIds ; i++)
-                {
-                    pDIds->set(i, (double)piIds[i]);
-                }
-
-                out.push_back(pDIds);
+                displayDynLibInfo();
+                out.push_back(getLibraryIDs());
                 return types::Function::OK;
             }
 
             //library name
-            pstLibName = wide_string_to_UTF8(pS->get(0));
+            pwstLibName = pS->get(0);
         }
         else
         {
@@ -163,31 +144,101 @@ types::Function::ReturnValue sci_link(types::typed_list &in, int _iRetCount, typ
     }
 
     int iErr    = 0;
-    int iRetID  = scilabLink(iIDSharedLib, pstLibName, pstSubNames, iSizeSubNames, bFortran, &iErr);
+    int iRetID  = scilabLink(iIDSharedLib, pwstLibName, pwstSubNames, iSizeSubNames, bFortran, &iErr);
 
-    if(in.size() >= 2)
+    if(iErr)
     {
-        freeArrayOfString(pstSubNames, iSizeSubNames);
+        dl_genErrorMessage(L"link", iErr, pwstLibName);
+
+        /* release lib if it is a new link */
+        if(iIDSharedLib == -1)
+        {
+            ConfigVariable::removeDynamicLibrary(iRetID);
+        }
+        return types::Function::Error;
     }
 
-    if(iErr)
+    out.push_back(new types::Double(iRetID));
+    return types::Function::OK;
+}
+/*-----------------------------------------------------------------------------------*/
+void displayDynLibInfo(void)
+{
+    std::list<ConfigVariable::EntryPointStr*>* pEPList = ConfigVariable::getEntryPointList();
+    std::vector<ConfigVariable::DynamicLibraryStr*>* pDLList = ConfigVariable::getDynamicLibraryList();
+
+    if(getIlibVerboseLevel() != ILIB_VERBOSE_NO_OUTPUT)
     {
-        dl_genErrorMessage("link", iErr, pstLibName);
-        if(pstLibName)
+        sciprintW(_W("Number of entry points %d.\nShared libraries :\n"), pEPList->size());
+    }
+
+    if(getIlibVerboseLevel() != ILIB_VERBOSE_NO_OUTPUT)
+    {
+        sciprintW(L"[ ");
+    }
+
+    int iLibCount = 0;
+    for(int i = 0 ; i < pDLList->size() ; i++)
+    {
+        if(getIlibVerboseLevel() != ILIB_VERBOSE_NO_OUTPUT) 
         {
-            FREE(pstLibName);
-            pstLibName = NULL;
+            if((*pDLList)[i] != NULL)
+            {
+                sciprintW(L"%d ", i);
+                iLibCount++;
+            }
+        }
+    }
+
+    if(getIlibVerboseLevel() != ILIB_VERBOSE_NO_OUTPUT) 
+    {
+        if(iLibCount < 2)
+        {
+            sciprintW(_W("] : %d library.\n"), iLibCount);
+        }
+        else
+        {
+            sciprintW(_W("] : %d libraries.\n"), iLibCount);
         }
-        return types::Function::Error;
     }
 
-    if(pstLibName)
+    std::list<ConfigVariable::EntryPointStr*>::const_reverse_iterator it;
+    for(it = pEPList->rbegin() ; it != pEPList->rend() ; it++)
     {
-        FREE(pstLibName);
-        pstLibName = NULL;
+        if(getIlibVerboseLevel() != ILIB_VERBOSE_NO_OUTPUT)
+        {
+            sciprintW(_W("Entry point %ls in shared library %d.\n"), (*it)->pwstEntryPointName, (*it)->iLibIndex);
+        }
     }
-    
-    out.push_back(new types::Double(iRetID));
-    return types::Function::OK;
+}
+/*-----------------------------------------------------------------------------------*/
+types::Double* getLibraryIDs(void)
+{
+    std::vector<ConfigVariable::DynamicLibraryStr*>* pDLList = ConfigVariable::getDynamicLibraryList();
+
+    int iLibCount = 0;
+    for(int i = 0 ; i < pDLList->size() ; i++)
+    {
+        if((*pDLList)[i] != NULL)
+        {
+            iLibCount++;
+        }
+    }
+
+    if(iLibCount == 0)
+    {
+        return types::Double::Empty();
+    }
+
+    types::Double* pOut = new types::Double(1, iLibCount);
+    iLibCount = 0;
+    for(int i = 0 ; i < pDLList->size() ; i++)
+    {
+        if((*pDLList)[i] != NULL)
+        {
+            pOut->set(iLibCount++, (double)i);
+        }
+    }
+    return pOut;
 }
 /*-----------------------------------------------------------------------------------*/
index 62d5998..63f182d 100644 (file)
@@ -15,6 +15,7 @@
 #include "dynamic_link_gw.hxx"
 #include "function.hxx"
 #include "double.hxx"
+#include "configvariable.hxx"
 
 extern "C"
 {
@@ -22,6 +23,9 @@ extern "C"
 #include "Scierror.h"
 #include "dynamic_link.h"
 }
+
+void unLinkAll();
+void unLink(int _iLib);
 /*--------------------------------------------------------------------------*/
 types::Function::ReturnValue sci_ulink(types::typed_list &in, int _iRetCount, types::typed_list &out)
 {
@@ -40,7 +44,7 @@ types::Function::ReturnValue sci_ulink(types::typed_list &in, int _iRetCount, ty
 
     if(in.size() == 0)
     {
-        unlinkallsharedlib();
+        unLinkAll();
     }
     else if(in.size() == 1)
     {
@@ -53,11 +57,26 @@ types::Function::ReturnValue sci_ulink(types::typed_list &in, int _iRetCount, ty
 
         for(int i = 0 ; i < pDIds->getSize() ; i++)
         {
-            int ilib = (int) pDIds->get(i);
-            unlinksharedlib(&ilib);
+            unLink(pDIds->get(i));
         }
     }
 
     return types::Function::OK;
 }
 /*--------------------------------------------------------------------------*/
+void unLinkAll()
+{
+    std::vector<ConfigVariable::DynamicLibraryStr*>* pDLLIst =  ConfigVariable::getDynamicLibraryList();
+    for(int i = 0 ; i < pDLLIst->size() ; i++)
+    {
+        unLink(i);
+    }
+}
+/*--------------------------------------------------------------------------*/
+void unLink(int _iLib)
+{
+    unsigned long iLib = ConfigVariable::getDynamicLibrary(_iLib)->hLib;
+    ConfigVariable::removeDynamicLibrary(_iLib);
+    Sci_dlclose(iLib);
+}
+/*--------------------------------------------------------------------------*/
index 8b42120..6e2096f 100644 (file)
 #include "Scierror.h"
 #include "localization.h"
 /*---------------------------------------------------------------------------*/
-void dl_genErrorMessage(char *fname, int errorCode, char* SharedLibraryName){
-       switch (errorCode)
-               {
-                       case -1:
-                               Scierror(236,_("%s: The shared archive was not loaded: %s\n"),fname,GetLastDynLibError());
-                               break;
+void dl_genErrorMessage(wchar_t* _pwstCallerName, int _iErr, wchar_t* _pwstLibraryName)
+{
+    switch (_iErr)
+    {
+    case -1:
+        ScierrorW(236, _W("%ls: The shared archive was not loaded: %ls\n"), _pwstCallerName, GetLastDynLibError());
+        break;
 
-                       case -2:
-                               Scierror(999,_("%s: Cannot open shared files. Max entry %d reached.\n"),fname,ENTRYMAX);
-                               break;
+    case -2:
+        ScierrorW(999, _W("%ls: Cannot open shared files. Max entry %d reached.\n"), _pwstCallerName, ENTRYMAX);
+        break;
 
-                       case -3:
-                               Scierror(999,_("%s: Shared lib %s does not exist.\n"),fname,SharedLibraryName);
-                               break;
+    case -3:
+        ScierrorW(999, _W("%ls: Shared lib %ls does not exist.\n") ,_pwstCallerName, _pwstLibraryName);
+        break;
 
-                       case -4:
-                               Scierror(999,_("%s: Already loaded from library %s\n"),fname,SharedLibraryName);
-                               break;
-                       case -5:
-                               Scierror(235,_("%s: problem with one of the entry point.\n"),fname,GetLastDynLibError());
-                               break;
-                       default:
-                               Scierror(999,_("%s: An error occurred: %s\n"),fname,GetLastDynLibError());
-                               break;
-               }
+    case -4:
+        ScierrorW(999, _W("%ls: Already loaded from library %ls\n"),_pwstCallerName, _pwstLibraryName);
+        break;
+    case -5:
+        ScierrorW(235, _W("%ls: problem with one of the entry point.\n"), _pwstCallerName, GetLastDynLibError());
+        break;
+    default:
+        ScierrorW(999, _W("%ls: An error occurred: %ls\n"), _pwstCallerName, GetLastDynLibError());
+        break;
+    }
 }
 /*---------------------------------------------------------------------------*/
index 76c07c0..4398898 100644 (file)
@@ -19,5 +19,5 @@
  * @param errorCode the code of error
  * @param SharedLibraryName name of the library
  */
-DYNAMIC_LINK_IMPEXP void dl_genErrorMessage(char* fname, int errorCode, char* SharedLibraryName);
+DYNAMIC_LINK_IMPEXP void dl_genErrorMessage(wchar_t* _pwstCallerName, int _iErr, wchar_t* _pwstLibraryName);
 /*--------------------------------------------------------------------------*/
index 4340ab8..a3ba0e0 100644 (file)
@@ -20,7 +20,7 @@
 * @param[in] dll filename
 * @return TRUE or FALSE
 */
-BOOL isDll(const char *dllfilename);
+BOOL isDll(const wchar_t* _pwstDLLName);
 
 /**
 *  check if it is a valid x64 dll
index 0294a16..4f83aa8 100644 (file)
@@ -77,7 +77,7 @@
     <ClCompile>
       <AdditionalOptions>%(AdditionalOptions)</AdditionalOptions>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>../../includes;../../src/c;../../../../libs/MALLOC/includes;../../../../libs/dynamiclibrary/includes;../../../../libs/intl;../../../string/includes;../../../output_stream/includes;../../../windows_tools/includes;../../../operations/includes;../../../localization/includes;../../../io/includes;../../../core/includes;../../../fileio/includes;../../../../libs/hashtable;../../../api_scilab/includes;../../../system_env/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>../../includes;../../src/c;../../../../libs/MALLOC/includes;../../../../libs/dynamiclibrary/includes;../../../../libs/intl;../../../string/includes;../../../output_stream/includes;../../../windows_tools/includes;../../../operations/includes;../../../localization/includes;../../../io/includes;../../../core/includes;../../../fileio/includes;../../../../libs/hashtable;../../../api_scilab/includes;../../../system_env/includes;../../../types/includes;../../../abstractSyntaxTree/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;DYNAMIC_LINK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>Default</BasicRuntimeChecks>
@@ -115,7 +115,7 @@ lib /DEF:"$(ProjectDir)Io_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformShor
     </Midl>
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>../../includes;../../src/c;../../../../libs/MALLOC/includes;../../../../libs/dynamiclibrary/includes;../../../../libs/intl;../../../string/includes;../../../output_stream/includes;../../../windows_tools/includes;../../../operations/includes;../../../localization/includes;../../../io/includes;../../../core/includes;../../../fileio/includes;../../../../libs/hashtable;../../../api_scilab/includes;../../../system_env/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>../../includes;../../src/c;../../../../libs/MALLOC/includes;../../../../libs/dynamiclibrary/includes;../../../../libs/intl;../../../string/includes;../../../output_stream/includes;../../../windows_tools/includes;../../../operations/includes;../../../localization/includes;../../../io/includes;../../../core/includes;../../../fileio/includes;../../../../libs/hashtable;../../../api_scilab/includes;../../../system_env/includes;../../../types/includes;../../../abstractSyntaxTree/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;DYNAMIC_LINK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>Default</BasicRuntimeChecks>
@@ -154,7 +154,7 @@ lib /DEF:"$(ProjectDir)Io_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformShor
       <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
       <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
       <WholeProgramOptimization>false</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>../../includes;../../src/c;../../../../libs/MALLOC/includes;../../../../libs/dynamiclibrary/includes;../../../../libs/intl;../../../string/includes;../../../output_stream/includes;../../../windows_tools/includes;../../../operations/includes;../../../localization/includes;../../../io/includes;../../../core/includes;../../../fileio/includes;../../../../libs/hashtable;../../../api_scilab/includes;../../../system_env/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>../../includes;../../src/c;../../../../libs/MALLOC/includes;../../../../libs/dynamiclibrary/includes;../../../../libs/intl;../../../string/includes;../../../output_stream/includes;../../../windows_tools/includes;../../../operations/includes;../../../localization/includes;../../../io/includes;../../../core/includes;../../../fileio/includes;../../../../libs/hashtable;../../../api_scilab/includes;../../../system_env/includes;../../../types/includes;../../../abstractSyntaxTree/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;DYNAMIC_LINK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -200,7 +200,7 @@ lib /DEF:"$(ProjectDir)Io_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformShor
       <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
       <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
       <WholeProgramOptimization>false</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>../../includes;../../src/c;../../../../libs/MALLOC/includes;../../../../libs/dynamiclibrary/includes;../../../../libs/intl;../../../string/includes;../../../output_stream/includes;../../../windows_tools/includes;../../../operations/includes;../../../localization/includes;../../../io/includes;../../../core/includes;../../../fileio/includes;../../../../libs/hashtable;../../../api_scilab/includes;../../../system_env/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>../../includes;../../src/c;../../../../libs/MALLOC/includes;../../../../libs/dynamiclibrary/includes;../../../../libs/intl;../../../string/includes;../../../output_stream/includes;../../../windows_tools/includes;../../../operations/includes;../../../localization/includes;../../../io/includes;../../../core/includes;../../../fileio/includes;../../../../libs/hashtable;../../../api_scilab/includes;../../../system_env/includes;../../../types/includes;../../../abstractSyntaxTree/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;DYNAMIC_LINK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -238,15 +238,14 @@ lib /DEF:"$(ProjectDir)Io_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformShor
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
-    <ClCompile Include="addinter.c" />
+    <ClCompile Include="..\cpp\addinter.cpp" />
+    <ClCompile Include="..\cpp\dynamic_link.cpp" />
     <ClCompile Include="dllinfo.c" />
     <ClCompile Include="dl_genErrorMessage.c" />
     <ClCompile Include="DllmainDynamic_link.c" />
-    <ClCompile Include="dynamic_link.c" />
     <ClCompile Include="GetFunctionByName.c" />
     <ClCompile Include="..\..\sci_gateway\c\gw_dynamic_link.c" />
     <ClCompile Include="ilib_verbose.c" />
-    <ClCompile Include="..\..\sci_gateway\c\sci_addinter.c" />
     <ClCompile Include="..\..\sci_gateway\c\sci_call.c" />
   </ItemGroup>
   <ItemGroup>
@@ -291,6 +290,9 @@ lib /DEF:"$(ProjectDir)Io_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformShor
       <Project>{4fc72d4a-80ee-4b1a-8724-0201c1a35621}</Project>
       <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
     </ProjectReference>
+    <ProjectReference Include="..\..\..\io\src\c\io.vcxproj">
+      <Project>{80c0f142-184b-4e08-a8ee-5e71437cf904}</Project>
+    </ProjectReference>
     <ProjectReference Include="..\..\..\localization\src\localization.vcxproj">
       <Project>{ecffeb0c-1eda-45ee-9a10-b18143852e17}</Project>
       <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
index 1f768da..a1d1a5d 100644 (file)
     </Filter>
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="addinter.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="dl_genErrorMessage.c">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="DllmainDynamic_link.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="dynamic_link.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="GetFunctionByName.c">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="ilib_verbose.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\sci_gateway\c\sci_addinter.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="..\..\sci_gateway\c\sci_call.c">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="dllinfo.c">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\cpp\addinter.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\cpp\dynamic_link.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\includes\addinter.h">
  */
 
 /*-----------------------------------------------------------------------------------*/
+#include "configvariable.hxx"
+
+extern "C"
+{
 #include <string.h> 
 #include <stdio.h>
 #include <stdlib.h>
@@ -33,7 +37,7 @@
 #ifdef _MSC_VER
 #include "ExceptionMessage.h"
 #endif
-
+}
 /* size of interface name */
 /* scilab limitation to nlgh characters (24)*/
 #define INTERFSIZE nlgh + 1 
@@ -53,99 +57,42 @@ static int LastInterf = 0;
 static void initializeInterfaces(void);
 static BOOL reallocDynInterf(void);
 /*-----------------------------------------------------------------------------------*/
-int AddInterfaceToScilab(char *filenamelib,char *spname,char **fcts,int sizefcts)
+int AddInterfaceToScilab(wchar_t* _pwstDynamicLibraryName, wchar_t* _pwstModuleName, wchar_t** _pwstEntryPointName, int _iEntryPointSize)
 {
-       int IdLib = -1; /* Id of library */
-       int idinput = -1; /* Id of a function */
-       int ierr1 = 0;
-       int one = 1;
-       char **subname = NULL;
-       int ierr = 0;
-       int i = 0;
-       int inum = 0;
-       int k1 = 0;
+       int iLibID = -1; /* Id of library */
+       int iErr = 0;
        
-       initializeLink();
-       initializeInterfaces();
-
        /** Try to unlink the interface if it was previously linked **/
-
-       for ( i = 0 ; i < LastInterf ; i++) 
-       {
-               if (strcmp(spname,DynInterf[i].name) == 0) 
-               {
-                       unlinksharedlib(&DynInterf[i].Nshared);
-                       break;
-               }
-       }
-
-       /** Try to find a free position in the interface table : inum **/
-       inum=-1;
-       for ( i = 0 ; i < LastInterf ; i++) 
-       {
-               if ( DynInterf[i].ok == 0 ) 
-               {
-                       inum= i;
-               }
-       }
-
-       inum = ( inum == -1 ) ? LastInterf : inum ;
-
-       /** Linking Files and add entry point name iname */
-
-       if ( inum >=  MaxInterfaces ) 
-       {
-               /* Try to resize DynInterf */
-               if ( ( !reallocDynInterf() ) || ( inum >=  MaxInterfaces ) ) return -1;
-       }
-
-       subname = (char **)MALLOC(sizeof (char*));
-       subname[0]= spname;
+    ConfigVariable::EntryPointStr* pEP = ConfigVariable::getEntryPoint(_pwstModuleName);
+    if(pEP)
+    {//entry point already linked, so remove it before add it
+        ConfigVariable::removeDynamicLibrary(pEP->iLibIndex);
+    }
 
        /* link then search  */ 
-       /* Trying with the fortran symbol */
-       IdLib =  scilabLink(idinput,filenamelib,subname,one,TRUE,&ierr1);
-       if (ierr1!=0)
-       {
-               /* Haven't been able to find the symbol. Try C symbol */
-               IdLib =  scilabLink(idinput,filenamelib,subname,one,FALSE,&ierr1);
-       }
-
-       subname[0] = NULL;
-       if (subname) { FREE(subname);subname = NULL;}
-
-       if ( IdLib < 0 ) return IdLib;
-
-       /** store the linked function in the interface function table DynInterf **/
-       DynInterf[inum].Nshared = IdLib;
-
-       if ( SearchInDynLinks(spname,&DynInterf[inum].func) < 0 ) 
-       {
-               /* Maximum number of dynamic interfaces */
-               return -6;
-       }
-       else
+       /* Haven't been able to find the symbol. Try C symbol */
+    iLibID =  scilabLink(iLibID, _pwstDynamicLibraryName, &_pwstModuleName, 1, FALSE, &iErr);
+    if(iErr)
        {
-               strncpy(DynInterf[inum].name,spname,INTERFSIZE);
-               DynInterf[inum].ok = TRUE;
-       }
-       if ( inum == LastInterf ) LastInterf++;
-
-       k1 = inum+1;
-       for (i = 0;i < sizefcts; i++)
-       {
-               int id[nsiz],zero=0,three=3,fptr = 0,fptr1 = 0,four=4;
-
-               /* find a previous functions with same name */
-               C2F(cvname)(id,fcts[i],&zero,(unsigned long)strlen(fcts[i]));
-               fptr1 = fptr = (DynInterfStart+k1)*1000 +(i+1);
-               /* clear previous def set fptr1 to 0*/
-               C2F(funtab)(id,&fptr1,&four,"NULL_NAME",0); 
-               /* reinstall */
-               C2F(funtab)(id,&fptr,&three,fcts[i],(unsigned long)strlen(fcts[i])); 
-       }
-
-       return ierr;
+       /* Trying with the fortran symbol */
+        iLibID =  scilabLink(iLibID, _pwstDynamicLibraryName, &_pwstModuleName, 1, TRUE, &iErr);
+        if(iErr)
+        {
+            return iErr;
+        }
+    }
+
+    pEP = ConfigVariable::getEntryPoint(_pwstModuleName);
+    if(pEP == NULL)
+    {//
+        return -1;
+    }
+
+    for(int i = 0 ; i < _iEntryPointSize ; i++)
+    {
+        pEP->functionPtr(_pwstEntryPointName[i]);
+    }
+       return 0;
 }
 /*-----------------------------------------------------------------------------------*/
 static void initializeInterfaces(void)
 */
 
 /*---------------------------------------------------------------------------*/
+
+#include "configvariable.hxx"
+
+extern "C"
+{
 #include <string.h> 
 #include <stdio.h>
 #include <stdlib.h>
@@ -34,8 +39,9 @@
 #include "getshortpathname.h"
 #include "BOOL.h"
 #include "charEncoding.h"
+}
 /*---------------------------------------------------------------------------*/
-static void Underscores(int isfor, char *ename, char *ename1);
+static void Underscores(BOOL _bFortran, wchar_t* _pwstEntryPointName, wchar_t* _pwstTrailingName);
 static int SearchFandS(char *op, int ilib);
 /*---------------------------------------------------------------------------*/
 #define MAXNAME  256 
@@ -63,7 +69,7 @@ __declspec (dllexport) CINTER_struct C2F(ibfu);
 /*---------------------------------------------------------------------------*/
 typedef char Name[MAXNAME];   /* could be changed to dynamic structure */
 
-typedef void (*function) ();
+typedef void (*function) (wchar_t*);
 
 typedef struct 
 { 
@@ -84,44 +90,39 @@ static int Nshared = 0;
 static int NEpoints = 0; /* Number of Linked names */
 static Epoints EP[ENTRYMAX];  /* entryPoints */
 /*---------------------------------------------------------------------------*/
-int scilabLink(int idsharedlibrary,
-               char *filename,
-               char **subnamesarray,int sizesubnamesarray,
-               BOOL fflag,int *ierr)
+int scilabLink(int _iLibID, wchar_t* _pwstLibraryName, wchar_t** _pwstEntryPointName, int _iEntryPointSize, BOOL _bFortran ,int *_piErr)
 {
-    int IdSharedLib = -1; 
+    int iLibID = -1; 
 
-    initializeLink();
-
-    if (idsharedlibrary == -1) 
+    if(_iLibID == -1) 
     {
-        IdSharedLib = Sci_dlopen(filename);
+        iLibID = Sci_dlopen(_pwstLibraryName);
     } 
     else 
     {
-        IdSharedLib = idsharedlibrary;
+        iLibID = _iLibID;
     }
 
-    if (IdSharedLib == -1 ) 
+    if(iLibID == -1) 
     {
-        if ( getWarningMode() ) 
+        if( getWarningMode() ) 
         {
 #ifdef _MSC_VER
-            if (isDll(filename))
+            if(isDllW(_pwstLibraryName))
             {
 #ifdef _WIN64
-                if (isX86Dll(filename))
+                if(isX86DllW(_pwstLibraryName))
                 {
-                    if (getIlibVerboseLevel() != ILIB_VERBOSE_NO_OUTPUT)
+                    if(getIlibVerboseLevel() != ILIB_VERBOSE_NO_OUTPUT)
                     {
                         sciprint(_("%s: can not to load a x86 dll in a x64 environment.\n" ), "link");
                     }
                     SetLastError(ERROR_DLL_INIT_FAILED);
                 }
 #else
-                if (isX64Dll(filename))
+                if(isX64DllW(_pwstLibraryName))
                 {
-                    if (getIlibVerboseLevel() != ILIB_VERBOSE_NO_OUTPUT)
+                    if(getIlibVerboseLevel() != ILIB_VERBOSE_NO_OUTPUT)
                     {
                         sciprint(_("%s: can not load a x64 dll in a x86 environment.\n" ), "link");
                     }
@@ -131,78 +132,39 @@ int scilabLink(int idsharedlibrary,
             }
             else
             {
-                char *pathSearch = searchEnv(filename, "PATH");
-                if (pathSearch == NULL)
+                wchar_t* pwstPathSearch = searchEnvW(_pwstLibraryName, L"PATH");
+                if(pwstPathSearch == NULL)
                 {
-                    if (getIlibVerboseLevel() != ILIB_VERBOSE_NO_OUTPUT)
+                    if(getIlibVerboseLevel() != ILIB_VERBOSE_NO_OUTPUT)
                     {
-                        sciprint(_("%s: The file %s does not exist in PATH environment.\n" ),"link", filename);
+                        sciprintW(_W("%ls: The file %ls does not exist in PATH environment.\n" ), L"link", _pwstLibraryName);
                     }
                 }
             }
 #else
-            if (getIlibVerboseLevel() != ILIB_VERBOSE_NO_OUTPUT)
+            if(getIlibVerboseLevel() != ILIB_VERBOSE_NO_OUTPUT)
             {
-                sciprint(_("Link failed for dynamic library '%s'.\n"),filename);
-                sciprint(_("An error occurred: %s\n"),GetLastDynLibError());
+                sciprintW(_W("Link failed for dynamic library '%ls'.\n"), _pwstLibraryName);
+                sciprint(_("An error occurred: %s\n"), GetLastDynLibError());
             }
 #endif
         }
-        *ierr = -1;
-        return IdSharedLib;
+        *_piErr = -1;
+        return iLibID;
     }
 
-    if ( (idsharedlibrary == -1) && (getIlibVerboseLevel() != ILIB_VERBOSE_NO_OUTPUT)) 
+    if( (_iLibID == -1) && (getIlibVerboseLevel() != ILIB_VERBOSE_NO_OUTPUT)) 
     {
         sciprint(_("Shared archive loaded.\n"));
         sciprint(_("Link done.\n"));
     }
 
-    if (sizesubnamesarray > 0)
+    for(int i = 0 ; i < _iEntryPointSize ; i++)
     {
-        int errorcode = 0;
-        int i = 0;
-        for(i = 0; i < sizesubnamesarray ; i++)
-        {
-            if (fflag) 
-            {
-                errorcode = Sci_dlsym(subnamesarray[i],IdSharedLib,"f");
-            }
-            else 
-            {
-                errorcode = Sci_dlsym(subnamesarray[i],IdSharedLib,"c");
-            }
-
-            if (errorcode < 0) *ierr = errorcode;
-        }
+        *_piErr = Sci_dlsym(_pwstEntryPointName[i], iLibID, _bFortran);
     }
-    return IdSharedLib;
-}
-/*---------------------------------------------------------------------------*/
-int *getAllIdSharedLib(int *sizeList)
-{
-    int *ListId = NULL;
-    int i = 0;
 
-    *sizeList = 0;
-    for ( i = 0 ; i < Nshared ; i++) 
-    {
-        if ( hd[i].ok == TRUE) 
-        {
-            (*sizeList)++;
-            if (ListId)
-            {
-                ListId = (int *)REALLOC(ListId,(*sizeList)*sizeof(int));
-                ListId[(*sizeList)-1] = i;
-            }
-            else
-            {
-                ListId = (int *)MALLOC((*sizeList)*sizeof(int));
-                ListId[(*sizeList)-1] = i;
-            }
-        }
-    }
-    return ListId;
+    return iLibID;
 }
 /*---------------------------------------------------------------------------*/
 char **getNamesOfFunctionsInSharedLibraries(int *sizearray)
@@ -210,19 +172,19 @@ char **getNamesOfFunctionsInSharedLibraries(int *sizearray)
     char **NamesOfFunctions = NULL;
     *sizearray = 0;
 
-    if ( (NEpoints) && (NEpoints > 0) )
+    if( (NEpoints) && (NEpoints > 0) )
     {
         int i = 0;
         NamesOfFunctions = (char **) MALLOC((NEpoints)*sizeof(char *));
-        if (NamesOfFunctions)
+        if(NamesOfFunctions)
         {
             for ( i = NEpoints-1 ; i >= 0 ; i--) 
             {
-                if (EP[i].name)
+                if(EP[i].name)
                 {
                     char *EntryName = (char *)MALLOC(((int)strlen(EP[i].name)+1)*sizeof(char));
 
-                    if (EntryName)
+                    if(EntryName)
                     {
                         (*sizearray)++;
                         strcpy(EntryName , EP[i].name);
@@ -239,40 +201,29 @@ char **getNamesOfFunctionsInSharedLibraries(int *sizearray)
 * Underscores : deals with the trailing _ 
 * in entry names 
 */
-static void Underscores(int isfor, char *ename, char *ename1)
+static void Underscores(BOOL _bFortran, wchar_t* _pwstEntryPointName, wchar_t* _pwstTrailingName)
 {
 #ifdef WLU1
-    *ename1='_'; ename1++;
+    *_pwstTrailingName = L'_';
+    _pwstTrailingName++;
 #endif
-    strcpy(ename1,ename);
+    wcscpy(_pwstTrailingName, _pwstEntryPointName);
 #ifdef WTU
-    if (isfor==1) strcat(ename1,"_");
-#endif
-    return;
-}
-/*---------------------------------------------------------------------------*/
-void initializeLink(void)
-{
-    static int first_entry = 0;
-    int i;
-    if ( first_entry == 0)
+    if(_bFortran)
     {
-        for ( i = 0 ; i < ENTRYMAX ; i++) 
-        {
-            hd[i].ok= FALSE;
-            hd[i].shl = EP[i].Nshared = -1;
-        }
-        first_entry++;
+        wcscat(_pwstTrailingName, L"_");
     }
+#endif
+    return;
 }
 /*---------------------------------------------------------------------------*/
 BOOL c_link(char *routinename,int *ilib)
 {
     void (*loc)();
-    if ( *ilib != -1 ) *ilib = SearchFandS(routinename,*ilib);
+    if( *ilib != -1 ) *ilib = SearchFandS(routinename,*ilib);
     else *ilib = SearchInDynLinks(routinename,&loc);
 
-    if (*ilib == -1) return FALSE;
+    if(*ilib == -1) return FALSE;
     return TRUE;
 }
 /*---------------------------------------------------------------------------*/
@@ -283,21 +234,21 @@ void C2F(iislink)(char *routinename, int *ilib)
 /*---------------------------------------------------------------------------*/
 void GetDynFunc(int ii, void (**realop) ())
 {
-    if ( EP[ii].Nshared != -1 ) *realop = EP[ii].epoint;
-    else *realop = (function) 0;
+    //if( EP[ii].Nshared != -1 ) *realop = EP[ii].epoint;
+    //else *realop = (function) 0;
 }
 /*---------------------------------------------------------------------------*/
 int SearchInDynLinks(char *op, void (**realop) ())
 {
-    int i=0;
-    for ( i = NEpoints-1 ; i >=0 ; i--) 
-    {
-        if ( strcmp(op,EP[i].name) == 0) 
-        {
-            *realop = EP[i].epoint;
-            return(EP[i].Nshared );
-        }
-    }
+    //int i=0;
+    //for ( i = NEpoints-1 ; i >=0 ; i--) 
+    //{
+    //    if( strcmp(op,EP[i].name) == 0) 
+    //    {
+    //        *realop = EP[i].epoint;
+    //        return(EP[i].Nshared );
+    //    }
+    //}
     return(-1);
 }
 /*---------------------------------------------------------------------------*/
@@ -310,7 +261,7 @@ static int SearchFandS(char *op, int ilib)
     int i = 0;
     for ( i = NEpoints-1 ; i >=0 ; i--) 
     {
-        if ( strcmp(op,EP[i].name) == 0 && EP[i].Nshared == ilib)
+        if( strcmp(op,EP[i].name) == 0 && EP[i].Nshared == ilib)
         {
             return(i);
         }
@@ -318,39 +269,6 @@ static int SearchFandS(char *op, int ilib)
     return(-1);
 }
 /*---------------------------------------------------------------------------*/
-void ShowDynLinks(void)
-{
-    int i=0,count=0;
-    if (getIlibVerboseLevel() != ILIB_VERBOSE_NO_OUTPUT) sciprint(_("Number of entry points %d.\nShared libraries :\n"),NEpoints);
-    if (getIlibVerboseLevel() != ILIB_VERBOSE_NO_OUTPUT) sciprint("[ ");
-    for ( i = 0 ; i < Nshared ; i++) 
-    {
-        if ( hd[i].ok == TRUE) 
-        { 
-            if (getIlibVerboseLevel() != ILIB_VERBOSE_NO_OUTPUT) 
-            {
-                sciprint("%d ",i);count++;
-            }
-        }
-    }
-
-    if (getIlibVerboseLevel() != ILIB_VERBOSE_NO_OUTPUT) 
-    {
-        if ( (count == 1) || (count == 0) )
-        {
-            sciprint(_("] : %d library.\n"),count);
-        }
-        else
-        {
-            sciprint(_("] : %d libraries.\n"),count);
-        }
-    }
-
-    for ( i = NEpoints-1 ; i >=0 ; i--) 
-    {
-        if (getIlibVerboseLevel() != ILIB_VERBOSE_NO_OUTPUT) sciprint(_("Entry point %s in shared library %d.\n"),EP[i].name,EP[i].Nshared);
-    }
-}
 /*---------------------------------------------------------------------------*/
 void unlinkallsharedlib(void)
 {
@@ -369,109 +287,106 @@ void unlinksharedlib(int *i)
     RemoveInterf(*i);
 }
 /*---------------------------------------------------------------------------*/
-int Sci_dlopen( char *loaded_file)
+int Sci_dlclose(unsigned long _hLib)
 {
-    static DynLibHandle  hd1 = NULL;
+#ifdef _MSC_VER
+        return FreeDynLibrary ((DynLibHandle) ULongToHandle(_hLib));
+#else
+        return FreeDynLibrary ((DynLibHandle) _hLib);
+#endif
+}
+/*---------------------------------------------------------------------------*/
+int Sci_dlopen(wchar_t* _pwstDynLibPath)
+{
+    static DynLibHandle hLib = NULL;
     int i = 0;
 
-    BOOL bConvert = FALSE;
-
 #ifdef _MSC_VER
     {
-        wchar_t *wcfilename = to_wide_string(loaded_file);
-        if (wcfilename)
-        {
-            hd1 = LoadDynLibraryW(wcfilename);
-            FREE(wcfilename);
-            wcfilename = NULL;
-        }
+        hLib = LoadDynLibraryW(_pwstDynLibPath);
     }
 #else
-    hd1 = LoadDynLibrary (loaded_file);
-#endif
-
-    if ( hd1 == NULL )  return -1 ; /* the shared archive was not loaded. */
-
-    for ( i = 0 ; i < Nshared ; i++ ) 
     {
-        if ( hd[i].ok == FALSE) 
-        {
-            /* Warning x64 windows */
-#ifdef _MSC_VER
-            hd[i].shl =  PtrToUlong(hd1);
-#else
-            hd[i].shl = (unsigned long)hd1;
-#endif
-
-            hd[i].ok = TRUE;
-            return(i);
-        }
+        char* pstDynLibPath = wide_string_to_UTF8(_pwstDynLibPath);
+        hLib = LoadDynLibrary (pstDynLibPath);
+        FREE(pstDynLibPath);
     }
+#endif
 
-    if ( Nshared == ENTRYMAX ) 
+    if(hLib == NULL)
     {
-        if (getIlibVerboseLevel() != ILIB_VERBOSE_NO_OUTPUT) sciprint(_("Cannot open shared files max entry %d reached.\n"),ENTRYMAX);
-        return(FALSE);
+        return -1 ; /* the shared archive was not loaded. */
     }
+
     /* Warning x64 windows */
+
+    ConfigVariable::DynamicLibraryStr* pDL = ConfigVariable::getNewDynamicLibraryStr();
+    ConfigVariable::setLibraryName(pDL, _pwstDynLibPath);
 #ifdef _MSC_VER
-    hd[Nshared].shl =   PtrToUlong(hd1);
+    pDL->hLib =   PtrToUlong(hLib);
 #else
-    hd[Nshared].shl = (unsigned long)hd1;
+    pDL->hLib = (unsigned long)hLib;
 #endif
-    hd[Nshared].ok = TRUE;
-    Nshared ++;
 
-    return Nshared-1;
+    
+    return ConfigVariable::addDynamicLibrary(pDL);
 }
 /*---------------------------------------------------------------------------*/
-int Sci_dlsym(char *ename,int ishared,char *strf)
+int Sci_dlsym(wchar_t* _pwstEntryPointName, int _iLibID, BOOL _bFortran)
 {
-    DynLibHandle hd1 = NULL;
-    int ish = Min(Max(0,ishared),ENTRYMAX-1);
-    char enamebuf[MAXNAME];
+    DynLibHandle hDynLib = NULL;
+    ConfigVariable::EntryPointStr* pEP = ConfigVariable::getNewEntryPointStr();
+    //+3 : 1 for '\0', 1 for prefix _, 1 for suffix _
+    wchar_t* pwstEntryPointName = (wchar_t*)MALLOC(sizeof(wchar_t) * (wcslen(_pwstEntryPointName) + 3));
+    memset(pwstEntryPointName, 0x00, (wcslen(_pwstEntryPointName) + 3));
 
-    if ( strf[0] == 'f' ) Underscores(1,ename,enamebuf);
-    else Underscores(0,ename,enamebuf);
+    Underscores(_bFortran, _pwstEntryPointName, pwstEntryPointName);
 
-    /* lookup the address of the function to be called */
-    if ( NEpoints == ENTRYMAX ) 
-    {
-        return -1;
-    }
-    if ( hd[ish].ok == FALSE )
-    {
+    
+    if(_iLibID < 0 || ConfigVariable::isDynamicLibrary(_iLibID) == false)
+    {//no valid library at this ID
         return -3;
     }
+
     /** entry was previously loaded **/
-    if ( SearchFandS(ename,ish) >= 0 ) 
+    if(ConfigVariable::getEntryPoint(_pwstEntryPointName, _iLibID) != NULL)
     {
-        sciprint(_("Entry name %s.\n"),ename);
+        sciprintW(_W("Entry name %ls.\n"), _pwstEntryPointName);
         return -4;
     }
-    else
-    {
-        /* Warning x64 windows */
+
+    /* Warning x64 windows */
+    pEP->iLibIndex = _iLibID;
 #ifdef _MSC_VER
-        hd1 = (DynLibHandle)  ULongToHandle(hd[ish].shl);
+    hDynLib = (DynLibHandle)  ULongToHandle(ConfigVariable::getDynamicLibrary(_iLibID)->hLib);
 #else
-        hd1 = (DynLibHandle)  hd[ish].shl;
+    hDynLib = (DynLibHandle)  ConfigVariable::getDynamicLibrary(_iLibID)->hLib;
 #endif
-        EP[NEpoints].epoint = (function) GetDynLibFuncPtr (hd1,enamebuf);
-        if ( EP[NEpoints].epoint == NULL )
-        {
-            if (getIlibVerboseLevel() != ILIB_VERBOSE_NO_OUTPUT) sciprint(_("%s is not an entry point.\n"),enamebuf);
-            return -5;
-        }
-        else 
+#ifdef _MCS_VER
+    pEP->functionPtr = (function) GetDynLibFuncPtrW(hDynLib, pwstEntryPointName);
+#else
+    char* pstEntryPointName = wide_string_to_UTF8(pwstEntryPointName);
+    pEP->functionPtr = (function) GetDynLibFuncPtr(hDynLib, pstEntryPointName);
+    FREE(pstEntryPointName);
+#endif    
+    if(pEP->functionPtr == NULL)
+    {
+        if(getIlibVerboseLevel() != ILIB_VERBOSE_NO_OUTPUT)
         {
-            /* we don't add the _ in the table */
-            if (debug) sciprint(_("Linking %s.\n"), ename);
-            strncpy(EP[NEpoints].name,ename,MAXNAME);
-            EP[NEpoints].Nshared = ish;
-            NEpoints++;
+            sciprintW(_W("%ls is not an entry point.\n"), _pwstEntryPointName);
         }
+        return -5;
+    }
+
+    /* we don't add the _ in the table */
+    if(debug)
+    {
+        sciprintW(_W("Linking %ls.\n"), _pwstEntryPointName);
     }
+
+    ConfigVariable::setEntryPointName(pEP, _pwstEntryPointName);
+    ConfigVariable::addEntryPoint(pEP);
+    FREE(pwstEntryPointName);
     return 0;  
 }
 /*---------------------------------------------------------------------------*/
@@ -481,7 +396,7 @@ void Sci_Delsym(int ishared)
     int i=0;
     for ( i = NEpoints-1 ; i >=0 ; i--) 
     {
-        if ( EP[i].Nshared == ish )
+        if( EP[i].Nshared == ish )
         {
             int j;
             for ( j = i ; j <= NEpoints - 2 ; j++ )
@@ -493,7 +408,7 @@ void Sci_Delsym(int ishared)
             NEpoints--;
         }
     }
-    if ( hd[ish].ok != FALSE)
+    if( hd[ish].ok != FALSE)
     {
         /* Warning x64 windows */
 #ifdef _MSC_VER
index db20287..fc6472d 100644 (file)
@@ -48,7 +48,10 @@ INCLUDES=-I"$(SCIDIR)/libs/MALLOC/includes" \
 -I"$(SCIDIR)/modules/windows_tools/includes" \
 -I"$(SCIDIR)/libs/f2c" \
 -I"$(SCIDIR)/libs/hashtable" \
--I"$(SCIDIR)/libs/intl"
+-I"$(SCIDIR)/libs/intl" \
+-I"$(SCIDIR)/modules/operations/includes" \
+-I"$(SCIDIR)/modules/symbol/includes" \
+-I"$(SCIDIR)/modules/types/includes"
 #==================================================
 CC_LDFLAGS = 
 #==================================================
@@ -111,7 +114,9 @@ SCILAB_LIBS="$(SCIDIR1)/bin/MALLOC.lib" "$(SCIDIR1)/bin/blasplus.lib" \
 "$(SCIDIR1)/bin/libintl.lib" "$(SCIDIR1)/bin/linpack_f.lib" \
 "$(SCIDIR1)/bin/call_scilab.lib" "$(SCIDIR1)/bin/time.lib" \
 "$(SCIDIR1)/bin/api_scilab.lib" "$(SCIDIR1)/bin/hashtable.lib" \
-"$(SCIDIR1)/bin/scilab_windows.lib" 
+"$(SCIDIR1)/bin/scilab_windows.lib" "$(SCIDIR1)/bin/operations.lib" \
+"$(SCIDIR1)/bin/symbol.lib"
+
 #==================================================
 # default rules for Fortran 77 & 90 Compilation 
 #==================================================
index aa1582b..46e0ab0 100644 (file)
@@ -1,27 +1,41 @@
 #include <math.h>
 #include "stack-c.h" 
+#include "api_scilab.h"
+#include "api_oldstack.h"
 
 static double fun2(double x);
-     
+
 void fun1(double *x,double *y) 
 {
-  *y=fun2(*x)/(*x); 
+    *y=fun2(*x)/(*x); 
 } 
 
 static double fun2(double x)
 { 
-  return( sin(x+1));
+    return( sin(x+1));
 }
 
-int intfun1(char *fname) 
+int intfun1(char *fname, int* _piKey) 
 {
-  int m1,n1,l1;
-  CheckRhs(1,1);
-  CheckLhs(1,1);
-  GetRhsVar(1, MATRIX_OF_DOUBLE_DATATYPE, &m1, &n1, &l1);
-  fun1(stk(l1),stk(l1));
-  LhsVar(1) = 1;
-  return 0;
+    SciErr sciErr;
+    int* piAddr = NULL;
+    double dblIn = 0;
+    double dblOut = 0;
+    CheckRhs(1,1);
+    CheckLhs(1,1);
+
+    sciErr = getVarAddressFromPosition(_piKey, 1, &piAddr);
+    if(sciErr.iErr != 0)
+    {//error
+        return 1;
+    }
+
+    getScalarDouble(_piKey, piAddr, &dblIn); 
+    fun1(&dblIn, &dblOut);
+
+    createScalarDouble(_piKey, Rhs + 1, dblOut);
+    LhsVar(1) = Rhs + 1;
+    return 0;
 }
 
 
index 623ac16..341b9b6 100644 (file)
@@ -184,6 +184,8 @@ private :
 public :
     static void setPromptMode(int _iPromptMode);
     static int getPromptMode(void);
+    static bool isPromptShow(void);
+
     static void setSilentError(int _iSilentError);
     static int getSilentError(void);
 
@@ -211,7 +213,48 @@ public :
     static void DecreasePauseLevel();
     static int getPauseLevel();
 
+// Dynamic Libraries
+
+    typedef struct 
+    {
+        wchar_t* pwstLibraryName;   /** name of dynamic library **/
+        unsigned long  hLib;        /** handle of the library **/
+    } DynamicLibraryStr;
+
+    typedef struct 
+    {
+        wchar_t* pwstEntryPointName;    /** name of interface **/
+        int iLibIndex;                  /** name of interface **/
+        void (*functionPtr)(wchar_t*);          /** entrypoint for the interface **/
+        bool bOK;                       /** flag set to TRUE if entrypoint can be used **/
+    } EntryPointStr;
+
+private :
+    static std::list<EntryPointStr*> m_EntryPointList;
+    static std::vector<DynamicLibraryStr*> m_DynLibList;
+public :
 
+    /* tools fucntions */
+    static void setLibraryName(DynamicLibraryStr* _pDynamicLibrary, wchar_t* _pwstLibraryName);
+    static void setEntryPointName(EntryPointStr* _pEntryPoint, wchar_t* _pwstEntryPointName);
+
+    /* "Constructors" */
+    static DynamicLibraryStr* getNewDynamicLibraryStr();
+    static EntryPointStr* getNewEntryPointStr();
+
+    /* Dynamic libraries functions */
+    static std::vector<DynamicLibraryStr*>* getDynamicLibraryList();
+    static int addDynamicLibrary(DynamicLibraryStr* _pDynamicLibrary);
+    static void removeDynamicLibrary(int _iDynamicLibraryIndex);
+    static DynamicLibraryStr* getDynamicLibrary(int _iDynamicLibraryIndex);
+    static bool isDynamicLibrary(int _iDynamicLibraryIndex);
+
+    /* Entry point functions */
+    static std::list<EntryPointStr*>* getEntryPointList();
+    static void addEntryPoint(EntryPointStr* _pEP);
+    static void removeEntryPoint(int _iEntryPointIndex);
+    static EntryPointStr* getEntryPoint(wchar_t* _pwstEntryPointName, int _iDynamicLibraryIndex = -1);
+    static std::vector<std::wstring> getEntryPointNameList();
 };
 
-#endif /* __CONFIGVARIABLE_HXX__ */
+#endif /* !__CONFIGVARIABLE_HXX__ */
index 41f63da..027a09f 100644 (file)
@@ -16,6 +16,7 @@ extern "C"
 {
 #include "strsubst.h"
 #include "os_wcsdup.h"
+#include "MALLOC.h"
 }
 /*
 ** Module List
@@ -365,6 +366,10 @@ int ConfigVariable::m_iSilentError = 0;
 void ConfigVariable::setPromptMode(int _iPromptMode)
 {
     m_iPromptMode = _iPromptMode;
+    if(m_iPromptMode == 0)
+    {
+        //m_iPromptMode = -1;
+    }
 }
 
 int ConfigVariable::getPromptMode(void)
@@ -372,6 +377,21 @@ int ConfigVariable::getPromptMode(void)
     return m_iPromptMode;
 }
 
+bool ConfigVariable::isPromptShow(void)
+{
+    if( m_iPromptMode == 0 || 
+        m_iPromptMode == 1 || 
+        m_iPromptMode == 2 || 
+        m_iPromptMode == 3)
+    {
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
 void ConfigVariable::setSilentError(int _iSilentError)
 {
     m_iSilentError = _iSilentError;
@@ -524,3 +544,169 @@ int ConfigVariable::getPauseLevel()
 /*
 ** \}
 */
+
+/*
+** Dynamic Link
+** \{
+*/
+
+std::vector<ConfigVariable::DynamicLibraryStr*> ConfigVariable::m_DynLibList;
+std::list<ConfigVariable::EntryPointStr*> ConfigVariable::m_EntryPointList;
+
+
+ConfigVariable::DynamicLibraryStr* ConfigVariable::getNewDynamicLibraryStr()
+{
+    DynamicLibraryStr* pDL = (DynamicLibraryStr*)MALLOC(sizeof(DynamicLibraryStr));
+    pDL->pwstLibraryName = NULL;
+    pDL->hLib = 0;
+    return pDL;
+}
+
+ConfigVariable::EntryPointStr* ConfigVariable::getNewEntryPointStr()
+{
+    EntryPointStr* pEP = (EntryPointStr*)MALLOC(sizeof(EntryPointStr));
+    pEP->bOK = false;
+    pEP->functionPtr = NULL;
+    pEP->iLibIndex = -1;
+    pEP->pwstEntryPointName = NULL;
+    return pEP;
+}
+
+void ConfigVariable::setLibraryName(ConfigVariable::DynamicLibraryStr* _pDynamicLibrary, wchar_t* _pwstLibraryName)
+{
+    if(_pDynamicLibrary)
+    {
+        if(_pDynamicLibrary->pwstLibraryName)
+        {
+            FREE(_pDynamicLibrary->pwstLibraryName);
+        }
+        _pDynamicLibrary->pwstLibraryName = os_wcsdup(_pwstLibraryName);
+    }
+}
+
+void ConfigVariable::setEntryPointName(ConfigVariable::EntryPointStr* _pEntryPoint, wchar_t* _pwstEntryPointName)
+{
+    if(_pEntryPoint)
+    {
+        if(_pEntryPoint->pwstEntryPointName)
+        {
+            FREE(_pEntryPoint->pwstEntryPointName);
+        }
+        _pEntryPoint->pwstEntryPointName = os_wcsdup(_pwstEntryPointName);;
+    }
+}
+
+/* Dynamic libraries functions */
+int ConfigVariable::addDynamicLibrary(ConfigVariable::DynamicLibraryStr* _pDynamicLibrary)
+{
+    for(int i = 0 ; i < m_DynLibList.size() ; i++)
+    {
+        if(m_DynLibList[i] == NULL)
+        {
+            m_DynLibList[i] = _pDynamicLibrary;
+            return i;
+        }
+    }
+
+    m_DynLibList.push_back(_pDynamicLibrary);
+    return m_DynLibList.size() - 1;
+}
+
+void ConfigVariable::removeDynamicLibrary(int _iDynamicLibraryIndex)
+{
+    if(_iDynamicLibraryIndex < m_DynLibList.size())
+    {
+        std::list<EntryPointStr*>::const_iterator it;
+        for(it = m_EntryPointList.begin() ; it != m_EntryPointList.end() ; it++)
+        {//clear all entry points linked to removed dynamic library
+            if((*it)->iLibIndex == _iDynamicLibraryIndex)
+            {
+                m_EntryPointList.remove(*it);
+                if(m_EntryPointList.size() == 0)
+                {
+                    break;
+                }
+                it = m_EntryPointList.begin();
+            }
+        }
+        //remove dynamic library
+        m_DynLibList[_iDynamicLibraryIndex] = NULL;
+    }
+
+    //clean dynamic library vector
+    while(m_DynLibList.size() != 0 && m_DynLibList.back() == NULL)
+    {
+        m_DynLibList.pop_back();
+    }
+}
+
+ConfigVariable::DynamicLibraryStr* ConfigVariable::getDynamicLibrary(int _iDynamicLibraryIndex)
+{
+    if(_iDynamicLibraryIndex < m_DynLibList.size())
+    {
+        return m_DynLibList[_iDynamicLibraryIndex];
+    }
+    return NULL;
+}
+
+bool ConfigVariable::isDynamicLibrary(int _iDynamicLibraryIndex)
+{
+    if(_iDynamicLibraryIndex < m_DynLibList.size())
+    {
+        if(m_DynLibList[_iDynamicLibraryIndex] != NULL)
+        {
+            return true;
+        }
+    }
+    return false;
+}
+
+void ConfigVariable::addEntryPoint(ConfigVariable::EntryPointStr* _pEP)
+{
+    if(_pEP != NULL)
+    {
+        m_EntryPointList.push_back(_pEP);
+    }
+}
+
+ConfigVariable::EntryPointStr* ConfigVariable::getEntryPoint(wchar_t* _pwstEntryPointName, int _iDynamicLibraryIndex)
+{
+    std::list<EntryPointStr*>::const_iterator it;
+    for(it = m_EntryPointList.begin() ; it != m_EntryPointList.end() ; it++)
+    {
+        //by pass iLibIndex check if _iDynamicLibraryIndex == -1
+        if(_iDynamicLibraryIndex == -1 || (*it)->iLibIndex == _iDynamicLibraryIndex)
+        {
+            if(wcscmp((*it)->pwstEntryPointName, _pwstEntryPointName) == 0)
+            {
+                return *it;
+            }
+        }
+    }
+    return NULL;
+}
+
+std::vector<std::wstring> ConfigVariable::getEntryPointNameList()
+{
+    std::vector<std::wstring> EntryPointNames;
+    std::list<EntryPointStr*>::const_iterator it;
+    for(it = m_EntryPointList.begin() ; it != m_EntryPointList.end() ; it++)
+    {
+        EntryPointNames.push_back((*it)->pwstEntryPointName);
+    }
+    return EntryPointNames;
+}
+
+std::vector<ConfigVariable::DynamicLibraryStr*>* ConfigVariable::getDynamicLibraryList()
+{
+    return &m_DynLibList;
+}
+
+std::list<ConfigVariable::EntryPointStr*>* ConfigVariable::getEntryPointList()
+{
+    return &m_EntryPointList;
+}
+
+/*
+** \}
+*/