comparison src/loadso/os2/SDL_sysloadso.c @ 1895:c121d94672cb

SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 10 Jul 2006 21:04:37 +0000
parents 92947e3a18db
children 3e42ad69f4a3
comparison
equal deleted inserted replaced
1894:c69cee13dd76 1895:c121d94672cb
31 #define INCL_DOSMODULEMGR 31 #define INCL_DOSMODULEMGR
32 #include <os2.h> 32 #include <os2.h>
33 33
34 #include "SDL_loadso.h" 34 #include "SDL_loadso.h"
35 35
36 void *SDL_LoadObject(const char *sofile) 36 void *
37 SDL_LoadObject(const char *sofile)
37 { 38 {
38 HMODULE handle = NULL; 39 HMODULE handle = NULL;
39 char buf[512]; 40 char buf[512];
40 APIRET ulrc = DosLoadModule(buf, sizeof (buf), (char *) sofile, &handle); 41 APIRET ulrc = DosLoadModule(buf, sizeof(buf), (char *) sofile, &handle);
41 42
42 /* Generate an error message if all loads failed */ 43 /* Generate an error message if all loads failed */
43 if ((ulrc != NO_ERROR) || (handle == NULL)) 44 if ((ulrc != NO_ERROR) || (handle == NULL))
44 SDL_SetError("Failed loading %s: %s", sofile, buf); 45 SDL_SetError("Failed loading %s: %s", sofile, buf);
45 46
46 return((void *) handle); 47 return ((void *) handle);
47 } 48 }
48 49
49 void *SDL_LoadFunction(void *handle, const char *name) 50 void *
51 SDL_LoadFunction(void *handle, const char *name)
50 { 52 {
51 const char *loaderror = "Unknown error"; 53 const char *loaderror = "Unknown error";
52 void *symbol = NULL; 54 void *symbol = NULL;
53 APIRET ulrc = DosQueryProcAddr((HMODULE)handle, 0, (char *)name, &symbol); 55 APIRET ulrc =
56 DosQueryProcAddr((HMODULE) handle, 0, (char *) name, &symbol);
54 if (ulrc == ERROR_INVALID_HANDLE) 57 if (ulrc == ERROR_INVALID_HANDLE)
55 loaderror = "Invalid module handle"; 58 loaderror = "Invalid module handle";
56 else if (ulrc == ERROR_INVALID_NAME) 59 else if (ulrc == ERROR_INVALID_NAME)
57 loaderror = "Symbol not found"; 60 loaderror = "Symbol not found";
58 61
59 if (symbol == NULL) 62 if (symbol == NULL)
60 SDL_SetError("Failed loading %s: %s", name, loaderror); 63 SDL_SetError("Failed loading %s: %s", name, loaderror);
61 64
62 return(symbol); 65 return (symbol);
63 } 66 }
64 67
65 void SDL_UnloadObject(void *handle) 68 void
69 SDL_UnloadObject(void *handle)
66 { 70 {
67 if ( handle != NULL ) 71 if (handle != NULL)
68 DosFreeModule((HMODULE) handle); 72 DosFreeModule((HMODULE) handle);
69 } 73 }
70 74
71 #endif /* SDL_LOADSO_OS2 */ 75 #endif /* SDL_LOADSO_OS2 */
76 /* vi: set ts=4 sw=4 expandtab: */