Dynamic link update: 66/4166/6
Bruno JOFRET [Mon, 6 Jun 2011 15:50:32 +0000 (17:50 +0200)]
- Map link
- Map c_link
- Map ilib_verbose
- Correct deprecated call to fileinfo in ilib_gen_Make_unix.sci

Change-Id: Ib255b23452aaa3a244ebb8e9aced1ae0052708f3

12 files changed:
scilab/modules/dynamic_link/includes/gw_dynamic_link.h
scilab/modules/dynamic_link/macros/ilib_gen_Make_unix.sci
scilab/modules/dynamic_link/sci_gateway/c/gw_dynamic_link.c
scilab/modules/dynamic_link/sci_gateway/c/sci_c_link.c
scilab/modules/dynamic_link/sci_gateway/c/sci_ilib_verbose.c
scilab/modules/dynamic_link/sci_gateway/c/sci_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/src/c/dl_genErrorMessage.h
scilab/modules/dynamic_link/src/c/dynamic_link.vcxproj
scilab/modules/dynamic_link/src/c/dynamic_link.vcxproj.filters

index 31ad668..a5add06 100644 (file)
@@ -16,6 +16,7 @@
 #define __GW_DYNAMIC_LINK__
 
 #include "dynlib_dynamic_link.h"
+#include "dynlib_dynamic_link_gw.h"
 #include "api_scilab.h"
 /*--------------------------------------------------------------------------*/
 DYNAMIC_LINK_IMPEXP int gw_dynamic_link(void);
@@ -26,13 +27,14 @@ DYNAMIC_LINK_IMPEXP int gw_dynamic_link(void);
 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);
-DYNAMIC_LINK_IMPEXP int sci_link(char *fname,unsigned long fname_len);
 DYNAMIC_LINK_IMPEXP int sci_ulink(char *fname,unsigned long fname_len);
-DYNAMIC_LINK_IMPEXP int sci_c_link(char *fname,unsigned long fname_len);
-DYNAMIC_LINK_IMPEXP int sci_ilib_verbose(char *fname,unsigned long fname_len);
-// YaSp
-DYNAMIC_LINK_IMPEXP int sci_getdynlibext(char *fname, int* _piKey);
 
 /*--------------------------------------------------------------------------*/
+//YaSp
+DYNAMIC_LINK_GW_IMPEXP int sci_link(char *fname, int* _piKey);
+DYNAMIC_LINK_GW_IMPEXP int sci_c_link(char *fname, int* _piKey);
+DYNAMIC_LINK_GW_IMPEXP int sci_getdynlibext(char *fname, int* _piKey);
+DYNAMIC_LINK_GW_IMPEXP int sci_ilib_verbose(char *fname, int* _piKey);
+
 #endif /* __GW_DYNAMIC_LINK__ */
 /*--------------------------------------------------------------------------*/
