test/testloadso.c
changeset 2120 2c835d58faad
parent 2068 f16a7d02a176
child 3338 9de326b3099c
     1.1 --- a/test/testloadso.c	Thu Jun 14 06:32:36 2007 +0000
     1.2 +++ b/test/testloadso.c	Thu Jun 14 13:21:29 2007 +0000
     1.3 @@ -7,65 +7,64 @@
     1.4  
     1.5  #include "SDL.h"
     1.6  
     1.7 -typedef int (*fntype)(const char *);
     1.8 +typedef int (*fntype) (const char *);
     1.9  
    1.10 -int main(int argc, char *argv[])
    1.11 +int
    1.12 +main(int argc, char *argv[])
    1.13  {
    1.14 -	int retval = 0;
    1.15 -	int hello = 0;
    1.16 -	const char *libname = NULL;
    1.17 -	const char *symname = NULL;
    1.18 -	void *lib = NULL;
    1.19 -	fntype fn = NULL;
    1.20 +    int retval = 0;
    1.21 +    int hello = 0;
    1.22 +    const char *libname = NULL;
    1.23 +    const char *symname = NULL;
    1.24 +    void *lib = NULL;
    1.25 +    fntype fn = NULL;
    1.26  
    1.27 -	if (argc != 3) {
    1.28 -		const char *app = argv[0];
    1.29 -		fprintf(stderr, "USAGE: %s <library> <functionname>\n", app);
    1.30 -		fprintf(stderr, "       %s --hello <lib with puts()>\n", app);
    1.31 -		return 1;
    1.32 -	}
    1.33 +    if (argc != 3) {
    1.34 +        const char *app = argv[0];
    1.35 +        fprintf(stderr, "USAGE: %s <library> <functionname>\n", app);
    1.36 +        fprintf(stderr, "       %s --hello <lib with puts()>\n", app);
    1.37 +        return 1;
    1.38 +    }
    1.39  
    1.40 -	/* Initialize SDL */
    1.41 -	if ( SDL_Init(0) < 0 ) {
    1.42 -		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
    1.43 -		return 2;
    1.44 -	}
    1.45 +    /* Initialize SDL */
    1.46 +    if (SDL_Init(0) < 0) {
    1.47 +        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
    1.48 +        return 2;
    1.49 +    }
    1.50  
    1.51 -	if (strcmp(argv[1], "--hello") == 0) {
    1.52 -		hello = 1;
    1.53 -		libname = argv[2];
    1.54 -		symname = "puts";
    1.55 -	} else {
    1.56 -		libname = argv[1];
    1.57 -		symname = argv[2];
    1.58 -	}
    1.59 +    if (strcmp(argv[1], "--hello") == 0) {
    1.60 +        hello = 1;
    1.61 +        libname = argv[2];
    1.62 +        symname = "puts";
    1.63 +    } else {
    1.64 +        libname = argv[1];
    1.65 +        symname = argv[2];
    1.66 +    }
    1.67  
    1.68 -	lib = SDL_LoadObject(libname);
    1.69 -        if (lib == NULL) {
    1.70 -		fprintf(stderr, "SDL_LoadObject('%s') failed: %s\n",
    1.71 -		        libname, SDL_GetError());
    1.72 -		retval = 3;
    1.73 -	} else {
    1.74 -		fn = (fntype) SDL_LoadFunction(lib, symname);
    1.75 -		if (fn == NULL) {
    1.76 -			fprintf(stderr, "SDL_LoadFunction('%s') failed: %s\n",
    1.77 -			        symname, SDL_GetError());
    1.78 -			retval = 4;
    1.79 -		} else {
    1.80 -			printf("Found %s in %s at %p\n", symname, libname, fn);
    1.81 -			if (hello) {
    1.82 -				printf("Calling function...\n");
    1.83 -				fflush(stdout);
    1.84 -				fn("     HELLO, WORLD!\n");
    1.85 -				printf("...apparently, we survived.  :)\n");
    1.86 -				printf("Unloading library...\n");
    1.87 -				fflush(stdout);
    1.88 -			}
    1.89 -		}
    1.90 -		SDL_UnloadObject(lib);
    1.91 -	}
    1.92 -	SDL_Quit();
    1.93 -	return(0);
    1.94 +    lib = SDL_LoadObject(libname);
    1.95 +    if (lib == NULL) {
    1.96 +        fprintf(stderr, "SDL_LoadObject('%s') failed: %s\n",
    1.97 +                libname, SDL_GetError());
    1.98 +        retval = 3;
    1.99 +    } else {
   1.100 +        fn = (fntype) SDL_LoadFunction(lib, symname);
   1.101 +        if (fn == NULL) {
   1.102 +            fprintf(stderr, "SDL_LoadFunction('%s') failed: %s\n",
   1.103 +                    symname, SDL_GetError());
   1.104 +            retval = 4;
   1.105 +        } else {
   1.106 +            printf("Found %s in %s at %p\n", symname, libname, fn);
   1.107 +            if (hello) {
   1.108 +                printf("Calling function...\n");
   1.109 +                fflush(stdout);
   1.110 +                fn("     HELLO, WORLD!\n");
   1.111 +                printf("...apparently, we survived.  :)\n");
   1.112 +                printf("Unloading library...\n");
   1.113 +                fflush(stdout);
   1.114 +            }
   1.115 +        }
   1.116 +        SDL_UnloadObject(lib);
   1.117 +    }
   1.118 +    SDL_Quit();
   1.119 +    return (0);
   1.120  }
   1.121 -
   1.122 -