Mercurial > sdl-ios-xcode
comparison src/loadso/dlopen/SDL_sysloadso.c @ 1662:782fd950bd46 SDL-1.3
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.
The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce
The headers are being converted to automatically generate doxygen documentation.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 28 May 2006 13:04:16 +0000 |
parents | 92947e3a18db |
children | 4da1ee79c9af |
comparison
equal
deleted
inserted
replaced
1661:281d3f4870e5 | 1662:782fd950bd46 |
---|---|
29 #include <stdio.h> | 29 #include <stdio.h> |
30 #include <dlfcn.h> | 30 #include <dlfcn.h> |
31 | 31 |
32 #include "SDL_loadso.h" | 32 #include "SDL_loadso.h" |
33 | 33 |
34 void *SDL_LoadObject(const char *sofile) | 34 void * |
35 SDL_LoadObject (const char *sofile) | |
35 { | 36 { |
36 void *handle = dlopen(sofile, RTLD_NOW); | 37 void *handle = dlopen (sofile, RTLD_NOW); |
37 const char *loaderror = (char *)dlerror(); | 38 const char *loaderror = (char *) dlerror (); |
38 if ( handle == NULL ) { | 39 if (handle == NULL) { |
39 SDL_SetError("Failed loading %s: %s", sofile, loaderror); | 40 SDL_SetError ("Failed loading %s: %s", sofile, loaderror); |
40 } | 41 } |
41 return(handle); | 42 return (handle); |
42 } | 43 } |
43 | 44 |
44 void *SDL_LoadFunction(void *handle, const char *name) | 45 void * |
46 SDL_LoadFunction (void *handle, const char *name) | |
45 { | 47 { |
46 void *symbol = dlsym(handle, name); | 48 void *symbol = dlsym (handle, name); |
47 if ( symbol == NULL ) { | 49 if (symbol == NULL) { |
48 size_t len = 1+SDL_strlen(name)+1; | 50 size_t len = 1 + SDL_strlen (name) + 1; |
49 char *_name = SDL_stack_alloc(char, len); | 51 char *_name = SDL_stack_alloc (char, len); |
50 _name[0] = '_'; | 52 _name[0] = '_'; |
51 SDL_strlcpy(&_name[1], name, len); | 53 SDL_strlcpy (&_name[1], name, len); |
52 symbol = dlsym(handle, name); | 54 symbol = dlsym (handle, name); |
53 SDL_stack_free(_name); | 55 SDL_stack_free (_name); |
54 if ( symbol == NULL ) { | 56 if (symbol == NULL) { |
55 SDL_SetError("Failed loading %s: %s", name, (const char *)dlerror()); | 57 SDL_SetError ("Failed loading %s: %s", name, |
56 } | 58 (const char *) dlerror ()); |
57 } | 59 } |
58 return(symbol); | 60 } |
61 return (symbol); | |
59 } | 62 } |
60 | 63 |
61 void SDL_UnloadObject(void *handle) | 64 void |
65 SDL_UnloadObject (void *handle) | |
62 { | 66 { |
63 if ( handle != NULL ) { | 67 if (handle != NULL) { |
64 dlclose(handle); | 68 dlclose (handle); |
65 } | 69 } |
66 } | 70 } |
67 | 71 |
68 #endif /* SDL_LOADSO_DLOPEN */ | 72 #endif /* SDL_LOADSO_DLOPEN */ |
73 /* vi: set ts=4 sw=4 expandtab: */ |