add system_property("property_name")
Allan Cornet [Sun, 13 May 2007 06:06:16 +0000 (06:06 +0000)]
add ver()
add JRE_path()

+ help files

17 files changed:
scilab/modules/jvm/Makefile.am
scilab/modules/jvm/etc/jvm.start
scilab/modules/jvm/help/en_US/jre_path.xml [new file with mode: 0644]
scilab/modules/jvm/help/en_US/system_getproperty.xml [new file with mode: 0644]
scilab/modules/jvm/help/en_US/ver.xml [new file with mode: 0644]
scilab/modules/jvm/help/en_US/with_embedded_jre.xml [new file with mode: 0644]
scilab/modules/jvm/includes/gw_jvm.h
scilab/modules/jvm/libjvm.vcproj
scilab/modules/jvm/macros/buildmacros.sce
scilab/modules/jvm/macros/jre_path.sci [new file with mode: 0644]
scilab/modules/jvm/macros/ver.sci [new file with mode: 0644]
scilab/modules/jvm/sci_gateway/c/gw_jvm.c
scilab/modules/jvm/sci_gateway/c/sci_system_getproperty.c [new file with mode: 0644]
scilab/modules/jvm/sci_gateway/jvm_gateway.xml
scilab/modules/jvm/src/c/getClasspath.c
scilab/modules/jvm/src/c/system_getproperty.c [new file with mode: 0644]
scilab/modules/jvm/src/c/system_getproperty.h [new file with mode: 0644]

index 35d039d..42b4867 100644 (file)
@@ -9,13 +9,14 @@ src/c/JVM_Unix.c \
 src/c/JVM.c \
 src/c/JniUtils.c \
 src/c/addToClasspath.c \
-src/c/getClasspath.c
+src/c/getClasspath.c \
+src/c/system_getproperty.c
 
 
 GATEWAY_C_SOURCES = sci_gateway/c/gw_jvm.c \
 sci_gateway/c/sci_jvm_version.c \
 sci_gateway/c/sci_with_embedded_jre.c \
-sci_gateway/c/sci_javaclasspath.c
+sci_gateway/c/sci_system_getproperty.c
 
 
 libscijvm_la_CFLAGS=  $(JAVA_JNI_INCLUDE) -I$(top_srcdir)/libs/MALLOC/includes/ -Iincludes/ -Isrc/c
index cd5201d..def53e0 100644 (file)
@@ -3,8 +3,8 @@
 // Copyright INRIA 2006
 // ====================================================================
 //Load  functions librarie
-//load('SCI/modules/jvm/macros/lib');
 if (getscilabmode()<>'NWNI') then
+  load('SCI/modules/jvm/macros/lib');
   javaclasspath(SCI+'/java/jar/modules/jvm.jar')
 end  
 // ====================================================================
