fixed graphics bug
[swftools.git] / lib / q.h
1 /* q.h
2    Header file for q.c.
3
4    Part of the swftools package.
5    
6    Copyright (c) 2001,2002,2003 Matthias Kramm <kramm@quiss.org>
7  
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.
12
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.
17
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 */
21
22 #ifndef __q_h__
23 #define __q_h__
24
25 #include <stdio.h>
26 #include "../config.h"
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 /* dynamically growing mem section */
33 typedef struct _mem_t {
34     char*buffer;
35     int len;
36     int pos;
37 } mem_t;
38
39 typedef struct _ringbuffer_t
40 {
41     void*internal;
42     int available;
43 } ringbuffer_t;
44
45 /* non-nul terminated string */
46 typedef struct _string_t {
47     char*str;
48     int len;
49 } string_t;
50
51 /* key/value pairs of strings */
52 typedef struct _map_t {
53     void*internal;
54 } map_t;
55
56 /* (void*)s referenced by strings */
57 typedef struct _dictionary_t {
58     void*internal;
59 } dictionary_t;
60
61 /* array of strings */
62 typedef struct _stringarray_t
63 {
64     void*internal;
65 } stringarray_t;
66
67 void mem_init(mem_t*mem);
68 int mem_put(mem_t*m, void*data, int length);
69 int mem_putstring(mem_t*m, string_t str);
70 void mem_clear(mem_t*mem);
71 void mem_destroy(mem_t*mem);
72
73 void ringbuffer_init(ringbuffer_t*r);
74 void ringbuffer_put(ringbuffer_t*r, void*buf, int size);
75 int ringbuffer_read(ringbuffer_t*r, void*buf, int size);
76 void ringbuffer_clear(ringbuffer_t*r);
77
78 void string_set(string_t*str, char*text);
79 void string_set2(string_t*str, char*text, int len);
80 void string_dup(string_t*str, const char*text);
81 void string_dup2(string_t*str, const char*text, int len);
82 int string_equals(string_t*str, const char*text);
83
84 void stringarray_init(stringarray_t*sa);
85 void stringarray_put(stringarray_t*sa, string_t str);
86 char* stringarray_at(stringarray_t*sa, int pos);
87 string_t stringarray_at2(stringarray_t*sa, int pos);
88 int stringarray_find(stringarray_t*sa, string_t*str);
89 void stringarray_clear(stringarray_t*sa);
90 void stringarray_destroy(stringarray_t*sa);
91
92 void map_init(map_t*map);
93 void map_put(map_t*map, string_t t1, string_t t2);
94 char* map_lookup(map_t*map, const char*name);
95 void map_dump(map_t*map, FILE*fi, const char*prefix);
96 void map_clear(map_t*map);
97 void map_destroy(map_t*map);
98
99 void dictionary_init(dictionary_t*dict);
100 void dictionary_put(dictionary_t*dict, string_t t1, void* t2);
101 void dictionary_put2(dictionary_t*dict, const char* t1, void* t2);
102 void* dictionary_lookup(dictionary_t*dict, const char*name);
103 void dictionary_dump(dictionary_t*dict, FILE*fi, const char*prefix);
104 void dictionary_del(dictionary_t*dict, const char* name);
105 void dictionary_clear(dictionary_t*dict);
106 void dictionary_destroy(dictionary_t*dict);
107
108 char* strdup_n(const char*str, int size);
109
110 void* qmalloc_internal(int len);
111 void* qrealloc_internal(void*old, int len);
112 void qfree_internal(void*old);
113
114 #define qmalloc(len) qmalloc_internal(len)
115 #define qrealloc(old, len) qmalloc_internal(old, len)
116 #define qfree(old) qmalloc_internal(old)
117
118 #ifdef __cplusplus
119 }
120 #endif
121
122 #endif //__q_h__