summaryrefslogtreecommitdiff
path: root/src/libstddjb/cbuffer_rpeek.c
blob: 8592d0069b633395c20775dd133ac36207650d3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* ISC license. */

#include <sys/uio.h>
#include <skalibs/cbuffer.h>

void cbuffer_rpeek (cbuffer_t const *b, struct iovec *v)
{
  v[0].iov_base = b->x + b->p ;
  if (b->n >= b->p)
  {
    v[0].iov_len = b->n - b->p ;
    v[1].iov_base = 0 ;
    v[1].iov_len = 0 ;
  }
  else
  {
    v[0].iov_len = b->a - b->p ;
    v[1].iov_base = b->x ;
    v[1].iov_len = b->n ;
  }
}