index 7564f98..cbf006f 100644 (file)
@@ -148,11 +148,11 @@ function ilib_gen_Make_unix(names,   ..
                       mprintf(gettext("   %s: Did not copy %s: Source and target directories are the same (%s).\n"),"ilib_gen_Make",x,pathFrom);
                     end
                 end
-                
+
                 if ~isfile(file_name + file_extension) then
                   error(999, msprintf(_("%s: Wrong value for input argument #%d: existing file(s) expected.\n"), "ilib_gen_Make_unix", 2));
                 end
-                
+
                 filelist = filelist + " " + file_name + file_extension;
 
             else
@@ -164,7 +164,7 @@ function ilib_gen_Make_unix(names,   ..
                 // Not that we don't want to copy working files
                 ignoredFileExtension=[".lo",".la",".lai"]
                 for f=filesMatching(:)'
-                
+
                   if ~isfile(f) then
                     error(999, msprintf(_("%s: Wrong value for input argument #%d: existing file(s) expected.\n"), "ilib_gen_Make_unix", 2));
                   end
@@ -187,7 +187,7 @@ function ilib_gen_Make_unix(names,   ..
         end
     end
 
-    if ldflags <> '' | cflags <> '' | fflags <> '' | cc <> '' | fileinfo(commandpath+"/Makefile.orig") == [] | fileinfo(commandpath+"/libtool") == [] then
+    if ldflags <> '' | cflags <> '' | fflags <> '' | cc <> '' | ~isfile(commandpath+"/Makefile.orig") | ~isfile(commandpath+"/libtool") then
         // Makefile.orig doesn't exists or may be invalid regarding the flags
         // run the ./configure with the flags
 
@@ -266,10 +266,13 @@ function generateConfigure(workingPath, ..
     cmd = gencompilationflags_unix(ldflags, cflags, fflags, cc, "configure")
     cmd = workingPath+"/compilerDetection.sh "+cmd
 
+    if ( ilib_verbose() == 2 ) then
+      mprintf(gettext("   %s: Command: %s\n"),"ilib_gen_Make", cmd);
+    end
+
     [msg,ierr,stderr] = unix_g(cmd);
 
     if ( ilib_verbose() == 2 ) then
-       mprintf(gettext("   %s: Command: %s\n"),"ilib_gen_Make",cmd);
        mprintf(gettext("   Output: %s\n"),msg);
        mprintf(gettext("   stderr: %s\n"),stderr);
     end
index 414f335..115756e 100644 (file)
@@ -22,10 +22,10 @@ static gw_generic_table Tab[] =
        {sci_addinter,"addinter"},
        {sci_fort,"fort"},
        {sci_call,"call"},
-       {sci_link,"link"},
+       {NULL ,""}, //link
        {sci_ulink,"ulink"},
-       {sci_c_link,"c_link"},
-       {sci_ilib_verbose,"ilib_verbose"}
+       {NULL, ""}, //c_link
+       {NULL, ""} // ilib_verbose
 };
 /*--------------------------------------------------------------------------*/
 int gw_dynamic_link(void)
index 3b230ea..0e5af41 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) INRIA - Allan CORNET
+ * Copyright (C) DIGITEO - 2011 - 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
 /*--------------------------------------------------------------------------*/
 #include "gw_dynamic_link.h"
 #include "stack-c.h"
+#include "api_scilab.h"
+#include "api_oldstack.h"
 #include "dynamic_link.h"
 #include "MALLOC.h"
 #include "localization.h"
 #include "Scierror.h"
 /*--------------------------------------------------------------------------*/
-int sci_c_link(char *fname,unsigned long fname_len)
+int sci_c_link(char *fname, int* _piKey)
 {
-       int ilib = 0;
-
-       CheckRhs(1,2);
-       CheckLhs(1,2);
-
-       /* [test,ilib]=c_link(routine-name)  */
-       /* test = c_link(routine-name)  */
-       /* test = c_link(routine-name,num)  */
-
-       if (Rhs == 2)
-       {
-               if (VarType(2) == sci_matrix)
-               {
-                       int m1 = 0, n1 = 0, l1 = 0;
-                       GetRhsVar(2,MATRIX_OF_DOUBLE_DATATYPE,&m1,&n1,&l1);
-                       if ( (m1 == n1) && (n1 == 1) )
-                       {
-                               ilib =  (int)*stk(l1);
-                       }
-                       else
-                       {
-                               Scierror(999,_("%s : second argument must be a unique id of a shared library.\n"),fname);
-                               return 0;
-                       }
-               }
-               else
-               {
-                       Scierror(999,_("%s : second argument must be a unique id of a shared library.\n"),fname);
-                       return 0;
-               }
-       }
-       else ilib = -1;
-
-
-       if (VarType(1) == sci_strings)
-       {
-               char **routinename = NULL;
-               int m1 = 0, n1 = 0;
-               GetRhsVar(1,"S",&m1,&n1,&routinename);
-
-               if ( (m1 == 1) && (n1 == 1) )
-               {
-                       int *paramoutINT=(int*)MALLOC(sizeof(int));
-                       BOOL FindFunction = FALSE;
-
-                       FindFunction = c_link(routinename[0],&ilib);
-                       if (routinename) {FREE(routinename);routinename = NULL;}
-
-                       
-
-                       if ( FindFunction )
-                       {
-                               *paramoutINT=(int)(TRUE);
-                       }
-                       else
-                       {
-                               *paramoutINT=(int)(FALSE);
-                       }
-
-                       CreateVarFromPtr(Rhs+1,MATRIX_OF_BOOLEAN_DATATYPE, &n1, &n1, &paramoutINT);
-                       LhsVar(1)=Rhs+1;
-
-                       if (Lhs == 2)
-                       {
-                               int one = 1;
-                               int l = 0;
-
-                               CreateVar(Rhs+2, MATRIX_OF_INTEGER_DATATYPE, &one, &one,&l);
-                               *istk(l) = (int)ilib;
-                               LhsVar(2)=Rhs+2;
-                       }
-
-                       C2F(putlhsvar)();
-                       if (paramoutINT) {FREE(paramoutINT);paramoutINT=NULL;}
-                       
-               }
-               else
-               {
-                       Scierror(999,_("%s: Wrong type for input argument #%d: A string expected.\n"), fname,1);
-               }
-       }
-       else
-       {
-               SciError(201);
-       }
-       return 0;
+    SciErr sciErr;
+    int iRet = 0;
+    int ilib = 0;
+    int* piAddress;
+    int iType;
+
+    char *routinename   = NULL;
+    int paramoutINT     = 0;
+    BOOL FindFunction   = FALSE;
+
+    CheckRhs(1,2);
+    CheckLhs(1,2);
+
+    /* [test,ilib]=c_link(routine-name)  */
+    /* test = c_link(routine-name)  */
+    /* test = c_link(routine-name,num)  */
+
+    if(Rhs == 2)
+    {
+        sciErr = getVarAddressFromPosition(_piKey, 2, &piAddress);
+        if(sciErr.iErr)
+        {
+            printError(&sciErr, 0);
+            return sciErr.iErr;
+        }
+        sciErr = getVarType(_piKey, piAddress, &iType);
+        if(sciErr.iErr)
+        {
+            printError(&sciErr, 0);
+            return sciErr.iErr;
+        }
+
+        if(isDoubleType(_piKey, piAddress))
+        {
+            double pdblReal = 0;
+            if(getScalarDouble(_piKey, piAddress, &pdblReal))
+            {
+                Scierror(999, _("%s : second argument must be a unique id of a shared library.\n"),fname);
+                return 1;
+            }
+
+            ilib = (int)pdblReal;
+        }
+        else
+        {
+            Scierror(999 ,_("%s : second argument must be a unique id of a shared library.\n"),fname);
+            return 0;
+        }
+    }
+    else 
+    {
+        ilib = -1;
+    }
+
+    sciErr = getVarAddressFromPosition(_piKey, 1, &piAddress);
+    if(sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        return sciErr.iErr;
+    }
+
+    if(isStringType(_piKey, piAddress) == FALSE)
+    {
+        Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 1);
+        return 1;
+    }
+
+    if(getAllocatedSingleString(_piKey, piAddress, &routinename))
+    {
+        return 1;
+    }
+
+    FindFunction = c_link(routinename, &ilib);
+    FREE(routinename);
+
+    if(FindFunction)
+    {
+        paramoutINT = (int)(TRUE);
+    }
+
+    if(createScalarBoolean(_piKey, Rhs + 1, paramoutINT))
+    {
+        return 1;
+    }
+
+    LhsVar(1) = Rhs + 1;
+
+    if(Lhs == 2)
+    {
+        if(createScalarDouble(_piKey, Rhs + 2, ilib))
+        {
+            return 1;
+        }
+
+        LhsVar(2) = Rhs + 2;
+    }
+
+    PutLhsVar();
+    return 0;
 }
 /*--------------------------------------------------------------------------*/
index da3d833..40ecf9d 100644 (file)
@@ -1,79 +1,83 @@
 /*
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) DIGITEO - 2009 - Allan CORNET
-* 
+*
 * 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
 *
 */
 
-/*--------------------------------------------------------------------------*/ 
+/*--------------------------------------------------------------------------*/
 #include "gw_dynamic_link.h"
 #include "stack-c.h"
+#include "api_scilab.h"
+#include "api_oldstack.h"
 #include "ilib_verbose.h"
 #include "localization.h"
 #include "Scierror.h"
 /*--------------------------------------------------------------------------*/
-int sci_ilib_verbose(char *fname,unsigned long fname_len)
+int sci_ilib_verbose(char *fname, int* _piKey)
 {
-       Rhs = Max(0, Rhs);
+    SciErr sciErr;
+    int iRet        = 0;
+    int* piAddress  = NULL;
+    double dblLevel = 0;
+    int iLevel      = 0;
+
+    CheckRhs(0,1);
+    CheckLhs(1,1);
+
+    if(Rhs == 0)
+    {
+        if(createScalarDouble(_piKey, Rhs + 1, (double)getIlibVerboseLevel()))
+        {
+            return 1;
+        }
+
+        LhsVar(1) = Rhs + 1;
+    }
+    else
+    {
+        sciErr = getVarAddressFromPosition(_piKey, 1, &piAddress);
+        if(sciErr.iErr)
+        {
+            printError(&sciErr, 0);
+            return sciErr.iErr;
+        }
+
+        if(isDoubleType(_piKey, piAddress) == 0)
+        {
+            Scierror(999,_("%s: Wrong type for input argument #%d: A int expected.\n"),fname,1);
+            return 1;
+        }
 
-       CheckRhs(0,1);
-       CheckLhs(1,1);
+        if(getScalarDouble(_piKey, piAddress, &dblLevel))
+        {
+            return 1;
+        }
 
-       if (Rhs == 0)
-       {
-               int n = 1 ,l = 0;
-               ilib_verbose_level currentLevel = getIlibVerboseLevel();
-               
-               CreateVar(Rhs+1, MATRIX_OF_INTEGER_DATATYPE, &n, &n,&l);
-               *istk(l) = (int)currentLevel;
-               LhsVar(1) = Rhs + 1;
-       }
-       else
-       {
-               if ( VarType(1)== sci_matrix )
-               {
-                       int m1 = 0, n1 = 0, l1 = 0;
-                       GetRhsVar(1, MATRIX_OF_DOUBLE_DATATYPE, &m1, &n1, &l1);
-                       if ( (m1 == n1) && (n1 == 1) )
-                       {
-                               double dlevel = (double)*stk(l1);
-                               int level = (int) dlevel;
+        iLevel = (int)dblLevel;
+        if(dblLevel != (double)iLevel)
+        {
+            Scierror(999,_("%s: Wrong value for input argument #%d: A int expected.\n"),fname,1);
+            return 0;
+        }
 
-                               if (dlevel != (double)level)
-                               {
-                                       Scierror(999,_("%s: Wrong value for input argument #%d: A int expected.\n"),fname,1);
-                                       return 0;
-                               }
+        if(!setIlibVerboseLevel((ilib_verbose_level)iLevel))
+        {
+            Scierror(999, _("%s: Wrong value for input argument #%d: Must be in the set {%s}.\n"), fname, 1, "0,1,2");
+            return 1;
+        }
+        else
+        {
+            LhsVar(1) = 0;
+        }
+    }
 
-                               if ( !setIlibVerboseLevel((ilib_verbose_level)level) )
-                               {
-                                       Scierror(999,_("%s: Wrong value for input argument #%d: Must be in the set {%s}.\n"),fname,1,"0,1,2");
-                                       return 0;
-                               }
-                               else
-                               {
-                                       LhsVar(1) = 0;
-                               }
-                       }
-                       else
-                       {
-                               Scierror(999,_("%s: Wrong size for input argument #%d: A scalar expected.\n"),fname,1);
-                               return 0;
-                       }
-               }
-               else
-               {
-                       Scierror(999,_("%s: Wrong type for input argument #%d: A int expected.\n"),fname,1);
-                       return 0;
-               }
-       }
-       
-       C2F(putlhsvar)();
-       return 0;
+    PutLhsVar();
+    return 0;
 }
 /*--------------------------------------------------------------------------*/
index f7e1415..ca4da72 100644 (file)
@@ -1,19 +1,21 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) INRIA - Allan CORNET
- * 
+ *
  * 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
  *
  */
 
