Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
0b2a67cf
Commit
0b2a67cf
authored
Aug 03, 2011
by
Francois Gouget
Committed by
Alexandre Julliard
Aug 05, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net: Add a WriteConsole() fall back so things still works on Windows if the output is redirected.
parent
d8624c04
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
5 deletions
+29
-5
net.c
programs/net/net.c
+29
-5
No files found.
programs/net/net.c
View file @
0b2a67cf
...
...
@@ -25,18 +25,44 @@
#define NET_START 0001
#define NET_STOP 0002
static
int
output_write
(
WCHAR
*
str
,
int
len
)
{
DWORD
ret
,
count
;
ret
=
WriteConsoleW
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
str
,
len
,
&
count
,
NULL
);
if
(
!
ret
)
{
DWORD
lenA
;
char
*
strA
;
/* On Windows WriteConsoleW() fails if the output is redirected. So fall
* back to WriteFile(), assuming the console encoding is still the right
* one in that case.
*/
lenA
=
WideCharToMultiByte
(
GetConsoleOutputCP
(),
0
,
str
,
len
,
NULL
,
0
,
NULL
,
NULL
);
strA
=
HeapAlloc
(
GetProcessHeap
(),
0
,
lenA
);
if
(
!
strA
)
return
0
;
WideCharToMultiByte
(
GetConsoleOutputCP
(),
0
,
str
,
len
,
strA
,
lenA
,
NULL
,
NULL
);
WriteFile
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
strA
,
len
,
&
count
,
FALSE
);
HeapFree
(
GetProcessHeap
(),
0
,
strA
);
}
return
count
;
}
static
int
output_string
(
int
msg
,
...)
{
WCHAR
fmt
[
8192
];
WCHAR
str
[
8192
];
int
len
;
DWORD
count
;
va_list
arguments
;
LoadStringW
(
GetModuleHandleW
(
NULL
),
msg
,
fmt
,
sizeof
(
fmt
));
va_start
(
arguments
,
msg
);
len
=
vsprintfW
(
str
,
fmt
,
arguments
);
WriteConsoleW
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
str
,
len
,
&
count
,
NULL
);
output_write
(
str
,
len
);
va_end
(
arguments
);
return
0
;
}
...
...
@@ -48,9 +74,7 @@ static BOOL output_error_string(DWORD error)
FORMAT_MESSAGE_IGNORE_INSERTS
|
FORMAT_MESSAGE_ALLOCATE_BUFFER
,
NULL
,
error
,
0
,
(
LPWSTR
)
&
pBuffer
,
0
,
NULL
))
{
DWORD
count
;
int
len
=
lstrlenW
(
pBuffer
);
WriteConsoleW
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
pBuffer
,
len
,
&
count
,
NULL
);
output_write
(
pBuffer
,
lstrlenW
(
pBuffer
));
LocalFree
(
pBuffer
);
return
TRUE
;
}
...
...
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