diff --git a/scilab/modules/jvm/help/en_US/jre_path.xml b/scilab/modules/jvm/help/en_US/jre_path.xml
new file mode 100644 (file)
index 0000000..aa1408c
--- /dev/null
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!DOCTYPE MAN SYSTEM "../../../../modules/helptools/help.dtd">\r
+<MAN>\r
+  <LANGUAGE>eng</LANGUAGE>\r
+\r
+  <TITLE>jre_path</TITLE>\r
+\r
+  <TYPE>Scilab Function</TYPE>\r
+\r
+  <DATE>$LastChangedDate: 2006-12-12 09:26:08 +0200$</DATE>\r
+\r
+  <SHORT_DESCRIPTION name="jre_path">returns Java Runtime Environment used by Scilab</SHORT_DESCRIPTION>\r
+\r
+  <CALLING_SEQUENCE>\r
+    <CALLING_SEQUENCE_ITEM>p=jre_path()</CALLING_SEQUENCE_ITEM>\r
+  </CALLING_SEQUENCE>\r
+\r
+  <PARAM>\r
+    <PARAM_INDENT>\r
+      <PARAM_ITEM>\r
+        <PARAM_NAME>p</PARAM_NAME>\r
+\r
+        <PARAM_DESCRIPTION>\r
+          <SP>: a string path of JRE</SP>\r
+        </PARAM_DESCRIPTION>\r
+      </PARAM_ITEM>\r
+    </PARAM_INDENT>\r
+  </PARAM>\r
+\r
+  <DESCRIPTION>\r
+    <P>returns Java Runtime Environment used by Scilab.</P>\r
+  </DESCRIPTION>\r
+\r
+  <SEE_ALSO>\r
+    <SEE_ALSO_ITEM>\r
+      <LINK>system_getproperty</LINK>\r
+    </SEE_ALSO_ITEM>\r
+  </SEE_ALSO>\r
+\r
+  <AUTHOR>A.C</AUTHOR>\r
+</MAN>
\ No newline at end of file
diff --git a/scilab/modules/jvm/help/en_US/system_getproperty.xml b/scilab/modules/jvm/help/en_US/system_getproperty.xml
new file mode 100644 (file)
index 0000000..b4e8a7c
--- /dev/null
@@ -0,0 +1,242 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE MAN SYSTEM "../../../../modules/helptools/help.dtd">
+<MAN>
+  <LANGUAGE>eng</LANGUAGE>
+
+  <TITLE>system_getproperty</TITLE>
+
+  <TYPE>Scilab Function</TYPE>
+
+  <DATE>$LastChangedDate: 2007-05-10 09:26:08 +0200$</DATE>
+
+  <SHORT_DESCRIPTION name="system_getproperty">gets the system property
+  indicated by a specified key.</SHORT_DESCRIPTION>
+
+  <CALLING_SEQUENCE>
+    <CALLING_SEQUENCE_ITEM>res=system_getproperty(key)</CALLING_SEQUENCE_ITEM>
+
+    <CALLING_SEQUENCE_ITEM>javaclasspath(path)</CALLING_SEQUENCE_ITEM>
+  </CALLING_SEQUENCE>
+
+  <PARAM>
+    <PARAM_INDENT>
+      <PARAM_ITEM>
+        <PARAM_NAME>res</PARAM_NAME>
+
+        <PARAM_DESCRIPTION>
+          <SP>: a string value</SP>
+        </PARAM_DESCRIPTION>
+      </PARAM_ITEM>
+
+      <PARAM_ITEM>
+        <PARAM_NAME>key</PARAM_NAME>
+
+        <PARAM_DESCRIPTION>
+          <SP>: a string</SP>
+        </PARAM_DESCRIPTION>
+      </PARAM_ITEM>
+    </PARAM_INDENT>
+  </PARAM>
+
+  <DESCRIPTION>
+    <P>gets the system property indicated by a specified key.</P>
+
+    <TABLE>
+      
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>java.version</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>Java Runtime Environment version</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>java.vendor</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>Java Runtime Environment vendor</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>java.vendor.url</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>Java vendor URL</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>java.home</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>Java installation directory</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>java.vm.specification.version</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>Java Virtual Machine specification version</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>java.vm.specification.vendor</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>Java Virtual Machine specification vendor</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>java.vm.specification.name</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>Java Virtual Machine specification name</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>java.vm.version</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>Java Virtual Machine implementation version</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>java.vm.vendor</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>Java Virtual Machine implementation vendor</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>java.vm.name</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>Java Virtual Machine implementation name</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>java.specification.version</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>Java Runtime Environment specification version</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>java.specification.vendor</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>Java Runtime Environment specification vendor</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>java.specification.name</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>Java Runtime Environment specification name</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>java.class.version</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>Java class format version number</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>java.class.path</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>Java class path</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>java.library.path</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>List of paths to search when loading libraries</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>java.io.tmpdir</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>Default temp file path</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>java.compiler</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>Name of JIT compiler to use</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>java.ext.dirs</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>Path of extension directory or directories</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>os.name</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>Operating system name</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>os.arch</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>Operating system architecture</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>os.version</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>Operating system version</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>file.separator</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>File separator ("/" on UNIX)</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>path.separator</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>Path separator (":" on UNIX)</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>line.separator Line separator</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>("\n" on UNIX)</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>user.name</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>User's account name</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>user.home</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>User's home directory</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+
+      <TABLE_NEW_ROW>
+        <TABLE_NEW_COLUMN>user.dir</TABLE_NEW_COLUMN>
+        <TABLE_NEW_COLUMN>User's current working directory</TABLE_NEW_COLUMN>
+      </TABLE_NEW_ROW> 
+      
+    </TABLE>
+  </DESCRIPTION>
+
+  <EXAMPLE><![CDATA[system_getproperty('awt.toolkit')
+system_getproperty('file.encoding')
+system_getproperty('file.encoding.pkg')
+system_getproperty('java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment')
+system_getproperty('java.awt.printerjob=sun.awt.windows.WPrinterJob')
+system_getproperty('java.class.path')
+system_getproperty('java.class.version')
+system_getproperty('java.endorsed.dirs')
+system_getproperty('java.ext.dirs')
+system_getproperty('java.home')
+system_getproperty('java.io.tmpdir')
+system_getproperty('java.library.path')
+system_getproperty('java.runtime.name')
+system_getproperty('java.runtime.version')
+system_getproperty('java.specification.name')
+system_getproperty('java.specification.vendor')
+system_getproperty('java.specification.version')
+system_getproperty('java.vendor')
+system_getproperty('java.vendor.url')
+system_getproperty('java.vendor.url.bug')
+system_getproperty('java.version')
+system_getproperty('java.vm.info')
+system_getproperty('java.vm.name')
+system_getproperty('java.vm.specification.name')
+system_getproperty('java.vm.specification.vendor')
+system_getproperty('java.vm.specification.version')
+system_getproperty('java.vm.vendor')
+system_getproperty('java.vm.version')
+system_getproperty('line.separator')
+system_getproperty('os.arch')
+system_getproperty('os.name')
+system_getproperty('os.version')
+system_getproperty('path.separator')
+system_getproperty('sun.arch.data.model')
+system_getproperty('sun.boot.class.path')
+system_getproperty('sun.boot.library.path')
+system_getproperty('sun.cpu.endian')
+system_getproperty('sun.cpu.isalist')
+system_getproperty('sun.desktop')
+system_getproperty('sun.io.unicode.encoding')
+system_getproperty('sun.jnu.encoding')
+system_getproperty('sun.management.compiler')
+system_getproperty('sun.os.patch.level')
+system_getproperty('user.country')
+system_getproperty('user.dir')
+system_getproperty('user.home')
+system_getproperty('user.language')
+system_getproperty('user.name')
+system_getproperty('user.timezone')
+system_getproperty('user.variant')
+]]></EXAMPLE>
+
+  <AUTHOR>A.C</AUTHOR>
+</MAN>
\ No newline at end of file
diff --git a/scilab/modules/jvm/help/en_US/ver.xml b/scilab/modules/jvm/help/en_US/ver.xml
new file mode 100644 (file)
index 0000000..0386553
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE MAN SYSTEM "../../../../modules/helptools/help.dtd">
+<MAN>
+  <LANGUAGE>eng</LANGUAGE>
+
+  <TITLE>ver</TITLE>
+
+  <TYPE>Scilab Function</TYPE>
+
+  <DATE>$LastChangedDate: 2007-05-10 09:26:08 +0200$</DATE>
+
+  <SHORT_DESCRIPTION name="ver">Version information for Scilab</SHORT_DESCRIPTION>
+
+  <CALLING_SEQUENCE>
+    <CALLING_SEQUENCE_ITEM>ver()</CALLING_SEQUENCE_ITEM>
+  </CALLING_SEQUENCE>
+
+  
+  <DESCRIPTION>
+    <P>Version information for Scilab.</P>
+  </DESCRIPTION>
+
+  <EXAMPLE><![CDATA[ver
+]]></EXAMPLE>
+
+  <AUTHOR>A.C</AUTHOR>
+</MAN>
diff --git a/scilab/modules/jvm/help/en_US/with_embedded_jre.xml b/scilab/modules/jvm/help/en_US/with_embedded_jre.xml
new file mode 100644 (file)
index 0000000..0fab304
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE MAN SYSTEM "../../../../modules/helptools/help.dtd">
+<MAN>
+  <LANGUAGE>eng</LANGUAGE>
+
+  <TITLE>with_embedded_jre</TITLE>
+
+  <TYPE>Scilab Function</TYPE>
+
+  <DATE>$LastChangedDate: 2007-05-10 09:26:08 +0200$</DATE>
+
+  <SHORT_DESCRIPTION name="with_embedded_jre">checks if scilab uses a embedded JRE</SHORT_DESCRIPTION>
+
+  <CALLING_SEQUENCE>
+    <CALLING_SEQUENCE_ITEM>res=with_embedded_jre()</CALLING_SEQUENCE_ITEM>
+  </CALLING_SEQUENCE>
+
+  <PARAM>
+    <PARAM_INDENT>
+      <PARAM_ITEM>
+        <PARAM_NAME>res</PARAM_NAME>
+
+        <PARAM_DESCRIPTION>
+          <SP>: a boolean</SP>
+        </PARAM_DESCRIPTION>
+      </PARAM_ITEM>
+    </PARAM_INDENT>
+  </PARAM>
+
+  <DESCRIPTION>
+    <P>checks if scilab uses a embedded JRE.</P>
+  </DESCRIPTION>
+
+  <EXAMPLE><![CDATA[res=with_embedded_jre();
+]]></EXAMPLE>
+
+  <AUTHOR>A.C</AUTHOR>
+</MAN>
index 76061f5..4d68210 100644 (file)
@@ -13,7 +13,7 @@ int C2F(gw_jvm)(void);
 /* Declaration of all the profile function declared and */\r
 /* used in sci_gateway */\r
 int C2F(sci_with_embedded_jre) _PARAMS((char *fname,unsigned long fname_len));\r