-/*-----------------------------------------------------------------------------------*/ 
+/*-----------------------------------------------------------------------------------*/
 #include <string.h>
 #include "gw_dynamic_link.h"
 #include "stack-c.h"
+#include "api_scilab.h"
+#include "api_oldstack.h"
 #include "Scierror.h"
 #include "dynamic_link.h"
 #include "MALLOC.h"
 #include "dl_genErrorMessage.h"
 #include "freeArrayOfString.h"
 #include "os_strdup.h"
+#include "os_wcsdup.h"
 /*-----------------------------------------------------------------------------------*/
-static int linkNoRhs(void);
-static int linkOneRhsShow(void);
+static int linkNoRhs(int *_piKey);
+static int linkOneRhsShow(int *_piKey);
 /*-----------------------------------------------------------------------------------*/
-int sci_link(char *fname,unsigned long fname_len)
+int sci_link(char *fname, int *_piKey)
 {
-       BOOL fflag = FALSE;
-       int idsharedlibrary = -1;
-
-       char *SharedLibraryName = NULL;
-
-       char **subname = NULL;
-       int sizesubname = 0;
-       int m2 = 0, n2 = 0;
-
-       char *param3flag = NULL;
-
-       int returnedID = -1;
-       int ierr = 0;
-
-       CheckRhs(0,3);
-       CheckLhs(1,1);
-
-       if (Rhs == 0)
-       {
-               return linkNoRhs();
-       }
-       else
-       {
-               if (Rhs >= 1)
-               {
-                       if (VarType(1)== sci_matrix)
-                       {
-                               int m1 = 0, n1 = 0, l1 = 0;
-                               GetRhsVar(1,MATRIX_OF_DOUBLE_DATATYPE,&m1,&n1,&l1);
-                               if ( (m1 == n1) && (n1 == 1) )
-                               {
-                                       idsharedlibrary= (int)*stk(l1);
-                               }
-                               else
-                               {
-                                       Scierror(999,_("%s : Wrong value for argument #%d: %s\n"),fname,1,_("Unique id of a shared library expected."));
-                                       return 0;
-                               }
-                       }
-                       else if (VarType(1) == sci_strings)
-                       {
-                               char **strings = NULL;
-                               int m1 = 0, n1 = 0;
-                               GetRhsVar(1,MATRIX_OF_STRING_DATATYPE,&m1,&n1,&strings);
-
-                               if ( (m1 == 1) && (n1 == 1) )
-                               {
-                                       SharedLibraryName = os_strdup(strings[0]);
-                                       freeArrayOfString(strings, m1*n1);
-                               }
-                               else
-                               {
-                                       freeArrayOfString(strings, m1*n1);
-                                       Scierror(999,_("%s : Wrong type for input argument #%d: %s\n"),fname,1,_("Unique dynamic library name expected."));
-                                       return 0;
-                               }
-
-                               if ( (Rhs == 1) && (strcmp(SharedLibraryName,"show")==0) )
-                               {
-                                       return linkOneRhsShow();
-                               }
-                       }
-                       else
-                       {
-                               Scierror(999,_("%s: Wrong type for input arguments: Strings expected.\n"),fname);
-                               return 0;
-                       }
-               }
-
-               if (Rhs >= 2)
-               {
-                       if (VarType(2) == sci_strings)
-                       {
-                               GetRhsVar(2,MATRIX_OF_STRING_DATATYPE,&m2,&n2,&subname);
-                               if ( ((m2 == 1) && (n2 >= 1)) || ((m2 >= 1) && (n2 == 1)) )
-                               {
-                                       if ((m2 == 1) && (n2 >= 1)) sizesubname = n2;
-                                       if ((m2 >= 1) && (n2 == 1)) sizesubname = m2;
-                               }
-                               else
-                               {
-                                       freeArrayOfString(subname,m2*n2);
-                                       Scierror(999,_("%s: Wrong type for input argument. Strings vector expected.\n"),fname);
-                                       return 0;
-                               }
-                       }
-                       else
-                       {
-                               Scierror(999,_("%s: Wrong type for input argument. Strings expected.\n"),fname);
-                               return 0;
-                       }
-               }
-
-               if (Rhs == 3)
-               {
-                       int m3 = 0,n3 = 0,l3 = 0;
-                       GetRhsVar(3,STRING_DATATYPE,&m3,&n3,&l3);
-                       if ( ( strcmp(cstk(l3),"f") == 0 ) || ( strcmp(cstk(l3),"c") == 0 ) )
-                       {
-                               param3flag = (char*)MALLOC(sizeof(char)*( strlen( cstk(l3) )+1 ) );
-                               strcpy(param3flag,cstk(l3));
-                       }
-                       else
-                       {
-                               Scierror(999,_("%s Wrong value for input argument #%d: '%s' or '%s' expected.\n"),fname,3,"f","c");
-                               return 0;
-                       }
-               }
-               else
-               {
-                       param3flag = os_strdup("f");
-               }
-
-               if (strcmp("f",param3flag)==0) fflag = TRUE;
-               else fflag = FALSE;
-
-               returnedID = scilabLink(idsharedlibrary,SharedLibraryName,subname,sizesubname,fflag,&ierr);
-               if (ierr == 0)
-               {
-                       int n = 1 ,l = 0;
-                       CreateVar(Rhs+1, MATRIX_OF_INTEGER_DATATYPE, &n, &n,&l);
-                       *istk(l) = (int)returnedID;
-                       LhsVar(1)=Rhs+1;
-                       C2F(putlhsvar)();
-               }
-               else
-               {
-                       dl_genErrorMessage(fname, ierr, SharedLibraryName);
-               }
-               
-               if (Rhs >= 2)
-               {
-                       freeArrayOfString(subname,m2*n2);
-               }
-
-               if (SharedLibraryName) { FREE(SharedLibraryName); SharedLibraryName=NULL;}
-       }
-
-       if (param3flag) {FREE(param3flag); param3flag=NULL;}
-
-       return 0;
+    SciErr sciErr;
+    BOOL fflag              = TRUE;
+    int idsharedlibrary     = -1;
+    char *SharedLibraryName = NULL;
+    wchar_t param3flag      = L'f';
+
+    char **pstSubName       = NULL;
+    int iRowsSubName        = 0;
+    int iColsSubName        = 0;
+    int iSizeSubName        = 0;
+
+    int returnedID          = -1;
+    int iErr                = 0;
+
+    CheckRhs(0,3);
+    CheckLhs(1,1);
+
+    if(Rhs == 0)
+    {
+        return linkNoRhs(_piKey);
+    }
+    else
+    {
+        if(Rhs >= 1)
+        {
+            int* piAddress1 = NULL;
+            sciErr = getVarAddressFromPosition(_piKey, 1, &piAddress1);
+            if(sciErr.iErr)
+            {
+                printError(&sciErr, 0);
+                return 1;
+            }
+
+            if(isDoubleType(_piKey, piAddress1))
+            {
+                double pdblReal = 0;
+                if(getScalarDouble(_piKey, piAddress1, &pdblReal))
+                {
+                    Scierror(999, _("%s : Wrong value for argument #%d: %s\n"), fname, 1, _("Unique id of a shared library expected."));
+                    return 1;
+                }
+            }
+            else if(isStringType(_piKey, piAddress1))
+            {
+                if(getAllocatedSingleString(_piKey, piAddress1, &SharedLibraryName))
+                {
+                    FREE(SharedLibraryName);
+                    return 1;
+                }
+
+                if((Rhs == 1) && (strcmp(SharedLibraryName,"show") == 0))
+                {
+                    return linkOneRhsShow(_piKey);
+                }
+            }
+            else
+            {
+                Scierror(999, _("%s: Wrong type for input argument #%d: A scalar or a string expected.\n"), fname);
+                return 1;
+            }
+        }
+
+        if(Rhs >= 2)
+        {
+            int* piAddress2 = NULL;
+            sciErr = getVarAddressFromPosition(_piKey, 2, &piAddress2);
+            if(sciErr.iErr)
+            {
+                printError(&sciErr, 0);
+                return 1;
+            }
+
+            //string scalar or vector
+            if(isStringType(_piKey, piAddress2) && (isVector(_piKey, piAddress2) || isScalar(_piKey, piAddress2)))
+            {
+                if(getAllocatedMatrixOfString(_piKey, piAddress2, &iRowsSubName, &iColsSubName, &pstSubName))
+                {
+                    return 1;
+                }
+
+                iSizeSubName = iRowsSubName * iColsSubName;
+            }
+            else
+            {
+                Scierror(999, _("%s: Wrong type for input argument #%d: A string or a string vector expected.\n"));
+                return 1;
+            }
+        }
+
+        if(Rhs == 3)
+        {
+            int* piAddress3     = NULL;
+            wchar_t* pwstData   = NULL;
+            int iRows           = 0;
+            int iCols           = 0;
+
+            sciErr = getVarAddressFromPosition(_piKey, 3, &piAddress3);
+            if(sciErr.iErr)
+            {
+                printError(&sciErr, 0);
+                return 1;
+            }
+
+            if(getAllocatedSingleWideString(_piKey, piAddress3, &pwstData))
+            {
+                return 1;
+            }
+
+            if((wcscmp(pwstData, L"f") == 0) || (wcscmp(pwstData, L"c") == 0))
+            {
+                if(pwstData[0] != L'f')
+                {
+                    fflag = FALSE;
+                }
+            }
+            else
+            {
+                freeAllocatedSingleWideString(pwstData);
+                Scierror(999,_("%s Wrong value for input argument #%d: '%s' or '%s' expected.\n"), fname, 3, "f", "c");
+                return 0;
+            }
+        }
+
+
+        returnedID = scilabLink(idsharedlibrary, SharedLibraryName, pstSubName, iSizeSubName, fflag, &iErr);
+        if(iErr == 0)
+        {
+            if(createScalarDouble(_piKey, Rhs + 1, returnedID))
+            {
+                return 1;
+            }
+            LhsVar(1) = Rhs + 1;
+            PutLhsVar();
+        }
+        else
+        {
+            dl_genErrorMessage(fname, iErr, SharedLibraryName);
+        }
+
+        if(Rhs >= 2)
+        {
+            freeArrayOfString(pstSubName, iSizeSubName);
+        }
+
+        if(SharedLibraryName)
+        {
+            FREE(SharedLibraryName);
+            SharedLibraryName = NULL;
+        }
+    }
+
+    return 0;
 }
 /*-----------------------------------------------------------------------------------*/
