From 945661b090eb2f4b08a63aec85411b6c8a878afb Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 14 Nov 2015 04:27:28 +0100 Subject: change prototypes for humanmode and machinemode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- include/slibc-human.h | 114 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 68 insertions(+), 46 deletions(-) (limited to 'include') diff --git a/include/slibc-human.h b/include/slibc-human.h index 25e5162..ee55568 100644 --- a/include/slibc-human.h +++ b/include/slibc-human.h @@ -33,56 +33,25 @@ -/** - * Ways to handled unrecognised escapes, - * and other configurations. - */ -enum unescape_mode +enum machinemode_mode { /** - * For any unrecognised character '#', - * '\#' results in an EINVAL-error. + * Return in the format where 0750 + * resolves to 'rwxr-x---'. * - * Cannot be used together with - * `UNESCAPE_VERBATIM` or `UNESCAPE_IGNORE`. + * If used in combination with `MACHINEMODE_MASK`, + * 0750 resolves to 'u=rwx,g=r-x,o=---'. */ - UNESCAPE_EINVAL = 1, + MACHINEMODE_STAT = 1, /** - * For any unrecognised character '#', - * '\#' results in '#'. + * Return in the format where 0750 + * resolves to 'u=rwx,g=rx,o='. * - * Cannot be used together with - * `UNESCAPE_EINVAL` or `UNESCAPE_IGNORE`. - */ - UNESCAPE_VERBATIM = 2, - - /** - * For any unrecognised character '#', - * '\#' results in '\#'. - * - * Cannot be used together with - * `UNESCAPE_EINVAL` or `UNESCAPE_VERBATIM`. + * If used in combination with `MACHINEMODE_STAT`, + * 0750 resolves to 'u=rwx,g=r-x,o=---'. */ - UNESCAPE_IGNORE = 4, - - - /** - * '\&' resolves to the byte 255 (0xFF). - * - * If not used, '\&' is handled as an - * unsupported escape. - */ - UNESCAPE_AMPERSAND = 8, - - /** - * '\0' resolves to the byte sequence - * 192 128 (0xC0 0x80). - * - * If not used, '\0' resolves to a - * 0 byte (termination). - */ - UNESCAPE_MOD_UTF8 = 16, + MACHINEMODE_MASK = 2, }; @@ -134,7 +103,7 @@ enum humansize_mode * `detail` < 0 is allowed, */ HUMANSIZE_ROUND = 32, - } + }; enum machinesize_mode @@ -156,13 +125,66 @@ enum machinesize_mode * included, otherwise 1024-base is used. */ MACHINESIZE_IEC = 2, - } + }; + + +/** + * Ways to handled unrecognised escapes, + * and other configurations. + */ +enum unescape_mode + { + /** + * For any unrecognised character '#', + * '\#' results in an EINVAL-error. + * + * Cannot be used together with + * `UNESCAPE_VERBATIM` or `UNESCAPE_IGNORE`. + */ + UNESCAPE_EINVAL = 1, + + /** + * For any unrecognised character '#', + * '\#' results in '#'. + * + * Cannot be used together with + * `UNESCAPE_EINVAL` or `UNESCAPE_IGNORE`. + */ + UNESCAPE_VERBATIM = 2, + + /** + * For any unrecognised character '#', + * '\#' results in '\#'. + * + * Cannot be used together with + * `UNESCAPE_EINVAL` or `UNESCAPE_VERBATIM`. + */ + UNESCAPE_IGNORE = 4, + + + /** + * '\&' resolves to the byte 255 (0xFF). + * + * If not used, '\&' is handled as an + * unsupported escape. + */ + UNESCAPE_AMPERSAND = 8, + + /** + * '\0' resolves to the byte sequence + * 192 128 (0xC0 0x80). + * + * If not used, '\0' resolves to a + * 0 byte (termination). + */ + UNESCAPE_MOD_UTF8 = 16, + }; -char* humanmode(char* restrict buffer, mode_t mode); +char* humanmode(char* restrict buffer, mode_t perm, enum machinemode_mode mode); -mode_t machinemode(const char* restrict str, mode_t mode, mode_t mask); +int machinemode(mode_t* restrict mode, mode_t* restrict mask, const char* restrict str); char* humansize(char* restrict buffer, size_t size, enum humansize_mode mode, int detail); -- cgit v1.2.3-70-g09d2