-int C2F(sci_jvm_version) _PARAMS((char *fname,unsigned long fname_len));\r
+int C2F(sci_system_getproperty) _PARAMS((char *fname,unsigned long fname_len));\r
 int C2F(sci_javaclasspath) _PARAMS((char *fname,unsigned long fname_len));\r
 /*-----------------------------------------------------------------------------------*/\r
 #endif /*  __GW_JVM_H__ */\r
index e3909eb..49213f6 100644 (file)
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\sci_gateway\c\sci_jvm_version.c"\r
+                               RelativePath=".\sci_gateway\c\sci_system_getproperty.c"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath=".\src\c\system_getproperty.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath=".\src\c\TerminateJVM.c"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath=".\src\c\system_getproperty.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath=".\includes\TerminateJVM.h"\r
                                >\r
                        </File>\r
index 18aeff4..df3d91d 100644 (file)
@@ -1,5 +1,5 @@
 //------------------------------------
 // Allan CORNET INRIA 2005
 //------------------------------------
-//genlib('jvmlib','SCI/modules/jvm/macros');
+genlib('jvmlib','SCI/modules/jvm/macros');
 //------------------------------------
diff --git a/scilab/modules/jvm/macros/jre_path.sci b/scilab/modules/jvm/macros/jre_path.sci
new file mode 100644 (file)
index 0000000..870cde1
--- /dev/null
@@ -0,0 +1,9 @@
+//===============================\r
+// Allan CORNET INRIA 2007\r
+//===============================\r
+// returns JRE path\r
+//===============================\r
+function pathofjre=jre_path()\r
+  pathofjre=system_getproperty('java.home');\r
+endfunction\r
+//===============================\r
diff --git a/scilab/modules/jvm/macros/ver.sci b/scilab/modules/jvm/macros/ver.sci
new file mode 100644 (file)
index 0000000..10c4190
--- /dev/null
@@ -0,0 +1,18 @@
+//===============================\r
+// Allan CORNET INRIA 2007\r
+//===============================\r
+//Version information for Scilab\r
+//===============================\r
+function ver()\r
+  mprintf('\n');\r
+  mprintf('-------------------------------------------------------------------------------\n');\r
+  sciver=getversion('scilab');\r
+  mprintf('Scilab Version %d.%d.%d.%d\n',sciver(1),sciver(2),sciver(3),sciver(4));\r
+  mprintf('Operating System: %s %s\n',system_getproperty('os.name'),system_getproperty('os.version'));\r
+  mprintf('Java VM Version: Java %s with %s\n%s %s\n', system_getproperty('java.vm.version'), ..\r
+    system_getproperty('java.vm.specification.vendor'), ..\r
+    system_getproperty('java.vm.name'), ..\r
+    system_getproperty('java.vm.info'));\r
+  mprintf('-------------------------------------------------------------------------------\n');\r
+endfunction\r
+//===============================\r
index 7e03ba1..b532999 100644 (file)
@@ -24,7 +24,7 @@ typedef struct table_struct
 static jvmTable Tab[]=\r
 {\r
        {C2F(sci_with_embedded_jre),"with_embedded_jre"},\r
-       {C2F(sci_jvm_version),"jvm_version"},\r
+       {C2F(sci_system_getproperty),"system_getproperty"},\r
        {C2F(sci_javaclasspath),"javaclasspath"}\r
 };\r
 /*-----------------------------------------------------------------------------------*/\r
