/** Function to call just after loading the library. */
int (*init) ();
/** Function to call to open a frame on the graphic device. */
- void *(*open) (MFrame *frame, MPlist *param);
+ int (*open) (MFrame *frame, MPlist *param);
/** Function to call just before unloading the library. */
int (*fini) ();
} MDeviceLibraryInterface;
static MPlist *device_library_list;
-
/** Close MFrame and free it. */
static void
{
}
-void *
+static void *
null_device_get_prop (MFrame *frame, MSymbol key)
{
return NULL;
}
-void
+static void
null_device_realize_face (MRealizedFace *rface)
{
rface->info = NULL;
}
-void
+static void
null_device_free_realized_face (MRealizedFace *rface)
{
}
return 0;
}
-static void *
+static int
null_device_open (MFrame *frame, MPlist *param)
{
MFace *face;
+ frame->device = NULL;
frame->device_type = 0;
frame->driver = &null_driver;
frame->font_driver_list = mplist ();
face = mface_copy (mface__default);
mplist_push (param, Mface, face);
M17N_OBJECT_UNREF (face);
- return &null_device;
+ return 0;
}
static MDeviceLibraryInterface null_interface =
\f
/* External API */
-void
+int
m17n_init_win (void)
{
int mdebug_mask = MDEBUG_INIT;
if (win_initialized++)
- return;
+ return 0;
m17n_init ();
if (merror_code != MERROR_NONE)
- return;
+ return -1;
MDEBUG_PUSH_TIME ();
if (mfont__init () < 0)
goto err;
MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize font module."));
- MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize win module."));
if (mfont__fontset_init () < 0)
goto err;
MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize fontset module."));
goto err;
MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize input-win module."));
mframe_default = NULL;
+ return 0;
err:
MDEBUG_POP_TIME ();
MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize the m17n GUI module."));
MDEBUG_POP_TIME ();
- return;
+ return -1;
}
void
dlclose (interface->handle);
}
free (interface->library);
- free (interface);
}
- M17N_OBJECT_UNREF (device_library_list);
#ifdef HAVE_FREETYPE
if (null_interface.handle)
(*null_interface.fini) ();
#endif /* not HAVE_FREETYPE */
+ M17N_OBJECT_UNREF (device_library_list);
MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize input-gui module."));
minput__win_fini ();
MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize draw module."));
if (! interface->handle)
{
(*interface->init) ();
- interface->handle = Mt;
+ interface->handle = (void *) 1;
}
#else /* not HAVE_FREETYPE */
MERROR (MERROR_WIN, NULL);
MERROR (MERROR_WIN, NULL);
if (! interface->handle)
{
- interface->handle = dlopen (interface->library, RTLD_NOW);
- if (! interface->handle)
- MERROR (MERROR_WIN, NULL);
- interface->init = dlsym (interface->handle, "device_init");
- interface->open = dlsym (interface->handle, "device_open");
- interface->fini = dlsym (interface->handle, "device_fini");
- if (! interface->init || ! interface->open || ! interface->fini
+ if (! (interface->handle = dlopen (interface->library, RTLD_NOW))
+ || ! (interface->init = dlsym (interface->handle, "device_init"))
+ || ! (interface->open = dlsym (interface->handle, "device_open"))
+ || ! (interface->fini = dlsym (interface->handle, "device_fini"))
|| (*interface->init) () < 0)
{
- dlclose (interface->handle);
+ fprintf (stderr, "%s\n", (char *) dlerror ());
+ if (interface->handle)
+ dlclose (interface->handle);
MERROR (MERROR_WIN, NULL);
}
}
}
M17N_OBJECT (frame, free_frame, MERROR_FRAME);
- if (! (frame->device = (*interface->open) (frame, plist)))
+ if ((*interface->open) (frame, plist) < 0)
{
free (frame);
MERROR (MERROR_WIN, NULL);