summaryrefslogtreecommitdiff
path: root/src/unistd/confstr.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-02-09 16:48:54 -0500
committerJakob Kaivo <jkk@ung.org>2019-02-09 16:48:54 -0500
commitdecde27a8de0953d402df2db3716543b213b9755 (patch)
treebcbd13522737dd099b0bb9ee0528d94e726def52 /src/unistd/confstr.c
parent4e875ebbf1febc03cee6d80f3dd23cd01112f95c (diff)
add POSIX.2 identifiers
Diffstat (limited to 'src/unistd/confstr.c')
-rw-r--r--src/unistd/confstr.c34
1 files changed, 34 insertions, 0 deletions
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 <unistd.h>
+#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)
+*/