-static int linkNoRhs(void)
+static int linkNoRhs(int* _piKey)
 {
-       int retval = 0;
-       static int l1 = 0,n1 = 0,m1 = 0;
-       int sizeFunctionsList = 0;
-       char ** FunctionsList = NULL;
-
-       FunctionsList = getNamesOfFunctionsInSharedLibraries(&sizeFunctionsList);
-
-       if ( (FunctionsList) && (sizeFunctionsList > 0) )
-       {
-               m1 = sizeFunctionsList;
-               n1 = 1;
-               CreateVarFromPtr(Rhs+1, MATRIX_OF_STRING_DATATYPE, &n1, &m1, FunctionsList);
-
-               LhsVar(1)=Rhs+1;
-               C2F(putlhsvar)();
-
-               freeArrayOfString(FunctionsList,sizeFunctionsList);
-       }
-       else
-       {
-               m1=0;
-               n1=0;
-               l1=0;
-               CreateVar(Rhs+1,MATRIX_OF_DOUBLE_DATATYPE,  &m1, &n1, &l1);
-               LhsVar(1)=Rhs+1;
-               C2F(putlhsvar)();
-       }
-       return retval;
+    SciErr sciErr;
+    int iRet = 0;
+    int sizeFunctionsList = 0;
+    char ** FunctionsList = NULL;
+
+    FunctionsList = getNamesOfFunctionsInSharedLibraries(&sizeFunctionsList);
+
+    if( (FunctionsList) && (sizeFunctionsList > 0) )
+    {
+        sciErr = createMatrixOfString(_piKey, Rhs + 1, 1, sizeFunctionsList, FunctionsList);
+        freeArrayOfString(FunctionsList,sizeFunctionsList);
+        if(sciErr.iErr)
+        {
+            printError(&sciErr, 0);
+            return sciErr.iErr;
+        }
+        LhsVar(1) = Rhs+1;
+        PutLhsVar();
+    }
+    else
+    {
+        iRet = createEmptyMatrix(_piKey, Rhs + 1);
+        if(iRet)
+        {
+            return iRet;
+        }
+        LhsVar(1) = Rhs+1;
+        PutLhsVar();
+    }
+    return 0;
 }
 /*-----------------------------------------------------------------------------------*/
