migrate substitution keywords to SVN
[reactos.git] / reactos / lib / kjs / src / r_std.c
1 /*
2 * Standard non re-entrant versions of the re-entrant functions.
3 * Copyright (c) 1998 New Generation Software (NGS) Oy
4 *
5 * Author: Markku Rossi <mtr@ngs.fi>
6 */
7
8 /*
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
18 *
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the Free
21 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * MA 02111-1307, USA
23 */
24
25 /*
26 * $Source: /cygdrive/c/RCVS/CVS/ReactOS/reactos/lib/kjs/src/r_std.c,v $
27 * $Id$
28 */
29
30 #include "jsint.h"
31 #include "rentrant.h"
32
33 /*
34 * Types and definitions.
35 */
36
37 /*
38 * Global functions.
39 */
40
41 /* Time. */
42
43 void
44 js_localtime (const time_t *clock, struct tm *result)
45 {
46 struct tm *tm = localtime (clock);
47 memcpy (result, tm, sizeof (*tm));
48 }
49
50
51 void
52 js_gmtime (const time_t *clock, struct tm *result)
53 {
54 struct tm *tm = gmtime (clock);
55 memcpy (result, tm, sizeof (*tm));
56 }
57
58
59 void
60 js_asctime (const struct tm *tm, char *buffer, int buffer_length)
61 {
62 char *cp = asctime (tm);
63 strcpy (buffer, cp);
64 }
65
66
67 /* Drand48. */
68
69 void *
70 js_drand48_create (JSVirtualMachine *vm)
71 {
72 return NULL;
73 }
74
75
76 void
77 js_drand48_destroy (void *drand48_context)
78 {
79 }
80
81
82 void
83 js_srand48 (void *drand48_context, long seed)
84 {
85 #if HAVE_DRAND48
86 srand48 (seed);
87 #else /* not HAVE_DRAND48 */
88 srand (seed);
89 #endif /* not HAVE_DRAND48 */
90 }
91
92 void
93 js_drand48 (void *drand48_context, double *random_return)
94 {
95 #if HAVE_DRAND48
96 *random_return = drand48 ();
97 #else /* not HAVE_DRAND48 */
98 *random_return = (double ) rand () / (double) INT_MAX;
99 #endif /* not HAVE_DRAND48 */
100 }