summaryrefslogtreecommitdiff
path: root/src/base/modules.c
diff options
context:
space:
mode:
authorDusan Durech <dusan@debian.(none)>2008-11-11 23:39:21 +0100
committerDusan Durech <dusan@debian.(none)>2008-11-11 23:39:21 +0100
commit957f3411170ca1d5f30ee2e2c4e25393195cce75 (patch)
tree18567d663d6d759d447b65458a410f426dae9044 /src/base/modules.c
parentde05256afe45ad24cda83ed1e2cf873c97de132c (diff)
modification coding stile :)
Diffstat (limited to 'src/base/modules.c')
-rw-r--r--src/base/modules.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/base/modules.c b/src/base/modules.c
index 149a92f..82b5d56 100644
--- a/src/base/modules.c
+++ b/src/base/modules.c
@@ -66,15 +66,14 @@ static void *getFce(module_t * p, char *s)
ret = dlsym(p->image, s);
if ((error = dlerror()) != NULL) {
- fprintf(stderr, _("Error %s occured when using getFce function!\n"),
- error);
+ fprintf(stderr, _("Error %s occured when using getFce function!\n"), error);
return NULL;
}
#else
FARPROC ret = GetProcAddress((HMODULE) p->image, (LPCSTR) s);
- if (!ret)
- fprintf(stderr, _("Error %s occured when using getFce function!\n"),
- s);
+ if (!ret) {
+ fprintf(stderr, _("Error %s occured when using getFce function!\n"), s);
+ }
#endif
return (void *) ret;
}
@@ -84,6 +83,7 @@ static void *mapImage(char *name)
#ifndef __WIN32__
void *image;
image = dlopen(name, RTLD_LAZY);
+
if (image == NULL) {
fputs(dlerror(), stderr);
return NULL;
@@ -140,10 +140,12 @@ static module_t *newModule(char *name)
assert(name != NULL);
setModulePath(name, path);
image = mapImage(path);
+
if (image == NULL) {
fprintf(stderr, _("Unable to map file %s!\n"), name);
return NULL;
}
+
ret = malloc(sizeof(module_t));
ret->image = image;
ret->name = strdup(name);
@@ -166,6 +168,7 @@ static module_t *newModule(char *name)
free(ret);
return NULL;
}
+
return ret;
}
@@ -196,6 +199,7 @@ int isModuleLoaded(char *name)
module_t *this;
this = (module_t *) listModule->list[i];
+
if (strcmp(this->name, name) == 0)
return 1;
}
@@ -207,17 +211,17 @@ int loadModule(char *name)
module_t *module;
if (isModuleLoaded(name)) {
- fprintf(stderr,
- _
- ("I've done this once, dont want to mess memory with module %s again!\n"),
- name);
+ fprintf(stderr, ("I've done this once, dont want to mess memory with module %s again!\n"), name);
return -1;
}
+
module = newModule(name);
+
if (module == NULL) {
fprintf(stderr, _("Loading module %s failed!\n"), name);
return -1;
}
+
addList(listModule, module);
return 0;
}
@@ -226,6 +230,7 @@ int loadDepModule(char *name)
{
if (isModuleLoaded(name))
return 0;
+
return loadModule(name);
}
@@ -235,6 +240,7 @@ void cmdModule(char *s)
for (i = 0; i < listModule->count; i++) {
module_t *this;
+
this = (module_t *) listModule->list[i];
this->fce_cmd(s);
}
@@ -247,6 +253,7 @@ void drawModule(int x, int y, int w, int h)
for (i = 0; i < listModule->count; i++) {
module_t *this;
+
this = (module_t *) listModule->list[i];
this->fce_draw(x, y, w, h);
}
@@ -259,6 +266,7 @@ void eventModule()
for (i = 0; i < listModule->count; i++) {
module_t *this;
+
this = (module_t *) listModule->list[i];
this->fce_event();
}
@@ -272,6 +280,7 @@ int isConflictModule(int x, int y, int w, int h)
module_t *this;
this = (module_t *) listModule->list[i];
+
if (this->fce_isConflict(x, y, w, h) == 1)
return 1;
}