Changeset 1208 for libcaca/trunk/caca/caca.c
- Timestamp:
- Oct 20, 2006, 12:43:17 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/caca/caca.c
r1054 r1208 24 24 # include <stdlib.h> 25 25 # include <string.h> 26 # include <stdio.h> 26 27 # if defined(HAVE_ERRNO_H) 27 28 # include <errno.h> 29 # endif 30 # if defined(USE_PLUGINS) 31 # if defined(HAVE_DLFCN_H) 32 # include <dlfcn.h> 33 # endif 28 34 # endif 29 35 #endif … … 34 40 #include "caca_internals.h" 35 41 36 static int caca_select_driver(caca_display_t *dp); 42 #if defined(USE_PLUGINS) 43 # define gl_install(p) caca_plugin_install("gl", p) 44 # define x11_install(p) caca_plugin_install("x11", p) 45 #endif 46 47 static int caca_select_driver(caca_display_t *); 48 #if defined(USE_PLUGINS) 49 static int caca_plugin_install(char const *, caca_display_t *); 50 #endif 37 51 38 52 /** \brief Attach a caca graphical context to a cucul canvas. … … 63 77 64 78 dp->cv = cv; 79 #if defined(USE_PLUGINS) 80 dp->plugin = NULL; 81 #endif 65 82 66 83 if(caca_select_driver(dp)) 67 84 { 85 #if defined(USE_PLUGINS) 86 if(dp->plugin) 87 dlclose(dp->plugin); 88 #endif 68 89 free(dp); 69 90 #if defined(HAVE_ERRNO_H) … … 75 96 if(dp->drv.init_graphics(dp)) 76 97 { 98 #if defined(USE_PLUGINS) 99 if(dp->plugin) 100 dlclose(dp->plugin); 101 #endif 77 102 free(dp); 78 103 #if defined(HAVE_ERRNO_H) … … 129 154 { 130 155 dp->drv.end_graphics(dp); 156 #if defined(USE_PLUGINS) 157 if(dp->plugin) 158 dlclose(dp->plugin); 159 #endif 131 160 dp->cv->refcount--; 132 161 free(dp); … … 202 231 } 203 232 233 #if defined(USE_PLUGINS) 234 static int caca_plugin_install(char const *name, caca_display_t *dp) 235 { 236 char buf[512]; 237 int (*sym) (caca_display_t *); 238 239 sprintf(buf, "%s/lib%s_plugin.so", PLUGINDIR, name); 240 dp->plugin = dlopen(buf, RTLD_NOW); 241 if(!dp->plugin) 242 { 243 sprintf(buf, "lib%s_plugin.so", name); 244 dp->plugin = dlopen(buf, RTLD_NOW); 245 if(!dp->plugin) 246 return -1; 247 } 248 249 sprintf(buf, "%s_install", name); 250 sym = dlsym(dp->plugin, buf); 251 if(!sym) 252 { 253 dlclose(dp->plugin); 254 return -1; 255 } 256 257 return sym(dp); 258 } 259 #endif 260
Note: See TracChangeset
for help on using the changeset viewer.