cosmetic, rename functions
[scilab.git] / scilab / modules / jvm / sci_gateway / c / sci_javalibrarypath.c
1 /*
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  * Copyright (C) INRIA - Allan CORNET
4  * 
5  * This file must be used under the terms of the CeCILL.
6  * This source file is licensed as described in the file COPYING, which
7  * you should have received as part of this distribution.  The terms
8  * are also available at    
9  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10  *
11  */
12
13 /*--------------------------------------------------------------------------*/
14 #include "gw_jvm.h"
15 #include "MALLOC.h"
16 #include "stack-c.h"
17 #include "Scierror.h"
18 #include "addToLibrarypath.h"
19 #include "getLibrarypath.h"
20 #include "localization.h"
21 #include "freeArrayOfString.h"
22 /*--------------------------------------------------------------------------*/
23 int sci_javalibrarypath(char *fname,unsigned long fname_len)
24 {
25         Rhs = Max(Rhs,0);
26         CheckRhs(0,1);
27         CheckLhs(0,1);
28
29         if (Rhs == 0)
30         {
31                 int nbRow=0;
32                 int nbCol=1;
33                 char **Strings=NULL;
34
35                 Strings=getLibrarypath(&nbRow);
36                 CreateVarFromPtr( Rhs+1,MATRIX_OF_STRING_DATATYPE, &nbRow, &nbCol,Strings );
37
38                 LhsVar(1)=Rhs+1;
39                 freeArrayOfString(Strings,nbRow*nbCol);
40         PutLhsVar();
41         }
42         else
43         {
44                 if ( GetType(1) == sci_strings )
45                 {
46                         static int n1=0,m1=0;
47                         int i=0;
48                         BOOL bOK=FALSE;
49                         char **libraryPaths=NULL;
50
51                         GetRhsVar(1,MATRIX_OF_STRING_DATATYPE,&m1,&n1,&libraryPaths);
52
53                         for (i = 0; i<m1*n1 ;i++)
54                         {
55                                 bOK=addToLibrarypath(libraryPaths[i]);
56                                 if (!bOK)
57                                 {
58                                         Scierror(999,_("%s: Could not add path to java.library.path: %s.\n"),fname, libraryPaths[i]);
59                                         freeArrayOfString(libraryPaths,m1*n1);
60                                         return 0;
61                                 }
62                         }
63                         LhsVar(1) = 0;
64                         freeArrayOfString(libraryPaths,m1*n1);
65             PutLhsVar();        
66                 }
67                 else
68                 {
69                         Scierror(999,_("%s: Wrong type for input argument #%d: String expected.\n"), fname,1);
70                 }
71         }
72         return 0;
73 }
74 /*--------------------------------------------------------------------------*/