diff --git a/scilab/modules/jvm/sci_gateway/c/sci_system_getproperty.c b/scilab/modules/jvm/sci_gateway/c/sci_system_getproperty.c
new file mode 100644 (file)
index 0000000..db89e16
--- /dev/null
@@ -0,0 +1,43 @@
+/*-----------------------------------------------------------------------------------*/\r
+/**\r
+* @author Allan CORNET INRIA 2007\r
+*/\r
+/*-----------------------------------------------------------------------------------*/\r
+#include <string.h>\r
+#include "gw_jvm.h"\r
+#include "MALLOC.h"\r
+#include "machine.h"\r
+#include "stack-c.h"\r
+#include "system_getproperty.h"\r
+/*-----------------------------------------------------------------------------------*/\r
+int C2F(sci_system_getproperty) _PARAMS((char *fname,unsigned long fname_len))\r
+{\r
+       Rhs = Max(Rhs,0);\r
+       CheckRhs(1,1);\r
+       CheckLhs(0,1);\r
+\r
+       if ( GetType(1) == sci_strings )\r
+       {\r
+               static int m1,n1=0,l1=0;\r
+               char *propertyName = NULL;\r
+               char *propertyValue = NULL;\r
+\r
+               GetRhsVar(1,"c",&m1,&n1,&l1);\r
+               propertyName=cstk(l1);\r
+               propertyValue=system_getproperty(propertyName,"unknown");\r
+\r
+               n1=1;\r
+               CreateVarFromPtr(Rhs+1, "c",(m1=(int)strlen(propertyValue), &m1),&n1,&propertyValue);\r
+               LhsVar(1)=Rhs+1;\r
+               C2F(putlhsvar)();\r
+               if (propertyValue) {FREE(propertyValue);propertyValue=NULL;}\r
+       }\r
+       else\r
+       {\r
+               Scierror(999,"invalid parameter.\r\n");\r
+               return 0;\r
+       }\r
+       return 0;\r
+}\r
+\r
+/*-----------------------------------------------------------------------------------*/
\ No newline at end of file
index 7bc48c1..bc2e93c 100644 (file)
@@ -24,6 +24,6 @@
 <!-- =================== -->\r
 \r
 <PRIMITIVE gatewayId="52" primitiveId="1" primitiveName="with_embedded_jre" />\r
