comparison src/loadso/macos/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
33 #include <CodeFragments.h> 33 #include <CodeFragments.h>
34 #include <Errors.h> 34 #include <Errors.h>
35 35
36 #include "SDL_loadso.h" 36 #include "SDL_loadso.h"
37 37
38 void *SDL_LoadObject(const char *sofile) 38 void *
39 SDL_LoadObject (const char *sofile)
39 { 40 {
40 void *handle = NULL; 41 void *handle = NULL;
41 const char *loaderror = NULL; 42 const char *loaderror = NULL;
42 CFragConnectionID library_id; 43 CFragConnectionID library_id;
43 Ptr mainAddr; 44 Ptr mainAddr;
44 Str255 errName; 45 Str255 errName;
45 OSErr error; 46 OSErr error;
46 char psofile[512]; 47 char psofile[512];
47 48
48 SDL_strlcpy(psofile, sofile, SDL_arraysize(psofile)); 49 SDL_strlcpy (psofile, sofile, SDL_arraysize (psofile));
49 error = GetSharedLibrary(C2PStr(psofile), kCompiledCFragArch, 50 error = GetSharedLibrary (C2PStr (psofile), kCompiledCFragArch,
50 kLoadCFrag, &library_id, &mainAddr, errName); 51 kLoadCFrag, &library_id, &mainAddr, errName);
51 switch (error) { 52 switch (error) {
52 case noErr: 53 case noErr:
53 loaderror = NULL; 54 loaderror = NULL;
54 break; 55 break;
55 case cfragNoLibraryErr: 56 case cfragNoLibraryErr:
56 loaderror = "Library not found"; 57 loaderror = "Library not found";
57 break; 58 break;
58 case cfragUnresolvedErr: 59 case cfragUnresolvedErr:
59 loaderror = "Unabled to resolve symbols"; 60 loaderror = "Unabled to resolve symbols";
60 break; 61 break;
61 case cfragNoPrivateMemErr: 62 case cfragNoPrivateMemErr:
62 case cfragNoClientMemErr: 63 case cfragNoClientMemErr:
63 loaderror = "Out of memory"; 64 loaderror = "Out of memory";
64 break; 65 break;
65 default: 66 default:
66 loaderror = "Unknown Code Fragment Manager error"; 67 loaderror = "Unknown Code Fragment Manager error";
67 break; 68 break;
68 } 69 }
69 if ( loaderror == NULL ) { 70 if (loaderror == NULL) {
70 handle = (void *)(library_id); 71 handle = (void *) (library_id);
71 } else { 72 } else {
72 SDL_SetError("Failed loading %s: %s", sofile, loaderror); 73 SDL_SetError ("Failed loading %s: %s", sofile, loaderror);
73 } 74 }
74 return(handle); 75 return (handle);
75 } 76 }
76 77
77 void *SDL_LoadFunction(void *handle, const char *name) 78 void *
79 SDL_LoadFunction (void *handle, const char *name)
78 { 80 {
79 void *symbol = NULL; 81 void *symbol = NULL;
80 const char *loaderror = NULL; 82 const char *loaderror = NULL;
81 CFragSymbolClass class; 83 CFragSymbolClass class;
82 CFragConnectionID library_id = (CFragConnectionID)handle; 84 CFragConnectionID library_id = (CFragConnectionID) handle;
83 char pname[512]; 85 char pname[512];
84 86
85 SDL_strlcpy(pname, name, SDL_arraysize(pname)); 87 SDL_strlcpy (pname, name, SDL_arraysize (pname));
86 if ( FindSymbol(library_id, C2PStr(pname), 88 if (FindSymbol (library_id, C2PStr (pname),
87 (char **)&symbol, &class) != noErr ) { 89 (char **) &symbol, &class) != noErr) {
88 loaderror = "Symbol not found"; 90 loaderror = "Symbol not found";
89 } 91 }
90 92
91 if ( symbol == NULL ) { 93 if (symbol == NULL) {
92 SDL_SetError("Failed loading %s: %s", name, loaderror); 94 SDL_SetError ("Failed loading %s: %s", name, loaderror);
93 } 95 }
94 return(symbol); 96 return (symbol);
95 } 97 }
96 98
97 void SDL_UnloadObject(void *handle) 99 void
100 SDL_UnloadObject (void *handle)
98 { 101 {
99 CFragConnectionID library_id; 102 CFragConnectionID library_id;
100 if ( handle != NULL ) { 103 if (handle != NULL) {
101 library_id = (CFragConnectionID)handle; 104 library_id = (CFragConnectionID) handle;
102 CloseConnection(&library_id); 105 CloseConnection (&library_id);
103 } 106 }
104 } 107 }
105 108
106 #endif /* SDL_LOADSO_MACOS */ 109 #endif /* SDL_LOADSO_MACOS */
110 /* vi: set ts=4 sw=4 expandtab: */