Kirill K. Smirnov : server: Move console codepages to the server.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri May 11 07:28:01 CDT 2007
Module: wine
Branch: master
Commit: 9d74661856c9221bde8234d35082cd6139592558
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9d74661856c9221bde8234d35082cd6139592558
Author: Kirill K. Smirnov <lich at math.spbu.ru>
Date: Thu May 10 21:19:47 2007 +0400
server: Move console codepages to the server.
---
dlls/kernel32/console.c | 75 +++++++++++++++++++++++++++++++---------
include/wine/server_protocol.h | 8 ++++-
server/console.c | 12 ++++++
server/console.h | 2 +
server/protocol.def | 6 +++
server/trace.c | 4 ++
6 files changed, 89 insertions(+), 18 deletions(-)
diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c
index 66bc796..b4e8437 100644
--- a/dlls/kernel32/console.c
+++ b/dlls/kernel32/console.c
@@ -55,9 +55,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(console);
-static UINT console_input_codepage;
-static UINT console_output_codepage;
-
static const WCHAR coninW[] = {'C','O','N','I','N','$',0};
static const WCHAR conoutW[] = {'C','O','N','O','U','T','$',0};
@@ -141,12 +138,19 @@ HWND WINAPI GetConsoleWindow(VOID)
*/
UINT WINAPI GetConsoleCP(VOID)
{
- if (!console_input_codepage)
+ BOOL ret;
+ UINT codepage = GetOEMCP(); /* default value */
+
+ SERVER_START_REQ(get_console_input_info)
{
- console_input_codepage = GetOEMCP();
- TRACE("%u\n", console_input_codepage);
+ req->handle = 0;
+ ret = !wine_server_call_err(req);
+ if (ret && reply->input_cp)
+ codepage = reply->input_cp;
}
- return console_input_codepage;
+ SERVER_END_REQ;
+
+ return codepage;
}
@@ -155,9 +159,24 @@ UINT WINAPI GetConsoleCP(VOID)
*/
BOOL WINAPI SetConsoleCP(UINT cp)
{
- if (!IsValidCodePage( cp )) return FALSE;
- console_input_codepage = cp;
- return TRUE;
+ BOOL ret;
+
+ if (!IsValidCodePage(cp))
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ SERVER_START_REQ(set_console_input_info)
+ {
+ req->handle = 0;
+ req->mask = SET_CONSOLE_INPUT_INFO_INPUT_CODEPAGE;
+ req->input_cp = cp;
+ ret = !wine_server_call_err(req);
+ }
+ SERVER_END_REQ;
+
+ return ret;
}
@@ -166,12 +185,19 @@ BOOL WINAPI SetConsoleCP(UINT cp)
*/
UINT WINAPI GetConsoleOutputCP(VOID)
{
- if (!console_output_codepage)
+ BOOL ret;
+ UINT codepage = GetOEMCP(); /* default value */
+
+ SERVER_START_REQ(get_console_input_info)
{
- console_output_codepage = GetOEMCP();
- TRACE("%u\n", console_output_codepage);
+ req->handle = 0;
+ ret = !wine_server_call_err(req);
+ if (ret && reply->output_cp)
+ codepage = reply->output_cp;
}
- return console_output_codepage;
+ SERVER_END_REQ;
+
+ return codepage;
}
@@ -187,9 +213,24 @@ UINT WINAPI GetConsoleOutputCP(VOID)
*/
BOOL WINAPI SetConsoleOutputCP(UINT cp)
{
- if (!IsValidCodePage( cp )) return FALSE;
- console_output_codepage = cp;
- return TRUE;
+ BOOL ret;
+
+ if (!IsValidCodePage(cp))
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ SERVER_START_REQ(set_console_input_info)
+ {
+ req->handle = 0;
+ req->mask = SET_CONSOLE_INPUT_INFO_OUTPUT_CODEPAGE;
+ req->output_cp = cp;
+ ret = !wine_server_call_err(req);
+ }
+ SERVER_END_REQ;
+
+ return ret;
}
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h
index 99f9f82..a5c5b03 100644
--- a/include/wine/server_protocol.h
+++ b/include/wine/server_protocol.h
@@ -1378,6 +1378,8 @@ struct set_console_input_info_request
int history_mode;
int history_size;
int edition_mode;
+ int input_cp;
+ int output_cp;
/* VARARG(title,unicode_str); */
};
struct set_console_input_info_reply
@@ -1389,6 +1391,8 @@ struct set_console_input_info_reply
#define SET_CONSOLE_INPUT_INFO_HISTORY_MODE 0x04
#define SET_CONSOLE_INPUT_INFO_HISTORY_SIZE 0x08
#define SET_CONSOLE_INPUT_INFO_EDITION_MODE 0x10
+#define SET_CONSOLE_INPUT_INFO_INPUT_CODEPAGE 0x20
+#define SET_CONSOLE_INPUT_INFO_OUTPUT_CODEPAGE 0x40
@@ -1404,6 +1408,8 @@ struct get_console_input_info_reply
int history_size;
int history_index;
int edition_mode;
+ int input_cp;
+ int output_cp;
/* VARARG(title,unicode_str); */
};
@@ -4722,6 +4728,6 @@ union generic_reply
struct get_next_device_request_reply get_next_device_request_reply;
};
-#define SERVER_PROTOCOL_VERSION 303
+#define SERVER_PROTOCOL_VERSION 304
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
diff --git a/server/console.c b/server/console.c
index 8e667d4..f1f3f3d 100644
--- a/server/console.c
+++ b/server/console.c
@@ -255,6 +255,8 @@ static struct object *create_console_input( struct thread* renderer )
console_input->history_index = 0;
console_input->history_mode = 0;
console_input->edition_mode = 0;
+ console_input->input_cp = 0;
+ console_input->output_cp = 0;
console_input->event = create_event( NULL, NULL, 0, 1, 0 );
if (!console_input->history || !console_input->evt)
@@ -680,6 +682,14 @@ static int set_console_input_info( const struct set_console_input_info_request *
{
console->edition_mode = req->edition_mode;
}
+ if (req->mask & SET_CONSOLE_INPUT_INFO_INPUT_CODEPAGE)
+ {
+ console->input_cp = req->input_cp;
+ }
+ if (req->mask & SET_CONSOLE_INPUT_INFO_OUTPUT_CODEPAGE)
+ {
+ console->output_cp = req->output_cp;
+ }
release_object( console );
return 1;
error:
@@ -1372,6 +1382,8 @@ DECL_HANDLER(get_console_input_info)
reply->history_size = console->history_size;
reply->history_index = console->history_index;
reply->edition_mode = console->edition_mode;
+ reply->input_cp = console->input_cp;
+ reply->output_cp = console->output_cp;
release_object( console );
}
diff --git a/server/console.h b/server/console.h
index 3864ee9..79e266c 100644
--- a/server/console.h
+++ b/server/console.h
@@ -42,6 +42,8 @@ struct console_input
int history_index; /* number of used entries in history array */
int history_mode; /* mode of history (non zero means remove doubled strings */
int edition_mode; /* index to edition mode flavors */
+ int input_cp; /* console input codepage */
+ int output_cp; /* console output codepage */
struct event *event; /* event to wait on for input queue */
};
diff --git a/server/protocol.def b/server/protocol.def
index fb2d8cd..6d88a13 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -1104,6 +1104,8 @@ struct console_renderer_event
int history_mode; /* whether we duplicate lines in history */
int history_size; /* number of lines in history */
int edition_mode; /* index to the edition mode flavors */
+ int input_cp; /* console input codepage */
+ int output_cp; /* console output codepage */
VARARG(title,unicode_str); /* console title */
@END
#define SET_CONSOLE_INPUT_INFO_ACTIVE_SB 0x01
@@ -1111,6 +1113,8 @@ struct console_renderer_event
#define SET_CONSOLE_INPUT_INFO_HISTORY_MODE 0x04
#define SET_CONSOLE_INPUT_INFO_HISTORY_SIZE 0x08
#define SET_CONSOLE_INPUT_INFO_EDITION_MODE 0x10
+#define SET_CONSOLE_INPUT_INFO_INPUT_CODEPAGE 0x20
+#define SET_CONSOLE_INPUT_INFO_OUTPUT_CODEPAGE 0x40
/* Get info about a console (input only) */
@@ -1121,6 +1125,8 @@ struct console_renderer_event
int history_size; /* number of lines in history */
int history_index; /* number of used lines in history */
int edition_mode; /* index to the edition mode flavors */
+ int input_cp; /* console input codepage */
+ int output_cp; /* console output codepage */
VARARG(title,unicode_str); /* console title */
@END
diff --git a/server/trace.c b/server/trace.c
index 8ae8d73..1dc83cf 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -1466,6 +1466,8 @@ static void dump_set_console_input_info_request( const struct set_console_input_
fprintf( stderr, " history_mode=%d,", req->history_mode );
fprintf( stderr, " history_size=%d,", req->history_size );
fprintf( stderr, " edition_mode=%d,", req->edition_mode );
+ fprintf( stderr, " input_cp=%d,", req->input_cp );
+ fprintf( stderr, " output_cp=%d,", req->output_cp );
fprintf( stderr, " title=" );
dump_varargs_unicode_str( cur_size );
}
@@ -1481,6 +1483,8 @@ static void dump_get_console_input_info_reply( const struct get_console_input_in
fprintf( stderr, " history_size=%d,", req->history_size );
fprintf( stderr, " history_index=%d,", req->history_index );
fprintf( stderr, " edition_mode=%d,", req->edition_mode );
+ fprintf( stderr, " input_cp=%d,", req->input_cp );
+ fprintf( stderr, " output_cp=%d,", req->output_cp );
fprintf( stderr, " title=" );
dump_varargs_unicode_str( cur_size );
}
More information about the wine-cvs
mailing list