fixed "identifier may not start with a digit" syntax error.
[swftools.git] / src / q.h
1 /* q.h
2    Header file for q.c.
3
4    Part of the swftools package.
5    
6    Copyright (c) 2001 Matthias Kramm <kramm@quiss.org>
7
8    This file is distributed under the GPL, see file COPYING for details */
9
10 #ifndef __q_h__
11 #define __q_h__
12
13 #include <stdio.h>
14
15 /* dynamically growing mem section */
16 typedef struct _mem_t {
17     char*buffer;
18     int len;
19     int pos;
20 } mem_t;
21
22 /* non-nul terminated string */
23 typedef struct _string_t {
24     char*str;
25     int len;
26 } string_t;
27
28 /* key/value pairs of strings */
29 typedef struct _map_t {
30     void*internal;
31 } map_t;
32
33 /* (void*)s referenced by strings */
34 typedef struct _dictionary_t {
35     void*internal;
36 } dictionary_t;
37
38 /* array of strings */
39 typedef struct stringarray_t
40 {
41     void*internal;
42 } stringarray_t;
43
44 void mem_init(mem_t*mem);
45 int mem_put(mem_t*m, void*data, int length);
46 int mem_putstring(mem_t*m, string_t str);
47 void mem_clear(mem_t*mem);
48 void mem_destroy(mem_t*mem);
49
50 void string_set(string_t*str, char*text);
51 void string_set2(string_t*str, char*text, int len);
52 void string_dup(string_t*str, const char*text);
53 void string_dup2(string_t*str, const char*text, int len);
54 int string_equals(string_t*str, const char*text);
55
56 void stringarray_init(stringarray_t*sa);
57 void stringarray_put(stringarray_t*sa, string_t str);
58 char* stringarray_at(stringarray_t*sa, int pos);
59 string_t stringarray_at2(stringarray_t*sa, int pos);
60 int stringarray_find(stringarray_t*sa, string_t*str);
61 void stringarray_clear(stringarray_t*sa);
62 void stringarray_destroy(stringarray_t*sa);
63
64 void map_init(map_t*map);
65 void map_put(map_t*map, string_t t1, string_t t2);
66 char* map_lookup(map_t*map, const char*name);
67 void map_dump(map_t*map, FILE*fi, const char*prefix);
68 void map_clear(map_t*map);
69 void map_destroy(map_t*map);
70
71 void dictionary_init(dictionary_t*dict);
72 void dictionary_put(dictionary_t*dict, string_t t1, void* t2);
73 void dictionary_put2(dictionary_t*dict, const char* t1, void* t2);
74 void* dictionary_lookup(dictionary_t*dict, const char*name);
75 void dictionary_dump(dictionary_t*dict, FILE*fi, const char*prefix);
76 void dictionary_del(dictionary_t*dict, const char* name);
77 void dictionary_clear(dictionary_t*dict);
78 void dictionary_destroy(dictionary_t*dict);
79
80 char* strndup(const char*str, int size);
81
82 void* qmalloc_internal(int len);
83 void* qrealloc_internal(void*old, int len);
84 void qfree_internal(void*old);
85
86 #define qmalloc(len) qmalloc_internal(len)
87 #define qrealloc(old, len) qmalloc_internal(old, len)
88 #define qfree(old) qmalloc_internal(old)
89
90 #endif //__q_h__