From 10e64c59e1af203cab71c5428a8bc93e2555d267 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 27 Feb 2011 02:57:28 -0800 Subject: [PATCH] Some old files that weren't in use. Goodbye. --- src/build/util.c | 1 - src/kernel/config.c | 5 - src/util.vcxproj | 4 - src/util.vcxproj.filters | 12 -- src/util/argstack.c | 66 ----------- src/util/argstack.h | 27 ----- src/util/patricia.c | 236 --------------------------------------- src/util/patricia.h | 21 ---- src/util/vmap.c | 146 ------------------------ src/util/vmap.h | 47 -------- src/util/vset.c | 104 ----------------- src/util/vset.h | 43 ------- src/util/windir.c | 56 ---------- src/util/windir.h | 50 --------- 14 files changed, 818 deletions(-) delete mode 100644 src/util/argstack.c delete mode 100644 src/util/argstack.h delete mode 100644 src/util/patricia.c delete mode 100644 src/util/patricia.h delete mode 100644 src/util/vmap.c delete mode 100644 src/util/vmap.h delete mode 100644 src/util/vset.c delete mode 100644 src/util/vset.h delete mode 100644 src/util/windir.c delete mode 100644 src/util/windir.h diff --git a/src/build/util.c b/src/build/util.c index 012c557da..5a37a6463 100644 --- a/src/build/util.c +++ b/src/build/util.c @@ -7,7 +7,6 @@ #include #include -#include #include #include #include diff --git a/src/kernel/config.c b/src/kernel/config.c index 4423ad467..c310d9703 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -86,11 +86,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -#define PTRIES 0 /* it turns out they are slow :-( */ -#if PTRIES -#include -#endif - struct settings global = { "Eressea", /* gamename */ }; diff --git a/src/util.vcxproj b/src/util.vcxproj index 027e10ae6..d21e79368 100644 --- a/src/util.vcxproj +++ b/src/util.vcxproj @@ -87,7 +87,6 @@ - @@ -109,7 +108,6 @@ - @@ -123,7 +121,6 @@ - @@ -145,7 +142,6 @@ - diff --git a/src/util.vcxproj.filters b/src/util.vcxproj.filters index f1e5a7d17..7ef937c10 100644 --- a/src/util.vcxproj.filters +++ b/src/util.vcxproj.filters @@ -11,9 +11,6 @@ - - Header Files - Header Files @@ -74,9 +71,6 @@ Header Files - - Header Files - Header Files @@ -115,9 +109,6 @@ - - Source Files - Source Files @@ -178,9 +169,6 @@ Source Files - - Source Files - Source Files diff --git a/src/util/argstack.c b/src/util/argstack.c deleted file mode 100644 index 614a18def..000000000 --- a/src/util/argstack.c +++ /dev/null @@ -1,66 +0,0 @@ -#include "argstack.h" -#include - -#define ARGSTKSIZE 16 -typedef struct arguments { - int n; - struct value { - int type; - union { - double number; - const char * str; - void * data; - } value; - } stack[ARGSTKSIZE]; -} arguments; - -void arg_init(struct arguments * arg) { - arg->n = 0; -} - -void arg_done(struct arguments * arg) { - arg = arg; -} - -void arg_pushuserdata(struct arguments * arg, int type, void * data) { - assert(arg->nstack[arg->n].type = type; - arg->stack[arg->n].value.data = data; - ++arg->n; -} - -void arg_pushstring(struct arguments * arg, const char * str) { - assert(arg->nstack[arg->n].type = ARG_TSTRING; - arg->stack[arg->n].value.str = str; - ++arg->n; -} - -void arg_pushnumber(struct arguments * arg, double number) { - assert(arg->nstack[arg->n].type = ARG_TSTRING; - arg->stack[arg->n].value.number = number; - ++arg->n; -} - -int arg_size(struct arguments * arg) { - return arg->n; -} - -void * arg_touserdata(struct arguments * arg, int idx, int type) { - assert(arg->n>idx && idx>=0); - assert(arg->stack[arg->n].type==type); - return arg->stack[arg->n].value.data; -} - -double arg_tonumber(struct arguments * arg, int idx) { - assert(arg->n>idx && idx>=0); - assert(arg->stack[arg->n].type==ARG_TNUMBER); - return arg->stack[arg->n].value.number; -} - -const char * arg_tostring(struct arguments * arg, int idx) { - assert(arg->n>idx && idx>=0); - assert(arg->stack[arg->n].type==ARG_TSTRING); - return arg->stack[arg->n].value.str; -} diff --git a/src/util/argstack.h b/src/util/argstack.h deleted file mode 100644 index b4a0dc420..000000000 --- a/src/util/argstack.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef UTIL_ARG_H -#define UTIL_ARG_H -#ifdef __cplusplus -extern "C" { -#endif - -struct arguments; - -#define ARG_TNUMBER -1 -#define ARG_TSTRING -2 - -void arg_init(struct arguments * arg); -void arg_done(struct arguments * arg); - -void arg_push(struct arguments * arg, int type, void * data); -void arg_pushstring(struct arguments * arg, const char * str); -void arg_pushnumber(struct arguments * arg, double number); - -int arg_size(struct arguments * arg); -void * arg_touserdata(struct arguments * arg, int idx, int type); -double arg_tonumber(struct arguments * arg, int idx); -const char * arg_tostring(struct arguments * arg, int idx); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/util/patricia.c b/src/util/patricia.c deleted file mode 100644 index 4189f146b..000000000 --- a/src/util/patricia.c +++ /dev/null @@ -1,236 +0,0 @@ -#include - -#include -#include -#include - -#include "patricia.h" - -#define MAXKEYLEN 128 - -/* TODO: custom memory management to optimize cache layout, or use arrays. */ - -/* NOTE: The structure saves an extra 0 delimiter for the key. Technically - * this wouldn't be necessary (because we know its' length from data[0]), - * but it makes it possible for trie_getkey to return a key without making - * a copy or have a cumbersome (const char**, size_t*) interface. - * +-----------+-------------+------+------------+ - * data: | keylen(1) | key(keylen) | 0(1) | data(size) | - * +-----------+-------------+------+------------+ - */ - -struct trie_node { - struct trie_node *l, *r; - char * data; - unsigned int bitpos; -}; - -#if 1 -#define get_bit(c, s, p) (unsigned int)((((p)>>3)>(unsigned int)(s))?0:((c)[(p)>>3]>>((p)&7)&1)) -#else -unsigned int get_bit(const char * c, size_t s, unsigned int p) -{ - if ((p>>3)>=(unsigned int)s) return 0; - return ((c)[p>>3]>>(p&7)&1); -} -#endif -#define node_bit(n, p) get_bit((n)->data+1, (n)->data[0], (p)) - -trie_node * trie_insert(trie_node **root_p, const char * key, const void * data, size_t size) -{ - trie_node * new_node; - size_t keylen = strlen(key); - trie_node ** insert_p = root_p, *node = *insert_p; - unsigned int p, bit=0; - - assert(keylenbitpos) { - insert_p = bit?&node->r:&node->l; - node = *insert_p; - if (node==NULL) { - continue; - } - } - - /* if we are looking at a back-node, we need to add our node before it. */ - if (p>=node->bitpos) { - /* find the point p where both differ. */ - if (keylen==(unsigned int)node->data[0] && strncmp(key, node->data+1, keylen)==0) { - /* we are trying to insert the same key again */ - - return node; - } - do { - ++p; - bit = get_bit(key, keylen, p); - } while (node_bit(node, p)==bit); - break; - } - - /* if instead we differ before reaching the end of the current prefix, we must split. - * we insert our node before the current one and re-attach it. */ - if (node_bit(node, p)!=bit) { - break; - } - } - - new_node = (trie_node *)malloc(sizeof(trie_node)); - new_node->bitpos = p; - new_node->data = malloc(keylen+2+size); - new_node->data[0] = (char)keylen; - memcpy(new_node->data+1, key, keylen+1); - if (data!=NULL && size>0) { - /* if data is NULL then the user only wanted some space that they're going to write to later */ - /* if size is 0 then the user is using the trie as a set, not a map */ - memcpy(new_node->data+2+keylen, data, size); - } - if (bit) { - new_node->l = node; - new_node->r = new_node; /* loop the 1-bit to ourselves, search will end */ - } else { - new_node->l = new_node; /* loop the 0-bit to ourselves, search will end */ - new_node->r = node; - } - *insert_p = new_node; - return new_node; -} - -void trie_remove(trie_node **root_p, trie_node *pos) -{ - if (pos!=NULL) { - const char * key = trie_getkey(pos); - size_t keylen = pos->data[0]; - trie_node ** node_p = root_p; - trie_node * node = *root_p; - - while (node) { - int bit; - trie_node ** next_p; - trie_node * next; - - if (node == pos) { - if (node->l==node) { - *node_p = node->r; - break; - } else if (node->r==node) { - *node_p = node->l; - break; - } - } - - bit = get_bit(key, keylen, node->bitpos); - next_p = bit?&node->r:&node->l; - next = *next_p; - if (next == pos && next->bitpos<=node->bitpos) { - /* the element that has a back-pointer to pos gets swapped with pos */ - char * data = pos->data; - pos->data = node->data; - node->data = data; - - /* finally, find the back-pointer to node and set it to pos */ - next_p = bit?&node->l:&node->r; /* NB: this is the OTHER child of node */ - next = *next_p; - key = trie_getkey(node); - keylen = (unsigned int)node->data[0]; - while (next) { - int new_bit; - if (next==node) { - *next_p = pos; - break; - } - new_bit = get_bit(key, keylen, next->bitpos); - next_p = new_bit?&next->r:&next->l; - next = *next_p; - } - *node_p = bit?node->l:node->r; - break; - } - node = *next_p; - node_p = next_p; - } - free(node->data); - free(node); - } -} - -void trie_debug(trie_node * root) -{ - const char * l = root->l?trie_getkey(root->l):"?"; - const char * r = root->r?trie_getkey(root->r):"?"; - printf("%s %d | %s | %s\n", trie_getkey(root), root->bitpos, l, r); - if (root->l && root->l->bitpos > root->bitpos) trie_debug(root->l); - if (root->r && root->r->bitpos > root->bitpos) trie_debug(root->r); -} - -trie_node * trie_find(trie_node *root, const char *key) -{ - trie_node * node = root; - size_t keylen = strlen(key); - - while (node) { - int bit = get_bit(key, keylen, node->bitpos); - trie_node * next = bit?node->r:node->l; - - if (next!=NULL) { - if (node->bitpos>=next->bitpos) { - if (keylen==(unsigned int)next->data[0] && strncmp(key, next->data+1, keylen)==0) { - return next; - } - next = NULL; - } - } - node = next; - } - return NULL; -} - -trie_node * trie_find_prefix(trie_node *root, const char *key) -{ - trie_node * node = root; - size_t keylen = strlen(key); - - while (node) { - int bit = get_bit(key, keylen, node->bitpos); - trie_node * next = bit?node->r:node->l; - - if (next!=NULL) { - if (node->bitpos>=next->bitpos) { - if (keylen<=(unsigned int)next->data[0] && strncmp(key, next->data+1, keylen)==0) { - return next; - } - next = NULL; - } - } - node = next; - } - return NULL; -} - -void * trie_getdata(trie_node * node) -{ - return node->data+2+node->data[0]; -} - -const char * trie_getkey(trie_node * node) -{ - return node->data+1; -} - -void trie_free(trie_node * root) -{ - if (root) { - if (root->l && root->l->bitpos>root->bitpos) trie_free(root->l); - if (root->r && root->r->bitpos>root->bitpos) trie_free(root->r); - free(root); - } -} diff --git a/src/util/patricia.h b/src/util/patricia.h deleted file mode 100644 index f01be96be..000000000 --- a/src/util/patricia.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef H_PATRICIA -#define H_PATRICIA -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct trie_node trie_node; - -trie_node * trie_insert(trie_node **root, const char *key, const void *data, size_t size); -trie_node * trie_find(trie_node *root, const char *key); -void * trie_getdata(trie_node *node); -const char * trie_getkey(trie_node *node); -void trie_free(trie_node * root); -void trie_remove(trie_node **root_p, trie_node *pos); -void trie_debug(trie_node * root); -trie_node * trie_find_prefix(trie_node *root, const char *key); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/util/vmap.c b/src/util/vmap.c deleted file mode 100644 index 6ca8f473d..000000000 --- a/src/util/vmap.c +++ /dev/null @@ -1,146 +0,0 @@ -/* -Copyright (c) 1998-2010, Enno Rehling - Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#ifdef _MSC_VER -#pragma warning (disable: 4711) -#endif - -#include -#include -#include -#include -#include "vmap.h" - -size_t -vmap_lowerbound(const vmap * vm, const int key) -/* returns the index of the entry which has the greatest key that is less or - * equal to 'key' */ -{ - vmapentry *first = vm->data, *middle; - unsigned int half, len = vm->size; - while (len > 0) { - half = len / 2; - middle = first; - middle += half; - if (middle->key < key) { - first = middle + 1; - len = len - half - 1; - } else - len = half; - } - return first - vm->data; -} - -void -vmap_init(vmap * map) -{ - map->size = 0; /* !! */ - map->maxsize = 4; - map->data = calloc(4, sizeof(vmapentry)); -} - -size_t -vmap_upperbound(const vmap * vm, const int key) -/* returns the index of the entry which has the smallest key that is greater - * or equal to 'key' */ -{ - unsigned int half, len = vm->size; - vmapentry *first = vm->data, *middle; - while (len > 0) { - half = len / 2; - middle = first; - middle += half; - if (key < middle->key) - len = half; - else { - first = middle + 1; - len = len - half - 1; - } - } - return first - vm->data; -} - -size_t -vmap_get(vmap * vm, const int key) -{ - size_t insert = vmap_lowerbound(vm, key); - vmapentry *at; - - /* make sure it's a unique key: */ - if (insert != vm->size && vm->data[insert].key == key) - return insert; - /* insert at this position: */ - if (vm->size == vm->maxsize) { - /* need more space */ - vm->maxsize *= 2; - vm->data = realloc(vm->data, vm->maxsize * sizeof(vmapentry)); - } - at = vm->data + insert; - memmove(at + 1, at, (vm->size - insert) * sizeof(vmapentry)); /* !1.3! */ - at->key = key; - at->value = 0; - ++vm->size; - return insert; -} - -size_t -vmap_insert(vmap * vm, const int key, void *data) -/* inserts an object into the vmap, identifies it with the 'key' which must be - * unique, and returns the vmapentry it created. */ -{ - size_t insert = vmap_lowerbound(vm, key); - vmapentry *at; - - /* make sure it's a unique key: */ - assert(insert == vm->size || vm->data[insert].key != key); - /* insert at this position: */ - if (vm->size == vm->maxsize) { - /* need more space */ - vm->maxsize = vm->maxsize ? (vm->maxsize * 2) : 4; - vm->data = realloc(vm->data, vm->maxsize * sizeof(vmapentry)); - } - at = vm->data + insert; - memmove(at + 1, at, (vm->size - insert) * sizeof(vmapentry)); - at->key = key; - at->value = data; - ++vm->size; - return insert; -} - -size_t -vmap_find(const vmap * vm, const int key) -/* returns the index of the vmapentry that's identified by the key or size (a - * past-the-end value) if it is not found. */ -{ - vmapentry *first = vm->data, *middle; - unsigned int half, len = vm->size; - while (len > 0) { - half = len / 2; - middle = first; - middle += half; - if (middle->key < key) { - first = middle + 1; - len = len - half - 1; - } else - len = half; - } - if (first != vm->data + vm->size && first->key == key) - return first - vm->data; - else - return vm->size; -} diff --git a/src/util/vmap.h b/src/util/vmap.h deleted file mode 100644 index 872d4db35..000000000 --- a/src/util/vmap.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -Copyright (c) 1998-2010, Enno Rehling - Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#ifndef VMAP_H -#define VMAP_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct vmapentry vmapentry; -struct vmapentry { - int key; - void *value; -}; -typedef struct vmap vmap; -struct vmap { - vmapentry *data; - unsigned int size; - unsigned int maxsize; -}; - -size_t vmap_lowerbound(const vmap * vm, const int key); -size_t vmap_upperbound(const vmap * vm, const int key); -size_t vmap_insert(vmap * vm, const int key, void *data); -size_t vmap_find(const vmap * vm, const int key); -size_t vmap_get(vmap * vm, const int key); -void vmap_init(vmap * vm); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/util/vset.c b/src/util/vset.c deleted file mode 100644 index f4bac1bb0..000000000 --- a/src/util/vset.c +++ /dev/null @@ -1,104 +0,0 @@ -/* -Copyright (c) 1998-2010, Enno Rehling - Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#include -#include -#include "vset.h" - -void -vset_init(vset * s) -{ - s->data = 0; - s->size = 0; - s->maxsize = 0; -} - -void -vset_destroy(vset * s) -{ - if (s->data) - free(s->data); -} - -int -vset_erase(vset * s, void *item) -{ - size_t i; - - for (i = 0; i != s->size; ++i) - if (s->data[i] == item) { - s->size--; - s->data[i] = s->data[s->size]; - return 1; - } - return 0; -} - -size_t -vset_add(vset * s, void *item) -{ - size_t i; - - if (!s->data) { - s->size = 0; - s->maxsize = 4; - s->data = calloc(4, sizeof(void *)); - } - for (i = 0; i != s->size; ++i) - if (s->data[i] == item) - return i; - if (s->size == s->maxsize) { - s->maxsize *= 2; - s->data = realloc(s->data, s->maxsize * sizeof(void *)); - } - s->data[s->size] = item; - ++s->size; - return s->size - 1; -} - -void * -vset_pop(vset *s) -{ - if(s->size == 0) return NULL; - s->size--; - return s->data[s->size+1]; -} - -int -vset_count(vset *s, void *item) -{ - size_t i; - int c = 0; - - for(i = 0; i != s->size; ++i) { - if(s->data[i] == item) c++; - } - - return c; -} - -void -vset_concat(vset *to, vset *from) -{ - size_t i; - - for(i=0; i != from->size; ++i) { - vset_add(to, from->data[i]); - } -} - diff --git a/src/util/vset.h b/src/util/vset.h deleted file mode 100644 index 30a045ceb..000000000 --- a/src/util/vset.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -Copyright (c) 1998-2010, Enno Rehling - Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#ifndef VOIDPTR_SETS -#define VOIDPTR_SETS -#ifdef __cplusplus -extern "C" { -#endif - -#include -typedef struct vset vset; -struct vset { - void **data; - size_t size; - size_t maxsize; -}; -extern void vset_init(vset * s); -extern void vset_destroy(vset * s); -extern size_t vset_add(vset * s, void *); -extern int vset_erase(vset * s, void *); -extern int vset_count(vset *s, void * i); -extern void *vset_pop(vset *s); -extern void vset_concat(vset *to, vset *from); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/util/windir.c b/src/util/windir.c deleted file mode 100644 index 9d62f8360..000000000 --- a/src/util/windir.c +++ /dev/null @@ -1,56 +0,0 @@ -/* -Copyright (c) 1998-2010, Enno Rehling - Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#ifdef _MSC_VER -#include - -#include -#include -#include "windir.h" - -DIR * -opendir(const char *name) -{ - static DIR direct; /* STATIC_RESULT: used for return, not across calls */ - - direct.first = 1; - _searchenv(name, "ERESSEA_PATH", direct.name); - if (*direct.name != '\0') - return &direct; - return NULL; -} - -struct dirent * -readdir(DIR * thedir) -{ - static struct _finddata_t ft; /* STATIC_RESULT: used for return, not across calls */ - static struct dirent de; /* STATIC_RESULT: used for return, not across calls */ - char where[_MAX_PATH]; - - strcat(strcpy(where, thedir->name), "/*"); - if (thedir->first) { - thedir->first = 0; - de.hnd = _findfirst(where, &ft); - } else { - if (_findnext(de.hnd, &ft) != 0) - return NULL; - } - _splitpath(ft.name, de.d_drive, de.d_dir, de.d_name, de.d_ext); - return &de; -} -#endif diff --git a/src/util/windir.h b/src/util/windir.h deleted file mode 100644 index de9851aa9..000000000 --- a/src/util/windir.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -Copyright (c) 1998-2010, Enno Rehling - Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - -#ifndef WINDIR_H -#define WINDIR_H - -#ifdef _MSC_VER -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -typedef struct DIR { - char name[_MAX_PATH]; - int first; -} DIR; - -typedef struct dirent { - char d_path[_MAX_PATH]; - char d_name[_MAX_FNAME]; - char d_drive[_MAX_DRIVE]; - char d_dir[_MAX_DIR]; - char d_ext[_MAX_EXT]; - intptr_t hnd; -} dirent; - -DIR *opendir(const char *name); -struct dirent *readdir(DIR * thedir); - -#ifdef __cplusplus -} -#endif -#endif -#endif