-
Notifications
You must be signed in to change notification settings - Fork 0
/
stdio.c
72 lines (54 loc) · 1.44 KB
/
stdio.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/***************************************************************
stdio.c
***************************************************************/
#include <windows.h>
#include "wince.h" /* for wce_mbtowc */
FILE *freopen(const char *filename, const char *mode, FILE *file)
{
wchar_t *wfilename, *wmode;
FILE *fp;
wfilename = wce_mbtowc(filename);
wmode = wce_mbtowc(mode);
fp = _wfreopen(wfilename, wmode, file);
free(wfilename);
free(wmode);
return fp;
}
FILE *fdopen( int handle, const char *mode )
{
wchar_t *wmode;
FILE* fp;
wmode = wce_mbtowc(mode);
fp = _wfdopen( (void*)handle, wmode );
free(wmode);
return fp;
}
errno_t fopen_s(FILE **file, const char *filename, const char *mode) {
FILE* p;
if(file == NULL || filename == NULL) {
return EINVAL;
}
p = fopen(filename, mode);
if(p == NULL) {
return EINVAL;
}
file = &p;
return 0;
}
int sprintf_s(char *buffer, size_t sizeOfBuffer, const char *format, ... ){
int ret;
va_list argptr;
va_start(argptr, format);
ret = sprintf(buffer, format, argptr);
va_end(argptr);
return ret;
}
int vsnprintf_s(char *buffer, size_t sizeOfBuffer, size_t count, const char *format, va_list argptr ) {
int ret;
ret = _vsnprintf(buffer, sizeOfBuffer, format, argptr);
return ret;
}
int _vscprintf(const char *format, va_list argptr) {
char buffer[8192];
return _vsnprintf(buffer, 8192, format, argptr);
}