summaryrefslogtreecommitdiff
path: root/src/string/strerror_s.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2020-08-16 15:55:19 -0400
committerJakob Kaivo <jkk@ung.org>2020-08-16 15:55:19 -0400
commite223e635cc53fa11e473cdbc864eb69a3da5f290 (patch)
treed481ca6fb0b7f4184f3ec259a6f9c37d76e56a26 /src/string/strerror_s.c
parent700fbd205a1a428677876d322606b9a354221892 (diff)
add skeleton of symbols from C11 LIB_EXT1
Diffstat (limited to 'src/string/strerror_s.c')
-rw-r--r--src/string/strerror_s.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/string/strerror_s.c b/src/string/strerror_s.c
new file mode 100644
index 00000000..293bb81d
--- /dev/null
+++ b/src/string/strerror_s.c
@@ -0,0 +1,35 @@
+#include "string.h"
+#include "errno.h"
+#include "__strerror.h"
+
+/** convert error number to string **/
+errno_t strerror_s(char *s, rsize_t maxsize, errno_t errnum)
+{
+ __C_EXT(1, 201112L);
+ if (errnum > __nstrerror || __strerror[errnum] == NULL) {
+ if (snprintf(s, maxsize, "Uknown error [%d]", errnum) < maxsize) {
+ return 0;
+ }
+ return 1;
+ }
+
+ strncpy(s, __strerror[errnum], maxsize);
+ return errnum;
+}
+
+/***
+The fn(strerror_s) converts the error number arg(errnum) to an error message
+string. The string returned should not be modified, and may be overwritten by
+subsequent calls.
+***/
+
+/* UNSPECIFIED: - */
+/* UNDEFINED: - */
+/* IMPLEMENTATION: - */
+/* LOCALE: LC_MESSAGES */
+
+/* RETURN: a pointer to the error message string */
+
+/*
+CEXT1(201112)
+*/