summaryrefslogtreecommitdiff
path: root/src/base
diff options
context:
space:
mode:
authororoborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-07-14 13:11:49 +0000
committeroroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-07-14 13:11:49 +0000
commit175fcebf75e896a3286d6e8f083b4dd23b1481ce (patch)
tree346325dd3587d560696dc794ff118c8958825373 /src/base
parentd3b93f1bda917c4aa3dd212a6c0ec2949c4a1ab4 (diff)
- modules.c pouziva pri clientovy libSDL a na servery libdl
git-svn-id: http://opensvn.csie.org/tuxanci_ng@130 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/base')
-rwxr-xr-xsrc/base/modules.c66
1 files changed, 63 insertions, 3 deletions
diff --git a/src/base/modules.c b/src/base/modules.c
index afe192c..d3c4cc1 100755
--- a/src/base/modules.c
+++ b/src/base/modules.c
@@ -2,9 +2,28 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <dlfcn.h>
#include <assert.h>
+// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+#ifndef PUBLIC_SERVER
+#define SUPPORT_SDL_DYN
+#endif
+
+#ifdef PUBLIC_SERVER
+#define SUPPORT_LIBDYN
+#endif
+
+// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+#ifdef SUPPORT_LIBDYN
+#include <dlfcn.h>
+#endif
+
+#ifdef SUPPORT_SDL_DYN
+#include <SDL/SDL.h>
+#endif
+
#include "main.h"
#include "list.h"
#include "tux.h"
@@ -55,18 +74,32 @@ static list_t *listModule;
static void* getFce(module_t *p, char *s)
{
void *ret;
+#ifdef SUPPORT_LIBDYN
char *error;
+#endif
assert( p != NULL );
assert( s != NULL );
+#ifdef SUPPORT_LIBDYN
ret = dlsym(p->image, s);
- if( ( error = dlerror() ) != NULL)
+ if( ( error = dlerror() ) != NULL )
{
fprintf (stderr, "error = %s\n", error);
return NULL;
}
+#endif
+
+#ifdef SUPPORT_SDL_DYN
+ ret = SDL_LoadFunction(p->image, s);
+
+ if( ret == NULL )
+ {
+ fprintf (stderr, "load %s error\n", s);
+ return NULL;
+ }
+#endif
return (void *)ret;
}
@@ -79,11 +112,23 @@ static module_t* newModule(char *name)
ret = malloc( sizeof(module_t) );
- ret->image = dlopen (name, RTLD_LAZY);
+#ifdef SUPPORT_LIBDYN
+ ret->image = dlopen(name, RTLD_LAZY);
+#endif
+
+#ifdef SUPPORT_SDL_DYN
+ ret->image = SDL_LoadObject(name);
+#endif
if(!ret->image)
{
+#ifdef SUPPORT_LIBDYN
fputs (dlerror(), stderr);
+#endif
+
+#ifdef SUPPORT_SDL_DYN
+ printf("load module error\n");
+#endif
free(ret);
return NULL;
}
@@ -106,7 +151,14 @@ static module_t* newModule(char *name)
{
fprintf(stderr, "init module failed !\n");
+#ifdef SUPPORT_LIBDYN
dlclose(ret->image);
+#endif
+
+#ifdef SUPPORT_SDL_DYN
+ SDL_UnloadObject(ret->image);
+#endif
+
free(ret->file);
free(ret);
return NULL;
@@ -122,7 +174,15 @@ static int destroyModule(module_t *p)
p->fce_destroy();
free(p->file);
+
+#ifdef SUPPORT_LIBDYN
dlclose(p->image);
+#endif
+
+#ifdef SUPPORT_SDL_DYN
+ SDL_UnloadObject(p->image);
+#endif
+
free(p);
printf("destroy module..\n");