summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--doc/index.html2
-rw-r--r--doc/upgrade.html7
-rw-r--r--package/deps.mak9
-rw-r--r--package/info2
-rw-r--r--src/include/skalibs/sig.h3
-rw-r--r--src/include/skalibs/unixconnection.h25
-rw-r--r--src/include/skalibs/unixonacid.h1
-rw-r--r--src/libstddjb/sig-internal.h15
-rw-r--r--src/libstddjb/sig_name.c11
-rw-r--r--src/libstddjb/sig_number.c12
-rw-r--r--src/libstddjb/sig_table.c83
-rw-r--r--src/libstddjb/skasigaction.c5
-rw-r--r--src/libunixonacid/unixconnection_free.c11
-rw-r--r--src/libunixonacid/unixconnection_init.c10
-rw-r--r--src/libunixonacid/unixconnection_zero.c5
15 files changed, 195 insertions, 6 deletions
diff --git a/doc/index.html b/doc/index.html
index 1d206c1..f41a771 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -59,7 +59,7 @@ with a standard C development environment </li>
 <h3> Download </h3>
 
 <ul>
- <li> The current released version of skalibs is <a href="skalibs-2.2.0.0.tar.gz">2.2.0.0</a>. </li>
+ <li> The current released version of skalibs is <a href="skalibs-2.2.1.0.tar.gz">2.2.1.0</a>. </li>
  <li> Alternatively, you can checkout a copy of the skalibs git repository:
 <pre> git clone git://git.skarnet.org/skalibs </pre> </li>
 </ul>
diff --git a/doc/upgrade.html b/doc/upgrade.html
index bc9c0f4..6786c2d 100644
--- a/doc/upgrade.html
+++ b/doc/upgrade.html
@@ -17,6 +17,13 @@
 
 <h1> What has changed in skalibs </h1>
 
+<h2> in 2.2.1.0 </h2>
+
+<ul>
+ <li> unixconnection added. </li>
+ <li> sig_name and sig_number added. </li>
+</ul>
+
 <h2> in 2.2.0.0 </h2>
 
 <ul>
diff --git a/package/deps.mak b/package/deps.mak
index 932914f..c4962d6 100644
--- a/package/deps.mak
+++ b/package/deps.mak
@@ -55,8 +55,9 @@ src/include/skalibs/unirandomegd.h: src/include/skalibs/unirandom.h
 src/include/skalibs/unisurf.h: src/include/skalibs/unirandom.h
 src/include/skalibs/unix-timed.h: src/include/skalibs/bufalloc.h src/include/skalibs/buffer.h src/include/skalibs/functypes.h src/include/skalibs/stralloc.h src/include/skalibs/tai.h
 src/include/skalibs/unix-transactional.h: src/include/skalibs/stralloc.h src/include/skalibs/uint64.h
+src/include/skalibs/unixconnection.h: src/include/skalibs/unixmessage.h
 src/include/skalibs/unixmessage.h: src/include/skalibs/buffer.h src/include/skalibs/cbuffer.h src/include/skalibs/gccattributes.h src/include/skalibs/genalloc.h src/include/skalibs/siovec.h src/include/skalibs/stralloc.h src/include/skalibs/tai.h src/include/skalibs/uint16.h src/include/skalibs/uint32.h
-src/include/skalibs/unixonacid.h: src/include/skalibs/kolbak.h src/include/skalibs/skaclient.h src/include/skalibs/unix-timed.h src/include/skalibs/unix-transactional.h src/include/skalibs/unixmessage.h
+src/include/skalibs/unixonacid.h: src/include/skalibs/kolbak.h src/include/skalibs/skaclient.h src/include/skalibs/unix-timed.h src/include/skalibs/unix-transactional.h src/include/skalibs/unixconnection.h src/include/skalibs/unixmessage.h
 src/include/skalibs/webipc.h: src/include/skalibs/djbunix.h src/include/skalibs/tai.h
 src/libdatastruct/avlnode-internal.h: src/include/skalibs/avlnode.h
 src/librandom/random-internal.h: src/include/skalibs/gccattributes.h src/include/skalibs/rrandom.h src/include/skalibs/surf.h src/include/skalibs/unirandom.h
