Mercurial > hg > th-libs
annotate th_util.h @ 129:aa2d608fb3f3
Cosmetics.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 22 Jun 2014 07:23:54 +0300 |
parents | 41c2638ee537 |
children | c878cdcfea9d 51eec969b07a |
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 |
85 | 4 * (C) Copyright 2002-2014 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 |
85 | 46 #define TH_PROG_AUTHOR "By Matti 'ccr' Hämäläinen (C) Copyright 2014 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 |
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
|
123 int th_get_error(); |
99 | 124 int th_errno_to_error(int error); |
96 | 125 const char *th_error_str(int error); |
126 | |
6 | 127 void THERR(const char *, ...); |
128 void THMSG(int, const char *, ...); | |
129 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
|
130 |
11 | 131 void THERR_V(const char *, va_list); |
132 void THMSG_V(int, const char *, va_list); | |
133 void THPRINT_V(int, const char *, va_list); | |
134 | |
6 | 135 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
|
136 void *th_malloc0(size_t); |
6 | 137 void *th_calloc(size_t, size_t); |
138 void *th_realloc(void *, size_t); | |
139 void th_free(void *); | |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
140 |
16 | 141 |
142 /* Doubly linked list handling | |
143 */ | |
69 | 144 typedef struct _qlist_t |
145 { | |
16 | 146 void *data; |
147 size_t num; | |
148 struct _qlist_t *prev, *next; | |
149 } qlist_t; | |
150 | |
151 | |
152 qlist_t * th_llist_new(void *data); | |
153 void th_llist_free(qlist_t *list); | |
154 void th_llist_free_func(qlist_t *list, void (*freefunc)(void *data)); | |
155 | |
53
2c90b33d3617
Add th_llist_append_node() and th_llist_prepend_node() to public header.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
156 void th_llist_append_node(qlist_t **list, qlist_t *node); |
16 | 157 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
|
158 void th_llist_prepend_node(qlist_t **list, qlist_t *node); |
16 | 159 qlist_t * th_llist_prepend(qlist_t **list, void *data); |
160 void th_llist_delete(qlist_t **list, const void *data); | |
161 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
|
162 void th_llist_delete_node_fast(qlist_t **list, qlist_t *node); |
16 | 163 |
164 qlist_t * th_llist_get_nth(qlist_t *list, const size_t n); | |
165 size_t th_llist_length(const qlist_t *list); | |
166 ssize_t th_llist_position(const qlist_t *list, const qlist_t *node); | |
167 | |
55
300fba04b7ad
Adjust the foreach linked list functions a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
54
diff
changeset
|
168 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
|
169 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
|
170 |
16 | 171 qlist_t * th_llist_find(qlist_t *list, const void *data); |
172 qlist_t * th_llist_find_func(qlist_t *list, const void *userdata, int (compare)(const void *, const void *)); | |
173 | |
174 | |
23
a4f894105953
Add ringbuffer implementation.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
175 /* Ringbuffer implementation |
a4f894105953
Add ringbuffer implementation.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
176 */ |
69 | 177 typedef struct |
178 { | |
33 | 179 char **data; |
23
a4f894105953
Add ringbuffer implementation.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
180 int n, size; |
a4f894105953
Add ringbuffer implementation.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
181 void (*deallocator)(void *); |
a4f894105953
Add ringbuffer implementation.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
182 } qringbuf_t; |
a4f894105953
Add ringbuffer implementation.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
183 |
a4f894105953
Add ringbuffer implementation.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
184 qringbuf_t * th_ringbuf_new(const size_t size, void (*mdeallocator)(void *)); |
95 | 185 BOOL th_ringbuf_grow(qringbuf_t *buf, const size_t n); |
186 void th_ringbuf_free(qringbuf_t *buf); | |
187 void th_ringbuf_add(qringbuf_t *buf, void *ptr); | |
23
a4f894105953
Add ringbuffer implementation.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
188 |
a4f894105953
Add ringbuffer implementation.
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
189 |
109
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
190 /* Growing buffers |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
191 */ |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
192 #define TH_BUFGROW (32) |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
193 |
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 typedef struct |
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 BOOL allocated; |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
198 uint8_t *data; |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
199 size_t size, len, mingrow; |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
200 } th_growbuf_t; |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
201 |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
202 |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
203 /* Simple growing string buffer |
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 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
|
206 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
|
207 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
|
208 |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
209 |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
210 /* Growing byte buffer |
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 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
|
213 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
|
214 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
|
215 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
|
216 |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
217 |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
218 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
|
219 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
|
220 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
|
221 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
|
222 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
|
223 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
|
224 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
|
225 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
|
226 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
|
227 |
fedad0ed894f
Remove th_growbuf, move to th_util.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
228 |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
229 #ifdef __cplusplus |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
230 } |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
231 #endif |
129 | 232 #endif // TH_UTIL_H |