-static int linkOneRhsShow(void)
+static int linkOneRhsShow(int *_piKey)
 {
-       int m1 = 0, n1 = 0, l1 = 0;
-       int *IdsList = NULL;
-       int sizeIds = 0;
-
-       ShowDynLinks();
-       IdsList = getAllIdSharedLib(&sizeIds);
-
-       if ( (sizeIds>0) && (IdsList) )
-       {
-               m1=1;
-               n1=sizeIds;
-               CreateVarFromPtr(Rhs+1, MATRIX_OF_INTEGER_DATATYPE, &m1, &n1, &IdsList);
-               if (IdsList) {FREE(IdsList); IdsList=NULL;}
-       }
-       else
-       {
-               m1=0;
-               n1=0;
-               l1=0;
-               CreateVar(Rhs+1,MATRIX_OF_DOUBLE_DATATYPE,  &m1, &n1, &l1);
-       }
-       LhsVar(1)=Rhs+1;
-       C2F(putlhsvar)();
-       return 0;
+    SciErr sciErr;
+    int iRet = 0;
+    int m1 = 0, n1 = 0, l1 = 0;
+    int *IdsList = NULL;
+    int sizeIds = 0;
+
+    ShowDynLinks();
+    IdsList = getAllIdSharedLib(&sizeIds);
+
+    if( (sizeIds>0) && (IdsList) )
+    {
+        sciErr = createMatrixOfInteger32(_piKey, Rhs + 1, 1, sizeIds, IdsList);
+        if(IdsList)
+        {
+            FREE(IdsList);
+            IdsList=NULL;
+        }
+        if(sciErr.iErr)
+        {
+            printError(&sciErr, 0);
+            return sciErr.iErr;
+        }
+    }
+    else
+    {
+        iRet = createEmptyMatrix(_piKey, Rhs + 1);
+        if(iRet)
+        {
+            return iRet;
+        }
+    }
+    LhsVar(1) = Rhs + 1;
+    PutLhsVar();
+    return 0;
 }
 /*-----------------------------------------------------------------------------------*/
