1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 #ifndef UCX_UTILS_H
39 #define UCX_UTILS_H
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45 #include "ucx.h"
46 #include "string.h"
47 #include "allocator.h"
48 #include <inttypes.h>
49 #include <string.h>
50 #include <stdarg.h>
51
52
53
54
55 #define UCX_STREAM_COPY_BUFSIZE 4096
56
57
58
59
60
61
62
63 void *ucx_strcpy(
void *s,
void *data);
64
65
66
67
68
69
70
71
72 void *ucx_memcpy(
void *m,
void *n);
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90 size_t ucx_stream_bncopy(
void *src,
void *dest, read_func rfnc, write_func wfnc,
91 char* buf,
size_t bufsize,
size_t n);
92
93
94
95
96
97
98
99
100
101
102
103
104 #define ucx_stream_copy(src,dest,rfnc,wfnc) ucx_stream_bncopy(\
105 src, dest, (read_func)rfnc, (write_func)wfnc, \
106 NULL,
UCX_STREAM_COPY_BUFSIZE, (
size_t)-
1)
107
108
109
110
111
112
113
114
115
116
117
118 #define ucx_stream_ncopy(src,dest,rfnc,wfnc, n) ucx_stream_bncopy(\
119 src, dest, (read_func)rfnc, (write_func)wfnc, \
120 NULL,
UCX_STREAM_COPY_BUFSIZE, n)
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136 #define ucx_stream_bcopy(src,dest,rfnc,wfnc, buf, bufsize) ucx_stream_bncopy(\
137 src, dest, (read_func)rfnc, (write_func)wfnc, \
138 buf, bufsize, (
size_t)-
1)
139
140
141
142
143
144
145
146
147 int ucx_strcmp(
void *s1,
void *s2,
void *data);
148
149
150
151
152
153
154
155
156 int ucx_strncmp(
void *s1,
void *s2,
void *n);
157
158
159
160
161
162
163
164
165
166 int ucx_intcmp(
void *i1,
void *i2,
void *data);
167
168
169
170
171
172
173
174
175
176
177 int ucx_floatcmp(
void *f1,
void *f2,
void *data);
178
179
180
181
182
183
184
185
186
187 int ucx_doublecmp(
void *d1,
void *d2,
void *data);
188
189
190
191
192
193
194
195
196
197 int ucx_ptrcmp(
void *ptr1,
void *ptr2,
void *data);
198
199
200
201
202
203
204
205
206 int ucx_memcmp(
void *ptr1,
void *ptr2,
void *n);
207
208
209
210
211
212
213
214
215
216
217 int ucx_fprintf(
void *stream, write_func wfc,
const char *fmt, ...);
218
219
220
221
222
223
224
225
226
227
228 int ucx_vfprintf(
void *stream, write_func wfc,
const char *fmt, va_list ap);
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247 sstr_t ucx_asprintf(UcxAllocator *allocator,
const char *fmt, ...);
248
249
250
251
252
253
254
255
256
257
258 sstr_t ucx_vasprintf(UcxAllocator *allocator,
const char *fmt, va_list ap);
259
260
261 #define ucx_sprintf(...) \
262 ucx_asprintf(ucx_default_allocator(),
__VA_ARGS__)
263
264
265
266
267
268
269
270
271
272
273 #define ucx_bprintf(buffer, ...) ucx_fprintf((UcxBuffer*)buffer, \
274 (write_func)ucx_buffer_write,
__VA_ARGS__)
275
276 #ifdef __cplusplus
277 }
278 #endif
279
280 #endif
281
282