Commit e7f75c5d authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

Include the msvcrt headers, remove duplicate definitions.

Fixed the signature of a few functions. Don't use wcs* functions, use *W (from unicode.h) instead.
parent 7a2da179
EXTRADEFS = -DUSE_MSVCRT_PREFIX
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../..
SRCDIR = @srcdir@
......
......@@ -9,8 +9,14 @@
#include "msvcrt.h"
#include "wincon.h"
#include "msvcrt/conio.h"
#include "msvcrt/stdio.h"
#include "msvcrt/stdlib.h"
DEFAULT_DEBUG_CHANNEL(msvcrt);
/* MT */
extern CRITICAL_SECTION MSVCRT_console_cs;
#define LOCK_CONSOLE EnterCriticalSection(&MSVCRT_console_cs)
......@@ -333,8 +339,6 @@ int _kbhit(void)
}
extern int snprintf(char *, int, const char *, ...);
/*********************************************************************
* _cprintf (MSVCRT.@)
*/
......@@ -350,7 +354,7 @@ int _cprintf(const char* format, ...)
* Return the number of bytes that would have been written
* The code below handles both cases
*/
while ((written = snprintf( mem, resize, format, valist )) == -1 ||
while ((written = _snprintf( mem, resize, format, valist )) == -1 ||
written > resize)
{
resize = (written == -1 ? resize * 2 : written + 1);
......
......@@ -5,6 +5,9 @@
*/
#include "msvcrt.h"
#include "msvcrt/stdlib.h"
DEFAULT_DEBUG_CHANNEL(msvcrt);
......
......@@ -5,20 +5,11 @@
*/
#include "msvcrt.h"
DEFAULT_DEBUG_CHANNEL(msvcrt);
#include "msvcrt/ctype.h"
/* ASCII char classification table - binary compatible */
#define _UPPER C1_UPPER
#define _LOWER C1_LOWER
#define _DIGIT C1_DIGIT
#define _SPACE C1_SPACE
#define _PUNCT C1_PUNCT
#define _CONTROL C1_CNTRL
#define _BLANK C1_BLANK
#define _HEX C1_XDIGIT
#define _LEADBYTE 0x8000
#define _ALPHA (C1_ALPHA|_UPPER|_LOWER)
DEFAULT_DEBUG_CHANNEL(msvcrt);
/* Some abbreviations to make the following table readable */
#define _C_ _CONTROL
#define _S_ _SPACE
#define _P_ _PUNCT
......
......@@ -6,6 +6,10 @@
#include <math.h>
#include "msvcrt.h"
#include "msvcrt/stdlib.h"
#include "msvcrt/string.h"
DEFAULT_DEBUG_CHANNEL(msvcrt);
unsigned int MSVCRT___argc;
......@@ -22,7 +26,8 @@ unsigned int MSVCRT_osversion; /* FIXME: */
unsigned int MSVCRT__winmajor;
unsigned int MSVCRT__winminor;
unsigned int MSVCRT__winver;
unsigned int MSVCRT__sys_nerr;
unsigned int MSVCRT__sys_nerr; /* FIXME: not accessible from Winelib apps */
char** MSVCRT__sys_errlist; /* FIXME: not accessible from Winelib apps */
unsigned int MSVCRT___setlc_active;
unsigned int MSVCRT___unguarded_readlc_active;
double MSVCRT__HUGE;
......@@ -30,8 +35,8 @@ char **MSVCRT___argv;
WCHAR **MSVCRT___wargv;
char *MSVCRT__acmdln;
WCHAR *MSVCRT__wcmdln;
char *MSVCRT__environ;
WCHAR *MSVCRT__wenviron;
char **MSVCRT__environ;
WCHAR **MSVCRT__wenviron;
char **MSVCRT___initenv;
WCHAR **MSVCRT___winitenv;
int MSVCRT_timezone;
......@@ -42,7 +47,7 @@ typedef void (*_INITTERMFUN)(void);
/***********************************************************************
* __p___argc (MSVCRT.@)
*/
unsigned int* __p___argc(void) { return &MSVCRT___argc; }
int* __p___argc(void) { return &MSVCRT___argc; }
/***********************************************************************
* __p__commode (MSVCRT.@)
......@@ -97,12 +102,12 @@ WCHAR*** __p___wargv(void) { return &MSVCRT___wargv; }
/*********************************************************************
* __p__environ (MSVCRT.@)
*/
char** __p__environ(void) { return &MSVCRT__environ; }
char*** __p__environ(void) { return &MSVCRT__environ; }
/*********************************************************************
* __p__wenviron (MSVCRT.@)
*/
WCHAR** __p__wenviron(void) { return &MSVCRT__wenviron; }
WCHAR*** __p__wenviron(void) { return &MSVCRT__wenviron; }
/*********************************************************************
* __p___initenv (MSVCRT.@)
......@@ -216,10 +221,16 @@ void msvcrt_init_args(void)
MSVCRT_free( cmdline );
TRACE("found %d arguments\n",MSVCRT___argc);
/* FIXME: This is plain wrong, we must convert from a '\0' separated
* memory block to an array of pointers to string format.
*/
MSVCRT__environ = GetEnvironmentStringsA();
MSVCRT___initenv = &MSVCRT__environ;
MSVCRT___initenv = MSVCRT__environ;
/* FIXME: This is plain wrong, we must convert from a '\0' separated
* memory block to an array of pointers to string format.
*/
MSVCRT__wenviron = GetEnvironmentStringsW();
MSVCRT___winitenv = &MSVCRT__wenviron;
MSVCRT___winitenv = MSVCRT__wenviron;
}
......@@ -232,26 +243,26 @@ void msvcrt_free_args(void)
/*********************************************************************
* __getmainargs (MSVCRT.@)
*/
void __getmainargs(int *argc, char ***argv, char **environ,
void __getmainargs(int *argc, char** *argv, char** *envp,
int expand_wildcards, int *new_mode)
{
TRACE("(%p,%p,%p,%d,%p).\n", argc, argv, environ, expand_wildcards, new_mode);
TRACE("(%p,%p,%p,%d,%p).\n", argc, argv, envp, expand_wildcards, new_mode);
*argc = MSVCRT___argc;
*argv = MSVCRT___argv;
*environ = MSVCRT__environ;
*envp = MSVCRT__environ;
MSVCRT__set_new_mode( *new_mode );
}
/*********************************************************************
* __wgetmainargs (MSVCRT.@)
*/
void __wgetmainargs(int *argc, WCHAR ***wargv, WCHAR **wenviron,
void __wgetmainargs(int *argc, WCHAR** *wargv, WCHAR** *wenvp,
int expand_wildcards, int *new_mode)
{
TRACE("(%p,%p,%p,%d,%p).\n", argc, wargv, wenviron, expand_wildcards, new_mode);
TRACE("(%p,%p,%p,%d,%p).\n", argc, wargv, wenvp, expand_wildcards, new_mode);
*argc = MSVCRT___argc;
*wargv = MSVCRT___wargv;
*wenviron = MSVCRT__wenviron;
*wenvp = MSVCRT__wenviron;
MSVCRT__set_new_mode( *new_mode );
}
......
......@@ -13,37 +13,17 @@
#include "msvcrt.h"
#include "ms_errno.h"
DEFAULT_DEBUG_CHANNEL(msvcrt);
#include "wine/unicode.h"
#include "msvcrt/direct.h"
#include "msvcrt/dos.h"
#include "msvcrt/io.h"
#include "msvcrt/stdlib.h"
#include "msvcrt/string.h"
typedef struct MSVCRT_finddata_t
{
unsigned attrib;
time_t time_create; /* -1 when N/A */
time_t time_access; /* -1 when N/A */
time_t time_write;
unsigned long size; /* FIXME: 64 bit ??*/
char name[MAX_PATH];
} MSVCRT_finddata_t;
typedef struct MSVCRT_wfinddata_t
{
unsigned attrib;
time_t time_create; /* -1 when N/A */
time_t time_access; /* -1 when N/A */
time_t time_write;
unsigned long size; /* FIXME: 64 bit ??*/
WCHAR name[MAX_PATH];
} MSVCRT_wfinddata_t;
typedef struct msvcrt_diskfree_t {
unsigned num_clusters;
unsigned available;
unsigned cluster_sectors;
unsigned sector_bytes;
} MSVCRT_diskfree_t;
DEFAULT_DEBUG_CHANNEL(msvcrt);
/* INTERNAL: Translate finddata_t to PWIN32_FIND_DATAA */
static void msvcrt_fttofd(LPWIN32_FIND_DATAA fd, MSVCRT_finddata_t* ft)
static void msvcrt_fttofd(LPWIN32_FIND_DATAA fd, struct _finddata_t* ft)
{
DWORD dw;
......@@ -63,7 +43,7 @@ static void msvcrt_fttofd(LPWIN32_FIND_DATAA fd, MSVCRT_finddata_t* ft)
}
/* INTERNAL: Translate wfinddata_t to PWIN32_FIND_DATAA */
static void msvcrt_wfttofd(LPWIN32_FIND_DATAW fd, MSVCRT_wfinddata_t* ft)
static void msvcrt_wfttofd(LPWIN32_FIND_DATAW fd, struct _wfinddata_t* ft)
{
DWORD dw;
......@@ -82,17 +62,6 @@ static void msvcrt_wfttofd(LPWIN32_FIND_DATAW fd, MSVCRT_wfinddata_t* ft)
strcpyW(ft->name, fd->cFileName);
}
char* msvcrt_strndup(const char*, unsigned int);
LPWSTR _wcsdup( LPCWSTR );
LPWSTR msvcrt_wstrndup( LPCWSTR , unsigned int );
char * MSVCRT_getenv(const char *);
WCHAR *wcscpy(WCHAR *,const WCHAR *);
WCHAR *wcsncpy(WCHAR *,const WCHAR *,unsigned int);
WCHAR *wcscat(WCHAR *,const WCHAR *);
WCHAR *wcschr(WCHAR *,WCHAR);
WCHAR *wcsrchr(WCHAR *,WCHAR);
void _splitpath(const char *,char *, char *,char *,char *);
/*********************************************************************
* _chdir (MSVCRT.@)
*/
......@@ -139,7 +108,7 @@ int _chdrive(int newdrive)
/*********************************************************************
* _findclose (MSVCRT.@)
*/
int _findclose(DWORD hand)
int _findclose(long hand)
{
TRACE(":handle %ld\n",hand);
if (!FindClose((HANDLE)hand))
......@@ -153,7 +122,7 @@ int _findclose(DWORD hand)
/*********************************************************************
* _findfirst (MSVCRT.@)
*/
DWORD _findfirst(const char * fspec, MSVCRT_finddata_t* ft)
long _findfirst(const char * fspec, struct _finddata_t* ft)
{
WIN32_FIND_DATAA find_data;
HANDLE hfind;
......@@ -172,7 +141,7 @@ DWORD _findfirst(const char * fspec, MSVCRT_finddata_t* ft)
/*********************************************************************
* _wfindfirst (MSVCRT.@)
*/
DWORD _wfindfirst(const WCHAR * fspec, MSVCRT_wfinddata_t* ft)
long _wfindfirst(const WCHAR * fspec, struct _wfinddata_t* ft)
{
WIN32_FIND_DATAW find_data;
HANDLE hfind;
......@@ -191,7 +160,7 @@ DWORD _wfindfirst(const WCHAR * fspec, MSVCRT_wfinddata_t* ft)
/*********************************************************************
* _findnext (MSVCRT.@)
*/
int _findnext(DWORD hand, MSVCRT_finddata_t * ft)
int _findnext(long hand, struct _finddata_t * ft)
{
WIN32_FIND_DATAA find_data;
......@@ -208,7 +177,7 @@ int _findnext(DWORD hand, MSVCRT_finddata_t * ft)
/*********************************************************************
* _wfindnext (MSVCRT.@)
*/
int _wfindnext(DWORD hand, MSVCRT_wfinddata_t * ft)
int _wfindnext(long hand, struct _wfinddata_t * ft)
{
WIN32_FIND_DATAW find_data;
......@@ -367,7 +336,7 @@ WCHAR* _wgetdcwd(int drive, WCHAR * buf, int size)
/*********************************************************************
* _getdiskfree (MSVCRT.@)
*/
unsigned int _getdiskfree(unsigned int disk, MSVCRT_diskfree_t* d)
unsigned int _getdiskfree(unsigned int disk, struct _diskfree_t* d)
{
char drivespec[4] = {'@', ':', '\\', 0};
DWORD ret[4];
......@@ -380,10 +349,10 @@ unsigned int _getdiskfree(unsigned int disk, MSVCRT_diskfree_t* d)
if (GetDiskFreeSpaceA(disk==0?NULL:drivespec,ret,ret+1,ret+2,ret+3))
{
d->cluster_sectors = (unsigned)ret[0];
d->sector_bytes = (unsigned)ret[1];
d->available = (unsigned)ret[2];
d->num_clusters = (unsigned)ret[3];
d->sectors_per_cluster = (unsigned)ret[0];
d->bytes_per_sector = (unsigned)ret[1];
d->avail_clusters = (unsigned)ret[2];
d->total_clusters = (unsigned)ret[3];
return 0;
}
err = GetLastError();
......@@ -446,7 +415,8 @@ void _wsplitpath(const WCHAR *inpath, WCHAR *drv, WCHAR *dir,
WCHAR pathbuff[MAX_PATH],*path=pathbuff;
TRACE(":splitting path '%s'\n",debugstr_w(path));
wcscpy(pathbuff, inpath);
/* FIXME: Should be an strncpyW or something */
strcpyW(pathbuff, inpath);
/* convert slashes to backslashes for searching */
for (ptr = (WCHAR*)path; *ptr; ++ptr)
......@@ -454,12 +424,12 @@ void _wsplitpath(const WCHAR *inpath, WCHAR *drv, WCHAR *dir,
*ptr = (WCHAR)L'\\';
/* look for drive spec */
if ((ptr = wcschr(path, (WCHAR)L':')) != (WCHAR)L'\0')
if ((ptr = strchrW(path, (WCHAR)L':')) != (WCHAR)L'\0')
{
++ptr;
if (drv)
{
wcsncpy(drv, path, ptr - path);
strncpyW(drv, path, ptr - path);
drv[ptr - path] = (WCHAR)L'\0';
}
path = ptr;
......@@ -468,8 +438,8 @@ void _wsplitpath(const WCHAR *inpath, WCHAR *drv, WCHAR *dir,
*drv = (WCHAR)L'\0';
/* find rightmost backslash or leftmost colon */
if ((ptr = wcsrchr(path, (WCHAR)L'\\')) == NULL)
ptr = (wcschr(path, (WCHAR)L':'));
if ((ptr = strrchrW(path, (WCHAR)L'\\')) == NULL)
ptr = (strchrW(path, (WCHAR)L':'));
if (!ptr)
{
......@@ -484,15 +454,15 @@ void _wsplitpath(const WCHAR *inpath, WCHAR *drv, WCHAR *dir,
{
ch = *ptr;
*ptr = (WCHAR)L'\0';
wcscpy(dir, path);
strcpyW(dir, path);
*ptr = ch;
}
}
if ((p = wcsrchr(ptr, (WCHAR)L'.')) == NULL)
if ((p = strrchrW(ptr, (WCHAR)L'.')) == NULL)
{
if (fname)
wcscpy(fname, ptr);
strcpyW(fname, ptr);
if (ext)
*ext = (WCHAR)L'\0';
}
......@@ -500,10 +470,10 @@ void _wsplitpath(const WCHAR *inpath, WCHAR *drv, WCHAR *dir,
{
*p = (WCHAR)L'\0';
if (fname)
wcscpy(fname, ptr);
strcpyW(fname, ptr);
*p = (WCHAR)L'.';
if (ext)
wcscpy(ext, p);
strcpyW(ext, p);
}
/* Fix pathological case - Win returns ':' as part of the
......@@ -516,8 +486,8 @@ void _wsplitpath(const WCHAR *inpath, WCHAR *drv, WCHAR *dir,
{
pathbuff[0] = (WCHAR)L':';
pathbuff[1] = (WCHAR)L'\0';
wcscat(pathbuff,dir);
wcscpy(dir, pathbuff);
strcatW(pathbuff,dir);
strcpyW(dir, pathbuff);
}
}
}
......@@ -688,7 +658,7 @@ VOID _makepath(char * path, const char * drive,
const char * extension )
{
char ch;
TRACE("_makepath got %s %s %s %s\n", drive, directory,
TRACE("got %s %s %s %s\n", drive, directory,
filename, extension);
if ( !path )
......@@ -719,7 +689,7 @@ VOID _makepath(char * path, const char * drive,
}
}
TRACE("_makepath returns %s\n",path);
TRACE("returning %s\n",path);
}
......
......@@ -9,9 +9,10 @@
#include "wine/unicode.h"
#include "msvcrt.h"
DEFAULT_DEBUG_CHANNEL(msvcrt);
#include "msvcrt/stdlib.h"
LPWSTR wcsrchr( LPWSTR str, WCHAR ch );
DEFAULT_DEBUG_CHANNEL(msvcrt);
/*********************************************************************
* getenv (MSVCRT.@)
......@@ -51,7 +52,7 @@ WCHAR *_wgetenv(const WCHAR *name)
for (pp = environ; (*pp); pp = pp + strlenW(pp) + 1)
{
pos =wcsrchr(pp,'=');
pos = strrchrW(pp,'=');
if (pos)
length = pos -pp;
else
......
......@@ -7,6 +7,11 @@
#include "msvcrt.h"
#include "ms_errno.h"
#include <stdio.h>
#include <string.h>
#include "msvcrt/conio.h"
DEFAULT_DEBUG_CHANNEL(msvcrt);
......@@ -86,8 +91,6 @@ int* __doserrno(void)
return GET_THREAD_VAR_PTR(doserrno);
}
char *strerror(int);
/*********************************************************************
* strerror (MSVCRT.@)
*/
......@@ -99,8 +102,6 @@ char* MSVCRT_strerror(int err)
/**********************************************************************
* _strerror (MSVCRT.@)
*/
extern int sprintf(char *str, const char *format, ...);
const char* _strerror(const char* err)
{
static char strerrbuff[256]; /* FIXME: Per thread, nprintf */
......@@ -108,12 +109,10 @@ const char* _strerror(const char* err)
return strerrbuff;
}
int _cprintf( const char * format, ... );
/*********************************************************************
* perror (MSVCRT.@)
*/
void MSVCRT_perror(const char *str)
void MSVCRT_perror(const char* str)
{
_cprintf("%s: %s\n",str,MSVCRT_strerror(GET_THREAD_VAR(errno)));
}
......@@ -5,6 +5,10 @@
*/
#include "msvcrt.h"
#include "msvcrt/conio.h"
#include "msvcrt/stdlib.h"
DEFAULT_DEBUG_CHANNEL(msvcrt);
/* MT */
......@@ -12,9 +16,7 @@ extern CRITICAL_SECTION MSVCRT_exit_cs;
#define LOCK_EXIT EnterCriticalSection(&MSVCRT_exit_cs)
#define UNLOCK_EXIT LeaveCriticalSection(&MSVCRT_exit_cs)
typedef void (*MSVCRT_atexit_func)(void);
static MSVCRT_atexit_func *MSVCRT_atexit_table = NULL;
static _onexit_t *MSVCRT_atexit_table = NULL;
static int MSVCRT_atexit_table_size = 0;
static int MSVCRT_atexit_registered = 0; /* Points to free slot */
......@@ -40,11 +42,9 @@ void __MSVCRT__call_atexit(void)
/*********************************************************************
* __dllonexit (MSVCRT.@)
*/
MSVCRT_atexit_func __dllonexit(MSVCRT_atexit_func func,
MSVCRT_atexit_func **start,
MSVCRT_atexit_func **end)
_onexit_t __dllonexit(_onexit_t func, _onexit_t **start, _onexit_t **end)
{
MSVCRT_atexit_func *tmp;
_onexit_t *tmp;
int len;
TRACE("(%p,%p,%p)\n", func, start, end);
......@@ -62,7 +62,7 @@ MSVCRT_atexit_func __dllonexit(MSVCRT_atexit_func func,
if (++len <= 0)
return NULL;
tmp = (MSVCRT_atexit_func *)MSVCRT_realloc(*start, len * sizeof(tmp));
tmp = (_onexit_t *)MSVCRT_realloc(*start, len * sizeof(tmp));
if (!tmp)
return NULL;
*start = tmp;
......@@ -145,7 +145,7 @@ void MSVCRT__cexit(void)
/*********************************************************************
* _onexit (MSVCRT.@)
*/
MSVCRT_atexit_func _onexit(MSVCRT_atexit_func func)
_onexit_t _onexit(_onexit_t func)
{
TRACE("(%p)\n",func);
......@@ -155,7 +155,7 @@ void MSVCRT__cexit(void)
LOCK_EXIT;
if (MSVCRT_atexit_registered > MSVCRT_atexit_table_size - 1)
{
MSVCRT_atexit_func *newtable;
_onexit_t *newtable;
TRACE("expanding table\n");
newtable = MSVCRT_calloc(sizeof(void *),MSVCRT_atexit_table_size + 32);
if (!newtable)
......@@ -191,7 +191,7 @@ void MSVCRT_exit(int exitcode)
/*********************************************************************
* atexit (MSVCRT.@)
*/
int MSVCRT_atexit(MSVCRT_atexit_func func)
int MSVCRT_atexit(_onexit_t func)
{
TRACE("(%p)\n", func);
return _onexit(func) == func ? 0 : -1;
......
......@@ -9,6 +9,9 @@
#include "msvcrt.h"
#include "msvcrt/stdlib.h"
DEFAULT_DEBUG_CHANNEL(msvcrt);
/* MT */
......
......@@ -111,17 +111,9 @@ static int compare_info(LCID lcid, DWORD flags, char* buff, const char* cmp)
return !strncasecmp(cmp, buff, strlen(cmp));
}
/* INTERNAL: Callback for enumerated languages */
#ifdef __GNUC__
#define UNUSED __attribute__((unused))
#else
#define UNUSED
#endif
static BOOL CALLBACK
find_best_locale_proc(HMODULE hModule UNUSED, LPCSTR type UNUSED,
LPCSTR name UNUSED, WORD LangID, LONG lParam)
find_best_locale_proc(HMODULE hModule WINE_UNUSED, LPCSTR type WINE_UNUSED,
LPCSTR name WINE_UNUSED, WORD LangID, LONG lParam)
{
locale_search_t *res = (locale_search_t *)lParam;
const LCID lcid = MAKELCID(LangID, SORT_DEFAULT);
......
......@@ -5,6 +5,9 @@
*/
#include "msvcrt.h"
#include "msvcrt/stdio.h"
DEFAULT_DEBUG_CHANNEL(msvcrt);
/* Index to TLS */
......@@ -21,11 +24,7 @@ static inline BOOL msvcrt_init_tls(void);
static inline BOOL msvcrt_free_tls(void);
static inline void msvcrt_init_critical_sections(void);
static inline void msvcrt_free_critical_sections(void);
#ifdef __GNUC__
const char *msvcrt_get_reason(DWORD reason) __attribute__((unused));
#else
const char *msvcrt_get_reason(DWORD reason);
#endif
const char* msvcrt_get_reason(DWORD reason) WINE_UNUSED;
void msvcrt_init_io(void);
void msvcrt_init_console(void);
......
......@@ -14,6 +14,8 @@
#include <ieeefp.h>
#endif
#include "msvcrt/stdlib.h"
DEFAULT_DEBUG_CHANNEL(msvcrt);
#ifndef HAVE_FINITE
......@@ -674,7 +676,7 @@ LONGLONG MSVCRT_div(int num, int denom)
* VERSION
* [!i386] Non-x86 can't run win32 apps so we don't need binary compatibility
*/
div_t MSVCRT_div(int num, int denom)
MSVCRT_div_t MSVCRT_div(int num, int denom)
{
return div(num,denom);
}
......@@ -700,7 +702,7 @@ ULONGLONG MSVCRT_ldiv(long num, long denom)
* VERSION
* [!i386] Non-x86 can't run win32 apps so we don't need binary compatibility
*/
ldiv_t MSVCRT_ldiv(long num, long denom)
MSVCRT_ldiv_t MSVCRT_ldiv(long num, long denom)
{
return ldiv(num,denom);
}
......
......@@ -10,6 +10,9 @@
*/
#include "msvcrt.h"
#include "msvcrt/string.h"
DEFAULT_DEBUG_CHANNEL(msvcrt);
unsigned char MSVCRT_mbctype[257];
......@@ -428,7 +431,7 @@ char *_mbsncpy(char *dst, const char *src, unsigned int len)
*
* Find a multibyte character in a multibyte string.
*/
char *_mbschr(const char *str, unsigned int c)
unsigned char* _mbschr(const unsigned char* str, unsigned int c)
{
if(MSVCRT___mb_cur_max > 1)
{
......@@ -472,7 +475,7 @@ unsigned int _mbsnccnt(const unsigned char *str, unsigned int len)
/*********************************************************************
* _mbsncat(MSVCRT.@)
*/
char *_mbsncat(char *dst, const unsigned char *src, unsigned int len)
unsigned char* _mbsncat(unsigned char* dst, const unsigned char* src, MSVCRT_size_t len)
{
if(MSVCRT___mb_cur_max > 1)
{
......
......@@ -6,6 +6,10 @@
#include "msvcrt.h"
#include <stdlib.h>
#include "msvcrt/stdlib.h"
DEFAULT_DEBUG_CHANNEL(msvcrt);
typedef int (*MSVCRT_comp_func)(const void*, const void*);
......@@ -19,8 +23,6 @@ void _beep( unsigned int freq, unsigned int duration)
Beep(freq, duration);
}
extern int rand(void);
/*********************************************************************
* rand (MSVCRT.@)
*/
......
......@@ -11,10 +11,6 @@
#include <ctype.h>
#include <string.h>
/* Files */
#define MSVCRT_EOF -1
#define MSVCRT_WEOF (WCHAR)(0xFFFF)
/* TLS data */
extern DWORD MSVCRT_tls_index;
......@@ -33,14 +29,13 @@ typedef struct __MSVCRT_thread_data
#define SET_THREAD_VAR(x,y) \
((MSVCRT_thread_data*)TlsGetValue(MSVCRT_tls_index))->x = y
void MSVCRT__set_errno(int);
int MSVCRT__set_new_mode(int mode);
int _fcloseall(void);
void* MSVCRT_malloc(unsigned int);
void* MSVCRT_calloc(unsigned int, unsigned int);
void MSVCRT_free(void *);
int _cputs(const char *);
int _cprintf( const char *, ... );
char* _strdup(const char *);
void MSVCRT__set_errno(int);
char* msvcrt_strndup(const char*,unsigned int);
LPWSTR msvcrt_wstrndup(LPCWSTR, unsigned int);
/* FIXME: This should be declared in new.h but it's not an extern "C" so
* it would not be much use anyway. Even for Winelib applications.
*/
int MSVCRT__set_new_mode(int mode);
#endif /* __WINE_MSVCRT_H */
......@@ -470,8 +470,8 @@ debug_channels (msvcrt)
@ cdecl _strtime(str) _strtime
@ forward -noimport _strupr ntdll._strupr
@ cdecl _swab(str str long) _swab
@ stub _sys_errlist #() # FIXME: This is supposed to be a variable!
@ stub _sys_nerr #() # FIXME: This is supposed to be a variable!
@ extern _sys_errlist MSVCRT__sys_errlist
@ extern _sys_nerr MSVCRT__sys_nerr
@ cdecl _tell(long) _tell
@ stub _telli64 #(long)
@ cdecl _tempnam(str str) _tempnam
......
......@@ -14,17 +14,10 @@
#include "msvcrt.h"
#include "ms_errno.h"
DEFAULT_DEBUG_CHANNEL(msvcrt);
/* Process creation flags */
#define _P_WAIT 0
#define _P_NOWAIT 1
#define _P_OVERLAY 2
#define _P_NOWAITO 3
#define _P_DETACH 4
#include "msvcrt/process.h"
#include "msvcrt/stdlib.h"
void MSVCRT__exit(int);
void _searchenv(const char* file, const char* env, char *buf);
DEFAULT_DEBUG_CHANNEL(msvcrt);
/* FIXME: Check file extensions for app to run */
static const unsigned int EXE = 'e' << 16 | 'x' << 8 | 'e';
......@@ -83,9 +76,9 @@ static int msvcrt_spawn(int flags, const char* exe, char* args, char* env)
}
/* INTERNAL: Convert argv list to a single 'delim'-separated string */
static char* msvcrt_argvtos(const char* *arg, char delim)
static char* msvcrt_argvtos(const char* const* arg, char delim)
{
const char **search = arg;
const char* const* search = arg;
long size = 0;
char *ret;
......@@ -152,8 +145,8 @@ int _cwait(int *status, int pid, int action)
/*********************************************************************
* _spawnve (MSVCRT.@)
*/
int _spawnve(int flags, const char* name, const char **argv,
const char **envv)
int _spawnve(int flags, const char* name, const char* const* argv,
const char* const* envv)
{
char * args = msvcrt_argvtos(argv,' ');
char * envs = msvcrt_argvtos(envv,0);
......@@ -177,7 +170,7 @@ int _spawnve(int flags, const char* name, const char **argv,
/*********************************************************************
* _spawnv (MSVCRT.@)
*/
int _spawnv(int flags, const char* name, const char **argv)
int _spawnv(int flags, const char* name, const char* const* argv)
{
return _spawnve(flags, name, argv, NULL);
}
......@@ -185,8 +178,8 @@ int _spawnv(int flags, const char* name, const char **argv)
/*********************************************************************
* _spawnvpe (MSVCRT.@)
*/
int _spawnvpe(int flags, const char* name, const char **argv,
const char **envv)
int _spawnvpe(int flags, const char* name, const char* const* argv,
const char* const* envv)
{
char fullname[MAX_PATH];
_searchenv(name, "PATH", fullname);
......@@ -196,7 +189,7 @@ int _spawnvpe(int flags, const char* name, const char **argv,
/*********************************************************************
* _spawnvp (MSVCRT.@)
*/
int _spawnvp(int flags, const char* name, const char **argv)
int _spawnvp(int flags, const char* name, const char* const* argv)
{
return _spawnvpe(flags, name, argv, NULL);
}
......
......@@ -8,6 +8,8 @@
*/
#include "msvcrt.h"
#include "msvcrt/stdlib.h"
#include "msvcrt/string.h"
DEFAULT_DEBUG_CHANNEL(msvcrt);
......
......@@ -5,6 +5,8 @@
*/
#include "msvcrt.h"
#include "msvcrt/process.h"
DEFAULT_DEBUG_CHANNEL(msvcrt);
......@@ -13,7 +15,7 @@ DEFAULT_DEBUG_CHANNEL(msvcrt);
*/
unsigned long _beginthreadex(void* sec,
unsigned int stack,
LPTHREAD_START_ROUTINE start,
unsigned __stdcall (*start)(void*),
void* arg, unsigned int flag,
unsigned int* addr)
{
......
......@@ -10,21 +10,18 @@
#include <sys/times.h>
#include "msvcrt.h"
DEFAULT_DEBUG_CHANNEL(msvcrt);
#include "msvcrt/stdlib.h"
#include "msvcrt/sys/timeb.h"
#include "msvcrt/time.h"
typedef struct __MSVCRT_timeb
{
time_t time;
unsigned short millitm;
short timezone;
short dstflag;
} MSVCRT_timeb;
DEFAULT_DEBUG_CHANNEL(msvcrt);
/* INTERNAL: Return formatted current time/date */
char* msvcrt_get_current_time(char* out, const char* format)
{
static const time_t bad_time = (time_t)-1;
static const MSVCRT_time_t bad_time = (MSVCRT_time_t)-1;
time_t t;
struct tm *_tm = NULL;
char *retval = NULL;
......@@ -73,7 +70,7 @@ clock_t MSVCRT_clock(void)
/*********************************************************************
* difftime (MSVCRT.@)
*/
double MSVCRT_difftime(time_t time1, time_t time2)
double MSVCRT_difftime(MSVCRT_time_t time1, MSVCRT_time_t time2)
{
return (double)(time1 - time2);
}
......@@ -81,16 +78,16 @@ double MSVCRT_difftime(time_t time1, time_t time2)
/*********************************************************************
* time (MSVCRT.@)
*/
time_t MSVCRT_time(time_t* buf)
MSVCRT_time_t MSVCRT_time(MSVCRT_time_t* buf)
{
time_t curtime = time(NULL);
MSVCRT_time_t curtime = time(NULL);
return buf ? *buf = curtime : curtime;
}
/*********************************************************************
* _ftime (MSVCRT.@)
*/
void _ftime(MSVCRT_timeb* buf)
void _ftime(struct _timeb *buf)
{
buf->time = MSVCRT_time(NULL);
buf->millitm = 0; /* FIXME */
......
......@@ -10,11 +10,16 @@
#include "winnls.h"
#include "wine/unicode.h"
#include "msvcrt/stdio.h"
#include "msvcrt/stdlib.h"
#include "msvcrt/string.h"
#include "msvcrt/wctype.h"
DEFAULT_DEBUG_CHANNEL(msvcrt);
/* INTERNAL: MSVCRT_malloc() based wstrndup */
LPWSTR msvcrt_wstrndup(LPCWSTR buf, unsigned int size)
WCHAR* msvcrt_wstrndup(LPCWSTR buf, unsigned int size)
{
WCHAR* ret;
unsigned int len = strlenW(buf), max_len;
......@@ -33,9 +38,9 @@ LPWSTR msvcrt_wstrndup(LPCWSTR buf, unsigned int size)
/*********************************************************************
* _wcsdup (MSVCRT.@)
*/
LPWSTR _wcsdup( LPCWSTR str )
WCHAR* _wcsdup( const WCHAR* str )
{
LPWSTR ret = NULL;
WCHAR* ret = NULL;
if (str)
{
int size = (strlenW(str) + 1) * sizeof(WCHAR);
......@@ -48,7 +53,7 @@ LPWSTR _wcsdup( LPCWSTR str )
/*********************************************************************
* _wcsicoll (MSVCRT.@)
*/
INT _wcsicoll( LPCWSTR str1, LPCWSTR str2 )
INT _wcsicoll( const WCHAR* str1, const WCHAR* str2 )
{
/* FIXME: handle collates */
return strcmpiW( str1, str2 );
......@@ -57,9 +62,9 @@ INT _wcsicoll( LPCWSTR str1, LPCWSTR str2 )
/*********************************************************************
* _wcsnset (MSVCRT.@)
*/
LPWSTR _wcsnset( LPWSTR str, WCHAR c, INT n )
WCHAR* _wcsnset( WCHAR* str, WCHAR c, MSVCRT_size_t n )
{
LPWSTR ret = str;
WCHAR* ret = str;
while ((n-- > 0) && *str) *str++ = c;
return ret;
}
......@@ -67,10 +72,10 @@ LPWSTR _wcsnset( LPWSTR str, WCHAR c, INT n )
/*********************************************************************
* _wcsrev (MSVCRT.@)
*/
LPWSTR _wcsrev( LPWSTR str )
WCHAR* _wcsrev( WCHAR* str )
{
LPWSTR ret = str;
LPWSTR end = str + strlenW(str) - 1;
WCHAR* ret = str;
WCHAR* end = str + strlenW(str) - 1;
while (end > str)
{
WCHAR t = *end;
......@@ -83,9 +88,9 @@ LPWSTR _wcsrev( LPWSTR str )
/*********************************************************************
* _wcsset (MSVCRT.@)
*/
LPWSTR _wcsset( LPWSTR str, WCHAR c )
WCHAR* _wcsset( WCHAR* str, WCHAR c )
{
LPWSTR ret = str;
WCHAR* ret = str;
while (*str) *str++ = c;
return ret;
}
......@@ -219,7 +224,7 @@ int _vsnwprintf(WCHAR *str, unsigned int len,
/*********************************************************************
* vswprintf (MSVCRT.@)
*/
int MSVCRT_vswprintf( LPWSTR str, LPCWSTR format, va_list args )
int MSVCRT_vswprintf( WCHAR* str, const WCHAR* format, va_list args )
{
return _vsnwprintf( str, INT_MAX, format, args );
}
......@@ -227,7 +232,7 @@ int MSVCRT_vswprintf( LPWSTR str, LPCWSTR format, va_list args )
/*********************************************************************
* wcscoll (MSVCRT.@)
*/
DWORD MSVCRT_wcscoll( LPCWSTR str1, LPCWSTR str2 )
int MSVCRT_wcscoll( const WCHAR* str1, const WCHAR* str2 )
{
/* FIXME: handle collates */
return strcmpW( str1, str2 );
......@@ -236,12 +241,12 @@ DWORD MSVCRT_wcscoll( LPCWSTR str1, LPCWSTR str2 )
/*********************************************************************
* wcspbrk (MSVCRT.@)
*/
LPWSTR MSVCRT_wcspbrk( LPCWSTR str, LPCWSTR accept )
WCHAR* MSVCRT_wcspbrk( const WCHAR* str, const WCHAR* accept )
{
LPCWSTR p;
const WCHAR* p;
while (*str)
{
for (p = accept; *p; p++) if (*p == *str) return (LPWSTR)str;
for (p = accept; *p; p++) if (*p == *str) return (WCHAR*)str;
str++;
}
return NULL;
......@@ -343,10 +348,6 @@ INT MSVCRT_iswxdigit( WCHAR wc )
return get_char_typeW(wc) & C1_XDIGIT;
}
extern char *_itoa( long , char *, int);
extern char *_ultoa( long , char *, int);
extern char *_ltoa( long , char *, int);
/*********************************************************************
* _itow (MSVCRT.@)
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment