4 Part of the swftools package.
6 Copyright (c) 2001,2002,2003,2004 Matthias Kramm <kramm@quiss.org>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
31 /* dynamically growing mem section */
32 typedef struct _mem_t {
38 /* fifo buffered growing mem region */
39 typedef struct _ringbuffer_t
45 /* non-nul terminated string */
46 typedef struct _string_t {
51 /* key/value pairs of strings */
52 typedef struct _map_t {
56 typedef struct _dictentry {
61 struct _dictentry*next;
64 /* (void*) pointers referenced by strings */
65 typedef struct _dict {
71 /* array of strings, string<->int mapping,
72 with O(1) for int->string lookup and
73 ~O(n/hashsize) for string->int lookup */
74 typedef struct _stringarray_t
87 int(*compare)(const void *, const void *);
90 void mem_init(mem_t*mem);
91 int mem_put(mem_t*m, void*data, int length);
92 int mem_putstring(mem_t*m, string_t str);
93 void mem_clear(mem_t*mem);
94 void mem_destroy(mem_t*mem);
96 void ringbuffer_init(ringbuffer_t*r);
97 void ringbuffer_put(ringbuffer_t*r, void*buf, int size);
98 int ringbuffer_read(ringbuffer_t*r, void*buf, int size);
99 void ringbuffer_clear(ringbuffer_t*r);
101 string_t string_new(const char*text, int len);
102 string_t string_new2(const char*text);
103 unsigned int string_hash(string_t*str);
104 unsigned int string_hash2(const char*str);
105 unsigned int string_hash3(const char*str, int len);
106 void string_set(string_t*str, const char*text);
107 void string_set2(string_t*str, const char*text, int len);
108 void string_dup(string_t*str, const char*text);
109 void string_dup2(string_t*str, const char*text, int len);
110 int string_equals(string_t*str, const char*text);
112 void stringarray_init(stringarray_t*sa, int hashsize);
113 void stringarray_put(stringarray_t*sa, string_t str);
114 char* stringarray_at(stringarray_t*sa, int pos);
115 string_t stringarray_at2(stringarray_t*sa, int pos);
116 int stringarray_find(stringarray_t*sa, string_t*str);
117 void stringarray_clear(stringarray_t*sa);
118 void stringarray_destroy(stringarray_t*sa);
121 void dict_init(dict_t*dict);
122 void dict_put(dict_t*dict, string_t t1, void* t2);
123 void dict_put2(dict_t*dict, const char* t1, void* t2);
124 void dict_put3(dict_t*dict, const char* t1, int len, void* t2);
126 stringarray_t* dict_index(dict_t*dict);
127 int dict_count(dict_t* dict);
128 void* dict_lookup(dict_t*dict, const char*name);
129 void dict_dump(dict_t*dict, FILE*fi, const char*prefix);
130 char dict_del(dict_t*dict, const char* name);
131 void dict_foreach_keyvalue(dict_t*h, void (*runFunction)(void*data, const char*key, void*val), void*data);
132 void dict_foreach_value(dict_t*h, void (*runFunction)(void*));
133 void dict_free_all(dict_t*h, void (*freeFunction)(void*));
134 void dict_clear(dict_t*dict);
135 void dict_destroy(dict_t*dict);
137 void map_init(map_t*map);
138 void map_put(map_t*map, string_t t1, string_t t2);
139 const char* map_lookup(map_t*map, const char*name);
140 void map_dump(map_t*map, FILE*fi, const char*prefix);
141 void map_clear(map_t*map);
142 void map_destroy(map_t*map);
144 void heap_init(heap_t*h,int n,int elem_size, int(*compare)(const void *, const void *));
145 void heap_clear(heap_t*h);
146 void heap_put(heap_t*h, void*e);
147 int heap_size(heap_t*h);
148 void* heap_max(heap_t*h);
149 void* heap_chopmax(heap_t*h);
150 void heap_dump(heap_t*h, FILE*fi);
151 void** heap_flatten(heap_t*h);
153 char* strdup_n(const char*str, int size);