|
1 /* GMODULE - GLIB wrapper code for dynamic module loading |
|
2 * Copyright (C) 1998 Tim Janik |
|
3 * Portions copyright (c) 2006 Nokia Corporation. All rights reserved. |
|
4 * |
|
5 * This library is free software; you can redistribute it and/or |
|
6 * modify it under the terms of the GNU Lesser General Public |
|
7 * License as published by the Free Software Foundation; either |
|
8 * version 2 of the License, or (at your option) any later version. |
|
9 * |
|
10 * This library is distributed in the hope that it will be useful, |
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 * Lesser General Public License for more details. |
|
14 * |
|
15 * You should have received a copy of the GNU Lesser General Public |
|
16 * License along with this library; if not, write to the |
|
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
18 * Boston, MA 02111-1307, USA. |
|
19 */ |
|
20 |
|
21 /* |
|
22 * Modified by the GLib Team and others 1997-2000. See the AUTHORS |
|
23 * file for a list of people on the GLib Team. See the ChangeLog |
|
24 * files for a list of changes. These files are distributed with |
|
25 * GLib at ftp://ftp.gtk.org/pub/gtk/. |
|
26 */ |
|
27 |
|
28 /* |
|
29 * MT safe |
|
30 */ |
|
31 |
|
32 #ifdef HAVE_CONFIG_H |
|
33 # include <config.h> |
|
34 #endif |
|
35 #include "gstdio.h" |
|
36 #include "gmodule.h" |
|
37 #include "gmoduleconf.h" |
|
38 #include <errno.h> |
|
39 #include <string.h> |
|
40 #include <sys/types.h> |
|
41 #include <sys/stat.h> |
|
42 #include <fcntl.h> |
|
43 #ifdef HAVE_UNISTD_H |
|
44 # include <unistd.h> |
|
45 #endif |
|
46 #if defined (G_OS_WIN32) |
|
47 # include <io.h> /* For open() and close() prototypes. */ |
|
48 #endif |
|
49 |
|
50 #ifdef __SYMBIAN32__ |
|
51 #include <gmodule_wsd.h> |
|
52 #endif /* __SYMBIAN32__ */ |
|
53 |
|
54 /* We maintain a list of modules, so we can reference count them. |
|
55 * That's needed because some platforms don't support refernce counts on |
|
56 * modules e.g. the shl_* implementation of HP-UX |
|
57 * (http://www.stat.umn.edu/~luke/xls/projects/dlbasics/dlbasics.html). |
|
58 * Also, the module for the program itself is kept seperatedly for |
|
59 * faster access and because it has special semantics. |
|
60 */ |
|
61 |
|
62 |
|
63 /* --- structures --- */ |
|
64 struct _GModule |
|
65 { |
|
66 gchar *file_name; |
|
67 #ifdef G_OS_WIN32 |
|
68 gchar *cp_file_name; |
|
69 #endif |
|
70 gpointer handle; |
|
71 guint ref_count : 31; |
|
72 guint is_resident : 1; |
|
73 GModuleUnload unload; |
|
74 GModule *next; |
|
75 }; |
|
76 |
|
77 |
|
78 /* --- prototypes --- */ |
|
79 static gpointer _g_module_open (const gchar *file_name, |
|
80 gboolean bind_lazy, |
|
81 gboolean bind_local); |
|
82 static void _g_module_close (gpointer handle, |
|
83 gboolean is_unref); |
|
84 static gpointer _g_module_self (void); |
|
85 static gpointer _g_module_symbol (gpointer handle, |
|
86 const gchar *symbol_name); |
|
87 static gchar* _g_module_build_path (const gchar *directory, |
|
88 const gchar *module_name); |
|
89 static inline void g_module_set_error (const gchar *error); |
|
90 static inline GModule* g_module_find_by_handle (gpointer handle); |
|
91 static inline GModule* g_module_find_by_name (const gchar *name); |
|
92 |
|
93 |
|
94 /* --- variables --- */ |
|
95 #if EMULATOR |
|
96 |
|
97 PLS(modules,gmodule,GModule *) |
|
98 PLS(main_module,gmodule,GModule *) |
|
99 PLS(module_error_private,gmodule,GStaticPrivate) |
|
100 |
|
101 #define modules (*FUNCTION_NAME(modules,gmodule)()) |
|
102 #define main_module (*FUNCTION_NAME(main_module,gmodule)()) |
|
103 #define module_error_private (*FUNCTION_NAME(module_error_private,gmodule)()) |
|
104 |
|
105 #else |
|
106 static GModule *modules = NULL; |
|
107 static GModule *main_module = NULL; |
|
108 static GStaticPrivate module_error_private = G_STATIC_PRIVATE_INIT; |
|
109 #endif /* EMULATOR */ |
|
110 |
|
111 |
|
112 /* --- inline functions --- */ |
|
113 static inline GModule* |
|
114 g_module_find_by_handle (gpointer handle) |
|
115 { |
|
116 GModule *module; |
|
117 GModule *retval = NULL; |
|
118 |
|
119 if (main_module && main_module->handle == handle) |
|
120 retval = main_module; |
|
121 else |
|
122 for (module = modules; module; module = module->next) |
|
123 if (handle == module->handle) |
|
124 { |
|
125 retval = module; |
|
126 break; |
|
127 } |
|
128 |
|
129 return retval; |
|
130 } |
|
131 |
|
132 static inline GModule* |
|
133 g_module_find_by_name (const gchar *name) |
|
134 { |
|
135 GModule *module; |
|
136 GModule *retval = NULL; |
|
137 |
|
138 for (module = modules; module; module = module->next) |
|
139 if (strcmp (name, module->file_name) == 0) |
|
140 { |
|
141 retval = module; |
|
142 break; |
|
143 } |
|
144 |
|
145 return retval; |
|
146 } |
|
147 |
|
148 static inline void |
|
149 g_module_set_error_unduped (gchar *error) |
|
150 { |
|
151 g_static_private_set (&module_error_private, error, g_free); |
|
152 errno = 0; |
|
153 } |
|
154 |
|
155 static inline void |
|
156 g_module_set_error (const gchar *error) |
|
157 { |
|
158 g_module_set_error_unduped (g_strdup (error)); |
|
159 } |
|
160 |
|
161 |
|
162 /* --- include platform specifc code --- */ |
|
163 #define SUPPORT_OR_RETURN(rv) { g_module_set_error (NULL); } |
|
164 #if (G_MODULE_IMPL == G_MODULE_IMPL_DL) |
|
165 #include "gmodule-dl.c" |
|
166 #elif (G_MODULE_IMPL == G_MODULE_IMPL_DLD) |
|
167 #include "gmodule-dld.c" |
|
168 #elif (G_MODULE_IMPL == G_MODULE_IMPL_WIN32) |
|
169 #include "gmodule-win32.c" |
|
170 #elif (G_MODULE_IMPL == G_MODULE_IMPL_DYLD) |
|
171 #include "gmodule-dyld.c" |
|
172 #elif (G_MODULE_IMPL == G_MODULE_IMPL_AR) |
|
173 #include "gmodule-ar.c" |
|
174 #else |
|
175 #undef SUPPORT_OR_RETURN |
|
176 #define SUPPORT_OR_RETURN(rv) { g_module_set_error ("dynamic modules are " \ |
|
177 "not supported by this system"); return rv; } |
|
178 static gpointer |
|
179 _g_module_open (const gchar *file_name, |
|
180 gboolean bind_lazy, |
|
181 gboolean bind_local) |
|
182 { |
|
183 return NULL; |
|
184 } |
|
185 static void |
|
186 _g_module_close (gpointer handle, |
|
187 gboolean is_unref) |
|
188 { |
|
189 } |
|
190 static gpointer |
|
191 _g_module_self (void) |
|
192 { |
|
193 return NULL; |
|
194 } |
|
195 static gpointer |
|
196 _g_module_symbol (gpointer handle, |
|
197 const gchar *symbol_name) |
|
198 { |
|
199 return NULL; |
|
200 } |
|
201 static gchar* |
|
202 _g_module_build_path (const gchar *directory, |
|
203 const gchar *module_name) |
|
204 { |
|
205 return NULL; |
|
206 } |
|
207 #endif /* no implementation */ |
|
208 |
|
209 /* --- functions --- */ |
|
210 EXPORT_C gboolean |
|
211 g_module_supported (void) |
|
212 { |
|
213 SUPPORT_OR_RETURN (FALSE); |
|
214 |
|
215 return TRUE; |
|
216 } |
|
217 |
|
218 static gchar* |
|
219 parse_libtool_archive (const gchar* libtool_name) |
|
220 { |
|
221 const guint TOKEN_DLNAME = G_TOKEN_LAST + 1; |
|
222 const guint TOKEN_INSTALLED = G_TOKEN_LAST + 2; |
|
223 const guint TOKEN_LIBDIR = G_TOKEN_LAST + 3; |
|
224 gchar *lt_dlname = NULL; |
|
225 gboolean lt_installed = TRUE; |
|
226 gchar *lt_libdir = NULL; |
|
227 gchar *name; |
|
228 GTokenType token; |
|
229 GScanner *scanner; |
|
230 |
|
231 int fd = g_open (libtool_name, O_RDONLY, 0); |
|
232 if (fd < 0) |
|
233 { |
|
234 gchar *display_libtool_name = g_filename_display_name (libtool_name); |
|
235 g_module_set_error_unduped (g_strdup_printf ("failed to open libtool archive \"%s\"", display_libtool_name)); |
|
236 g_free (display_libtool_name); |
|
237 return NULL; |
|
238 } |
|
239 /* search libtool's dlname specification */ |
|
240 scanner = g_scanner_new (NULL); |
|
241 g_scanner_input_file (scanner, fd); |
|
242 scanner->config->symbol_2_token = TRUE; |
|
243 g_scanner_scope_add_symbol (scanner, 0, "dlname", |
|
244 GUINT_TO_POINTER (TOKEN_DLNAME)); |
|
245 g_scanner_scope_add_symbol (scanner, 0, "installed", |
|
246 GUINT_TO_POINTER (TOKEN_INSTALLED)); |
|
247 g_scanner_scope_add_symbol (scanner, 0, "libdir", |
|
248 GUINT_TO_POINTER (TOKEN_LIBDIR)); |
|
249 while (!g_scanner_eof (scanner)) |
|
250 { |
|
251 token = g_scanner_get_next_token (scanner); |
|
252 if (token == TOKEN_DLNAME || token == TOKEN_INSTALLED || |
|
253 token == TOKEN_LIBDIR) |
|
254 { |
|
255 if (g_scanner_get_next_token (scanner) != '=' || |
|
256 g_scanner_get_next_token (scanner) != |
|
257 (token == TOKEN_INSTALLED ? |
|
258 G_TOKEN_IDENTIFIER : G_TOKEN_STRING)) |
|
259 { |
|
260 gchar *display_libtool_name = g_filename_display_name (libtool_name); |
|
261 g_module_set_error_unduped (g_strdup_printf ("unable to parse libtool archive \"%s\"", display_libtool_name)); |
|
262 g_free (display_libtool_name); |
|
263 |
|
264 g_free (lt_dlname); |
|
265 g_free (lt_libdir); |
|
266 g_scanner_destroy (scanner); |
|
267 close (fd); |
|
268 |
|
269 return NULL; |
|
270 } |
|
271 else |
|
272 { |
|
273 if (token == TOKEN_DLNAME) |
|
274 { |
|
275 g_free (lt_dlname); |
|
276 lt_dlname = g_strdup (scanner->value.v_string); |
|
277 } |
|
278 else if (token == TOKEN_INSTALLED) |
|
279 lt_installed = |
|
280 strcmp (scanner->value.v_identifier, "yes") == 0; |
|
281 else /* token == TOKEN_LIBDIR */ |
|
282 { |
|
283 g_free (lt_libdir); |
|
284 lt_libdir = g_strdup (scanner->value.v_string); |
|
285 } |
|
286 } |
|
287 } |
|
288 } |
|
289 |
|
290 if (!lt_installed) |
|
291 { |
|
292 gchar *dir = g_path_get_dirname (libtool_name); |
|
293 g_free (lt_libdir); |
|
294 lt_libdir = g_strconcat (dir, G_DIR_SEPARATOR_S ".libs", NULL); |
|
295 g_free (dir); |
|
296 } |
|
297 |
|
298 name = g_strconcat (lt_libdir, G_DIR_SEPARATOR_S, lt_dlname, NULL); |
|
299 |
|
300 g_free (lt_dlname); |
|
301 g_free (lt_libdir); |
|
302 g_scanner_destroy (scanner); |
|
303 close (fd); |
|
304 |
|
305 return name; |
|
306 } |
|
307 |
|
308 static inline gboolean |
|
309 str_check_suffix (const gchar* string, |
|
310 const gchar* suffix) |
|
311 { |
|
312 gsize string_len = strlen (string); |
|
313 gsize suffix_len = strlen (suffix); |
|
314 |
|
315 return string_len >= suffix_len && |
|
316 strcmp (string + string_len - suffix_len, suffix) == 0; |
|
317 } |
|
318 |
|
319 #if EMULATOR |
|
320 |
|
321 PLS(g_module_global_lock,gmodule,GStaticRecMutex) |
|
322 #define g_module_global_lock (*FUNCTION_NAME(g_module_global_lock,gmodule)()) |
|
323 |
|
324 #else |
|
325 |
|
326 static GStaticRecMutex g_module_global_lock = G_STATIC_REC_MUTEX_INIT; |
|
327 |
|
328 #endif /* EMULATOR */ |
|
329 |
|
330 EXPORT_C GModule* |
|
331 g_module_open (const gchar *file_name, |
|
332 GModuleFlags flags) |
|
333 { |
|
334 GModule *module; |
|
335 gpointer handle = NULL; |
|
336 gchar *name = NULL; |
|
337 |
|
338 SUPPORT_OR_RETURN (NULL); |
|
339 |
|
340 g_static_rec_mutex_lock (&g_module_global_lock); |
|
341 if (!file_name) |
|
342 { |
|
343 if (!main_module) |
|
344 { |
|
345 handle = _g_module_self (); |
|
346 if (handle) |
|
347 { |
|
348 main_module = g_new (GModule, 1); |
|
349 main_module->file_name = NULL; |
|
350 #ifdef G_OS_WIN32 |
|
351 main_module->cp_file_name = NULL; |
|
352 #endif |
|
353 main_module->handle = handle; |
|
354 main_module->ref_count = 1; |
|
355 main_module->is_resident = TRUE; |
|
356 main_module->unload = NULL; |
|
357 main_module->next = NULL; |
|
358 } |
|
359 } |
|
360 else |
|
361 main_module->ref_count++; |
|
362 |
|
363 g_static_rec_mutex_unlock (&g_module_global_lock); |
|
364 return main_module; |
|
365 } |
|
366 |
|
367 /* we first search the module list by name */ |
|
368 module = g_module_find_by_name (file_name); |
|
369 if (module) |
|
370 { |
|
371 module->ref_count++; |
|
372 |
|
373 g_static_rec_mutex_unlock (&g_module_global_lock); |
|
374 return module; |
|
375 } |
|
376 |
|
377 /* check whether we have a readable file right away */ |
|
378 if (g_file_test (file_name, G_FILE_TEST_IS_REGULAR)) |
|
379 name = g_strdup (file_name); |
|
380 /* try completing file name with standard library suffix */ |
|
381 if (!name) |
|
382 { |
|
383 name = g_strconcat (file_name, "." G_MODULE_SUFFIX, NULL); |
|
384 if (!g_file_test (name, G_FILE_TEST_IS_REGULAR)) |
|
385 { |
|
386 g_free (name); |
|
387 name = NULL; |
|
388 } |
|
389 } |
|
390 /* try completing by appending libtool suffix */ |
|
391 if (!name) |
|
392 { |
|
393 name = g_strconcat (file_name, ".la", NULL); |
|
394 if (!g_file_test (name, G_FILE_TEST_IS_REGULAR)) |
|
395 { |
|
396 g_free (name); |
|
397 name = NULL; |
|
398 } |
|
399 } |
|
400 /* we can't access() the file, lets hope the platform backends finds |
|
401 * it via library paths |
|
402 */ |
|
403 if (!name) |
|
404 { |
|
405 gchar *dot = strrchr (file_name, '.'); |
|
406 gchar *slash = strrchr (file_name, G_DIR_SEPARATOR); |
|
407 |
|
408 /* make sure the name has a suffix */ |
|
409 if (!dot || dot < slash) |
|
410 name = g_strconcat (file_name, "." G_MODULE_SUFFIX, NULL); |
|
411 else |
|
412 name = g_strdup (file_name); |
|
413 } |
|
414 |
|
415 /* ok, try loading the module */ |
|
416 if (name) |
|
417 { |
|
418 /* if it's a libtool archive, figure library file to load */ |
|
419 if (str_check_suffix (name, ".la")) /* libtool archive? */ |
|
420 { |
|
421 gchar *real_name = parse_libtool_archive (name); |
|
422 |
|
423 /* real_name might be NULL, but then module error is already set */ |
|
424 g_free (name); |
|
425 name = real_name; |
|
426 } |
|
427 if (name) |
|
428 handle = _g_module_open (name, (flags & G_MODULE_BIND_LAZY) != 0, |
|
429 (flags & G_MODULE_BIND_LOCAL) != 0); |
|
430 } |
|
431 else |
|
432 { |
|
433 gchar *display_file_name = g_filename_display_name (file_name); |
|
434 g_module_set_error_unduped (g_strdup_printf ("unable to access file \"%s\"", display_file_name)); |
|
435 g_free (display_file_name); |
|
436 } |
|
437 g_free (name); |
|
438 |
|
439 if (handle) |
|
440 { |
|
441 gchar *saved_error; |
|
442 GModuleCheckInit check_init; |
|
443 const gchar *check_failed = NULL; |
|
444 |
|
445 /* search the module list by handle, since file names are not unique */ |
|
446 module = g_module_find_by_handle (handle); |
|
447 if (module) |
|
448 { |
|
449 _g_module_close (module->handle, TRUE); |
|
450 module->ref_count++; |
|
451 g_module_set_error (NULL); |
|
452 |
|
453 g_static_rec_mutex_unlock (&g_module_global_lock); |
|
454 return module; |
|
455 } |
|
456 |
|
457 saved_error = g_strdup (g_module_error ()); |
|
458 g_module_set_error (NULL); |
|
459 module = g_new (GModule, 1); |
|
460 module->file_name = g_strdup (file_name); |
|
461 #ifdef G_OS_WIN32 |
|
462 module->cp_file_name = g_locale_from_utf8 (file_name, -1, |
|
463 NULL, NULL, NULL); |
|
464 #endif |
|
465 module->handle = handle; |
|
466 module->ref_count = 1; |
|
467 module->is_resident = FALSE; |
|
468 module->unload = NULL; |
|
469 module->next = modules; |
|
470 modules = module; |
|
471 |
|
472 /* check initialization */ |
|
473 if (g_module_symbol (module, "g_module_check_init", (gpointer) &check_init)) |
|
474 check_failed = check_init (module); |
|
475 |
|
476 /* we don't call unload() if the initialization check failed. */ |
|
477 if (!check_failed) |
|
478 g_module_symbol (module, "g_module_unload", (gpointer) &module->unload); |
|
479 |
|
480 if (check_failed) |
|
481 { |
|
482 gchar *error; |
|
483 |
|
484 error = g_strconcat ("GModule initialization check failed: ", check_failed, NULL); |
|
485 g_module_close (module); |
|
486 module = NULL; |
|
487 g_module_set_error (error); |
|
488 g_free (error); |
|
489 } |
|
490 else |
|
491 g_module_set_error (saved_error); |
|
492 |
|
493 g_free (saved_error); |
|
494 } |
|
495 |
|
496 g_static_rec_mutex_unlock (&g_module_global_lock); |
|
497 return module; |
|
498 } |
|
499 |
|
500 #ifdef G_OS_WIN32 |
|
501 |
|
502 #undef g_module_open |
|
503 |
|
504 GModule* |
|
505 g_module_open (const gchar *file_name, |
|
506 GModuleFlags flags) |
|
507 { |
|
508 gchar *utf8_file_name = g_locale_to_utf8 (file_name, -1, NULL, NULL, NULL); |
|
509 GModule *retval = g_module_open_utf8 (utf8_file_name, flags); |
|
510 |
|
511 g_free (utf8_file_name); |
|
512 |
|
513 return retval; |
|
514 } |
|
515 |
|
516 #endif |
|
517 |
|
518 EXPORT_C gboolean |
|
519 g_module_close (GModule *module) |
|
520 { |
|
521 SUPPORT_OR_RETURN (FALSE); |
|
522 |
|
523 g_return_val_if_fail (module != NULL, FALSE); |
|
524 g_return_val_if_fail (module->ref_count > 0, FALSE); |
|
525 |
|
526 g_static_rec_mutex_lock (&g_module_global_lock); |
|
527 |
|
528 module->ref_count--; |
|
529 |
|
530 if (!module->ref_count && !module->is_resident && module->unload) |
|
531 { |
|
532 GModuleUnload unload; |
|
533 |
|
534 unload = module->unload; |
|
535 module->unload = NULL; |
|
536 unload (module); |
|
537 } |
|
538 |
|
539 if (!module->ref_count && !module->is_resident) |
|
540 { |
|
541 GModule *last; |
|
542 GModule *node; |
|
543 |
|
544 last = NULL; |
|
545 |
|
546 node = modules; |
|
547 while (node) |
|
548 { |
|
549 if (node == module) |
|
550 { |
|
551 if (last) |
|
552 last->next = node->next; |
|
553 else |
|
554 modules = node->next; |
|
555 break; |
|
556 } |
|
557 last = node; |
|
558 node = last->next; |
|
559 } |
|
560 module->next = NULL; |
|
561 |
|
562 _g_module_close (module->handle, FALSE); |
|
563 g_free (module->file_name); |
|
564 #ifdef G_OS_WIN32 |
|
565 g_free (module->cp_file_name); |
|
566 #endif |
|
567 g_free (module); |
|
568 } |
|
569 |
|
570 g_static_rec_mutex_unlock (&g_module_global_lock); |
|
571 return g_module_error() == NULL; |
|
572 } |
|
573 |
|
574 EXPORT_C void |
|
575 g_module_make_resident (GModule *module) |
|
576 { |
|
577 g_return_if_fail (module != NULL); |
|
578 |
|
579 module->is_resident = TRUE; |
|
580 } |
|
581 |
|
582 EXPORT_C G_CONST_RETURN gchar* |
|
583 g_module_error (void) |
|
584 { |
|
585 return g_static_private_get (&module_error_private); |
|
586 } |
|
587 |
|
588 EXPORT_C gboolean |
|
589 g_module_symbol (GModule *module, |
|
590 const gchar *symbol_name, |
|
591 gpointer *symbol) |
|
592 { |
|
593 const gchar *module_error; |
|
594 |
|
595 if (symbol) |
|
596 *symbol = NULL; |
|
597 SUPPORT_OR_RETURN (FALSE); |
|
598 |
|
599 g_return_val_if_fail (module != NULL, FALSE); |
|
600 g_return_val_if_fail (symbol_name != NULL, FALSE); |
|
601 g_return_val_if_fail (symbol != NULL, FALSE); |
|
602 |
|
603 g_static_rec_mutex_lock (&g_module_global_lock); |
|
604 |
|
605 #ifdef G_MODULE_NEED_USCORE |
|
606 { |
|
607 gchar *name; |
|
608 |
|
609 name = g_strconcat ("_", symbol_name, NULL); |
|
610 *symbol = _g_module_symbol (module->handle, name); |
|
611 g_free (name); |
|
612 } |
|
613 #else /* !G_MODULE_NEED_USCORE */ |
|
614 *symbol = _g_module_symbol (module->handle, symbol_name); |
|
615 #endif /* !G_MODULE_NEED_USCORE */ |
|
616 |
|
617 module_error = g_module_error (); |
|
618 if (module_error) |
|
619 { |
|
620 gchar *error; |
|
621 |
|
622 error = g_strconcat ("`", symbol_name, "': ", module_error, NULL); |
|
623 g_module_set_error (error); |
|
624 g_free (error); |
|
625 *symbol = NULL; |
|
626 } |
|
627 |
|
628 g_static_rec_mutex_unlock (&g_module_global_lock); |
|
629 return *symbol != NULL; |
|
630 } |
|
631 |
|
632 EXPORT_C G_CONST_RETURN gchar* |
|
633 g_module_name (GModule *module) |
|
634 { |
|
635 g_return_val_if_fail (module != NULL, NULL); |
|
636 |
|
637 if (module == main_module) |
|
638 return "main"; |
|
639 |
|
640 return module->file_name; |
|
641 } |
|
642 |
|
643 #ifdef G_OS_WIN32 |
|
644 |
|
645 #undef g_module_name |
|
646 |
|
647 G_CONST_RETURN gchar* |
|
648 g_module_name (GModule *module) |
|
649 { |
|
650 g_return_val_if_fail (module != NULL, NULL); |
|
651 |
|
652 if (module == main_module) |
|
653 return "main"; |
|
654 |
|
655 return module->cp_file_name; |
|
656 } |
|
657 |
|
658 #endif |
|
659 |
|
660 EXPORT_C gchar* |
|
661 g_module_build_path (const gchar *directory, |
|
662 const gchar *module_name) |
|
663 { |
|
664 g_return_val_if_fail (module_name != NULL, NULL); |
|
665 |
|
666 return _g_module_build_path (directory, module_name); |
|
667 } |