@@ -475,11 +476,14 @@ src/libstddjb/sig_block.o src/libstddjb/sig_block.lo: src/libstddjb/sig_block.c
 src/libstddjb/sig_blocknone.o src/libstddjb/sig_blocknone.lo: src/libstddjb/sig_blocknone.c src/include/skalibs/sig.h
 src/libstddjb/sig_blockset.o src/libstddjb/sig_blockset.lo: src/libstddjb/sig_blockset.c src/include/skalibs/sig.h
 src/libstddjb/sig_catch.o src/libstddjb/sig_catch.lo: src/libstddjb/sig_catch.c src/include/skalibs/sig.h
+src/libstddjb/sig_name.o src/libstddjb/sig_name.lo: src/libstddjb/sig_name.c src/libstddjb/sig-internal.h src/include/skalibs/sig.h
+src/libstddjb/sig_number.o src/libstddjb/sig_number.lo: src/libstddjb/sig_number.c src/include/skalibs/bytestr.h src/libstddjb/sig-internal.h src/include/skalibs/sig.h
 src/libstddjb/sig_pause.o src/libstddjb/sig_pause.lo: src/libstddjb/sig_pause.c src/include/skalibs/sig.h
 src/libstddjb/sig_push.o src/libstddjb/sig_push.lo: src/libstddjb/sig_push.c src/include/skalibs/sig.h
 src/libstddjb/sig_restoreto.o src/libstddjb/sig_restoreto.lo: src/libstddjb/sig_restoreto.c src/include/skalibs/sig.h
 src/libstddjb/sig_shield.o src/libstddjb/sig_shield.lo: src/libstddjb/sig_shield.c src/include/skalibs/sig.h
 src/libstddjb/sig_stack.o src/libstddjb/sig_stack.lo: src/libstddjb/sig_stack.c src/include/skalibs/nsig.h src/include/skalibs/sig.h
+src/libstddjb/sig_table.o src/libstddjb/sig_table.lo: src/libstddjb/sig_table.c src/libstddjb/sig-internal.h
 src/libstddjb/sig_unblock.o src/libstddjb/sig_unblock.lo: src/libstddjb/sig_unblock.c src/include/skalibs/sig.h
 src/libstddjb/sig_unshield.o src/libstddjb/sig_unshield.lo: src/libstddjb/sig_unshield.c src/include/skalibs/sig.h
 src/libstddjb/sigfpe.o src/libstddjb/sigfpe.lo: src/libstddjb/sigfpe.c src/include/skalibs/segfault.h
@@ -745,6 +749,9 @@ src/libunixonacid/timed_flush.o src/libunixonacid/timed_flush.lo: src/libunixona
 src/libunixonacid/timed_get.o src/libunixonacid/timed_get.lo: src/libunixonacid/timed_get.c src/include/skalibs/allreadwrite.h src/include/skalibs/functypes.h src/include/skalibs/iopause.h src/include/skalibs/tai.h src/include/skalibs/unix-timed.h
 src/libunixonacid/timed_getln.o src/libunixonacid/timed_getln.lo: src/libunixonacid/timed_getln.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/include/skalibs/functypes.h src/include/skalibs/skamisc.h src/include/skalibs/stralloc.h src/include/skalibs/tai.h src/include/skalibs/unix-timed.h
 src/libunixonacid/timed_getlnmax.o src/libunixonacid/timed_getlnmax.lo: src/libunixonacid/timed_getlnmax.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/include/skalibs/functypes.h src/include/skalibs/skamisc.h src/include/skalibs/tai.h src/include/skalibs/unix-timed.h
