2 /* Test program to test dynamic loading with the loadso subsystem.
10 typedef int (*fntype)(const char *);
12 int main(int argc, char *argv[])
16 const char *libname = NULL;
17 const char *symname = NULL;
22 const char *app = argv[0];
23 fprintf(stderr, "USAGE: %s <library> <functionname>\n", app);
24 fprintf(stderr, " %s --hello <lib with puts()>\n", app);
29 if ( SDL_Init(0) < 0 ) {
30 fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
34 if (strcmp(argv[1], "--hello") == 0) {
43 lib = SDL_LoadObject(libname);
45 fprintf(stderr, "SDL_LoadObject('%s') failed: %s\n",
46 libname, SDL_GetError());
49 fn = (fntype) SDL_LoadFunction(lib, symname);
51 fprintf(stderr, "SDL_LoadFunction('%s') failed: %s\n",
52 symname, SDL_GetError());
55 printf("Found %s in %s at %p\n", symname, libname, fn);
57 printf("Calling function...\n");
59 fn(" HELLO, WORLD!\n");
60 printf("...apparently, we survived. :)\n");
61 printf("Unloading library...\n");
65 SDL_UnloadObject(lib);