diff options
| author | Tomas Chvatal (scarabeus) <tomas.chvatal@gmail.com> | 2008-10-22 22:51:24 +0200 |
|---|---|---|
| committer | Tomas Chvatal (scarabeus) <tomas.chvatal@gmail.com> | 2008-10-22 22:51:24 +0200 |
| commit | 44daf03024fbf7cbffa10349044786f6ab784821 (patch) | |
| tree | fe311eb22e2d853dfc18fde1a9e55d21815f4f82 /src/base/storage.c~ | |
| parent | e12753d2ec9db83ec08bb9db63902a82fb245cdd (diff) | |
Revert "X"
This reverts commit e12753d2ec9db83ec08bb9db63902a82fb245cdd.
Diffstat (limited to 'src/base/storage.c~')
| -rw-r--r-- | src/base/storage.c~ | 125 |
1 files changed, 0 insertions, 125 deletions
diff --git a/src/base/storage.c~ b/src/base/storage.c~ deleted file mode 100644 index 7a7ee91..0000000 --- a/src/base/storage.c~ +++ /dev/null @@ -1,125 +0,0 @@ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <assert.h> - -#include "main.h" -#include "list.h" - -typedef struct struct_storage_item -{ - char *name; - char *group; - void *data; -} storage_item_t; - -list_t* newStorage() -{ - return newList(); -} - -static storage_item_t* newStorageItem(char *group, char *name, void *data) -{ - storage_item_t *new; - - assert(name != NULL); - assert(group != NULL); - assert(data != NULL); - new = malloc(sizeof(storage_item_t)); - new->name = strdup(name); - new->group = strdup(group); - new->data = data; - return new; -} - -static void destroyStorageItem(storage_item_t *p, void *f) -{ - void(*fce)(void *); - - assert(p != NULL); - assert(f != NULL); - fce = f; - fce(p->data); - free(p->name); - free(p->group); - free(p); -} - -void addItemToStorage(list_t *list, char *group, char *name, void *data) -{ - assert(list != NULL); - assert(group != NULL); - assert(name != NULL); - addList(list, newStorageItem(group, name, data) ); -} - -void* getItemFromStorage(list_t *list, char *group, char *name) -{ - storage_item_t *this; - int i; - - assert(list != NULL); - assert(group != NULL); - assert(name != NULL); - for (i = 0; i < list->count; i++) { - this = (storage_item_t *) list->list[i]; - if (strcmp(group, this->group) == 0 && strcmp(name, this->name) == 0) - return this->data; - } -#ifdef DEBUG - printf(_("%s %s was not found in storage!\n"), group, name); -#endif - return NULL; -} - -void delItemFromStorage(list_t *list, char *group, char *name, void *f) -{ - storage_item_t *this; - int i; - - assert(list != NULL); - assert(group != NULL); - assert(name != NULL); - for (i = 0; i < list->count; i++) { - this = (storage_item_t *) list->list[i]; - if (strcmp(group, this->group) == 0 && strcmp(name, this->name) == 0) { - destroyStorageItem(this, f); - delList(list, i); - return; - } - } - return; -} - -void delAllItemFromStorage(list_t *list, char *group, void *f) -{ - storage_item_t *this; - int i; - - assert(list != NULL); - assert(group != NULL); - - for (i = 0; i < list->count; i++) { - this = (storage_item_t *) list->list[i]; - if (strcmp(group, this->group) == 0) { - destroyStorageItem(this, f); - delList(list, i); - i--; - } - } -} - -void destroyStorage(list_t *p, void *f) -{ - storage_item_t *this; - int i; - - assert(p != NULL); - assert(f != NULL); - for (i = 0; i < p->count; i++) { - this = (storage_item_t *)p->list[i]; - destroyStorageItem(this, f); - } - destroyList(p); -} |