comparison src/loadso/beos/SDL_sysloadso.c @ 2069:8d4c2498bb72

Merged r2903:2904 from SDL-1.2 branch to trunk: BeOS loadso updates.
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 07 Nov 2006 15:18:42 +0000
parents c121d94672cb
children 2c835d58faad
comparison
equal deleted inserted replaced
2068:f16a7d02a176 2069:8d4c2498bb72
33 33
34 void * 34 void *
35 SDL_LoadObject(const char *sofile) 35 SDL_LoadObject(const char *sofile)
36 { 36 {
37 void *handle = NULL; 37 void *handle = NULL;
38 const char *loaderror = "Unknown error";
39 image_id library_id = load_add_on(sofile); 38 image_id library_id = load_add_on(sofile);
40 if (library_id == B_ERROR) { 39 if (library_id < 0) {
41 loaderror = "BeOS error"; 40 SDL_SetError(strerror((int) library_id));
42 } else { 41 } else {
43 handle = (void *) (library_id); 42 handle = (void *) (library_id);
44 }
45
46 if (handle == NULL) {
47 SDL_SetError("Failed loading %s: %s", sofile, loaderror);
48 } 43 }
49 return (handle); 44 return (handle);
50 } 45 }
51 46
52 void * 47 void *
53 SDL_LoadFunction(void *handle, const char *name) 48 SDL_LoadFunction(void *handle, const char *name)
54 { 49 {
55 void *symbol = NULL; 50 void *sym = NULL;
56 const char *loaderror = "Unknown error";
57 image_id library_id = (image_id) handle; 51 image_id library_id = (image_id) handle;
58 if (get_image_symbol(library_id, 52 status_t rc = get_image_symbol(library_id, name, B_SYMBOL_TYPE_TEXT, &sym);
59 name, B_SYMBOL_TYPE_TEXT, &symbol) != B_NO_ERROR) { 53 if (rc != B_NO_ERROR) {
60 loaderror = "Symbol not found"; 54 SDL_SetError(strerror(rc));
61 } 55 }
62 56 return (sym);
63 if (symbol == NULL) {
64 SDL_SetError("Failed loading %s: %s", name, loaderror);
65 }
66 return (symbol);
67 } 57 }
68 58
69 void 59 void
70 SDL_UnloadObject(void *handle) 60 SDL_UnloadObject(void *handle)
71 { 61 {
75 unload_add_on(library_id); 65 unload_add_on(library_id);
76 } 66 }
77 } 67 }
78 68
79 #endif /* SDL_LOADSO_BEOS */ 69 #endif /* SDL_LOADSO_BEOS */
70
80 /* vi: set ts=4 sw=4 expandtab: */ 71 /* vi: set ts=4 sw=4 expandtab: */
72