Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
e7f75c5d
Commit
e7f75c5d
authored
Apr 10, 2001
by
Francois Gouget
Committed by
Alexandre Julliard
Apr 10, 2001
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
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
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
227 additions
and
326 deletions
+227
-326
Makefile.in
dlls/msvcrt/Makefile.in
+1
-0
console.c
dlls/msvcrt/console.c
+7
-3
cpp.c
dlls/msvcrt/cpp.c
+3
-0
ctype.c
dlls/msvcrt/ctype.c
+3
-12
data.c
dlls/msvcrt/data.c
+25
-14
dir.c
dlls/msvcrt/dir.c
+34
-64
environ.c
dlls/msvcrt/environ.c
+4
-3
errno.c
dlls/msvcrt/errno.c
+6
-7
exit.c
dlls/msvcrt/exit.c
+11
-11
file.c
dlls/msvcrt/file.c
+54
-124
heap.c
dlls/msvcrt/heap.c
+3
-0
locale.c
dlls/msvcrt/locale.c
+2
-10
main.c
dlls/msvcrt/main.c
+4
-5
math.c
dlls/msvcrt/math.c
+4
-2
mbcs.c
dlls/msvcrt/mbcs.c
+5
-2
misc.c
dlls/msvcrt/misc.c
+4
-2
msvcrt.h
dlls/msvcrt/msvcrt.h
+8
-13
msvcrt.spec
dlls/msvcrt/msvcrt.spec
+2
-2
process.c
dlls/msvcrt/process.c
+11
-18
string.c
dlls/msvcrt/string.c
+2
-0
thread.c
dlls/msvcrt/thread.c
+3
-1
time.c
dlls/msvcrt/time.c
+10
-13
wcs.c
dlls/msvcrt/wcs.c
+21
-20
No files found.
dlls/msvcrt/Makefile.in
View file @
e7f75c5d
EXTRADEFS
=
-DUSE_MSVCRT_PREFIX
TOPSRCDIR
=
@top_srcdir@
TOPOBJDIR
=
../..
SRCDIR
=
@srcdir@
...
...
dlls/msvcrt/console.c
View file @
e7f75c5d
...
...
@@ -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
);
...
...
dlls/msvcrt/cpp.c
View file @
e7f75c5d
...
...
@@ -5,6 +5,9 @@
*/
#include "msvcrt.h"
#include "msvcrt/stdlib.h"
DEFAULT_DEBUG_CHANNEL
(
msvcrt
);
...
...
dlls/msvcrt/ctype.c
View file @
e7f75c5d
...
...
@@ -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
...
...
dlls/msvcrt/data.c
View file @
e7f75c5d
...
...
@@ -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
,
env
iron
,
expand_wildcards
,
new_mode
);
TRACE
(
"(%p,%p,%p,%d,%p).
\n
"
,
argc
,
argv
,
env
p
,
expand_wildcards
,
new_mode
);
*
argc
=
MSVCRT___argc
;
*
argv
=
MSVCRT___argv
;
*
env
iron
=
MSVCRT__environ
;
*
env
p
=
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
,
wenv
iron
,
expand_wildcards
,
new_mode
);
TRACE
(
"(%p,%p,%p,%d,%p).
\n
"
,
argc
,
wargv
,
wenv
p
,
expand_wildcards
,
new_mode
);
*
argc
=
MSVCRT___argc
;
*
wargv
=
MSVCRT___wargv
;
*
wenv
iron
=
MSVCRT__wenviron
;
*
wenv
p
=
MSVCRT__wenviron
;
MSVCRT__set_new_mode
(
*
new_mode
);
}
...
...
dlls/msvcrt/dir.c
View file @
e7f75c5d
...
...
@@ -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
->
avail
able
=
(
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
);
}
...
...
dlls/msvcrt/environ.c
View file @
e7f75c5d
...
...
@@ -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
...
...
dlls/msvcrt/errno.c
View file @
e7f75c5d
...
...
@@ -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
)));
}
dlls/msvcrt/exit.c
View file @
e7f75c5d
...
...
@@ -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
;
...
...
dlls/msvcrt/file.c
View file @
e7f75c5d
...
...
@@ -7,99 +7,34 @@
* Copyright 2000 Jon Griffiths
*/
#include <time.h>
#include <stdio.h>
#include <unistd.h>
#include "ntddk.h"
#include "msvcrt.h"
#include "ms_errno.h"
DEFAULT_DEBUG_CHANNEL
(
msvcrt
);
#include "wine/unicode.h"
#include "msvcrt/direct.h"
#include "msvcrt/fcntl.h"
#include "msvcrt/io.h"
#include "msvcrt/stdio.h"
#include "msvcrt/stdlib.h"
#include "msvcrt/string.h"
#include "msvcrt/sys/stat.h"
#include "msvcrt/sys/utime.h"
#include "msvcrt/time.h"
/* stat() mode bits */
#define _S_IFMT 0xF000
#define _S_IFREG 0x8000
#define _S_IFDIR 0x4000
#define _S_IFCHR 0x2000
#define _S_IFIFO 0x1000
#define _S_IFBLK 0x3000
#define _S_IREAD 0x0100
#define _S_IWRITE 0x0080
#define _S_IEXEC 0x0040
DEFAULT_DEBUG_CHANNEL
(
msvcrt
);
/* for stat mode, permissions apply to all,owner and group */
#define MSVCRT_S_IREAD (_S_IREAD | (_S_IREAD >> 3) | (_S_IREAD >> 6))
#define MSVCRT_S_IWRITE (_S_IWRITE | (_S_IWRITE >> 3) | (_S_IWRITE >> 6))
#define MSVCRT_S_IEXEC (_S_IEXEC | (_S_IEXEC >> 3) | (_S_IEXEC >> 6))
/* _open modes */
#define _O_RDONLY 0x0000
#define _O_WRONLY 0x0001
#define _O_RDWR 0x0002
#define _O_APPEND 0x0008
#define _O_CREAT 0x0100
#define _O_TRUNC 0x0200
#define _O_EXCL 0x0400
#define _O_TEXT 0x4000
#define _O_BINARY 0x8000
#define _O_TEMPORARY 0x0040
/* Will be closed and deleted on exit */
/* _access() bit flags FIXME: incomplete */
#define W_OK 2
typedef
struct
_crtfile
{
char
*
_ptr
;
int
_cnt
;
char
*
_base
;
int
_flag
;
int
_file
;
/* fd */
int
_charbuf
;
int
_bufsiz
;
char
*
_tmpfname
;
}
MSVCRT_FILE
;
/* file._flag flags */
#define _IOREAD 0x0001
#define _IOWRT 0x0002
#define _IOEOF 0x0010
#define _IOERR 0x0020
#define _IORW 0x0080
#define _IOAPPEND 0x0200
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#define _IOFBF 0
#define _IOLBF 1
#define _IONBF 2
#define BUFSIZ 512
#define MSVCRT_stdin (&MSVCRT__iob[0])
#define MSVCRT_stdout (&MSVCRT__iob[1])
#define MSVCRT_stderr (&MSVCRT__iob[2])
struct
_stat
{
unsigned
short
st_dev
;
unsigned
short
st_ino
;
unsigned
short
st_mode
;
short
st_nlink
;
short
st_uid
;
short
st_gid
;
unsigned
int
st_rdev
;
int
st_size
;
int
st_atime
;
int
st_mtime
;
int
st_ctime
;
};
typedef
long
MSVCRT_fpos_t
;
struct
_utimbuf
{
time_t
actime
;
time_t
modtime
;
};
/* FIXME: Make this dynamic */
#define MSVCRT_MAX_FILES 257
...
...
@@ -109,6 +44,9 @@ MSVCRT_FILE* MSVCRT_files[MSVCRT_MAX_FILES];
int
MSVCRT_flags
[
MSVCRT_MAX_FILES
];
char
*
MSVCRT_tempfiles
[
MSVCRT_MAX_FILES
];
MSVCRT_FILE
MSVCRT__iob
[
3
];
#define MSVCRT_stdin (MSVCRT__iob+STDIN_FILENO)
#define MSVCRT_stdout (MSVCRT__iob+STDOUT_FILENO)
#define MSVCRT_stderr (MSVCRT__iob+STDERR_FILENO)
static
int
MSVCRT_fdstart
=
3
;
/* first unallocated fd */
static
int
MSVCRT_fdend
=
3
;
/* highest allocated fd */
...
...
@@ -134,14 +72,6 @@ extern CRITICAL_SECTION MSVCRT_file_cs;
#define LOCK_FILES EnterCriticalSection(&MSVCRT_file_cs)
#define UNLOCK_FILES LeaveCriticalSection(&MSVCRT_file_cs)
time_t
MSVCRT_time
(
time_t
*
);
int
_getdrive
(
void
);
WCHAR
*
_wcsdup
(
const
WCHAR
*
);
unsigned
int
wcslen
(
const
WCHAR
*
);
int
iswalpha
(
WCHAR
);
int
towupper
(
WCHAR
);
int
towlower
(
WCHAR
);
int
_vsnwprintf
(
WCHAR
*
,
unsigned
int
,
const
WCHAR
*
,
va_list
);
/* INTERNAL: Get the HANDLE for a fd */
static
HANDLE
msvcrt_fdtoh
(
int
fd
)
...
...
@@ -656,7 +586,7 @@ int _futime(int fd, struct _utimbuf *t)
if
(
!
t
)
{
time_t
currTime
;
MSVCRT_
time_t
currTime
;
MSVCRT_time
(
&
currTime
);
RtlSecondsSince1970ToTime
(
currTime
,
&
at
);
memcpy
(
&
wt
,
&
at
,
sizeof
(
wt
));
...
...
@@ -681,7 +611,7 @@ int _futime(int fd, struct _utimbuf *t)
/*********************************************************************
* _get_osfhandle (MSVCRT.@)
*/
HANDLE
_get_osfhandle
(
int
fd
)
long
_get_osfhandle
(
int
fd
)
{
HANDLE
hand
=
msvcrt_fdtoh
(
fd
);
HANDLE
newhand
=
hand
;
...
...
@@ -789,7 +719,7 @@ WCHAR *_wmktemp(WCHAR *pattern)
/*********************************************************************
* _open (MSVCRT.@)
*/
int
_open
(
const
char
*
path
,
int
flags
)
int
_open
(
const
char
*
path
,
int
flags
,...
)
{
DWORD
access
=
0
,
creation
=
0
;
int
ioflag
=
0
,
fd
;
...
...
@@ -875,9 +805,9 @@ int _open(const char *path,int flags)
/*********************************************************************
* _wopen (MSVCRT.@)
*/
int
_wopen
(
const
WCHAR
*
path
,
int
flags
)
int
_wopen
(
const
WCHAR
*
path
,
int
flags
,...
)
{
const
unsigned
int
len
=
wcslen
(
path
);
const
unsigned
int
len
=
strlenW
(
path
);
char
*
patha
=
MSVCRT_calloc
(
len
+
1
,
1
);
if
(
patha
&&
WideCharToMultiByte
(
CP_ACP
,
0
,
path
,
len
,
patha
,
len
,
NULL
,
NULL
))
{
...
...
@@ -919,10 +849,10 @@ int _wcreat(const WCHAR *path, int flags)
/*********************************************************************
* _open_osfhandle (MSVCRT.@)
*/
int
_open_osfhandle
(
HANDLE
hand
,
int
flags
)
int
_open_osfhandle
(
long
hand
,
int
flags
)
{
int
fd
=
msvcrt_alloc_fd
(
hand
,
flags
);
TRACE
(
":handle (%d) fd (%d)
\n
"
,
hand
,
fd
);
TRACE
(
":handle (%
l
d) fd (%d)
\n
"
,
hand
,
fd
);
return
fd
;
}
...
...
@@ -1057,7 +987,7 @@ int _stat(const char* path, struct _stat * buf)
buf
->
st_atime
=
dw
;
RtlTimeToSecondsSince1970
(
&
hfi
.
ftLastWriteTime
,
&
dw
);
buf
->
st_mtime
=
buf
->
st_ctime
=
dw
;
TRACE
(
"
\n
%d %d %d %
d %d %
d
\n
"
,
buf
->
st_mode
,
buf
->
st_nlink
,
buf
->
st_size
,
TRACE
(
"
\n
%d %d %d %
ld %ld %l
d
\n
"
,
buf
->
st_mode
,
buf
->
st_nlink
,
buf
->
st_size
,
buf
->
st_atime
,
buf
->
st_mtime
,
buf
->
st_ctime
);
return
0
;
}
...
...
@@ -1083,13 +1013,13 @@ int _wstat(const WCHAR* path, struct _stat * buf)
memset
(
buf
,
0
,
sizeof
(
struct
_stat
));
/* FIXME: rdev isn
t drive num,despite what the docs say
-what is it? */
if
(
iswalpha
(
*
path
))
buf
->
st_dev
=
buf
->
st_rdev
=
to
wupper
(
*
path
-
(
WCHAR
)
L'A'
);
/* drive num */
/* FIXME: rdev isn
't drive num, despite what the docs says
-what is it? */
if
(
MSVCRT_
iswalpha
(
*
path
))
buf
->
st_dev
=
buf
->
st_rdev
=
to
upperW
(
*
path
-
(
WCHAR
)
L'A'
);
/* drive num */
else
buf
->
st_dev
=
buf
->
st_rdev
=
_getdrive
()
-
1
;
plen
=
wcslen
(
path
);
plen
=
strlenW
(
path
);
/* Dir, or regular file? */
if
((
hfi
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
||
...
...
@@ -1101,8 +1031,8 @@ int _wstat(const WCHAR* path, struct _stat * buf)
/* executable? */
if
(
plen
>
6
&&
path
[
plen
-
4
]
==
(
WCHAR
)
L'.'
)
/* shortest exe: "\x.exe" */
{
ULONGLONG
ext
=
to
wlower
(
path
[
plen
-
1
])
|
(
towlower
(
path
[
plen
-
2
])
<<
16
)
|
((
ULONGLONG
)
to
wlower
(
path
[
plen
-
3
])
<<
32
);
ULONGLONG
ext
=
to
lowerW
(
path
[
plen
-
1
])
|
(
tolowerW
(
path
[
plen
-
2
])
<<
16
)
|
((
ULONGLONG
)
to
lowerW
(
path
[
plen
-
3
])
<<
32
);
if
(
ext
==
WCEXE
||
ext
==
WCBAT
||
ext
==
WCCMD
||
ext
==
WCCOM
)
mode
|=
MSVCRT_S_IEXEC
;
}
...
...
@@ -1118,7 +1048,7 @@ int _wstat(const WCHAR* path, struct _stat * buf)
buf
->
st_atime
=
dw
;
RtlTimeToSecondsSince1970
(
&
hfi
.
ftLastWriteTime
,
&
dw
);
buf
->
st_mtime
=
buf
->
st_ctime
=
dw
;
TRACE
(
"
\n
%d %d %d %
d %d %
d
\n
"
,
buf
->
st_mode
,
buf
->
st_nlink
,
buf
->
st_size
,
TRACE
(
"
\n
%d %d %d %
ld %ld %l
d
\n
"
,
buf
->
st_mode
,
buf
->
st_nlink
,
buf
->
st_size
,
buf
->
st_atime
,
buf
->
st_mtime
,
buf
->
st_ctime
);
return
0
;
}
...
...
@@ -1211,7 +1141,7 @@ int _wutime(const WCHAR* path, struct _utimbuf *t)
/*********************************************************************
* _write (MSVCRT.@)
*/
unsigned
int
_write
(
int
fd
,
const
void
*
buf
,
unsigned
int
count
)
int
_write
(
int
fd
,
const
void
*
buf
,
unsigned
int
count
)
{
DWORD
num_written
;
HANDLE
hand
=
msvcrt_fdtoh
(
fd
);
...
...
@@ -1366,9 +1296,9 @@ char *MSVCRT_fgets(char *s, int size, MSVCRT_FILE* file)
/*********************************************************************
* fgetwc (MSVCRT.@)
*/
WCHAR
MSVCRT_fgetwc
(
MSVCRT_FILE
*
file
)
MSVCRT_wint_t
MSVCRT_fgetwc
(
MSVCRT_FILE
*
file
)
{
WCHAR
wc
;
MSVCRT_wint_t
wc
;
if
(
_read
(
file
->
_file
,
&
wc
,
sizeof
(
wc
))
!=
sizeof
(
wc
))
return
MSVCRT_WEOF
;
return
wc
;
...
...
@@ -1377,7 +1307,7 @@ WCHAR MSVCRT_fgetwc(MSVCRT_FILE* file)
/*********************************************************************
* getwc (MSVCRT.@)
*/
WCHAR
MSVCRT_getwc
(
MSVCRT_FILE
*
file
)
MSVCRT_wint_t
MSVCRT_getwc
(
MSVCRT_FILE
*
file
)
{
return
MSVCRT_fgetwc
(
file
);
}
...
...
@@ -1385,7 +1315,7 @@ WCHAR MSVCRT_getwc(MSVCRT_FILE* file)
/*********************************************************************
* _fgetwchar (MSVCRT.@)
*/
WCHAR
_fgetwchar
(
void
)
MSVCRT_wint_t
_fgetwchar
(
void
)
{
return
MSVCRT_fgetwc
(
MSVCRT_stdin
);
}
...
...
@@ -1393,7 +1323,7 @@ WCHAR _fgetwchar(void)
/*********************************************************************
* getwchar (MSVCRT.@)
*/
WCHAR
MSVCRT_getwchar
(
void
)
MSVCRT_wint_t
MSVCRT_getwchar
(
void
)
{
return
_fgetwchar
();
}
...
...
@@ -1401,7 +1331,7 @@ WCHAR MSVCRT_getwchar(void)
/*********************************************************************
* fputwc (MSVCRT.@)
*/
WCHAR
MSVCRT_fputwc
(
WCHAR
wc
,
MSVCRT_FILE
*
file
)
MSVCRT_wint_t
MSVCRT_fputwc
(
MSVCRT_wint_t
wc
,
MSVCRT_FILE
*
file
)
{
if
(
_write
(
file
->
_file
,
&
wc
,
sizeof
(
wc
))
!=
sizeof
(
wc
))
return
MSVCRT_WEOF
;
...
...
@@ -1411,7 +1341,7 @@ WCHAR MSVCRT_fputwc(WCHAR wc, MSVCRT_FILE* file)
/*********************************************************************
* _fputwchar (MSVCRT.@)
*/
WCHAR
_fputwchar
(
WCHAR
wc
)
MSVCRT_wint_t
_fputwchar
(
MSVCRT_wint_t
wc
)
{
return
MSVCRT_fputwc
(
wc
,
MSVCRT_stdout
);
}
...
...
@@ -1482,7 +1412,7 @@ MSVCRT_FILE* MSVCRT_fopen(const char *path, const char *mode)
*/
MSVCRT_FILE
*
_wfopen
(
const
WCHAR
*
path
,
const
WCHAR
*
mode
)
{
const
unsigned
int
plen
=
wcslen
(
path
),
mlen
=
wcslen
(
mode
);
const
unsigned
int
plen
=
strlenW
(
path
),
mlen
=
strlenW
(
mode
);
char
*
patha
=
MSVCRT_calloc
(
plen
+
1
,
1
);
char
*
modea
=
MSVCRT_calloc
(
mlen
+
1
,
1
);
...
...
@@ -1548,9 +1478,9 @@ int _fputchar(int c)
/*********************************************************************
* fread (MSVCRT.@)
*/
DWORD
MSVCRT_fread
(
void
*
ptr
,
int
size
,
in
t
nmemb
,
MSVCRT_FILE
*
file
)
MSVCRT_size_t
MSVCRT_fread
(
void
*
ptr
,
MSVCRT_size_t
size
,
MSVCRT_size_
t
nmemb
,
MSVCRT_FILE
*
file
)
{
DWORD
read
=
_read
(
file
->
_file
,
ptr
,
size
*
nmemb
);
int
read
=
_read
(
file
->
_file
,
ptr
,
size
*
nmemb
);
if
(
read
<=
0
)
return
0
;
return
read
/
size
;
...
...
@@ -1615,7 +1545,7 @@ int MSVCRT_fsetpos(MSVCRT_FILE* file, MSVCRT_fpos_t *pos)
*/
int
MSVCRT_fscanf
(
MSVCRT_FILE
*
file
,
const
char
*
format
,
...)
{
/* NOTE: If you extend this function, extend _cscanf in console.c too */
/* NOTE: If you extend this function, extend
MSVCRT_
_cscanf in console.c too */
int
rd
=
0
;
int
nch
;
va_list
ap
;
...
...
@@ -1736,7 +1666,7 @@ int MSVCRT_fscanf(MSVCRT_FILE* file, const char *format, ...)
/*********************************************************************
* fseek (MSVCRT.@)
*/
LONG
MSVCRT_fseek
(
MSVCRT_FILE
*
file
,
LONG
offset
,
int
whence
)
int
MSVCRT_fseek
(
MSVCRT_FILE
*
file
,
long
offset
,
int
whence
)
{
return
_lseek
(
file
->
_file
,
offset
,
whence
);
}
...
...
@@ -1752,9 +1682,9 @@ LONG MSVCRT_ftell(MSVCRT_FILE* file)
/*********************************************************************
* fwrite (MSVCRT.@)
*/
unsigned
int
MSVCRT_fwrite
(
const
void
*
ptr
,
int
size
,
in
t
nmemb
,
MSVCRT_FILE
*
file
)
MSVCRT_size_t
MSVCRT_fwrite
(
const
void
*
ptr
,
MSVCRT_size_t
size
,
MSVCRT_size_
t
nmemb
,
MSVCRT_FILE
*
file
)
{
unsigned
int
written
=
_write
(
file
->
_file
,
ptr
,
size
*
nmemb
);
int
written
=
_write
(
file
->
_file
,
ptr
,
size
*
nmemb
);
if
(
written
<=
0
)
return
0
;
return
written
/
size
;
...
...
@@ -1773,7 +1703,7 @@ int MSVCRT_fputs(const char *s, MSVCRT_FILE* file)
*/
int
MSVCRT_fputws
(
const
WCHAR
*
s
,
MSVCRT_FILE
*
file
)
{
return
MSVCRT_fwrite
(
s
,
wcslen
(
s
),
1
,
file
)
==
1
?
0
:
MSVCRT_EOF
;
return
MSVCRT_fwrite
(
s
,
strlenW
(
s
),
1
,
file
)
==
1
?
0
:
MSVCRT_EOF
;
}
/*********************************************************************
...
...
@@ -1825,9 +1755,9 @@ int MSVCRT_putc(int c, MSVCRT_FILE* file)
/*********************************************************************
* putchar (MSVCRT.@)
*/
void
MSVCRT_putchar
(
int
c
)
int
MSVCRT_putchar
(
int
c
)
{
MSVCRT_fputc
(
c
,
MSVCRT_stdout
);
return
MSVCRT_fputc
(
c
,
MSVCRT_stdout
);
}
/*********************************************************************
...
...
@@ -1847,7 +1777,7 @@ int MSVCRT_puts(const char *s)
int
_putws
(
const
WCHAR
*
s
)
{
static
const
WCHAR
nl
=
(
WCHAR
)
L'\n'
;
if
(
MSVCRT_fwrite
(
s
,
wcslen
(
s
),
1
,
MSVCRT_stdout
)
==
1
)
if
(
MSVCRT_fwrite
(
s
,
strlenW
(
s
),
1
,
MSVCRT_stdout
)
==
1
)
return
MSVCRT_fwrite
(
&
nl
,
sizeof
(
nl
),
1
,
MSVCRT_stdout
)
==
1
?
0
:
MSVCRT_EOF
;
return
MSVCRT_EOF
;
}
...
...
@@ -1921,9 +1851,10 @@ int _wrename(const WCHAR *oldpath,const WCHAR *newpath)
/*********************************************************************
* setvbuf (MSVCRT.@)
*/
void
MSVCRT_setvbuf
(
MSVCRT_FILE
*
file
,
char
*
buf
,
int
mode
,
unsigned
in
t
size
)
int
MSVCRT_setvbuf
(
MSVCRT_FILE
*
file
,
char
*
buf
,
int
mode
,
MSVCRT_size_
t
size
)
{
FIXME
(
"(%p,%p,%d,%d)stub
\n
"
,
file
,
buf
,
mode
,
size
);
return
-
1
;
}
/*********************************************************************
...
...
@@ -1931,7 +1862,7 @@ void MSVCRT_setvbuf(MSVCRT_FILE* file, char *buf, int mode, unsigned int size)
*/
void
MSVCRT_setbuf
(
MSVCRT_FILE
*
file
,
char
*
buf
)
{
MSVCRT_setvbuf
(
file
,
buf
,
buf
?
_IOFBF
:
_IONBF
,
BUFSIZ
);
MSVCRT_setvbuf
(
file
,
buf
,
buf
?
MSVCRT__IOFBF
:
MSVCRT_
_IONBF
,
BUFSIZ
);
}
/*********************************************************************
...
...
@@ -1964,7 +1895,6 @@ MSVCRT_FILE* MSVCRT_tmpfile(void)
return
msvcrt_alloc_fp
(
fd
);
return
NULL
;
}
extern
int
vsnprintf
(
void
*
,
unsigned
int
,
const
void
*
,
va_list
);
/*********************************************************************
* vfprintf (MSVCRT.@)
...
...
dlls/msvcrt/heap.c
View file @
e7f75c5d
...
...
@@ -9,6 +9,9 @@
#include "msvcrt.h"
#include "msvcrt/stdlib.h"
DEFAULT_DEBUG_CHANNEL
(
msvcrt
);
/* MT */
...
...
dlls/msvcrt/locale.c
View file @
e7f75c5d
...
...
@@ -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
);
...
...
dlls/msvcrt/main.c
View file @
e7f75c5d
...
...
@@ -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
);
...
...
dlls/msvcrt/math.c
View file @
e7f75c5d
...
...
@@ -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
);
}
...
...
dlls/msvcrt/mbcs.c
View file @
e7f75c5d
...
...
@@ -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
in
t
len
)
unsigned
char
*
_mbsncat
(
unsigned
char
*
dst
,
const
unsigned
char
*
src
,
MSVCRT_size_
t
len
)
{
if
(
MSVCRT___mb_cur_max
>
1
)
{
...
...
dlls/msvcrt/misc.c
View file @
e7f75c5d
...
...
@@ -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.@)
*/
...
...
dlls/msvcrt/msvcrt.h
View file @
e7f75c5d
...
...
@@ -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 */
dlls/msvcrt/msvcrt.spec
View file @
e7f75c5d
...
...
@@ -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
...
...
dlls/msvcrt/process.c
View file @
e7f75c5d
...
...
@@ -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
);
}
...
...
dlls/msvcrt/string.c
View file @
e7f75c5d
...
...
@@ -8,6 +8,8 @@
*/
#include "msvcrt.h"
#include "msvcrt/stdlib.h"
#include "msvcrt/string.h"
DEFAULT_DEBUG_CHANNEL
(
msvcrt
);
...
...
dlls/msvcrt/thread.c
View file @
e7f75c5d
...
...
@@ -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
)
{
...
...
dlls/msvcrt/time.c
View file @
e7f75c5d
...
...
@@ -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 */
...
...
dlls/msvcrt/wcs.c
View file @
e7f75c5d
...
...
@@ -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.@)
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment