mirror of https://github.com/encounter/SDL.git
os2, geniconv: default functions pointers to Uni*() API,
In case they get accessed before SDL_Init() was called.
This commit is contained in:
parent
67cb548bef
commit
d2456b6e4c
|
@ -46,17 +46,17 @@ extern size_t _System os2_iconv (iconv_t cd,
|
||||||
char **outbuf, size_t *outbytesleft);
|
char **outbuf, size_t *outbytesleft);
|
||||||
extern int _System os2_iconv_close (iconv_t cd);
|
extern int _System os2_iconv_close (iconv_t cd);
|
||||||
|
|
||||||
/* Functions pointers types */
|
/* Functions pointers */
|
||||||
typedef iconv_t (_System *FNICONV_OPEN)(const char*, const char*);
|
typedef iconv_t (_System *FNICONV_OPEN)(const char*, const char*);
|
||||||
typedef size_t (_System *FNICONV) (iconv_t, char **, size_t *, char **, size_t *);
|
typedef size_t (_System *FNICONV) (iconv_t, char **, size_t *, char **, size_t *);
|
||||||
typedef int (_System *FNICONV_CLOSE)(iconv_t);
|
typedef int (_System *FNICONV_CLOSE)(iconv_t);
|
||||||
|
|
||||||
/* Used DLL module handle */
|
|
||||||
static HMODULE hmIconv = NULLHANDLE;
|
static HMODULE hmIconv = NULLHANDLE;
|
||||||
/* Functions pointers */
|
static FNICONV_OPEN fn_iconv_open = os2_iconv_open;
|
||||||
static FNICONV_OPEN fn_iconv_open = NULL;
|
static FNICONV fn_iconv = os2_iconv;
|
||||||
static FNICONV fn_iconv = NULL;
|
static FNICONV_CLOSE fn_iconv_close = os2_iconv_close;
|
||||||
static FNICONV_CLOSE fn_iconv_close = NULL;
|
|
||||||
|
static int geniconv_init = 0;
|
||||||
|
|
||||||
|
|
||||||
static BOOL _loadDLL(const char *dllname,
|
static BOOL _loadDLL(const char *dllname,
|
||||||
|
@ -102,10 +102,12 @@ static BOOL _loadDLL(const char *dllname,
|
||||||
|
|
||||||
static void _init(void)
|
static void _init(void)
|
||||||
{
|
{
|
||||||
if (fn_iconv_open != NULL) {
|
if (geniconv_init) {
|
||||||
return; /* Already initialized */
|
return; /* Already initialized */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
geniconv_init = 1;
|
||||||
|
|
||||||
/* Try to load kiconv.dll, iconv2.dll or iconv.dll */
|
/* Try to load kiconv.dll, iconv2.dll or iconv.dll */
|
||||||
if (!_loadDLL("KICONV", "_libiconv_open", "_libiconv", "_libiconv_close") &&
|
if (!_loadDLL("KICONV", "_libiconv_open", "_libiconv", "_libiconv_close") &&
|
||||||
!_loadDLL("ICONV2", "_libiconv_open", "_libiconv", "_libiconv_close") &&
|
!_loadDLL("ICONV2", "_libiconv_open", "_libiconv", "_libiconv_close") &&
|
||||||
|
@ -123,16 +125,19 @@ static void _init(void)
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Non-standard function for iconv to unload the used dynamic library */
|
/* function to unload the used iconv dynamic library */
|
||||||
void libiconv_clean(void)
|
void libiconv_clean(void)
|
||||||
{
|
{
|
||||||
|
geniconv_init = 0;
|
||||||
|
|
||||||
|
/* reset the function pointers. */
|
||||||
|
fn_iconv_open = os2_iconv_open;
|
||||||
|
fn_iconv = os2_iconv;
|
||||||
|
fn_iconv_close = os2_iconv_close;
|
||||||
|
|
||||||
if (hmIconv != NULLHANDLE) {
|
if (hmIconv != NULLHANDLE) {
|
||||||
DosFreeModule(hmIconv);
|
DosFreeModule(hmIconv);
|
||||||
hmIconv = NULLHANDLE;
|
hmIconv = NULLHANDLE;
|
||||||
|
|
||||||
fn_iconv_open = NULL;
|
|
||||||
fn_iconv = NULL;
|
|
||||||
fn_iconv_close = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue