diff options
| author | Tomas Chvatal (scarabeus) <tomas.chvatal@gmail.com> | 2008-10-22 22:50:54 +0200 |
|---|---|---|
| committer | Tomas Chvatal (scarabeus) <tomas.chvatal@gmail.com> | 2008-10-22 22:50:54 +0200 |
| commit | e12753d2ec9db83ec08bb9db63902a82fb245cdd (patch) | |
| tree | 6e4a63b790d6335f969f88b797a927e0fb25f37a /src/base/shareFunction.c~ | |
| parent | 0b4d9821c7333b8c4bdf7e0eeb750aef502a1137 (diff) | |
X
Diffstat (limited to 'src/base/shareFunction.c~')
| -rw-r--r-- | src/base/shareFunction.c~ | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/base/shareFunction.c~ b/src/base/shareFunction.c~ new file mode 100644 index 0000000..b7bddc2 --- /dev/null +++ b/src/base/shareFunction.c~ @@ -0,0 +1,65 @@ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <assert.h> + +#include "main.h" +#include "list.h" +#include "shareFunction.h" + +typedef struct share_fce_item_struct +{ + char *name; + void *function; +} share_fce_item_t; + +static list_t *listShareFce; + +static share_fce_item_t* newShareFceItem(char *name, void *function) +{ + share_fce_item_t *new; + + new = malloc( sizeof(share_fce_item_t) ); + new->name = strdup(name); + new->function = function; + return new; +} + +static void destroyShareFce(share_fce_item_t *p) +{ + free(p->name); + free(p); +} + +void initShareFunction() +{ + listShareFce = newList(); +} +void addToShareFce(char *name, void *function) +{ +#ifdef DEBUG + printf(_("Adding \"%s\" to share function.\n"), name); +#endif + addList(listShareFce, newShareFceItem(name, function) ); +} + +void* getShareFce(char *name) +{ + int i; + + for (i = 0; i < listShareFce->count; i++) { + share_fce_item_t *this; + + this = (share_fce_item_t *)listShareFce->list[i]; + if( strcmp(this->name, name) == 0 ) + return this->function; + } + return NULL; +} + +void quitShareFunction() +{ + destroyListItem(listShareFce, destroyShareFce); +} + |