sdl

FORK: Simple Directmedia Layer
git clone https://git.neptards.moe/neptards/sdl.git
Log | Files | Refs

SDL_sysloadso.c (2267B)


      1 /*
      2   Simple DirectMedia Layer
      3   Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
      4 
      5   This software is provided 'as-is', without any express or implied
      6   warranty.  In no event will the authors be held liable for any damages
      7   arising from the use of this software.
      8 
      9   Permission is granted to anyone to use this software for any purpose,
     10   including commercial applications, and to alter it and redistribute it
     11   freely, subject to the following restrictions:
     12 
     13   1. The origin of this software must not be misrepresented; you must not
     14      claim that you wrote the original software. If you use this software
     15      in a product, an acknowledgment in the product documentation would be
     16      appreciated but is not required.
     17   2. Altered source versions must be plainly marked as such, and must not be
     18      misrepresented as being the original software.
     19   3. This notice may not be removed or altered from any source distribution.
     20 */
     21 #include "../../SDL_internal.h"
     22 
     23 #ifdef SDL_LOADSO_OS2
     24 
     25 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
     26 /* System dependent library loading routines                           */
     27 
     28 #include "SDL_loadso.h"
     29 #include "../../core/os2/SDL_os2.h"
     30 
     31 #define INCL_DOSMODULEMGR
     32 #define INCL_DOSERRORS
     33 #include <os2.h>
     34 
     35 void *
     36 SDL_LoadObject(const char *sofile)
     37 {
     38     ULONG   ulRC;
     39     HMODULE hModule;
     40     CHAR    acError[256];
     41     PSZ     pszModName;
     42 
     43     if (!sofile) {
     44         SDL_SetError("NULL sofile");
     45         return NULL;
     46     }
     47 
     48     pszModName = OS2_UTF8ToSys(sofile);
     49     ulRC = DosLoadModule(acError, sizeof(acError), pszModName, &hModule);
     50     SDL_free(pszModName);
     51     if (ulRC != NO_ERROR) {
     52         SDL_SetError("Failed loading %s (E%u)", acError, ulRC);
     53         return NULL;
     54     }
     55 
     56     return (void *)hModule;
     57 }
     58 
     59 void *
     60 SDL_LoadFunction(void *handle, const char *name)
     61 {
     62     ULONG   ulRC;
     63     PFN     pFN;
     64 
     65     ulRC = DosQueryProcAddr((HMODULE)handle, 0, name, &pFN);
     66     if (ulRC != NO_ERROR) {
     67         SDL_SetError("Failed loading procedure %s (E%u)", name, ulRC);
     68         return NULL;
     69     }
     70 
     71     return (void *)pFN;
     72 }
     73 
     74 void
     75 SDL_UnloadObject(void *handle)
     76 {
     77     if (handle != NULL) {
     78         DosFreeModule((HMODULE)handle);
     79     }
     80 }
     81 
     82 #endif /* SDL_LOADSO_OS2 */
     83 
     84 /* vi: set ts=4 sw=4 expandtab: */