summaryrefslogtreecommitdiff
path: root/src/libstddjb/cbuffer_rpeek.c
blob: 22a1ef51f56b5145ff24c467d0d0e74c30bc4a7e (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 <skalibs/cbuffer.h>
#include <skalibs/siovec.h>

void cbuffer_rpeek (cbuffer_t *b, siovec_t *v)
{
  v[0].s = b->x + b->p ;
  if (b->n >= b->p)
  {
    v[0].len = b->n - b->p ;
    v[1].s = 0 ;
    v[1].len = 0 ;
  }
  else
  {
    v[0].len = b->a - b->p ;
    v[1].s = b->x ;
    v[1].len = b->n ;
  }
}