~ubuntu-branches/ubuntu/raring/scilab/raring-proposed

« back to all changes in this revision

Viewing changes to modules/jvm/sci_gateway/c/sci_system_setproperty.c

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2012-08-30 14:42:38 UTC
  • mfrom: (1.4.7)
  • Revision ID: package-import@ubuntu.com-20120830144238-c1y2og7dbm7m9nig
Tags: 5.4.0-beta-3-1~exp1
* New upstream release
* Update the scirenderer dep
* Get ride of libjhdf5-java dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3
3
 * Copyright (C) INRIA - Allan CORNET
4
 
 * 
 
4
 *
5
5
 * This file must be used under the terms of the CeCILL.
6
6
 * This source file is licensed as described in the file COPYING, which
7
7
 * you should have received as part of this distribution.  The terms
8
 
 * are also available at    
 
8
 * are also available at
9
9
 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10
10
 *
11
11
 */
19
19
#include "Scierror.h"
20
20
#include "localization.h"
21
21
/*--------------------------------------------------------------------------*/
22
 
int sci_system_setproperty(char *fname,unsigned long fname_len)
 
22
int sci_system_setproperty(char *fname, unsigned long fname_len)
23
23
{
24
 
        Rhs = Max(Rhs,0);
25
 
        CheckRhs(2,2);
26
 
        CheckLhs(1,1);
27
 
 
28
 
        if ( (GetType(1) == sci_strings) && (GetType(2) == sci_strings) )
29
 
        {
30
 
                static int m1,n1=0,l1=0;
31
 
                static int m2,n2=0,l2=0;
32
 
                char *propertyName = NULL;
33
 
                char *propertyValue = NULL;
34
 
                char *previousValue = NULL;
35
 
 
36
 
                GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
37
 
                propertyName = cstk(l1);
38
 
 
39
 
                GetRhsVar(2,STRING_DATATYPE,&m2,&n2,&l2);
40
 
                propertyValue = cstk(l2);
41
 
 
42
 
                previousValue = system_setproperty(propertyName,propertyValue);
43
 
 
44
 
                if (previousValue)
45
 
                {
46
 
                        n1=1;
47
 
                        CreateVarFromPtr(Rhs+1,STRING_DATATYPE,(m1=(int)strlen(propertyValue), &m1),&n1,&previousValue);
48
 
                }
49
 
                else
50
 
                {
51
 
                        n1 = 0;
52
 
                        m1 = 0;
53
 
                        l1 = 0;
54
 
                        CreateVar(Rhs+1,MATRIX_OF_DOUBLE_DATATYPE,&n1,&m1,&l1);
55
 
                }
56
 
                LhsVar(1)=Rhs+1;
57
 
                if (previousValue) {FREE(previousValue); previousValue = NULL;}
 
24
    Rhs = Max(Rhs, 0);
 
25
    CheckRhs(2, 2);
 
26
    CheckLhs(1, 1);
 
27
 
 
28
    if ( (GetType(1) == sci_strings) && (GetType(2) == sci_strings) )
 
29
    {
 
30
        static int m1, n1 = 0, l1 = 0;
 
31
        static int m2, n2 = 0, l2 = 0;
 
32
        char *propertyName = NULL;
 
33
        char *propertyValue = NULL;
 
34
        char *previousValue = NULL;
 
35
 
 
36
        GetRhsVar(1, STRING_DATATYPE, &m1, &n1, &l1);
 
37
        propertyName = cstk(l1);
 
38
 
 
39
        GetRhsVar(2, STRING_DATATYPE, &m2, &n2, &l2);
 
40
        propertyValue = cstk(l2);
 
41
 
 
42
        previousValue = system_setproperty(propertyName, propertyValue);
 
43
 
 
44
        if (previousValue)
 
45
        {
 
46
            n1 = 1;
 
47
            m1 = (int)strlen(propertyValue);
 
48
            CreateVarFromPtr(Rhs + 1, STRING_DATATYPE, &m1, &n1, &previousValue);
 
49
        }
 
50
        else
 
51
        {
 
52
            n1 = 0;
 
53
            m1 = 0;
 
54
            l1 = 0;
 
55
            CreateVar(Rhs + 1, MATRIX_OF_DOUBLE_DATATYPE, &n1, &m1, &l1);
 
56
        }
 
57
        LhsVar(1) = Rhs + 1;
 
58
        if (previousValue)
 
59
        {
 
60
            FREE(previousValue);
 
61
            previousValue = NULL;
 
62
        }
58
63
        PutLhsVar();
59
 
        }
60
 
        else
61
 
        {
62
 
                Scierror(999,_("%s: Wrong type for input argument #%d or #%d: String expected.\n"),fname, 1, 2);
63
 
        }
64
 
        return 0;
 
64
    }
 
65
    else
 
66
    {
 
67
        Scierror(999, _("%s: Wrong type for input argument #%d or #%d: String expected.\n"), fname, 1, 2);
 
68
    }
 
69
    return 0;
65
70
}
66
71
/*--------------------------------------------------------------------------*/