this patch prints out some information, and falls back to user backend if curses' is not available
A+ -- Eric Pouech
Name: wc_init ChangeLog: if (n)curses wasn't available at compile time: - print sensible information - falls back to user backend License: X11 GenDate: 2003/06/08 10:14:38 UTC ModifiedFiles: programs/wineconsole/wineconsole.c programs/wineconsole/winecon_private.h programs/wineconsole/user.c programs/wineconsole/curses.c =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/programs/wineconsole/wineconsole.c,v retrieving revision 1.25 diff -u -u -r1.25 wineconsole.c --- programs/wineconsole/wineconsole.c 17 Mar 2003 21:20:41 -0000 1.25 +++ programs/wineconsole/wineconsole.c 8 Jun 2003 09:56:19 -0000 @@ -529,12 +529,12 @@ * active screen buffer) */ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appname, - BOOL (*backend)(struct inner_data*)) + enum init_return (*backend)(struct inner_data*)) { struct inner_data* data = NULL; DWORD ret; struct config_data cfg; STARTUPINFOW si; data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data)); if (!data) return 0; @@ -605,12 +609,26 @@ WINE_TRACE("using hConOut %p\n", data->hConOut); /* filling data->curcfg from cfg */ - if ((*backend)(data)) + retry: + switch ((*backend)(data)) { + case init_success: WINECON_SetConfig(data, &cfg, TRUE); data->curcfg.registry = cfg.registry; WINECON_DumpConfig("fint", &data->curcfg); return data; + 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; } error: @@ -665,10 +683,10 @@ } struct wc_init { - LPCSTR ptr; + LPCSTR ptr; enum {from_event, from_process_name} mode; - BOOL (*backend)(struct inner_data*); - HANDLE event; + enum init_return (*backend)(struct inner_data*); + HANDLE event; }; /****************************************************************** Index: programs/wineconsole/winecon_private.h =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/programs/wineconsole/winecon_private.h,v retrieving revision 1.10 diff -u -u -r1.10 winecon_private.h --- programs/wineconsole/winecon_private.h 9 Jan 2003 06:01:51 -0000 1.10 +++ programs/wineconsole/winecon_private.h 8 Jun 2003 09:47:58 -0000 @@ -89,5 +89,8 @@ extern void WINECON_DumpConfig(const char* pfx, const struct config_data* cfg); /* backends... */ -extern BOOL WCUSER_InitBackend(struct inner_data* data); -extern BOOL WCCURSES_InitBackend(struct inner_data* data); +enum init_return { + init_success, init_failed, init_not_supported +}; +extern enum init_return WCUSER_InitBackend(struct inner_data* data); +extern enum init_return WCCURSES_InitBackend(struct inner_data* data); Index: programs/wineconsole/user.c =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/programs/wineconsole/user.c,v retrieving revision 1.19 diff -u -u -r1.19 user.c --- programs/wineconsole/user.c 25 Feb 2003 03:58:22 -0000 1.19 +++ programs/wineconsole/user.c 8 Jun 2003 09:49:22 -0000 @@ -1353,14 +1353,14 @@ * Initialisation part II: creation of window. * */ -BOOL WCUSER_InitBackend(struct inner_data* data) +enum init_return WCUSER_InitBackend(struct inner_data* data) { static WCHAR wClassName[] = {'W','i','n','e','C','o','n','s','o','l','e','C','l','a','s','s',0}; WNDCLASS wndclass; data->private = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct inner_data_user)); - if (!data->private) return FALSE; + if (!data->private) return init_failed; data->fnMainLoop = WCUSER_MainLoop; data->fnPosCursor = WCUSER_PosCursor; @@ -1389,7 +1389,7 @@ CreateWindow(wndclass.lpszClassName, NULL, WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_MINIMIZEBOX|WS_HSCROLL|WS_VSCROLL, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, 0, 0, wndclass.hInstance, data); - if (!PRIVATE(data)->hWnd) return FALSE; + if (!PRIVATE(data)->hWnd) return init_failed; - return TRUE; + return init_success; } Index: programs/wineconsole/curses.c =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/programs/wineconsole/curses.c,v retrieving revision 1.8 diff -u -u -r1.8 curses.c --- programs/wineconsole/curses.c 4 Jun 2003 20:14:47 -0000 1.8 +++ programs/wineconsole/curses.c 8 Jun 2003 09:52:52 -0000 @@ -717,10 +717,10 @@ * Initialisation part II: creation of window. * */ -BOOL WCCURSES_InitBackend(struct inner_data* data) +enum init_return WCCURSES_InitBackend(struct inner_data* data) { data->private = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct inner_data_curse)); - if (!data->private) return FALSE; + if (!data->private) return init_failed; data->fnMainLoop = WCCURSES_MainLoop; data->fnPosCursor = WCCURSES_PosCursor; @@ -737,7 +737,7 @@ (obj_handle_t*)&PRIVATE(data)->hInput)) { WINE_FIXME("Cannot open 0\n"); - return 0; + return init_failed; } /* FIXME: should find a good way to enable buffer scrolling @@ -782,12 +782,12 @@ mousemask(0, &PRIVATE(data)->initial_mouse_mask); } - return TRUE; + return init_success; } #else BOOL WCCURSES_InitBackend(struct inner_data* data) { - return FALSE; + return init_not_supported; } #endif