+src/libunixonacid/unixconnection_free.o src/libunixonacid/unixconnection_free.lo: src/libunixonacid/unixconnection_free.c src/include/skalibs/unixconnection.h src/include/skalibs/unixmessage.h
+src/libunixonacid/unixconnection_init.o src/libunixonacid/unixconnection_init.lo: src/libunixonacid/unixconnection_init.c src/include/skalibs/unixconnection.h src/include/skalibs/unixmessage.h
+src/libunixonacid/unixconnection_zero.o src/libunixonacid/unixconnection_zero.lo: src/libunixonacid/unixconnection_zero.c src/include/skalibs/unixconnection.h
 src/libunixonacid/unixmessage_bits_closeall.o src/libunixonacid/unixmessage_bits_closeall.lo: src/libunixonacid/unixmessage_bits_closeall.c src/include/skalibs/bitarray.h src/include/skalibs/unixmessage.h
 src/libunixonacid/unixmessage_bits_closenone.o src/libunixonacid/unixmessage_bits_closenone.lo: src/libunixonacid/unixmessage_bits_closenone.c src/include/skalibs/bitarray.h src/include/skalibs/unixmessage.h
 src/libunixonacid/unixmessage_drop.o src/libunixonacid/unixmessage_drop.lo: src/libunixonacid/unixmessage_drop.c src/include/skalibs/djbunix.h src/include/skalibs/unixmessage.h
diff --git a/package/info b/package/info
index 7415877..d89fde2 100644
--- a/package/info
+++ b/package/info
@@ -1,4 +1,4 @@
 package=skalibs
-version=2.2.0.0
+version=2.2.1.0
 category=prog
 package_macro_name=SKALIBS
diff --git a/src/include/skalibs/sig.h b/src/include/skalibs/sig.h
index 7972e14..fa46b00 100644
--- a/src/include/skalibs/sig.h
+++ b/src/include/skalibs/sig.h
@@ -43,4 +43,7 @@ extern void sig_pause (void) ;
 extern void sig_shield (void) ;
 extern void sig_unshield (void) ;
 
+extern char const *sig_name (int) ;
+extern int sig_number (char const *) ;
+
 #endif
diff --git a/src/include/skalibs/unixconnection.h b/src/include/skalibs/unixconnection.h
new file mode 100644
index 0000000..50a6ee8
--- /dev/null
+++ b/src/include/skalibs/unixconnection.h
@@ -0,0 +1,25 @@
+ /* ISC license. */
+
+#ifndef UNIXCONNECTION_H
+#define UNIXCONNECTION_H
+
+#include <skalibs/unixmessage.h>
+
+typedef struct unixconnection_s unixconnection_t, *unixconnection_t_ref ;
+struct unixconnection_s
+{
+  unixmessage_sender_t out ;
+  unixmessage_receiver_t in ;
+  char mainbuf[UNIXMESSAGE_BUFSIZE] ;
+  char auxbuf[UNIXMESSAGE_AUXBUFSIZE] ;
+} ;
+#define UNIXCONNECTION_ZERO { .out = UNIXMESSAGE_SENDER_ZERO, .in = UNIXMESSAGE_RECEIVER_ZERO } ;
+extern unixconnection_t const unixconnection_zero ;
+
+extern void unixconnection_init (unixconnection_t *, int, int) ;
+extern void unixconnection_free (unixconnection_t *) ;
+
+#define unixconnection_flush(io) unixmessage_sender_flush(&(io)->out)
+#define unixconnection_receive(io, m) unixmessage_receive(&(io)->in, m)
+
+#endif
diff --git a/src/include/skalibs/unixonacid.h b/src/include/skalibs/unixonacid.h
index a150e39..9ec3fe8 100644
--- a/src/include/skalibs/unixonacid.h
+++ b/src/include/skalibs/unixonacid.h
@@ -6,6 +6,7 @@
 #include <skalibs/unix-transactional.h>
 #include <skalibs/unix-timed.h>
 #include <skalibs/unixmessage.h>
+#include <skalibs/unixconnection.h>
 #include <skalibs/kolbak.h>
 #include <skalibs/skaclient.h>
 
