From decde27a8de0953d402df2db3716543b213b9755 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Sat, 9 Feb 2019 16:48:54 -0500 Subject: add POSIX.2 identifiers --- src/unistd/confstr.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/unistd/confstr.c (limited to 'src/unistd/confstr.c') diff --git a/src/unistd/confstr.c b/src/unistd/confstr.c new file mode 100644 index 00000000..a0f57b30 --- /dev/null +++ b/src/unistd/confstr.c @@ -0,0 +1,34 @@ +#include +#include "errno.h" +#include "string.h" + +size_t confstr(int name, char *buf, size_t len) +{ + char *value = NULL; + + if (len > 0) { + __ASSERT_NONNULL(buf); + } + + switch (name) { + #include "_confstr.h" + default: + value = NULL; + break; + } + + if (value == NULL) { + errno = EINVAL; + return 0; + } + + if (len > 0) { + strncpy(buf, value, len); + } + + return strlen(value); +} + +/* +POSIX(2) +*/ -- cgit v1.2.1