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
7303b8c4
Commit
7303b8c4
authored
Apr 20, 2011
by
Piotr Caban
Committed by
Alexandre Julliard
Apr 25, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Use callback based printf in cprintf functions family.
parent
056dfb26
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
44 deletions
+44
-44
console.c
dlls/msvcrt/console.c
+19
-43
msvcrt.h
dlls/msvcrt/msvcrt.h
+2
-1
wcs.c
dlls/msvcrt/wcs.c
+23
-0
No files found.
dlls/msvcrt/console.c
View file @
7303b8c4
...
@@ -298,37 +298,30 @@ int CDECL _kbhit(void)
...
@@ -298,37 +298,30 @@ int CDECL _kbhit(void)
return
retval
;
return
retval
;
}
}
static
int
puts_clbk_console_a
(
void
*
ctx
,
int
len
,
const
char
*
str
)
{
LOCK_CONSOLE
;
if
(
!
WriteConsoleA
(
MSVCRT_console_out
,
str
,
len
,
NULL
,
NULL
))
len
=
-
1
;
UNLOCK_CONSOLE
;
return
len
;
}
static
int
puts_clbk_console_w
(
void
*
ctx
,
int
len
,
const
MSVCRT_wchar_t
*
str
)
{
LOCK_CONSOLE
;
if
(
!
WriteConsoleW
(
MSVCRT_console_out
,
str
,
len
,
NULL
,
NULL
))
len
=
-
1
;
UNLOCK_CONSOLE
;
return
len
;
}
/*********************************************************************
/*********************************************************************
* _vcprintf (MSVCRT.@)
* _vcprintf (MSVCRT.@)
*/
*/
int
CDECL
_vcprintf
(
const
char
*
format
,
__ms_va_list
valist
)
int
CDECL
_vcprintf
(
const
char
*
format
,
__ms_va_list
valist
)
{
{
char
buf
[
2048
];
return
pf_printf_a
(
puts_clbk_console_a
,
NULL
,
format
,
NULL
,
FALSE
,
FALSE
,
arg_clbk_valist
,
NULL
,
valist
);
LPWSTR
formatW
=
NULL
;
DWORD
sz
;
pf_output
out
;
int
retval
;
out
.
unicode
=
FALSE
;
out
.
buf
.
A
=
out
.
grow
.
A
=
buf
;
out
.
used
=
0
;
out
.
len
=
sizeof
(
buf
);
sz
=
MultiByteToWideChar
(
CP_ACP
,
0
,
format
,
-
1
,
NULL
,
0
);
formatW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sz
*
sizeof
(
WCHAR
)
);
MultiByteToWideChar
(
CP_ACP
,
0
,
format
,
-
1
,
formatW
,
sz
);
if
((
retval
=
pf_vsnprintf
(
&
out
,
formatW
,
NULL
,
FALSE
,
valist
))
>
0
)
{
LOCK_CONSOLE
;
retval
=
_cputs
(
out
.
buf
.
A
);
UNLOCK_CONSOLE
;
}
HeapFree
(
GetProcessHeap
(),
0
,
formatW
);
if
(
out
.
buf
.
A
!=
buf
)
MSVCRT_free
(
out
.
buf
.
A
);
return
retval
;
}
}
/*********************************************************************
/*********************************************************************
...
@@ -352,24 +345,7 @@ int CDECL _cprintf(const char* format, ...)
...
@@ -352,24 +345,7 @@ int CDECL _cprintf(const char* format, ...)
*/
*/
int
CDECL
_vcwprintf
(
const
MSVCRT_wchar_t
*
format
,
__ms_va_list
valist
)
int
CDECL
_vcwprintf
(
const
MSVCRT_wchar_t
*
format
,
__ms_va_list
valist
)
{
{
MSVCRT_wchar_t
buf
[
2048
];
return
pf_printf_w
(
puts_clbk_console_w
,
NULL
,
format
,
NULL
,
FALSE
,
FALSE
,
arg_clbk_valist
,
NULL
,
valist
);
pf_output
out
;
int
retval
;
out
.
unicode
=
TRUE
;
out
.
buf
.
W
=
out
.
grow
.
W
=
buf
;
out
.
used
=
0
;
out
.
len
=
sizeof
(
buf
)
/
sizeof
(
buf
[
0
]);
if
((
retval
=
pf_vsnprintf
(
&
out
,
format
,
NULL
,
FALSE
,
valist
))
>=
0
)
{
LOCK_CONSOLE
;
retval
=
_cputws
(
out
.
buf
.
W
);
UNLOCK_CONSOLE
;
}
if
(
out
.
buf
.
W
!=
buf
)
MSVCRT_free
(
out
.
buf
.
W
);
return
retval
;
}
}
/*********************************************************************
/*********************************************************************
...
...
dlls/msvcrt/msvcrt.h
View file @
7303b8c4
...
@@ -943,11 +943,12 @@ typedef union _printf_arg
...
@@ -943,11 +943,12 @@ typedef union _printf_arg
LONGLONG
get_longlong
;
LONGLONG
get_longlong
;
double
get_double
;
double
get_double
;
}
printf_arg
;
}
printf_arg
;
typedef
printf_arg
(
*
args_clbk
)(
void
*
,
int
,
size_
t
,
__ms_va_list
*
);
typedef
printf_arg
(
*
args_clbk
)(
void
*
,
int
,
in
t
,
__ms_va_list
*
);
int
pf_printf_a
(
puts_clbk_a
,
void
*
,
const
char
*
,
MSVCRT__locale_t
,
int
pf_printf_a
(
puts_clbk_a
,
void
*
,
const
char
*
,
MSVCRT__locale_t
,
BOOL
,
BOOL
,
args_clbk
,
void
*
,
__ms_va_list
);
BOOL
,
BOOL
,
args_clbk
,
void
*
,
__ms_va_list
);
int
pf_printf_w
(
puts_clbk_w
,
void
*
,
const
MSVCRT_wchar_t
*
,
MSVCRT__locale_t
,
int
pf_printf_w
(
puts_clbk_w
,
void
*
,
const
MSVCRT_wchar_t
*
,
MSVCRT__locale_t
,
BOOL
,
BOOL
,
args_clbk
,
void
*
,
__ms_va_list
);
BOOL
,
BOOL
,
args_clbk
,
void
*
,
__ms_va_list
);
printf_arg
arg_clbk_valist
(
void
*
,
int
,
int
,
__ms_va_list
*
);
#define MSVCRT__OVERFLOW 3
#define MSVCRT__OVERFLOW 3
#define MSVCRT__UNDERFLOW 4
#define MSVCRT__UNDERFLOW 4
...
...
dlls/msvcrt/wcs.c
View file @
7303b8c4
...
@@ -1091,6 +1091,29 @@ int pf_vsnprintf( pf_output *out, const WCHAR *format,
...
@@ -1091,6 +1091,29 @@ int pf_vsnprintf( pf_output *out, const WCHAR *format,
}
}
/*********************************************************************
/*********************************************************************
* arg_clbk_valist (INTERNAL)
*/
printf_arg
arg_clbk_valist
(
void
*
ctx
,
int
arg_pos
,
int
type
,
__ms_va_list
*
valist
)
{
printf_arg
ret
;
if
(
type
==
VT_I8
)
ret
.
get_longlong
=
va_arg
(
*
valist
,
LONGLONG
);
else
if
(
type
==
VT_INT
)
ret
.
get_int
=
va_arg
(
*
valist
,
int
);
else
if
(
type
==
VT_R8
)
ret
.
get_double
=
va_arg
(
*
valist
,
double
);
else
if
(
type
==
VT_PTR
)
ret
.
get_ptr
=
va_arg
(
*
valist
,
void
*
);
else
{
ERR
(
"Incorrect type
\n
"
);
ret
.
get_int
=
0
;
}
return
ret
;
}
/*********************************************************************
* vsnprintf_internal (INTERNAL)
* vsnprintf_internal (INTERNAL)
*/
*/
static
inline
int
vsnprintf_internal
(
char
*
str
,
MSVCRT_size_t
len
,
const
char
*
format
,
static
inline
int
vsnprintf_internal
(
char
*
str
,
MSVCRT_size_t
len
,
const
char
*
format
,
...
...
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