From d670dea78e1cad0d3b01db31f0c2a1a7d6960194 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 15 Nov 2015 22:25:03 +0100 Subject: implement humanmode 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 | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/slibc-human.h b/include/slibc-human.h index ee55568..4c98902 100644 --- a/include/slibc-human.h +++ b/include/slibc-human.h @@ -33,7 +33,10 @@ -enum machinemode_mode +/** + * Representation settings for file permissions. + */ +enum humanmode_mode { /** * Return in the format where 0750 @@ -182,7 +185,21 @@ enum unescape_mode -char* humanmode(char* restrict buffer, mode_t perm, enum machinemode_mode mode); +/** + * Convert file permission from machine representation to human representation. + * + * @param buffer Sufficiently large buffer for the output, or `NULL`. + * 18 characters is always sufficient, regardless of `mode`. + * @param perm Machine representation of the permissions, will be masked with 07777. + * @param mode Representation style, 0 for default. + * @return Human representation of the file permissions, `NULL` on error. + * On success, the caller is responsible for deallocating the + * returned pointer, if and only if `buffer` is `NULL`. + * + * @throws EINVAL If `mode` is invalid. + * @throws ENOMEM The process cannot allocate more memory. + */ +char* humanmode(char* restrict, mode_t, enum humanmode_mode); int machinemode(mode_t* restrict mode, mode_t* restrict mask, const char* restrict str); -- cgit v1.2.3-70-g09d2