Merge remote-tracking branch 'origin/master' into YaSp 66/8866/2
Antoine ELIAS [Wed, 29 Aug 2012 15:02:01 +0000 (17:02 +0200)]
Conflicts:
scilab/Scilab_f2c.sln
scilab/configure
scilab/modules/core/sci_gateway/c/sci_getscilabmode.c
scilab/modules/core/src/c/stack2.c
scilab/modules/fileio/sci_gateway/c/sci_filesep.c
scilab/modules/fileio/sci_gateway/c/sci_getrelativefilename.c
scilab/modules/fileio/sci_gateway/c/sci_pathsep.c
scilab/modules/hdf5/Makefile.am
scilab/modules/hdf5/Makefile.in
scilab/modules/hdf5/includes/h5_writeDataToFile.h
scilab/modules/hdf5/sci_gateway/cpp/sci_export_to_hdf5.cpp
scilab/modules/hdf5/sci_gateway/cpp/sci_import_from_hdf5.cpp
scilab/modules/hdf5/src/c/h5_fileManagement.c
scilab/modules/hdf5/src/c/h5_readDataFromFile.c
scilab/modules/hdf5/src/c/h5_writeDataToFile.c
scilab/modules/hdf5/src/c/hdf5.vcxproj
scilab/modules/hdf5/src/c/hdf5.vcxproj.filters
scilab/modules/interpolation/sci_gateway/c/sci_linear_interpn.c
scilab/modules/javasci/src/c/javasci2_helper.c
scilab/modules/linear_algebra/macros/norm.sci
scilab/modules/localization/sci_gateway/c/sci_getlanguage.c
scilab/modules/matio/tests/unit_tests/loadmatfile.tst
scilab/modules/overloading/macros/%hm_max.sci
scilab/modules/overloading/macros/%hm_min.sci
scilab/modules/sparse/Makefile.in
scilab/modules/sparse/sci_gateway/c/gw_sparse.c
scilab/modules/sparse/sci_gateway/c/sci_spmax.c
scilab/modules/sparse/sci_gateway/c/sci_spmin.c
scilab/modules/tclsci/sci_gateway/c/sci_TCL_GetVersion.c
scilab/modules/windows_tools/sci_gateway/c/sci_mcisendstring.c

Change-Id: Ie046a804eb1b8698cf22929a39bf692b81faebd0

42 files changed:
1  2 
scilab/bin/scilab
scilab/configure
scilab/configure.ac
scilab/modules/arnoldi/sci_gateway/c/sci_eigs.c
scilab/modules/development_tools/macros/test_run.sci
scilab/modules/elementary_functions/sci_gateway/c/sci_maxi.c
scilab/modules/fftw/sci_gateway/c/sci_fftw.c
scilab/modules/hdf5/Makefile.am
scilab/modules/hdf5/Makefile.in
scilab/modules/hdf5/includes/gw_hdf5.h
scilab/modules/hdf5/includes/import_from_hdf5_v1.hxx
scilab/modules/hdf5/includes/listvar_in_hdf5_v1.hxx
scilab/modules/hdf5/sci_gateway/c/gw_hdf5.c
scilab/modules/hdf5/sci_gateway/cpp/sci_export_to_hdf5.cpp
scilab/modules/hdf5/sci_gateway/cpp/sci_import_from_hdf5.cpp
scilab/modules/hdf5/sci_gateway/cpp/sci_is_hdf5_file.cpp
scilab/modules/hdf5/sci_gateway/cpp/sci_listvar_in_hdf5.cpp
scilab/modules/hdf5/sci_gateway/hdf5_gateway.xml
scilab/modules/hdf5/src/c/core_Import.def
scilab/modules/hdf5/src/c/h5_fileManagement.c
scilab/modules/hdf5/src/c/h5_readDataFromFile.c
scilab/modules/hdf5/src/c/h5_writeDataToFile.c
scilab/modules/hdf5/src/c/hdf5.vcxproj
scilab/modules/hdf5/src/cpp/import_from_hdf5_v1.cpp
scilab/modules/hdf5/src/cpp/listvar_in_hdf5_v1.cpp
scilab/modules/interpolation/sci_gateway/c/sci_eval_cshep2d.c
scilab/modules/interpolation/sci_gateway/c/sci_linear_interpn.c
scilab/modules/linear_algebra/macros/cond.sci
scilab/modules/localization/sci_gateway/c/sci_getlanguage.c
scilab/modules/scicos_blocks/src/c/cscope.c
scilab/modules/sparse/Makefile.am
scilab/modules/sparse/Makefile.in
scilab/modules/sparse/src/c/sparse.vcxproj
scilab/modules/sparse/src/c/sparse.vcxproj.filters
scilab/modules/statistics/tests/unit_tests/cdfbet.tst
scilab/modules/tclsci/sci_gateway/c/sci_TCL_GetVersion.c
scilab/modules/ui_data/sci_gateway/cpp/sci_editvar.cpp
scilab/modules/windows_tools/sci_gateway/c/sci_chartooem.c
scilab/modules/windows_tools/sci_gateway/c/sci_mcisendstring.c
scilab/modules/windows_tools/sci_gateway/c/sci_oemtochar.c
scilab/modules/windows_tools/src/c/WScilex/WScilex.vcxproj.filters
scilab/modules/windows_tools/src/c/scilab_windows/FilesAssociations.c

Simple merge
@@@ -14136,7 -13734,7 +14134,7 @@@ $as_echo_n "checking gluegen2-rt... " >
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 14139 "configure"
 -// #line 13737 "configure"
++// #line 14137 "configure"
  import java.util.regex.Pattern;
  
  import jogamp.common.os.MachineDescriptionRuntime;
@@@ -14310,7 -13908,7 +14308,7 @@@ $as_echo_n "checking jhall... " >&6; 
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 14313 "configure"
 -// #line 13911 "configure"
++// #line 14311 "configure"
  import java.util.regex.Pattern;
  
  import javax.help.JHelp;
@@@ -14427,7 -14025,7 +14425,7 @@@ $as_echo_n "checking javahelp2... " >&6
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 14430 "configure"
 -// #line 14028 "configure"
++// #line 14428 "configure"
  import java.util.regex.Pattern;
  
  import javax.help.JHelp;
@@@ -14545,7 -14143,7 +14543,7 @@@ $as_echo_n "checking jrosetta-API... " 
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 14548 "configure"
 -// #line 14146 "configure"
++// #line 14546 "configure"
  import java.util.regex.Pattern;
  
  import com.artenum.rosetta.interfaces.core.ConsoleConfiguration;
@@@ -14660,7 -14258,7 +14658,7 @@@ $as_echo_n "checking jrosetta-api... " 
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 14663 "configure"
 -// #line 14261 "configure"
++// #line 14661 "configure"
  import java.util.regex.Pattern;
  
  import com.artenum.rosetta.interfaces.core.ConsoleConfiguration;
@@@ -14778,7 -14376,7 +14776,7 @@@ $as_echo_n "checking jrosetta-engine..
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 14781 "configure"
 -// #line 14379 "configure"
++// #line 14779 "configure"
  import java.util.regex.Pattern;
  
  import com.artenum.rosetta.core.action.AbstractConsoleAction;
@@@ -14884,7 -14482,7 +14882,7 @@@ $as_echo_n "checking minimal version (1
     if test "x" == "x"; then
  
      cat << \EOF > conftest.java
- // #line 14887 "configure"
 -// #line 14485 "configure"
++// #line 14885 "configure"
  import java.util.regex.Pattern;
  
  import com.artenum.rosetta.util.ConfigurationBuilder;
     else
  
      cat << \EOF > conftest.java
- // #line 14959 "configure"
 -// #line 14557 "configure"
++// #line 14957 "configure"
  import java.util.regex.Pattern;
  
  import com.artenum.rosetta.util.ConfigurationBuilder;
@@@ -15049,7 -14647,7 +15047,7 @@@ $as_echo_n "checking jeuclid-core... " 
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 15052 "configure"
 -// #line 14650 "configure"
++// #line 15050 "configure"
  import java.util.regex.Pattern;
  
  import net.sourceforge.jeuclid.LayoutContext;
@@@ -15168,7 -14766,7 +15166,7 @@@ $as_echo_n "checking fop... " >&6; 
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 15171 "configure"
 -// #line 14769 "configure"
++// #line 15169 "configure"
  import java.util.regex.Pattern;
  
  import org.apache.fop.pdf.PDFInfo;
@@@ -15285,7 -14883,7 +15283,7 @@@ $as_echo_n "checking batik-all... " >&6
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 15288 "configure"
 -// #line 14886 "configure"
++// #line 15286 "configure"
  import java.util.regex.Pattern;
  
  import org.apache.batik.parser.Parser;
@@@ -15402,7 -15000,7 +15400,7 @@@ $as_echo_n "checking batik... " >&6; 
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 15405 "configure"
 -// #line 15003 "configure"
++// #line 15403 "configure"
  import java.util.regex.Pattern;
  
  import org.apache.batik.parser.Parser;
@@@ -15509,7 -15107,7 +15507,7 @@@ $as_echo_n "checking minimal version (1
     if test "x" == "x"; then
  
      cat << \EOF > conftest.java
- // #line 15512 "configure"
 -// #line 15110 "configure"
++// #line 15510 "configure"
  import java.util.regex.Pattern;
  
  import org.apache.batik.Version;
     else
  
      cat << \EOF > conftest.java
- // #line 15584 "configure"
 -// #line 15182 "configure"
++// #line 15582 "configure"
  import java.util.regex.Pattern;
  
  import org.apache.batik.Version;
@@@ -15672,7 -15270,7 +15670,7 @@@ $as_echo_n "checking commons-io... " >&
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 15675 "configure"
 -// #line 15273 "configure"
++// #line 15673 "configure"
  import java.util.regex.Pattern;
  
  import org.apache.commons.io.output.CountingOutputStream;
@@@ -15789,7 -15387,7 +15787,7 @@@ $as_echo_n "checking xmlgraphics-common
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 15792 "configure"
 -// #line 15390 "configure"
++// #line 15790 "configure"
  import java.util.regex.Pattern;
  
  import org.apache.xmlgraphics.util.Service;
@@@ -15906,7 -15504,7 +15904,7 @@@ $as_echo_n "checking avalon-framework..
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 15909 "configure"
 -// #line 15507 "configure"
++// #line 15907 "configure"
  import java.util.regex.Pattern;
  
  import org.apache.avalon.framework.configuration.ConfigurationException;
@@@ -16023,7 -15621,7 +16021,7 @@@ $as_echo_n "checking xml-apis-ext... " 
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 16026 "configure"
 -// #line 15624 "configure"
++// #line 16024 "configure"
  import java.util.regex.Pattern;
  
  import org.w3c.dom.svg.SVGDocument;
@@@ -16140,7 -15738,7 +16138,7 @@@ $as_echo_n "checking xml-commons-apis-e
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 16143 "configure"
 -// #line 15741 "configure"
++// #line 16141 "configure"
  import java.util.regex.Pattern;
  
  import org.w3c.dom.svg.SVGDocument;
@@@ -16261,7 -15859,7 +16259,7 @@@ $as_echo_n "checking commons-logging..
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 16264 "configure"
 -// #line 15862 "configure"
++// #line 16262 "configure"
  import java.util.regex.Pattern;
  
  import org.apache.commons.logging.LogFactory;
@@@ -16378,7 -15976,7 +16376,7 @@@ $as_echo_n "checking jlatexmath... " >&
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 16381 "configure"
 -// #line 15979 "configure"
++// #line 16379 "configure"
  import java.util.regex.Pattern;
  
  import org.scilab.forge.jlatexmath.TeXFormula;
@@@ -16485,7 -16083,7 +16483,7 @@@ $as_echo_n "checking minimal version (0
     if test "x" == "x"; then
  
      cat << \EOF > conftest.java
- // #line 16488 "configure"
 -// #line 16086 "configure"
++// #line 16486 "configure"
  import java.util.regex.Pattern;
  
  import org.scilab.forge.jlatexmath.TeXFormula;
     else
  
      cat << \EOF > conftest.java
- // #line 16560 "configure"
 -// #line 16158 "configure"
++// #line 16558 "configure"
  import java.util.regex.Pattern;
  
  import org.scilab.forge.jlatexmath.TeXFormula;
@@@ -16654,7 -16252,7 +16652,7 @@@ $as_echo_n "checking checkstyle... " >&
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 16657 "configure"
 -// #line 16255 "configure"
++// #line 16655 "configure"
  import java.util.regex.Pattern;
  
  import com.puppycrawl.tools.checkstyle.CheckStyleTask;
@@@ -16771,7 -16369,7 +16769,7 @@@ $as_echo_n "checking commons-beanutils.
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 16774 "configure"
 -// #line 16372 "configure"
++// #line 16772 "configure"
  import java.util.regex.Pattern;
  
  import org.apache.commons.beanutils.Converter;
@@@ -16888,7 -16486,7 +16886,7 @@@ $as_echo_n "checking antlr... " >&6; 
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 16891 "configure"
 -// #line 16489 "configure"
++// #line 16889 "configure"
  import java.util.regex.Pattern;
  
  import antlr.TokenStreamException;
@@@ -17005,7 -16603,7 +17003,7 @@@ $as_echo_n "checking junit4... " >&6; 
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 17008 "configure"
 -// #line 16606 "configure"
++// #line 17006 "configure"
  import java.util.regex.Pattern;
  
  import org.junit.Assert;
@@@ -17122,7 -16720,7 +17120,7 @@@ $as_echo_n "checking cobertura... " >&6
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 17125 "configure"
 -// #line 16723 "configure"
++// #line 17123 "configure"
  import java.util.regex.Pattern;
  
  import net.sourceforge.cobertura.merge.Main;
@@@ -17239,7 -16837,7 +17237,7 @@@ $as_echo_n "checking asm3... " >&6; 
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 17242 "configure"
 -// #line 16840 "configure"
++// #line 17240 "configure"
  import java.util.regex.Pattern;
  
  import org.objectweb.asm.Type;
@@@ -17355,7 -16953,7 +17353,7 @@@ $as_echo_n "checking asm... " >&6; 
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 17358 "configure"
 -// #line 16956 "configure"
