diff options
Diffstat (limited to 'src/unistd/confstr.c')
| -rw-r--r-- | src/unistd/confstr.c | 34 |
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) +*/ |
