License Header change: Removed the LICENSE_END before beta
[scilab.git] / scilab / modules / api_scilab / tests / nonreg_tests / sci_addErrorMessage.c
1 /*
2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) Scilab Enterprises - 2013 - Simon MARCHETTO
4 *
5  * Copyright (C) 2012 - 2016 - Scilab Enterprises
6  *
7  * This file is hereby licensed under the terms of the GNU GPL v2.0,
8  * pursuant to article 5.3.4 of the CeCILL v.2.1.
9  * This file was originally licensed under the terms of the CeCILL v2.1,
10  * and continues to be available under such terms.
11  * For more information, see the COPYING file which you should have received
12  * along with this program.
13 *
14 */
15
16 #include <stdio.h>
17 #include "api_scilab.h"
18 #include "api_int.h"
19
20 /*--------------------------------------------------------------------------*/
21 int sci_addErrorMessage(char *fname, void* pvApiCtx)
22 {
23     SciErr sciErr;
24     int *piAddressVarOne = NULL;
25     int errorMessageCount = 0;
26     sciErr.iMsgCount = 0;
27
28     CheckInputArgument(pvApiCtx, 1, 1);
29     sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne);
30     if (!sciErr.iErr)
31     {
32         if (isIntegerType(pvApiCtx, piAddressVarOne))
33         {
34             if (!getScalarInteger32(pvApiCtx, piAddressVarOne,
35                                     &errorMessageCount))
36             {
37                 ;
38             }
39             {
40                 SciErr sciErr;
41                 char errMsg[100];
42                 int i = 0;
43                 sciErr.iMsgCount = 0;
44
45                 for (i = 1; i <= errorMessageCount; i++)
46                 {
47                     sprintf(errMsg, "Error %d", i);
48                     addErrorMessage(&sciErr, 999, errMsg);
49                 }
50                 printError(&sciErr, 0);
51
52                 return -1;
53             }
54         }
55     }
56     return -1;
57 }
58 /*--------------------------------------------------------------------------*/