++// #line 17356 "configure"
  import java.util.regex.Pattern;
  
  import org.objectweb.asm.Type;
  
  
  #################
 +## EIGEN
 +#################
 +
 +
 +ac_ext=cpp
 +ac_cpp='$CXXCPP $CPPFLAGS'
 +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5
 +$as_echo_n "checking how to run the C++ preprocessor... " >&6; }
 +if test -z "$CXXCPP"; then
 +  if ${ac_cv_prog_CXXCPP+:} false; then :
 +  $as_echo_n "(cached) " >&6
 +else
 +      # Double quotes because CXXCPP needs to be expanded
 +    for CXXCPP in "$CXX -E" "/lib/cpp"
 +    do
 +      ac_preproc_ok=false
 +for ac_cxx_preproc_warn_flag in '' yes
 +do
 +  # Use a header file that comes with gcc, so configuring glibc
 +  # with a fresh cross-compiler works.
 +  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
 +  # <limits.h> exists even on freestanding compilers.
 +  # On the NeXT, cc -E runs the code through the compiler's parser,
 +  # not just through cpp. "Syntax error" is here to catch this case.
 +  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 +/* end confdefs.h.  */
 +#ifdef __STDC__
 +# include <limits.h>
 +#else
 +# include <assert.h>
 +#endif
 +                   Syntax error
 +_ACEOF
 +if ac_fn_cxx_try_cpp "$LINENO"; then :
 +
 +else
 +  # Broken: fails on valid input.
 +continue
 +fi
 +rm -f conftest.err conftest.i conftest.$ac_ext
 +
 +  # OK, works on sane cases.  Now check whether nonexistent headers
 +  # can be detected and how.
 +  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 +/* end confdefs.h.  */
 +#include <ac_nonexistent.h>
 +_ACEOF
 +if ac_fn_cxx_try_cpp "$LINENO"; then :
 +  # Broken: success on invalid input.
 +continue
 +else
 +  # Passes both tests.
 +ac_preproc_ok=:
 +break
 +fi
 +rm -f conftest.err conftest.i conftest.$ac_ext
 +
 +done
 +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
 +rm -f conftest.i conftest.err conftest.$ac_ext
 +if $ac_preproc_ok; then :
 +  break
 +fi
 +
 +    done
 +    ac_cv_prog_CXXCPP=$CXXCPP
 +
 +fi
 +  CXXCPP=$ac_cv_prog_CXXCPP
 +else
 +  ac_cv_prog_CXXCPP=$CXXCPP
 +fi
 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5
 +$as_echo "$CXXCPP" >&6; }
 +ac_preproc_ok=false
 +for ac_cxx_preproc_warn_flag in '' yes
 +do
 +  # Use a header file that comes with gcc, so configuring glibc
 +  # with a fresh cross-compiler works.
 +  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
 +  # <limits.h> exists even on freestanding compilers.
 +  # On the NeXT, cc -E runs the code through the compiler's parser,
 +  # not just through cpp. "Syntax error" is here to catch this case.
 +  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 +/* end confdefs.h.  */
 +#ifdef __STDC__
 +# include <limits.h>
 +#else
 +# include <assert.h>
 +#endif
 +                   Syntax error
 +_ACEOF
 +if ac_fn_cxx_try_cpp "$LINENO"; then :
 +
 +else
 +  # Broken: fails on valid input.
 +continue
 +fi
 +rm -f conftest.err conftest.i conftest.$ac_ext
 +
 +  # OK, works on sane cases.  Now check whether nonexistent headers
 +  # can be detected and how.
 +  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 +/* end confdefs.h.  */
 +#include <ac_nonexistent.h>
 +_ACEOF
 +if ac_fn_cxx_try_cpp "$LINENO"; then :
 +  # Broken: success on invalid input.
 +continue
 +else
 +  # Passes both tests.
 +ac_preproc_ok=:
 +break
 +fi
 +rm -f conftest.err conftest.i conftest.$ac_ext
 +
 +done
 +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
 +rm -f conftest.i conftest.err conftest.$ac_ext
 +if $ac_preproc_ok; then :
 +
 +else
 +  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 +as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check
 +See \`config.log' for more details" "$LINENO" 5; }
 +fi
 +
 +ac_ext=cpp
 +ac_cpp='$CXXCPP $CPPFLAGS'
 +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 +
 +
 +
 +ac_ext=cpp
 +ac_cpp='$CXXCPP $CPPFLAGS'
 +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 +
 +
 +
 +# Check whether --with-eigen_include was given.
 +if test "${with_eigen_include+set}" = set; then :
 +  withval=$with_eigen_include; with_eigen_include=$withval
 +else
 +  with_eigen_include='yes'
 +
 +fi
 +
 +
 +
 +save_CPPFLAGS="$CPPFLAGS"
 +
 +if test "x$with_eigen_include" != "xyes"; then
 +      CPPFLAGS="-I$with_eigen_include"
 +      ac_fn_cxx_check_header_mongrel "$LINENO" "Eigen/Sparse" "ac_cv_header_Eigen_Sparse" "$ac_includes_default"
 +if test "x$ac_cv_header_Eigen_Sparse" = xyes; then :
 +  EIGEN_CPPFLAGS="$CPPFLAGS"
 +else
 +  as_fn_error $? "Cannot find headers (Eigen/Sparse) of the library EIGEN in $with_eigen_include. Please install the dev package (Debian : libeigen3-dev)" "$LINENO" 5
 +
 +fi
 +
 +
 +    PATH_TO_EIGEN=$with_eigen_include
 +else
 +      ac_fn_cxx_check_header_mongrel "$LINENO" "Eigen/Sparse" "ac_cv_header_Eigen_Sparse" "$ac_includes_default"
 +if test "x$ac_cv_header_Eigen_Sparse" = xyes; then :
 +  EIGEN_CPPFLAGS=""
 +else
 +         $as_unset ac_cv_header_Eigen_Sparse
 +                CPPFLAGS="-I/usr/include/eigen3/"
 +                ac_fn_cxx_check_header_mongrel "$LINENO" "Eigen/Sparse" "ac_cv_header_Eigen_Sparse" "$ac_includes_default"
 +if test "x$ac_cv_header_Eigen_Sparse" = xyes; then :
 +  EIGEN_CPPFLAGS=$CPPFLAGS
 +else
 +  as_fn_error $? "Cannot find headers (Eigen/Sparse) of the library eigen. Please install the dev package (Debian : libeigen3-dev)" "$LINENO" 5
 +
 +fi
 +
 +
 +
 +fi
 +
 +
 +    PATH_TO_EIGEN="/usr/include/eigen3/"
 +fi
 +CPPFLAGS="$save_CPPFLAGS"
 +
 +CHK_EIGEN_WORLD=3
 +CHK_EIGEN_MAJOR=1
 +CHK_EIGEN_MINOR=0
 +
 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if Eigen is version $CHK_EIGEN_WORLD.$CHK_EIGEN_MAJOR.$CHK_EIGEN_MINOR or later" >&5
 +$as_echo_n "checking if Eigen is version $CHK_EIGEN_WORLD.$CHK_EIGEN_MAJOR.$CHK_EIGEN_MINOR or later... " >&6; }
 +cat > conftest.$ac_ext <<EOF
- #line 21469 "configure"
++#line 21467 "configure"
 +#include "confdefs.h"
 +
 +#include "$PATH_TO_EIGEN/Eigen/Sparse"
 +#if EIGEN_VERSION_AT_LEAST(3,1,0)
 +EIGEN_VERSION_OK
 +#endif
 +
 +EOF
 +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
 +  grep "EIGEN_VERSION_OK" >/dev/null 2>&1; then
 +  rm -rf conftest*
 +  \
 +EIGEN_VERSION_OK=1
 +else
 +  rm -rf conftest*
 +  \
 +EIGEN_VERSION_OK=0
 +fi
 +rm -f conftest*
 +
 +if test $EIGEN_VERSION_OK = 0; then
 +   as_fn_error $? "Version $CHK_EIGEN_WORLD.$CHK_EIGEN_MAJOR.$CHK_EIGEN_MINOR of Eigen expected (at least)" "$LINENO" 5
 +else
 +   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 +$as_echo "yes" >&6; }
 +fi
 +
 +
 +
 +$as_echo "#define WITH_EIGEN /**/" >>confdefs.h
 +
 +ac_ext=c
 +ac_cpp='$CPP $CPPFLAGS'
 +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 +ac_compiler_gnu=$ac_cv_c_compiler_gnu
 +
 +
 +
 +
 +#################
  ## MPI
  #################
  
@@@ -25536,7 -24891,7 +25534,7 @@@ CPPFLAGS="$CPPFLAGS -I$CHK_TCL_INCLUDE_
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if tcl is version $CHK_TCL_MAJOR.$CHK_TCL_MINOR or later" >&5
  $as_echo_n "checking if tcl is version $CHK_TCL_MAJOR.$CHK_TCL_MINOR or later... " >&6; }
  cat > conftest.$ac_ext <<EOF
- #line 25539 "configure"
 -#line 24894 "configure"
++#line 25537 "configure"
  #include "confdefs.h"
  
  #include "$CHK_TCL_INCLUDE_PATH/$CHK_TCL_INC_NAME"
@@@ -25846,7 -25201,7 +25844,7 @@@ CPPFLAGS="$CPPFLAGS $TCL_INC_PATH -I$CH
  $as_echo_n "checking if tk is version $CHK_TK_MAJOR.$CHK_TK_MINOR or later... " >&6; }
  
  cat > conftest.$ac_ext <<EOF
- #line 25849 "configure"
 -#line 25204 "configure"
++#line 25847 "configure"
  #include "confdefs.h"
  
  #include "$CHK_TK_INCLUDE_PATH/$CHK_TK_INC_NAME"
@@@ -26424,7 -25779,7 +26422,7 @@@ $as_echo_n "checking saxon... " >&6; 
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 26427 "configure"
 -// #line 25782 "configure"
++// #line 26425 "configure"
  import java.util.regex.Pattern;
  
  import com.icl.saxon.Loader;
@@@ -26541,7 -25896,7 +26539,7 @@@ $as_echo_n "checking jlatexmath-fop... 
              export ac_java_classpath="$jar_resolved:$ac_java_classpath"
  
      cat << \EOF > conftest.java
- // #line 26544 "configure"
 -// #line 25899 "configure"
++// #line 26542 "configure"
  import java.util.regex.Pattern;
  
  import org.scilab.forge.jlatexmath.fop.JLaTeXMathObj;
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
- #line 32864 "configure"
 -#line 32219 "configure"
++#line 32862 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
    lt_status=$lt_dlunknown
    cat > conftest.$ac_ext <<_LT_EOF
- #line 32970 "configure"
 -#line 32325 "configure"
++#line 32968 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
Simple merge
   */
  /*--------------------------------------------------------------------------*/
  #include <string.h>
 -#include "api_scilab.h"
  #include "gw_elementary_functions.h"
 -#include "localization.h"
 +#include "MALLOC.h"
 +#include "basic_functions.h"
 +#include "idmin.h"
 +#include "idmax.h"
 +#include "../../../sparse/includes/gw_sparse.h"
 +#include "api_scilab.h"
  #include "Scierror.h"
 +#include "localization.h"
 +
 +int func_comp(char* fname, int _iMini, void* pvApiCtx);
 +
 +SciErr compare_list(void* pvApiCtx, char* _pstName, int* _piAddress, int _iIsMini);
 +SciErr compare_multiple_double(void* pvApiCtx, char* _pstName, int _iIsMini);
 +SciErr compare_double_inside(void* pvApiCtx, int* _piAddress, int _iIsMini, int _iMode);
 +
 +static SciErr compare_double(void* pvApiCtx, int _iIsMini, int** _piAddr, int _iNbItem);
 +
  /*--------------------------------------------------------------------------*/
 -extern int C2F(intmaxi) (char *fname, int *id, unsigned long fname_len);
 -/*--------------------------------------------------------------------------*/
 -int sci_maxi(char *fname, unsigned long fname_len)
 +
 +int sci_maxi(char *fname, void* pvApiCtx)
 +{
 +      return func_comp(fname, 0, pvApiCtx);
 +}
 +
 +int sci_mini(char *fname, void* pvApiCtx)
 +{
 +      return func_comp(fname, 1, pvApiCtx);
 +}
 +
 +
 +int func_comp(char* fname, int _iMini, void* pvApiCtx)
 +{
 +      SciErr sciErr;
 +      int i;
 +      int iMode                               = 0;
 +      int iType1                      = 0;
 +      int iModeActive = 0;
 +      int *piAddr1            = NULL;
 +
 +      CheckLhs(1,2);
 +
 +      sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr1);
 +      if(sciErr.iErr)
 +      {
 +              printError(&sciErr, 0);
 +              return 0;
 +      }
 +
 +      sciErr = getVarType(pvApiCtx, piAddr1, &iType1);
 +      if(sciErr.iErr)
 +      {
 +              printError(&sciErr, 0);
 +              return 0;
 +      }
 +
 +      //manage "c", "r", "m"
 +      if(Rhs == 2)
 +      {
 +              int *piAddr2    = NULL;
 +              int iType2              = 0;
 +
 +              if(iType1 != sci_matrix)
 +              {
 +                      Scierror(999, _("%s: More than one argument can be use only with double matrix in first argument.\n"), fname);
 +                      return 0;
 +              }
 +
 +              sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddr2);
 +              if(sciErr.iErr)
 +              {
 +                      printError(&sciErr, 0);
 +                      return 0;
 +              }
 +
 +              sciErr = getVarType(pvApiCtx, piAddr2, &iType2);
 +              if(sciErr.iErr)
 +              {
 +                      printError(&sciErr, 0);
 +                      return 0;
 +              }
 +
 +              if(iType2 == sci_strings)
 +              {
 +                      sciErr = getProcessMode(pvApiCtx, 2, piAddr1, &iMode);
 +                      if(sciErr.iErr)
 +                      {
 +                              printError(&sciErr, 0);
 +                              return 0;
 +                      }
 +                      iModeActive = 1;
 +              }
 +      }
 +
 +      switch(iType1)
 +      {
 +      case sci_matrix :
 +              if(Rhs == 1 || (Rhs == 2 && iModeActive))
 +              {
 +                      sciErr = compare_double_inside(pvApiCtx, piAddr1, _iMini, iMode);
 +                      if(sciErr.iErr)
 +                      {
 +                              printError(&sciErr, 0);
 +                              return 0;
 +                      }
 +              }
 +              else
 +              {
 +                      for(i = 2 ; i <= Rhs ; i++)
 +                      {
 +                              int* piAddr             = NULL;
 +                              int iType = 0;
 +                              sciErr = getVarAddressFromPosition(pvApiCtx, i, &piAddr);
 +                              if(sciErr.iErr)
 +                              {
 +                                      printError(&sciErr, 0);
 +                                      return 0;
 +                              }
 +
 +                              sciErr = getVarType(pvApiCtx, piAddr, &iType);
 +                              if(sciErr.iErr)
 +                              {
 +                                      printError(&sciErr, 0);
 +                                      return 0;
 +                              }
 +
 +                              if(iType != sci_matrix)
 +                              {
 +                                      OverLoad(1);
 +                                      return 0;
 +                              }
 +                      }
 +                      sciErr = compare_multiple_double(pvApiCtx, fname, _iMini);
 +                      if(sciErr.iErr)
 +                      {
 +                              printError(&sciErr, 0);
 +                              return 0;
 +                      }
 +              }
 +              break;
 +      case sci_list :
 +              sciErr = compare_list(pvApiCtx, fname, piAddr1, _iMini);
 +              if(sciErr.iErr)
 +              {
 +                      printError(&sciErr, 0);
 +                      return 0;
 +              }
 +              break;
 +      case sci_sparse:
-               if(iModeActive)
-                       sci_spmin(fname, pvApiCtx);
-               else
-                       sci_spmax(fname, pvApiCtx);
++        //TODO YASP
++              //if(iModeActive)
++              //      sci_spmin(fname, pvApiCtx);
++              //else
++              //      sci_spmax(fname, pvApiCtx);
 +              break;
 +      default:
 +              OverLoad(1);
 +              return 0;
 +              break;
 +      }
 +
 +      PutLhsVar();
 +      return 0;
 +}
 +
 +SciErr compare_multiple_double(void* pvApiCtx, char* _pstName, int _iIsMini)
  {
 -    Rhs = Max(Rhs, 0);
 -    if (Rhs == 0)
 -    {
 -        Scierror(999, _("%s: Wrong number of input argument(s).\n"), fname);
 -    }
 -    else
 -    {
 -        static int id[6];
 -
 -        C2F(intmaxi) (fname, id, fname_len);
 -    }
 -    return 0;
 +      SciErr sciErr;
 +      int i;
 +      char* fname                     = _pstName;
 +      int iNbItem                     = Rhs;
 +      int **piItem            = NULL;
 +
 +      piItem = (int**)MALLOC(sizeof(int*) * iNbItem);
 +      for(i = 0 ; i < Rhs ; i++)
 +      {
 +              int iType = 0;
 +              sciErr = getVarAddressFromPosition(pvApiCtx, i + 1, &piItem[i]);
 +              if(sciErr.iErr)
 +              {
 +                      return sciErr;
 +              }
 +
 +              sciErr = getVarType(pvApiCtx, piItem[i], &iType);
 +              if(sciErr.iErr)
 +              {
 +                      return sciErr;
 +              }
 +
 +              if(iType != sci_matrix)
 +              {
 +                      OverLoad(1);
 +                      return sciErr;
 +              }
 +      }
 +
 +      return compare_double(pvApiCtx, _iIsMini, piItem, iNbItem);
  }
  
 +SciErr compare_double_inside(void* pvApiCtx, int* _piAddress, int _iIsMini, int _iMode)
 +{
 +      SciErr sciErr;
 +      int i;
 +      int iRows                                                       = 0;
 +      int iCols                                                       = 0;
 +      int iValIndex                                   = 0;
 +      int iOne                                                        = 1;//for fortran calls
 +
 +      double *pdblReal                        = NULL;
 +      double *pdblRealRet1    = NULL;
 +      double *pdblRealRet2    = NULL;
 +
 +      sciErr.iErr                                             = 0;
 +
 +      if(isVarComplex(pvApiCtx, _piAddress))
 +      {
 +        ScierrorW(999, _W("%ls:  Wrong type for input argument #%d: Real Matrix expected.\n"), L"max", 1);
 +        sciErr.iErr = 1;
 +        return sciErr;
 +      }
 +
 +      sciErr = getMatrixOfDouble(pvApiCtx, _piAddress, &iRows, &iCols, &pdblReal);
 +      if(sciErr.iErr)
 +      {
 +              return sciErr;
 +      }
 +
 +      if(iRows * iCols <= 0)
 +      {
 +              iRows = 0;
 +              iCols = 0;
 +              sciErr = allocMatrixOfDouble(pvApiCtx, Rhs + 1, 0, 0, &pdblRealRet1);
 +              if(sciErr.iErr)
 +              {
 +                      return sciErr;
 +              }
 +
 +              LhsVar(1) = Rhs + 1;
 +              if(Lhs == 2)
 +              {
 +                      sciErr = allocMatrixOfDouble(pvApiCtx, Rhs + 2, 0, 0, &pdblRealRet2);
 +                      if(sciErr.iErr)
 +                      {
 +                              return sciErr;
 +                      }
 +
 +                      LhsVar(2) = Rhs + 2;
 +              }
 +              return sciErr;
 +      }
 +
 +      switch(_iMode)
 +      {
 +      case BY_ALL :
 +              sciErr = allocMatrixOfDouble(pvApiCtx, Rhs + 1, 1, 1, &pdblRealRet1);
 +              if(sciErr.iErr)
 +              {
 +                      return sciErr;
 +              }
 +
 +              if(_iIsMini)
 +              {
 +                      int iSize = iRows * iCols;
 +                      iValIndex = C2F(idmin)(&iSize, pdblReal, &iOne);
 +              }
 +              else //maxi
 +              {
 +                      int iSize = iRows * iCols;
 +                      iValIndex = C2F(idmax)(&iSize, pdblReal, &iOne);
 +              }
 +
 +              pdblRealRet1[0] = pdblReal[iValIndex-1];
 +              LhsVar(1) = Rhs + 1;
 +
 +              if(Lhs == 2)
 +              {
 +                      if(iRows == 1 || iCols == 1)
 +                      {
 +                              sciErr = allocMatrixOfDouble(pvApiCtx, Rhs + 2, 1, 1, &pdblRealRet2);
 +                              if(sciErr.iErr)
 +                              {
 +                                      return sciErr;
 +                              }
 +
 +                              pdblRealRet2[0] = iValIndex;
 +                      }
 +                      else
 +                      {
 +                              sciErr = allocMatrixOfDouble(pvApiCtx, Rhs + 2, 1, 2, &pdblRealRet2);
 +                              if(sciErr.iErr)
 +                              {
 +                                      return sciErr;
 +                              }
 +
 +                              pdblRealRet2[0] = ((iValIndex - 1) % iRows) + 1;
 +                              pdblRealRet2[1] = ((iValIndex - 1) / iRows) + 1;
 +                      }
 +                      LhsVar(2) = Rhs + 2;
 +              }
 +              break;
 +      case BY_ROWS :
 +              sciErr = allocMatrixOfDouble(pvApiCtx, Rhs + 1, 1, iCols, &pdblRealRet1);
 +              if(sciErr.iErr)
 +              {
 +                      return sciErr;
 +              }
 +
 +              if(Lhs == 2)
 +              {
 +                      sciErr = allocMatrixOfDouble(pvApiCtx, Rhs + 2, 1, iCols, &pdblRealRet2);
 +                      if(sciErr.iErr)
 +                      {
 +                              return sciErr;
 +                      }
 +              }
 +
 +              if(_iIsMini)
 +              {
 +                      for(i = 0 ; i < iCols ; i++)
 +                      {
 +                              iValIndex                                       = C2F(idmin)(&iRows, &pdblReal[i * iRows], &iOne);
 +                              pdblRealRet1[i]         = pdblReal[i * iRows + iValIndex - 1];
 +                              if(Lhs == 2)
 +                              {
 +                                      pdblRealRet2[i] = iValIndex;
 +                              }
 +                      }
 +              }
 +              else //maxi
 +              {
 +                      for(i = 0 ; i < iCols ; i++)
 +                      {
 +                              iValIndex                                       = C2F(idmax)(&iRows, &pdblReal[i*iRows], &iOne);
 +                              pdblRealRet1[i]         = pdblReal[i * iRows + iValIndex - 1];
 +                              if(Lhs == 2)
 +                              {
 +                                      pdblRealRet2[i] = iValIndex;
 +                              }
 +                      }
 +              }
 +
 +              LhsVar(1) = Rhs + 1;
 +              if(Lhs == 2)
 +              {
 +                      LhsVar(2) = Rhs + 2;
 +              }
 +              break;
 +      case BY_COLS :
 +              sciErr = allocMatrixOfDouble(pvApiCtx, Rhs + 1, iRows, 1, &pdblRealRet1);
 +              if(sciErr.iErr)
 +              {
 +                      return sciErr;
 +              }
 +
 +              if(Lhs == 2)
 +              {
 +                      sciErr = allocMatrixOfDouble(pvApiCtx, Rhs + 2, iRows, 1, &pdblRealRet2);
 +                      if(sciErr.iErr)
 +                      {
 +                              return sciErr;
 +                      }
 +              }
 +
 +              if(_iIsMini)
 +              {
 +                      for(i = 0 ; i < iRows ; i++)
 +                      {
 +                              iValIndex                                       = C2F(idmin)(&iCols, &pdblReal[i], &iRows);
 +                              pdblRealRet1[i]         = pdblReal[i + (iValIndex - 1) * iRows];
 +                              if(Lhs == 2)
 +                              {
 +                                      pdblRealRet2[i] = iValIndex;
 +                              }
 +                      }
 +              }
 +              else //maxi
 +              {
 +                      for(i = 0 ; i < iRows ; i++)
 +                      {
 +                              iValIndex                                       = C2F(idmax)(&iCols, &pdblReal[i], &iRows);
 +                              pdblRealRet1[i]         = pdblReal[i + (iValIndex - 1) * iRows];
 +                              if(Lhs == 2)
 +                              {
 +                                      pdblRealRet2[i] = iValIndex;
 +                              }
 +                      }
 +              }
 +
 +              LhsVar(1) = Rhs + 1;
 +              if(Lhs == 2)
 +              {
 +                      LhsVar(2) = Rhs + 2;
 +              }
 +              break;
 +      default:
 +              break;
 +      }
 +      return sciErr;
 +}
 +
 +SciErr compare_list(void* pvApiCtx, char* _pstName, int* _piAddress, int _iIsMini)
 +{
 +      SciErr sciErr;
 +      int i;
 +      char* fname             = _pstName;
 +      int iNbItem             = 0;
 +      int **piItem    = NULL;
 +
 +      sciErr = getListItemNumber(pvApiCtx, _piAddress, &iNbItem);
 +      if(sciErr.iErr)
 +      {
 +              return sciErr;
 +      }
 +
 +
 +      piItem = (int**)MALLOC(sizeof(int*) * iNbItem);
 +      for(i = 0 ; i < iNbItem ; i++)
 +      {
 +              int iType = 0;
 +              sciErr = getListItemAddress(pvApiCtx, _piAddress, i+1, &piItem[i]);
 +              if(sciErr.iErr)
 +              {
 +                      return sciErr;
 +              }
 +
 +              sciErr = getVarType(pvApiCtx, piItem[i], &iType);
 +              if(sciErr.iErr)
 +              {
 +                      return sciErr;
 +              }
 +
 +              if(iType != sci_matrix)
 +              {
 +                      OverLoad(1);
 +                      return sciErr;
 +              }
 +      }
 +
 +      return compare_double(pvApiCtx, _iIsMini, piItem, iNbItem);
 +}
 +
 +static SciErr compare_double(void* pvApiCtx, int _iIsMini, int** _piAddr, int _iNbItem)
 +{
 +      SciErr sciErr;
 +      int i,j;
 +      int iRows                                                       = 0;
 +      int iCols                                                       = 0;
 +      int iRefRows                                    = 0;
 +      int iRefCols                                    = 0;
 +
 +      double *pdblReal                        = NULL;
 +      double *pdblRealRet1    = NULL;
 +      double *pdblRealRet2    = NULL;
 +
 +      for(i = 0 ; i < _iNbItem ; i++)
 +      {
 +              int iRhsRows    = 0;
 +              int iRhsCols    = 0;
 +
 +              if(isVarComplex(pvApiCtx, _piAddr[i]))
 +              {
 +            ScierrorW(999, _W("%ls:  Wrong type for input argument #%d: Real Matrix expected.\n"), L"max", i+1);
 +            sciErr.iErr = 1;
 +                      return sciErr;
 +              }
 +
 +              sciErr = getVarDimension(pvApiCtx, _piAddr[i], &iRhsRows, &iRhsCols);
 +              if(sciErr.iErr)
 +              {
 +                      return sciErr;
 +              }
 +
 +              if(iRhsRows * iRhsCols == 0)
 +              {
 +            ScierrorW(999, _W("%ls:  Wrong type for input argument #%d: Real Matrix expected.\n"), L"max", i+1);
 +            sciErr.iErr = 1;
 +                      return sciErr;
 +              }
 +
 +              if(i == 0)
 +              {
 +                      iRows = iRhsRows;
 +                      iCols = iRhsCols;
 +              }
 +              else
 +              {
 +                      if(iRhsRows != 1 || iRhsCols != 1)
 +                      {
 +                              if(iRhsRows != iRows || iRhsCols != iCols)
 +                              {
 +                                      if(iRows * iCols != 1)
 +                                      {
 +                        ScierrorW(999, _W("%ls:  Wrong type for input argument #%d: A real scalar expected.\n"), L"max", i+1);
 +                        sciErr.iErr = 1;
 +                                              return sciErr;
 +                                      }
 +                                      else
 +                                      {
 +                                              iRows = iRhsRows;
 +                                              iCols = iRhsCols;
 +                                      }
 +                              }
 +                      }
 +              }
 +      }//for
 +
 +      sciErr = allocMatrixOfDouble(pvApiCtx, Rhs + 1, iRows, iCols, &pdblRealRet1);
 +      if(sciErr.iErr)
 +      {
 +              return sciErr;
 +      }
 +
 +      if(Lhs == 2)
 +      {
 +              sciErr = allocMatrixOfDouble(pvApiCtx, Rhs + 2, iRows, iCols, &pdblRealRet2);
 +              if(sciErr.iErr)
 +              {
 +                      return sciErr;
 +              }
 +
 +              vDset(iRows * iCols, 1, pdblRealRet2, 1);
 +      }
 +
 +      sciErr = getMatrixOfDouble(pvApiCtx, _piAddr[0], &iRefRows, &iRefCols, &pdblReal);
 +      if(sciErr.iErr)
 +      {
 +              return sciErr;
 +      }
 +
 +      if(iRefRows * iRefCols == 1)
 +      {
 +              vDset(iRows * iCols, pdblReal[0], pdblRealRet1, 1);
 +      }
 +      else
 +      {
 +              memcpy(pdblRealRet1, pdblReal, iRows * iCols * sizeof(double));
 +      }
 +
 +      for(i = 1 ; i < _iNbItem ; i++)
 +      {
 +              int iVar                                = i + 1;
 +              int iCurRows            = 0;
 +              int iCurCols            = 0;
 +              int iCurData            = 0;
 +              double *pdblCur = NULL;
 +              int iInc                                = 0;
 +              int iIndex2                     = 0;
 +              int iIndex3                     = 0;
 +
 +              sciErr = getMatrixOfDouble(pvApiCtx, _piAddr[i], &iCurRows, &iCurCols, &pdblCur);
 +              if(sciErr.iErr)
 +              {
 +                      return sciErr;
 +              }
 +
 +              if(iCurRows == 1 && iCurCols == 1)
 +              {
 +                      iInc = 0;
 +              }
 +              else
 +              {
 +                      iInc = 1;
 +              }
 +
 +              if(_iIsMini)
 +              {
 +                      int k = 0;
 +                      for(j = 0 ; j < iRows * iCols; j++)
 +                      {
 +                              if(pdblCur[k] < pdblRealRet1[j] || ISNAN(pdblCur[k]) == 1)
 +                              {
 +                                      pdblRealRet1[j] = pdblCur[k];
 +                                      if(Lhs == 2)
 +                                      {
 +                                              pdblRealRet2[j] = (double)(i + 1);
 +                                      }
 +                              }
 +                              k += iInc;
 +                      }
 +              }
 +              else//maxi
 +              {
 +                      int k = 0;
 +                      for(j = 0 ; j < iRows * iCols; j++)
 +                      {
 +                              if(pdblCur[k] > pdblRealRet1[j] || ISNAN(pdblCur[k]) == 1)
 +                              {
 +                                      pdblRealRet1[j] = pdblCur[k];
 +                                      if(Lhs == 2)
 +                                      {
 +                                              pdblRealRet2[j] = (double)(i + 1);
 +                                      }
 +                              }
 +                              k += iInc;
 +                      }
 +              }
 +      }//for
 +
 +      LhsVar(1) = Rhs + 1;
 +
 +      if(Lhs == 2)
 +      {
 +              LhsVar(2) = Rhs + 2;
 +      }
 +      return sciErr;
 +}
  /*--------------------------------------------------------------------------*/
@@@ -42,13 -49,6 +49,9 @@@ libscihdf5_la_CPPFLAGS = -I$(srcdir)/in
                  -I$(top_srcdir)/modules/commons/src/jni/ \
                                -I$(top_srcdir)/modules/localization/includes/ \
                                -I$(top_srcdir)/modules/fileio/includes/ \
-                               -I$(top_srcdir)/modules/system_env/includes/ \
 +                              -I$(top_srcdir)/modules/string/includes/ \
-                               -I$(top_srcdir)/modules/types/includes/ \
-                               -I$(top_srcdir)/modules/functions_manager/includes/ \
-                               -I$(top_srcdir)/modules/symbol/includes/ \
-                               -I$(top_srcdir)/modules/ast/includes/ \
-                 -I$(top_srcdir)/libs/dynamiclibrary/includes/ \
++                              -I$(top_srcdir)/modules/system_env/includes/ \
++                              -I$(top_srcdir)/modules/operations/includes/ \
                                $(JAVA_JNI_INCLUDE) \
                                $(HDF5_CFLAGS) \
                                $(AM_CPPFLAGS)
@@@ -478,13 -474,6 +481,9 @@@ libscihdf5_la_CPPFLAGS = -I$(srcdir)/in
                  -I$(top_srcdir)/modules/commons/src/jni/ \
                                -I$(top_srcdir)/modules/localization/includes/ \
                                -I$(top_srcdir)/modules/fileio/includes/ \
-                               -I$(top_srcdir)/modules/system_env/includes/ \
 +                              -I$(top_srcdir)/modules/string/includes/ \
-                               -I$(top_srcdir)/modules/types/includes/ \
-                               -I$(top_srcdir)/modules/functions_manager/includes/ \
-                               -I$(top_srcdir)/modules/symbol/includes/ \
-                               -I$(top_srcdir)/modules/ast/includes/ \
-                 -I$(top_srcdir)/libs/dynamiclibrary/includes/ \
++                              -I$(top_srcdir)/modules/system_env/includes/ \
++                              -I$(top_srcdir)/modules/operations/includes/ \
                                $(JAVA_JNI_INCLUDE) \
                                $(HDF5_CFLAGS) \
                                $(AM_CPPFLAGS)
@@@ -9,14 -9,18 +9,18 @@@
   * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
   *
   */
- /*--------------------------------------------------------------------------*/
+ /*--------------------------------------------------------------------------*/ 
  #ifndef __GW_HDF5_H__
  #define __GW_HDF5_H__
- /*--------------------------------------------------------------------------*/
+ /*--------------------------------------------------------------------------*/ 
  #include "dynlib_hdf5_scilab.h"
- /*--------------------------------------------------------------------------*/
+ /*--------------------------------------------------------------------------*/ 
  HDF5_SCILAB_IMPEXP int gw_hdf5(void);
- /*--------------------------------------------------------------------------*/
+ /*--------------------------------------------------------------------------*/ 
 -HDF5_SCILAB_IMPEXP int sci_export_to_hdf5(char *fname,unsigned long fname_len);
 -HDF5_SCILAB_IMPEXP int sci_import_from_hdf5(char *fname,unsigned long fname_len);
 -HDF5_SCILAB_IMPEXP int sci_listvar_in_hdf5(char *fname,unsigned long fname_len);
 -HDF5_SCILAB_IMPEXP int sci_is_hdf5_file(char *fname,unsigned long fname_len);
++HDF5_SCILAB_IMPEXP int sci_export_to_hdf5(char *fname, int* pvApiCtx);
++HDF5_SCILAB_IMPEXP int sci_import_from_hdf5(char *fname, int* pvApiCtx);
++HDF5_SCILAB_IMPEXP int sci_listvar_in_hdf5(char *fname, int* pvApiCtx);
++HDF5_SCILAB_IMPEXP int sci_is_hdf5_file(char *fname, int* pvApiCtx);
+ /*--------------------------------------------------------------------------*/ 
  #endif /* __GW_HDF5_H__ */
  /*--------------------------------------------------------------------------*/
index 0000000,112c599..74ec767
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,13 +1,13 @@@
+ /*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2012 - Scilab Enterprises - 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
+ *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
 -int sci_import_from_hdf5_v1(char *fname, unsigned long fname_len);
++int sci_import_from_hdf5_v1(char *fname, int* pvCtx);
index 0000000,0349ad3..0d6c711
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,13 +1,13 @@@
+ /*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2012 - Scilab Enterprises - 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
+ *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
 -int sci_listvar_in_hdf5_v1(char *fname, unsigned long fname_len);
++int sci_listvar_in_hdf5_v1(char *fname, int* pvCtx);
  #include "api_scilab.h"
  #include "MALLOC.h"
  
- /*--------------------------------------------------------------------------*/
+ /*--------------------------------------------------------------------------*/ 
  /*  interface function */
- /*--------------------------------------------------------------------------*/
- static gw_generic_table Tab[] =
+ /*--------------------------------------------------------------------------*/ 
+ static gw_generic_table Tab[] = 
  {
-       {NULL, ""}, //export_to_hdf5
-       {NULL, ""}, //import_from_hdf5
-       {NULL, ""}, //listvar_in_hdf5
-       {NULL, ""} //is_hdf5_file
 -      {sci_export_to_hdf5, "export_to_hdf5"},
 -      {sci_import_from_hdf5, "import_from_hdf5"},
 -      {sci_listvar_in_hdf5, "listvar_in_hdf5"},
 -      {sci_is_hdf5_file, "is_hdf5_file"}
++      {NULL, "export_to_hdf5"},
++      {NULL, "import_from_hdf5"},
++      {NULL, "listvar_in_hdf5"},
++      {NULL, "is_hdf5_file"}
  };
- /*--------------------------------------------------------------------------*/
+ /*--------------------------------------------------------------------------*/ 
  int gw_hdf5(void)
  {
 -      Rhs = Max(0,Rhs);
 -
 -      if(pvApiCtx == NULL)
 -      {
 -              pvApiCtx = (StrCtx*)MALLOC(sizeof(StrCtx));
 -      }
 -
 -      pvApiCtx->pstName = (char*)Tab[Fin-1].name;
 -      callFunctionFromGateway(Tab, SIZE_CURRENT_GENERIC_TABLE(Tab));
        return 0;
  }
- /*--------------------------------------------------------------------------*/
+ /*--------------------------------------------------------------------------*/ 
  
@@@ -34,67 -26,66 +26,64 @@@ extern "C
  #include "h5_writeDataToFile.h"
  #include "h5_readDataFromFile.h"
  #include "h5_attributeConstants.h"
- #include "sci_types.h"
- #include "expandPathVariable.h"
+ #include "freeArrayOfString.h"
 -#ifdef _MSC_VER
 -#include "strdup_windows.h"
 -#endif
 -#include "scilabmode.h"
++#include "os_strdup.h"
++#include "sci_mode.h"
+ #include "splitpath.h"
+ #include "scicurdir.h"
  }
  
  //#define PRINT_DEBUG
  int iLevel = 0;
  
- static bool export_data(int _iH5File, InternalType* pIT, wchar_t* _pwstName);
- static bool export_list(int _iH5File, InternalType* pIT, wchar_t* _pwstName);
- static bool export_double(int _iH5File, InternalType* pIT,wchar_t* _pwstName);
- static bool export_poly(int _iH5File, InternalType* pIT,wchar_t* _pwstName);
- static bool export_boolean(int _iH5File, InternalType* pIT,wchar_t* _pwstName);
- static bool export_sparse(int _iH5File, InternalType* pIT,wchar_t* _pwstName);
- //static bool export_boolean_sparse(int _iH5File, InternalType* pIT,wchar_t* _pwstName);
- //static bool export_matlab_sparse(void* pvApiCtx, int *_piVar, char* _pstName);
- static bool export_ints(int _iH5File, InternalType* pIT,wchar_t* _pwstName);
- //static bool export_handles(void* pvApiCtx, int *_piVar, char* _pstName);
- static bool export_strings(int _iH5File, InternalType* pIT,wchar_t* _pwstName);
- //static bool export_u_function(void* pvApiCtx, int *_piVar, char* _pstName);
- //static bool export_c_function(void* pvApiCtx, int *_piVar, char* _pstName);
- //static bool export_lib(void* pvApiCtx, int *_piVar, char* _pstName);
- //static bool export_lufact_pointer(void* pvApiCtx, int *_piVar, char* _pstName);
- static bool export_void(int _iH5File, InternalType* pIT,wchar_t* _pwstName);
 -static bool export_data(int _iH5File, int *_piVar, char* _pstName);
 -static bool export_list(int _iH5File, int *_piVar, char* _pstName, int _iVarType);
 -static bool export_double(int _iH5File, int *_piVar, char* _pstName);
 -static bool export_poly(int _iH5File, int *_piVar, char* _pstName);
 -static bool export_boolean(int _iH5File, int *_piVar, char* _pstName);
 -static bool export_sparse(int _iH5File, int *_piVar, char* _pstName);
 -static bool export_boolean_sparse(int _iH5File, int *_piVar, char* _pstName);
 -static bool export_matlab_sparse(int *_piVar, char* _pstName);
 -static bool export_ints(int _iH5File, int *_piVar, char* _pstName);
 -static bool export_handles(int *_piVar, char* _pstName);
 -static bool export_strings(int _iH5File, int *_piVar, char* _pstName);
 -static bool export_u_function(int *_piVar, char* _pstName);
 -static bool export_c_function(int *_piVar, char* _pstName);
 -static bool export_lib(int *_piVar, char* _pstName);
 -static bool export_lufact_pointer(int *_piVar, char* _pstName);
 -static bool export_void(int _iH5File, int *_piVar, char* _pstName);
++static bool export_data(int* pvCtx, int _iH5File, int *_piVar, char* _pstName);
++static bool export_list(int* pvCtx, int _iH5File, int *_piVar, char* _pstName, int _iVarType);
++static bool export_double(int* pvCtx, int _iH5File, int *_piVar, char* _pstName);
++static bool export_poly(int* pvCtx, int _iH5File, int *_piVar, char* _pstName);
++static bool export_boolean(int* pvCtx, int _iH5File, int *_piVar, char* _pstName);
++static bool export_sparse(int* pvCtx, int _iH5File, int *_piVar, char* _pstName);
++static bool export_boolean_sparse(int* pvCtx, int _iH5File, int *_piVar, char* _pstName);
++static bool export_matlab_sparse(int* pvCtx, int *_piVar, char* _pstName);
++static bool export_ints(int* pvCtx, int _iH5File, int *_piVar, char* _pstName);
++static bool export_handles(int* pvCtx, int *_piVar, char* _pstName);
++static bool export_strings(int* pvCtx, int _iH5File, int *_piVar, char* _pstName);
++static bool export_u_function(int* pvCtx, int *_piVar, char* _pstName);
++static bool export_c_function(int* pvCtx, int *_piVar, char* _pstName);
++static bool export_lib(int* pvCtx, int *_piVar, char* _pstName);
++static bool export_lufact_pointer(int* pvCtx, int *_piVar, char* _pstName);
++static bool export_void(int* pvCtx, int _iH5File, int *_piVar, char* _pstName);
  
  void print_type(char* _pstType);
- int extractVarNameList(typed_list &in, wchar_t** _pstNameList);
 -int extractVarNameList(int _iStart, int _iEnd, char** _pstNameList);
++int extractVarNameList(int* pvCtx, int _iStart, int _iEnd, char** _pstNameList);
  
  /*--------------------------------------------------------------------------*/
- Function::ReturnValue sci_export_to_hdf5(typed_list &in, int _iRetCount, typed_list &out)
 -int sci_export_to_hdf5(char *fname, unsigned long fname_len)
++int sci_export_to_hdf5(char *fname, int* pvApiCtx)
  {
-     int iNbVar              = 0;
-     InternalType** pITList  = NULL;
-     wchar_t** pwstNameList    = NULL;
-     wchar_t* pwstFileName   = NULL;
-     char* pstFileName       = NULL;
-     bool bExport            = false;
-     bool bAppendMode        = false;
+     int iNbVar          = 0;
+     int** piAddrList    = NULL;
+     char** pstNameList  = NULL;
+     char *pstFileName   = NULL;
+     bool bExport        = false;
+     bool bAppendMode    = false;
  
-     if(in.size() < 2)
-     {
-         ScierrorW(77, _W("%ls: Wrong number of input argument(s): At least %d expected.\n"), L"export_to_hdf5", 2);
-         return Function::Error;
-     }
+     SciErr sciErr;
+     CheckInputArgumentAtLeast(pvApiCtx, 1);
 -    CheckLhs(0, 1);
++    CheckOutputArgument(pvApiCtx, 0, 1);
  
-     pwstNameList = (wchar_t**)MALLOC(sizeof(wchar_t*) * in.size());
-     iNbVar = extractVarNameList(in, pwstNameList);
 -    pstNameList = (char**)MALLOC(sizeof(char*) * Rhs);
 -    iNbVar = extractVarNameList(1, Rhs, pstNameList);
++    pstNameList = (char**)MALLOC(sizeof(char*) * nbInputArgument(pvApiCtx));
++    iNbVar = extractVarNameList(pvApiCtx, 1, nbInputArgument(pvApiCtx), pstNameList);
      if (iNbVar == 0)
      {
-         FREE(pwstNameList);
-         return Function::Error;
+         FREE(pstNameList);
+         return 1;
      }
  
-     pITList = (InternalType**)MALLOC(sizeof(InternalType*) * (iNbVar));
-     for (int i = 1 ; i < in.size() ; i++)
+     piAddrList = (int**)MALLOC(sizeof(int*) * (iNbVar));
 -    for (int i = 1 ; i < Rhs ; i++)
++    for (int i = 1 ; i < nbInputArgument(pvApiCtx) ; i++)
      {
-         if (wcscmp(pwstNameList[i], L"-append") == 0)
+         if (strcmp(pstNameList[i], "-append") == 0)
          {
              bAppendMode = true;
          }
              //import all data
              for (int i = 0 ; i < iNbItem ; i++)
              {
-                 wchar_t *pwstVarNameList = to_wide_string(pstVarNameList[i]);
-                 for (int j = 1 ; j < in.size() ; j++)
 -                for (int j = 1 ; j < Rhs ; j++)
++                for (int j = 1 ; j < nbInputArgument(pvApiCtx) ; j++)
                  {
-                     if (wcscmp(pwstNameList[i], L"-append") == 0)
+                     if (strcmp(pstNameList[i], "-append") == 0)
                      {
                          continue;
                      }
  
-                     if (wcscmp(pwstVarNameList, pwstNameList[j]) == 0)
+                     if (strcmp(pstVarNameList[i], pstNameList[j]) == 0)
                      {
-                         ScierrorW(999, _W("%ls: Variable \'%ls\' already exists in file \'%ls\'."), L"export_to_hfd5", pwstVarNameList, pwstNameList[0]);
-                         FREE(pwstVarNameList);
-                         FREE(pstVarNameList[i]);
-                         return Function::Error;
+                         Scierror(999, _("%s: Variable \'%s\' already exists in file \'%s\'."), fname, pstVarNameList[i], pstNameList[0]);
+                         return 1;
                      }
                  }
-                 FREE(pwstVarNameList);
                  FREE(pstVarNameList[i]);
              }
              FREE(pstVarNameList);
-             FREE(pstFileName);
-             FREE(pwstNameList);
          }
+     }
  
-         for(int i = 1 ; i < in.size(); i++)
+     // export data
 -    for (int i = 1 ; i < Rhs ; i++)
++    for (int i = 1 ; i < nbInputArgument(pvApiCtx) ; i++)
+     {
+         if (strcmp(pstNameList[i], "-append") == 0)
          {
-             if (wcscmp(pwstNameList[i], L"-append") == 0)
-             {
-                 continue;
-             }
-             bExport = export_data(iH5File, pITList[i], pwstNameList[i]);
-             if(bExport == false)
-             {
-                 break;
-             }
+             continue;
          }
  
-         if (bExport && in.size() != 1)
 -        bExport = export_data(iH5File, piAddrList[i], pstNameList[i]);
++        bExport = export_data(pvApiCtx, iH5File, piAddrList[i], pstNameList[i]);
+         if (bExport == false)
          {
-             //add or update scilab version and file version in hdf5 file
-             if (updateScilabVersion(iH5File) < 0)
-             {
-                 ScierrorW(999, _W("%ls: Unable to update Scilab version in \"%ls\"."), L"export_to_hfd5", pwstNameList[0]);
-                 return Function::Error;
-             }
+             break;
+         }
+     }
  
-             if (updateFileVersion(iH5File) < 0)
-             {
-                 ScierrorW(999, _W("%ls: Unable to update HDF5 format version in \"%ls\"."), L"export_to_hfd5", pwstNameList[0]);
-                 return Function::Error;
-             }
 -    if (bExport && Rhs != 1)
++    if (bExport && nbInputArgument(pvApiCtx) != 1)
+     {
+         //add or update scilab version and file version in hdf5 file
+         if (updateScilabVersion(iH5File) < 0)
+         {
+             Scierror(999, _("%s: Unable to update Scilab version in \"%s\"."), fname, pstNameList[0]);
+             return 1;
          }
  
-         //close hdf5 file
-         closeHDF5File(iH5File);
-         if(bExport == false && in.size() != 1)
-         {//remove file
-             deleteafileW(pwstNameList[0]);
+         if (updateFileVersion(iH5File) < 0)
+         {
+             Scierror(999, _("%s: Unable to update HDF5 format version in \"%s\"."), fname, pstNameList[0]);
+             return 1;
          }
      }
+     //close hdf5 file
+     closeHDF5File(iH5File);
 -    if (bExport == false && Rhs != 1)
++    if (bExport == false && nbInputArgument(pvApiCtx) != 1)
+     {
+         //remove file
+         deleteafile(pstFileName);
+     }
+     FREE(pstFileName);
      //create boolean return value
-     Bool* pOut = new Bool(bExport);
-     out.push_back(pOut);
+     int *piReturn = NULL;
 -    sciErr = allocMatrixOfBoolean(pvApiCtx, Rhs + 1, 1, 1, &piReturn);
++    sciErr = allocMatrixOfBoolean(pvApiCtx, nbInputArgument(pvApiCtx) + 1, 1, 1, &piReturn);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
 -    if (bExport == true || Rhs == 1)
++    if (bExport == true || nbInputArgument(pvApiCtx) == 1)
+     {
+         piReturn[0] = 1;
+     }
+     else
+     {
+         piReturn[0] = 0;
+     }
  
      //free memory
-     for (int i = 0 ; i < in.size() ; i++)
 -    for (int i = 0 ; i < Rhs ; i++)
++    for (int i = 0 ; i < nbInputArgument(pvApiCtx) ; i++)
      {
-         FREE(pwstNameList[i]);
+         FREE(pstNameList[i]);
      }
+     FREE(pstNameList);
+     FREE(piAddrList);
  
-     FREE(pwstNameList);
-     FREE(pITList);
-     return Function::OK;
 -    LhsVar(1) = Rhs + 1;
 -    PutLhsVar();
++    AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
++    ReturnArguments(pvApiCtx);
+     return 0;
  }
  
- static bool export_data(int _iH5File, InternalType* pIT, wchar_t* _pwstName)
 -static bool export_data(int _iH5File, int* _piVar, char* _pstName)
++static bool export_data(int* pvCtx, int _iH5File, int* _piVar, char* _pstName)
  {
      bool bReturn = false;
+     int iType = 0;
  
-     switch(pIT->getType())
 -    SciErr sciErr = getVarType(pvApiCtx, _piVar, &iType);
++    SciErr sciErr = getVarType(pvCtx, _piVar, &iType);
+     if (sciErr.iErr)
      {
-     case InternalType::RealDouble :
-         {
-             bReturn = export_double(_iH5File, pIT, _pwstName);
-             break;
-         }
-    case InternalType::RealPoly :
-         {
-             bReturn = export_poly(_iH5File, pIT, _pwstName);
-             break;
-         }
-     case InternalType::RealBool :
-         {
-             bReturn = export_boolean(_iH5File, pIT, _pwstName);
-             break;
-         }
-         /*
-     case sci_sparse :
-         {
-             bReturn = export_sparse(_iH5File, pIT, _pwstName);
-             break;
-         }
-     case sci_boolean_sparse :
-         {
-             bReturn = export_boolean_sparse(_iH5File, pIT, _pwstName);
-             break;
-         }
-     case sci_matlab_sparse :
-         {
-             bReturn = export_matlab_sparse(pvApiCtx, _piVar, _pwstName);
-             break;
-         }
-      */
-     case InternalType::RealInt8 :
-     case InternalType::RealUInt8 :
-     case InternalType::RealInt16 :
-     case InternalType::RealUInt16 :
-     case InternalType::RealInt32 :
-     case InternalType::RealUInt32 :
-     case InternalType::RealInt64 :
-     case InternalType::RealUInt64 :
-         {
-             bReturn = export_ints(_iH5File, pIT, _pwstName);
-             break;
-         }
-         /*
-     case sci_handles :
-         {
-             bReturn = export_handles(pvApiCtx, _piVar, _pwstName);
-             break;
-         }
-         */
-     case InternalType::RealString :
-         {
-             bReturn = export_strings(_iH5File, pIT, _pwstName);
-             break;
-         }
-         /*
-     case Function :
-         {
-             bReturn = export_u_function(pvApiCtx, _piVar, _pwstName);
-             break;
-         }
-     case sci_c_function :
-         {
-             bReturn = export_c_function(pvApiCtx, _piVar, _pwstName);
-             break;
-         }
-     case sci_lib :
-         {
-             bReturn = export_lib(pvApiCtx, _piVar, _pwstName);
-             break;
-         }
-         */
-     case InternalType::RealList :
-     case InternalType::RealTList :
-     case InternalType::RealMList :
-         {
-             bReturn = export_list(_iH5File, pIT, _pwstName);
-             break;
-         }
-         /*
-     case sci_lufact_pointer :
-         {
-             bReturn = export_lufact_pointer(pvApiCtx, _piVar, _pwstName);
-             break;
-         }
-         */
-     case 0 : //void case to "null" items in list
-         {
-             bReturn = export_void(_iH5File, pIT, _pwstName);
-             break;
-         }
+         printError(&sciErr, 0);
+         return false;
+     }
+     switch (iType)
+     {
+         case sci_matrix :
+             {
 -                bReturn = export_double(_iH5File, _piVar, _pstName);
++                bReturn = export_double(pvCtx, _iH5File, _piVar, _pstName);
+                 break;
+             }
+         case sci_poly :
+             {
 -                bReturn = export_poly(_iH5File, _piVar, _pstName);
++                bReturn = export_poly(pvCtx, _iH5File, _piVar, _pstName);
+                 break;
+             }
+         case sci_boolean :
+             {
 -                bReturn = export_boolean(_iH5File, _piVar, _pstName);
++                bReturn = export_boolean(pvCtx, _iH5File, _piVar, _pstName);
+                 break;
+             }
+         case sci_sparse :
+             {
 -                bReturn = export_sparse(_iH5File, _piVar, _pstName);
++                bReturn = export_sparse(pvCtx, _iH5File, _piVar, _pstName);
+                 break;
+             }
+         case sci_boolean_sparse :
+             {
 -                bReturn = export_boolean_sparse(_iH5File, _piVar, _pstName);
++                bReturn = export_boolean_sparse(pvCtx, _iH5File, _piVar, _pstName);
+                 break;
+             }
+         case sci_matlab_sparse :
+             {
 -                bReturn = export_matlab_sparse(_piVar, _pstName);
++                bReturn = export_matlab_sparse(pvCtx, _piVar, _pstName);
+                 break;
+             }
+         case sci_ints :
+             {
 -                bReturn = export_ints(_iH5File, _piVar, _pstName);
++                bReturn = export_ints(pvCtx, _iH5File, _piVar, _pstName);
+                 break;
+             }
+         case sci_handles :
+             {
 -                bReturn = export_handles(_piVar, _pstName);
++                bReturn = export_handles(pvCtx, _piVar, _pstName);
+                 break;
+             }
+         case sci_strings :
+             {
 -                bReturn = export_strings(_iH5File, _piVar, _pstName);
++                bReturn = export_strings(pvCtx, _iH5File, _piVar, _pstName);
+                 break;
+             }
+         case sci_u_function :
+             {
 -                bReturn = export_u_function(_piVar, _pstName);
++                bReturn = export_u_function(pvCtx, _piVar, _pstName);
+                 break;
+             }
+         case sci_c_function :
+             {
 -                bReturn = export_c_function(_piVar, _pstName);
++                bReturn = export_c_function(pvCtx, _piVar, _pstName);
+                 break;
+             }
+         case sci_lib :
+             {
 -                bReturn = export_lib(_piVar, _pstName);
++                bReturn = export_lib(pvCtx, _piVar, _pstName);
+                 break;
+             }
+         case sci_list :
+         case sci_tlist :
+         case sci_mlist :
+             {
 -                bReturn = export_list(_iH5File, _piVar, _pstName, iType);
++                bReturn = export_list(pvCtx, _iH5File, _piVar, _pstName, iType);
+                 break;
+             }
+         case sci_lufact_pointer :
+             {
 -                bReturn = export_lufact_pointer(_piVar, _pstName);
++                bReturn = export_lufact_pointer(pvCtx, _piVar, _pstName);
+                 break;
+             }
+         case 0 : //void case to "null" items in list
+             {
 -                bReturn = export_void(_iH5File, _piVar, _pstName);
++                bReturn = export_void(pvCtx, _iH5File, _piVar, _pstName);
+                 break;
+             }
+         default :
+             {
+                 bReturn = false;
+                 break;
+             }
      }
      return bReturn;
  }
  
- static bool export_void(int _iH5File, InternalType* pIT,wchar_t* _pwstName)
 -static bool export_void(int _iH5File, int *_piVar, char* _pstName)
++static bool export_void(int* pvCtx, int _iH5File, int *_piVar, char* _pstName)
  {
-     int iRet = writeVoid(_iH5File, wide_string_to_UTF8(_pwstName));
-     if(iRet)
+     int iRet = writeVoid(_iH5File, _pstName);
+     if (iRet)
      {
          return false;
      }
      return true;
  }
  
- static bool export_undefined(int _iH5File, InternalType* pIT,wchar_t* _pwstName)
 -static bool export_undefined(int _iH5File, int *_piVar, char* _pstName)
++static bool export_undefined(int* pvCtx, int _iH5File, int *_piVar, char* _pstName)
  {
-     int iRet = writeUndefined(_iH5File, wide_string_to_UTF8(_pwstName));
-     if(iRet)
+     int iRet = writeUndefined(_iH5File, _pstName);
+     if (iRet)
      {
          return false;
      }
      return true;
  }
  
- static bool export_list(int _iH5File, InternalType* pIT, wchar_t* _pwstName)
 -static bool export_list(int _iH5File, int *_piVar, char* _pstName, int _iVarType)
++static bool export_list(int* pvCtx, int _iH5File, int *_piVar, char* _pstName, int _iVarType)
  {
      int iRet        = 0;
-     char* pstName   = wide_string_to_UTF8(_pwstName);
      bool bReturn    = false;
+     int iItemNumber = 0;
 -    SciErr sciErr   = getListItemNumber(pvApiCtx, _piVar, &iItemNumber);
++    SciErr sciErr   = getListItemNumber(pvCtx, _piVar, &iItemNumber);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return false;
+     }
  
-     List* pList = pIT->getAs<List>();
-     int iItemNumber = pList->getSize();
      //create groupe name
-     char* pstGroupName        = createGroupName(pstName);
+     char* pstGroupName        = createGroupName(_pstName);
+     char pstMsg[256];
+     sprintf(pstMsg, "list (%d)", iItemNumber);
+     print_type(pstMsg);
  
      iLevel++;
      //open list
      void *pvList = openList(_iH5File, pstGroupName, iItemNumber);
-     for(int i = 0 ; i < iItemNumber ; i++)
+     for (int i = 0 ; i < iItemNumber ; i++)
      {
          int *piNewVar = NULL;
-        // getListItemAddress(_piVar, i + 1, &piNewVar);//1 indexed
-         InternalType* pNewIT =  pList->get(i);
 -        getListItemAddress(pvApiCtx, _piVar, i + 1, &piNewVar);//1 indexed
++        getListItemAddress(pvCtx, _piVar, i + 1, &piNewVar);//1 indexed
          char* pstPathName   = createPathName(pstGroupName, i);
-         wchar_t* pwstPathName = to_wide_string(pstPathName);
-         if(pNewIT->isListUndefined())
-         {//undefined item
-             bReturn = export_undefined(_iH5File, pNewIT, pwstPathName);
+         if (piNewVar == NULL)
+         {
+             //undefined item
 -            bReturn = export_undefined(_iH5File, piNewVar, pstPathName);
++            bReturn = export_undefined(pvCtx, _iH5File, piNewVar, pstPathName);
          }
          else
          {
-             bReturn = export_data(_iH5File, pNewIT, pwstPathName);
 -            bReturn = export_data(_iH5File, piNewVar, pstPathName);
++            bReturn = export_data(pvCtx, _iH5File, piNewVar, pstPathName);
          }
  
          iRet = addItemInList(_iH5File, pvList, i, pstPathName);
      return true;
  }
  
- static bool export_double(int _iH5File, InternalType* pIT,wchar_t* _pwstName)
 -static bool export_double(int _iH5File, int *_piVar, char* _pstName)
++static bool export_double(int* pvCtx, int _iH5File, int *_piVar, char* _pstName)
  {
      int iRet            = 0;
-     Double* pDbl = pIT->getAs<Double>();
-     char* pstName       = wide_string_to_UTF8(_pwstName);
 -    int iComplex        = isVarComplex(pvApiCtx, _piVar);
++    int iComplex        = isVarComplex(pvCtx, _piVar);
+     int piDims[2];
+     int iType = 0;
+     double *pdblReal  = NULL;
+     double *pdblImg           = NULL;
 -    SciErr sciErr = getVarType(pvApiCtx, _piVar, &iType);
++    SciErr sciErr = getVarType(pvCtx, _piVar, &iType);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return false;
+     }
  
-     if(pDbl->isComplex())
-         iRet = writeDoubleComplexMatrix(_iH5File, pstName, pDbl->getRows(), pDbl->getCols(), pDbl->getReal(), pDbl->getImg());
+     if (iType != sci_matrix)
+     {
+         return false;
+     }
+     if (iComplex)
+     {
 -        sciErr = getComplexMatrixOfDouble(pvApiCtx, _piVar, &piDims[0], &piDims[1], &pdblReal, &pdblImg);
++        sciErr = getComplexMatrixOfDouble(pvCtx, _piVar, &piDims[0], &piDims[1], &pdblReal, &pdblImg);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return false;
+         }
+         iRet = writeDoubleComplexMatrix(_iH5File, _pstName, 2, piDims, pdblReal, pdblImg);
+     }
      else
-         iRet = writeDoubleMatrix(_iH5File, pstName, pDbl->getRows(), pDbl->getCols(), pDbl->getReal());
+     {
 -        sciErr = getMatrixOfDouble(pvApiCtx, _piVar, &piDims[0], &piDims[1], &pdblReal);
++        sciErr = getMatrixOfDouble(pvCtx, _piVar, &piDims[0], &piDims[1], &pdblReal);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return false;
+         }
  
-     FREE(pstName);
+         iRet = writeDoubleMatrix(_iH5File, _pstName, 2, piDims, pdblReal);
+     }
  
-     if(iRet)
+     if (iRet)
      {
          return false;
      }
      return true;
  }
  
- static bool export_poly(int _iH5File, InternalType* pIT,wchar_t* _pwstName)
 -static bool export_poly(int _iH5File, int *_piVar, char* _pstName)
++static bool export_poly(int* pvCtx, int _iH5File, int *_piVar, char* _pstName)
  {
-     int iRet                = 0;
-     Polynom* pPoly   = pIT->getAs<Polynom>();
-     char* pstName           = wide_string_to_UTF8(_pwstName);
-     char* varName           = wide_string_to_UTF8(pPoly->getVariableName().c_str());
-     double** real           = NULL;
-     double** img            = NULL;
-     int* nbrCoef            = NULL;
-     int size                = pPoly->getRows()*pPoly->getCols();
+     int iRet = 0;
+     int* piNbCoef = NULL;
+     double** pdblReal = NULL;
+     double** pdblImg = NULL;
+     char pstVarName[64]       = {0};
+     int iVarNameLen = 0;
+     int piDims[2];
  
-     real = (double**)MALLOC(size*sizeof(double*));
-     nbrCoef = (int*)MALLOC(size*sizeof(int));
  
-     for(int i=0; i < size; i++)
 -    SciErr sciErr = getPolyVariableName(pvApiCtx, _piVar, pstVarName, &iVarNameLen);
++    SciErr sciErr = getPolyVariableName(pvCtx, _piVar, pstVarName, &iVarNameLen);
+     if (sciErr.iErr)
      {
-         nbrCoef[i] = pPoly->get(i)->getRank();
-         real[i] = pPoly->get(i)->getCoefReal();
+         printError(&sciErr, 0);
+         return false;
      }
  
-     if(pPoly->isComplex())
 -    if (isVarComplex(pvApiCtx, _piVar))
++    if (isVarComplex(pvCtx, _piVar))
      {
-         img = (double**)MALLOC(size*sizeof(double*));
-         for(int i=0; i <size; i++)
 -        sciErr = getComplexMatrixOfPoly(pvApiCtx, _piVar, &piDims[0], &piDims[1], NULL, NULL, NULL);
++        sciErr = getComplexMatrixOfPoly(pvCtx, _piVar, &piDims[0], &piDims[1], NULL, NULL, NULL);
+         if (sciErr.iErr)
          {
-             img[i] = pPoly->get(i)->getCoefImg();
+             printError(&sciErr, 0);
+             return false;
          }
  
-         iRet = writePolyComplexMatrix(_iH5File, pstName, varName , pPoly->getRows(), pPoly->getCols(), nbrCoef, real, img);
-         FREE(img);
+         piNbCoef = (int*)MALLOC(piDims[0] * piDims[1] * sizeof(int));
 -        sciErr = getComplexMatrixOfPoly(pvApiCtx, _piVar, &piDims[0], &piDims[1], piNbCoef, NULL, NULL);
++        sciErr = getComplexMatrixOfPoly(pvCtx, _piVar, &piDims[0], &piDims[1], piNbCoef, NULL, NULL);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return false;
+         }
+         pdblReal = (double**)MALLOC(sizeof(double*) * piDims[0] * piDims[1]);
+         pdblImg = (double**)MALLOC(sizeof(double*) * piDims[0] * piDims[1]);
+         for (int i = 0 ; i < piDims[0] * piDims[1] ; i++)
+         {
+             pdblReal[i] = (double*)MALLOC(sizeof(double) * piNbCoef[i]);// for null termination
+             pdblImg[i]        = (double*)MALLOC(sizeof(double) * piNbCoef[i]);// for null termination
+         }
 -        sciErr = getComplexMatrixOfPoly(pvApiCtx, _piVar, &piDims[0], &piDims[1], piNbCoef, pdblReal, pdblImg);
++        sciErr = getComplexMatrixOfPoly(pvCtx, _piVar, &piDims[0], &piDims[1], piNbCoef, pdblReal, pdblImg);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return false;
+         }
+         iRet = writePolyComplexMatrix(_iH5File, _pstName, pstVarName, 2, piDims, piNbCoef, pdblReal, pdblImg);
      }
      else
      {
-         iRet = writePolyMatrix(_iH5File, pstName, varName, pPoly->getRows(), pPoly->getCols(), nbrCoef, real);
-     }
 -        sciErr = getMatrixOfPoly(pvApiCtx, _piVar, &piDims[0], &piDims[1], NULL, NULL);
++        sciErr = getMatrixOfPoly(pvCtx, _piVar, &piDims[0], &piDims[1], NULL, NULL);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return false;
+         }
  
-     FREE(nbrCoef);
-     FREE(real);
-     FREE(pstName);
-     FREE(varName);
+         piNbCoef = (int*)MALLOC(piDims[0] * piDims[1] * sizeof(int));
 -        sciErr = getMatrixOfPoly(pvApiCtx, _piVar, &piDims[0], &piDims[1], piNbCoef, NULL);
++        sciErr = getMatrixOfPoly(pvCtx, _piVar, &piDims[0], &piDims[1], piNbCoef, NULL);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return false;
+         }
  
-     if(iRet)
+         pdblReal = (double**)MALLOC(sizeof(double*) * piDims[0] * piDims[1]);
+         for (int i = 0 ; i < piDims[0] * piDims[1] ; i++)
+         {
+             pdblReal[i] = (double*)MALLOC(sizeof(double) * piNbCoef[i]);// for null termination
+         }
 -        sciErr = getMatrixOfPoly(pvApiCtx, _piVar, &piDims[0], &piDims[1], piNbCoef, pdblReal);
++        sciErr = getMatrixOfPoly(pvCtx, _piVar, &piDims[0], &piDims[1], piNbCoef, pdblReal);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return false;
+         }
+         iRet = writePolyMatrix(_iH5File, _pstName, pstVarName, 2, piDims, piNbCoef, pdblReal);
+     }
+     if (iRet)
      {
          return false;
      }
      return true;
  }
  
- static bool export_boolean(int _iH5File, InternalType* pIT,wchar_t* _pwstName)
 -static bool export_boolean(int _iH5File, int *_piVar, char* _pstName)
++static bool export_boolean(int* pvCtx, int _iH5File, int *_piVar, char* _pstName)
  {
-     int iRet            = 0;
-     Bool* pBool  = pIT->getAs<Bool>();
-     char* pstName       = wide_string_to_UTF8(_pwstName);
+     int *piData = NULL;
+     int piDims[2];
  
-     iRet = writeBooleanMatrix(_iH5File, pstName, pBool->getRows(), pBool->getCols(), pBool->get());
-     FREE(pstName);
+     //for error management
 -    SciErr sciErr = getMatrixOfBoolean(pvApiCtx, _piVar, &piDims[0], &piDims[1], &piData);
++    SciErr sciErr = getMatrixOfBoolean(pvCtx, _piVar, &piDims[0], &piDims[1], &piData);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 0;
+     }
  
-     if(iRet)
+     int iRet = writeBooleanMatrix(_iH5File, _pstName, 2, piDims, piData);
+     if (iRet)
      {
          //Msg ??
          return false;
      print_type(pstMsg);
      return true;
  }
- /*
- static bool export_boolean_sparse(int _iH5File, InternalType* pIT,wchar_t* _pwstName)
- {
-     int iRet                                          = 0;
-     int iRows                                         = 0;InternalType::Real
-     int iCols                                         = 0;
-     int iNbItem                                       = 0;
-     int* piNbItemRow          = NULL;
-     int* piColPos                             = NULL;
  
-     SciErr sciErr = getBooleanSparseMatrix(pvApiCtx, _piVar, &iRows, &iCols, &iNbItem, &piNbItemRow, &piColPos);
-     if(sciErr.iErr)
 -static bool export_boolean_sparse(int _iH5File, int *_piVar, char* _pstName)
++static bool export_boolean_sparse(int* pvCtx, int _iH5File, int *_piVar, char* _pstName)
+ {
+     int iRet = 0;
+     int iNbItem = 0;
+     int* piNbItemRow = NULL;
+     int* piColPos = NULL;
+     int piDims[2];
 -    SciErr sciErr = getBooleanSparseMatrix(pvApiCtx, _piVar, &piDims[0], &piDims[1], &iNbItem, &piNbItemRow, &piColPos);
++    SciErr sciErr = getBooleanSparseMatrix(pvCtx, _piVar, &piDims[0], &piDims[1], &iNbItem, &piNbItemRow, &piColPos);
+     if (sciErr.iErr)
      {
          printError(&sciErr, 0);
          return false;
      print_type(pstMsg);
      return true;
  }
- /*
- static bool export_sparse(int _iH5File, InternalType* pIT,wchar_t* _pwstName)
 -static bool export_sparse(int _iH5File, int *_piVar, char* _pstName)
++static bool export_sparse(int* pvCtx, int _iH5File, int *_piVar, char* _pstName)
  {
-     int iRet                                          = 0;
-     int iRows                                         = 0;
-     int iCols                                         = 0;
-     int iNbItem                                       = 0;
-     int* piNbItemRow          = NULL;
-     int* piColPos                             = NULL;
-     double* pdblReal          = NULL;
-     double* pdblImg           = NULL;
+     int iRet = 0;
+     int iNbItem = 0;
+     int* piNbItemRow = NULL;
+     int* piColPos = NULL;
+     double* pdblReal = NULL;
+     double* pdblImg = NULL;
+     int piDims[2];
      SciErr sciErr;
  
-     if(isVarComplex(pvApiCtx, _piVar))
 -    if (isVarComplex(pvApiCtx, _piVar))
++    if (isVarComplex(pvCtx, _piVar))
      {
-         sciErr = getComplexSparseMatrix(pvApiCtx, _piVar, &iRows, &iCols, &iNbItem, &piNbItemRow, &piColPos, &pdblReal, &pdblImg);
-         if(sciErr.iErr)
 -        sciErr = getComplexSparseMatrix(pvApiCtx, _piVar, &piDims[0], &piDims[1], &iNbItem, &piNbItemRow, &piColPos, &pdblReal, &pdblImg);
++        sciErr = getComplexSparseMatrix(pvCtx, _piVar, &piDims[0], &piDims[1], &iNbItem, &piNbItemRow, &piColPos, &pdblReal, &pdblImg);
+         if (sciErr.iErr)
          {
              printError(&sciErr, 0);
              return false;
      }
      else
      {
-         sciErr = getSparseMatrix(pvApiCtx, _piVar, &iRows, &iCols, &iNbItem, &piNbItemRow, &piColPos, &pdblReal);
-         if(sciErr.iErr)
 -        sciErr = getSparseMatrix(pvApiCtx, _piVar, &piDims[0], &piDims[1], &iNbItem, &piNbItemRow, &piColPos, &pdblReal);
++        sciErr = getSparseMatrix(pvCtx, _piVar, &piDims[0], &piDims[1], &iNbItem, &piNbItemRow, &piColPos, &pdblReal);
+         if (sciErr.iErr)
          {
              printError(&sciErr, 0);
              return false;
      print_type(pstMsg);
      return true;
  }
- /*
- static bool export_matlab_sparse(void* pvApiCtx, int *_piVar, char* _pstName)
 -static bool export_matlab_sparse(int *_piVar, char* _pstName)
++static bool export_matlab_sparse(int* pvCtx, int *_piVar, char* _pstName)
  {
      print_type(_pstName);
      return false;
  }
- */
- static bool export_ints(int _iH5File, InternalType* pIT,wchar_t* _pwstName)
 -static bool export_ints(int _iH5File, int *_piVar, char* _pstName)
++static bool export_ints(int* pvCtx, int _iH5File, int *_piVar, char* _pstName)
  {
-     int iRet            = 0;
-     char* pstName       = wide_string_to_UTF8(_pwstName);
+     int iRet = 0;
+     void *piData = NULL;
+     int iPrec = 0;
+     int piDims[2];
  
-     switch(pIT->getType())
 -    SciErr sciErr = getMatrixOfIntegerPrecision(pvApiCtx, _piVar, &iPrec);
++    SciErr sciErr = getMatrixOfIntegerPrecision(pvCtx, _piVar, &iPrec);
+     if (sciErr.iErr)
      {
-         case InternalType::RealInt8 :
-         {
-             Int8* pInt    = pIT->getAs<Int8>();
-             iRet = writeInteger8Matrix(_iH5File, pstName, pInt->getRows(), pInt->getCols(), pInt->get());
-             break;
-         }
-         case InternalType::RealUInt8 :
-         {
-             UInt8* pInt    = pIT->getAs<UInt8>();
-             iRet = writeUnsignedInteger8Matrix(_iH5File, pstName, pInt->getRows(), pInt->getCols(), pInt->get());
-             break;
-         }
-         case InternalType::RealInt16 :
-         {
-             Int16* pInt    = pIT->getAs<Int16>();
-             iRet = writeInteger16Matrix(_iH5File, pstName, pInt->getRows(), pInt->getCols(), pInt->get());
+         printError(&sciErr, 0);
+         return false;
+     }
+     switch (iPrec)
+     {
+         case SCI_INT8 :
 -            sciErr = getMatrixOfInteger8(pvApiCtx, _piVar, &piDims[0], &piDims[1], (char**)&piData);
++            sciErr = getMatrixOfInteger8(pvCtx, _piVar, &piDims[0], &piDims[1], (char**)&piData);
+             if (sciErr.iErr)
+             {
+                 printError(&sciErr, 0);
+                 return false;
+             }
+             iRet = writeInteger8Matrix(_iH5File, _pstName, 2, piDims, (char*)piData);
              break;
-         }
-         case InternalType::RealUInt16 :
-         {
-             UInt16* pInt    = pIT->getAs<UInt16>();
-             iRet = writeUnsignedInteger16Matrix(_iH5File, pstName, pInt->getRows(), pInt->getCols(), pInt->get());
+         case SCI_UINT8 :
 -            sciErr = getMatrixOfUnsignedInteger8(pvApiCtx, _piVar, &piDims[0], &piDims[1], (unsigned char**)&piData);
++            sciErr = getMatrixOfUnsignedInteger8(pvCtx, _piVar, &piDims[0], &piDims[1], (unsigned char**)&piData);
+             if (sciErr.iErr)
+             {
+                 printError(&sciErr, 0);
+                 return false;
+             }
+             iRet = writeUnsignedInteger8Matrix(_iH5File, _pstName, 2, piDims, (unsigned char*)piData);
              break;
-         }
-         case InternalType::RealInt32 :
-         {
-             Int32* pInt    = pIT->getAs<Int32>();
-             iRet = writeInteger32Matrix(_iH5File, pstName, pInt->getRows(), pInt->getCols(), pInt->get());
+         case SCI_INT16 :
 -            sciErr = getMatrixOfInteger16(pvApiCtx, _piVar, &piDims[0], &piDims[1], (short**)&piData);
++            sciErr = getMatrixOfInteger16(pvCtx, _piVar, &piDims[0], &piDims[1], (short**)&piData);
+             if (sciErr.iErr)
+             {
+                 printError(&sciErr, 0);
+                 return false;
+             }
+             iRet = writeInteger16Matrix(_iH5File, _pstName, 2, piDims, (short*)piData);
              break;
-         }
-         case InternalType::RealUInt32 :
-         {
-             UInt32* pInt    = pIT->getAs<UInt32>();
-             iRet = writeUnsignedInteger32Matrix(_iH5File, pstName, pInt->getRows(), pInt->getCols(), pInt->get());
+         case SCI_UINT16 :
 -            sciErr = getMatrixOfUnsignedInteger16(pvApiCtx, _piVar, &piDims[0], &piDims[1], (unsigned short**)&piData);
++            sciErr = getMatrixOfUnsignedInteger16(pvCtx, _piVar, &piDims[0], &piDims[1], (unsigned short**)&piData);
+             if (sciErr.iErr)
+             {
+                 printError(&sciErr, 0);
+                 return false;
+             }
+             iRet = writeUnsignedInteger16Matrix(_iH5File, _pstName, 2, piDims, (unsigned short*)piData);
              break;
-         }
-         case InternalType::RealInt64 :
-         {
-             Int64* pInt    = pIT->getAs<Int64>();
-             iRet = writeInteger64Matrix(_iH5File, pstName, pInt->getRows(), pInt->getCols(), pInt->get());
+         case SCI_INT32 :
 -            sciErr = getMatrixOfInteger32(pvApiCtx, _piVar, &piDims[0], &piDims[1], (int**)&piData);
++            sciErr = getMatrixOfInteger32(pvCtx, _piVar, &piDims[0], &piDims[1], (int**)&piData);
+             if (sciErr.iErr)
+             {
+                 printError(&sciErr, 0);
+                 return false;
+             }
+             iRet = writeInteger32Matrix(_iH5File, _pstName, 2, piDims, (int*)piData);
              break;
-         }
-         case InternalType::RealUInt64 :
-         {
-             UInt64* pInt    = pIT->getAs<UInt64>();
-             iRet = writeUnsignedInteger64Matrix(_iH5File, pstName, pInt->getRows(), pInt->getCols(), pInt->get());
+         case SCI_UINT32 :
 -            sciErr = getMatrixOfUnsignedInteger32(pvApiCtx, _piVar, &piDims[0], &piDims[1], (unsigned int**)&piData);
++            sciErr = getMatrixOfUnsignedInteger32(pvCtx, _piVar, &piDims[0], &piDims[1], (unsigned int**)&piData);
+             if (sciErr.iErr)
+             {
+                 printError(&sciErr, 0);
+                 return false;
+             }
+             iRet = writeUnsignedInteger32Matrix(_iH5File, _pstName, 2, piDims, (unsigned int*)piData);
              break;
-         }
+         case SCI_INT64 :
+             //sciErr = getMatrixOfInteger64(_piVar, &piDims[0], &piDims[1], (long long**)&piData);
+             //if(sciErr.iErr)
+             //{
+             //        printError(&sciErr, 0);
+             //        return false;
+             //}
+             //iRet = writeInteger64Matrix(_iH5File, _pstName, 2, piDims, (long long*)piData);
+             //break;
+         case SCI_UINT64 :
+             //sciErr = getMatrixOfUnsignedInteger64(_piVar, &piDims[0], &piDims[1], (unsigned long long**)&piData);
+             //if(sciErr.iErr)
+             //{
+             //        printError(&sciErr, 0);
+             //        return false;
+             //}
+             //iRet = writeUnsignedInteger64Matrix(_iH5File, _pstName, 2, piDims, (unsigned long long*)piData);
+             //break;
          default :
-             iRet = true;
+             return 1;
+             break;
      }
  
-     if(iRet)
+     if (iRet)
      {
          return false;
      }
- /*
      char pstMsg[512];
-     sprintf(pstMsg, "int%d (%d x %d)", 8*iPrec, iRows, iCols);
+     sprintf(pstMsg, "int%d (%d x %d)", 8 * iPrec, piDims[0], piDims[1]);
      print_type(pstMsg);
- */
      return true;
  }
- /*
- static bool export_handles(void* pvApiCtx, int *_piVar, char* _pstName)
 -static bool export_handles(int *_piVar, char* _pstName)
++static bool export_handles(int* pvCtx, int *_piVar, char* _pstName)
  {
      print_type(_pstName);
      return false;
  }
- */
- static bool export_strings(int _iH5File, InternalType* pIT,wchar_t* _pwstName)
 -static bool export_strings(int _iH5File, int *_piVar, char* _pstName)
++static bool export_strings(int* pvCtx, int _iH5File, int *_piVar, char* _pstName)
  {
+     int iRet = 0;
+     int* piLen = NULL;
+     char** pstData = NULL;
+     int piDims[2];
  
-     int iRet            = 0;
-     String* pStr = pIT->getAs<String>();
-     char* pstName       = wide_string_to_UTF8(_pwstName);
-     char** pstData      = NULL;
 -    SciErr sciErr = getMatrixOfString(pvApiCtx, _piVar, &piDims[0], &piDims[1], NULL, NULL);
++    SciErr sciErr = getMatrixOfString(pvCtx, _piVar, &piDims[0], &piDims[1], NULL, NULL);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return false;
+     }
  
-     pstData = (char**)malloc(pStr->getRows()*pStr->getCols()*sizeof(char*));
+     piLen = (int*)MALLOC(piDims[0] * piDims[1] * sizeof(int));
 -    sciErr = getMatrixOfString(pvApiCtx, _piVar, &piDims[0], &piDims[1], piLen, NULL);
++    sciErr = getMatrixOfString(pvCtx, _piVar, &piDims[0], &piDims[1], piLen, NULL);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return false;
+     }
  
-     for(int i=0; i < pStr->getRows()*pStr->getCols(); i++)
-         pstData[i] = wide_string_to_UTF8(pStr->get(i));
+     pstData = (char**)MALLOC(sizeof(char*) * piDims[0] * piDims[1]);
+     for (int i = 0 ; i < piDims[0] * piDims[1] ; i++)
+     {
+         pstData[i] = (char*)MALLOC(sizeof(char) * (piLen[i] + 1));// for null termination
+     }
  
-     iRet = writeStringMatrix(_iH5File, pstName, pStr->getRows(), pStr->getCols(),pstData);
 -    sciErr = getMatrixOfString(pvApiCtx, _piVar, &piDims[0], &piDims[1], piLen, pstData);
++    sciErr = getMatrixOfString(pvCtx, _piVar, &piDims[0], &piDims[1], piLen, pstData);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return false;
+     }
  
-     FREE(pstName);
-     FREE(pstData);
+     iRet = writeStringMatrix(_iH5File, _pstName, 2, piDims, pstData);
  
-     if(iRet)
+     if (iRet)
      {
          return false;
      }
  
      char pstMsg[512];
-     sprintf(pstMsg, "string (%d x %d)", pStr->getRows(), pStr->getCols());
+     sprintf(pstMsg, "string (%d x %d)", piDims[0], piDims[1]);
      print_type(pstMsg);
  
+     freeArrayOfString(pstData, piDims[0] * piDims[1]);
      return true;
  }
- /*
- static bool export_u_function(void* pvApiCtx, int *_piVar, char* _pstName)
 -static bool export_u_function(int *_piVar, char* _pstName)
++static bool export_u_function(int* pvCtx, int *_piVar, char* _pstName)
  {
      print_type(_pstName);
      return false;
  }
- /*
- static bool export_c_function(void* pvApiCtx, int *_piVar, char* _pstName)
 -static bool export_c_function(int *_piVar, char* _pstName)
++static bool export_c_function(int* pvCtx, int *_piVar, char* _pstName)
  {
      print_type(_pstName);
      return false;
  }
- /*
- static bool export_lib(void* pvApiCtx, int *_piVar, char* _pstName)
 -static bool export_lib(int *_piVar, char* _pstName)
++static bool export_lib(int* pvCtx, int *_piVar, char* _pstName)
  {
      print_type(_pstName);
      return false;
  }
- /*
- static bool export_lufact_pointer(void* pvApiCtx, int *_piVar, char* _pstName)
 -static bool export_lufact_pointer(int *_piVar, char* _pstName)
++static bool export_lufact_pointer(int* pvCtx, int *_piVar, char* _pstName)
  {
      print_type(_pstName);
      return false;
@@@ -754,16 -897,25 +895,25 @@@ void print_type(char* _pstType
  #endif
  }
  
- int extractVarNameList(typed_list &in, wchar_t** _pstNameList)
 -int extractVarNameList(int _iStart, int _iEnd, char** _pstNameList)
++int extractVarNameList(int* pvCtx, int _iStart, int _iEnd, char** _pstNameList)
  {
      int iCount = 0;
  
-     for(int i = 0 ; i < in.size() ; i++)
+     for (int i = _iStart ; i <= _iEnd ; i++)
      {
-         if(in[i]->isString() == false || in[i]->getAs<String>()->isScalar() == false)
+         int* piAddr = NULL;
+         int iType   = 0;
 -        SciErr sciErr = getVarAddressFromPosition(pvApiCtx, i, &piAddr);
++        SciErr sciErr = getVarAddressFromPosition(pvCtx, i, &piAddr);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return 0;
+         }
 -        if (getAllocatedSingleString(pvApiCtx, piAddr, &_pstNameList[iCount]))
++        if (getAllocatedSingleString(pvCtx, piAddr, &_pstNameList[iCount]))
          {
-             ScierrorW(999,_W("%ls: Wrong type for input argument #%d: A string expected.\n"), L"export_to_hdf5", i + 1);
+             Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), "export_to_hdf5", i);
              return 0;
          }
  
@@@ -39,250 -27,363 +27,362 @@@ extern "C
  #include "expandPathVariable.h"
  }
  
+ #include "import_from_hdf5_v1.hxx"
 -static bool import_variable(int _iFile, char* _pstVarName);
 -static bool import_data(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
 -static bool import_double(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
 -static bool import_string(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
 -static bool import_boolean(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
 -static bool import_integer(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
 -static bool import_sparse(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
 -static bool import_boolean_sparse(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
 -static bool import_poly(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
 -static bool import_list(int _iDatasetId, int _iVarType, int _iItemPos, int *_piAddress, char *_pstVarname);
 -static bool import_void(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
 -static bool import_undefined(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
 -
 -int sci_import_from_hdf5(char *fname, unsigned long fname_len)
++static bool import_variable(int* pvCtx, int _iFile, char* _pstVarName);
++static bool import_data(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
++static bool import_double(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
++static bool import_string(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
++static bool import_boolean(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
++static bool import_integer(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
++static bool import_sparse(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
++static bool import_boolean_sparse(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
++static bool import_poly(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
++static bool import_list(int* pvCtx, int _iDatasetId, int _iVarType, int _iItemPos, int *_piAddress, char *_pstVarname);
++static bool import_void(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
++static bool import_undefined(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
++
++int sci_import_from_hdf5(char *fname, int* pvApiCtx)
+ {
+     SciErr sciErr;
  
- //#define PRINT_DEBUG
- //#define TIME_DEBUG
- static int iTab = 0;
- static int iCloseList = 0;
- void print_tree(char* _pstMsg);
+     int* piAddr = NULL;
+     char* pstFilename = NULL;
+     char* pstExpandedFilename = NULL;
+     bool bImport = true;
  
- static types::InternalType* import_data(int _iDatasetId);
- static types::InternalType* import_double(int _iDatasetId);
- static types::InternalType* import_string(int _iDatasetId);
- static types::InternalType* import_boolean(int _iDatasetId);
- static types::InternalType* import_integer(int _iDatasetId);
- //static types::InternalType* import_sparse(int _iDatasetId);
- //static types::InternalType* import_boolean_sparse(int _iDatasetId);
- static types::InternalType* import_poly(int _iDatasetId);
- static types::InternalType* import_list(int _iDatasetId, int _iVarType);
- //static types::InternalType* import_void(int _iDatasetId);
- static types::InternalType* import_undefined(int _iDatasetId);
+     int iSelectedVar = Rhs - 1;
  
- types::Function::ReturnValue sci_import_from_hdf5(types::typed_list &in, int _iRetCount, types::typed_list &out)
- {
-     char* pstFileName       = NULL;
-     int iNbItem             = 0;
-     int iFile               = 0;
-     bool bImport            = false;
-     int iSelectedVar        = in.size() - 1;
 -    CheckInputArgumentAtLeast(pvApiCtx, 1);
++    CheckInputArgumentAtLeast(pvApiCtx , 1);
+     CheckOutputArgument(pvApiCtx, 1, 1);
  
-     if(in.size() != 1)
+     sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+     if (sciErr.iErr)
      {
-         ScierrorW(77, _W("%ls: Wrong number of input argument(s): %d expected.\n"), L"import_from_hdf5", 1);
-         return types::Function::Error;
+         printError(&sciErr, 0);
+         return 1;
      }
  
-     if(in[0]->isString() == false || in[0]->getAs<types::String>()->isScalar() == false)
+     if (getAllocatedSingleString(pvApiCtx, piAddr, &pstFilename))
      {
-         ScierrorW(999,_W("%ls: Wrong type for input argument #%d: A string expected.\n"), L"import_from_hdf5", 1);
-         return types::Function::Error;
+         Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), fname, 2);
+         return 1;
      }
  
-     pstFileName = wide_string_to_UTF8(in[0]->getAs<types::String>()->get(0));
      //open hdf5 file
-     iFile = openHDF5File(pstFileName);
-     if(iFile < 0)
+     pstExpandedFilename = expandPathVariable(pstFilename);
+     int iFile = openHDF5File(pstExpandedFilename, 0);
+     if (iFile < 0)
      {
-         ScierrorW(999,_W("%ls: Cannot open file %s.\n"), L"import_to_hdf5", pstFileName);
-         return types::Function::Error;
+         Scierror(999, _("%s: Unable to open file: %s\n"), fname, pstFilename);
+         FREE(pstExpandedFilename);
+         FREE(pstFilename);
+         return 1;
      }
  
+     FREE(pstExpandedFilename);
+     FREE(pstFilename);
  
      //manage version information
      int iVersion = getSODFormatAttribute(iFile);
-     if (iVersion > SOD_FILE_VERSION)
-     {//can't read file with version newer that me !
-         ScierrorW(999, _W("%ls: Wrong SOD file format version. Max Expected: %d Found: %d\n"), L"import_to_hdf5", SOD_FILE_VERSION, iVersion);
-         return types::Function::Error;
-     }
-     if (iSelectedVar)
+     if (iVersion != SOD_FILE_VERSION)
      {
-         char** pstVarNameList = (char**)MALLOC(sizeof(char*) * iNbItem);
-         wchar_t** pwstVarNameList = (wchar_t**)MALLOC(sizeof(wchar_t*) * iNbItem);
-         iNbItem = getVariableNames(iFile, pstVarNameList);
-         for(int i=0; i<iNbItem; i++)
+         if (iVersion > SOD_FILE_VERSION)
          {
-             pwstVarNameList[i] = to_wide_string(pstVarNameList[i]);
+             //can't read file with version newer that me !
+             Scierror(999, _("%s: Wrong SOD file format version. Max Expected: %d Found: %d\n"), fname, SOD_FILE_VERSION, iVersion);
+             return 1;
+         }
+         else
+         {
+             //call older import functions and exit or ... EXIT !
+             if (iVersion == 1 || iVersion == -1)
+             {
+                 //sciprint("old sci_import_from_hdf5_v1\n");
 -                return sci_import_from_hdf5_v1(fname, fname_len);
++                return sci_import_from_hdf5_v1(fname, pvApiCtx);
+             }
          }
+     }
  
-         //import all data
-         for(int i = 0 ; i < iNbItem ; i++)
+     if (iSelectedVar)
+     {
+         //selected variable
+         char* pstVarName = NULL;
+         for (int i = 0 ; i < iSelectedVar ; i++)
          {
-             int iDataSetId = getDataSetIdFromName(iFile, pstVarNameList[i]);
-             if(iDataSetId == 0)
+             sciErr = getVarAddressFromPosition(pvApiCtx, i + 2, &piAddr);
+             if (sciErr.iErr)
              {
-                 return types::Function::Error;
+                 printError(&sciErr, 0);
+                 return 1;
              }
  
-             types::InternalType* pIT = import_data(iDataSetId);
+             if (getAllocatedSingleString(pvApiCtx, piAddr, &pstVarName))
+             {
+                 Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), fname, i + 1);
+                 return 1;
+             }
  
-             if(pIT == NULL)
 -            if (import_variable(iFile, pstVarName) == false)
++            if (import_variable(pvApiCtx, iFile, pstVarName) == false)
              {
+                 bImport = false;
                  break;
              }
  
-             symbol::Context::getInstance()->put(symbol::Symbol(pwstVarNameList[i]), *pIT);
-             bImport = true;
+             FREE(pstVarName);
+         }
+     }
+     else
+     {
+         //all variables
+         int iNbItem = 0;
+         iNbItem = getVariableNames(iFile, NULL);
+         if (iNbItem != 0)
+         {
+             char **pstVarNameList = (char **)MALLOC(sizeof(char *) * iNbItem);
+             iNbItem = getVariableNames(iFile, pstVarNameList);
+             //import all data
+             for (int i = 0; i < iNbItem; i++)
+             {
 -                if (import_variable(iFile, pstVarNameList[i]) == false)
++                if (import_variable(pvApiCtx, iFile, pstVarNameList[i]) == false)
+                 {
+                     bImport = false;
+                     break;
+                 }
+             }
          }
      }
      //close the file
      closeHDF5File(iFile);
  
-     //create boolean return value
-     types::Bool* pOut = new types::Bool(bImport);
-     out.push_back(pOut);
+     int *piReturn = NULL;
+     sciErr = allocMatrixOfBoolean(pvApiCtx, Rhs + 1, 1, 1, &piReturn);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     if (bImport == true)
+     {
+         piReturn[0] = 1;
+     }
+     else
+     {
+         piReturn[0] = 0;
+     }
+     AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+     ReturnArguments(pvApiCtx);
+     //  printf("End gateway !!!\n");
+     return 0;
+ }
  
-     FREE(pstFileName);
 -static bool import_variable(int _iFile, char* _pstVarName)
++static bool import_variable(int* pvCtx, int _iFile, char* _pstVarName)
+ {
+     int iDataSetId = getDataSetIdFromName(_iFile, _pstVarName);
+     if (iDataSetId == 0)
+     {
+         return false;
+     }
  
-     return types::Function::OK;
 -    return import_data(iDataSetId, 0, NULL, _pstVarName);
++    return import_data(pvCtx, iDataSetId, 0, NULL, _pstVarName);
  }
  
- //static types::InternalType* import_data(void* pvApiCtx, int _iDatasetId)
- static types::InternalType* import_data(int _iDatasetId)
 -static bool import_data(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
++static bool import_data(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
  {
-     types::InternalType* pIT = NULL;
      bool bRet = false;
      //get var type
      int iVarType = getScilabTypeFromDataSet(_iDatasetId);
-     switch(iVarType)
+     switch (iVarType)
      {
-     case sci_matrix :
+         case sci_matrix:
          {
-             pIT = import_double(_iDatasetId);
 -            bRet = import_double(_iDatasetId, _iItemPos, _piAddress, _pstVarname);
++            bRet = import_double(pvCtx, _iDatasetId, _iItemPos, _piAddress, _pstVarname);
              break;
          }
-     case sci_strings :
+         case sci_strings:
          {
-             pIT = import_string(_iDatasetId);
 -            bRet = import_string(_iDatasetId, _iItemPos, _piAddress, _pstVarname);
++            bRet = import_string(pvCtx, _iDatasetId, _iItemPos, _piAddress, _pstVarname);
              break;
          }
-     case sci_list :
-     case sci_tlist :
-     case sci_mlist :
+         case sci_list:
+         case sci_tlist:
+         case sci_mlist:
          {
-             pIT = import_list(_iDatasetId, iVarType);
 -            bRet = import_list(_iDatasetId, iVarType, _iItemPos, _piAddress, _pstVarname);
++            bRet = import_list(pvCtx, _iDatasetId, iVarType, _iItemPos, _piAddress, _pstVarname);
              break;
          }
-     case sci_boolean :
+         case sci_boolean:
          {
-             pIT = import_boolean(_iDatasetId);
 -            bRet = import_boolean(_iDatasetId, _iItemPos, _piAddress, _pstVarname);
++            bRet = import_boolean(pvCtx, _iDatasetId, _iItemPos, _piAddress, _pstVarname);
              break;
          }
-     case sci_poly :
+         case sci_poly:
          {
-             pIT = import_poly(_iDatasetId);
 -            bRet = import_poly(_iDatasetId, _iItemPos, _piAddress, _pstVarname);
++            bRet = import_poly(pvCtx, _iDatasetId, _iItemPos, _piAddress, _pstVarname);
              break;
          }
-     case sci_ints:
+         case sci_ints:
          {
-             pIT = import_integer(_iDatasetId);
 -            bRet = import_integer(_iDatasetId, _iItemPos, _piAddress, _pstVarname);
++            bRet = import_integer(pvCtx, _iDatasetId, _iItemPos, _piAddress, _pstVarname);
              break;
          }
-         /*
-     case sci_sparse :
+         case sci_sparse:
          {
-             pIT = import_sparse(pvApiCtx, _iDatasetId);
 -            bRet = import_sparse(_iDatasetId, _iItemPos, _piAddress, _pstVarname);
++            bRet = import_sparse(pvCtx, _iDatasetId, _iItemPos, _piAddress, _pstVarname);
              break;
          }
-     case sci_boolean_sparse :
+         case sci_boolean_sparse:
          {
-             pIT = import_boolean_sparse(pvApiCtx, _iDatasetId);
 -            bRet = import_boolean_sparse(_iDatasetId, _iItemPos, _piAddress, _pstVarname);
++            bRet = import_boolean_sparse(pvCtx, _iDatasetId, _iItemPos, _piAddress, _pstVarname);
              break;
          }
-         */
-     case sci_void : //void item only on list variable
+         case sci_void:             //void item only on list variable
          {
-             //pIT = import_void(_iDatasetId);
 -            bRet = import_void(_iDatasetId, _iItemPos, _piAddress, _pstVarname);
++            bRet = import_void(pvCtx, _iDatasetId, _iItemPos, _piAddress, _pstVarname);
              break;
          }
-     case sci_undefined : //undefined item only on list variable
+         case sci_undefined:        //undefined item only on list variable
          {
-             pIT = import_undefined(_iDatasetId);
 -            bRet = import_undefined(_iDatasetId, _iItemPos, _piAddress, _pstVarname);
++            bRet = import_undefined(pvCtx, _iDatasetId, _iItemPos, _piAddress, _pstVarname);
              break;
          }
-     default :
+         default:
          {
-             Scierror(999,_("%s: Invalid HDF5 Scilab format.\n"), "import_from_hdf5");
- #ifdef PRINT_DEBUG
-             {
-                 char pstMsg[512];
-                 sprintf(pstMsg, "Unknown type : %d", iVarType);
-                 print_tree(pstMsg);
-             }
- #endif
-             return NULL;
+             Scierror(999, _("%s: Invalid HDF5 Scilab format.\n"), "import_from_hdf5");
          }
      }
-     return pIT;
+     return bRet;
  }
- /*
- static types::InternalType* import_void(int _iDatasetId)
 -static bool import_void(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
++static bool import_void(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
  {
+     SciErr sciErr;
  
-     if(_piAddress)
+     if (_piAddress)
      {
-         sciErr = createVoidInNamedList(pvApiCtx);
 -        sciErr = createVoidInNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos);
++        sciErr = createVoidInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos);
      }
      else
      {
-         return NULL;
+         return false;
      }
  
-     return pVoid;
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return false;
+     }
+     return true;
  }
- */
- static types::InternalType* import_undefined(int _iDatasetId)
 -static bool import_undefined(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
++static bool import_undefined(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
  {
-     return new types::ListUndefined();
+     SciErr sciErr;
+     if (_piAddress)
+     {
 -        sciErr = createUndefinedInNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos);
++        sciErr = createUndefinedInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos);
+     }
+     else
+     {
+         return false;
+     }
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return false;
+     }
+     return true;
  }
  
- static types::InternalType* import_double(int _iDatasetId)
 -static bool import_double(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
++static bool import_double(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
  {
-     int iRet            = 0;
-     int iComplex        = 0;
-     double *pdblReal    = NULL;
-     double *pdblImg     = NULL;
-     int       iRows           = 0;
-     int iCols           = 0;
-     iRet        = getDatasetDims(_iDatasetId, &iRows, &iCols);
-     iComplex    = isComplexData(_iDatasetId);
-     if(iRet)
+     SciErr sciErr;
+     int iRet = 0;
+     double *pdblReal = NULL;
+     double *pdblImg = NULL;
+     int iDims = 0;
+     int* piDims = NULL;
+     int iComplex = 0;
+     int iSize = 0;
+     iRet = getDatasetInfo(_iDatasetId, &iComplex, &iDims, NULL);
+     if (iRet < 0)
      {
-         return NULL;
+         return false;
      }
-     if(iRows * iCols != 0)
+     piDims = (int*)MALLOC(sizeof(int) * iDims);
+     iSize = getDatasetInfo(_iDatasetId, &iComplex, &iDims, piDims);
+     if (iDims == 2 && piDims[0] * piDims[1] != 0)
      {
-         if(iComplex)
+         if (iComplex)
          {
-             pdblReal  = (double *) MALLOC(iRows * iCols * sizeof(double));
-             pdblImg           = (double *) MALLOC(iRows * iCols * sizeof(double));
-             iRet        = readDoubleComplexMatrix(_iDatasetId, iRows, iCols, pdblReal, pdblImg);
+             pdblReal = (double *)MALLOC(iSize * sizeof(double));
+             pdblImg = (double *)MALLOC(iSize * sizeof(double));
+             iRet = readDoubleComplexMatrix(_iDatasetId, pdblReal, pdblImg);
          }
          else
          {
-             pdblReal  = (double *) MALLOC(iRows * iCols * sizeof(double));
-             iRet        = readDoubleMatrix(_iDatasetId, iRows, iCols, pdblReal);
+             pdblReal = (double *)MALLOC(iSize * sizeof(double));
+             iRet = readDoubleMatrix(_iDatasetId, pdblReal);
          }
  
-         if(iRet)
+         if (iRet)
          {
-             return NULL;
+             return false;
          }
      }
+     else if (iDims > 2)
+     {
+         //hypermatrix
+         return false;
+     }
      else
      {
-         //bug 7224 : to close dataset
-         iRet    = readEmptyMatrix(_iDatasetId);
-         if(iRet)
+         /*bug 7224 : to close dataset */
+         iRet = readEmptyMatrix(_iDatasetId);
+         if (iRet)
+         {
+             return false;
+         }
+         // Hack to sure that piDims will not be null at line 372.
+         iDims = 2;
+         piDims = (int*)MALLOC(sizeof(int) * iDims);
+         memset(piDims, 0, sizeof(int) * iDims);
+     }
+     if (_piAddress == NULL)
+     {
+         if (iComplex)
+         {
 -            sciErr = createNamedComplexMatrixOfDouble(pvApiCtx, _pstVarname, piDims[0], piDims[1], pdblReal, pdblImg);
++            sciErr = createNamedComplexMatrixOfDouble(pvCtx, _pstVarname, piDims[0], piDims[1], pdblReal, pdblImg);
+         }
+         else
+         {
 -            sciErr = createNamedMatrixOfDouble(pvApiCtx, _pstVarname, piDims[0], piDims[1], pdblReal);
++            sciErr = createNamedMatrixOfDouble(pvCtx, _pstVarname, piDims[0], piDims[1], pdblReal);
+         }
+     }
+     else //if not null this variable is in a list
+     {
+         if (iComplex)
+         {
 -            sciErr = createComplexMatrixOfDoubleInNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], pdblReal, pdblImg);
++            sciErr = createComplexMatrixOfDoubleInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], pdblReal, pdblImg);
+         }
+         else
          {
-             return NULL;
 -            sciErr = createMatrixOfDoubleInNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], pdblReal);
++            sciErr = createMatrixOfDoubleInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], pdblReal);
          }
      }
  
          FREE(pdblImg);
      }
  
-     return pDbl;
+     if (iRet)
+     {
+         return false;
+     }
  
+     return true;
  }
  
- static types::InternalType* import_string(int _iDatasetId)
 -static bool import_string(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
++static bool import_string(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
  {
-     int iRet            = 0;
-     int       iRows           = 0;
-     int iCols           = 0;
-     char **pstData      = NULL;
-     wchar_t** pwstData   = NULL;
-     iRet = getDatasetDims(_iDatasetId, &iRows, &iCols);
-     if(iRet)
+     SciErr sciErr;
+     int iRet = 0;
+     char **pstData = NULL;
+     int iDims = 0;
+     int* piDims = NULL;
+     int iComplex = 0;
+     int iSize = 0;
+     iRet = getDatasetInfo(_iDatasetId, &iComplex, &iDims, NULL);
+     if (iRet < 0)
      {
-         return NULL;
+         return false;
      }
  
-     pstData = (char **) MALLOC(iRows * iCols * sizeof(char*));
-     pwstData = (wchar_t **) MALLOC(iRows * iCols * sizeof(wchar_t*));
+     piDims = (int*)MALLOC(sizeof(int) * iDims);
+     iSize = getDatasetInfo(_iDatasetId, &iComplex, &iDims, piDims);
  
-     iRet = readStringMatrix(_iDatasetId, iRows, iCols, pstData);
-     if(iRet)
+     pstData = (char **)MALLOC(iSize * sizeof(char *));
+     iRet = readStringMatrix(_iDatasetId, pstData);
+     if (iRet)
      {
-         return NULL;
+         return false;
      }
  
-     for(int i=0; i < iRows * iCols; i++)
+     if (_piAddress == NULL)
      {
-         pwstData[i] = to_wide_string(pstData[i]);
 -        sciErr = createNamedMatrixOfString(pvApiCtx, _pstVarname, piDims[0], piDims[1], pstData);
++        sciErr = createNamedMatrixOfString(pvCtx, _pstVarname, piDims[0], piDims[1], pstData);
+     }
+     else                        //if not null this variable is in a list
+     {
 -        sciErr = createMatrixOfStringInNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], pstData);
++        sciErr = createMatrixOfStringInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], pstData);
      }
  
-     types::String* pStr = new types::String(iRows,iCols);
-     pStr->set(pwstData);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return false;
+     }
  
      FREE(pstData);
-     FREE(pwstData);
-     return pStr;
+     return true;
  }
  
- static types::InternalType* import_integer( int _iDatasetId)
 -static bool import_integer(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
++static bool import_integer(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
  {
-     int iRet    = 0;
-     int       iRows   = 0;
-     int iCols   = 0;
-     int iPrec   = 0;
+     int iRet = 0;
+     int iDims = 0;
+     int* piDims = NULL;
+     int iComplex = 0;
+     int iSize = 0;
+     int iPrec = 0;
+     SciErr sciErr;
  
-     iRet = getDatasetDims(_iDatasetId, &iRows, &iCols);
-     if(iRet)
+     iRet = getDatasetInfo(_iDatasetId, &iComplex, &iDims, NULL);
+     if (iRet < 0)
      {
-         return NULL;
+         return false;
      }
  
+     piDims = (int*)MALLOC(sizeof(int) * iDims);
+     iSize = getDatasetInfo(_iDatasetId, &iComplex, &iDims, piDims);
      iRet = getDatasetPrecision(_iDatasetId, &iPrec);
-     if(iRet)
+     if (iRet)
      {
-         return NULL;
+         return false;
      }
  
-     switch(iPrec)
+     switch (iPrec)
      {
-     case sci_int8 :
+         case SCI_INT8:
          {
-             char* pcData      = NULL;
-             pcData = (char*)MALLOC(sizeof(char) * iRows * iCols);
-             iRet = readInteger8Matrix(_iDatasetId, iRows, iCols, pcData);
-             if(iRet)
+             char *pcData = NULL;
+             pcData = (char *)MALLOC(sizeof(char) * iSize);
+             iRet = readInteger8Matrix(_iDatasetId, pcData);
+             if (iRet)
+             {
+                 return false;
+             }
+             if (_piAddress == NULL)
              {
-                 return NULL;
 -                sciErr = createNamedMatrixOfInteger8(pvApiCtx, _pstVarname, piDims[0], piDims[1], pcData);
++                sciErr = createNamedMatrixOfInteger8(pvCtx, _pstVarname, piDims[0], piDims[1], pcData);
+             }
+             else
+             {
 -                sciErr = createMatrixOfInteger8InNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], pcData);
++                sciErr = createMatrixOfInteger8InNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], pcData);
              }
-             types::Int8* pInt = new types::Int8(iRows,iCols);;
-             pInt->set(pcData);
-             return pInt;
          }
-     case sci_uint8 :
+         break;
+         case SCI_UINT8:
          {
-             unsigned char* pucData    = NULL;
-             pucData = (unsigned char*)MALLOC(sizeof(unsigned char) * iRows * iCols);
-             iRet = readUnsignedInteger8Matrix(_iDatasetId, iRows, iCols, pucData);
-             if(iRet)
+             unsigned char *pucData = NULL;
+             pucData = (unsigned char *)MALLOC(sizeof(unsigned char) * iSize);
+             iRet = readUnsignedInteger8Matrix(_iDatasetId, pucData);
+             if (iRet)
              {
-                 return NULL;
+                 return false;
+             }
+             if (_piAddress == NULL)
+             {
 -                sciErr = createNamedMatrixOfUnsignedInteger8(pvApiCtx, _pstVarname, piDims[0], piDims[1], pucData);
++                sciErr = createNamedMatrixOfUnsignedInteger8(pvCtx, _pstVarname, piDims[0], piDims[1], pucData);
+             }
+             else
+             {
 -                sciErr = createMatrixOfUnsignedInteger8InNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], pucData);
++                sciErr = createMatrixOfUnsignedInteger8InNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], pucData);
              }
-             types::UInt8* pInt = new types::UInt8(iRows,iCols);;
-             pInt->set(pucData);
-             return pInt;
          }
-     case sci_int16 :
+         break;
+         case SCI_INT16:
          {
-             short* psData     = NULL;
-             psData = (short*)MALLOC(sizeof(short) * iRows * iCols);
-             iRet = readInteger16Matrix(_iDatasetId, iRows, iCols, psData);
-             if(iRet)
+             short *psData = NULL;
+             psData = (short *)MALLOC(sizeof(short) * iSize);
+             iRet = readInteger16Matrix(_iDatasetId, psData);
+             if (iRet)
              {
-                 return NULL;
+                 return false;
              }
  
-             types::Int16* pInt = new types::Int16(iRows,iCols);
-             pInt->set(psData);
-             return pInt;
+             if (_piAddress == NULL)
+             {
 -                sciErr = createNamedMatrixOfInteger16(pvApiCtx, _pstVarname, piDims[0], piDims[1], psData);
++                sciErr = createNamedMatrixOfInteger16(pvCtx, _pstVarname, piDims[0], piDims[1], psData);
+             }
+             else
+             {
 -                sciErr = createMatrixOfInteger16InNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], psData);
++                sciErr = createMatrixOfInteger16InNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], psData);
+             }
          }
-     case sci_uint16 :
+         break;
+         case SCI_UINT16:
          {
-             unsigned short* pusData   = NULL;
-             pusData = (unsigned short*)MALLOC(sizeof(unsigned short) * iRows * iCols);
-             iRet = readUnsignedInteger16Matrix(_iDatasetId, iRows, iCols, pusData);
-             if(iRet)
+             unsigned short *pusData = NULL;
+             pusData = (unsigned short *)MALLOC(sizeof(unsigned short) * iSize);
+             iRet = readUnsignedInteger16Matrix(_iDatasetId, pusData);
+             if (iRet)
              {
-                 return NULL;
+                 return false;
              }
  
-             types::UInt16* pInt = new types::UInt16(iRows,iCols);;
-             pInt->set(pusData);
-             return pInt;
+             if (_piAddress == NULL)
+             {
 -                sciErr = createNamedMatrixOfUnsignedInteger16(pvApiCtx, _pstVarname, piDims[0], piDims[1], pusData);
++                sciErr = createNamedMatrixOfUnsignedInteger16(pvCtx, _pstVarname, piDims[0], piDims[1], pusData);
+             }
+             else
+             {
 -                sciErr = createMatrixOfUnsignedInteger16InNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], pusData);
++                sciErr = createMatrixOfUnsignedInteger16InNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], pusData);
+             }
          }
-     case sci_int32 :
+         break;
+         case SCI_INT32:
          {
-             int* piData       = NULL;
-             piData = (int*)MALLOC(sizeof(int) * iRows * iCols);
-             iRet = readInteger32Matrix(_iDatasetId, iRows, iCols, piData);
-             if(iRet)
+             int *piData = NULL;
+             piData = (int *)MALLOC(sizeof(int) * iSize);
+             iRet = readInteger32Matrix(_iDatasetId, piData);
+             if (iRet)
              {
-                 return NULL;
+                 return false;
              }
  
-             types::Int32* pInt = new types::Int32(iRows,iCols);;
-             pInt->set(piData);
-             return pInt;
+             if (_piAddress == NULL)
+             {
 -                sciErr = createNamedMatrixOfInteger32(pvApiCtx, _pstVarname, piDims[0], piDims[1], piData);
++                sciErr = createNamedMatrixOfInteger32(pvCtx, _pstVarname, piDims[0], piDims[1], piData);
+             }
+             else
+             {
 -                sciErr = createMatrixOfInteger32InNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], piData);
++                sciErr = createMatrixOfInteger32InNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], piData);
+             }
          }
-     case sci_uint32 :
+         break;
+         case SCI_UINT32:
          {
-             unsigned int* puiData     = NULL;
-             puiData = (unsigned int*)MALLOC(sizeof(unsigned int) * iRows * iCols);
-             iRet = readUnsignedInteger32Matrix(_iDatasetId, iRows, iCols, puiData);
-             if(iRet)
+             unsigned int *puiData = NULL;
+             puiData = (unsigned int *)MALLOC(sizeof(unsigned int) * iSize);
+             iRet = readUnsignedInteger32Matrix(_iDatasetId, puiData);
+             if (iRet)
              {
-                 return NULL;
+                 return false;
              }
  
-             types::UInt32* pInt = new types::UInt32(iRows,iCols);
-             pInt->set(puiData);
-             return pInt;
+             if (_piAddress == NULL)
+             {
 -                sciErr = createNamedMatrixOfUnsignedInteger32(pvApiCtx, _pstVarname, piDims[0], piDims[1], puiData);
++                sciErr = createNamedMatrixOfUnsignedInteger32(pvCtx, _pstVarname, piDims[0], piDims[1], puiData);
+             }
+             else
+             {
 -                sciErr = createMatrixOfUnsignedInteger32InNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], puiData);
++                sciErr = createMatrixOfUnsignedInteger32InNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], puiData);
+             }
          }
-     case sci_int64 :
+         break;
+         case SCI_INT64:
          {
-             long long* pllData        = NULL;
-             pllData = (long long*)MALLOC(sizeof(long long) * iRows * iCols);
-             iRet = readInteger64Matrix(_iDatasetId, iRows, iCols, pllData);
-             if(iRet)
+ #ifdef __SCILAB_INT64__
+             long long *pllData = NULL;
+             pllData = (long long *)MALLOC(sizeof(long long) * iSize);
+             iRet = readInteger64Matrix(_iDatasetId, pllData);
+             if (iRet)
              {
-                 return NULL;
+                 return false;
              }
  
-             types::Int64* pInt = new types::Int64(iRows,iCols);
-             pInt->set(pllData);
-             return pInt;
+             if (_piAddress == NULL)
+             {
 -                sciErr = createNamedMatrixOfInteger64(_pstVarname, piDims[0], piDims[1], pllData);
++                sciErr = createNamedMatrixOfInteger64(pvCtx, _pstVarname, piDims[0], piDims[1], pllData);
+             }
+             else
+             {
 -                sciErr = createMatrixOfInteger64InNamedList(_pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], pllData);
++                sciErr = createMatrixOfInteger64InNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], pllData);
+             }
+ #else
+             return false;
+ #endif
          }
          break;
-     case sci_uint64 :
+         case SCI_UINT64:
          {
-             unsigned long long* pullData      = NULL;
-             pullData = (unsigned long long*)MALLOC(sizeof(unsigned long long) * iRows * iCols);
-             iRet = readUnsignedInteger64Matrix(_iDatasetId, iRows, iCols, pullData);
-             if(iRet)
+ #ifdef __SCILAB_INT64__
+             unsigned long long *pullData = NULL;
+             pullData = (unsigned long long *)MALLOC(sizeof(unsigned long long) * iSize);
+             iRet = readUnsignedInteger64Matrix(_iDatasetId, pullData);
+             if (iRet)
              {
-                 return NULL;
+                 return false;
              }
  
-             types::UInt64* pInt = new types::UInt64(iRows,iCols);
-             pInt->set(pullData);
-             return pInt;
+             if (_piAddress == NULL)
+             {
 -                sciErr = createNamedMatrixOfUnsignedInteger64(_pstVarname, piDims[0], piDims[1], pullData);
++                sciErr = createNamedMatrixOfUnsignedInteger64(pvCtx, _pstVarname, piDims[0], piDims[1], pullData);
+             }
+             else
+             {
 -                sciErr = createMatrixOfUnsignedInteger64InNamedList(_pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], pullData);
++                sciErr = createMatrixOfUnsignedInteger64InNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], pullData);
+             }
+ #else
+             return false;
+ #endif
          }
          break;
-     default :
-         return NULL;
+         default:
+             return false;
      }
  
-     return NULL;
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return false;
+     }
+     return true;
  }
  
- static types::InternalType* import_boolean(int _iDatasetId)
 -static bool import_boolean(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
++static bool import_boolean(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
  {
-     int iRet        = 0;
-     int* piData           = NULL;
-     int       iRows       = 0;
-     int iCols       = 0;
+     int iRet = 0;
+     int *piData = NULL;
+     int iDims = 0;
+     int* piDims = NULL;
+     int iComplex = 0;
+     int iSize = 0;
+     SciErr sciErr;
  
-     iRet = getDatasetDims(_iDatasetId, &iRows, &iCols);
-     if(iRet)
+     iRet = getDatasetInfo(_iDatasetId, &iComplex, &iDims, NULL);
+     if (iRet < 0)
      {
-         return NULL;
+         return false;
      }
  
-     if(iRows * iCols != 0)
+     piDims = (int*)MALLOC(sizeof(int) * iDims);
+     iSize = getDatasetInfo(_iDatasetId, &iComplex, &iDims, piDims);
+     if (iSize != 0)
      {
-         piData  = (int *) MALLOC(iRows * iCols * sizeof(int));
-         iRet    = readBooleanMatrix(_iDatasetId, iRows, iCols, piData);
-         if(iRet)
+         piData = (int *)MALLOC(iSize * sizeof(int));
+         iRet = readBooleanMatrix(_iDatasetId, piData);
+         if (iRet)
          {
-             return NULL;
+             return false;
          }
      }
  
-     types::Bool* pBool = new types::Bool(iRows,iCols);
-     pBool->set(piData);
+     if (_piAddress == NULL)
+     {
 -        sciErr = createNamedMatrixOfBoolean(pvApiCtx, _pstVarname, piDims[0], piDims[1], piData);
++        sciErr = createNamedMatrixOfBoolean(pvCtx, _pstVarname, piDims[0], piDims[1], piData);
+     }
+     else                        //if not null this variable is in a list
+     {
 -        sciErr = createMatrixOfBooleanInNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], piData);
++        sciErr = createMatrixOfBooleanInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], piData);
+     }
  
-     if(piData)
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return false;
+     }
+     if (piData)
      {
          FREE(piData);
      }
  
-     return pBool;
+     if (iRet)
+     {
+         return false;
+     }
+     return true;
  }
  
- static types::InternalType* import_poly(int _iDatasetId)
 -static bool import_poly(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
++static bool import_poly(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
  {
-     int iRet                = 0;
-     int i                   = 0;
-     int       iRows               = 0;
-     int iCols               = 0;
-     int iComplex            = 0;
-     char pstVarName[64]           = {0};
-     wchar_t* pwstVarName    = NULL;
-     double **pdblReal       = NULL;
-     double **pdblImg        = NULL;
-     int *piNbCoef           = NULL;
+     int iRet = 0;
+     int iComplex = 0;
+     char pstVarName[64] = { 0 };
+     double **pdblReal = NULL;
+     double **pdblImg = NULL;
+     int *piNbCoef = NULL;
+     int iDims = 0;
+     int* piDims = NULL;
+     int iSize = 0;
+     SciErr sciErr;
  
-     iRet = getDatasetDims(_iDatasetId, &iRows, &iCols);
-     if(iRet)
+     iRet = getDatasetInfo(_iDatasetId, &iComplex, &iDims, NULL);
+     if (iRet < 0)
      {
-         return NULL;
+         return false;
      }
  
-     iComplex = isComplexData(_iDatasetId);
+     piDims = (int*)MALLOC(sizeof(int) * iDims);
+     iSize = getDatasetInfo(_iDatasetId, &iComplex, &iDims, piDims);
  
-     if(iComplex)
+     if (iComplex)
      {
-         piNbCoef    = (int*)MALLOC(iRows * iCols * sizeof(int));
-         pdblReal    = (double**)MALLOC(iRows * iCols * sizeof(double*));
-         pdblImg     = (double**)MALLOC(iRows * iCols * sizeof(double*));
-         iRet        = readPolyComplexMatrix(_iDatasetId, pstVarName, iRows, iCols, piNbCoef, pdblReal, pdblImg);
+         piNbCoef = (int *)MALLOC(iSize * sizeof(int));
+         pdblReal = (double **)MALLOC(iSize * sizeof(double *));
+         pdblImg = (double **)MALLOC(iSize * sizeof(double *));
+         iRet = readPolyComplexMatrix(_iDatasetId, pstVarName, iDims, piDims, piNbCoef, pdblReal, pdblImg);
      }
      else
      {
-         piNbCoef    = (int*)MALLOC(iRows * iCols * sizeof(int));
-         pdblReal    = (double**)MALLOC(iRows * iCols * sizeof(double*));
-         iRet          = readPolyMatrix(_iDatasetId, pstVarName, iRows, iCols, piNbCoef, pdblReal);
+         piNbCoef = (int *)MALLOC(iSize * sizeof(int));
+         pdblReal = (double **)MALLOC(iSize * sizeof(double *));
+         iRet = readPolyMatrix(_iDatasetId, pstVarName, iDims, piDims, piNbCoef, pdblReal);
      }
  
-     if(iRet)
+     if (iRet)
      {
-         return NULL;
+         return false;
      }
  
-     pwstVarName = to_wide_string(pstVarName);
-     types::Polynom* pPoly = new types::Polynom(pwstVarName,iRows,iCols,piNbCoef);
-     for(int i = 0 ; i < iRows * iCols ; i++)
+     if (_piAddress == NULL)
      {
-         types::Double* pCoef = new types::Double(1, piNbCoef[i],  iComplex == 0 ? false : true);
-         pCoef->set(pdblReal[i]);
-         if(iComplex)
+         if (iComplex)
          {
-             pCoef->setImg(pdblImg[i]);
 -            sciErr = createNamedComplexMatrixOfPoly(pvApiCtx, _pstVarname, pstVarName, piDims[0], piDims[1], piNbCoef, pdblReal, pdblImg);
++            sciErr = createNamedComplexMatrixOfPoly(pvCtx, _pstVarname, pstVarName, piDims[0], piDims[1], piNbCoef, pdblReal, pdblImg);
+         }
+         else
+         {
 -            sciErr = createNamedMatrixOfPoly(pvApiCtx, _pstVarname, pstVarName, piDims[0], piDims[1], piNbCoef, pdblReal);
++            sciErr = createNamedMatrixOfPoly(pvCtx, _pstVarname, pstVarName, piDims[0], piDims[1], piNbCoef, pdblReal);
          }
-         pPoly->setCoef(i, pCoef);
      }
-     for(i = 0 ; i < iRows * iCols ; i++)
+     else                        //if not null this variable is in a list
      {
-         FREE(pdblReal[i]);
-         if(iComplex)
+         if (iComplex)
          {
-             FREE(pdblImg[i]);
+             sciErr =
 -                createComplexMatrixOfPolyInNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, pstVarName, piDims[0], piDims[1], piNbCoef, pdblReal,
++                createComplexMatrixOfPolyInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, pstVarName, piDims[0], piDims[1], piNbCoef, pdblReal,
+                         pdblImg);
+         }
+         else
+         {
 -            sciErr = createMatrixOfPolyInNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, pstVarName, piDims[0], piDims[1], piNbCoef, pdblReal);
++            sciErr = createMatrixOfPolyInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, pstVarName, piDims[0], piDims[1], piNbCoef, pdblReal);
          }
      }
  
-     FREE(pdblReal);
-     if(iComplex)
+     if (sciErr.iErr)
      {
-         FREE(pdblImg);
+         printError(&sciErr, 0);
+         return false;
      }
  
-     FREE(piNbCoef);
+     for (int i = 0; i < iSize; i++)
+     {
+         FREE(pdblReal[i]);
+     }
+     FREE(pdblReal);
  
-     if(iRet)
+     if (iComplex)
      {
-         return NULL;
+         for (int i = 0; i < iSize; i++)
+         {
+             FREE(pdblImg[i]);
+         }
+         FREE(pdblImg);
      }
  
-     return pPoly;
+     FREE(piNbCoef);
+     return true;
  }
- /*
- static types::InternalType* import_sparse(void* pvApiCtx, int _iDatasetId)
 -static bool import_sparse(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
++static bool import_sparse(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
  {
-     int iRet                                          = 0;
-     int       iRows                                           = 0;
-     int iCols                                         = 0;
-     int iComplex                              = 0;
-     double *pdblReal          = NULL;
-     double *pdblImg                   = NULL;
-     int iNbItem                                       = 0;
-     int* piNbItemRow          = NULL;
-     int* piColPos                             = NULL;
+     int iRet = 0;
+     int iRows = 0;
+     int iCols = 0;
+     int iComplex = 0;
+     double *pdblReal = NULL;
+     double *pdblImg = NULL;
+     int iNbItem = 0;
+     int *piNbItemRow = NULL;
+     int *piColPos = NULL;
      SciErr sciErr;
  
-     iRet                                                              = getSparseDimension(_iDatasetId, &iRows, &iCols, &iNbItem);
-     if(iRet)
+     iRet = getSparseDimension(_iDatasetId, &iRows, &iCols, &iNbItem);
+     if (iRet)
      {
          return false;
      }
          return false;
      }
  
-     if(_piAddress == NULL)
+     if (_piAddress == NULL)
      {
-         if(iComplex)
+         if (iComplex)
          {
-             sciErr = createNamedComplexSparseMatrix(pvApiCtx, iRows, iCols, iNbItem, piNbItemRow, piColPos, pdblReal, pdblImg);
 -            sciErr = createNamedComplexSparseMatrix(pvApiCtx, _pstVarname, iRows, iCols, iNbItem, piNbItemRow, piColPos, pdblReal, pdblImg);
++            sciErr = createNamedComplexSparseMatrix(pvCtx, _pstVarname, iRows, iCols, iNbItem, piNbItemRow, piColPos, pdblReal, pdblImg);
          }
          else
          {
-             sciErr = createNamedSparseMatrix(pvApiCtx, iRows, iCols, iNbItem, piNbItemRow, piColPos, pdblReal);
 -            sciErr = createNamedSparseMatrix(pvApiCtx, _pstVarname, iRows, iCols, iNbItem, piNbItemRow, piColPos, pdblReal);
++            sciErr = createNamedSparseMatrix(pvCtx, _pstVarname, iRows, iCols, iNbItem, piNbItemRow, piColPos, pdblReal);
          }
      }
-     else //if not null this variable is in a list
+     else                        //if not null this variable is in a list
      {
-         if(iComplex)
+         if (iComplex)
          {
-             sciErr = createComplexSparseMatrixInNamedList(pvApiCtx, iRows, iCols, iNbItem, piNbItemRow, piColPos, pdblReal, pdblImg);
+             sciErr =
 -                createComplexSparseMatrixInNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, iNbItem, piNbItemRow, piColPos,
++                createComplexSparseMatrixInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, iNbItem, piNbItemRow, piColPos,
+                         pdblReal, pdblImg);
          }
          else
          {
-             sciErr = createSparseMatrixInNamedList(pvApiCtx, iRows, iCols, iNbItem, piNbItemRow, piColPos, pdblReal);
+             sciErr =
 -                createSparseMatrixInNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, iNbItem, piNbItemRow, piColPos, pdblReal);
++                createSparseMatrixInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, iNbItem, piNbItemRow, piColPos, pdblReal);
          }
      }
  
      return true;
  }
  
- static types::InternalType* import_boolean_sparse(void* pvApiCtx, int _iDatasetId)
 -static bool import_boolean_sparse(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
++static bool import_boolean_sparse(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
  {
-     int iRet                                          = 0;
-     int       iRows                                           = 0;
-     int iCols                                         = 0;
-     int     types::Polynom* pPoly = NULL;iNbItem                                      = 0;
-     int* piNbItemRow          = NULL;
-     int* piColPos                             = NULL;
+     int iRet = 0;
+     int iRows = 0;
+     int iCols = 0;
+     int iNbItem = 0;
+     int *piNbItemRow = NULL;
+     int *piColPos = NULL;
      SciErr sciErr;
  
-     iRet                                                              = getSparseDimension(_iDatasetId, &iRows, &iCols, &iNbItem);
-     if(iRet)
+     iRet = getSparseDimension(_iDatasetId, &iRows, &iCols, &iNbItem);
+     if (iRet)
      {
          return false;
      }
          return false;
      }
  
-     if(_piAddress == NULL)
+     if (_piAddress == NULL)
      {
-         sciErr                                        = createNamedBooleanSparseMatrix(pvApiCtx, iRows, iCols, iNbItem, piNbItemRow, piColPos);
 -        sciErr = createNamedBooleanSparseMatrix(pvApiCtx, _pstVarname, iRows, iCols, iNbItem, piNbItemRow, piColPos);
++        sciErr = createNamedBooleanSparseMatrix(pvCtx, _pstVarname, iRows, iCols, iNbItem, piNbItemRow, piColPos);
      }
-     else //if not null this variable is in a list
+     else                        //if not null this variable is in a list
      {
-         sciErr                                        = createBooleanSparseMatrixInNamedList(pvApiCtx, iRows, iCols, iNbItem, piNbItemRow, piColPos);
 -        sciErr = createBooleanSparseMatrixInNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, iNbItem, piNbItemRow, piColPos);
++        sciErr = createBooleanSparseMatrixInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, iNbItem, piNbItemRow, piColPos);
      }
  
-     if(sciErr.iErr)
+     if (sciErr.iErr)
      {
          printError(&sciErr, 0);
          return false;
  
      return true;
  }
- */
- static types::InternalType* import_list(int _iDatasetId, int _iVarType)
 -static bool import_list(int _iDatasetId, int _iVarType, int _iItemPos, int *_piAddress, char *_pstVarname)
++static bool import_list(int* pvCtx, int _iDatasetId, int _iVarType, int _iItemPos, int *_piAddress, char *_pstVarname)
  {
-     int iRet                = 0;
-     int i                   = 0;
-     int       iItems              = 0;
-     hobj_ref_t* piItemRef   = NULL;
+     int iRet = 0;
+     int i = 0;
+     int iItems = 0;
+     int *piListAddr = NULL;
+     hobj_ref_t *piItemRef = NULL;
+     SciErr sciErr;
  
      iRet = getListDims(_iDatasetId, &iItems);
-     if(iRet)
+     if (iRet)
      {
-         return NULL;
+         return false;
      }
  
-     if(iItems == 0)
-     {//special case for empty list
+     if (iItems == 0)
+     {
+         //special case for empty list
      }
      else
      {
          }
      }
  
-     types::List* pList  = NULL;
-     switch(_iVarType)
-     {
-     case sci_list :
+     if (_piAddress == 0)
      {
-         pList = new types::List();
-         break;
+         switch (_iVarType)
+         {
+             case sci_list:
 -                sciErr = createNamedList(pvApiCtx, _pstVarname, iItems, &piListAddr);
++                sciErr = createNamedList(pvCtx, _pstVarname, iItems, &piListAddr);
+                 break;
+             case sci_tlist:
 -                sciErr = createNamedTList(pvApiCtx, _pstVarname, iItems, &piListAddr);
++                sciErr = createNamedTList(pvCtx, _pstVarname, iItems, &piListAddr);
+                 break;
+             case sci_mlist:
 -                sciErr = createNamedMList(pvApiCtx, _pstVarname, iItems, &piListAddr);
++                sciErr = createNamedMList(pvCtx, _pstVarname, iItems, &piListAddr);
+                 break;
+             default:
+                 return false;
+         }
      }
-     case sci_tlist :
+     else                        //if not null this variable is in a list
      {
-         pList = new types::TList();
-         break;
+         switch (_iVarType)
+         {
+             case sci_list:
 -                sciErr = createListInNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, iItems, &piListAddr);
++                sciErr = createListInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iItems, &piListAddr);
+                 break;
+             case sci_tlist:
 -                sciErr = createTListInNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, iItems, &piListAddr);
++                sciErr = createTListInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iItems, &piListAddr);
+                 break;
+             case sci_mlist:
 -                sciErr = createMListInNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, iItems, &piListAddr);
++                sciErr = createMListInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iItems, &piListAddr);
+                 break;
+             default:
+                 return false;
+         }
      }
-     case sci_mlist :
+     if (sciErr.iErr)
      {
-         pList = new types::MList();
-         break;
-     }
-     default :
-         return NULL;
+         printError(&sciErr, 0);
+         return false;
      }
  
-     iTab++;
-     for(i = 0 ; i < iItems ; i++)
+     for (i = 0; i < iItems; i++)
      {
          int iItemDataset = 0;
          iRet = getListItemDataset(_iDatasetId, piItemRef, i, &iItemDataset);
-         if(iRet || iItemDataset == 0)
+         if (iRet || iItemDataset == 0)
          {
-             return NULL;
+             return false;
          }
  
-         types::InternalType* pItem = import_data(iItemDataset);
-         if(pItem == NULL)
 -        bool bRet = import_data(iItemDataset, i + 1, piListAddr, _pstVarname);
++        bool bRet = import_data(pvCtx, iItemDataset, i + 1, piListAddr, _pstVarname);
+         if (bRet == false)
          {
-             return NULL;
+             return false;
          }
-         pList->append(pItem);
      }
-     iTab--;
  
      iRet = deleteListItemReferences(_iDatasetId, piItemRef);
-     if(iRet)
+     if (iRet)
      {
-         return NULL;
+         return false;
      }
  
-     return pList;
- }
- void print_tree(char* _pstMsg)
- {
- #ifdef PRINT_DEBUG
-     for(int i = 0 ; i < iTab ; i++)
-     {
-         printf("\t");
-     }
-     printf("%s\n", _pstMsg);
- #endif
+     return true;
  }
  
  /*--------------------------------------------------------------------------*/
@@@ -25,7 -25,7 +25,7 @@@ extern "C
  }
  
  
- int sci_is_hdf5_file(char *fname, void *pvApiCtx)
 -int sci_is_hdf5_file(char *fname, unsigned long fname_len)
++int sci_is_hdf5_file(char *fname, int* pvApiCtx)
  {
      SciErr sciErr;
      int *piAddr     = NULL;
@@@ -54,7 -56,7 +56,7 @@@ static bool read_undefined(int _iDatase
  
  static void generateInfo(VarInfo* _pInfo, const char* _pstType);
  
- int sci_listvar_in_hdf5(char *fname, void *pvApiCtx)
 -int sci_listvar_in_hdf5(char *fname, unsigned long fname_len)
++int sci_listvar_in_hdf5(char *fname, int* pvApiCtx)
  {
      SciErr sciErr;
      int *piAddr     = NULL;
      FREE(pstFileName);
      FREE(pstFile);
  
+     //manage version information
+     int iVersion = getSODFormatAttribute(iFile);
+     if(iVersion != SOD_FILE_VERSION)
+     {
+         if (iVersion > SOD_FILE_VERSION)
+         {//can't read file with version newer that me !
+             Scierror(999, _("%s: Wrong SOD file format version. Max Expected: %d Found: %d\n"), fname, SOD_FILE_VERSION, iVersion);
+             return 1;
+         }
+         else
+         {//call older import functions and exit or ... EXIT !
+             if(iVersion == 1 || iVersion == -1)
+             {
+                 //sciprint("old sci_listvar_in_hdf5_v1\n");
 -                return sci_listvar_in_hdf5_v1(fname, fname_len);
++                return sci_listvar_in_hdf5_v1(fname, pvApiCtx);
+             }
+         }
+     }
      iNbItem = getVariableNames(iFile, NULL);
      if (iNbItem != 0)
      {
   Interface description. In this file, we define the list of the function which
   will be available into Scilab and the link to the "native" function.
  
 - gatewayId is the position in the hashtable 'Interfaces' defined in the
 - file SCI/modules/core/src/c/callinterf.h
 -
 - primitiveId is the position in the hashtable '<module>Table Tab[]' defined
 - in the file modules/<module>/sci_gateway/c/gw_<module>.c
 -
 - primitiveName is the name of the Scilab function
 -
   Don't touch if you do not know what you are doing
 -
  -->
 -<PRIMITIVE gatewayId="62" primitiveId="1" primitiveName="export_to_hdf5" />
 -<PRIMITIVE gatewayId="62" primitiveId="2" primitiveName="import_from_hdf5" />
 -<PRIMITIVE gatewayId="62" primitiveId="3" primitiveName="listvar_in_hdf5" />
 -<PRIMITIVE gatewayId="62" primitiveId="4" primitiveName="is_hdf5_file" />
 -
 -</GATEWAY>
 +<module name="hdf5">
-     <gateway name="sci_export_to_hdf5"      function="export_to_hdf5"   type="1" />
-     <gateway name="sci_import_from_hdf5"    function="import_from_hdf5" type="1" />
-     <gateway name="sci_listvar_in_hdf5"     function="listvar_in_hdf5"  type="1" />
-     <gateway name="sci_is_hdf5_file"        function="is_hdf5_file"     type="1" />
++    <gateway name="sci_export_to_hdf5"      function="export_to_hdf5"   type="0" />
++    <gateway name="sci_import_from_hdf5"    function="import_from_hdf5" type="0" />
++    <gateway name="sci_listvar_in_hdf5"     function="listvar_in_hdf5"  type="0" />
++    <gateway name="sci_is_hdf5_file"        function="is_hdf5_file"     type="0" />
 +</module>
@@@ -5,8 -5,8 +5,5 @@@ EXPORT
  ;--------------------------
  ; core
  ;--------------------------
- getScilabMode
  callFunctionFromGateway
--com_
- vstk_
- freeArrayOfString
+ freeArrayOfString
 -oGetDoubleComplexFromPointer
 -vGetPointerFromDoubleComplex
index 0000000,cd7e942..d06a29d
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,298 +1,296 @@@
+ /*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2010 - DIGITEO - Allan CORNET
+ *  Copyright (C) 2012 - Scilab Enterprises - 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
+ *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+ /*--------------------------------------------------------------------------*/
+ #include <hdf5.h>
+ #include <string.h>
+ #include "h5_fileManagement.h"
+ #include "FileExist.h"
+ #include "deleteafile.h"
+ #include "isdir.h"
+ #include "splitpath.h"
+ #include "scicurdir.h"
+ #include "MALLOC.h"
 -#ifdef _MSC_VER
 -#include "strdup_windows.h"
 -#endif
++#include "os_strdup.h"
+ /*--------------------------------------------------------------------------*/
+ static char *getPathFilename(char *fullfilename);
+ static char *getFilenameWithExtension(char *fullfilename);
+ /*--------------------------------------------------------------------------*/
+ int createHDF5File(char *name)
+ {
+     hid_t       file;
+     hid_t fapl = H5Pcreate(H5P_FILE_ACCESS);
+     char *pathdest = getPathFilename(name);
+     char *currentpath = NULL;
+     char *filename = getFilenameWithExtension(name);
+     int ierr = 0;
+     //H5Pset_fclose_degree(fapl, H5F_CLOSE_STRONG);
+     /* TO DO : remove when HDF5 will be fixed ... */
+     /* HDF5 does not manage no ANSI characters */
+     /* UGLY workaround :( */
+     /* We split path, move in this path, open file */
+     /* and return in previous place */
+     /* see BUG 6440 */
+     currentpath = scigetcwd(&ierr);
+     //prevent error msg to change directory to ""
+     if (strcmp(pathdest, "") != 0)
+     {
+         scichdir(pathdest);
+     }
+     FREE(pathdest);
+     /*bug 5629 : to prevent replace directory by file*/
+     if (isdir(filename))
+     {
+         FREE(filename);
+         FREE(currentpath);
+         return -2;
+     }
+     if (FileExist(filename))
+     {
+         deleteafile(filename);
+     }
+     /*
+     * Create a new file using the default properties.
+     */
+     file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
+     scichdir(currentpath);
+     FREE(currentpath);
+     FREE(filename);
+     return file;
+ }
+ /*--------------------------------------------------------------------------*/
+ int openHDF5File(char *name, int _iAppendMode)
+ {
+     hid_t           file;
+     char *pathdest = getPathFilename(name);
+     char *currentpath = NULL;
+     char *filename = getFilenameWithExtension(name);
+     int ierr = 0;
+     void *oldclientdata = NULL;
+     /* Used to avoid stack trace to be displayed */
+     H5E_auto2_t oldfunc;
+     /* TO DO : remove when HDF5 will be fixed ... */
+     /* HDF5 does not manage no ANSI characters */
+     /* UGLY workaround :( */
+     /* We split path, move in this path, open file */
+     /* and return in previous place */
+     /* see BUG 6440 */
+     currentpath = scigetcwd(&ierr);
+     //prevent error msg to change directory to ""
+     if (strcmp(pathdest, "") != 0)
+     {
+         scichdir(pathdest);
+     }
+     /* Save old error handler */
+     H5Eget_auto2(H5E_DEFAULT, &oldfunc, &oldclientdata);
+     /* Turn off error handling */
+     H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
+     if(_iAppendMode == 0)
+     {//read only
+         file = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT);
+     }
+     else
+     {//read write to append
+         file = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT);
+     }
+     /* The following test will display the backtrace in case of error */
+     /* Deactivated because displayed each time we call 'load' to open a non-HDF5 file */
+     /*if (file < 0)
+     {
+         H5Eprint(stderr);
+         }*/
+     /* Restore previous error handler */
+     H5Eset_auto2(H5E_DEFAULT, oldfunc, oldclientdata);
+     scichdir(currentpath);
+     if (currentpath)
+     {
+         FREE(currentpath);
+         currentpath = NULL;
+     }
+     if (filename)
+     {
+         FREE(filename);
+         filename = NULL;
+     }
+     if (pathdest)
+     {
+         FREE(pathdest);
+         pathdest = NULL;
+     }
+     return file;
+ }
+ /*--------------------------------------------------------------------------*/
+ int isHDF5File(char* _pstFilename)
+ {
+     int iRet = 0;
+     char *pathdest = getPathFilename(_pstFilename);
+     char *currentpath = NULL;
+     char *filename = getFilenameWithExtension(_pstFilename);
+     int ierr = 0;
+     /* TO DO : remove when HDF5 will be fixed ... */
+     /* HDF5 does not manage no ANSI characters */
+     /* UGLY workaround :( */
+     /* We split path, move in this path, open file */
+     /* and return in previous place */
+     /* see BUG 6440 */
+     currentpath = scigetcwd(&ierr);
+     {
+         //prevent error msg to change directory to ""
+         if (strcmp(pathdest, "") != 0)
+         {
+             scichdir(pathdest);
+         }
+         FREE(pathdest);
+         iRet = H5Fis_hdf5(filename);
+         FREE(filename);
+     }
+     scichdir(currentpath);
+     FREE(currentpath);
+     return iRet > 0 ? 1 : 0;
+ }
+ void closeHDF5File(int file)
+ {
+     herr_t status                                     = 0;
+     //        H5Fflush(file, H5F_SCOPE_GLOBAL);
+     status = H5Fclose(file);
+     if (status < 0)
+     {
+         fprintf(stderr, "%s", "failed to close file");
+     }
+ }
+ /*--------------------------------------------------------------------------*/
+ static char *getPathFilename(char *fullfilename)
+ {
+     char *path = NULL;
+     if (fullfilename)
+     {
 -        char* drv  = strdup(fullfilename);
 -        char* dir  = strdup(fullfilename);
 -        char* name = strdup(fullfilename);
 -        char* ext  = strdup(fullfilename);
++        char* drv  = os_strdup(fullfilename);
++        char* dir  = os_strdup(fullfilename);
++        char* name = os_strdup(fullfilename);
++        char* ext  = os_strdup(fullfilename);
 -        path = strdup(fullfilename);
++        path = os_strdup(fullfilename);
+         if (drv && dir && name && ext && path)
+         {
+             splitpath(fullfilename, FALSE, drv, dir, name, ext);
+             if (strcmp(drv, "") == 0)
+             {
+                 strcpy(path, dir);
+             }
+             else
+             {
+                 strcpy(path, drv);
+                 strcat(path, dir);
+             }
+         }
+         if (drv)
+         {
+             FREE(drv);
+             drv = NULL;
+         }
+         if (dir)
+         {
+             FREE(dir);
+             dir = NULL;
+         }
+         if (name)
+         {
+             FREE(name);
+             name = NULL;
+         }
+         if (ext)
+         {
+             FREE(ext);
+             ext = NULL;
+         }
+     }
+     return path;
+ }
+ /*--------------------------------------------------------------------------*/
+ static char *getFilenameWithExtension(char *fullfilename)
+ {
+     char *filename = NULL;
+     if (fullfilename)
+     {
 -        char* drv  = strdup(fullfilename);
 -        char* dir  = strdup(fullfilename);
 -        char* name = strdup(fullfilename);
 -        char* ext  = strdup(fullfilename);
++        char* drv  = os_strdup(fullfilename);
++        char* dir  = os_strdup(fullfilename);
++        char* name = os_strdup(fullfilename);
++        char* ext  = os_strdup(fullfilename);
 -        filename = strdup(fullfilename);
++        filename = os_strdup(fullfilename);
+         if (drv && dir && name && ext && filename)
+         {
+             splitpath(fullfilename, FALSE, drv, dir, name, ext);
+             if (strcmp(ext, "") == 0)
+             {
+                 strcpy(filename, name);
+             }
+             else
+             {
+                 strcpy(filename, name);
+                 strcat(filename, ext);
+             }
+         }
+         if (drv)
+         {
+             FREE(drv);
+             drv = NULL;
+         }
+         if (dir)
+         {
+             FREE(dir);
+             dir = NULL;
+         }
+         if (name)
+         {
+             FREE(name);
+             name = NULL;
+         }
+         if (ext)
+         {
+             FREE(ext);
+             ext = NULL;
+         }
+     }
+     return filename;
+ }
+ /*--------------------------------------------------------------------------*/
index 0000000,b08bf4f..e500466
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,1079 +1,1080 @@@
+ /*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2012 - Scilab Enterprises - 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
+ *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+ #define H5_USE_16_API
+ #ifndef _MSC_VER
+ #include <sys/time.h>
+ #else
+ #include <windows.h>
+ //#include <winbase.h>
+ #endif
+ #include <string.h>
+ #include <hdf5.h>
+ #include <stdlib.h>
+ #include "MALLOC.h"
+ #include "sci_types.h"
+ #include "stack3.h"
+ #include "h5_attributeConstants.h"
+ #include "h5_readDataFromFile.h"
++#include "doublecomplex.h"
+ //#define TIME_DEBUG
+ static herr_t find_attr_by_name(hid_t loc_id, const char *name, void *data)
+ {
+     return !strcmp(name, (const char *)data);
+ }
+ /************************************************************
+ Operator function.  Prints the name and type of the object
+ being examined.
+ ************************************************************/
+ static herr_t op_func(hid_t loc_id, const char *name, void *operator_data)
+ {
+     H5G_stat_t statbuf;
+     herr_t status = 0;
+     int *pDataSetId = (int*)operator_data;
+     /*
+      * Get type of the object and return only datasetId
+      * through operator_data.
+      */
+     status = H5Gget_objinfo(loc_id, name, 0, &statbuf);
+     if (status < 0)
+     {
+         return -1;
+     }
+     switch (statbuf.type)
+     {
+         case H5G_GROUP:
+             break;
+         case H5G_DATASET:
+             *pDataSetId = H5Dopen(loc_id, name);
+             break;
+         case H5G_TYPE:
+             break;
+         default:
+             break;
+     }
+     return 0;
+ }
+ static int readIntAttribute(int _iDatasetId, const char *_pstName)
+ {
+     hid_t iAttributeId;
+     herr_t status;
+     int iVal = -1;
+     if (H5Aiterate(_iDatasetId, NULL, find_attr_by_name, (void *)_pstName))
+     {
+         iAttributeId = H5Aopen_name(_iDatasetId, _pstName);
+         if (iAttributeId < 0)
+         {
+             return -1;
+         }
+         status = H5Aread(iAttributeId, H5T_NATIVE_INT, &iVal);
+         if (status < 0)
+         {
+             return -1;
+         }
+         status = H5Aclose(iAttributeId);
+         if (status < 0)
+         {
+             return -1;
+         }
+     }
+     return iVal;
+ }
+ /*
+ ** WARNING : this function returns an allocated value that must be freed.
+ */
+ static char* readAttribute(int _iDatasetId, const char *_pstName)
+ {
+     hid_t iAttributeId;
+     hid_t iFileType, memtype, iSpace;
+     herr_t status;
+     hsize_t dims[1];
+     size_t iDim;
+     char *pstValue = NULL;
+     if (H5Aiterate(_iDatasetId, NULL, find_attr_by_name, (void *)_pstName))
+     {
+         iAttributeId = H5Aopen_name(_iDatasetId, _pstName);
+         if (iAttributeId < 0)
+         {
+             return NULL;
+         }
+         /*
+          * Get the datatype and its size.
+          */
+         iFileType = H5Aget_type(iAttributeId);
+         iDim = H5Tget_size(iFileType);
+         iDim++;                 /* Make room for null terminator */
+         /*
+          * Get dataspace and allocate memory for read buffer.  This is a
+          * two dimensional attribute so the dynamic allocation must be done
+          * in steps.
+          */
+         iSpace = H5Aget_space(iAttributeId);
+         if (iSpace < 0)
+         {
+             return NULL;
+         }
+         status = H5Sget_simple_extent_dims(iSpace, dims, NULL);
+         if (status < 0)
+         {
+             return NULL;
+         }
+         /*
+          * Allocate space for string data.
+          */
+         pstValue = (char *)MALLOC((size_t) ((dims[0] * iDim + 1) * sizeof(char)));
+         /*
+          * Create the memory datatype.
+          */
+         memtype = H5Tcopy(H5T_C_S1);
+         status = H5Tset_size(memtype, iDim);
+         if (status < 0)
+         {
+             return NULL;
+         }
+         /*
+          * Read the data.
+          */
+         status = H5Aread(iAttributeId, memtype, pstValue);
+         if (status < 0)
+         {
+             FREE(pstValue);
+             return NULL;
+         }
+         status = H5Tclose(memtype);
+         if (status < 0)
+         {
+             FREE(pstValue);
+             return NULL;
+         }
+         status = H5Sclose(iSpace);
+         if (status < 0)
+         {
+             FREE(pstValue);
+             return NULL;
+         }
+         status = H5Tclose(iFileType);
+         if (status < 0)
+         {
+             FREE(pstValue);
+             return NULL;
+         }
+         status = H5Aclose(iAttributeId);
+         if (status < 0)
+         {
+             FREE(pstValue);
+             return NULL;
+         }
+     }
+     return pstValue;
+ }
+ static int checkAttribute(int _iDatasetId, char *_pstAttribute, char *_pstValue)
+ {
+     int iRet = 0;
+     char *pstScilabClass = NULL;
+     //status = H5Giterate (_iFile, "/", NULL, op_func, &iDatasetId);
+     pstScilabClass = readAttribute(_iDatasetId, _pstAttribute);
+     if (pstScilabClass != NULL && strcmp(pstScilabClass, _pstValue) == 0)
+     {
+         iRet = 1;
+     }
+     if (pstScilabClass)
+     {
+         FREE(pstScilabClass);
+     }
+     return iRet;
+ }
+ /*
+ ** WARNING : this function returns an allocated value that must be freed.
+ */
+ char* getScilabVersionAttribute(int _iFile)
+ {
+     return readAttribute(_iFile, g_SCILAB_CLASS_SCI_VERSION);
+ }
+ int getSODFormatAttribute(int _iFile)
+ {
+     return readIntAttribute(_iFile, g_SCILAB_CLASS_SOD_VERSION);
+ }
+ int getDatasetInfo(int _iDatasetId, int* _iComplex, int* _iDims, int* _piDims)
+ {
+     int iSize = 1;
+     hid_t data_type;
+     H5T_class_t data_class;
+     hid_t space = H5Dget_space(_iDatasetId);
+     if(space < 0)
+     {
+         return -1;
+     }
+     data_type = H5Dget_type(_iDatasetId);
+     data_class = H5Tget_class(data_type);
+     if(data_class == H5T_COMPOUND) 
+     {
+         *_iComplex = 1;
+     }
+     else if(data_class == H5T_REFERENCE)
+     {
+         *_iComplex = isComplexData(_iDatasetId);
+     }
+     else
+     {
+         *_iComplex = 0;
+     }
+     *_iDims = H5Sget_simple_extent_ndims(space);
+     if(*_iDims < 0)
+     {
+         H5Sclose(space);
+         return -1;
+     }
+     if(_piDims != 0)
+     {
+         int i = 0;
+         hsize_t* dims = (hsize_t*)MALLOC(sizeof(hsize_t) * *_iDims);
+         if(H5Sget_simple_extent_dims(space, dims, NULL) < 0)
+         {
+             return -1;
+         }
+         //reverse dimensions
+         for(i = 0 ; i < *_iDims ; i++)
+         {//reverse dimensions to improve rendering in external tools
+             _piDims[i] = (int)dims[*_iDims - 1 - i];
+             iSize *= _piDims[i];
+         }
+     }
+     H5Sclose(space);
+     return iSize;
+ }
+ int getSparseDimension(int _iDatasetId, int *_piRows, int *_piCols, int *_piNbItem)
+ {
+     int iRet = 0;
+     int iDummy = 0;
+     //get number of item in the sparse matrix
+     getDatasetDims(_iDatasetId, _piRows, _piCols);
+     *_piNbItem = readIntAttribute(_iDatasetId, g_SCILAB_CLASS_ITEMS);
+     return iRet;
+ }
+ static int isEmptyDataset(int _iDatasetId)
+ {
+     return checkAttribute(_iDatasetId, (char *)g_SCILAB_CLASS_EMPTY, "true");
+ }
+ int isComplexData(int _iDatasetId)
+ {
+     return checkAttribute(_iDatasetId, (char *)g_SCILAB_CLASS_COMPLEX, "true");
+ }
+ int getDatasetPrecision(int _iDatasetId, int *_piPrec)
+ {
+     int iRet = 0;
+     char *pstScilabClass = readAttribute(_iDatasetId, g_SCILAB_CLASS_PREC);
+     if (pstScilabClass == NULL)
+     {
+         return -1;
+     }
+     else if (strcmp(pstScilabClass, "8") == 0)
+     {
+         *_piPrec = SCI_INT8;
+     }
+     else if (strcmp(pstScilabClass, "u8") == 0)
+     {
+         *_piPrec = SCI_UINT8;
+     }
+     else if (strcmp(pstScilabClass, "16") == 0)
+     {
+         *_piPrec = SCI_INT16;
+     }
+     else if (strcmp(pstScilabClass, "u16") == 0)
+     {
+         *_piPrec = SCI_UINT16;
+     }
+     else if (strcmp(pstScilabClass, "32") == 0)
+     {
+         *_piPrec = SCI_INT32;
+     }
+     else if (strcmp(pstScilabClass, "u32") == 0)
+     {
+         *_piPrec = SCI_UINT32;
+     }
+     else if (strcmp(pstScilabClass, "64") == 0)
+     {
+         *_piPrec = SCI_INT64;
+     }
+     else if (strcmp(pstScilabClass, "u64") == 0)
+     {
+         *_piPrec = SCI_UINT64;
+     }
+     else
+     {
+         iRet = 1;
+     }
+     FREE(pstScilabClass);
+     return iRet;
+ }
+ int getVariableNames(int _iFile, char **pstNameList)
+ {
+     hsize_t i = 0;
+     hsize_t iCount = 0;
+     herr_t status = 0;
+     int iNbItem = 0;
+     status = H5Gget_num_objs(_iFile, &iCount);
+     if (status != 0)
+     {
+         return 0;
+     }
+     for (i = 0; i < iCount; i++)
+     {
+         if (H5Gget_objtype_by_idx(_iFile, i) == H5G_DATASET)
+         {
+             if (pstNameList != NULL)
+             {
+                 int iLen = 0;
+                 iLen = (int)H5Gget_objname_by_idx(_iFile, i, NULL, iLen);
+                 pstNameList[iNbItem] = (char *)MALLOC(sizeof(char) * (iLen + 1));   //null terminated
+                 H5Gget_objname_by_idx(_iFile, i, pstNameList[iNbItem], iLen + 1);
+             }
+             iNbItem++;
+         }
+     }
+     return iNbItem;
+ }
+ int getDataSetIdFromName(int _iFile, char *_pstName)
+ {
+     return H5Dopen(_iFile, _pstName);
+ }
+ int getDataSetId(int _iFile)
+ {
+     herr_t status = 0;
+     int iDatasetId = 0;
+     /*
+      * Begin iteration.
+      */
+     status = H5Giterate(_iFile, "/", NULL, op_func, &iDatasetId);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return iDatasetId;
+ }
+ int getListDims(int _iDatasetId, int *_piItems)
+ {
+     /*
+      * Get dataspace and dimensions of the dataset. This is a
+      * two dimensional dataset.
+      */
+     if (isEmptyDataset(_iDatasetId))
+     {
+         *_piItems = 0;
+     }
+     else
+     {
+         *_piItems = readIntAttribute(_iDatasetId, g_SCILAB_CLASS_ITEMS);
+     }
+     return 0;
+ }
+ int getDatasetDims(int _iDatasetId, int *_piRows, int *_piCols)
+ {
+     /*
+      * Get dataspace and dimensions of the dataset. This is a
+      * two dimensional dataset.
+      */
+     if (isEmptyDataset(_iDatasetId))
+     {
+         *_piCols = 0;
+         *_piRows = 0;
+     }
+     else
+     {
+         *_piRows = readIntAttribute(_iDatasetId, g_SCILAB_CLASS_ROWS);
+         *_piCols = readIntAttribute(_iDatasetId, g_SCILAB_CLASS_COLS);
+     }
+     return 0;
+ }
+ int readDoubleMatrix(int _iDatasetId, double *_pdblData)
+ {
+     herr_t status;
+     //Read the data.
+     status = H5Dread(_iDatasetId, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, _pdblData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Dclose(_iDatasetId);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int readDoubleComplexMatrix(int _iDatasetId, double *_pdblReal, double *_pdblImg)
+ {
+     hid_t compoundId;
+     herr_t status;
+     int iDims = 0;
+     int* piDims = NULL;
+     int iComplex = 0;
+     int iSize = 1;
+     doublecomplex* pData = NULL;
+     int i = 0;
+     /*define compound dataset*/
+     compoundId = H5Tcreate(H5T_COMPOUND, sizeof(doublecomplex));
+     H5Tinsert(compoundId, "real", HOFFSET(doublecomplex, r), H5T_NATIVE_DOUBLE);
+     H5Tinsert(compoundId, "imag", HOFFSET(doublecomplex, i), H5T_NATIVE_DOUBLE);
+     //get dimension from dataset
+     getDatasetInfo(_iDatasetId, &iComplex, &iDims, NULL);
+     piDims = (int*)MALLOC(sizeof(int) * iDims);
+     iSize = getDatasetInfo(_iDatasetId, &iComplex, &iDims, piDims);
+     FREE(piDims);
+     //alloc temp array
+     pData = (doublecomplex*)MALLOC(sizeof(doublecomplex) * iSize);
+     //Read the data.
+     status = H5Dread(_iDatasetId, compoundId, H5S_ALL, H5S_ALL, H5P_DEFAULT, pData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     
+     vGetPointerFromDoubleComplex(pData, iSize, _pdblReal, _pdblImg);
+     FREE(pData);
+     status = H5Dclose(_iDatasetId);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int readEmptyMatrix(int _iDatasetId)
+ {
+     //close dataset
+     herr_t status;
+     status = H5Dclose(_iDatasetId);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int readBooleanMatrix(int _iDatasetId, int *_piData)
+ {
+     herr_t status = 0;
+     /*
+      * Read the data.
+      */
+     status = H5Dread(_iDatasetId, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, _piData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Dclose(_iDatasetId);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int readStringMatrix(int _iDatasetId, char **_pstData)
+ {
+     herr_t status;
+     hid_t typeId;
+     typeId = H5Tcopy(H5T_C_S1);
+     status = H5Tset_size(typeId, H5T_VARIABLE);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Read the data.
+     status = H5Dread(_iDatasetId, typeId, H5S_ALL, H5S_ALL, H5P_DEFAULT, _pstData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Tclose(typeId);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Dclose(_iDatasetId);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ static int readComplexPoly(int _iDatasetId, int *_piNbCoef, double **_pdblReal, double **_pdblImg)
+ {
+     int iComplex = 0;
+     int iSize = 0;
+     int iDims = 0;
+     //Get the datatype and its size.
+     iSize = getDatasetInfo(_iDatasetId, &iComplex, &iDims, _piNbCoef);
+     //Allocate space for string data.
+     *_pdblReal = (double *)MALLOC(*_piNbCoef * sizeof(double));
+     *_pdblImg = (double *)MALLOC(*_piNbCoef * sizeof(double));
+     //Read the data and return result.
+     return readDoubleComplexMatrix(_iDatasetId, *_pdblReal, *_pdblImg);
+ }
+ static int readPoly(int _iDatasetId, int *_piNbCoef, double **_pdblData)
+ {
+     int iComplex = 0;
+     int iSize = 0;
+     int iDims = 0;
+     //Get the datatype and its size.
+     iSize = getDatasetInfo(_iDatasetId, &iComplex, &iDims, _piNbCoef);
+     *_pdblData = (double *)MALLOC(*_piNbCoef * sizeof(double));
+     //Read the data and return result.
+     return readDoubleMatrix(_iDatasetId, *_pdblData);
+ }
+ int readCommonPolyMatrix(int _iDatasetId, char *_pstVarname, int _iComplex, int _iDims, int* _piDims, int *_piNbCoef, double **_pdblReal, double **_pdblImg)
+ {
+     int i = 0;
+     hid_t obj = 0;
+     char *pstVarName = 0;
+     hsize_t* piDims = NULL;
+     hobj_ref_t *pData = NULL;
+     herr_t status;
+     int iSize = 1;
+     for(i = 0 ; i < _iDims ; i++)
+     {
+         iSize *= _piDims[i];
+     }
+     pData = (hobj_ref_t *) MALLOC(iSize * sizeof(hobj_ref_t));
+     /*
+      * Read the data.
+      */
+     status = H5Dread(_iDatasetId, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, pData);
+     if (status < 0)
+     {
+         FREE(pData);
+         return -1;
+     }
+     for (i = 0; i < iSize; i++)
+     {
+         /*
+          * Open the referenced object, get its name and type.
+          */
+         obj = H5Rdereference(_iDatasetId, H5R_OBJECT, &pData[i]);
+         if (_iComplex)
+         {
+             status = readComplexPoly(obj, &_piNbCoef[i], &_pdblReal[i], &_pdblImg[i]);
+         }
+         else
+         {
+             status = readPoly(obj, &_piNbCoef[i], &_pdblReal[i]);
+         }
+         if (status < 0)
+         {
+             FREE(pData);
+             return -1;
+         }
+     }
+     pstVarName = readAttribute(_iDatasetId, g_SCILAB_CLASS_VARNAME);
+     strcpy(_pstVarname, pstVarName);
+     FREE(pstVarName);
+     status = H5Dclose(_iDatasetId);
+     if (status < 0)
+     {
+         FREE(pData);
+         return -1;
+     }
+     FREE(pData);
+     return 0;
+ }
+ int readPolyMatrix(int _iDatasetId, char *_pstVarname, int _iDims, int* _piDims, int *_piNbCoef, double **_pdblData)
+ {
+     return readCommonPolyMatrix(_iDatasetId, _pstVarname, 0, _iDims, _piDims, _piNbCoef, _pdblData, NULL);
+ }
+ int readPolyComplexMatrix(int _iDatasetId, char *_pstVarname, int _iDims, int* _piDims, int *_piNbCoef, double **_pdblReal, double **_pdblImg)
+ {
+     return readCommonPolyMatrix(_iDatasetId, _pstVarname, 1, _iDims, _piDims, _piNbCoef, _pdblReal, _pdblImg);
+ }
+ int readInteger8Matrix(int _iDatasetId, char *_pcData)
+ {
+     herr_t status = 0;
+     /*
+      * Read the data.
+      */
+     status = H5Dread(_iDatasetId, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, _pcData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Dclose(_iDatasetId);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int readInteger16Matrix(int _iDatasetId, short *_psData)
+ {
+     herr_t status = 0;
+     /*
+      * Read the data.
+      */
+     status = H5Dread(_iDatasetId, H5T_NATIVE_INT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, _psData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Dclose(_iDatasetId);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int readInteger32Matrix(int _iDatasetId, int *_piData)
+ {
+     herr_t status = 0;
+     /*
+      * Read the data.
+      */
+     status = H5Dread(_iDatasetId, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, _piData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Dclose(_iDatasetId);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int readInteger64Matrix(int _iDatasetId, long long *_pllData)
+ {
+     herr_t status = 0;
+     /*
+      * Read the data.
+      */
+     status = H5Dread(_iDatasetId, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, _pllData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Dclose(_iDatasetId);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int readUnsignedInteger8Matrix(int _iDatasetId, unsigned char *_pucData)
+ {
+     herr_t status = 0;
+     /*
+      * Read the data.
+      */
+     status = H5Dread(_iDatasetId, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, _pucData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Dclose(_iDatasetId);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int readUnsignedInteger16Matrix(int _iDatasetId, unsigned short *_pusData)
+ {
+     herr_t status = 0;
+     /*
+      * Read the data.
+      */
+     status = H5Dread(_iDatasetId, H5T_NATIVE_UINT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, _pusData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Dclose(_iDatasetId);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int readUnsignedInteger32Matrix(int _iDatasetId, unsigned int *_puiData)
+ {
+     herr_t status = 0;
+     /*
+      * Read the data.
+      */
+     status = H5Dread(_iDatasetId, H5T_NATIVE_UINT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, _puiData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Dclose(_iDatasetId);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int readUnsignedInteger64Matrix(int _iDatasetId, unsigned long long *_pullData)
+ {
+     herr_t status = 0;
+     /*
+      * Read the data.
+      */
+     status = H5Dread(_iDatasetId, H5T_NATIVE_UINT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, _pullData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Dclose(_iDatasetId);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int readCommonSparseComplexMatrix(int _iDatasetId, int _iComplex, int _iRows, int _iCols, int _iNbItem, int *_piNbItemRow, int *_piColPos, double *_pdblReal, double *_pdblImg)
+ {
+     hid_t obj = 0;
+     hobj_ref_t pRef[3] = {0};
+     herr_t status;
+     /*
+      * Read the data.
+      */
+     status = H5Dread(_iDatasetId, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, pRef);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //read Row data
+     obj = H5Rdereference(_iDatasetId, H5R_OBJECT, &pRef[0]);
+     status = readInteger32Matrix(obj, _piNbItemRow);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //read cols data
+     obj = H5Rdereference(_iDatasetId, H5R_OBJECT, &pRef[1]);
+     status = readInteger32Matrix(obj, _piColPos);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //read sparse data
+     obj = H5Rdereference(_iDatasetId, H5R_OBJECT, &pRef[2]);
+     if (_iComplex)
+     {
+         status = readDoubleComplexMatrix(obj, _pdblReal, _pdblImg);
+     }
+     else
+     {
+         status = readDoubleMatrix(obj, _pdblReal);
+     }
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int readSparseMatrix(int _iDatasetId, int _iRows, int _iCols, int _iNbItem, int *_piNbItemRow, int *_piColPos, double *_pdblReal)
+ {
+     return readCommonSparseComplexMatrix(_iDatasetId, 0, _iRows, _iCols, _iNbItem, _piNbItemRow, _piColPos, _pdblReal, NULL);
+ }
+ int readSparseComplexMatrix(int _iDatasetId, int _iRows, int _iCols, int _iNbItem, int *_piNbItemRow, int *_piColPos, double *_pdblReal, double *_pdblImg)
+ {
+     return readCommonSparseComplexMatrix(_iDatasetId, 1, _iRows, _iCols, _iNbItem, _piNbItemRow, _piColPos, _pdblReal, _pdblImg);
+ }
+ int readBooleanSparseMatrix(int _iDatasetId, int _iRows, int _iCols, int _iNbItem, int *_piNbItemRow, int *_piColPos)
+ {
+     hid_t obj = 0;
+     hobj_ref_t pRef[2] = {0};
+     herr_t status;
+     /*
+      * Read the data.
+      */
+     status = H5Dread(_iDatasetId, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, pRef);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //read Row data
+     obj = H5Rdereference(_iDatasetId, H5R_OBJECT, &pRef[0]);
+     status = readInteger32Matrix(obj, _piNbItemRow);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //read cols data
+     obj = H5Rdereference(_iDatasetId, H5R_OBJECT, &pRef[1]);
+     status = readInteger32Matrix(obj, _piColPos);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int getScilabTypeFromDataSet(int _iDatasetId)
+ {
+     int iVarType = 0;
+     char *pstScilabClass = readAttribute(_iDatasetId, g_SCILAB_CLASS);
+     if (pstScilabClass == NULL)
+     {
+         return unknow_type;
+     }
+     /* HDF5 Float type + SCILAB_Class = double <=> double */
+     if (strcmp(pstScilabClass, g_SCILAB_CLASS_DOUBLE) == 0)
+     {
+         iVarType = sci_matrix;
+     }
+     else if (strcmp(pstScilabClass, g_SCILAB_CLASS_STRING) == 0)
+     {
+         iVarType = sci_strings;
+     }
+     else if (strcmp(pstScilabClass, g_SCILAB_CLASS_BOOLEAN) == 0)
+     {
+         iVarType = sci_boolean;
+     }
+     else if (strcmp(pstScilabClass, g_SCILAB_CLASS_BOOLEAN) == 0)
+     {
+         iVarType = sci_boolean;
+     }
+     else if (strcmp(pstScilabClass, g_SCILAB_CLASS_POLY) == 0)
+     {
+         iVarType = sci_poly;
+     }
+     else if (strcmp(pstScilabClass, g_SCILAB_CLASS_INT) == 0)
+     {
+         iVarType = sci_ints;
+     }
+     else if (strcmp(pstScilabClass, g_SCILAB_CLASS_SPARSE) == 0)
+     {
+         iVarType = sci_sparse;
+     }
+     else if (strcmp(pstScilabClass, g_SCILAB_CLASS_BSPARSE) == 0)
+     {
+         iVarType = sci_boolean_sparse;
+     }
+     else if (strcmp(pstScilabClass, g_SCILAB_CLASS_LIST) == 0)
+     {
+         iVarType = sci_list;
+     }
+     else if (strcmp(pstScilabClass, g_SCILAB_CLASS_TLIST) == 0)
+     {
+         iVarType = sci_tlist;
+     }
+     else if (strcmp(pstScilabClass, g_SCILAB_CLASS_MLIST) == 0)
+     {
+         iVarType = sci_mlist;
+     }
+     else if (strcmp(pstScilabClass, g_SCILAB_CLASS_VOID) == 0)
+     {
+         iVarType = sci_void;
+     }
+     else if (strcmp(pstScilabClass, g_SCILAB_CLASS_UNDEFINED) == 0)
+     {
+         iVarType = sci_undefined;
+     }
+     FREE(pstScilabClass);
+     return iVarType;
+ }
+ int getListItemReferences(int _iDatasetId, hobj_ref_t ** _piItemRef)
+ {
+     int iItem = 0;
+     herr_t status = 0;
+     getListDims(_iDatasetId, &iItem);
+     *_piItemRef = (hobj_ref_t *) MALLOC(iItem * sizeof(hobj_ref_t));
+     status = H5Dread(_iDatasetId, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, *_piItemRef);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int getListItemDataset(int _iDatasetId, void *_piItemRef, int _iItemPos, int *_piItemDataset)
+ {
+     hobj_ref_t poRef = ((hobj_ref_t *) _piItemRef)[_iItemPos];
+     *_piItemDataset = H5Rdereference(_iDatasetId, H5R_OBJECT, &poRef);
+     if (*_piItemDataset == 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int deleteListItemReferences(int _iDatasetId, void *_piItemRef)
+ {
+     herr_t status;
+     if (_piItemRef)
+     {
+         hobj_ref_t *poRef = (hobj_ref_t *) _piItemRef;
+         FREE(poRef);
+     }
+     status = H5Dclose(_iDatasetId);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
index 0000000,0b3f5e5..dc41c31
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,1781 +1,1780 @@@
+ /*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2012 - Scilab Enterprises - 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
+ *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+ #define H5_USE_16_API
+ #include <hdf5.h>
+ #include <MALLOC.h>
+ #include <math.h>
+ #include <string.h>
+ #include <stdlib.h>
+ #include "sci_types.h"
+ #include "version.h"
+ #include "core_math.h"
+ #include "h5_writeDataToFile.h"
+ #include "h5_readDataFromFile.h"
+ #include "h5_attributeConstants.h"
+ #include "doublecomplex.h"
 -#include "stack3.h"
+ static hid_t enableCompression(int _iLevel, int _iRank, const hsize_t * _piDims)
+ {
+     /*hid_t iRet = 0;
+     int iLevel = _iLevel;*/
+     return H5P_DEFAULT;
+     /*
+       if(iLevel < 0)
+         {
+             iLevel = 0;
+         }
+       if(iLevel > 9)
+         {
+             iLevel = 9;
+         }
+         if(iLevel)
+         {
+             iRet = H5Pcreate(H5P_DATASET_CREATE);
+             if(iRet < 0)
+             {
+                 iRet = 0;
+             }
+             else
+             {
+                 if(H5Pset_layout(iRet,H5D_COMPACT)<0)
+                 {
+                     H5Pclose(iRet);
+                     iRet = 0;
+                 }
+                 else
+                 {
+                     if(H5Pset_chunk(iRet,_iRank, _piDims)<0)
+                     {
+                         H5Pclose(iRet);
+                         iRet = 0;
+                     }
+                     else
+                     {
+                         if(H5Pset_deflate(iRet,iLevel)<0)
+                         {
+                             H5Pclose(iRet);
+                             iRet = 0;
+                         }
+                     }
+                 }
+             }
+         }
+         else
+         {
+             iRet = H5Pcopy(H5P_DEFAULT);
+         }
+         return iRet;
+     */
+ }
+ static hsize_t* convertDims(int* _piRank, int* _piDims, int* _piSize)
+ {
+     int iSize = 1;
+     int i = 0;
+     hsize_t* piDims = (hsize_t*)malloc(sizeof(hsize_t) * *_piRank);
+     for (i = 0 ; i < *_piRank ; i++)
+     {
+         //reverse dimensions to improve rendering in external tools
+         piDims[i] = _piDims[*_piRank - 1 - i];
+         iSize *= (int)piDims[i];
+     }
+     /*
+      * Fix bug under Linux due to this HDF5 error:
+      * HDF5-DIAG: Error detected in HDF5 (1.8.4-patch1) thread 140525686855488:
+      *   #000: ../../../src/H5S.c line 1335 in H5Screate_simple(): zero sized dimension for non-unlimited dimension
+      *     major: Invalid arguments to routine
+      *     minor: Bad value
+      */
+     if (iSize == 0)
+     {
+         *_piRank = 0;
+     }
+     *_piSize = iSize;
+     return piDims;
+ }
+ static herr_t addIntAttribute(int _iDatasetId, const char *_pstName, const int _iVal)
+ {
+     hsize_t attributeDims[1] = { 1 };
+     hid_t attributeTypeId, attributeSpace;
+     herr_t status;
+     //Create attribute dataspace.  Setting maximum size to NULL sets the maximum size to be the current size.
+     attributeSpace = H5Screate_simple(1, attributeDims, NULL);
+     //Create the attribute and write it.
+     attributeTypeId = H5Acreate(_iDatasetId, _pstName, H5T_NATIVE_INT, attributeSpace, H5P_DEFAULT);
+     if (attributeTypeId < 0)
+     {
+         return -1;
+     }
+     status = H5Awrite(attributeTypeId, H5T_NATIVE_INT, &_iVal);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Close and release resources.
+     status = H5Aclose(attributeTypeId);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Sclose(attributeSpace);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ static herr_t addAttribute(int _iDatasetId, const char *_pstName, const char *_pstValue)
+ {
+     hsize_t attributeDims[1] = { 1 };
+     hid_t attributeTypeId, attributeSpace, attr;
+     herr_t status;
+     //Create attribute dataspace.  Setting maximum size to NULL sets the maximum size to be the current size.
+     attributeSpace = H5Screate_simple(1, attributeDims, NULL);
+     //Create special attribute type
+     attributeTypeId = H5Tcopy(H5T_C_S1);
+     status = H5Tset_size(attributeTypeId, strlen(_pstValue));
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Create the attribute and write it.
+     attr = H5Acreate(_iDatasetId, _pstName, attributeTypeId, attributeSpace, H5P_DEFAULT);
+     if (attr < 0)
+     {
+         return -1;
+     }
+     status = H5Awrite(attr, attributeTypeId, _pstValue);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Close and release resources.
+     status = H5Aclose(attr);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Tclose(attributeTypeId);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int updateScilabVersion(int _iFile)
+ {
+     herr_t status;
+     //try to read attribute
+     char* pstScilabVersion = getScilabVersionAttribute(_iFile);
+     if (pstScilabVersion)
+     {
+         //delete before write
+         status = H5Adelete(_iFile, g_SCILAB_CLASS_SCI_VERSION);
+         if (status < 0)
+         {
+             return -1;
+         }
+     }
+     if (strstr(SCI_VERSION_STRING, "branch"))
+     {
+         //compiled by user
+         char pstVersion[64];
+         sprintf(pstVersion, "%s %d.%d.%d", SCI_VERSION_STRING, SCI_VERSION_MAJOR, SCI_VERSION_MINOR, SCI_VERSION_MAINTENANCE);
+         status = addAttribute(_iFile, g_SCILAB_CLASS_SCI_VERSION, pstVersion);
+     }
+     else
+     {
+         //compiled by compilation chain
+         status = addAttribute(_iFile, g_SCILAB_CLASS_SCI_VERSION, SCI_VERSION_STRING);
+     }
+     return status;
+ }
+ int updateFileVersion(int _iFile)
+ {
+     herr_t status;
+     //try to read attribute
+     int iHdf5Version = getSODFormatAttribute(_iFile);
+     if (iHdf5Version != -1)
+     {
+         status = H5Adelete(_iFile, g_SCILAB_CLASS_SOD_VERSION);
+         if (status < 0)
+         {
+             return -1;
+         }
+     }
+     return addIntAttribute(_iFile, g_SCILAB_CLASS_SOD_VERSION, SOD_FILE_VERSION);
+ }
+ int writeStringMatrix(int _iFile, char *_pstDatasetName, int _iDims, int* _piDims, char **data)
+ {
+     int iSize = 0;
+     hsize_t* piDims = NULL;
+     hid_t typeId, space, dset;
+     herr_t status;
+     hid_t iCompress;
+     piDims = convertDims(&_iDims, _piDims, &iSize);
+     //Create string dataspace.  Setting maximum size to NULL sets the maximum size to be the current size.
+     space = H5Screate_simple(_iDims, piDims, NULL);
+     if (space < 0)
+     {
+         FREE(piDims);
+         return -1;
+     }
+     //Create special string type
+     typeId = H5Tcopy(H5T_C_S1);
+     status = H5Tset_size(typeId, H5T_VARIABLE);
+     if (status < 0)
+     {
+         FREE(piDims);
+         return -1;
+     }
+     //Create the data set and write it.
+     iCompress = enableCompression(9, _iDims, piDims);
+     FREE(piDims);
+     dset = H5Dcreate(_iFile, _pstDatasetName, typeId, space, iCompress);
+     if (dset < 0)
+     {
+         return -1;
+     }
+     status = H5Dwrite(dset, typeId, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Add attribute SCILAB_Class = string to dataset
+     status = addAttribute(dset, g_SCILAB_CLASS, g_SCILAB_CLASS_STRING);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Close and release resources.
+     status = H5Dclose(dset);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Tclose(typeId);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ char *createGroupName(char *_pstGroupName)
+ {
+     char *pstSlash = NULL;
+     char *pstGroupName = (char *)MALLOC((strlen(_pstGroupName) + 3) * sizeof(char));
+     // Generate groupname #<dataSetName>#
+     sprintf(pstGroupName, "#%s#", _pstGroupName);
+     pstSlash = strstr(pstGroupName, "/");
+     if (pstSlash != NULL)
+     {
+         pstSlash[0] = '_';
+     }
+     return pstGroupName;
+ }
+ char* createPathName(char *_pstGroupName, int _iIndex)
+ {
+     char *pstName = NULL;
+     char *pstPathName = NULL;
+     int iNameLen = (int)log10((double)_iIndex + 1) + 1;
+     iNameLen += 2; //for both '#'
+     iNameLen += 1; //for null termanation
+     pstName = (char *)MALLOC(iNameLen * sizeof(char));
+     //1 for null termination, 2 for '#' characters
+     sprintf(pstName, "#%d#", _iIndex);
+     pstPathName = (char *)MALLOC((strlen(_pstGroupName) + strlen(pstName) + 2) * sizeof(char));
+     //1 for null termination, 1 for separator, 2 for '#' characters
+     sprintf(pstPathName, "%s/%s", _pstGroupName, pstName);
+     FREE(pstName);
+     return pstPathName;
+ }
+ int writeVoid(int _iFile, char *_pstDatasetName)
+ {
+     hsize_t piDims[1] = { 1 };
+     herr_t status = 0;
+     hid_t iSpace = 0;
+     hid_t iDataset = 0;
+     hid_t iCompress = 0;
+     char cData = 0;
+     //Create dataspace.  Setting maximum size to NULL sets the maximum size to be the current size.
+     iSpace = H5Screate_simple(1, piDims, NULL);
+     if (iSpace < 0)
+     {
+         return -1;
+     }
+     //Create the dataset and write the array data to it.
+     iCompress = enableCompression(9, 1, piDims);
+     iDataset = H5Dcreate(_iFile, _pstDatasetName, H5T_NATIVE_INT8, iSpace, iCompress);
+     if (iDataset < 0)
+     {
+         return -1;
+     }
+     status = H5Dwrite(iDataset, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, &cData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Add attribute SCILAB_Class = double to dataset
+     status = addAttribute(iDataset, g_SCILAB_CLASS, g_SCILAB_CLASS_VOID);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Close and release resources.
+     status = H5Dclose(iDataset);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Sclose(iSpace);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int writeUndefined(int _iFile, char *_pstDatasetName)
+ {
+     hsize_t piDims[1] = { 1 };
+     herr_t status = 0;
+     hid_t iSpace = 0;
+     hid_t iDataset = 0;
+     hid_t iCompress = 0;
+     char cData = 0;
+     //Create dataspace.  Setting maximum size to NULL sets the maximum size to be the current size.
+     iSpace = H5Screate_simple(1, piDims, NULL);
+     if (iSpace < 0)
+     {
+         return -1;
+     }
+     //Create the dataset and write the array data to it.
+     iCompress = enableCompression(9, 1, piDims);
+     iDataset = H5Dcreate(_iFile, _pstDatasetName, H5T_NATIVE_INT8, iSpace, iCompress);
+     if (iDataset < 0)
+     {
+         return -1;
+     }
+     status = H5Dwrite(iDataset, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, &cData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Add attribute SCILAB_Class = double to dataset
+     status = addAttribute(iDataset, g_SCILAB_CLASS, g_SCILAB_CLASS_UNDEFINED);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Close and release resources.
+     status = H5Dclose(iDataset);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Sclose(iSpace);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int writeDoubleMatrix(int _iFile, char *_pstDatasetName, int _iDims, int* _piDims, double *_pdblData)
+ {
+     hid_t space = 0;
+     hid_t dset = 0;
+     herr_t status = 0;
+     hsize_t *piDims = NULL;
+     hid_t iCompress = 0;
+     int i = 0;
+     int iSize = 0;
+     piDims = convertDims(&_iDims, _piDims, &iSize);
+     if (_iDims == 2 && piDims[0] == 0 && piDims[1] == 0)
+     {
+         // []
+         space = H5Screate_simple(0, NULL, NULL);
+         if (space < 0)
+         {
+             free(piDims);
+             return -1;
+         }
+         //Create the dataset and write the array data to it.
+         iCompress = enableCompression(9, _iDims, piDims);
+         free(piDims);
+         dset = H5Dcreate(_iFile, _pstDatasetName, H5T_NATIVE_DOUBLE, space, iCompress);
+         if (dset < 0)
+         {
+             return -1;
+         }
+         //Add attribute SCILAB_Class = double to dataset
+         status = addAttribute(dset, g_SCILAB_CLASS, g_SCILAB_CLASS_DOUBLE);
+         if (status < 0)
+         {
+             return -1;
+         }
+         //Close and release resources.
+         status = H5Dclose(dset);
+         if (status < 0)
+         {
+             return -1;
+         }
+         status = H5Sclose(space);
+         if (status < 0)
+         {
+             return -1;
+         }
+         return 0;
+     }
+     //Create dataspace.  Setting maximum size to NULL sets the maximum size to be the current size.
+     space = H5Screate_simple(_iDims, piDims, NULL);
+     if (space < 0)
+     {
+         free(piDims);
+         return -1;
+     }
+     //Create the dataset and write the array data to it.
+     iCompress = enableCompression(9, _iDims, piDims);
+     free(piDims);
+     dset = H5Dcreate(_iFile, _pstDatasetName, H5T_NATIVE_DOUBLE, space, iCompress);
+     if (dset < 0)
+     {
+         return -1;
+     }
+     status = H5Dwrite(dset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, _pdblData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Add attribute SCILAB_Class = double to dataset
+     status = addAttribute(dset, g_SCILAB_CLASS, g_SCILAB_CLASS_DOUBLE);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Close and release resources.
+     status = H5Dclose(dset);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Sclose(space);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return status;
+ }
+ int writeDoubleComplexMatrix(int _iFile, char *_pstDatasetName, int _iDims, int* _piDims, double *_pdblReal, double *_pdblImg)
+ {
+     hid_t space = 0;
+     hid_t dset = 0;
+     herr_t status = 0;
+     hsize_t *piDims = NULL;
+     hid_t iCompress = 0;
+     hid_t compoundId;
+     int iSize = 1;
+     doublecomplex* pData = NULL;
+     //create sub group only for non empty matrix
+     if (_iDims == 2 && _piDims[0] == 0 && _piDims[1] == 0)
+     {
+         // [] complex
+         //a revoir
+         return -1;
+     }
+     compoundId = H5Tcreate (H5T_COMPOUND, sizeof(doublecomplex));
+     H5Tinsert(compoundId, "real", HOFFSET(doublecomplex, r), H5T_NATIVE_DOUBLE);
+     H5Tinsert(compoundId, "imag", HOFFSET(doublecomplex, i), H5T_NATIVE_DOUBLE);
+     piDims = convertDims(&_iDims, _piDims, &iSize);
+     //Create dataspace.  Setting maximum size to NULL sets the maximum size to be the current size.
+     space = H5Screate_simple(_iDims, piDims, NULL);
+     if (space < 0)
+     {
+         free(piDims);
+         return -1;
+     }
+     //Create the dataset and write the array data to it.
+     iCompress = enableCompression(9, _iDims, piDims);
+     free(piDims);
+     dset = H5Dcreate(_iFile, _pstDatasetName, compoundId, space, iCompress);
+     if (dset < 0)
+     {
+         return -1;
+     }
+     //convert double data doublecomplex data
+     pData = oGetDoubleComplexFromPointer(_pdblReal, _pdblImg, iSize);
+     status = H5Dwrite(dset, compoundId, H5S_ALL, H5S_ALL, H5P_DEFAULT, pData);
+     FREE(pData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Add attribute SCILAB_Class = double to dataset
+     status = addAttribute(dset, g_SCILAB_CLASS, g_SCILAB_CLASS_DOUBLE);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Close and release resources.
+     status = H5Dclose(dset);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Sclose(space);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return status;
+ }
+ int writeBooleanMatrix(int _iFile, char *_pstDatasetName, int _iDims, int* _piDims, int *_piData)
+ {
+     int iSize = 0;
+     hsize_t* piDims = NULL;
+     herr_t status;
+     hid_t iSpace;
+     hid_t iCompress;
+     hid_t iDataset;
+     piDims = convertDims(&_iDims, _piDims, &iSize);
+     //Create dataspace.  Setting maximum size to NULL sets the maximum size to be the current size.
+     iSpace = H5Screate_simple(_iDims, piDims, NULL);
+     if (iSpace < 0)
+     {
+         return -1;
+     }
+     //Create the dataset and write the array data to it.
+     iCompress = enableCompression(9, _iDims, piDims);
+     iDataset = H5Dcreate(_iFile, _pstDatasetName, H5T_NATIVE_INT, iSpace, iCompress);
+     if (iDataset < 0)
+     {
+         return -1;
+     }
+     status = H5Dwrite(iDataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, _piData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Add attribute SCILAB_Class = double to dataset
+     status = addAttribute(iDataset, g_SCILAB_CLASS, g_SCILAB_CLASS_BOOLEAN);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Close and release resources.
+     status = H5Dclose(iDataset);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Sclose(iSpace);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ static int writeCommonPolyMatrix(int _iFile, char *_pstDatasetName, char *_pstVarName, int _iComplex, int _iDims, int* _piDims, int *_piNbCoef, double **_pdblReal, double **_pdblImg)
+ {
+     int i = 0;
+     hsize_t* piDims = NULL;
+     herr_t status = 0;
+     hid_t space = 0;
+     hid_t dset = 0;
+     hid_t group = 0;
+     hid_t iCompress = 0;
+     hobj_ref_t *pData = 0;
+     int iSize = 0;
+     char *pstPathName = NULL;
+     char *pstGroupName = NULL;
+     piDims = convertDims(&_iDims, _piDims, &iSize);
+     // Create ref matrix
+     pData = (hobj_ref_t *)MALLOC(iSize * sizeof(hobj_ref_t));
+     // Generate groupname #<dataSetName>#
+     pstGroupName = createGroupName(_pstDatasetName);
+     //First create a group to store all referenced objects.
+     group = H5Gcreate(_iFile, pstGroupName, H5P_DEFAULT);
+     status = H5Gclose(group);
+     //Now create each String as a dedicated DataSet.
+     for (i = 0 ; i < iSize ; i++)
+     {
+         pstPathName = createPathName(pstGroupName, i);
+         // Write the string to ref
+         if (_iComplex)
+         {
+             status = writeDoubleComplexMatrix(_iFile, pstPathName, 1, &_piNbCoef[i], _pdblReal[i], _pdblImg[i]);
+         }
+         else
+         {
+             status = writeDoubleMatrix(_iFile, pstPathName, 1, &_piNbCoef[i], _pdblReal[i]);
+         }
+         if (status < 0)
+         {
+             FREE(pstPathName);
+             FREE(pstGroupName);
+             FREE(pData);
+             FREE(piDims);
+             return -1;
+         }
+         // create the ref
+         status = H5Rcreate(&pData[i], _iFile, pstPathName, H5R_OBJECT, -1);
+         if (status < 0)
+         {
+             FREE(pstPathName);
+             FREE(pstGroupName);
+             FREE(pData);
+             FREE(piDims);
+             return -1;
+         }
+         FREE(pstPathName);
+     }
+     FREE(pstGroupName);
+     //Create dataspace.  Setting maximum size to NULL sets the maximum size to be the current size.
+     space = H5Screate_simple(_iDims, piDims, NULL);
+     if (status < 0)
+     {
+         FREE(piDims);
+         FREE(pData);
+         return -1;
+     }
+     //Create the dataset and write the array data to it.
+     iCompress = enableCompression(9, _iDims, piDims);
+     FREE(piDims);
+     dset = H5Dcreate(_iFile, _pstDatasetName, H5T_STD_REF_OBJ, space, iCompress);
+     if (dset < 0)
+     {
+         FREE(pData);
+         return -1;
+     }
+     status = H5Dwrite(dset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, pData);
+     if (status < 0)
+     {
+         FREE(pData);
+         return -1;
+     }
+     FREE(pData);
+     //Add attribute SCILAB_Class = poly to dataset
+     status = addAttribute(dset, g_SCILAB_CLASS, g_SCILAB_CLASS_POLY);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Add attribute Varname attribute to dataset
+     status = addAttribute(dset, g_SCILAB_CLASS_VARNAME, _pstVarName);
+     if (status < 0)
+     {
+         return -1;
+     }
+     if (_iComplex)
+     {
+         //Add attribute Varname attribute to dataset
+         status = addAttribute(dset, g_SCILAB_CLASS_COMPLEX, "true");
+         if (status < 0)
+         {
+             return -1;
+         }
+     }
+     //Close and release resources.
+     status = H5Dclose(dset);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Sclose(space);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int writePolyMatrix(int _iFile, char *_pstDatasetName, char *_pstVarName, int _iDims, int* _piDims, int *_piNbCoef, double **_pdblReal)
+ {
+     return writeCommonPolyMatrix(_iFile, _pstDatasetName, _pstVarName, 0, _iDims, _piDims, _piNbCoef, _pdblReal, NULL);
+ }
+ int writePolyComplexMatrix(int _iFile, char *_pstDatasetName, char *_pstVarName, int _iDims, int* _piDims, int *_piNbCoef, double **_pdblReal,
+                            double **_pdblImg)
+ {
+     return writeCommonPolyMatrix(_iFile, _pstDatasetName, _pstVarName, 1, _iDims, _piDims, _piNbCoef, _pdblReal, _pdblImg);
+ }
+ int writeInteger8Matrix(int _iFile, char *_pstDatasetName, int _iDims, int* _piDims, char *_pcData)
+ {
+     hsize_t* piDims = NULL;
+     herr_t status = 0;
+     hid_t iSpace = 0;
+     hid_t iDataset = 0;
+     hid_t iCompress = 0;
+     int iSize = 0;
+     piDims = convertDims(&_iDims, _piDims, &iSize);
+     //Create dataspace.  Setting maximum size to NULL sets the maximum size to be the current size.
+     iSpace = H5Screate_simple(_iDims, piDims, NULL);
+     if (iSpace < 0)
+     {
+         FREE(piDims);
+         return -1;
+     }
+     //Create the dataset and write the array data to it.
+     iCompress = enableCompression(9, _iDims, piDims);
+     FREE(piDims);
+     iDataset = H5Dcreate(_iFile, _pstDatasetName, H5T_NATIVE_INT8, iSpace, iCompress);
+     if (iDataset < 0)
+     {
+         return -1;
+     }
+     status = H5Dwrite(iDataset, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, _pcData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Add attribute SCILAB_Class = double to dataset
+     status = addAttribute(iDataset, g_SCILAB_CLASS, g_SCILAB_CLASS_INT);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = addAttribute(iDataset, g_SCILAB_CLASS_PREC, "8");
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Close and release resources.
+     status = H5Dclose(iDataset);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Sclose(iSpace);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int writeInteger16Matrix(int _iFile, char *_pstDatasetName, int _iDims, int* _piDims, short *_psData)
+ {
+     hsize_t* piDims = NULL;
+     herr_t status = 0;
+     hid_t iSpace = 0;
+     hid_t iDataset = 0;
+     hid_t iCompress = 0;
+     int iSize = 0;
+     piDims = convertDims(&_iDims, _piDims, &iSize);
+     //Create dataspace.  Setting maximum size to NULL sets the maximum size to be the current size.
+     iSpace = H5Screate_simple(_iDims, piDims, NULL);
+     if (iSpace < 0)
+     {
+         FREE(piDims);
+         return -1;
+     }
+     //Create the dataset and write the array data to it.
+     iCompress = enableCompression(9, _iDims, piDims);
+     FREE(piDims);
+     iDataset = H5Dcreate(_iFile, _pstDatasetName, H5T_NATIVE_INT16, iSpace, iCompress);
+     if (iDataset < 0)
+     {
+         return -1;
+     }
+     status = H5Dwrite(iDataset, H5T_NATIVE_INT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, _psData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Add attribute SCILAB_Class = double to dataset
+     status = addAttribute(iDataset, g_SCILAB_CLASS, g_SCILAB_CLASS_INT);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = addAttribute(iDataset, g_SCILAB_CLASS_PREC, "16");
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Close and release resources.
+     status = H5Dclose(iDataset);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Sclose(iSpace);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int writeInteger32Matrix(int _iFile, char *_pstDatasetName, int _iDims, int* _piDims, int *_piData)
+ {
+     hsize_t* piDims = NULL;
+     herr_t status = 0;
+     hid_t iSpace = 0;
+     hid_t iDataset = 0;
+     hid_t iCompress = 0;
+     int iSize = 0;
+     piDims = convertDims(&_iDims, _piDims, &iSize);
+     //Create dataspace.  Setting maximum size to NULL sets the maximum size to be the current size.
+     iSpace = H5Screate_simple(_iDims, piDims, piDims);
+     if (iSpace < 0)
+     {
+         FREE(piDims);
+         return -1;
+     }
+     //Create the dataset and write the array data to it.
+     iCompress = enableCompression(9, _iDims, piDims);
+     FREE(piDims);
+     iDataset = H5Dcreate(_iFile, _pstDatasetName, H5T_NATIVE_INT32, iSpace, iCompress);
+     if (iDataset < 0)
+     {
+         return -1;
+     }
+     status = H5Dwrite(iDataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, _piData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Add attribute SCILAB_Class = double to dataset
+     status = addAttribute(iDataset, g_SCILAB_CLASS, g_SCILAB_CLASS_INT);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = addAttribute(iDataset, g_SCILAB_CLASS_PREC, "32");
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Close and release resources.
+     status = H5Dclose(iDataset);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Sclose(iSpace);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int writeInteger64Matrix(int _iFile, char *_pstDatasetName, int _iDims, int* _piDims, long long *_pllData)
+ {
+     hsize_t* piDims = NULL;
+     herr_t status = 0;
+     hid_t iSpace = 0;
+     hid_t iDataset = 0;
+     hid_t iCompress = 0;
+     int iSize = 0;
+     piDims = convertDims(&_iDims, _piDims, &iSize);
+     //Create dataspace.  Setting maximum size to NULL sets the maximum size to be the current size.
+     iSpace = H5Screate_simple(_iDims, piDims, NULL);
+     if (iSpace < 0)
+     {
+         FREE(piDims);
+         return -1;
+     }
+     //Create the dataset and write the array data to it.
+     iCompress = enableCompression(9, _iDims, piDims);
+     FREE(piDims);
+     iDataset = H5Dcreate(_iFile, _pstDatasetName, H5T_NATIVE_INT64, iSpace, iCompress);
+     if (iDataset < 0)
+     {
+         return -1;
+     }
+     status = H5Dwrite(iDataset, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, _pllData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Add attribute SCILAB_Class = double to dataset
+     status = addAttribute(iDataset, g_SCILAB_CLASS, g_SCILAB_CLASS_INT);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = addAttribute(iDataset, g_SCILAB_CLASS_PREC, "64");
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Close and release resources.
+     status = H5Dclose(iDataset);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Sclose(iSpace);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int writeUnsignedInteger8Matrix(int _iFile, char *_pstDatasetName, int _iDims, int* _piDims, unsigned char *_pucData)
+ {
+     hsize_t* piDims = NULL;
+     herr_t status = 0;
+     hid_t iSpace = 0;
+     hid_t iDataset = 0;
+     hid_t iCompress = 0;
+     int iSize = 0;
+     piDims = convertDims(&_iDims, _piDims, &iSize);
+     //Create dataspace.  Setting maximum size to NULL sets the maximum size to be the current size.
+     iSpace = H5Screate_simple(_iDims, piDims, NULL);
+     if (iSpace < 0)
+     {
+         FREE(piDims);
+         return -1;
+     }
+     //Create the dataset and write the array data to it.
+     iCompress = enableCompression(9, _iDims, piDims);
+     FREE(piDims);
+     iDataset = H5Dcreate(_iFile, _pstDatasetName, H5T_NATIVE_UINT8, iSpace, iCompress);
+     if (iDataset < 0)
+     {
+         return -1;
+     }
+     status = H5Dwrite(iDataset, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, _pucData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Add attribute SCILAB_Class = double to dataset
+     status = addAttribute(iDataset, g_SCILAB_CLASS, g_SCILAB_CLASS_INT);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = addAttribute(iDataset, g_SCILAB_CLASS_PREC, "u8");
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Close and release resources.
+     status = H5Dclose(iDataset);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Sclose(iSpace);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int writeUnsignedInteger16Matrix(int _iFile, char *_pstDatasetName, int _iDims, int* _piDims, unsigned short *_pusData)
+ {
+     hsize_t* piDims = NULL;
+     herr_t status = 0;
+     hid_t iSpace = 0;
+     hid_t iDataset = 0;
+     hid_t iCompress = 0;
+     int iSize = 0;
+     piDims = convertDims(&_iDims, _piDims, &iSize);
+     //Create dataspace.  Setting maximum size to NULL sets the maximum size to be the current size.
+     iSpace = H5Screate_simple(_iDims, piDims, NULL);
+     if (iSpace < 0)
+     {
+         FREE(piDims);
+         return -1;
+     }
+     //Create the dataset and write the array data to it.
+     iCompress = enableCompression(9, _iDims, piDims);
+     FREE(piDims);
+     iDataset = H5Dcreate(_iFile, _pstDatasetName, H5T_NATIVE_UINT16, iSpace, iCompress);
+     if (iDataset < 0)
+     {
+         return -1;
+     }
+     status = H5Dwrite(iDataset, H5T_NATIVE_UINT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, _pusData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Add attribute SCILAB_Class = double to dataset
+     status = addAttribute(iDataset, g_SCILAB_CLASS, g_SCILAB_CLASS_INT);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = addAttribute(iDataset, g_SCILAB_CLASS_PREC, "u16");
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Close and release resources.
+     status = H5Dclose(iDataset);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Sclose(iSpace);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int writeUnsignedInteger32Matrix(int _iFile, char *_pstDatasetName, int _iDims, int* _piDims, unsigned int *_puiData)
+ {
+     hsize_t* piDims = NULL;
+     herr_t status = 0;
+     hid_t iSpace = 0;
+     hid_t iDataset = 0;
+     hid_t iCompress = 0;
+     int iSize = 0;
+     piDims = convertDims(&_iDims, _piDims, &iSize);
+     //Create dataspace.  Setting maximum size to NULL sets the maximum size to be the current size.
+     iSpace = H5Screate_simple(_iDims, piDims, NULL);
+     if (iSpace < 0)
+     {
+         FREE(piDims);
+         return -1;
+     }
+     //Create the dataset and write the array data to it.
+     iCompress = enableCompression(9, _iDims, piDims);
+     FREE(piDims);
+     iDataset = H5Dcreate(_iFile, _pstDatasetName, H5T_NATIVE_UINT32, iSpace, iCompress);
+     if (iDataset < 0)
+     {
+         return -1;
+     }
+     status = H5Dwrite(iDataset, H5T_NATIVE_UINT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, _puiData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Add attribute SCILAB_Class = double to dataset
+     status = addAttribute(iDataset, g_SCILAB_CLASS, g_SCILAB_CLASS_INT);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = addAttribute(iDataset, g_SCILAB_CLASS_PREC, "u32");
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Close and release resources.
+     status = H5Dclose(iDataset);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Sclose(iSpace);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int writeUnsignedInteger64Matrix(int _iFile, char *_pstDatasetName, int _iDims, int* _piDims, unsigned long long *_pullData)
+ {
+     hsize_t* piDims = NULL;
+     herr_t status = 0;
+     hid_t iSpace = 0;
+     hid_t iDataset = 0;
+     hid_t iCompress = 0;
+     int iSize = 0;
+     piDims = convertDims(&_iDims, _piDims, &iSize);
+     //Create dataspace.  Setting maximum size to NULL sets the maximum size to be the current size.
+     iSpace = H5Screate_simple(_iDims, piDims, NULL);
+     if (iSpace < 0)
+     {
+         FREE(piDims);
+         return -1;
+     }
+     //Create the dataset and write the array data to it.
+     iCompress = enableCompression(9, _iDims, piDims);
+     FREE(piDims);
+     iDataset = H5Dcreate(_iFile, _pstDatasetName, H5T_NATIVE_UINT64, iSpace, iCompress);
+     if (iDataset < 0)
+     {
+         return -1;
+     }
+     status = H5Dwrite(iDataset, H5T_NATIVE_UINT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, _pullData);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Add attribute SCILAB_Class = double to dataset
+     status = addAttribute(iDataset, g_SCILAB_CLASS, g_SCILAB_CLASS_INT);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = addAttribute(iDataset, g_SCILAB_CLASS_PREC, "u64");
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Close and release resources.
+     status = H5Dclose(iDataset);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Sclose(iSpace);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int writeCommonSparseComplexMatrix(int _iFile, char *_pstDatasetName, int _iComplex, int _iRows, int _iCols, int _iNbItem, int *_piNbItemRow,
+                                    int *_piColPos, double *_pdblReal, double *_pdblImg)
+ {
+     hsize_t dims[1] = { 3 };
+     herr_t status = 0;
+     hid_t space = 0;
+     hid_t dset = 0;
+     hid_t group = 0;
+     hid_t iCompress = 0;
+     hobj_ref_t pDataRef[3] = {0};
+     char *pstRowPath = NULL;
+     char *pstColPath = NULL;
+     char *pstDataPath = NULL;
+     char *pstGroupName = NULL;
+     // Generate groupname #<dataSetName>#
+     pstGroupName = createGroupName(_pstDatasetName);
+     //First create a group to store all referenced objects.
+     group = H5Gcreate(_iFile, pstGroupName, H5P_DEFAULT);
+     status = H5Gclose(group);
+     if (status < 0)
+     {
+         FREE(pstGroupName);
+         return -1;
+     }
+     //Create each sub dataset and insert data
+     pstRowPath = createPathName(pstGroupName, 0);
+     status = writeInteger32Matrix(_iFile, pstRowPath, 1, &_iRows, _piNbItemRow);
+     if (status < 0)
+     {
+         FREE(pstRowPath);
+         FREE(pstGroupName);
+         return -1;
+     }
+     status = H5Rcreate(&pDataRef[0], _iFile, pstRowPath, H5R_OBJECT, -1);
+     if (status < 0)
+     {
+         FREE(pstRowPath);
+         FREE(pstGroupName);
+         return -1;
+     }
+     pstColPath = createPathName(pstGroupName, 1);
+     status = writeInteger32Matrix(_iFile, pstColPath, 1, &_iNbItem, _piColPos);
+     if (status < 0)
+     {
+         FREE(pstRowPath);
+         FREE(pstColPath);
+         FREE(pstGroupName);
+         return -1;
+     }
+     status = H5Rcreate(&pDataRef[1], _iFile, pstColPath, H5R_OBJECT, -1);
+     if (status < 0)
+     {
+         FREE(pstRowPath);
+         FREE(pstColPath);
+         FREE(pstGroupName);
+         return -1;
+     }
+     pstDataPath = createPathName(pstGroupName, 2);
+     if (_iComplex)
+     {
+         status = writeDoubleComplexMatrix(_iFile, pstDataPath, 1, &_iNbItem, _pdblReal, _pdblImg);
+     }
+     else
+     {
+         status = writeDoubleMatrix(_iFile, pstDataPath, 1, &_iNbItem, _pdblReal);
+     }
+     if (status < 0)
+     {
+         FREE(pstRowPath);
+         FREE(pstColPath);
+         FREE(pstDataPath);
+         FREE(pstGroupName);
+         return -1;
+     }
+     status = H5Rcreate(&pDataRef[2], _iFile, pstDataPath, H5R_OBJECT, -1);
+     if (status < 0)
+     {
+         FREE(pstRowPath);
+         FREE(pstColPath);
+         FREE(pstDataPath);
+         FREE(pstGroupName);
+         return -1;
+     }
+     //FREE group names
+     FREE(pstRowPath);
+     FREE(pstColPath);
+     FREE(pstDataPath);
+     FREE(pstGroupName);
+     //Create dataspace.  Setting maximum size to NULL sets the maximum size to be the current size.
+     space = H5Screate_simple(1, dims, NULL);
+     if (space < 0)
+     {
+         return -1;
+     }
+     //Create the dataset and write the array data to it.
+     iCompress = enableCompression(9, 1, dims);
+     dset = H5Dcreate(_iFile, _pstDatasetName, H5T_STD_REF_OBJ, space, iCompress);
+     if (dset < 0)
+     {
+         return -1;
+     }
+     status = H5Dwrite(dset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, pDataRef);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Add attribute SCILAB_Class = poly to dataset
+     //sprintf(pstRow, "%d", _iRows);
+     //sprintf(pstCol, "%d", _iCols);
+     status = addAttribute(dset, g_SCILAB_CLASS, g_SCILAB_CLASS_SPARSE);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = addIntAttribute(dset, g_SCILAB_CLASS_ROWS, _iRows);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = addIntAttribute(dset, g_SCILAB_CLASS_COLS, _iCols);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = addIntAttribute(dset, g_SCILAB_CLASS_ITEMS, _iNbItem);
+     if (status < 0)
+     {
+         return -1;
+     }
+     if (_iComplex)
+     {
+         //Add attribute Varname attribute to dataset
+         status = addAttribute(dset, g_SCILAB_CLASS_COMPLEX, "true");
+         if (status < 0)
+         {
+             return -1;
+         }
+     }
+     //Close and release resources.
+     status = H5Dclose(dset);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Sclose(space);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ int writeSparseMatrix(int _iFile, char *_pstDatasetName, int _iRows, int _iCols, int _iNbItem, int *_piNbItemRow, int *_piColPos, double *_pdblReal)
+ {
+     return writeCommonSparseComplexMatrix(_iFile, _pstDatasetName, 0, _iRows, _iCols, _iNbItem, _piNbItemRow, _piColPos, _pdblReal, NULL);
+ }
+ int writeSparseComplexMatrix(int _iFile, char *_pstDatasetName, int _iRows, int _iCols, int _iNbItem, int *_piNbItemRow, int *_piColPos,
+                              double *_pdblReal, double *_pdblImg)
+ {
+     return writeCommonSparseComplexMatrix(_iFile, _pstDatasetName, 1, _iRows, _iCols, _iNbItem, _piNbItemRow, _piColPos, _pdblReal, _pdblImg);
+ }
+ int writeBooleanSparseMatrix(int _iFile, char *_pstDatasetName, int _iRows, int _iCols, int _iNbItem, int *_piNbItemRow, int *_piColPos)
+ {
+     hsize_t dims[1] = { 2 };
+     herr_t status = 0;
+     hid_t space = 0;
+     hid_t dset = 0;
+     hid_t group = 0;
+     hid_t iCompress = 0;
+     hobj_ref_t pDataRef[2] = {0};
+     char *pstRowPath = NULL;
+     char *pstColPath = NULL;
+     char *pstGroupName = NULL;
+     // Generate groupname #<dataSetName>#
+     pstGroupName = createGroupName(_pstDatasetName);
+     //First create a group to store all referenced objects.
+     group = H5Gcreate(_iFile, pstGroupName, H5P_DEFAULT);
+     status = H5Gclose(group);
+     if (status < 0)
+     {
+         FREE(pstGroupName);
+         return -1;
+     }
+     //Create each sub dataset and insert data
+     pstRowPath = createPathName(pstGroupName, 0);
+     status = writeInteger32Matrix(_iFile, pstRowPath, 1, &_iRows, _piNbItemRow);
+     if (status < 0)
+     {
+         FREE(pstRowPath);
+         FREE(pstGroupName);
+         return -1;
+     }
+     status = H5Rcreate(&pDataRef[0], _iFile, pstRowPath, H5R_OBJECT, -1);
+     if (status < 0)
+     {
+         FREE(pstRowPath);
+         FREE(pstGroupName);
+         return -1;
+     }
+     pstColPath = createPathName(pstGroupName, 1);
+     status = writeInteger32Matrix(_iFile, pstColPath, 1, &_iNbItem, _piColPos);
+     if (status < 0)
+     {
+         FREE(pstRowPath);
+         FREE(pstColPath);
+         FREE(pstGroupName);
+         return -1;
+     }
+     status = H5Rcreate(&pDataRef[1], _iFile, pstColPath, H5R_OBJECT, -1);
+     if (status < 0)
+     {
+         FREE(pstRowPath);
+         FREE(pstColPath);
+         FREE(pstGroupName);
+         return -1;
+     }
+     //FREE group names
+     FREE(pstRowPath);
+     FREE(pstColPath);
+     FREE(pstGroupName);
+     //Create dataspace.  Setting maximum size to NULL sets the maximum size to be the current size.
+     space = H5Screate_simple(1, dims, NULL);
+     if (space < 0)
+     {
+         return -1;
+     }
+     //Create the dataset and write the array data to it.
+     iCompress = enableCompression(9, 1, dims);
+     dset = H5Dcreate(_iFile, _pstDatasetName, H5T_STD_REF_OBJ, space, iCompress);
+     if (dset < 0)
+     {
+         return -1;
+     }
+     status = H5Dwrite(dset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, pDataRef);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Add attribute SCILAB_Class = boolean sparse to dataset
+     status = addAttribute(dset, g_SCILAB_CLASS, g_SCILAB_CLASS_BSPARSE);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = addIntAttribute(dset, g_SCILAB_CLASS_ROWS, _iRows);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = addIntAttribute(dset, g_SCILAB_CLASS_COLS, _iCols);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = addIntAttribute(dset, g_SCILAB_CLASS_ITEMS, _iNbItem);
+     if (status < 0)
+     {
+         return -1;
+     }
+     //Close and release resources.
+     status = H5Dclose(dset);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Sclose(space);
+     if (status < 0)
+     {
+         return -1;
+     }
+     return 0;
+ }
+ //create a group and create hobj_ref_t array
+ void *openList(int _iFile, char *pstDatasetName, int _iNbItem)
+ {
+     herr_t status = 0;
+     hid_t group = 0;
+     hobj_ref_t *pobjArray = NULL;
+     //First create a group to store all referenced objects.
+     group = H5Gcreate(_iFile, pstDatasetName, H5P_DEFAULT);
+     status = H5Gclose(group);
+     if (status < 0)
+     {
+         return NULL;
+     }
+     if (_iNbItem)
+     {
+         pobjArray = MALLOC(sizeof(hobj_ref_t) * _iNbItem);
+     }
+     return pobjArray;
+ }
+ int addItemInList(int _iFile, void *_pvList, int _iPos, char *_pstItemName)
+ {
+     hobj_ref_t *pobjArray = (hobj_ref_t *) _pvList;
+     return H5Rcreate(&pobjArray[_iPos], _iFile, _pstItemName, H5R_OBJECT, -1);
+ }
+ int closeList(int _iFile, void *_pvList, char *_pstListName, int _iNbItem, int _iVarType)
+ {
+     herr_t status = 0;
+     hsize_t dims[1] = { _iNbItem };
+     hid_t space = 0;
+     hid_t dset = 0;
+     hid_t iCompress = 0;
+     const char *pcstClass = NULL;
+     switch (_iVarType)
+     {
+         case sci_list:
+             pcstClass = g_SCILAB_CLASS_LIST;
+             break;
+         case sci_tlist:
+             pcstClass = g_SCILAB_CLASS_TLIST;
+             break;
+         case sci_mlist:
+             pcstClass = g_SCILAB_CLASS_MLIST;
+             break;
+         default:
+             return 1;
+     }
+     if (_iNbItem == 0)
+     {
+         //tips for empty list
+         //insert a fake refence in the array, value = 0
+         hobj_ref_t pvList[1];
+         pvList[0] = 0;
+         //Create dataspace.  Setting maximum size to NULL sets the maximum size to be the current size.
+         dims[0] = 1;
+         space = H5Screate_simple(1, dims, NULL);
+         if (space < 0)
+         {
+             return -1;
+         }
+         //Create the dataset and write the array data to it.
+         iCompress = enableCompression(9, 1, dims);
+         dset = H5Dcreate(_iFile, _pstListName, H5T_STD_REF_OBJ, space, iCompress);
+         if (dset < 0)
+         {
+             return -1;
+         }
+         status = H5Dwrite(dset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, (hobj_ref_t *) pvList);
+         if (status < 0)
+         {
+             return -1;
+         }
+         //Add attribute SCILAB_Class = string to dataset
+         status = addAttribute(dset, g_SCILAB_CLASS, pcstClass);
+         if (status < 0)
+         {
+             return -1;
+         }
+         status = addAttribute(dset, g_SCILAB_CLASS_EMPTY, "true");
+         if (status < 0)
+         {
+             return -1;
+         }
+     }
+     else
+     {
+         //Create dataspace.  Setting maximum size to NULL sets the maximum size to be the current size.
+         space = H5Screate_simple(1, dims, NULL);
+         if (status < 0)
+         {
+             return -1;
+         }
+         //Create the dataset and write the array data to it.
+         iCompress = enableCompression(9, 1, dims);
+         dset = H5Dcreate(_iFile, _pstListName, H5T_STD_REF_OBJ, space, iCompress);
+         if (dset < 0)
+         {
+             return -1;
+         }
+         status = H5Dwrite(dset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, (hobj_ref_t *) _pvList);
+         if (status < 0)
+         {
+             return -1;
+         }
+         //Add attribute SCILAB_Class = string to dataset
+         status = addAttribute(dset, g_SCILAB_CLASS, pcstClass);
+         if (status < 0)
+         {
+             return -1;
+         }
+         status = addIntAttribute(dset, g_SCILAB_CLASS_ITEMS, _iNbItem);
+         if (status < 0)
+         {
+             return -1;
+         }
+     }
+     //Close and release resources.
+     status = H5Dclose(dset);
+     if (status < 0)
+     {
+         return -1;
+     }
+     status = H5Sclose(space);
+     if (status < 0)
+     {
+         return -1;
+     }
+     FREE(_pvList);
+     return 0;
+ }
    </PropertyGroup>
    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
      <ClCompile>
-       <AdditionalOptions>%(AdditionalOptions)</AdditionalOptions>
        <Optimization>Disabled</Optimization>
-       <AdditionalIncludeDirectories>.;../../includes;../../../../libs/MALLOC/includes;../../../output_stream/includes;../../../core/includes;../../../api_scilab/includes;../../../localization/includes;../../../../libs/intl;../../../../libs/hdf5/include;../../../windows_tools/includes;../../../operations/includes;../../../fileio/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../jni;../cpp;../../../system_env/includes;../../../string/includes;../../../types/includes;../../../functions_manager/includes;../../../ast/includes;../../../symbol/includes;../../../commons/src/jni;../../../../libs/dynamiclibrary/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;HDF5_SCILAB_EXPORTS;_HDF5USEDLL_;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-       <MinimalRebuild>true</MinimalRebuild>
-       <BasicRuntimeChecks>Default</BasicRuntimeChecks>
 -      <AdditionalIncludeDirectories>.;../../includes;../../../../libs/MALLOC/includes;../../../output_stream/includes;../../../core/includes;../../../api_scilab/includes;../../../localization/includes;../../../../libs/intl;../../../../libs/hdf5/include;../../../windows_tools/includes;../../../fileio/includes;../../../commons/src/jni;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../jni;../cpp;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
++      <AdditionalIncludeDirectories>.;../../includes;../../../../libs/MALLOC/includes;../../../output_stream/includes;../../../core/includes;../../../api_scilab/includes;../../../localization/includes;../../../../libs/intl;../../../../libs/hdf5/include;../../../windows_tools/includes;../../../fileio/includes;../../../commons/src/jni;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../jni;../cpp;../../../operations/includes;../../../string/includes;../../../system_env/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;HDF5_SCILAB_EXPORTS;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
        <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
-       <PrecompiledHeader>
-       </PrecompiledHeader>
        <WarningLevel>Level3</WarningLevel>
-       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+       <DisableSpecificWarnings>4251;%(DisableSpecificWarnings)</DisableSpecificWarnings>
      </ClCompile>
      <PreLinkEvent>
        <Message>Make dependencies</Message>
      </Midl>
      <ClCompile>
        <Optimization>Disabled</Optimization>
-       <AdditionalIncludeDirectories>.;../../includes;../../../../libs/MALLOC/includes;../../../output_stream/includes;../../../core/includes;../../../api_scilab/includes;../../../localization/includes;../../../../libs/intl;../../../../libs/hdf5/include;../../../windows_tools/includes;../../../operations/includes;../../../fileio/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../jni;../cpp;../../../system_env/includes;../../../string/includes;../../../types/includes;../../../functions_manager/includes;../../../ast/includes;../../../symbol/includes;../../../commons/src/jni;../../../../libs/dynamiclibrary/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;HDF5_SCILAB_EXPORTS;_HDF5USEDLL_;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-       <MinimalRebuild>true</MinimalRebuild>
-       <BasicRuntimeChecks>Default</BasicRuntimeChecks>
 -      <AdditionalIncludeDirectories>.;../../includes;../../../../libs/MALLOC/includes;../../../output_stream/includes;../../../core/includes;../../../api_scilab/includes;../../../localization/includes;../../../../libs/intl;../../../../libs/hdf5/include;../../../windows_tools/includes;../../../fileio/includes;../../../commons/src/jni;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../jni;../cpp;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
++      <AdditionalIncludeDirectories>.;../../includes;../../../../libs/MALLOC/includes;../../../output_stream/includes;../../../core/includes;../../../api_scilab/includes;../../../localization/includes;../../../../libs/intl;../../../../libs/hdf5/include;../../../windows_tools/includes;../../../fileio/includes;../../../commons/src/jni;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../jni;../cpp;../../../operations/includes;../../../string/includes;../../../system_env/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;HDF5_SCILAB_EXPORTS;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
        <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
-       <PrecompiledHeader>
-       </PrecompiledHeader>
        <WarningLevel>Level3</WarningLevel>
-       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+       <DisableSpecificWarnings>4251;%(DisableSpecificWarnings)</DisableSpecificWarnings>
      </ClCompile>
      <PreLinkEvent>
        <Message>Make dependencies</Message>
    </ItemDefinitionGroup>
    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
      <ClCompile>
-       <AdditionalOptions>%(AdditionalOptions)</AdditionalOptions>
-       <Optimization>MaxSpeed</Optimization>
-       <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
        <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
        <WholeProgramOptimization>false</WholeProgramOptimization>
-       <AdditionalIncludeDirectories>.;../../includes;../../../../libs/MALLOC/includes;../../../output_stream/includes;../../../core/includes;../../../api_scilab/includes;../../../localization/includes;../../../../libs/intl;../../../../libs/hdf5/include;../../../windows_tools/includes;../../../operations/includes;../../../fileio/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../jni;../cpp;../../../system_env/includes;../../../string/includes;../../../types/includes;../../../functions_manager/includes;../../../ast/includes;../../../symbol/includes;../../../commons/src/jni;../../../../libs/dynamiclibrary/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;HDF5_SCILAB_EXPORTS;_HDF5USEDLL_;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
 -      <AdditionalIncludeDirectories>.;../../includes;../../../../libs/MALLOC/includes;../../../output_stream/includes;../../../core/includes;../../../api_scilab/includes;../../../localization/includes;../../../../libs/intl;../../../../libs/hdf5/include;../../../windows_tools/includes;../../../fileio/includes;../../../commons/src/jni;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../jni;../cpp;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
++      <AdditionalIncludeDirectories>.;../../includes;../../../../libs/MALLOC/includes;../../../output_stream/includes;../../../core/includes;../../../api_scilab/includes;../../../localization/includes;../../../../libs/intl;../../../../libs/hdf5/include;../../../windows_tools/includes;../../../fileio/includes;../../../commons/src/jni;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../jni;../cpp;../../../operations/includes;../../../string/includes;../../../system_env/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;HDF5_SCILAB_EXPORTS;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
        <StringPooling>true</StringPooling>
        <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
-       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
-       <PrecompiledHeader>
-       </PrecompiledHeader>
        <WarningLevel>Level3</WarningLevel>
-       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
        <MultiProcessorCompilation>true</MultiProcessorCompilation>
+       <DisableSpecificWarnings>4251;%(DisableSpecificWarnings)</DisableSpecificWarnings>
      </ClCompile>
      <PreLinkEvent>
        <Message>Make dependencies</Message>
        <TargetEnvironment>X64</TargetEnvironment>
      </Midl>
      <ClCompile>
-       <Optimization>MaxSpeed</Optimization>
-       <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
        <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
        <WholeProgramOptimization>false</WholeProgramOptimization>
-       <AdditionalIncludeDirectories>.;../../includes;../../../../libs/MALLOC/includes;../../../output_stream/includes;../../../core/includes;../../../api_scilab/includes;../../../localization/includes;../../../../libs/intl;../../../../libs/hdf5/include;../../../windows_tools/includes;../../../operations/includes;../../../fileio/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../jni;../cpp;../../../system_env/includes;../../../string/includes;../../../types/includes;../../../functions_manager/includes;../../../ast/includes;../../../symbol/includes;../../../commons/src/jni;../../../../libs/dynamiclibrary/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;HDF5_SCILAB_EXPORTS;_HDF5USEDLL_;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
 -      <AdditionalIncludeDirectories>.;../../includes;../../../../libs/MALLOC/includes;../../../output_stream/includes;../../../core/includes;../../../api_scilab/includes;../../../localization/includes;../../../../libs/intl;../../../../libs/hdf5/include;../../../windows_tools/includes;../../../fileio/includes;../../../commons/src/jni;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../jni;../cpp;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
++      <AdditionalIncludeDirectories>.;../../includes;../../../../libs/MALLOC/includes;../../../output_stream/includes;../../../core/includes;../../../api_scilab/includes;../../../localization/includes;../../../../libs/intl;../../../../libs/hdf5/include;../../../windows_tools/includes;../../../fileio/includes;../../../commons/src/jni;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../jni;../cpp;../../../operations/includes;../../../string/includes;../../../system_env/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;HDF5_SCILAB_EXPORTS;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
        <StringPooling>true</StringPooling>
        <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
-       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
-       <PrecompiledHeader>
-       </PrecompiledHeader>
        <WarningLevel>Level3</WarningLevel>
-       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
        <MultiProcessorCompilation>true</MultiProcessorCompilation>
+       <DisableSpecificWarnings>4251;%(DisableSpecificWarnings)</DisableSpecificWarnings>
      </ClCompile>
      <PreLinkEvent>
        <Message>Make dependencies</Message>
        <Project>{ecffeb0c-1eda-45ee-9a10-b18143852e17}</Project>
        <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
      </ProjectReference>
++    <ProjectReference Include="..\..\..\operations\operations.vcxproj">
++      <Project>{1bb396f7-ce61-4cfc-9c22-266b2cfb2e74}</Project>
++    </ProjectReference>
      <ProjectReference Include="..\..\..\output_stream\src\c\output_stream.vcxproj">
        <Project>{a5911cd7-f8e8-440c-a23e-4843a0636f3a}</Project>
        <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
index 0000000,efb68c2..2803aaf
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,1160 +1,1159 @@@
+ /*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - 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
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+ extern "C"
+ {
+ #include <hdf5.h>
+ #include <string.h>
+ #include "gw_hdf5.h"
+ #include "MALLOC.h"
+ #include "Scierror.h"
+ #include "localization.h"
+ #include "sciprint.h"
+ #include "api_scilab.h"
+ #include "../../../call_scilab/includes/call_scilab.h"
+ #include "h5_fileManagement.h"
+ #include "h5_readDataFromFile_v1.h"
+ #include "h5_attributeConstants.h"
 -#include "intmacr2tree.h"
+ #include "expandPathVariable.h"
+ }
+ //#define PRINT_DEBUG
+ //#define TIME_DEBUG
+ static int iTab = 0;
+ static int iCloseList = 0;
+ void print_tree_v1(char *_pstMsg);
 -static bool import_variable_v1(int _iFile, char* _pstVarName);
 -static bool import_data_v1(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
 -static bool import_double_v1(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
 -static bool import_string_v1(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
 -static bool import_boolean_v1(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
 -static bool import_integer_v1(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
 -static bool import_sparse_v1(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
 -static bool import_boolean_sparse_v1(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
 -static bool import_poly_v1(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
 -static bool import_list_v1(int _iDatasetId, int _iVarType, int _iItemPos, int *_piAddress, char *_pstVarname);
 -static bool import_void_v1(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
 -static bool import_undefined_v1(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
 -
 -int sci_import_from_hdf5_v1(char *fname, unsigned long fname_len)
++static bool import_variable_v1(int* pvCtx, int _iFile, char* _pstVarName);
++static bool import_data_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
++static bool import_double_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
++static bool import_string_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
++static bool import_boolean_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
++static bool import_integer_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
++static bool import_sparse_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
++static bool import_boolean_sparse_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
++static bool import_poly_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
++static bool import_list_v1(int* pvCtx, int _iDatasetId, int _iVarType, int _iItemPos, int *_piAddress, char *_pstVarname);
++static bool import_void_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
++static bool import_undefined_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname);
++
++int sci_import_from_hdf5_v1(char *fname, int* pvApiCtx)
+ {
+     SciErr sciErr;
+     int* piAddr = NULL;
+     char* pstFilename = NULL;
+     char* pstExpandedFilename = NULL;
+     bool bImport = true;
+     int iSelectedVar = Rhs - 1;
+     checkInputArgumentAtLeast(pvApiCtx, 1);
+     CheckLhs(1, 1);
+     iCloseList = 0;
+     sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     if (getAllocatedSingleString(pvApiCtx, piAddr, &pstFilename))
+     {
+         Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), fname, 2);
+         return 1;
+     }
+     //open hdf5 file
+     pstExpandedFilename = expandPathVariable(pstFilename);
+     int iFile = openHDF5File(pstExpandedFilename, 0);
+     if (iFile < 0)
+     {
+         FREE(pstExpandedFilename);
+         FREE(pstFilename);
+         Scierror(999, _("%s: Unable to open file: %s\n"), fname, pstFilename);
+         return 1;
+     }
+     FREE(pstExpandedFilename);
+     FREE(pstFilename);
+     if (iSelectedVar)
+     {
+         //selected variable
+         char* pstVarName = NULL;
+         for (int i = 0 ; i < iSelectedVar ; i++)
+         {
+             sciErr = getVarAddressFromPosition(pvApiCtx, i + 2, &piAddr);
+             if (sciErr.iErr)
+             {
+                 printError(&sciErr, 0);
+                 return 1;
+             }
+             if (getAllocatedSingleString(pvApiCtx, piAddr, &pstVarName))
+             {
+                 Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), fname, i + 1);
+                 return 1;
+             }
 -            if (import_variable_v1(iFile, pstVarName) == false)
++            if (import_variable_v1(pvApiCtx, iFile, pstVarName) == false)
+             {
+                 bImport = false;
+                 break;
+             }
+             FREE(pstVarName);
+         }
+     }
+     else
+     {
+         //all variables
+         int iNbItem = 0;
+         iNbItem = getVariableNames_v1(iFile, NULL);
+         if (iNbItem != 0)
+         {
+             char **pstVarNameList = (char **)MALLOC(sizeof(char *) * iNbItem);
+             iNbItem = getVariableNames_v1(iFile, pstVarNameList);
+             //import all data
+             for (int i = 0; i < iNbItem; i++)
+             {
 -                if (import_variable_v1(iFile, pstVarNameList[i]) == false)
++                if (import_variable_v1(pvApiCtx, iFile, pstVarNameList[i]) == false)
+                 {
+                     bImport = false;
+                     break;
+                 }
+             }
+         }
+     }
+     //close the file
+     closeHDF5File(iFile);
+     int *piReturn = NULL;
+     sciErr = allocMatrixOfBoolean(pvApiCtx, Rhs + 1, 1, 1, &piReturn);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     if (bImport == true)
+     {
+         piReturn[0] = 1;
+     }
+     else
+     {
+         piReturn[0] = 0;
+     }
+     LhsVar(1) = Rhs + 1;
+     PutLhsVar();
+     //  printf("End gateway !!!\n");
+     return 0;
+ }
 -static bool import_variable_v1(int _iFile, char* _pstVarName)
++static bool import_variable_v1(int* pvCtx, int _iFile, char* _pstVarName)
+ {
+     int iDataSetId = getDataSetIdFromName_v1(_iFile, _pstVarName);
+     if (iDataSetId == 0)
+     {
+         return false;
+     }
 -    return import_data_v1(iDataSetId, 0, NULL, _pstVarName);
++    return import_data_v1(pvCtx, iDataSetId, 0, NULL, _pstVarName);
+ }
 -static bool import_data_v1(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
++static bool import_data_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
+ {
+     bool bRet = false;
+     //get var type
+     int iVarType = getScilabTypeFromDataSet_v1(_iDatasetId);
+     switch (iVarType)
+     {
+         case sci_matrix:
+         {
 -            bRet = import_double_v1(_iDatasetId, _iItemPos, _piAddress, _pstVarname);
++            bRet = import_double_v1(pvCtx, _iDatasetId, _iItemPos, _piAddress, _pstVarname);
+             break;
+         }
+         case sci_strings:
+         {
 -            bRet = import_string_v1(_iDatasetId, _iItemPos, _piAddress, _pstVarname);
++            bRet = import_string_v1(pvCtx, _iDatasetId, _iItemPos, _piAddress, _pstVarname);
+             break;
+         }
+         case sci_list:
+         case sci_tlist:
+         case sci_mlist:
+         {
 -            bRet = import_list_v1(_iDatasetId, iVarType, _iItemPos, _piAddress, _pstVarname);
++            bRet = import_list_v1(pvCtx, _iDatasetId, iVarType, _iItemPos, _piAddress, _pstVarname);
+             break;
+         }
+         case sci_boolean:
+         {
 -            bRet = import_boolean_v1(_iDatasetId, _iItemPos, _piAddress, _pstVarname);
++            bRet = import_boolean_v1(pvCtx, _iDatasetId, _iItemPos, _piAddress, _pstVarname);
+             break;
+         }
+         case sci_poly:
+         {
 -            bRet = import_poly_v1(_iDatasetId, _iItemPos, _piAddress, _pstVarname);
++            bRet = import_poly_v1(pvCtx, _iDatasetId, _iItemPos, _piAddress, _pstVarname);
+             break;
+         }
+         case sci_ints:
+         {
 -            bRet = import_integer_v1(_iDatasetId, _iItemPos, _piAddress, _pstVarname);
++            bRet = import_integer_v1(pvCtx, _iDatasetId, _iItemPos, _piAddress, _pstVarname);
+             break;
+         }
+         case sci_sparse:
+         {
 -            bRet = import_sparse_v1(_iDatasetId, _iItemPos, _piAddress, _pstVarname);
++            bRet = import_sparse_v1(pvCtx, _iDatasetId, _iItemPos, _piAddress, _pstVarname);
+             break;
+         }
+         case sci_boolean_sparse:
+         {
 -            bRet = import_boolean_sparse_v1(_iDatasetId, _iItemPos, _piAddress, _pstVarname);
++            bRet = import_boolean_sparse_v1(pvCtx, _iDatasetId, _iItemPos, _piAddress, _pstVarname);
+             break;
+         }
+         case sci_void:             //void item only on list variable
+         {
 -            bRet = import_void_v1(_iDatasetId, _iItemPos, _piAddress, _pstVarname);
++            bRet = import_void_v1(pvCtx, _iDatasetId, _iItemPos, _piAddress, _pstVarname);
+             break;
+         }
+         case sci_undefined:        //undefined item only on list variable
+         {
 -            bRet = import_undefined_v1(_iDatasetId, _iItemPos, _piAddress, _pstVarname);
++            bRet = import_undefined_v1(pvCtx, _iDatasetId, _iItemPos, _piAddress, _pstVarname);
+             break;
+         }
+         default:
+         {
+             Scierror(999, _("%s: Invalid HDF5 Scilab format.\n"), "import_from_hdf5");
+ #ifdef PRINT_DEBUG
+             {
+                 char pstMsg[512];
+                 sprintf(pstMsg, "Unknown type : %d", iVarType);
+                 print_tree(pstMsg);
+             }
+ #endif
+         }
+     }
+     return bRet;
+ }
 -static bool import_void_v1(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
++static bool import_void_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
+ {
+     SciErr sciErr;
+     if (_piAddress)
+     {
 -        sciErr = createVoidInNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos);
++        sciErr = createVoidInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos);
+     }
+     else
+     {
+         return false;
+     }
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return false;
+     }
+     return true;
+ }
 -static bool import_undefined_v1(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
++static bool import_undefined_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
+ {
+     SciErr sciErr;
+     if (_piAddress)
+     {
 -        sciErr = createUndefinedInNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos);
++        sciErr = createUndefinedInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos);
+     }
+     else
+     {
+         return false;
+     }
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return false;
+     }
+     return true;
+ }
 -static bool import_double_v1(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
++static bool import_double_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
+ {
+     int iRet = 0;
+     double *pdblReal = NULL;
+     double *pdblImg = NULL;
+     int iRows = 0;
+     int iCols = 0;
+     int iComplex = 0;
+     SciErr sciErr;
+ #ifdef TIME_DEBUG
+     LARGE_INTEGER iStart, iEnd, iFreq;
+     QueryPerformanceFrequency(&iFreq);
+     QueryPerformanceCounter(&iStart);
+ #endif
+     iRet = getDatasetDims_v1(_iDatasetId, &iRows, &iCols);
+     iComplex = isComplexData_v1(_iDatasetId);
+     if (iRet)
+     {
+         return false;
+     }
+     if (iRows * iCols != 0)
+     {
+         if (iComplex)
+         {
+             pdblReal = (double *)MALLOC(iRows * iCols * sizeof(double));
+             pdblImg = (double *)MALLOC(iRows * iCols * sizeof(double));
+             iRet = readDoubleComplexMatrix_v1(_iDatasetId, iRows, iCols, pdblReal, pdblImg);
+         }
+         else
+         {
+             pdblReal = (double *)MALLOC(iRows * iCols * sizeof(double));
+             iRet = readDoubleMatrix_v1(_iDatasetId, iRows, iCols, pdblReal);
+         }
+         if (iRet)
+         {
+             return false;
+         }
+     }
+     else
+     {
+         /*bug 7224 : to close dataset */
+         iRet = readEmptyMatrix_v1(_iDatasetId);
+         if (iRet)
+         {
+             return false;
+         }
+     }
+     if (_piAddress == NULL)
+     {
+         if (iComplex)
+         {
 -            sciErr = createNamedComplexMatrixOfDouble(pvApiCtx, _pstVarname, iRows, iCols, pdblReal, pdblImg);
++            sciErr = createNamedComplexMatrixOfDouble(pvCtx, _pstVarname, iRows, iCols, pdblReal, pdblImg);
+         }
+         else
+         {
 -            sciErr = createNamedMatrixOfDouble(pvApiCtx, _pstVarname, iRows, iCols, pdblReal);
++            sciErr = createNamedMatrixOfDouble(pvCtx, _pstVarname, iRows, iCols, pdblReal);
+         }
+     }
+     else                        //if not null this variable is in a list
+     {
+         if (iComplex)
+         {
 -            sciErr = createComplexMatrixOfDoubleInNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, pdblReal, pdblImg);
++            sciErr = createComplexMatrixOfDoubleInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, pdblReal, pdblImg);
+         }
+         else
+         {
 -            sciErr = createMatrixOfDoubleInNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, pdblReal);
++            sciErr = createMatrixOfDoubleInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, pdblReal);
+         }
+     }
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return false;
+     }
+ #ifdef PRINT_DEBUG
+     char pstMsg[512];
+     sprintf(pstMsg, "double_%d (%d x %d)", _iItemPos, iRows, iCols);
+     print_tree(pstMsg);
+ #endif
+     if (pdblReal)
+     {
+         FREE(pdblReal);
+     }
+     if (pdblImg)
+     {
+         FREE(pdblImg);
+     }
+     if (iRet)
+     {
+         return false;
+     }
+ #ifdef TIME_DEBUG
+     QueryPerformanceCounter(&iEnd);
+     double dblTime = ((iEnd.QuadPart - iStart.QuadPart) * 1000.0) / iFreq.QuadPart;
+     printf("Total Double : %0.3f ms\n\n", dblTime);
+ #endif
+     return true;
+ }
 -static bool import_string_v1(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
++static bool import_string_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
+ {
+     int iRet = 0;
+     int i = 0;
+     int iRows = 0;
+     int iCols = 0;
+     char **pstData = NULL;
+     SciErr sciErr;
+ #ifdef TIME_DEBUG
+     LARGE_INTEGER iStart1, iEnd1, iStart2, iEnd2, iStart3, iEnd3, iFreq;
+     QueryPerformanceFrequency(&iFreq);
+     QueryPerformanceCounter(&iStart1);
+ #endif
+     iRet = getDatasetDims_v1(_iDatasetId, &iRows, &iCols);
+     if (iRet)
+     {
+         return false;
+     }
+     pstData = (char **)MALLOC(iRows * iCols * sizeof(char *));
+ #ifdef TIME_DEBUG
+     QueryPerformanceCounter(&iStart1);
+ #endif
+     iRet = readStringMatrix_v1(_iDatasetId, iRows, iCols, pstData);
+     if (iRet)
+     {
+         return false;
+     }
+ #ifdef TIME_DEBUG
+     QueryPerformanceCounter(&iEnd1);
+ #endif
+ #ifdef TIME_DEBUG
+     QueryPerformanceCounter(&iStart2);
+ #endif
+     if (_piAddress == NULL)
+     {
 -        sciErr = createNamedMatrixOfString(pvApiCtx, _pstVarname, iRows, iCols, pstData);
++        sciErr = createNamedMatrixOfString(pvCtx, _pstVarname, iRows, iCols, pstData);
+     }
+     else                        //if not null this variable is in a list
+     {
 -        sciErr = createMatrixOfStringInNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, pstData);
++        sciErr = createMatrixOfStringInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, pstData);
+     }
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return false;
+     }
+ #ifdef TIME_DEBUG
+     QueryPerformanceCounter(&iEnd2);
+     QueryPerformanceCounter(&iStart3);
+ #endif
+ #ifdef PRINT_DEBUG
+     char pstMsg[512];
+     sprintf(pstMsg, "string_%d (%d x %d)", _iItemPos, iRows, iCols);
+     print_tree(pstMsg);
+ #endif
+     for (i = 0; i < iRows * iCols; i++)
+     {
+         FREE(pstData[i]);
+     }
+     FREE(pstData);
+     if (iRet)
+     {
+         return false;
+     }
+ #ifdef TIME_DEBUG
+     QueryPerformanceCounter(&iEnd3);
+     //double dblTime    =((iEnd1.QuadPart - iStart1.QuadPart) * 1000.0) / iFreq.QuadPart;
+     //printf("HDF5 : %0.3f ms\n", dblTime);
+     //dblTime   =((iEnd2.QuadPart - iStart2.QuadPart) * 1000.0) / iFreq.QuadPart;
+     //printf("Stack : %0.3f ms\n", dblTime);
+     //dblTime   =((iEnd3.QuadPart - iStart3.QuadPart) * 1000.0) / iFreq.QuadPart;
+     //printf("Clear : %0.3f ms\n", dblTime);
+     double dblTime = ((iEnd3.QuadPart - iStart1.QuadPart) * 1000.0) / iFreq.QuadPart;
+     printf("Total String: %0.3f ms\n\n", dblTime);
+ #endif
+     return true;
+ }
 -static bool import_integer_v1(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
++static bool import_integer_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
+ {
+     int iRet = 0;
+     int iRows = 0;
+     int iCols = 0;
+     int iPrec = 0;
+     SciErr sciErr;
+     iRet = getDatasetDims_v1(_iDatasetId, &iRows, &iCols);
+     if (iRet)
+     {
+         return false;
+     }
+     iRet = getDatasetPrecision_v1(_iDatasetId, &iPrec);
+     if (iRet)
+     {
+         return false;
+     }
+     switch (iPrec)
+     {
+         case SCI_INT8:
+         {
+             char *pcData = NULL;
+             pcData = (char *)MALLOC(sizeof(char) * iRows * iCols);
+             iRet = readInteger8Matrix_v1(_iDatasetId, iRows, iCols, pcData);
+             if (iRet)
+             {
+                 return false;
+             }
+             if (_piAddress == NULL)
+             {
 -                sciErr = createNamedMatrixOfInteger8(pvApiCtx, _pstVarname, iRows, iCols, pcData);
++                sciErr = createNamedMatrixOfInteger8(pvCtx, _pstVarname, iRows, iCols, pcData);
+             }
+             else
+             {
 -                sciErr = createMatrixOfInteger8InNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, pcData);
++                sciErr = createMatrixOfInteger8InNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, pcData);
+             }
+         }
+         break;
+         case SCI_UINT8:
+         {
+             unsigned char *pucData = NULL;
+             pucData = (unsigned char *)MALLOC(sizeof(unsigned char) * iRows * iCols);
+             iRet = readUnsignedInteger8Matrix_v1(_iDatasetId, iRows, iCols, pucData);
+             if (iRet)
+             {
+                 return false;
+             }
+             if (_piAddress == NULL)
+             {
 -                sciErr = createNamedMatrixOfUnsignedInteger8(pvApiCtx, _pstVarname, iRows, iCols, pucData);
++                sciErr = createNamedMatrixOfUnsignedInteger8(pvCtx, _pstVarname, iRows, iCols, pucData);
+             }
+             else
+             {
 -                sciErr = createMatrixOfUnsignedInteger8InNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, pucData);
++                sciErr = createMatrixOfUnsignedInteger8InNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, pucData);
+             }
+         }
+         break;
+         case SCI_INT16:
+         {
+             short *psData = NULL;
+             psData = (short *)MALLOC(sizeof(short) * iRows * iCols);
+             iRet = readInteger16Matrix_v1(_iDatasetId, iRows, iCols, psData);
+             if (iRet)
+             {
+                 return false;
+             }
+             if (_piAddress == NULL)
+             {
 -                sciErr = createNamedMatrixOfInteger16(pvApiCtx, _pstVarname, iRows, iCols, psData);
++                sciErr = createNamedMatrixOfInteger16(pvCtx, _pstVarname, iRows, iCols, psData);
+             }
+             else
+             {
 -                sciErr = createMatrixOfInteger16InNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, psData);
++                sciErr = createMatrixOfInteger16InNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, psData);
+             }
+         }
+         break;
+         case SCI_UINT16:
+         {
+             unsigned short *pusData = NULL;
+             pusData = (unsigned short *)MALLOC(sizeof(unsigned short) * iRows * iCols);
+             iRet = readUnsignedInteger16Matrix_v1(_iDatasetId, iRows, iCols, pusData);
+             if (iRet)
+             {
+                 return false;
+             }
+             if (_piAddress == NULL)
+             {
 -                sciErr = createNamedMatrixOfUnsignedInteger16(pvApiCtx, _pstVarname, iRows, iCols, pusData);
++                sciErr = createNamedMatrixOfUnsignedInteger16(pvCtx, _pstVarname, iRows, iCols, pusData);
+             }
+             else
+             {
 -                sciErr = createMatrixOfUnsignedInteger16InNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, pusData);
++                sciErr = createMatrixOfUnsignedInteger16InNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, pusData);
+             }
+         }
+         break;
+         case SCI_INT32:
+         {
+             int *piData = NULL;
+             piData = (int *)MALLOC(sizeof(int) * iRows * iCols);
+             iRet = readInteger32Matrix_v1(_iDatasetId, iRows, iCols, piData);
+             if (iRet)
+             {
+                 return false;
+             }
+             if (_piAddress == NULL)
+             {
 -                sciErr = createNamedMatrixOfInteger32(pvApiCtx, _pstVarname, iRows, iCols, piData);
++                sciErr = createNamedMatrixOfInteger32(pvCtx, _pstVarname, iRows, iCols, piData);
+             }
+             else
+             {
 -                sciErr = createMatrixOfInteger32InNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, piData);
++                sciErr = createMatrixOfInteger32InNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, piData);
+             }
+         }
+         break;
+         case SCI_UINT32:
+         {
+             unsigned int *puiData = NULL;
+             puiData = (unsigned int *)MALLOC(sizeof(unsigned int) * iRows * iCols);
+             iRet = readUnsignedInteger32Matrix_v1(_iDatasetId, iRows, iCols, puiData);
+             if (iRet)
+             {
+                 return false;
+             }
+             if (_piAddress == NULL)
+             {
 -                sciErr = createNamedMatrixOfUnsignedInteger32(pvApiCtx, _pstVarname, iRows, iCols, puiData);
++                sciErr = createNamedMatrixOfUnsignedInteger32(pvCtx, _pstVarname, iRows, iCols, puiData);
+             }
+             else
+             {
 -                sciErr = createMatrixOfUnsignedInteger32InNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, puiData);
++                sciErr = createMatrixOfUnsignedInteger32InNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, puiData);
+             }
+         }
+         break;
+         case SCI_INT64:
+         {
+ #ifdef __SCILAB_INT64__
+             long long *pllData = NULL;
+             pllData = (long long *)MALLOC(sizeof(long long) * iRows * iCols);
+             iRet = readInteger64Matrix_v1(_iDatasetId, iRows, iCols, pllData);
+             if (iRet)
+             {
+                 return false;
+             }
+             if (_piAddress == NULL)
+             {
 -                sciErr = createNamedMatrixOfInteger64(_pstVarname, iRows, iCols, pllData);
++                sciErr = createNamedMatrixOfInteger64(pvCtx, _pstVarname, iRows, iCols, pllData);
+             }
+             else
+             {
 -                sciErr = createMatrixOfInteger64InNamedList(_pstVarname, _piAddress, _iItemPos, iRows, iCols, pllData);
++                sciErr = createMatrixOfInteger64InNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, pllData);
+             }
+ #else
+             return false;
+ #endif
+         }
+         break;
+         case SCI_UINT64:
+         {
+ #ifdef __SCILAB_INT64__
+             unsigned long long *pullData = NULL;
+             pullData = (unsigned long long *)MALLOC(sizeof(unsigned long long) * iRows * iCols);
+             iRet = readUnsignedInteger64Matrix_v1(_iDatasetId, iRows, iCols, pullData);
+             if (iRet)
+             {
+                 return false;
+             }
+             if (_piAddress == NULL)
+             {
 -                sciErr = createNamedMatrixOfUnsignedInteger64(_pstVarname, iRows, iCols, pullData);
++                sciErr = createNamedMatrixOfUnsignedInteger64(pvCtx, _pstVarname, iRows, iCols, pullData);
+             }
+             else
+             {
 -                sciErr = createMatrixOfUnsignedInteger64InNamedList(_pstVarname, _piAddress, _iItemPos, iRows, iCols, pullData);
++                sciErr = createMatrixOfUnsignedInteger64InNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, pullData);
+             }
+ #else
+             return false;
+ #endif
+         }
+         break;
+         default:
+             return false;
+     }
+ #ifdef PRINT_DEBUG
+     char pstMsg[512];
+     sprintf(pstMsg, "integer_%d (%d x %d)", _iItemPos, iRows, iCols);
+     print_tree(pstMsg);
+ #endif
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return false;
+     }
+     return true;
+ }
 -static bool import_boolean_v1(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
++static bool import_boolean_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
+ {
+     int iRet = 0;
+     int *piData = NULL;
+     int iRows = 0;
+     int iCols = 0;
+     SciErr sciErr;
+     iRet = getDatasetDims_v1(_iDatasetId, &iRows, &iCols);
+     if (iRet)
+     {
+         return false;
+     }
+     if (iRows * iCols != 0)
+     {
+         piData = (int *)MALLOC(iRows * iCols * sizeof(int));
+         iRet = readBooleanMatrix_v1(_iDatasetId, iRows, iCols, piData);
+         if (iRet)
+         {
+             return false;
+         }
+     }
+     if (_piAddress == NULL)
+     {
 -        sciErr = createNamedMatrixOfBoolean(pvApiCtx, _pstVarname, iRows, iCols, piData);
++        sciErr = createNamedMatrixOfBoolean(pvCtx, _pstVarname, iRows, iCols, piData);
+     }
+     else                        //if not null this variable is in a list
+     {
 -        sciErr = createMatrixOfBooleanInNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, piData);
++        sciErr = createMatrixOfBooleanInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, piData);
+     }
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return false;
+     }
+ #ifdef PRINT_DEBUG
+     char pstMsg[512];
+     sprintf(pstMsg, "boolean_%d (%d x %d)", _iItemPos, iRows, iCols);
+     print_tree(pstMsg);
+ #endif
+     if (piData)
+     {
+         FREE(piData);
+     }
+     if (iRet)
+     {
+         return false;
+     }
+     return true;
+ }
 -static bool import_poly_v1(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
++static bool import_poly_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
+ {
+     int iRet = 0;
+     int i = 0;
+     int iRows = 0;
+     int iCols = 0;
+     int iComplex = 0;
+     char pstVarName[64] = { 0 };
+     double **pdblReal = NULL;
+     double **pdblImg = NULL;
+     int *piNbCoef = NULL;
+     SciErr sciErr;
+     iRet = getDatasetDims_v1(_iDatasetId, &iRows, &iCols);
+     if (iRet)
+     {
+         return false;
+     }
+     iComplex = isComplexData_v1(_iDatasetId);
+     if (iComplex)
+     {
+         piNbCoef = (int *)MALLOC(iRows * iCols * sizeof(int));
+         pdblReal = (double **)MALLOC(iRows * iCols * sizeof(double *));
+         pdblImg = (double **)MALLOC(iRows * iCols * sizeof(double *));
+         iRet = readPolyComplexMatrix_v1(_iDatasetId, pstVarName, iRows, iCols, piNbCoef, pdblReal, pdblImg);
+     }
+     else
+     {
+         piNbCoef = (int *)MALLOC(iRows * iCols * sizeof(int));
+         pdblReal = (double **)MALLOC(iRows * iCols * sizeof(double *));
+         iRet = readPolyMatrix_v1(_iDatasetId, pstVarName, iRows, iCols, piNbCoef, pdblReal);
+     }
+     if (iRet)
+     {
+         return false;
+     }
+     if (_piAddress == NULL)
+     {
+         if (iComplex)
+         {
 -            sciErr = createNamedComplexMatrixOfPoly(pvApiCtx, _pstVarname, pstVarName, iRows, iCols, piNbCoef, pdblReal, pdblImg);
++            sciErr = createNamedComplexMatrixOfPoly(pvCtx, _pstVarname, pstVarName, iRows, iCols, piNbCoef, pdblReal, pdblImg);
+         }
+         else
+         {
 -            sciErr = createNamedMatrixOfPoly(pvApiCtx, _pstVarname, pstVarName, iRows, iCols, piNbCoef, pdblReal);
++            sciErr = createNamedMatrixOfPoly(pvCtx, _pstVarname, pstVarName, iRows, iCols, piNbCoef, pdblReal);
+         }
+     }
+     else                        //if not null this variable is in a list
+     {
+         if (iComplex)
+         {
+             sciErr =
 -                createComplexMatrixOfPolyInNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, pstVarName, iRows, iCols, piNbCoef, pdblReal,
++                createComplexMatrixOfPolyInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, pstVarName, iRows, iCols, piNbCoef, pdblReal,
+                         pdblImg);
+         }
+         else
+         {
 -            sciErr = createMatrixOfPolyInNamedList(pvApiCtx, _pstVarname, _piAddress, _iItemPos, pstVarName, iRows, iCols, piNbCoef, pdblReal);
++            sciErr = createMatrixOfPolyInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, pstVarName, iRows, iCols, piNbCoef, pdblReal);
+         }
+     }
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return false;
+     }
+ #ifdef PRINT_DEBUG
+     char pstMsg[512];
+     sprintf(pstMsg, "poly_%d (%d x %d)", _iItemPos, iRows, iCols);
+     print_tree(pstMsg);
+ #endif
+     for (i = 0; i < iRows * iCols; i++)
+     {
+         FREE(pdblReal[i]);
+     }
+     FREE(pdblReal);
+     FREE(piNbCoef);
+     if (iRet)
+     {
+         return false;
+     }
+     return true;
+ }
 -static bool import_sparse_v1(int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
++static bool import_sparse_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
+ {
+     int iRet = 0;
+     int iRows = 0;
+     int iCols = 0;
+     int iComplex = 0;
+     double *pdblReal = NULL;
+     double *pdblImg = NULL;
+     int iNbItem = 0;
+     int *piNbItemRow = NULL;