add system_property("property_name")
[scilab.git] / scilab / modules / jvm / sci_gateway / c / sci_system_getproperty.c
1 /*-----------------------------------------------------------------------------------*/\r
2 /**\r
3 * @author Allan CORNET INRIA 2007\r
4 */\r
5 /*-----------------------------------------------------------------------------------*/\r
6 #include <string.h>\r
7 #include "gw_jvm.h"\r
8 #include "MALLOC.h"\r
9 #include "machine.h"\r
10 #include "stack-c.h"\r
11 #include "system_getproperty.h"\r
12 /*-----------------------------------------------------------------------------------*/\r
13 int C2F(sci_system_getproperty) _PARAMS((char *fname,unsigned long fname_len))\r
14 {\r
15         Rhs = Max(Rhs,0);\r
16         CheckRhs(1,1);\r
17         CheckLhs(0,1);\r
18 \r
19         if ( GetType(1) == sci_strings )\r
20         {\r
21                 static int m1,n1=0,l1=0;\r
22                 char *propertyName = NULL;\r
23                 char *propertyValue = NULL;\r
24 \r
25                 GetRhsVar(1,"c",&m1,&n1,&l1);\r
26                 propertyName=cstk(l1);\r
27                 propertyValue=system_getproperty(propertyName,"unknown");\r
28 \r
29                 n1=1;\r
30                 CreateVarFromPtr(Rhs+1, "c",(m1=(int)strlen(propertyValue), &m1),&n1,&propertyValue);\r
31                 LhsVar(1)=Rhs+1;\r
32                 C2F(putlhsvar)();\r
33                 if (propertyValue) {FREE(propertyValue);propertyValue=NULL;}\r
34         }\r
35         else\r
36         {\r
37                 Scierror(999,"invalid parameter.\r\n");\r
38                 return 0;\r
39         }\r
40         return 0;\r
41 }\r
42 \r
43 /*-----------------------------------------------------------------------------------*/