skalibs

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

kolbak_enqueue.c (397B)


      1 /* ISC license. */
      2 
      3 #include <sys/types.h>
      4 #include <errno.h>
      5 
      6 #include <skalibs/kolbak.h>
      7 #include <skalibs/unixmessage.h>
      8 
      9 int kolbak_enqueue (kolbak_queue *q, unixmessage_handler_func_ref f, void *data)
     10 {
     11   size_t newtail = (q->tail + 1) % q->n ;
     12   if (newtail == q->head) return (errno = ENOBUFS, 0) ;
     13   q->x[q->tail].f = f ;
     14   q->x[q->tail].data = data ;
     15   q->tail = newtail ;
     16   return 1 ;
     17 }