blob: a1e502e16bccf569f49ff867fc6b5306c6fa6ac8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
/* ISC license. */
#include <sys/types.h>
#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 ;
}
}
|