80 * provided for <code>buf</code>, this is the size of the buffer that shall be |
85 * provided for <code>buf</code>, this is the size of the buffer that shall be |
81 * implicitly created |
86 * implicitly created |
82 * @param n the maximum number of bytes that shall be copied |
87 * @param n the maximum number of bytes that shall be copied |
83 * @return the total number of bytes copied |
88 * @return the total number of bytes copied |
84 */ |
89 */ |
85 size_t ucx_stream_copy(void *src, void *dest, read_func rfnc, write_func wfnc, |
90 size_t ucx_stream_bncopy(void *src, void *dest, read_func rfnc, write_func wfnc, |
86 char* buf, size_t bufsize, size_t n); |
91 char* buf, size_t bufsize, size_t n); |
87 |
92 |
88 /** |
93 /** |
89 * Shorthand for ucx_stream_copy using the default copy buffer. |
94 * Shorthand for an unbounded ucx_stream_bncopy call using a default buffer. |
90 * |
95 * |
91 * @param src the source stream |
96 * @param src the source stream |
92 * @param dest the destination stream |
97 * @param dest the destination stream |
93 * @param rfnc the read function |
98 * @param rfnc the read function |
94 * @param wfnc the write function |
99 * @param wfnc the write function |
95 * @return total number of bytes copied |
100 * @return total number of bytes copied |
96 */ |
101 * |
97 #define ucx_stream_hcopy(src,dest,rfnc,wfnc) ucx_stream_copy(\ |
102 * @see #UCX_STREAM_COPY_BUFSIZE |
98 src, dest, (read_func)rfnc, (write_func)wfnc, NULL, 0x100, SIZE_MAX) |
103 */ |
99 |
104 #define ucx_stream_copy(src,dest,rfnc,wfnc) ucx_stream_bncopy(\ |
100 /** |
105 src, dest, (read_func)rfnc, (write_func)wfnc, \ |
101 * Shorthand for ucx_stream_copy using the default copy buffer and a copy limit. |
106 NULL, UCX_STREAM_COPY_BUFSIZE, (size_t)-1) |
|
107 |
|
108 /** |
|
109 * Shorthand for ucx_stream_bncopy using a default copy buffer. |
102 * |
110 * |
103 * @param src the source stream |
111 * @param src the source stream |
104 * @param dest the destination stream |
112 * @param dest the destination stream |
105 * @param rfnc the read function |
113 * @param rfnc the read function |
106 * @param wfnc the write function |
114 * @param wfnc the write function |
107 * @param n maximum number of bytes that shall be copied |
115 * @param n maximum number of bytes that shall be copied |
108 * @return total number of bytes copied |
116 * @return total number of bytes copied |
109 */ |
117 */ |
110 #define ucx_stream_ncopy(src,dest,rfnc,wfnc, n) ucx_stream_copy(\ |
118 #define ucx_stream_ncopy(src,dest,rfnc,wfnc, n) ucx_stream_bncopy(\ |
111 src, dest, (read_func)rfnc, (write_func)wfnc, NULL, 0x100, n) |
119 src, dest, (read_func)rfnc, (write_func)wfnc, \ |
|
120 NULL, UCX_STREAM_COPY_BUFSIZE, n) |
|
121 |
|
122 /** |
|
123 * Shorthand for an unbounded ucx_stream_bncopy call using the specified buffer. |
|
124 * |
|
125 * @param src the source stream |
|
126 * @param dest the destination stream |
|
127 * @param rfnc the read function |
|
128 * @param wfnc the write function |
|
129 * @param buf a pointer to the copy buffer or <code>NULL</code> if a buffer |
|
130 * shall be implicitly created on the heap |
|
131 * @param bufsize the size of the copy buffer - if <code>NULL</code> was |
|
132 * provided for <code>buf</code>, this is the size of the buffer that shall be |
|
133 * implicitly created |
|
134 * @return total number of bytes copied |
|
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) |
112 |
139 |
113 /** |
140 /** |
114 * Wraps the strcmp function. |
141 * Wraps the strcmp function. |
115 * @param s1 string one |
142 * @param s1 string one |
116 * @param s2 string two |
143 * @param s2 string two |
232 * @return a sstr_t containing the formatted string |
255 * @return a sstr_t containing the formatted string |
233 * @see ucx_asprintf() |
256 * @see ucx_asprintf() |
234 */ |
257 */ |
235 sstr_t ucx_vasprintf(UcxAllocator *allocator, const char *fmt, va_list ap); |
258 sstr_t ucx_vasprintf(UcxAllocator *allocator, const char *fmt, va_list ap); |
236 |
259 |
237 /** |
260 /** Shortcut for ucx_asprintf() with default allocator. */ |
238 * A <code>printf()</code> like function which writes the output to an |
261 #define ucx_sprintf(...) \ |
|
262 ucx_asprintf(ucx_default_allocator(), __VA_ARGS__) |
|
263 |
|
264 /** |
|
265 * A <code>printf()</code> like function which writes the output to a |
239 * UcxBuffer. |
266 * UcxBuffer. |
240 * |
267 * |
241 * @param buffer the buffer the data is written to |
268 * @param buffer the buffer the data is written to |
242 * @param ... format string and additional arguments |
269 * @param ... format string and additional arguments |
243 * @return the total number of bytes written |
270 * @return the total number of bytes written |