diff options
author | Jason King <jason.king@joyent.com> | 2020-01-09 10:59:44 -0600 |
---|---|---|
committer | Jason King <jason.king@joyent.com> | 2020-01-14 09:36:41 -0600 |
commit | 356ce177517a15babb8fd801d490f239298643b7 (patch) | |
tree | 5832178e3712a2bc6981458d9c1e5f13345b04f7 /usr/src/lib/libcustr/common/libcustr.h | |
parent | 9554f7e18d034b915acbd51b3c4e3261c88e166d (diff) | |
download | illumos-joyent-356ce177517a15babb8fd801d490f239298643b7.tar.gz |
12178 Allow bytes to be removed from a custr
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Andy Fiddaman <andy@omniosce.org>
Approved by: Gordon Ross <gwr@nexenta.com>
Diffstat (limited to 'usr/src/lib/libcustr/common/libcustr.h')
-rw-r--r-- | usr/src/lib/libcustr/common/libcustr.h | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/usr/src/lib/libcustr/common/libcustr.h b/usr/src/lib/libcustr/common/libcustr.h index 8fe5fee1b7..f8f15db07b 100644 --- a/usr/src/lib/libcustr/common/libcustr.h +++ b/usr/src/lib/libcustr/common/libcustr.h @@ -10,7 +10,7 @@ */ /* - * Copyright 2019, Joyent, Inc. + * Copyright 2019 Joyent, Inc. */ #ifndef _LIBCUSTR_H @@ -142,6 +142,52 @@ size_t custr_len(custr_t *); void custr_reset(custr_t *); /* + * custr_remove(cus, idx, len) + * + * Remove len bytes from cus, starting at idx. + * + * Returns 0 on success or -1 on failure. On failure, errno will be set to: + * EINVAL Either the idx or len parameter is invalid + * + */ +int custr_remove(custr_t *, size_t, size_t); + +/* + * custr_rremove(cus, idx, len) + * + * Remove len bytes from cus, starting at idx relative to the end of cus. + * That is, 0 = last byte of cus, 1 = second to last byte of cus, ...). + * The direction of removal is always towards the end of the string. I.e. + * 'custr_rremove(cus, 1, 2)' removes the last two bytes of cus. + * + * Returns 0 on success or -1 on failure. On failure, errno will be set to: + * EINVAL Either the idx or len parameter is invalid + * + */ +int custr_rremove(custr_t *, size_t, size_t); + +/* + * custr_trunc(cus, idx) + * + * Truncate cus starting at idx. + * + * Returns 0 on success or -1 on failure. On failure, errno is set to: + * EINVAL The idx value was invalid. + */ +int custr_trunc(custr_t *, size_t); + +/* + * custr_rtrunc(cus, idx) + * + * Truncate cus starting at idx relative to the end of cus (similar to how + * the idx paramter is treated with custr_rremove()). + * + * Returns 0 on success or -1 on failure. On failure, errno is set to: + * EINVAL The idx value was invalid. + */ +int custr_rtrunc(custr_t *, size_t); + +/* * Retrieve a const pointer to a NUL-terminated string version of the contents * of the dynamic string. Storage for this string should not be freed, and * the pointer will be invalidated by any mutations to the dynamic string. |