Updated.
[wine] / dlls / msvcrt / misc.c
1 /*
2  * msvcrt.dll misc functions
3  *
4  * Copyright 2000 Jon Griffiths
5  */
6
7 #include "msvcrt.h"
8
9 DEFAULT_DEBUG_CHANNEL(msvcrt);
10
11 typedef int (__cdecl *MSVCRT_comp_func)(const void*, const void*);
12
13 /*********************************************************************
14  *              _beep (MSVCRT.@)
15  */
16 void __cdecl MSVCRT__beep( unsigned int freq, unsigned int duration)
17 {
18     TRACE(":Freq %d, Duration %d\n",freq,duration);
19     Beep(freq, duration);
20 }
21
22 extern int rand(void);
23
24 /*********************************************************************
25  *              rand (MSVCRT.@)
26  */
27 int __cdecl MSVCRT_rand()
28 {
29   return (rand() & 0x7fff);
30 }
31
32 /*********************************************************************
33  *              _sleep (MSVCRT.@)
34  */
35 void __cdecl MSVCRT__sleep(unsigned long timeout)
36 {
37   TRACE("MSVCRT__sleep for %ld milliseconds\n",timeout);
38   Sleep((timeout)?timeout:1);
39 }
40
41 /*********************************************************************
42  *              _lfind (MSVCRT.@)
43  */
44 void* __cdecl MSVCRT__lfind(const void * match, const void * start,
45 unsigned int * array_size,unsigned int elem_size, MSVCRT_comp_func cf)
46 {
47   unsigned int size = *array_size;
48   if (size)
49     do
50     {
51       if (cf(match, start) == 0)
52         return (void *)start; /* found */
53       start += elem_size;
54     } while (--size);
55   return NULL;
56 }
57
58 /*********************************************************************
59  *              _lsearch (MSVCRT.@)
60  */
61 void * __cdecl MSVCRT__lsearch(const void * match,void *  start,
62 unsigned int * array_size,unsigned int elem_size, MSVCRT_comp_func cf)
63 {
64   unsigned int size = *array_size;
65   if (size)
66     do
67     {
68       if (cf(match, start) == 0)
69         return start; /* found */
70       start += elem_size;
71     } while (--size);
72
73   /* not found, add to end */
74   memcpy(start, match, elem_size);
75   array_size[0]++;
76   return start;
77 }
78
79 /*********************************************************************
80  *              _chkesp (MSVCRT.@)
81  */
82 void __cdecl MSVCRT__chkesp(void)
83 {
84
85 }