summaryrefslogtreecommitdiff
path: root/src/libstddjb
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstddjb')
-rw-r--r--src/libstddjb/strerr_diel.c24
-rw-r--r--src/libstddjb/strerr_dielsys.c23
-rw-r--r--src/libstddjb/strerr_diev.c13
-rw-r--r--src/libstddjb/strerr_dievsys.c13
-rw-r--r--src/libstddjb/strerr_warnl.c22
-rw-r--r--src/libstddjb/strerr_warnlsys.c22
-rw-r--r--src/libstddjb/strerr_warnv.c17
-rw-r--r--src/libstddjb/strerr_warnvsys.c20
8 files changed, 154 insertions, 0 deletions
diff --git a/src/libstddjb/strerr_diel.c b/src/libstddjb/strerr_diel.c
new file mode 100644
index 0000000..d142402
--- /dev/null
+++ b/src/libstddjb/strerr_diel.c
@@ -0,0 +1,24 @@
+/* ISC license. */
+
+/* MT-unsafe */
+
+#include <stdarg.h>
+#include <unistd.h>
+
+#include <skalibs/strerr.h>
+
+void strerr_diel (int e, unsigned int n, ...)
+{
+ if (n)
+ {
+ va_list ap ;
+ char const *v[n] ;
+ va_start(ap, n) ;
+ va_arg(ap, unsigned int) ;
+ for (unsigned int i = 0 ; i < n ; i++)
+ v[i++] = va_arg(ap, char const *) ;
+ va_end(ap) ;
+ strerr_warnv(v, n) ;
+ }
+ _exit(e) ;
+}
diff --git a/src/libstddjb/strerr_dielsys.c b/src/libstddjb/strerr_dielsys.c
new file mode 100644
index 0000000..5c0e334
--- /dev/null
+++ b/src/libstddjb/strerr_dielsys.c
@@ -0,0 +1,23 @@
+/* ISC license. */
+
+/* MT-unsafe */
+
+#include <stdarg.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <skalibs/strerr.h>
+
+void strerr_dielsys (int e, unsigned int n, ...)
+{
+ va_list ap ;
+ char const *v[n+1] ;
+ va_start(ap, n) ;
+ va_arg(ap, unsigned int) ;
+ for (unsigned int i = 0 ; i < n ; i++)
+ v[i++] = va_arg(ap, char const *) ;
+ va_end(ap) ;
+ v[n] = strerror(errno) ;
+ strerr_diev(e, v, n+1) ;
+}
diff --git a/src/libstddjb/strerr_diev.c b/src/libstddjb/strerr_diev.c
new file mode 100644
index 0000000..bf1e8fc
--- /dev/null
+++ b/src/libstddjb/strerr_diev.c
@@ -0,0 +1,13 @@
+/* ISC license. */
+
+/* MT-unsafe */
+
+#include <unistd.h>
+
+#include <skalibs/strerr.h>
+
+void strerr_diev (int e, char const *const *v, unsigned int n)
+{
+ strerr_warnv(v, n) ;
+ _exit(e) ;
+}
diff --git a/src/libstddjb/strerr_dievsys.c b/src/libstddjb/strerr_dievsys.c
new file mode 100644
index 0000000..10437f9
--- /dev/null
+++ b/src/libstddjb/strerr_dievsys.c
@@ -0,0 +1,13 @@
+/* ISC license. */
+
+/* MT-unsafe */
+
+#include <unistd.h>
+
+#include <skalibs/strerr.h>
+
+void strerr_dievsys (int e, char const *const *v, unsigned int n)
+{
+ strerr_warnvsys(v, n) ;
+ _exit(e) ;
+}
diff --git a/src/libstddjb/strerr_warnl.c b/src/libstddjb/strerr_warnl.c
new file mode 100644
index 0000000..17c370d
--- /dev/null
+++ b/src/libstddjb/strerr_warnl.c
@@ -0,0 +1,22 @@
+/* ISC license. */
+
+/* MT-unsafe */
+
+#include <stdarg.h>
+
+#include <skalibs/strerr.h>
+
+void strerr_warnl (unsigned int n, ...)
+{
+ if (n)
+ {
+ va_list ap ;
+ char const *v[n] ;
+ va_start(ap, n) ;
+ va_arg(ap, unsigned int) ;
+ for (unsigned int i = 0 ; i < n ; i++)
+ v[i++] = va_arg(ap, char const *) ;
+ va_end(ap) ;
+ strerr_warnv(v, n) ;
+ }
+}
diff --git a/src/libstddjb/strerr_warnlsys.c b/src/libstddjb/strerr_warnlsys.c
new file mode 100644
index 0000000..fbd7a6b
--- /dev/null
+++ b/src/libstddjb/strerr_warnlsys.c
@@ -0,0 +1,22 @@
+/* ISC license. */
+
+/* MT-unsafe */
+
+#include <stdarg.h>
+#include <string.h>
+#include <errno.h>
+
+#include <skalibs/strerr.h>
+
+void strerr_warnlsys (unsigned int n, ...)
+{
+ va_list ap ;
+ char const *v[n+1] ;
+ va_start(ap, n) ;
+ va_arg(ap, unsigned int) ;
+ for (unsigned int i = 0 ; i < n ; i++)
+ v[i++] = va_arg(ap, char const *) ;
+ va_end(ap) ;
+ v[n] = strerror(errno) ;
+ strerr_warnv(v, n+1) ;
+}
diff --git a/src/libstddjb/strerr_warnv.c b/src/libstddjb/strerr_warnv.c
new file mode 100644
index 0000000..f59cfe9
--- /dev/null
+++ b/src/libstddjb/strerr_warnv.c
@@ -0,0 +1,17 @@
+/* ISC license. */
+
+/* MT-unsafe */
+
+#include <errno.h>
+
+#include <skalibs/buffer.h>
+#include <skalibs/strerr.h>
+
+void strerr_warnv (char const *const *v, unsigned int n)
+{
+ int e = errno ;
+ for (unsigned int i = 0 ; i < n ; i++)
+ if (v[i]) buffer_puts(buffer_2, v[i]) ;
+ buffer_putflush(buffer_2, "\n", 1) ;
+ errno = e ;
+}
diff --git a/src/libstddjb/strerr_warnvsys.c b/src/libstddjb/strerr_warnvsys.c
new file mode 100644
index 0000000..fcab1b8
--- /dev/null
+++ b/src/libstddjb/strerr_warnvsys.c
@@ -0,0 +1,20 @@
+/* ISC license. */
+
+/* MT-unsafe */
+
+#include <string.h>
+#include <errno.h>
+
+#include <skalibs/buffer.h>
+#include <skalibs/strerr.h>
+
+void strerr_warnvsys (char const *const *v, unsigned int n)
+{
+ int e = errno ;
+ for (unsigned int i = 0 ; i < n ; i++)
+ if (v[i]) buffer_puts(buffer_2, v[i]) ;
+ buffer_put(buffer_2, ": ", 2) ;
+ buffer_puts(buffer_2, strerror(e)) ;
+ buffer_putflush(buffer_2, "\n", 1) ;
+ errno = e ;
+}