2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) INRIA - Allan CORNET
5 * Copyright (C) 2012 - 2016 - Scilab Enterprises
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.
17 /*--------------------------------------------------------------------------*/
26 #include "api_scilab.h"
28 #include "localization.h"
29 /*--------------------------------------------------------------------------*/
30 int sci_sleep(char *fname, void* pvApiCtx)
33 int m1 = 0, n1 = 0 , iRows = 0, iCols = 0, option = 0;
36 int * p1_in_address = NULL;
37 int * p2_in_address = NULL;
38 double * pDblReal = NULL;
46 sciErr = getVarAddressFromPosition(pvApiCtx, 1, &p1_in_address);
47 sciErr = getMatrixOfDouble(pvApiCtx, p1_in_address, &m1, &n1, &pDblReal);
49 if (isScalar(pvApiCtx, p1_in_address) == 0)
51 Scierror(999, _("%s: Wrong type for input argument #%d: A real scalar expected.\n"), fname, 1);
54 sec = (double) * pDblReal;
58 Scierror(999, _("%s: Wrong values for input argument #%d: Non-negative integers expected.\n"), fname, 1);
64 sciErr = getVarAddressFromPosition(pvApiCtx, 2, &p2_in_address);
65 getAllocatedSingleString(pvApiCtx, p2_in_address, &opt);
67 if (strcmp("s", opt) != 0)
69 Scierror(999, _("%s: Wrong value for input argument #%d: 's' expected.\n"), fname, 2);
72 if (strcmp("s", opt) == 0)
84 ms = sec * 1000; /* convert seconds into milliseconds */
93 Sleep((DWORD)ms); /* Number of milliseconds to sleep. */
99 useconds = (unsigned) sec;
102 useconds = useconds * 1000;
107 usleep(useconds * 1000);
112 sleep(useconds * 1000);
124 /*--------------------------------------------------------------------------*/