diff --git a/src/libstddjb/sig-internal.h b/src/libstddjb/sig-internal.h
new file mode 100644
index 0000000..9b540fa
--- /dev/null
+++ b/src/libstddjb/sig-internal.h
@@ -0,0 +1,15 @@
+/* ISC license. */
+
+#ifndef SIG_INTERNAL
+#define SIG_INTERNAL
+
+typedef struct sigtable_s sigtable_t, *sigtable_t_ref ;
+struct sigtable_s
+{
+  int number ;
+  char const *name ;
+} ;
+
+extern sigtable_t const skalibs_sigtable[] ;
+
+#endif
diff --git a/src/libstddjb/sig_name.c b/src/libstddjb/sig_name.c
new file mode 100644
index 0000000..dd5a456
--- /dev/null
+++ b/src/libstddjb/sig_name.c
@@ -0,0 +1,11 @@
+/* ISC license. */
+
+#include <skalibs/sig.h>
+#include "sig-internal.h"
+
+char const *sig_name (int sig)
+{
+  register sigtable_t const *p = skalibs_sigtable ;
+  for (; p->number ; p++) if (sig == p->number) break ;
+  return p->number ? p->name : "???" ;
+}
diff --git a/src/libstddjb/sig_number.c b/src/libstddjb/sig_number.c
new file mode 100644
index 0000000..93d9b59
--- /dev/null
+++ b/src/libstddjb/sig_number.c
@@ -0,0 +1,12 @@
+/* ISC license. */
+
+#include <skalibs/bytestr.h>
+#include <skalibs/sig.h>
+#include "sig-internal.h"
+
+int sig_number (char const *name)
+{
+  register sigtable_t const *p = skalibs_sigtable ;
+  for (; p->name ; p++) if (!str_diff(name, p->name)) break ;
+  return p->number ;
+}
diff --git a/src/libstddjb/sig_table.c b/src/libstddjb/sig_table.c
new file mode 100644
index 0000000..d097cb5
--- /dev/null
+++ b/src/libstddjb/sig_table.c
@@ -0,0 +1,83 @@
+ /* ISC license. */
+
+#include <signal.h>
+#include "sig-internal.h"
+
+sigtable_t const skalibs_sigtable[] =
+{
+  { SIGABRT, "ABRT" },
+  { SIGALRM, "ALRM" },
+  { SIGBUS, "BUS" },
+  { SIGCHLD, "CHLD" },
+  { SIGCONT, "CONT" },
+  { SIGFPE, "FPE" },
+  { SIGHUP, "HUP" },
+  { SIGILL, "ILL" },
+  { SIGINT, "INT" },
+  { SIGKILL, "KILL" },
+  { SIGPIPE, "PIPE" },
+  { SIGQUIT, "QUIT" },
+  { SIGSEGV, "SEGV" },
+  { SIGSTOP, "STOP" },
+  { SIGTERM, "TERM" },
+  { SIGTSTP, "TSTP" },
+  { SIGTTIN, "TTIN" },
+  { SIGTTOU, "TTOU" },
+  { SIGUSR1, "USR1" },
+  { SIGUSR2, "USR2" },
+#ifdef SIGPOLL
+  { SIGPOLL, "POLL" },
+#endif
+#ifdef SIGPROF
+  { SIGPROF, "PROF" },
+#endif 
+#ifdef SIGSYS
+  { SIGSYS, "SYS" },
+#endif
+#ifdef SIGTRAP
+  { SIGTRAP, "TRAP" },
+#endif
+#ifdef SIGURG
+  { SIGURG, "URG" },
+#endif
+#ifdef SIGVTALRM
+  { SIGVTALRM, "VTALRM" },
+#endif
+#ifdef SIGXCPU
+  { SIGXCPU, "XCPU" },
+#endif
+#ifdef SIGXFSZ
+  { SIGXFSZ, "XFSZ" },
+#endif
+#ifdef SIGIOT
+  { SIGIOT, "IOT" },
+#endif
+#ifdef SIGEMT
+  { SIGEMT, "EMT" },
+#endif
+#ifdef SIGSTKFLT
+  { SIGSTKFLT, "STKFLT" },
+#endif
+#ifdef SIGCLD
+  { SIGCLD, "CLD" },
+#endif
+#ifdef SIGWINCH
+  { SIGWINCH, "WINCH" },
+#endif
+#ifdef SIGIO
+  { SIGIO, "IO" },
+#endif
+#ifdef SIGINFO
+  { SIGINFO, "INFO" },
+#endif
+#ifdef SIGLOST
+  { SIGLOST, "LOST" },
+#endif
+#ifdef SIGPWR
+  { SIGPWR, "PWR" },
+#endif
+#ifdef SIGUNUSED
+  { SIGUNUSED, "UNUSED" },
+#endif
+  { 0, 0 }
+} ;
diff --git a/src/libstddjb/skasigaction.c b/src/libstddjb/skasigaction.c
index a673fcb..bb55642 100644
--- a/src/libstddjb/skasigaction.c
+++ b/src/libstddjb/skasigaction.c
@@ -1,7 +1,6 @@
 /* ISC license. */
 
 #include <signal.h>
