src/video/x11/SDL_x11dyn.c
changeset 1895 c121d94672cb
parent 1874 9e85b267f8f3
     1.1 --- a/src/video/x11/SDL_x11dyn.c	Thu Jul 06 18:01:37 2006 +0000
     1.2 +++ b/src/video/x11/SDL_x11dyn.c	Mon Jul 10 21:04:37 2006 +0000
     1.3 @@ -53,35 +53,35 @@
     1.4  #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR NULL
     1.5  #endif
     1.6  
     1.7 -static x11dynlib x11libs[] =
     1.8 -{
     1.9 -    { NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC },
    1.10 -    { NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT },
    1.11 -    { NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER },
    1.12 -    { NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR },
    1.13 +static x11dynlib x11libs[] = {
    1.14 +    {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC},
    1.15 +    {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT},
    1.16 +    {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER},
    1.17 +    {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR},
    1.18  };
    1.19  
    1.20 -static void X11_GetSym(const char *fnname, int *rc, void **fn)
    1.21 +static void
    1.22 +X11_GetSym(const char *fnname, int *rc, void **fn)
    1.23  {
    1.24 -	int i;
    1.25 -	for (i = 0; i < SDL_TABLESIZE(x11libs); i++) {
    1.26 -		if (x11libs[i].lib != NULL)
    1.27 -		{
    1.28 -			*fn = SDL_LoadFunction(x11libs[i].lib, fnname);
    1.29 -			if (*fn != NULL)
    1.30 -				break;
    1.31 -		}
    1.32 -	}
    1.33 +    int i;
    1.34 +    for (i = 0; i < SDL_TABLESIZE(x11libs); i++) {
    1.35 +        if (x11libs[i].lib != NULL) {
    1.36 +            *fn = SDL_LoadFunction(x11libs[i].lib, fnname);
    1.37 +            if (*fn != NULL)
    1.38 +                break;
    1.39 +        }
    1.40 +    }
    1.41  
    1.42 -	#if DEBUG_DYNAMIC_X11
    1.43 -	if (*fn != NULL)
    1.44 -		printf("X11: Found '%s' in %s (%p)\n", fnname, x11libs[i].libname, *fn);
    1.45 -	else
    1.46 -		printf("X11: Symbol '%s' NOT FOUND!\n", fnname);
    1.47 -	#endif
    1.48 +#if DEBUG_DYNAMIC_X11
    1.49 +    if (*fn != NULL)
    1.50 +        printf("X11: Found '%s' in %s (%p)\n", fnname, x11libs[i].libname,
    1.51 +               *fn);
    1.52 +    else
    1.53 +        printf("X11: Symbol '%s' NOT FOUND!\n", fnname);
    1.54 +#endif
    1.55  
    1.56 -	if (*fn == NULL)
    1.57 -		*rc = 0;  /* kill this module. */
    1.58 +    if (*fn == NULL)
    1.59 +        *rc = 0;                /* kill this module. */
    1.60  }
    1.61  
    1.62  
    1.63 @@ -93,11 +93,11 @@
    1.64  #include "SDL_x11sym.h"
    1.65  #undef SDL_X11_MODULE
    1.66  #undef SDL_X11_SYM
    1.67 -#endif  /* SDL_VIDEO_DRIVER_X11_DYNAMIC */
    1.68 +#endif /* SDL_VIDEO_DRIVER_X11_DYNAMIC */
    1.69  
    1.70  /* Annoying varargs entry point... */
    1.71  #ifdef X_HAVE_UTF8_STRING
    1.72 -XIC (*pXCreateIC)(XIM,...) = NULL;
    1.73 +XIC(*pXCreateIC) (XIM,...) = NULL;
    1.74  #endif
    1.75  
    1.76  /* These SDL_X11_HAVE_* flags are here whether you have dynamic X11 or not. */
    1.77 @@ -110,77 +110,76 @@
    1.78  
    1.79  static int x11_load_refcount = 0;
    1.80  
    1.81 -void SDL_X11_UnloadSymbols(void)
    1.82 +void
    1.83 +SDL_X11_UnloadSymbols(void)
    1.84  {
    1.85 -	#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
    1.86 -	/* Don't actually unload if more than one module is using the libs... */
    1.87 -	if (x11_load_refcount > 0) {
    1.88 -		if (--x11_load_refcount == 0) {
    1.89 -			int i;
    1.90 +#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
    1.91 +    /* Don't actually unload if more than one module is using the libs... */
    1.92 +    if (x11_load_refcount > 0) {
    1.93 +        if (--x11_load_refcount == 0) {
    1.94 +            int i;
    1.95  
    1.96 -			/* set all the function pointers to NULL. */
    1.97 -			#define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 1;
    1.98 -			#define SDL_X11_SYM(rc,fn,params,args,ret) p##fn = NULL;
    1.99 -			#include "SDL_x11sym.h"
   1.100 -			#undef SDL_X11_MODULE
   1.101 -			#undef SDL_X11_SYM
   1.102 +            /* set all the function pointers to NULL. */
   1.103 +#define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 1;
   1.104 +#define SDL_X11_SYM(rc,fn,params,args,ret) p##fn = NULL;
   1.105 +#include "SDL_x11sym.h"
   1.106 +#undef SDL_X11_MODULE
   1.107 +#undef SDL_X11_SYM
   1.108  
   1.109 -			#ifdef X_HAVE_UTF8_STRING
   1.110 -			pXCreateIC = NULL;
   1.111 -			#endif
   1.112 +#ifdef X_HAVE_UTF8_STRING
   1.113 +            pXCreateIC = NULL;
   1.114 +#endif
   1.115  
   1.116 -			for (i = 0; i < SDL_TABLESIZE(x11libs); i++) {
   1.117 -				if (x11libs[i].lib != NULL) {
   1.118 -					SDL_UnloadObject(x11libs[i].lib);
   1.119 -					x11libs[i].lib = NULL;
   1.120 -				}
   1.121 -			}
   1.122 -		}
   1.123 -	}
   1.124 -	#endif
   1.125 +            for (i = 0; i < SDL_TABLESIZE(x11libs); i++) {
   1.126 +                if (x11libs[i].lib != NULL) {
   1.127 +                    SDL_UnloadObject(x11libs[i].lib);
   1.128 +                    x11libs[i].lib = NULL;
   1.129 +                }
   1.130 +            }
   1.131 +        }
   1.132 +    }
   1.133 +#endif
   1.134  }
   1.135  
   1.136  /* returns non-zero if all needed symbols were loaded. */
   1.137 -int SDL_X11_LoadSymbols(void)
   1.138 +int
   1.139 +SDL_X11_LoadSymbols(void)
   1.140  {
   1.141 -	int rc = 1;  /* always succeed if not using Dynamic X11 stuff. */
   1.142 +    int rc = 1;                 /* always succeed if not using Dynamic X11 stuff. */
   1.143  
   1.144 -	#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
   1.145 -	/* deal with multiple modules (dga, x11, etc) needing these symbols... */
   1.146 -	if (x11_load_refcount++ == 0) {
   1.147 -		int i;
   1.148 -		int *thismod = NULL;
   1.149 -		for (i = 0; i < SDL_TABLESIZE(x11libs); i++) {
   1.150 -			if (x11libs[i].libname != NULL) {
   1.151 -				x11libs[i].lib = SDL_LoadObject(x11libs[i].libname);
   1.152 -			}
   1.153 -		}
   1.154 -		#define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname;
   1.155 -		#define SDL_X11_SYM(a,fn,x,y,z) X11_GetSym(#fn,thismod,(void**)&p##fn);
   1.156 -		#include "SDL_x11sym.h"
   1.157 -		#undef SDL_X11_MODULE
   1.158 -		#undef SDL_X11_SYM
   1.159 +#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
   1.160 +    /* deal with multiple modules (dga, x11, etc) needing these symbols... */
   1.161 +    if (x11_load_refcount++ == 0) {
   1.162 +        int i;
   1.163 +        int *thismod = NULL;
   1.164 +        for (i = 0; i < SDL_TABLESIZE(x11libs); i++) {
   1.165 +            if (x11libs[i].libname != NULL) {
   1.166 +                x11libs[i].lib = SDL_LoadObject(x11libs[i].libname);
   1.167 +            }
   1.168 +        }
   1.169 +#define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname;
   1.170 +#define SDL_X11_SYM(a,fn,x,y,z) X11_GetSym(#fn,thismod,(void**)&p##fn);
   1.171 +#include "SDL_x11sym.h"
   1.172 +#undef SDL_X11_MODULE
   1.173 +#undef SDL_X11_SYM
   1.174  
   1.175 -		#ifdef X_HAVE_UTF8_STRING
   1.176 -		X11_GetSym("XCreateIC",&SDL_X11_HAVE_UTF8,(void **)&pXCreateIC);
   1.177 -		#endif
   1.178 +#ifdef X_HAVE_UTF8_STRING
   1.179 +        X11_GetSym("XCreateIC", &SDL_X11_HAVE_UTF8, (void **) &pXCreateIC);
   1.180 +#endif
   1.181  
   1.182 -		if (!SDL_X11_HAVE_BASEXLIB) {  /* some required symbol didn't load. */
   1.183 -			SDL_X11_UnloadSymbols();  /* in case something got loaded... */
   1.184 -			rc = 0;
   1.185 -		}
   1.186 -	}
   1.187 -	#else
   1.188 -		#if DEBUG_DYNAMIC_X11
   1.189 -		printf("X11: No dynamic X11 support in this build of SDL.\n");
   1.190 -		#endif
   1.191 -		#ifdef X_HAVE_UTF8_STRING
   1.192 -		pXCreateIC = XCreateIC;
   1.193 -		#endif
   1.194 -	#endif
   1.195 +        if (!SDL_X11_HAVE_BASEXLIB) {   /* some required symbol didn't load. */
   1.196 +            SDL_X11_UnloadSymbols();    /* in case something got loaded... */
   1.197 +            rc = 0;
   1.198 +        }
   1.199 +    }
   1.200 +#else
   1.201 +#ifdef X_HAVE_UTF8_STRING
   1.202 +    pXCreateIC = XCreateIC;
   1.203 +#endif
   1.204 +#endif
   1.205  
   1.206 -	return rc;
   1.207 +    return rc;
   1.208  }
   1.209  
   1.210  /* end of SDL_x11dyn.c ... */
   1.211 -
   1.212 +/* vi: set ts=4 sw=4 expandtab: */