Dynamic link update:
[scilab.git] / scilab / modules / dynamic_link / sci_gateway / c / sci_ilib_verbose.c
1 /*
2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) DIGITEO - 2009 - 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_dynamic_link.h"
15 #include "stack-c.h"
16 #include "api_scilab.h"
17 #include "api_oldstack.h"
18 #include "ilib_verbose.h"
19 #include "localization.h"
20 #include "Scierror.h"
21 /*--------------------------------------------------------------------------*/
22 int sci_ilib_verbose(char *fname, int* _piKey)
23 {
24     SciErr sciErr;
25     int iRet        = 0;
26     int* piAddress  = NULL;
27     double dblLevel = 0;
28     int iLevel      = 0;
29
30     CheckRhs(0,1);
31     CheckLhs(1,1);
32
33     if(Rhs == 0)
34     {
35         if(createScalarDouble(_piKey, Rhs + 1, (double)getIlibVerboseLevel()))
36         {
37             return 1;
38         }
39
40         LhsVar(1) = Rhs + 1;
41     }
42     else
43     {
44         sciErr = getVarAddressFromPosition(_piKey, 1, &piAddress);
45         if(sciErr.iErr)
46         {
47             printError(&sciErr, 0);
48             return sciErr.iErr;
49         }
50
51         if(isDoubleType(_piKey, piAddress) == 0)
52         {
53             Scierror(999,_("%s: Wrong type for input argument #%d: A int expected.\n"),fname,1);
54             return 1;
55         }
56
57         if(getScalarDouble(_piKey, piAddress, &dblLevel))
58         {
59             return 1;
60         }
61
62         iLevel = (int)dblLevel;
63         if(dblLevel != (double)iLevel)
64         {
65             Scierror(999,_("%s: Wrong value for input argument #%d: A int expected.\n"),fname,1);
66             return 0;
67         }
68
69         if(!setIlibVerboseLevel((ilib_verbose_level)iLevel))
70         {
71             Scierror(999, _("%s: Wrong value for input argument #%d: Must be in the set {%s}.\n"), fname, 1, "0,1,2");
72             return 1;
73         }
74         else
75         {
76             LhsVar(1) = 0;
77         }
78     }
79
80     PutLhsVar();
81     return 0;
82 }
83 /*--------------------------------------------------------------------------*/