79 |
void |
void |
80 |
buf_reverse (char *p, size_t nbytes) |
buf_reverse (char *p, size_t nbytes) |
81 |
{ |
{ |
82 |
unsigned char *h = p, *t = &h[nbytes - 1]; |
char *h = p, *t = &h[nbytes - 1]; |
83 |
unsigned char temp; |
char temp; |
84 |
|
|
85 |
nbytes /= 2; |
nbytes /= 2; |
86 |
while (nbytes--) |
while (nbytes--) |
249 |
} |
} |
250 |
} |
} |
251 |
|
|
252 |
|
/* Copies buffer SRC, of SRC_LEN bytes, |
253 |
|
to DST, which is in a buffer DST_SIZE bytes long. |
254 |
|
Truncates DST to DST_SIZE - 1 characters, if necessary. */ |
255 |
|
void |
256 |
|
str_copy_buf_trunc (char *dst, size_t dst_size, |
257 |
|
const char *src, size_t src_size) |
258 |
|
{ |
259 |
|
size_t dst_len; |
260 |
|
assert (dst_size > 0); |
261 |
|
|
262 |
|
dst_len = src_size < dst_size ? src_size : dst_size - 1; |
263 |
|
memcpy (dst, src, dst_len); |
264 |
|
dst[dst_len] = '\0'; |
265 |
|
} |
266 |
|
|
267 |
/* Converts each character in S to uppercase. */ |
/* Converts each character in S to uppercase. */ |
268 |
void |
void |
269 |
str_uppercase (char *s) |
str_uppercase (char *s) |