skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

commit 347f8a8a14e3fb736ea6f42c7a0da1a0472f947f
parent 16de50671c7ad77f2acb4ca19d8806aad0490f03
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Mon, 19 Jan 2015 16:20:29 +0000

 - Added unixconnection
 - Added sig_name & sig_number (suggestion from Olivier Brunel)
 - version bumped to 2.2.1.0, rc

Diffstat:
Mdoc/index.html | 2+-
Mdoc/upgrade.html | 7+++++++
Mpackage/deps.mak | 9++++++++-
Mpackage/info | 2+-
Msrc/include/skalibs/sig.h | 3+++
Asrc/include/skalibs/unixconnection.h | 25+++++++++++++++++++++++++
Msrc/include/skalibs/unixonacid.h | 1+
Asrc/libstddjb/sig-internal.h | 15+++++++++++++++
Asrc/libstddjb/sig_name.c | 11+++++++++++
Asrc/libstddjb/sig_number.c | 12++++++++++++
Asrc/libstddjb/sig_table.c | 83+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/libstddjb/skasigaction.c | 5++---
Asrc/libunixonacid/unixconnection_free.c | 11+++++++++++
Asrc/libunixonacid/unixconnection_init.c | 10++++++++++
Asrc/libunixonacid/unixconnection_zero.c | 5+++++
15 files changed, 195 insertions(+), 6 deletions(-)

diff --git 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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -0,0 +1,5 @@ + /* ISC license. */ + +#include <skalibs/unixconnection.h> + +unixconnection_t const unixconnection_zero = UNIXCONNECTION_ZERO ;