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