diff options
| author | Jakob Kaivo <jkk@ung.org> | 2019-02-09 16:48:54 -0500 |
|---|---|---|
| committer | Jakob Kaivo <jkk@ung.org> | 2019-02-09 16:48:54 -0500 |
| commit | decde27a8de0953d402df2db3716543b213b9755 (patch) | |
| tree | bcbd13522737dd099b0bb9ee0528d94e726def52 /src | |
| parent | 4e875ebbf1febc03cee6d80f3dd23cd01112f95c (diff) | |
add POSIX.2 identifiers
Diffstat (limited to 'src')
30 files changed, 276 insertions, 0 deletions
diff --git a/src/unistd/_CS_PATH.c b/src/unistd/_CS_PATH.c new file mode 100644 index 00000000..53187da7 --- /dev/null +++ b/src/unistd/_CS_PATH.c @@ -0,0 +1,10 @@ +#include <unistd.h> +#define _CS_PATH 0 + +/* +UNG_VALUE(/bin:/usr/bin) +*/ +/* +POSIX(2) +*/ + diff --git a/src/unistd/_POSIX2_CHAR_TERM.c b/src/unistd/_POSIX2_CHAR_TERM.c new file mode 100644 index 00000000..9a7e889b --- /dev/null +++ b/src/unistd/_POSIX2_CHAR_TERM.c @@ -0,0 +1,6 @@ +#include <unistd.h> +#define _POSIX2_CHAR_TERM /* TODO */ +/* +POSIX(2) +*/ + diff --git a/src/unistd/_POSIX2_C_DEV.c b/src/unistd/_POSIX2_C_DEV.c new file mode 100644 index 00000000..89578936 --- /dev/null +++ b/src/unistd/_POSIX2_C_DEV.c @@ -0,0 +1,6 @@ +#include <unistd.h> +#define _POSIX2_C_DEV /* TODO */ +/* +POSIX(2) +*/ + diff --git a/src/unistd/_POSIX2_C_VERSION.c b/src/unistd/_POSIX2_C_VERSION.c new file mode 100644 index 00000000..44c9a0ba --- /dev/null +++ b/src/unistd/_POSIX2_C_VERSION.c @@ -0,0 +1,20 @@ +#include <unistd.h> + +#if (defined _POSIX_C_SOURCE) +#if _POSIX_C_SOURCE >= 200809L +#define _POSIX2_C_VERSION (200809L) +#elif _POSIX_C_SOURCE >= 200112L +#define _POSIX2_C_VERSION (200112L) +#elif _POSIX_C_SOURCE >= 199506L +#define _POSIX2_C_VERSION (199506L) +#elif _POSIX_C_SOURCE >= 2 +#define _POSIX2_C_VERSION (199209L) +#else +#undef _POSIX2_C_VERSION +#endif +#endif + +/* +POSIX(2) +*/ + diff --git a/src/unistd/_POSIX2_FORT_DEV.c b/src/unistd/_POSIX2_FORT_DEV.c new file mode 100644 index 00000000..dd22e4bf --- /dev/null +++ b/src/unistd/_POSIX2_FORT_DEV.c @@ -0,0 +1,6 @@ +#include <unistd.h> +#define _POSIX2_FORT_DEV /* TODO */ +/* +POSIX(2) +*/ + diff --git a/src/unistd/_POSIX2_FORT_RUN.c b/src/unistd/_POSIX2_FORT_RUN.c new file mode 100644 index 00000000..54d21036 --- /dev/null +++ b/src/unistd/_POSIX2_FORT_RUN.c @@ -0,0 +1,6 @@ +#include <unistd.h> +#define _POSIX2_FORT_RUN /* TODO */ +/* +POSIX(2) +*/ + diff --git a/src/unistd/_POSIX2_SW_DEV.c b/src/unistd/_POSIX2_SW_DEV.c new file mode 100644 index 00000000..ddd0f01b --- /dev/null +++ b/src/unistd/_POSIX2_SW_DEV.c @@ -0,0 +1,6 @@ +#include <unistd.h> +#define _POSIX2_SW_DEV +/* +POSIX(2) +*/ + diff --git a/src/unistd/_POSIX2_UPE.c b/src/unistd/_POSIX2_UPE.c new file mode 100644 index 00000000..a0c6299a --- /dev/null +++ b/src/unistd/_POSIX2_UPE.c @@ -0,0 +1,6 @@ +#include <unistd.h> +#define _POSIX2_UPE /* TODO */ +/* +POSIX(2) +*/ + diff --git a/src/unistd/_SC_2_CHAR_TERM.c b/src/unistd/_SC_2_CHAR_TERM.c new file mode 100644 index 00000000..fa6448ca --- /dev/null +++ b/src/unistd/_SC_2_CHAR_TERM.c @@ -0,0 +1,6 @@ +#includee <unistd.h> +#define _SC_2_CHAR_TERM 2 +/* +POSIX(2) +*/ + diff --git a/src/unistd/_SC_2_C_DEV.c b/src/unistd/_SC_2_C_DEV.c new file mode 100644 index 00000000..2b295181 --- /dev/null +++ b/src/unistd/_SC_2_C_DEV.c @@ -0,0 +1,6 @@ +#include <unistd.h> +#define _SC_2_C_DEV 1 +/* +POSIX(2) +*/ + diff --git a/src/unistd/_SC_2_FORT_DEV.c b/src/unistd/_SC_2_FORT_DEV.c new file mode 100644 index 00000000..796a3a55 --- /dev/null +++ b/src/unistd/_SC_2_FORT_DEV.c @@ -0,0 +1,6 @@ +#include <unistd.h> +#define _SC_2_FORT_DEV 3 +/* +POSIX(2) +*/ + diff --git a/src/unistd/_SC_2_FORT_RUN.c b/src/unistd/_SC_2_FORT_RUN.c new file mode 100644 index 00000000..6ed244f2 --- /dev/null +++ b/src/unistd/_SC_2_FORT_RUN.c @@ -0,0 +1,6 @@ +#include <unistd.h> +#define _SC_2_FORT_RUN 4 +/* +POSIX(2) +*/ + diff --git a/src/unistd/_SC_2_LOCALEDEF.c b/src/unistd/_SC_2_LOCALEDEF.c new file mode 100644 index 00000000..5c90849a --- /dev/null +++ b/src/unistd/_SC_2_LOCALEDEF.c @@ -0,0 +1,6 @@ +#include <unistd.h> +#define _SC_2_LOCALEDEF 5 +/* +POSIX(2) +*/ + diff --git a/src/unistd/_SC_2_SW_DEV.c b/src/unistd/_SC_2_SW_DEV.c new file mode 100644 index 00000000..1fb22735 --- /dev/null +++ b/src/unistd/_SC_2_SW_DEV.c @@ -0,0 +1,6 @@ +#include <unistd.h> +#define _SC_2_SW_DEV 12 +/* +POSIX(2) +*/ + diff --git a/src/unistd/_SC_2_UPE.c b/src/unistd/_SC_2_UPE.c new file mode 100644 index 00000000..325f5f6a --- /dev/null +++ b/src/unistd/_SC_2_UPE.c @@ -0,0 +1,6 @@ +#include <unistd.h> +#define _SC_2_UPE 13 +/* +POSIX(2) +*/ + diff --git a/src/unistd/_SC_2_VERSION.c b/src/unistd/_SC_2_VERSION.c new file mode 100644 index 00000000..9a23e011 --- /dev/null +++ b/src/unistd/_SC_2_VERSION.c @@ -0,0 +1,6 @@ +#include <unistd.h> +#define _SC_2_VERSION 14 +/* +POSIX(2) +*/ + diff --git a/src/unistd/_SC_BC_BASE_MAX.c b/src/unistd/_SC_BC_BASE_MAX.c new file mode 100644 index 00000000..a4cc9151 --- /dev/null +++ b/src/unistd/_SC_BC_BASE_MAX.c @@ -0,0 +1,6 @@ +#include <unistd.h> +#define _SC_BC_BASE_MAX 23 +/* +POSIX(2) +*/ + diff --git a/src/unistd/_SC_BC_DIM_MAX.c b/src/unistd/_SC_BC_DIM_MAX.c new file mode 100644 index 00000000..57b3b670 --- /dev/null +++ b/src/unistd/_SC_BC_DIM_MAX.c @@ -0,0 +1,6 @@ +#include <unistd.h> +#define _SC_BC_DIM_MAX 24 +/* +POSIX(2) +*/ + diff --git a/src/unistd/_SC_BC_SCALE_MAX.c b/src/unistd/_SC_BC_SCALE_MAX.c new file mode 100644 index 00000000..5daab23f --- /dev/null +++ b/src/unistd/_SC_BC_SCALE_MAX.c @@ -0,0 +1,6 @@ +#include <unistd.h> +#define _SC_BC_SCALE_MAX 25 +/* +POSIX(2) +*/ + diff --git a/src/unistd/_SC_BC_STRING_MAX.c b/src/unistd/_SC_BC_STRING_MAX.c new file mode 100644 index 00000000..5f20b4f7 --- /dev/null +++ b/src/unistd/_SC_BC_STRING_MAX.c @@ -0,0 +1,6 @@ +#include <unistd.h> +#define _SC_BC_STRING_MAX 26 +/* +POSIX(2) +*/ + diff --git a/src/unistd/_SC_COLL_WEIGHTS_MAX.c b/src/unistd/_SC_COLL_WEIGHTS_MAX.c new file mode 100644 index 00000000..dbe4b209 --- /dev/null +++ b/src/unistd/_SC_COLL_WEIGHTS_MAX.c @@ -0,0 +1,6 @@ +#include <unistd.h> +#define _SC_COLL_WEIGHTS_MAX 30 +/* +POSIX(2) +*/ + diff --git a/src/unistd/_SC_EXPR_NEST_MAX.c b/src/unistd/_SC_EXPR_NEST_MAX.c new file mode 100644 index 00000000..7a6a24e5 --- /dev/null +++ b/src/unistd/_SC_EXPR_NEST_MAX.c @@ -0,0 +1,6 @@ +#include <unistd.h> +#define _SC_EXPR_NEST_MAX 33 +/* +POSIX(2) +*/ + diff --git a/src/unistd/_SC_LINE_MAX.c b/src/unistd/_SC_LINE_MAX.c new file mode 100644 index 00000000..7fc4c837 --- /dev/null +++ b/src/unistd/_SC_LINE_MAX.c @@ -0,0 +1,6 @@ +#include <unistd.h> +#define _SC_LINE_MAX 41 +/* +POSIX(2) +*/ + diff --git a/src/unistd/_SC_RE_DUP_MAX.c b/src/unistd/_SC_RE_DUP_MAX.c new file mode 100644 index 00000000..4eefc22f --- /dev/null +++ b/src/unistd/_SC_RE_DUP_MAX.c @@ -0,0 +1,6 @@ +#include <unistd.h> +#define _SC_RE_DUP_MAX 58 +/* +POSIX(2) +*/ + 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) +*/ diff --git a/src/unistd/getopt.c b/src/unistd/getopt.c new file mode 100644 index 00000000..29fe5590 --- /dev/null +++ b/src/unistd/getopt.c @@ -0,0 +1,56 @@ +#include "string.h" +#include "stdio.h" +#include <unistd.h> + +int getopt(int argc, char * const argv[], const char *optstring) +{ + static int optchar = 0; + char *cursor = NULL; + + if (optind = 0 || argv[optind][optchar] == '\0') { + optind++; + optchar = 0; + } + + if (!strcmp(argv[optind], "--")) { + optind++; + return -1; + } + + if (optchar == 0 && argv[optind][optchar] != '-') { + return -1; + } + + optchar++; + + printf("Checking %c\n", argv[optind][optchar]); + + cursor = strchr(optstring, argv[optind][optchar]); + if (cursor) { + if (cursor[1] == ':') { + /* An option-argument is required */ + /* if (no arg) { */ + /* optopt = *cursor; */ + /* if (opterr) { */ + /* fprintf(stderr, "%s: Missing argument to -%c\n", argv[0], *cursor); */ + /* } */ + /* return optstring[0] == ':' ? ':' : '?'; */ + /* } */ + /* optarg = argv[++optind]; */ + /* optchar = 0; */ + /* optind++; */ + } + return *cursor; + } + + optopt = argv[optind][optchar]; + if (opterr) { + fprintf(stderr, "%s: Invalid option -%c\n", *cursor); + } + return '?'; +} + +/* +POSIX(2) +*/ + diff --git a/src/unistd/optarg.c b/src/unistd/optarg.c new file mode 100644 index 00000000..be7407c1 --- /dev/null +++ b/src/unistd/optarg.c @@ -0,0 +1,6 @@ +#include <unistd.h> +char * optarg; +/* +POSIX(2) +*/ + diff --git a/src/unistd/opterr.c b/src/unistd/opterr.c new file mode 100644 index 00000000..f5e831e4 --- /dev/null +++ b/src/unistd/opterr.c @@ -0,0 +1,6 @@ +#include <unistd.h> +int opterr; +/* +POSIX(2) +*/ + diff --git a/src/unistd/optind.c b/src/unistd/optind.c new file mode 100644 index 00000000..8cd6e14b --- /dev/null +++ b/src/unistd/optind.c @@ -0,0 +1,6 @@ +#include <unistd.h> +int optind; +/* +POSIX(2) +*/ + diff --git a/src/unistd/optopt.c b/src/unistd/optopt.c new file mode 100644 index 00000000..673316d5 --- /dev/null +++ b/src/unistd/optopt.c @@ -0,0 +1,6 @@ +#include <unistd.h> +int optopt = 0; +/* +POSIX(2) +*/ + |
