Mercurial > hg > th-libs
annotate th_util.h @ 148:bca55caf5c37
Update copyright year.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 07 Jan 2015 16:56:29 +0200 |
parents | fdea1c3acc53 |
children | b4e1b15a64e1 |
rev | line source |
---|---|
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 /* |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 * Generic utility-functions, macros and defaults |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 * Programmed and designed by Matti 'ccr' Hamalainen |
144 | 4 * (C) Copyright 2002-2015 Tecnic Software productions (TNSP) |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 * |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 * Please read file 'COPYING' for information on license and distribution. |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 */ |
49
598609fb49b0
Change how "config.h" is included, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
8 #ifndef TH_UTIL_H |
598609fb49b0
Change how "config.h" is included, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
9 #define TH_UTIL_H |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
10 |
49
598609fb49b0
Change how "config.h" is included, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
11 #ifdef HAVE_CONFIG_H |
598609fb49b0
Change how "config.h" is included, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
12 #include "config.h" |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
13 #endif |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
14 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 #include "th_types.h" |
45
e031a062b731
Separate program "banner" printing from th_args_help() to th_print_banner().
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
16 #include <stdio.h> |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
17 #include <stdarg.h> |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 #include <stdlib.h> |
75 | 19 #include <unistd.h> |
16 | 20 #include <sys/types.h> |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
21 #ifndef HAVE_NO_ASSERT |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 #include <assert.h> |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
23 #endif |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
24 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
25 #ifdef HAVE_STRING_H |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
26 #include <string.h> |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
27 #else |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
28 #ifdef HAVE_STRINGS_H |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
29 #include <strings.h> |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
30 #endif |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
31 #endif |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
32 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
33 #ifdef HAVE_MEMORY_H |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
34 #include <memory.h> |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
35 #endif |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
36 |
92 | 37 |
49
598609fb49b0
Change how "config.h" is included, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
38 #ifdef __cplusplus |
598609fb49b0
Change how "config.h" is included, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
39 extern "C" { |
598609fb49b0
Change how "config.h" is included, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
40 #endif |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
41 |
4
67f4a4233372
Move defaults to header file.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
42 #ifdef TH_NO_DEFAULTS |
6 | 43 #define TH_PROG_AUTHOR NULL |
44 #define TH_PROG_LICENSE NULL | |
4
67f4a4233372
Move defaults to header file.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
45 #else |
148 | 46 #define TH_PROG_AUTHOR "By Matti 'ccr' Hämäläinen (C) Copyright 2015 TNSP" |
6 | 47 #define TH_PROG_LICENSE "This software is licensed under GNU GPL version 2" |
4
67f4a4233372
Move defaults to header file.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
48 #endif |
67f4a4233372
Move defaults to header file.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
49 |
67f4a4233372
Move defaults to header file.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
50 |
95 | 51 // Replacement for assert() |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
52 #ifdef HAVE_NO_ASSERT |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
53 # ifdef NDEBUG |
129 | 54 # define assert(NEXPR) // stub |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
55 # else |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
56 # define assert(NEXPR) do { if (!(NEXPR)) { fprintf(stderr, "[%s:%d] assert(" # NEXPR ") failed!\n", __FILE__, __LINE__); abort(); } } while (0) |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
57 # endif |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
58 #endif |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
59 |
96 | 60 |
61 /* Error codes | |
62 */ | |
97 | 63 enum |
64 { | |
96 | 65 // General error codes |
66 THERR_OK = 0, | |
67 THERR_PROGRESS, // Status OK, but operation in progress | |
68 | |
69 THERR_INTERNAL, | |
70 | |
71 THERR_FOPEN, | |
72 THERR_FREAD, | |
73 THERR_FWRITE, | |
74 THERR_FSEEK, | |
75 THERR_NOT_FOUND, // Resource/data not found | |
76 | |
77 THERR_INVALID_DATA, // Some data was invalid | |
78 THERR_MALLOC, // Memory allocation failure | |
79 THERR_ALREADY_INIT, // Resource has already been initialized | |
80 THERR_INIT_FAIL, // General initialization failure | |
81 THERR_INVALID_ARGS, | |
82 | |
83 THERR_NULLPTR, // NULL pointer specified in critical argument | |
84 THERR_NOT_SUPPORTED,// Operation not supported | |
85 THERR_OUT_OF_DATA, | |
86 THERR_EXTRA_DATA, | |
87 THERR_BOUNDS, | |
88 THERR_TIMED_OUT, | |
89 | |
90 // Network errors | |
91 THERR_AUTH_FAILED, | |
92 }; | |
93 | |
94 #define TH_SYSTEM_ERRORS 100000 | |
95 | |
97 | 96 /* Log levels |
97 */ | |
98 enum | |
99 { | |
100 THLOG_NONE = 0, | |
101 THLOG_ERROR, | |
102 THLOG_WARNING, | |
103 THLOG_INFO, | |
104 THLOG_DEBUG, | |
105 }; | |
106 | |
96 | 107 |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
108 /* Global variables |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
109 */ |
19 | 110 extern int th_verbosityLevel; |
111 extern char *th_prog_name, | |
60 | 112 *th_prog_desc, |
19 | 113 *th_prog_version, |
114 *th_prog_author, | |
115 *th_prog_license; | |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
116 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
117 /* Functions |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
118 */ |
60 | 119 void th_init(char *name, char *desc, char *version, |
120 char *author, char *license); | |
121 void th_print_banner(FILE *outFile, const char *binName, const char *usage); | |
45
e031a062b731
Separate program "banner" printing from th_args_help() to th_print_banner().
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
122 |
143 | 123 int th_term_width(); |
124 int th_term_height(); | |
125 | |
101
a8f732601fdc
Rename th_get_errno() to th_get_error(), it's more appropriate since it does
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
126 int th_get_error(); |
99 | 127 int th_errno_to_error(int error); |
96 | 128 const char *th_error_str(int error); |
129 | |
6 | 130 void THERR(const char *, ...); |
131 void THMSG(int, const char *, ...); | |
132 void THPRINT(int, const char *, ...); | |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
133 |
11 | 134 void THERR_V(const char *, va_list); |
135 void THMSG_V(int, const char *, va_list); | |
136 void THPRINT_V(int, const char *, va_list); | |
137 | |
6 | 138 void *th_malloc(size_t); |
68
29f9651465c6
Added a new memory allocator function, th_malloc0(size), which is the same as calloc(1, size).
Matti Hamalainen <ccr@tnsp.org>
parents:
66
diff
changeset
|
139 void *th_malloc0(size_t); |
6 | 140 void *th_calloc(size_t, size_t); |
141 void *th_realloc(void *, size_t); | |
142 void th_free(void *); | |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
143 |
16 | 144 |
145 /* Doubly linked list handling | |
146 */ | |
69 | 147 typedef struct _qlist_t |
148 { | |
16 | 149 void *data; |
150 size_t num; | |
151 struct _qlist_t *prev, *next; | |
152 } qlist_t; | |
153 | |
154 | |
155 qlist_t * th_llist_new(void *data); | |
156 void th_llist_free(qlist_t *list); | |
157 void th_llist_free_func(qlist_t *list, void (*freefunc)(void *data)); | |
158 | |
53
2c90b33d3617
Add th_llist_append_node() and th_llist_prepend_node() to public header.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
159 void th_llist_append_node(qlist_t **list, qlist_t *node); |
16 | 160 qlist_t * th_llist_append(qlist_t **list, void *data); |
53
2c90b33d3617
Add th_llist_append_node() and th_llist_prepend_node() to public header.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
161 void th_llist_prepend_node(qlist_t **list, qlist_t *node); |
16 | 162 qlist_t * th_llist_prepend(qlist_t **list, void *data); |
163 void th_llist_delete(qlist_t **list, const void *data); | |
164 void th_llist_delete_node(qlist_t **list, qlist_t *node); | |
93
029b3dea31ff
Make th_llist_delete_node_fast() public.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
165 void th_llist_delete_node_fast(qlist_t **list, qlist_t *node); |
16 | 166 |
167 qlist_t * th_llist_get_nth(qlist_t *list, const size_t n); | |
168 size_t th_llist_length(const qlist_t *list); | |
169 ssize_t th_llist_position(const qlist_t *list, const qlist_t *node); | |
170 | |
55
300fba04b7ad
Adjust the foreach linked list functions a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
54
diff
changeset
|
171 void th_llist_foreach(qlist_t *list, void (*func)(qlist_t *node, void *userdata), void *data); |
300fba04b7ad
Adjust the foreach linked list functions a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
54
diff
changeset
|
172 int th_llist_foreach_cond(qlist_t *list, int (*func)(qlist_t *node, void *userdata), void *data, qlist_t **res); |
54
48926b3ff598
Add new linked list handling functions: th_llist_foreach() and th_llist_foreach_cond()
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
173 |
16 | 174 qlist_t * th_llist_find(qlist_t *list, const void *data); |
175 qlist_t * th_llist_find_func(qlist_t *list, const void *userdata, int (compare)(const void *, const void *)); | |
176 | |
177 | |
23
a4f894105953
Add ringbuffer implementation.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
178 /* Ringbuffer implementation |
a4f894105953
Add ringbuffer implementation.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
179 */ |
69 | 180 typedef struct |
181 { | |
33 | 182 char **data; |
23
a4f894105953
Add ringbuffer implementation.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
183 int n, size; |
a4f894105953
Add ringbuffer implementation.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
184 void (*deallocator)(void *); |
a4f894105953
Add ringbuffer implementation.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
185 } qringbuf_t; |
a4f894105953
Add ringbuffer implementation.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
186 |
a4f894105953
Add ringbuffer implementation.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
187 qringbuf_t * th_ringbuf_new(const size_t size, void (*mdeallocator)(void *)); |
95 | 188 BOOL th_ringbuf_grow(qringbuf_t *buf, const size_t n); |
189 void th_ringbuf_free(qringbuf_t *buf); | |
190 void th_ringbuf_add(qringbuf_t *buf, void *ptr); | |
23
a4f894105953
Add ringbuffer implementation.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
191 |
a4f894105953
Add ringbuffer implementation.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
192 |
109
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
193 /* Growing buffers |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
194 */ |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
195 #define TH_BUFGROW (32) |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
196 |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
197 |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
198 typedef struct |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
199 { |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
200 BOOL allocated; |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
201 uint8_t *data; |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
202 size_t size, len, mingrow; |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
203 } th_growbuf_t; |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
204 |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
205 |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
206 /* Simple growing string buffer |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
207 */ |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
208 BOOL th_strbuf_grow(char **buf, size_t *bufsize, size_t *len, const size_t grow); |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
209 BOOL th_strbuf_putch(char **buf, size_t *bufsize, size_t *len, const char ch); |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
210 BOOL th_strbuf_puts(char **buf, size_t *bufsize, size_t *len, const char *str); |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
211 |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
212 |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
213 /* Growing byte buffer |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
214 */ |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
215 void th_growbuf_init(th_growbuf_t *buf, const size_t mingrow); |
115
13f001f1ad6e
More work on growbuf stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
216 void th_growbuf_clear(th_growbuf_t *buf); |
109
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
217 th_growbuf_t *th_growbuf_new(const size_t mingrow); |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
218 void th_growbuf_free(th_growbuf_t *buf); |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
219 |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
220 |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
221 BOOL th_growbuf_grow(th_growbuf_t *buf, const size_t grow); |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
222 BOOL th_growbuf_puts(th_growbuf_t *buf, const char *str, BOOL eos); |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
223 BOOL th_growbuf_putch(th_growbuf_t *buf, const char ch); |
120
41c2638ee537
Use void* instead of uint8_t* in th_growbuf_put_str()
Matti Hamalainen <ccr@tnsp.org>
parents:
115
diff
changeset
|
224 BOOL th_growbuf_put_str(th_growbuf_t *buf, const void *s, const size_t len); |
109
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
225 BOOL th_growbuf_put_u8(th_growbuf_t *buf, const uint8_t val); |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
226 BOOL th_growbuf_put_u16_be(th_growbuf_t *buf, const uint16_t val); |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
227 BOOL th_growbuf_put_u16_le(th_growbuf_t *buf, const uint16_t val); |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
228 BOOL th_growbuf_put_u32_be(th_growbuf_t *buf, const uint32_t val); |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
229 BOOL th_growbuf_put_u32_le(th_growbuf_t *buf, const uint32_t val); |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
230 |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
231 |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
232 #ifdef __cplusplus |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
233 } |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
234 #endif |
129 | 235 #endif // TH_UTIL_H |