-<PRIMITIVE gatewayId="52" primitiveId="2" primitiveName="jvm_version" />\r
+<PRIMITIVE gatewayId="52" primitiveId="2" primitiveName="system_getproperty" />\r
 <PRIMITIVE gatewayId="52" primitiveId="3" primitiveName="javaclasspath" />\r
 </GATEWAY>\r
index e5fbb47..f5d1a4b 100644 (file)
@@ -54,7 +54,7 @@ char **getClasspath(int *sizeClasspathArray)
                                                string = (char*)MALLOC(sizeof(char)*(strlen(str)+1));\r
 \r
                                                #if _MSC_VER\r
-                                               if (strlen(str) > 6) strcpy(string,&str[6]);\r
+                                               if (strlen(str) > 1) strcpy(string,&str[1]);\r
                                                #else\r
                                                if (strlen(str) > 5) strcpy(string,&str[5]);\r
                                                #endif\r
diff --git a/scilab/modules/jvm/src/c/system_getproperty.c b/scilab/modules/jvm/src/c/system_getproperty.c
new file mode 100644 (file)
index 0000000..5cdf270
--- /dev/null
@@ -0,0 +1,47 @@
+/*-----------------------------------------------------------------------------------*/\r
+/* INRIA 2007 */\r
+/* Allan CORNET */\r
+/*-----------------------------------------------------------------------------------*/ \r
+#include <jni.h>\r
+#include <string.h>\r
+#include "system_getproperty.h"\r
+#include "getScilabJNIEnv.h"\r
+#include "MALLOC.h"\r
+/*-----------------------------------------------------------------------------------*/ \r
+char * system_getproperty(char *property,char *defaultproperty)\r
+{\r
+       char *retValue=NULL;\r
+       JNIEnv * currentENV = getScilabJNIEnv();\r
+\r
+       if (currentENV)\r
+       {\r
+               jclass cls=NULL;\r
+               cls = (*currentENV)->FindClass(currentENV, "java/lang/System");\r
+               if (cls)\r
+               {\r
+                       jmethodID mid=NULL;\r
+                       mid = (*currentENV)->GetStaticMethodID(currentENV, cls, "getProperty","(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;");\r
+                       if (mid)\r
+                       {\r
+                               const char *strValue = NULL;\r
+                               jstring jstrProperty;\r
+                               jstring jstrDefaultValue;\r
+                               jstring jstrValue;\r
+                               jstrProperty = (*currentENV)->NewStringUTF(currentENV,property);\r
+                               jstrDefaultValue = (*currentENV)->NewStringUTF(currentENV,defaultproperty);\r
+\r
+                               jstrValue=(*currentENV)->CallStaticObjectMethod(currentENV,cls, mid,jstrProperty,jstrDefaultValue);\r
+\r
+                               strValue = (*currentENV)->GetStringUTFChars(currentENV,jstrValue, 0);\r
+                               if (strValue)\r
+                               {\r
+                                       retValue = (char*)MALLOC(sizeof(char)*(strlen(strValue)+1));\r
+                                       strcpy(retValue,strValue);\r
+                               }\r
+                               (*currentENV)->ReleaseStringUTFChars(currentENV, jstrValue , strValue);\r
+                       }\r
+               }\r
+       }\r
+       return retValue;\r
+}\r
+/*-----------------------------------------------------------------------------------*/ \r
diff --git a/scilab/modules/jvm/src/c/system_getproperty.h b/scilab/modules/jvm/src/c/system_getproperty.h
new file mode 100644 (file)
index 0000000..5b8664c
--- /dev/null
@@ -0,0 +1,16 @@
+/*-----------------------------------------------------------------------------------*/\r
+/* INRIA 2007 */\r
+/* Allan CORNET */\r
+/*-----------------------------------------------------------------------------------*/ \r
+#ifndef __SYSTEM_GETPROPERTY_H__\r
+#define __SYSTEM_GETPROPERTY_H__\r
+\r
+/**\r
+* get system property\r
+* @param property name\r
+* @return property value\r
+*/\r
+char * system_getproperty(char *property,char *defaultproperty);\r
+\r
+#endif /* __SYSTEM_GETPROPERTY_H__ */\r
+/*-----------------------------------------------------------------------------------*/ \r