Changelog: - Try ncursesw, ncurses and curses so library before giving up at startup
diff -ur wine-20031016/programs/wineconsole/curses.c wine-my/programs/wineconsole/curses.c --- wine-20031016/programs/wineconsole/curses.c 2003-10-15 23:01:05.000000000 +0200 +++ wine-my/programs/wineconsole/curses.c 2003-11-14 05:20:46.000000000 +0100 @@ -61,14 +61,6 @@ #define PRIVATE(data) ((struct inner_data_curse*)((data)->private)) #if defined(HAVE_CURSES_H) || defined(HAVE_NCURSES_H) || defined(HAVE_NCURSESW_NCURSES_H) - -#ifdef HAVE_NCURSESW_NCURSES_H -# define CURSES_NAME "ncursesw" -#elif defined(HAVE_NCURSES_H) -# define CURSES_NAME "ncurses" -#else -# define CURSES_NAME "curses" -#endif struct inner_data_curse { @@ -79,8 +71,29 @@ int allow_scroll; }; +struct curses_type +{ + char *name; + char *soname; + int sizeof_char; +}; + +static const struct curses_type curses_known [] = + { +#ifdef SONAME_LIBCURSES + {"curses", SONAME_LIBCURSES , sizeof(chtype)}, +#endif +#ifdef SONAME_LIBNCURSES + {"ncurses", SONAME_LIBNCURSES , sizeof(chtype)}, +#endif +#ifdef SONAME_LIBNCURSESW + {"ncursesw", SONAME_LIBNCURSESW, sizeof(cchar_t)}, +#endif + }; +#define NC_MAX_KNOWN (sizeof(curses_known)/sizeof(curses_known[0])) static void *nc_handle = NULL; +static const struct curses_type *nc_type = NULL; #define MAKE_FUNCPTR(f) static typeof(f) * p_##f; @@ -121,18 +134,26 @@ static BOOL WCCURSES_bind_libcurses(void) { -#ifdef HAVE_NCURSES_H - static const char *ncname = SONAME_LIBNCURSES; -#else - static const char *ncname = SONAME_LIBCURSES; -#endif + int nc_no = NC_MAX_KNOWN -1; + char err_buf[256]; + + retry: + while(nc_no >= 0) + { + nc_type = &curses_known[nc_no]; + nc_handle = wine_dlopen(nc_type->soname, RTLD_NOW, err_buf, 256); + if (nc_handle) break; + WINE_TRACE("dlopening %s (%s) failed:\n%s\n", + nc_type->name,nc_type->soname,err_buf); + nc_no--; + } - nc_handle = wine_dlopen(ncname, RTLD_NOW, NULL, 0); - if(!nc_handle) + if (nc_no < 0) { - WINE_MESSAGE("Wine cannot find the " CURSES_NAME " library (%s).\n", - ncname); - return FALSE; + WINE_WARN("Wine cannot find any suitable variants of the curses library:\n"); + for (nc_no = NC_MAX_KNOWN - 1; nc_no >= 0; nc_no--) + WINE_WARN("%s\n",curses_known[nc_no].soname); + return FALSE; } #define LOAD_FUNCPTR(f) \ @@ -175,16 +196,18 @@ #undef LOAD_FUNCPTR + WINE_TRACE("Using %s (%s) at %p.\n",nc_type->name,nc_type->soname,nc_handle); return TRUE; sym_not_found: WINE_MESSAGE( - "Wine cannot find certain functions that it needs inside the " - CURSES_NAME "\nlibrary. To enable Wine to use " CURSES_NAME - " please upgrade your " CURSES_NAME "\nlibraries\n"); + "Wine cannot find certain functions that it needs inside the %s\n" + "library. To enable Wine to use %s please upgrade your %s\n" + "libraries (%s)\n",nc_type->name,nc_type->name,nc_type->name,nc_type->soname); wine_dlclose(nc_handle, NULL, 0); nc_handle = NULL; - return FALSE; + nc_no--; + goto retry; } #define curs_set p_curs_set @@ -232,10 +255,10 @@ WINE_FIXME("Cannot create pad\n"); if (PRIVATE(data)->line) PRIVATE(data)->line = HeapReAlloc(GetProcessHeap(), 0, PRIVATE(data)->line, - sizeof(chtype) * data->curcfg.sb_width); + nc_type->sizeof_char * data->curcfg.sb_width); else PRIVATE(data)->line = HeapAlloc(GetProcessHeap(), 0, - sizeof(chtype) * data->curcfg.sb_width); + nc_type->sizeof_char * data->curcfg.sb_width); if (!PRIVATE(data)->line) WINE_FIXME("Cannot create line\n"); }