2001-11-24 00:04:58 +01:00
|
|
|
/*
|
|
|
|
* an application for displaying Win32 console
|
|
|
|
*
|
2002-09-04 20:41:52 +02:00
|
|
|
* Copyright 2001, 2002 Eric Pouech
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2001-11-24 00:04:58 +01:00
|
|
|
*/
|
|
|
|
|
2002-04-26 21:05:15 +02:00
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
#include <stdio.h>
|
2001-11-30 19:46:42 +01:00
|
|
|
#include "wine/server.h"
|
2001-11-24 00:04:58 +01:00
|
|
|
#include "winecon_private.h"
|
2002-12-14 00:37:06 +01:00
|
|
|
#include "winnls.h"
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2002-05-14 23:45:13 +02:00
|
|
|
#include "wine/debug.h"
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2002-05-14 23:45:13 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(wineconsole);
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2002-09-04 20:41:52 +02:00
|
|
|
void WINECON_Fatal(const char* msg)
|
|
|
|
{
|
|
|
|
WINE_ERR("%s\n", msg);
|
|
|
|
ExitProcess(0);
|
|
|
|
}
|
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
/******************************************************************
|
|
|
|
* WINECON_FetchCells
|
|
|
|
*
|
|
|
|
* updates the local copy of cells (band to update)
|
|
|
|
*/
|
2001-11-30 19:46:42 +01:00
|
|
|
void WINECON_FetchCells(struct inner_data* data, int upd_tp, int upd_bm)
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_START_REQ( read_console_output )
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2002-05-30 22:12:58 +02:00
|
|
|
req->handle = (obj_handle_t)data->hConOut;
|
2001-11-30 19:46:42 +01:00
|
|
|
req->x = 0;
|
|
|
|
req->y = upd_tp;
|
|
|
|
req->mode = CHAR_INFO_MODE_TEXTATTR;
|
|
|
|
req->wrap = TRUE;
|
2001-12-04 21:46:54 +01:00
|
|
|
wine_server_set_reply( req, &data->cells[upd_tp * data->curcfg.sb_width],
|
|
|
|
(upd_bm-upd_tp+1) * data->curcfg.sb_width * sizeof(CHAR_INFO) );
|
2001-11-30 19:46:42 +01:00
|
|
|
wine_server_call( req );
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_END_REQ;
|
2001-11-24 00:04:58 +01:00
|
|
|
data->fnRefresh(data, upd_tp, upd_bm);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* WINECON_NotifyWindowChange
|
|
|
|
*
|
|
|
|
* Inform server that visible window on sb has changed
|
|
|
|
*/
|
2001-11-30 19:46:42 +01:00
|
|
|
void WINECON_NotifyWindowChange(struct inner_data* data)
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
|
|
|
SERVER_START_REQ( set_console_output_info )
|
|
|
|
{
|
2002-05-30 22:12:58 +02:00
|
|
|
req->handle = (obj_handle_t)data->hConOut;
|
2001-12-04 21:46:54 +01:00
|
|
|
req->win_left = data->curcfg.win_pos.X;
|
|
|
|
req->win_top = data->curcfg.win_pos.Y;
|
|
|
|
req->win_right = data->curcfg.win_pos.X + data->curcfg.win_width - 1;
|
|
|
|
req->win_bottom = data->curcfg.win_pos.Y + data->curcfg.win_height - 1;
|
2001-11-30 19:46:42 +01:00
|
|
|
req->mask = SET_CONSOLE_OUTPUT_INFO_DISPLAY_WINDOW;
|
|
|
|
wine_server_call( req );
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* WINECON_GetHistorySize
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
int WINECON_GetHistorySize(HANDLE hConIn)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
SERVER_START_REQ(get_console_input_info)
|
|
|
|
{
|
2002-05-30 22:12:58 +02:00
|
|
|
req->handle = (obj_handle_t)hConIn;
|
2001-11-30 19:46:42 +01:00
|
|
|
if (!wine_server_call_err( req )) ret = reply->history_size;
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* WINECON_SetHistorySize
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINECON_SetHistorySize(HANDLE hConIn, int size)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
SERVER_START_REQ(set_console_input_info)
|
|
|
|
{
|
2002-05-30 22:12:58 +02:00
|
|
|
req->handle = (obj_handle_t)hConIn;
|
2001-11-24 00:04:58 +01:00
|
|
|
req->mask = SET_CONSOLE_INPUT_INFO_HISTORY_SIZE;
|
|
|
|
req->history_size = size;
|
2001-11-30 19:46:42 +01:00
|
|
|
ret = !wine_server_call_err( req );
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* WINECON_GetHistoryMode
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
int WINECON_GetHistoryMode(HANDLE hConIn)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
SERVER_START_REQ(get_console_input_info)
|
|
|
|
{
|
2002-05-30 22:12:58 +02:00
|
|
|
req->handle = (obj_handle_t)hConIn;
|
2001-11-30 19:46:42 +01:00
|
|
|
if (!wine_server_call_err( req )) ret = reply->history_mode;
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* WINECON_SetHistoryMode
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINECON_SetHistoryMode(HANDLE hConIn, int mode)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
SERVER_START_REQ(set_console_input_info)
|
|
|
|
{
|
2002-05-30 22:12:58 +02:00
|
|
|
req->handle = (obj_handle_t)hConIn;
|
2001-11-24 00:04:58 +01:00
|
|
|
req->mask = SET_CONSOLE_INPUT_INFO_HISTORY_MODE;
|
|
|
|
req->history_mode = mode;
|
2001-11-30 19:46:42 +01:00
|
|
|
ret = !wine_server_call_err( req );
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* WINECON_GetConsoleTitle
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2001-11-30 19:46:42 +01:00
|
|
|
BOOL WINECON_GetConsoleTitle(HANDLE hConIn, WCHAR* buffer, size_t len)
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
if (len < sizeof(WCHAR)) return FALSE;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_START_REQ( get_console_input_info )
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2002-05-30 22:12:58 +02:00
|
|
|
req->handle = (obj_handle_t)hConIn;
|
2001-11-30 19:46:42 +01:00
|
|
|
wine_server_set_reply( req, buffer, len - sizeof(WCHAR) );
|
|
|
|
if ((ret = !wine_server_call_err( req )))
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
len = wine_server_reply_size( reply );
|
|
|
|
buffer[len / sizeof(WCHAR)] = 0;
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_END_REQ;
|
2001-11-24 00:04:58 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2003-01-09 07:01:51 +01:00
|
|
|
/******************************************************************
|
|
|
|
* WINECON_SetEditionMode
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static BOOL WINECON_SetEditionMode(HANDLE hConIn, int edition_mode)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
SERVER_START_REQ( set_console_input_info )
|
|
|
|
{
|
|
|
|
req->handle = (obj_handle_t)hConIn;
|
|
|
|
req->mask = SET_CONSOLE_INPUT_INFO_EDITION_MODE;
|
|
|
|
req->edition_mode = edition_mode;
|
|
|
|
ret = !wine_server_call_err( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
/******************************************************************
|
|
|
|
* WINECON_GrabChanges
|
|
|
|
*
|
|
|
|
* A change occurs, try to figure out which
|
|
|
|
*/
|
|
|
|
int WINECON_GrabChanges(struct inner_data* data)
|
|
|
|
{
|
2002-03-23 19:45:57 +01:00
|
|
|
struct console_renderer_event evts[256];
|
2003-10-09 06:27:08 +02:00
|
|
|
int i, num, ev_found;
|
2001-11-24 00:04:58 +01:00
|
|
|
HANDLE h;
|
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_START_REQ( get_console_renderer_events )
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
wine_server_set_reply( req, evts, sizeof(evts) );
|
2002-05-30 22:12:58 +02:00
|
|
|
req->handle = (obj_handle_t)data->hSynchro;
|
2001-11-30 19:46:42 +01:00
|
|
|
if (!wine_server_call_err( req )) num = wine_server_reply_size(reply) / sizeof(evts[0]);
|
|
|
|
else num = 0;
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_END_REQ;
|
2002-05-14 23:45:13 +02:00
|
|
|
if (!num) {WINE_WARN("hmm renderer signaled but no events available\n"); return 1;}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
/* FIXME: should do some event compression here (cursor pos, update) */
|
2002-03-23 19:45:57 +01:00
|
|
|
/* step 1: keep only last cursor pos event */
|
2003-10-09 06:27:08 +02:00
|
|
|
ev_found = -1;
|
2002-03-23 19:45:57 +01:00
|
|
|
for (i = num - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
if (evts[i].event == CONSOLE_RENDERER_CURSOR_POS_EVENT)
|
|
|
|
{
|
2004-03-17 21:48:30 +01:00
|
|
|
if (ev_found != -1)
|
|
|
|
evts[i].event = CONSOLE_RENDERER_NONE_EVENT;
|
2003-10-09 06:27:08 +02:00
|
|
|
ev_found = i;
|
2002-03-23 19:45:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* step 2: manage update events */
|
2003-10-09 06:27:08 +02:00
|
|
|
ev_found = -1;
|
2003-12-02 04:52:35 +01:00
|
|
|
for (i = 0; i < num; i++)
|
2002-03-23 19:45:57 +01:00
|
|
|
{
|
2003-12-02 04:52:35 +01:00
|
|
|
if (evts[i].event == CONSOLE_RENDERER_NONE_EVENT ||
|
|
|
|
evts[i].event == CONSOLE_RENDERER_CURSOR_POS_EVENT ||
|
|
|
|
evts[i].event == CONSOLE_RENDERER_CURSOR_GEOM_EVENT) continue;
|
2003-10-09 06:27:08 +02:00
|
|
|
if (evts[i].event != CONSOLE_RENDERER_UPDATE_EVENT)
|
2002-03-23 19:45:57 +01:00
|
|
|
{
|
2003-10-09 06:27:08 +02:00
|
|
|
ev_found = -1;
|
|
|
|
continue;
|
2003-12-02 04:52:35 +01:00
|
|
|
}
|
2003-10-09 06:27:08 +02:00
|
|
|
|
2003-12-02 04:52:35 +01:00
|
|
|
if (ev_found != -1 && /* Only 2 cases where they can NOT merge */
|
2003-10-09 06:27:08 +02:00
|
|
|
!(evts[i ].u.update.bottom + 1 < evts[ev_found].u.update.top ||
|
|
|
|
evts[ev_found].u.update.bottom + 1 < evts[i ].u.update.top))
|
|
|
|
{
|
|
|
|
evts[i].u.update.top = min(evts[i ].u.update.top,
|
|
|
|
evts[ev_found].u.update.top);
|
|
|
|
evts[i].u.update.bottom = max(evts[i ].u.update.bottom,
|
|
|
|
evts[ev_found].u.update.bottom);
|
|
|
|
evts[ev_found].event = CONSOLE_RENDERER_NONE_EVENT;
|
2002-03-23 19:45:57 +01:00
|
|
|
}
|
2003-10-09 06:27:08 +02:00
|
|
|
ev_found = i;
|
2002-03-23 19:45:57 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-05-14 23:45:13 +02:00
|
|
|
WINE_TRACE("Events:");
|
2001-11-24 00:04:58 +01:00
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
switch (evts[i].event)
|
|
|
|
{
|
2003-10-09 06:27:08 +02:00
|
|
|
case CONSOLE_RENDERER_NONE_EVENT:
|
2003-12-02 04:52:35 +01:00
|
|
|
WINE_TRACE(" NOP");
|
2003-10-09 06:27:08 +02:00
|
|
|
break;
|
2001-11-24 00:04:58 +01:00
|
|
|
case CONSOLE_RENDERER_TITLE_EVENT:
|
2003-12-02 04:52:35 +01:00
|
|
|
WINE_TRACE(" title()");
|
2001-11-24 00:04:58 +01:00
|
|
|
data->fnSetTitle(data);
|
|
|
|
break;
|
|
|
|
case CONSOLE_RENDERER_ACTIVE_SB_EVENT:
|
|
|
|
SERVER_START_REQ( open_console )
|
|
|
|
{
|
|
|
|
req->from = (int)data->hConIn;
|
|
|
|
req->access = GENERIC_READ | GENERIC_WRITE;
|
|
|
|
req->share = FILE_SHARE_READ | FILE_SHARE_WRITE;
|
|
|
|
req->inherit = FALSE;
|
2001-11-30 19:46:42 +01:00
|
|
|
h = wine_server_call_err( req ) ? 0 : (HANDLE)reply->handle;
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
2003-10-08 21:20:11 +02:00
|
|
|
WINE_TRACE(" active(%d)", (int)h);
|
2001-11-24 00:04:58 +01:00
|
|
|
if (h)
|
|
|
|
{
|
|
|
|
CloseHandle(data->hConOut);
|
|
|
|
data->hConOut = h;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CONSOLE_RENDERER_SB_RESIZE_EVENT:
|
2002-06-01 01:06:46 +02:00
|
|
|
if (data->curcfg.sb_width != evts[i].u.resize.width ||
|
2002-09-04 20:41:52 +02:00
|
|
|
data->curcfg.sb_height != evts[i].u.resize.height || !data->cells)
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2003-10-08 21:20:11 +02:00
|
|
|
WINE_TRACE(" resize(%d,%d)", evts[i].u.resize.width, evts[i].u.resize.height);
|
2001-12-04 21:46:54 +01:00
|
|
|
data->curcfg.sb_width = evts[i].u.resize.width;
|
|
|
|
data->curcfg.sb_height = evts[i].u.resize.height;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2003-10-15 23:01:05 +02:00
|
|
|
if (data->cells)
|
|
|
|
data->cells = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, data->cells,
|
2001-12-04 21:46:54 +01:00
|
|
|
data->curcfg.sb_width * data->curcfg.sb_height * sizeof(CHAR_INFO));
|
2003-10-15 23:01:05 +02:00
|
|
|
else
|
|
|
|
data->cells = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
|
|
data->curcfg.sb_width * data->curcfg.sb_height * sizeof(CHAR_INFO));
|
|
|
|
|
2002-09-04 20:41:52 +02:00
|
|
|
if (!data->cells) WINECON_Fatal("OOM\n");
|
2001-11-24 00:04:58 +01:00
|
|
|
data->fnResizeScreenBuffer(data);
|
|
|
|
data->fnComputePositions(data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CONSOLE_RENDERER_UPDATE_EVENT:
|
2003-10-08 21:20:11 +02:00
|
|
|
WINE_TRACE(" update(%d,%d)", evts[i].u.update.top, evts[i].u.update.bottom);
|
2001-11-24 00:04:58 +01:00
|
|
|
WINECON_FetchCells(data, evts[i].u.update.top, evts[i].u.update.bottom);
|
|
|
|
break;
|
|
|
|
case CONSOLE_RENDERER_CURSOR_POS_EVENT:
|
|
|
|
if (evts[i].u.cursor_pos.x != data->cursor.X || evts[i].u.cursor_pos.y != data->cursor.Y)
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
2003-10-08 21:20:11 +02:00
|
|
|
WINE_TRACE(" curs-pos(%d,%d)",evts[i].u.cursor_pos.x, evts[i].u.cursor_pos.y);
|
2001-11-24 00:04:58 +01:00
|
|
|
data->cursor.X = evts[i].u.cursor_pos.x;
|
|
|
|
data->cursor.Y = evts[i].u.cursor_pos.y;
|
|
|
|
data->fnPosCursor(data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CONSOLE_RENDERER_CURSOR_GEOM_EVENT:
|
2002-06-01 01:06:46 +02:00
|
|
|
if (evts[i].u.cursor_geom.size != data->curcfg.cursor_size ||
|
2001-12-04 21:46:54 +01:00
|
|
|
evts[i].u.cursor_geom.visible != data->curcfg.cursor_visible)
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2003-10-08 21:20:11 +02:00
|
|
|
WINE_TRACE(" curs-geom(%d,%d)",
|
|
|
|
evts[i].u.cursor_geom.size, evts[i].u.cursor_geom.visible);
|
2003-10-08 21:18:33 +02:00
|
|
|
data->fnShapeCursor(data, evts[i].u.cursor_geom.size,
|
|
|
|
evts[i].u.cursor_geom.visible, FALSE);
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CONSOLE_RENDERER_DISPLAY_EVENT:
|
2001-12-04 21:46:54 +01:00
|
|
|
if (evts[i].u.display.left != data->curcfg.win_pos.X)
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2003-10-08 21:20:11 +02:00
|
|
|
WINE_TRACE(" h-scroll(%d)", evts[i].u.display.left);
|
2003-10-08 21:18:33 +02:00
|
|
|
data->fnScroll(data, evts[i].u.display.left, TRUE);
|
|
|
|
data->fnPosCursor(data);
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
2001-12-04 21:46:54 +01:00
|
|
|
if (evts[i].u.display.top != data->curcfg.win_pos.Y)
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2003-10-08 21:20:11 +02:00
|
|
|
WINE_TRACE(" v-scroll(%d)", evts[i].u.display.top);
|
2003-10-08 21:18:33 +02:00
|
|
|
data->fnScroll(data, evts[i].u.display.top, FALSE);
|
|
|
|
data->fnPosCursor(data);
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
if (evts[i].u.display.width != data->curcfg.win_width ||
|
2001-12-04 21:46:54 +01:00
|
|
|
evts[i].u.display.height != data->curcfg.win_height)
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2003-10-08 21:20:11 +02:00
|
|
|
WINE_TRACE(" win-size(%d,%d)", evts[i].u.display.width, evts[i].u.display.height);
|
2001-12-04 21:46:54 +01:00
|
|
|
data->curcfg.win_width = evts[i].u.display.width;
|
|
|
|
data->curcfg.win_height = evts[i].u.display.height;
|
2001-11-24 00:04:58 +01:00
|
|
|
data->fnComputePositions(data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CONSOLE_RENDERER_EXIT_EVENT:
|
2003-10-08 21:20:11 +02:00
|
|
|
WINE_TRACE(". Exit!!\n");
|
2001-11-24 00:04:58 +01:00
|
|
|
return 0;
|
|
|
|
default:
|
2002-05-14 23:45:13 +02:00
|
|
|
WINE_FIXME("Unknown event type (%d)\n", evts[i].event);
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-08 21:20:11 +02:00
|
|
|
WINE_TRACE(".\n");
|
2001-11-24 00:04:58 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2002-09-04 20:41:52 +02:00
|
|
|
/******************************************************************
|
|
|
|
* WINECON_SetConfig
|
|
|
|
*
|
|
|
|
* Apply to data all the configuration elements from cfg. This includes modification
|
|
|
|
* of server side equivalent and visual parts.
|
|
|
|
* If force is FALSE, only the changed items are modified.
|
|
|
|
*/
|
|
|
|
void WINECON_SetConfig(struct inner_data* data,
|
|
|
|
const struct config_data* cfg, BOOL force)
|
|
|
|
{
|
|
|
|
if (force || data->curcfg.cursor_size != cfg->cursor_size ||
|
|
|
|
data->curcfg.cursor_visible != cfg->cursor_visible)
|
|
|
|
{
|
|
|
|
CONSOLE_CURSOR_INFO cinfo;
|
|
|
|
cinfo.dwSize = cfg->cursor_size;
|
|
|
|
/* <FIXME>: this hack is needed to pass thru the invariant test operation on server side
|
|
|
|
* (no notification is sent when invariant operation is requested
|
|
|
|
*/
|
|
|
|
cinfo.bVisible = !cfg->cursor_visible;
|
|
|
|
SetConsoleCursorInfo(data->hConOut, &cinfo);
|
|
|
|
/* </FIXME> */
|
|
|
|
cinfo.bVisible = cfg->cursor_visible;
|
|
|
|
/* this shall update (through notif) curcfg */
|
|
|
|
SetConsoleCursorInfo(data->hConOut, &cinfo);
|
|
|
|
}
|
|
|
|
if (force || data->curcfg.history_size != cfg->history_size)
|
|
|
|
{
|
|
|
|
data->curcfg.history_size = cfg->history_size;
|
|
|
|
WINECON_SetHistorySize(data->hConIn, cfg->history_size);
|
|
|
|
}
|
|
|
|
if (force || data->curcfg.history_nodup != cfg->history_nodup)
|
|
|
|
{
|
|
|
|
data->curcfg.history_nodup = cfg->history_nodup;
|
|
|
|
WINECON_SetHistoryMode(data->hConIn, cfg->history_nodup);
|
|
|
|
}
|
|
|
|
data->curcfg.menu_mask = cfg->menu_mask;
|
|
|
|
data->curcfg.quick_edit = cfg->quick_edit;
|
|
|
|
if (force || 1 /* FIXME: font info has changed */)
|
|
|
|
{
|
|
|
|
data->fnSetFont(data, cfg->face_name, cfg->cell_height, cfg->font_weight);
|
|
|
|
}
|
|
|
|
if (force || data->curcfg.def_attr != cfg->def_attr)
|
|
|
|
{
|
|
|
|
data->curcfg.def_attr = cfg->def_attr;
|
|
|
|
SetConsoleTextAttribute(data->hConOut, cfg->def_attr);
|
|
|
|
}
|
2003-02-26 05:37:15 +01:00
|
|
|
/* now let's look at the window / sb size changes...
|
|
|
|
* since the server checks that sb is always bigger than window,
|
|
|
|
* we have to take care of doing the operations in the right order
|
|
|
|
*/
|
|
|
|
/* a set of macros to make things easier to read
|
|
|
|
* The Test<A><B> macros test if the <A> (width/height) needs to be changed
|
|
|
|
* for <B> (window / ScreenBuffer)
|
|
|
|
* The Change<A><B> actually modify the <B> dimension of <A>.
|
|
|
|
*/
|
|
|
|
#define TstSBfWidth() (force || data->curcfg.sb_width != cfg->sb_width)
|
|
|
|
#define TstWinWidth() (force || data->curcfg.win_width != cfg->win_width)
|
|
|
|
|
|
|
|
#define ChgSBfWidth() do {c.X = cfg->sb_width; \
|
|
|
|
c.Y = data->curcfg.sb_height;\
|
|
|
|
SetConsoleScreenBufferSize(data->hConOut, c);\
|
|
|
|
} while (0)
|
|
|
|
#define ChgWinWidth() do {pos.Left = pos.Top = 0; \
|
|
|
|
pos.Right = cfg->win_width - 1; \
|
|
|
|
pos.Bottom = data->curcfg.win_height - 1; \
|
|
|
|
SetConsoleWindowInfo(data->hConOut, FALSE, &pos);\
|
|
|
|
} while (0)
|
|
|
|
#define TstSBfHeight() (force || data->curcfg.sb_height != cfg->sb_height)
|
|
|
|
#define TstWinHeight() (force || data->curcfg.win_height != cfg->win_height)
|
|
|
|
|
|
|
|
/* since we're going to apply height after width is done, we use width as defined
|
|
|
|
* in cfg, and not in data->curcfg because if won't be updated yet */
|
|
|
|
#define ChgSBfHeight() do {c.X = cfg->sb_width; c.Y = cfg->sb_height; \
|
|
|
|
SetConsoleScreenBufferSize(data->hConOut, c); \
|
|
|
|
} while (0)
|
|
|
|
#define ChgWinHeight() do {pos.Left = pos.Top = 0; \
|
|
|
|
pos.Right = cfg->win_width - 1; \
|
|
|
|
pos.Bottom = cfg->win_height - 1; \
|
|
|
|
SetConsoleWindowInfo(data->hConOut, FALSE, &pos);\
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
do
|
2002-09-04 20:41:52 +02:00
|
|
|
{
|
|
|
|
COORD c;
|
|
|
|
SMALL_RECT pos;
|
|
|
|
|
2003-02-26 05:37:15 +01:00
|
|
|
if (TstSBfWidth())
|
|
|
|
{
|
|
|
|
if (TstWinWidth())
|
|
|
|
{
|
|
|
|
/* we're changing both at the same time, do it in the right order */
|
|
|
|
if (cfg->sb_width >= data->curcfg.win_width)
|
|
|
|
{
|
|
|
|
ChgSBfWidth(); ChgWinWidth();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ChgWinWidth(); ChgSBfWidth();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else ChgSBfWidth();
|
|
|
|
}
|
|
|
|
else if (TstWinWidth()) ChgWinWidth();
|
|
|
|
if (TstSBfHeight())
|
|
|
|
{
|
|
|
|
if (TstWinHeight())
|
|
|
|
{
|
|
|
|
if (cfg->sb_height >= data->curcfg.win_height)
|
|
|
|
{
|
|
|
|
ChgSBfHeight(); ChgWinHeight();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ChgWinHeight(); ChgSBfHeight();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else ChgSBfHeight();
|
|
|
|
}
|
|
|
|
else if (TstWinHeight()) ChgWinHeight();
|
|
|
|
} while (0);
|
|
|
|
#undef TstSBfWidth
|
|
|
|
#undef TstWinWidth
|
|
|
|
#undef ChgSBfWidth
|
|
|
|
#undef ChgWinWidth
|
|
|
|
#undef TstSBfHeight
|
|
|
|
#undef TstWinHeight
|
|
|
|
#undef ChgSBfHeight
|
|
|
|
#undef ChgWinHeight
|
|
|
|
|
2002-09-04 20:41:52 +02:00
|
|
|
data->curcfg.exit_on_die = cfg->exit_on_die;
|
2003-01-09 07:01:51 +01:00
|
|
|
if (force || data->curcfg.edition_mode != cfg->edition_mode)
|
|
|
|
{
|
|
|
|
data->curcfg.edition_mode = cfg->edition_mode;
|
|
|
|
WINECON_SetEditionMode(data->hConIn, cfg->edition_mode);
|
|
|
|
}
|
2002-09-04 20:41:52 +02:00
|
|
|
/* we now need to gather all events we got from the operations above,
|
|
|
|
* in order to get data correctly updated
|
|
|
|
*/
|
|
|
|
WINECON_GrabChanges(data);
|
|
|
|
}
|
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
/******************************************************************
|
|
|
|
* WINECON_Delete
|
|
|
|
*
|
|
|
|
* Destroy wineconsole internal data
|
|
|
|
*/
|
|
|
|
static void WINECON_Delete(struct inner_data* data)
|
|
|
|
{
|
|
|
|
if (!data) return;
|
|
|
|
|
2002-12-14 00:37:06 +01:00
|
|
|
if (data->fnDeleteBackend) data->fnDeleteBackend(data);
|
2001-11-24 00:04:58 +01:00
|
|
|
if (data->hConIn) CloseHandle(data->hConIn);
|
|
|
|
if (data->hConOut) CloseHandle(data->hConOut);
|
|
|
|
if (data->hSynchro) CloseHandle(data->hSynchro);
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, data->cells);
|
2001-11-24 00:04:58 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* WINECON_Init
|
|
|
|
*
|
|
|
|
* Initialisation part I. Creation of server object (console input and
|
|
|
|
* active screen buffer)
|
|
|
|
*/
|
2002-10-03 21:54:57 +02:00
|
|
|
static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appname,
|
2003-06-13 18:32:52 +02:00
|
|
|
enum init_return (*backend)(struct inner_data*))
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
|
|
|
struct inner_data* data = NULL;
|
|
|
|
DWORD ret;
|
2002-09-04 20:41:52 +02:00
|
|
|
struct config_data cfg;
|
|
|
|
STARTUPINFOW si;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
|
|
|
data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data));
|
|
|
|
if (!data) return 0;
|
|
|
|
|
2002-09-04 20:41:52 +02:00
|
|
|
GetStartupInfo(&si);
|
|
|
|
|
|
|
|
if (pid == 0)
|
|
|
|
{
|
|
|
|
if (!si.lpTitle) WINECON_Fatal("Should have a title set");
|
|
|
|
appname = si.lpTitle;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* load settings */
|
|
|
|
WINECON_RegLoad(appname, &cfg);
|
|
|
|
|
|
|
|
/* some overrides */
|
|
|
|
if (pid == 0)
|
|
|
|
{
|
|
|
|
if (si.dwFlags & STARTF_USECOUNTCHARS)
|
|
|
|
{
|
|
|
|
cfg.sb_width = si.dwXCountChars;
|
|
|
|
cfg.sb_height = si.dwYCountChars;
|
|
|
|
}
|
|
|
|
if (si.dwFlags & STARTF_USEFILLATTRIBUTE)
|
|
|
|
cfg.def_attr = si.dwFillAttribute;
|
|
|
|
/* should always be defined */
|
|
|
|
}
|
2001-12-04 21:46:54 +01:00
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
/* the handles here are created without the whistles and bells required by console
|
|
|
|
* (mainly because wineconsole doesn't need it)
|
2002-07-02 01:22:48 +02:00
|
|
|
* - they are not inheritable
|
2001-11-24 00:04:58 +01:00
|
|
|
* - hConIn is not synchronizable
|
|
|
|
*/
|
|
|
|
SERVER_START_REQ(alloc_console)
|
|
|
|
{
|
2003-06-21 04:07:10 +02:00
|
|
|
req->access = GENERIC_READ | GENERIC_WRITE;
|
|
|
|
req->inherit = FALSE;
|
2003-06-23 05:37:14 +02:00
|
|
|
req->pid = pid;
|
2003-06-21 04:07:10 +02:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
ret = !wine_server_call_err( req );
|
|
|
|
data->hConIn = (HANDLE)reply->handle_in;
|
|
|
|
data->hSynchro = (HANDLE)reply->event;
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
if (!ret) goto error;
|
2002-09-04 20:41:52 +02:00
|
|
|
WINE_TRACE("using hConIn %p, hSynchro event %p\n", data->hConIn, data->hSynchro);
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_START_REQ( set_console_input_info )
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2002-05-30 22:12:58 +02:00
|
|
|
req->handle = (obj_handle_t)data->hConIn;
|
2001-11-24 00:04:58 +01:00
|
|
|
req->mask = SET_CONSOLE_INPUT_INFO_TITLE;
|
2002-12-14 00:37:06 +01:00
|
|
|
wine_server_add_data( req, appname, lstrlenW(appname) * sizeof(WCHAR) );
|
2001-11-30 19:46:42 +01:00
|
|
|
ret = !wine_server_call_err( req );
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_END_REQ;
|
2001-12-04 21:46:54 +01:00
|
|
|
if (!ret) goto error;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2001-12-04 21:46:54 +01:00
|
|
|
SERVER_START_REQ(create_console_output)
|
|
|
|
{
|
2002-05-30 22:12:58 +02:00
|
|
|
req->handle_in = (obj_handle_t)data->hConIn;
|
2001-12-04 21:46:54 +01:00
|
|
|
req->access = GENERIC_WRITE|GENERIC_READ;
|
|
|
|
req->share = FILE_SHARE_READ|FILE_SHARE_WRITE;
|
|
|
|
req->inherit = FALSE;
|
2002-09-04 20:41:52 +02:00
|
|
|
ret = !wine_server_call_err( req );
|
|
|
|
data->hConOut = (HANDLE)reply->handle_out;
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
2001-12-04 21:46:54 +01:00
|
|
|
SERVER_END_REQ;
|
2002-09-04 20:41:52 +02:00
|
|
|
if (!ret) goto error;
|
|
|
|
WINE_TRACE("using hConOut %p\n", data->hConOut);
|
|
|
|
|
|
|
|
/* filling data->curcfg from cfg */
|
2003-06-13 18:32:52 +02:00
|
|
|
retry:
|
|
|
|
switch ((*backend)(data))
|
2002-09-04 20:41:52 +02:00
|
|
|
{
|
2003-06-13 18:32:52 +02:00
|
|
|
case init_success:
|
2002-09-04 20:41:52 +02:00
|
|
|
WINECON_SetConfig(data, &cfg, TRUE);
|
|
|
|
data->curcfg.registry = cfg.registry;
|
|
|
|
WINECON_DumpConfig("fint", &data->curcfg);
|
|
|
|
return data;
|
2003-06-13 18:32:52 +02:00
|
|
|
case init_failed:
|
|
|
|
break;
|
|
|
|
case init_not_supported:
|
|
|
|
if (backend == WCCURSES_InitBackend)
|
|
|
|
{
|
|
|
|
WINE_ERR("(n)curses was not found at configuration time.\n"
|
|
|
|
"If you want (n)curses support, please install relevant packages.\n"
|
|
|
|
"Now forcing user backend instead of (n)curses.\n");
|
|
|
|
backend = WCUSER_InitBackend;
|
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
break;
|
2002-09-04 20:41:52 +02:00
|
|
|
}
|
2001-11-24 00:04:58 +01:00
|
|
|
|
|
|
|
error:
|
2002-09-04 20:41:52 +02:00
|
|
|
WINE_ERR("failed to init.\n");
|
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
WINECON_Delete(data);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* WINECON_Spawn
|
|
|
|
*
|
2002-06-25 01:00:47 +02:00
|
|
|
* Spawn the child process when invoked with wineconsole foo bar
|
2001-11-24 00:04:58 +01:00
|
|
|
*/
|
2002-09-04 20:41:52 +02:00
|
|
|
static BOOL WINECON_Spawn(struct inner_data* data, LPWSTR cmdLine)
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
|
|
|
PROCESS_INFORMATION info;
|
|
|
|
STARTUPINFO startup;
|
|
|
|
BOOL done;
|
|
|
|
|
|
|
|
/* we're in the case wineconsole <exe> <options>... spawn the new process */
|
|
|
|
memset(&startup, 0, sizeof(startup));
|
|
|
|
startup.cb = sizeof(startup);
|
2001-12-04 21:46:54 +01:00
|
|
|
startup.dwFlags = STARTF_USESTDHANDLES;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
|
|
|
/* the attributes of wineconsole's handles are not adequate for inheritance, so
|
|
|
|
* get them with the correct attributes before process creation
|
|
|
|
*/
|
|
|
|
if (!DuplicateHandle(GetCurrentProcess(), data->hConIn, GetCurrentProcess(),
|
|
|
|
&startup.hStdInput, GENERIC_READ|GENERIC_WRITE|SYNCHRONIZE, TRUE, 0) ||
|
2002-06-01 01:06:46 +02:00
|
|
|
!DuplicateHandle(GetCurrentProcess(), data->hConOut, GetCurrentProcess(),
|
2001-11-24 00:04:58 +01:00
|
|
|
&startup.hStdOutput, GENERIC_READ|GENERIC_WRITE, TRUE, 0) ||
|
2002-06-01 01:06:46 +02:00
|
|
|
!DuplicateHandle(GetCurrentProcess(), data->hConOut, GetCurrentProcess(),
|
2002-09-04 20:41:52 +02:00
|
|
|
&startup.hStdError, GENERIC_READ|GENERIC_WRITE, TRUE, 0))
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2002-05-14 23:45:13 +02:00
|
|
|
WINE_ERR("Can't dup handles\n");
|
2001-11-24 00:04:58 +01:00
|
|
|
/* no need to delete handles, we're exiting the programm anyway */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-09-04 20:41:52 +02:00
|
|
|
done = CreateProcess(NULL, cmdLine, NULL, NULL, TRUE, 0L, NULL, NULL, &startup, &info);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
/* we no longer need the handles passed to the child for the console */
|
|
|
|
CloseHandle(startup.hStdInput);
|
|
|
|
CloseHandle(startup.hStdOutput);
|
|
|
|
CloseHandle(startup.hStdError);
|
|
|
|
|
2003-03-07 21:34:55 +01:00
|
|
|
CloseHandle(info.hProcess);
|
|
|
|
CloseHandle(info.hThread);
|
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
return done;
|
|
|
|
}
|
|
|
|
|
2003-03-04 03:13:25 +01:00
|
|
|
struct wc_init {
|
2003-06-13 18:32:52 +02:00
|
|
|
LPCSTR ptr;
|
2003-03-04 03:13:25 +01:00
|
|
|
enum {from_event, from_process_name} mode;
|
2003-06-13 18:32:52 +02:00
|
|
|
enum init_return (*backend)(struct inner_data*);
|
|
|
|
HANDLE event;
|
2003-03-04 03:13:25 +01:00
|
|
|
};
|
|
|
|
|
2001-12-04 21:46:54 +01:00
|
|
|
/******************************************************************
|
2003-03-04 03:13:25 +01:00
|
|
|
* WINECON_ParseOptions
|
2001-12-04 21:46:54 +01:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2003-03-04 03:13:25 +01:00
|
|
|
static BOOL WINECON_ParseOptions(const char* lpCmdLine, struct wc_init* wci)
|
2001-11-25 01:49:36 +01:00
|
|
|
{
|
2003-03-04 03:13:25 +01:00
|
|
|
memset(wci, 0, sizeof(*wci));
|
|
|
|
wci->ptr = lpCmdLine;
|
|
|
|
wci->mode = from_process_name;
|
|
|
|
wci->backend = WCCURSES_InitBackend;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
while (*wci->ptr == ' ' || *wci->ptr == '\t') wci->ptr++;
|
|
|
|
if (wci->ptr[0] != '-') break;
|
|
|
|
if (strncmp(wci->ptr, "--use-event=", 12) == 0)
|
|
|
|
{
|
|
|
|
char* end;
|
|
|
|
wci->event = (HANDLE)strtol(wci->ptr + 12, &end, 10);
|
|
|
|
if (end == wci->ptr + 12) return FALSE;
|
|
|
|
wci->mode = from_event;
|
|
|
|
wci->ptr = end;
|
2003-03-10 20:03:33 +01:00
|
|
|
wci->backend = WCUSER_InitBackend;
|
2003-03-04 03:13:25 +01:00
|
|
|
}
|
|
|
|
else if (strncmp(wci->ptr, "--backend=", 10) == 0)
|
|
|
|
{
|
|
|
|
if (strncmp(wci->ptr + 10, "user", 4) == 0)
|
|
|
|
{
|
|
|
|
wci->backend = WCUSER_InitBackend;
|
|
|
|
wci->ptr += 14;
|
|
|
|
}
|
|
|
|
else if (strncmp(wci->ptr + 10, "curses", 6) == 0)
|
|
|
|
{
|
|
|
|
wci->ptr += 16;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-03-10 20:03:33 +01:00
|
|
|
else
|
|
|
|
return FALSE;
|
2003-03-04 03:13:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2001-11-25 01:49:36 +01:00
|
|
|
}
|
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
/******************************************************************
|
2002-05-12 01:06:32 +02:00
|
|
|
* WinMain
|
2001-11-24 00:04:58 +01:00
|
|
|
*
|
|
|
|
* wineconsole can either be started as:
|
2001-11-25 01:49:36 +01:00
|
|
|
* wineconsole --use-event=<int> used when a new console is created (AllocConsole)
|
2001-11-24 00:04:58 +01:00
|
|
|
* wineconsole <pgm> <arguments> used to start the program <pgm> from the command line in
|
|
|
|
* a freshly created console
|
2003-03-04 03:13:25 +01:00
|
|
|
* --backend=(curses|user) can also be used to select the desired backend
|
2001-11-24 00:04:58 +01:00
|
|
|
*/
|
2002-05-12 01:06:32 +02:00
|
|
|
int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, INT nCmdShow)
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
|
|
|
struct inner_data* data;
|
|
|
|
int ret = 1;
|
2003-03-04 03:13:25 +01:00
|
|
|
struct wc_init wci;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2003-03-04 03:13:25 +01:00
|
|
|
if (!WINECON_ParseOptions(lpCmdLine, &wci))
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2003-03-04 03:13:25 +01:00
|
|
|
WINE_ERR("Wrong command line options\n");
|
|
|
|
return 0;
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
2002-09-04 20:41:52 +02:00
|
|
|
|
2003-03-04 03:13:25 +01:00
|
|
|
switch (wci.mode)
|
|
|
|
{
|
|
|
|
case from_event:
|
|
|
|
/* case of wineconsole <evt>, signal process that created us that we're up and running */
|
|
|
|
if (!(data = WINECON_Init(hInst, 0, NULL, wci.backend))) return 0;
|
|
|
|
ret = SetEvent(wci.event);
|
|
|
|
if (!ret) WINE_ERR("SetEvent failed.\n");
|
|
|
|
break;
|
|
|
|
case from_process_name:
|
|
|
|
{
|
|
|
|
WCHAR buffer[256];
|
|
|
|
|
2003-03-07 21:34:55 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, wci.ptr, -1, buffer, sizeof(buffer) / sizeof(buffer[0]));
|
2003-03-04 03:13:25 +01:00
|
|
|
|
|
|
|
if (!(data = WINECON_Init(hInst, GetCurrentProcessId(), buffer, wci.backend)))
|
|
|
|
return 0;
|
|
|
|
ret = WINECON_Spawn(data, buffer);
|
|
|
|
if (!ret)
|
|
|
|
WINE_MESSAGE("wineconsole: spawning client program failed (%s), invalid/missing command line arguments ?\n", wine_dbgstr_w(buffer));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 0;
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
|
2002-09-04 20:41:52 +02:00
|
|
|
if (ret)
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2002-06-25 01:00:47 +02:00
|
|
|
WINE_TRACE("calling MainLoop.\n");
|
2001-11-24 00:04:58 +01:00
|
|
|
ret = data->fnMainLoop(data);
|
|
|
|
}
|
2002-06-25 01:00:47 +02:00
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
WINECON_Delete(data);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|