this serie of two patches enhances a bit the way wineconsole can be parameter with this patch, the main changes are: - console configuration can now be based on the application currently running. To be precise, a configuration is associated to each title a console has when it starts. By default, it's the process name (hence the shortcut above). [note that when you change after the console creation it's title, the configuration isn't changed) - the configuration parameters have been a bit enhanced, but it shouldn't matter to most of us - the meaning of the "default" & "properties" menu items (used to change configuration): properties now change the configuration associated with the current console (and its title), while default modifies the master configuration (used when no configuration is associated with console's title). in each case, when configuration (in dialog) is done, a confirmation box will ask the user if only current console session should be modified or if changes must be applied to all consoles with same title - a new configuration item is available: it allows not to close the console once all its processes have terminated. It's called "close on exit" - finally, a few startup parameters are now better handled (especially in AllocConsole) (wrt windows behavior) the patches are split in two: - this first one applies to kernel32.dll, and changes some information passing between kernel32 and wineconsole - the second one contains wineconsole internal modifications A+
Name: conalloc ChangeLog: now passing some console parameters at wineconsole creation instead of successive server requests better prototypes for console functions in kernel some minor console creation fixes License: X11 GenDate: 2002/09/01 19:48:13 UTC ModifiedFiles: dlls/kernel/console.c dlls/kernel/editline.c dlls/kernel/kernel_main.c AddedFiles: dlls/kernel/console_private.h =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/dlls/kernel/console.c,v retrieving revision 1.7 diff -u -u -r1.7 console.c --- dlls/kernel/console.c 17 Aug 2002 00:43:16 -0000 1.7 +++ dlls/kernel/console.c 31 Aug 2002 13:18:16 -0000 @@ -47,10 +47,10 @@ #include "wine/unicode.h" #include "wine/debug.h" #include "msvcrt/excpt.h" +#include "console_private.h" WINE_DEFAULT_DEBUG_CHANNEL(console); - static UINT console_input_codepage; static UINT console_output_codepage; @@ -823,9 +823,6 @@ } #endif /* defined(__i386__) */ -/* editline.c */ -extern WCHAR* CONSOLE_Readline(HANDLE, int); - static WCHAR* S_EditString /* = NULL */; static unsigned S_EditStrPos /* = 0 */; @@ -850,15 +847,35 @@ * helper for AllocConsole * starts the renderer process */ -static BOOL start_console_renderer(void) +static BOOL start_console_renderer_helper(const char* appname, STARTUPINFOA* si, + HANDLE hEvent) { - char buffer[256]; - int ret; - STARTUPINFOA si; + char buffer[1024]; + int ret; PROCESS_INFORMATION pi; + + /* FIXME: use dynamic allocation for most of the buffers below */ + ret = snprintf(buffer, sizeof(buffer), "%s --use-event=%d", appname, hEvent); + if ((ret > -1) && (ret < sizeof(buffer)) && + CreateProcessA(NULL, buffer, NULL, NULL, TRUE, DETACHED_PROCESS, + NULL, NULL, si, &pi)) + { + if (WaitForSingleObject(hEvent, INFINITE) != WAIT_OBJECT_0) return FALSE; + + TRACE("Started wineconsole pid=%08lx tid=%08lx\n", + pi.dwProcessId, pi.dwThreadId); + + return TRUE; + } + return FALSE; +} + +static BOOL start_console_renderer(STARTUPINFOA* si) +{ HANDLE hEvent = 0; LPSTR p; OBJECT_ATTRIBUTES attr; + BOOL ret = FALSE; attr.Length = sizeof(attr); attr.RootDirectory = 0; @@ -870,39 +887,21 @@ NtCreateEvent(&hEvent, EVENT_ALL_ACCESS, &attr, TRUE, FALSE); if (!hEvent) return FALSE; - memset(&si, 0, sizeof(si)); - si.cb = sizeof(si); - - /* FIXME: use dynamic allocation for most of the buffers below */ /* first try environment variable */ if ((p = getenv("WINECONSOLE")) != NULL) { - ret = snprintf(buffer, sizeof(buffer), "%s --use-event=%d", p, hEvent); - if ((ret > -1) && (ret < sizeof(buffer)) && - CreateProcessA(NULL, buffer, NULL, NULL, TRUE, DETACHED_PROCESS, NULL, NULL, &si, &pi)) - goto succeed; - ERR("Couldn't launch Wine console from WINECONSOLE env var... trying default access\n"); + ret = start_console_renderer_helper(p, si, hEvent); + if (!ret) + ERR("Couldn't launch Wine console from WINECONSOLE env var (%s)... " + "trying default access\n", p); } /* then try the regular PATH */ - sprintf(buffer, "wineconsole --use-event=%d", hEvent); - if (CreateProcessA(NULL, buffer, NULL, NULL, TRUE, DETACHED_PROCESS, NULL, NULL, &si, &pi)) - goto succeed; - - goto the_end; - - succeed: - if (WaitForSingleObject(hEvent, INFINITE) != WAIT_OBJECT_0) goto the_end; - CloseHandle(hEvent); - - TRACE("Started wineconsole pid=%08lx tid=%08lx\n", pi.dwProcessId, pi.dwThreadId); - - return TRUE; + if (!ret) + ret = start_console_renderer_helper("wineconsole", si, hEvent); - the_end: - ERR("Can't allocate console\n"); CloseHandle(hEvent); - return FALSE; + return ret; } /*********************************************************************** @@ -915,7 +914,9 @@ HANDLE handle_in = INVALID_HANDLE_VALUE; HANDLE handle_out = INVALID_HANDLE_VALUE; HANDLE handle_err = INVALID_HANDLE_VALUE; - STARTUPINFOW si; + STARTUPINFOA siCurrent; + STARTUPINFOA siConsole; + char buffer[1024]; TRACE("()\n"); @@ -929,7 +930,29 @@ return FALSE; } - if (!start_console_renderer()) + GetStartupInfoA(&siCurrent); + + memset(&siConsole, 0, sizeof(siConsole)); + siConsole.cb = sizeof(siConsole); + /* setup a view arguments for wineconsole (it'll use them as default values) */ + if (siCurrent.dwFlags & STARTF_USECOUNTCHARS) + { + siConsole.dwFlags |= STARTF_USECOUNTCHARS; + siConsole.dwXCountChars = siCurrent.dwXCountChars; + siConsole.dwYCountChars = siCurrent.dwYCountChars; + } + if (siCurrent.dwFlags & STARTF_USEFILLATTRIBUTE) + { + siConsole.dwFlags |= STARTF_USEFILLATTRIBUTE; + siConsole.dwFillAttribute = siCurrent.dwFillAttribute; + } + /* FIXME (should pass the unicode form) */ + if (siCurrent.lpTitle) + siConsole.lpTitle = siCurrent.lpTitle; + else if (GetModuleFileNameA(0, buffer, sizeof(buffer))) + siConsole.lpTitle = buffer; + + if (!start_console_renderer(&siConsole)) goto the_end; handle_in = CreateFileA( "CONIN$", GENERIC_READ|GENERIC_WRITE|SYNCHRONIZE, @@ -948,19 +971,6 @@ SetStdHandle(STD_INPUT_HANDLE, handle_in); SetStdHandle(STD_OUTPUT_HANDLE, handle_out); SetStdHandle(STD_ERROR_HANDLE, handle_err); - - GetStartupInfoW(&si); - if (si.dwFlags & STARTF_USECOUNTCHARS) - { - COORD c; - c.X = si.dwXCountChars; - c.Y = si.dwYCountChars; - SetConsoleScreenBufferSize(handle_out, c); - } - if (si.dwFlags & STARTF_USEFILLATTRIBUTE) - SetConsoleTextAttribute(handle_out, si.dwFillAttribute); - if (si.lpTitle) - SetConsoleTitleW(si.lpTitle); SetLastError(ERROR_SUCCESS); Index: dlls/kernel/editline.c =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/dlls/kernel/editline.c,v retrieving revision 1.1 diff -u -u -r1.1 editline.c --- dlls/kernel/editline.c 31 Jul 2002 19:20:28 -0000 1.1 +++ dlls/kernel/editline.c 31 Jul 2002 19:55:47 -0000 @@ -29,14 +29,9 @@ #include "wine/unicode.h" #include "winnls.h" #include "wine/debug.h" +#include "console_private.h" WINE_DEFAULT_DEBUG_CHANNEL(console); - -/* console.c */ -extern int CONSOLE_GetHistory(int idx, WCHAR* buf, int buf_len); -extern BOOL CONSOLE_AppendHistory(const WCHAR *p); -extern unsigned int CONSOLE_GetNumHistoryEntries(void); -extern void CONSOLE_FillLineUniform(HANDLE hConsoleOutput, int i, int j, int len, LPCHAR_INFO lpFill); struct WCEL_Context; Index: dlls/kernel/kernel_main.c =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/dlls/kernel/kernel_main.c,v retrieving revision 1.35 diff -u -u -r1.35 kernel_main.c --- dlls/kernel/kernel_main.c 28 Aug 2002 23:42:34 -0000 1.35 +++ dlls/kernel/kernel_main.c 1 Sep 2002 19:48:10 -0000 @@ -38,12 +38,13 @@ #include "miscemu.h" #include "module.h" #include "task.h" +#include "wincon.h" +#include "console_private.h" extern void LOCALE_Init(void); extern BOOL RELAY_Init(void); extern int __wine_set_signal_handler(unsigned, int (*)(unsigned)); -extern int CONSOLE_HandleCtrlC(unsigned); extern int main_create_flags; @@ -108,7 +109,7 @@ /* Create the shared heap for broken win95 native dlls */ HeapCreate( HEAP_SHARED, 0, 0 ); - /* finish the process initialisation, if needed */ + /* finish the process initialisation for console bits, if needed */ __wine_set_signal_handler(SIGINT, CONSOLE_HandleCtrlC); if (main_create_flags & CREATE_NEW_CONSOLE) @@ -117,6 +118,8 @@ if (RtlImageNtHeader(mod)->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI) AllocConsole(); } + if (main_create_flags & CREATE_NEW_PROCESS_GROUP) + SetConsoleCtrlHandler(NULL, TRUE); return TRUE; } --- /dev/null Thu Jan 1 01:00:00 1970 +++ dlls/kernel/console_private.h Wed Jul 31 16:38:01 2002 @@ -0,0 +1,13 @@ +/* console.c */ +extern int CONSOLE_HandleCtrlC(unsigned); +/* console.c */ +extern int CONSOLE_GetHistory(int idx, WCHAR* buf, int buf_len); +extern BOOL CONSOLE_AppendHistory(const WCHAR *p); +extern unsigned CONSOLE_GetNumHistoryEntries(void); +extern void CONSOLE_FillLineUniform(HANDLE hConsoleOutput, int i, int j, int len, LPCHAR_INFO lpFill); + +/* editline.c */ +extern WCHAR* CONSOLE_Readline(HANDLE, int); + + +