index d7b775d..f5fe9c4 100644 (file)
@@ -23,5 +23,8 @@ extern "C"
 bool 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"c_link", &sci_c_link, MODULE_NAME));
+    symbol::Context::getInstance()->AddFunction(types::Function::createFunction(L"ilib_verbose", &sci_ilib_verbose, MODULE_NAME));
     return true;
 }
index b32dfff..247dcda 100644 (file)
@@ -77,7 +77,7 @@
     <ClCompile>
       <AdditionalOptions>%(AdditionalOptions)</AdditionalOptions>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>../../includes;../../../api_scilab/includes;../../../symbol/includes;../../../types/includes;../../../core/includes;../../../abstractSyntaxTree/includes;../../../localization/includes;../../../operations/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;%(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;../../../api_scilab/includes;../../../symbol/includes;../../../types/includes;../../../core/includes;../../../abstractSyntaxTree/includes;../../../localization/includes;../../../operations/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;%(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;../../../api_scilab/includes;../../../symbol/includes;../../../types/includes;../../../core/includes;../../../abstractSyntaxTree/includes;../../../localization/includes;../../../operations/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;%(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;../../../api_scilab/includes;../../../symbol/includes;../../../types/includes;../../../core/includes;../../../abstractSyntaxTree/includes;../../../localization/includes;../../../operations/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;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;DYNAMIC_LINK_GW_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClCompile Include="..\c\sci_c_link.c" />
+    <ClCompile Include="..\c\sci_getdynlibext.c" />
+    <ClCompile Include="..\c\sci_ilib_verbose.c" />
+    <ClCompile Include="..\c\sci_link.c" />
     <ClCompile Include="dynamic_link_gw.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\..\..\api_scilab\api_scilab.vcxproj">
       <Project>{43c5bab1-1dca-4743-a183-77e0d42fe7d0}</Project>
     </ProjectReference>
+    <ProjectReference Include="..\..\..\core\src\c\core.vcxproj">
+      <Project>{c6e2bc17-34d8-46e4-85f3-6293cb21adcd}</Project>
+    </ProjectReference>
     <ProjectReference Include="..\..\..\localization\src\localization.vcxproj">
       <Project>{ecffeb0c-1eda-45ee-9a10-b18143852e17}</Project>
     </ProjectReference>
+    <ProjectReference Include="..\..\..\output_stream\src\c\output_stream.vcxproj">
+      <Project>{a5911cd7-f8e8-440c-a23e-4843a0636f3a}</Project>
+    </ProjectReference>
     <ProjectReference Include="..\..\..\symbol\symbol.vcxproj">
       <Project>{2c60033b-0dbd-4ca4-80d3-176c9be9ce2f}</Project>
     </ProjectReference>
       <Project>{eab6c580-22b3-4359-ba1d-dd7499a96163}</Project>
     </ProjectReference>
   </ItemGroup>
+  <ItemGroup>
+    <Library Include="..\..\..\..\bin\libintl.lib" />
+  </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
index 571f612..1c501fb 100644 (file)
     <ClCompile Include="dynamic_link_gw.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\c\sci_c_link.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\c\sci_ilib_verbose.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\c\sci_link.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\c\sci_getdynlibext.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\includes\dynamic_link_gw.hxx">
@@ -26,4 +38,7 @@
       <Filter>Header Files</Filter>
     </ClInclude>
   </ItemGroup>
+  <ItemGroup>
+    <Library Include="..\..\..\..\bin\libintl.lib" />
+  </ItemGroup>
 </Project>
\ No newline at end of file
index 964a152..76c07c0 100644 (file)
@@ -19,5 +19,5 @@
  * @param errorCode the code of error
  * @param SharedLibraryName name of the library
  */
-void dl_genErrorMessage(char* fname, int errorCode, char* SharedLibraryName);
+DYNAMIC_LINK_IMPEXP void dl_genErrorMessage(char* fname, int errorCode, char* SharedLibraryName);
 /*--------------------------------------------------------------------------*/
index f6d6a9a..29314e2 100644 (file)
@@ -247,11 +247,7 @@ lib /DEF:"$(ProjectDir)Io_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformShor
     <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_c_link.c" />
     <ClCompile Include="..\..\sci_gateway\c\sci_call.c" />
-    <ClCompile Include="..\..\sci_gateway\c\sci_getdynlibext.c" />
-    <ClCompile Include="..\..\sci_gateway\c\sci_ilib_verbose.c" />
-    <ClCompile Include="..\..\sci_gateway\c\sci_link.c" />
     <ClCompile Include="..\..\sci_gateway\c\sci_ulink.c" />
   </ItemGroup>
   <ItemGroup>
index 51a0184..2a894ac 100644 (file)
     <ClCompile Include="..\..\sci_gateway\c\sci_addinter.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\sci_gateway\c\sci_c_link.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="..\..\sci_gateway\c\sci_call.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\sci_gateway\c\sci_getdynlibext.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\sci_gateway\c\sci_ilib_verbose.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\sci_gateway\c\sci_link.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="..\..\sci_gateway\c\sci_ulink.c">
       <Filter>Source Files</Filter>
     </ClCompile>