X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fm17n-gui.c;h=cac713a1a0bdf9b818ba625b10cc4891d5af1c2d;hb=8b6752e826a02f1a3efa94262836caa98333ee23;hp=28a1f18b1507e7755f7de27db92a4826a756256d;hpb=ecae8da462d41d982fc1bb81aa65242c7103926e;p=m17n%2Fm17n-lib.git diff --git a/src/m17n-gui.c b/src/m17n-gui.c index 28a1f18..cac713a 100644 --- a/src/m17n-gui.c +++ b/src/m17n-gui.c @@ -96,7 +96,7 @@ typedef struct /** 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; @@ -106,7 +106,6 @@ typedef struct static MPlist *device_library_list; - /** Close MFrame and free it. */ static void @@ -154,19 +153,19 @@ null_device_close (MFrame *frame) { } -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) { } @@ -207,11 +206,12 @@ null_device_fini () 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 (); @@ -222,7 +222,7 @@ null_device_open (MFrame *frame, MPlist *param) face = mface_copy (mface__default); mplist_push (param, Mface, face); M17N_OBJECT_UNREF (face); - return &null_device; + return 0; } static MDeviceLibraryInterface null_interface = @@ -240,16 +240,16 @@ MSymbol Mfreetype; /* 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 (); @@ -276,7 +276,6 @@ m17n_init_win (void) 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.")); @@ -290,12 +289,13 @@ m17n_init_win (void) 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 @@ -323,13 +323,12 @@ m17n_fini_win (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.")); @@ -624,7 +623,7 @@ mframe (MPlist *plist) if (! interface->handle) { (*interface->init) (); - interface->handle = Mt; + interface->handle = (void *) 1; } #else /* not HAVE_FREETYPE */ MERROR (MERROR_WIN, NULL); @@ -637,23 +636,22 @@ mframe (MPlist *plist) 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);