4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21 * All rights reserved.
23 * The Original Code is: all of this file, with exception of below:
25 * Contributor(s): Peter O'Gorman
27 * ***** END GPL LICENSE BLOCK *****
32 #include "../PIL_dynlib.h"
34 #if !defined(CHAR_MAX)
39 * XXX, should use mallocN so we can see
40 * handle's not being released. fixme zr
53 PILdynlib *PIL_dynlib_open(char *name) {
54 void *handle= LoadLibrary(name);
57 PILdynlib *lib= malloc(sizeof(*lib));
66 void *PIL_dynlib_find_symbol(PILdynlib* lib, char *symname) {
67 return GetProcAddress(lib->handle, symname);
70 char *PIL_dynlib_get_error_as_string(PILdynlib* lib) {
73 /* if lib is NULL reset the last error code */
75 if (!lib) SetLastError(ERROR_SUCCESS);
78 static char buf[1024];
80 if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
83 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
93 void PIL_dynlib_close(PILdynlib *lib) {
94 FreeLibrary(lib->handle);
107 PILdynlib *PIL_dynlib_open(char *name) {
108 void *handle= dlopen(name, RTLD_LAZY);
111 PILdynlib *lib= malloc(sizeof(*lib));
120 void *PIL_dynlib_find_symbol(PILdynlib* lib, char *symname) {
121 return dlsym(lib->handle, symname);
124 char *PIL_dynlib_get_error_as_string(PILdynlib* lib) {
128 void PIL_dynlib_close(PILdynlib *lib) {
129 dlclose(lib->handle);