2001-01-11 00:59:25 +01:00
|
|
|
/*
|
|
|
|
* msvcrt.dll misc functions
|
|
|
|
*
|
|
|
|
* Copyright 2000 Jon Griffiths
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
|
|
|
|
2001-04-11 01:25:25 +02:00
|
|
|
#include <stdlib.h>
|
2001-04-23 20:20:55 +02:00
|
|
|
|
|
|
|
#include "msvcrt.h"
|
2001-04-11 01:25:25 +02:00
|
|
|
#include "msvcrt/stdlib.h"
|
|
|
|
|
|
|
|
|
2002-01-22 01:57:16 +01:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
|
2001-01-11 00:59:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _beep (MSVCRT.@)
|
|
|
|
*/
|
2001-04-10 23:16:07 +02:00
|
|
|
void _beep( unsigned int freq, unsigned int duration)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
TRACE(":Freq %d, Duration %d\n",freq,duration);
|
|
|
|
Beep(freq, duration);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* rand (MSVCRT.@)
|
|
|
|
*/
|
2001-04-10 23:16:07 +02:00
|
|
|
int MSVCRT_rand()
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
return (rand() & 0x7fff);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _sleep (MSVCRT.@)
|
|
|
|
*/
|
2001-04-10 23:16:07 +02:00
|
|
|
void _sleep(unsigned long timeout)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2001-04-10 23:16:07 +02:00
|
|
|
TRACE("_sleep for %ld milliseconds\n",timeout);
|
2001-01-11 00:59:25 +01:00
|
|
|
Sleep((timeout)?timeout:1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _lfind (MSVCRT.@)
|
|
|
|
*/
|
2001-04-10 23:16:07 +02:00
|
|
|
void* _lfind(const void* match, const void* start,
|
|
|
|
unsigned int* array_size, unsigned int elem_size,
|
2002-12-18 21:17:20 +01:00
|
|
|
int (*cf)(const void*,const void*) )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
unsigned int size = *array_size;
|
|
|
|
if (size)
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (cf(match, start) == 0)
|
|
|
|
return (void *)start; /* found */
|
2002-07-03 23:10:43 +02:00
|
|
|
start = (char*)start + elem_size;
|
2001-01-11 00:59:25 +01:00
|
|
|
} while (--size);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _lsearch (MSVCRT.@)
|
|
|
|
*/
|
2001-04-10 23:16:07 +02:00
|
|
|
void* _lsearch(const void* match, void* start,
|
|
|
|
unsigned int* array_size, unsigned int elem_size,
|
2002-12-18 21:17:20 +01:00
|
|
|
int (*cf)(const void*,const void*) )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
unsigned int size = *array_size;
|
|
|
|
if (size)
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (cf(match, start) == 0)
|
|
|
|
return start; /* found */
|
2002-07-03 23:10:43 +02:00
|
|
|
start = (char*)start + elem_size;
|
2001-01-11 00:59:25 +01:00
|
|
|
} while (--size);
|
|
|
|
|
|
|
|
/* not found, add to end */
|
|
|
|
memcpy(start, match, elem_size);
|
|
|
|
array_size[0]++;
|
|
|
|
return start;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _chkesp (MSVCRT.@)
|
|
|
|
*/
|
2001-04-10 23:16:07 +02:00
|
|
|
void _chkesp(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|