-#include <skalibs/sysdeps.h>
 #include <skalibs/sig.h>
 
 int skasigaction (int sig, struct skasigaction const *new, struct skasigaction *old)
@@ -10,11 +9,11 @@ int skasigaction (int sig, struct skasigaction const *new, struct skasigaction *
   if (((new->flags & SKASA_MASKALL) ? sigfillset(&sanew.sa_mask) : sigemptyset(&sanew.sa_mask)) == -1) return -1 ;
   sanew.sa_handler = new->handler ;
   sanew.sa_flags = (new->flags & SKASA_NOCLDSTOP) ? SA_NOCLDSTOP : 0 ;
-  if (sigaction(sig, &sanew, &saold) == -1) return -1 ;
+  if (sigaction(sig, &sanew, &saold) < 0) return -1 ;
   if (old)
   {
     register int r = sigismember(&saold.sa_mask, (sig == SIGTERM) ? SIGPIPE : SIGTERM) ;
-    if (r == -1) return -1 ;
+    if (r < 0) return -1 ;
     old->flags = 0 ;
     if (r) old->flags |= SKASA_MASKALL ;
     if (saold.sa_flags & SA_NOCLDSTOP) old->flags |= SKASA_NOCLDSTOP ;
diff --git a/src/libunixonacid/unixconnection_free.c b/src/libunixonacid/unixconnection_free.c
new file mode 100644
index 0000000..52f9027
--- /dev/null
+++ b/src/libunixonacid/unixconnection_free.c
@@ -0,0 +1,11 @@
+ /* ISC license. */
+
+#include <skalibs/unixmessage.h>
+#include <skalibs/unixconnection.h>
+
+void unixconnection_free (unixconnection_t *io)
+{
+  unixmessage_sender_free(&io->out) ;
+  unixmessage_receiver_free(&io->in) ;
+  *io = unixconnection_zero ;
+}
diff --git a/src/libunixonacid/unixconnection_init.c b/src/libunixonacid/unixconnection_init.c
new file mode 100644
index 0000000..7831d6a
--- /dev/null
+++ b/src/libunixonacid/unixconnection_init.c
@@ -0,0 +1,10 @@
+ /* ISC license. */
+
+#include <skalibs/unixmessage.h>
+#include <skalibs/unixconnection.h>
+
+void unixconnection_init (unixconnection_t *io, int fdin, int fdout)
+{
+  unixmessage_receiver_init(&io->in, fdin, io->mainbuf, UNIXMESSAGE_BUFSIZE, io->auxbuf, UNIXMESSAGE_AUXBUFSIZE) ;
+  unixmessage_sender_init(&io->out, fdout) ;
+}
diff --git a/src/libunixonacid/unixconnection_zero.c b/src/libunixonacid/unixconnection_zero.c
new file mode 100644
index 0000000..9100cac
--- /dev/null
+++ b/src/libunixonacid/unixconnection_zero.c
@@ -0,0 +1,5 @@
+ /* ISC license. */
+
+#include <skalibs/unixconnection.h>
+
+unixconnection_t const unixconnection_zero = UNIXCONNECTION_ZERO ;