skalibs

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

cbuffer_rpeek.c (371B)


      1 /* ISC license. */
      2 
      3 #include <sys/uio.h>
      4 #include <skalibs/cbuffer.h>
      5 
      6 void cbuffer_rpeek (cbuffer const *b, struct iovec *v)
      7 {
      8   v[0].iov_base = b->x + b->p ;
      9   if (b->n >= b->p)
     10   {
     11     v[0].iov_len = b->n - b->p ;
     12     v[1].iov_base = 0 ;
     13     v[1].iov_len = 0 ;
     14   }
     15   else
     16   {
     17     v[0].iov_len = b->a - b->p ;
     18     v[1].iov_base = b->x ;
     19     v[1].iov_len = b->n ;
     20   }
     21 }