SolarCapture C Bindings User Guide  SF-115721-CD
Issue 3
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
iovec.h File Reference

sc_iovec_ptr: Supports iterating over a 'struct iovec'. More...

#include <string.h>

Data Structures

struct  sc_iovec_ptr
 An sc_iovec_ptr provides a convenient way to iterate over an iovec array without modifying it. More...
 

Functions

static void sc_iovec_ptr_init (struct sc_iovec_ptr *iovp, const struct iovec *iov, int iovlen)
 Initialise a struct sc_iovec_ptr. More...
 
static void sc_iovec_ptr_init_buf (struct sc_iovec_ptr *iovp, void *buf, int len)
 Initialise a struct sc_iovec_ptr with a contiguous buffer. More...
 
static void sc_iovec_ptr_init_packet (struct sc_iovec_ptr *iovp, const struct sc_packet *packet)
 Initialise a struct sc_iovec_ptr to point at packet data. More...
 
static int sc_iovec_ptr_bytes (const struct sc_iovec_ptr *iovp)
 Returns the number of bytes represented by an sc_iovec_ptr. More...
 
int sc_iovec_ptr_skip (struct sc_iovec_ptr *iovp, int bytes_to_skip)
 Skip forward over an iovec. More...
 
int sc_iovec_ptr_find_chr (const struct sc_iovec_ptr *iovp, int c)
 Find offset of character in iovec. More...
 
int sc_iovec_ptr_copy_out (void *dest, struct sc_iovec_ptr *iovp, int max_bytes)
 Copy data out of an sc_iovec_ptr. More...
 
static void sc_iovec_copy_from_end_offset (void *dest_buf, const struct iovec *iov, int iovlen, int bytes, int offset)
 Copy data out of the end with the offset of a sc_iovec_ptr. More...
 
static void sc_iovec_copy_to_end_offset (struct iovec *iov, const void *src_buf, int iovlen, int bytes, int offset)
 Copy data to the end with the offset of a sc_iovec_ptr, overwriting any existing data. More...
 
static void sc_iovec_copy_from_end (void *dest_buf, const struct iovec *iov, int iovlen, int bytes)
 Copy data out of the end of a sc_iovec_ptr. More...
 
static void sc_iovec_trim_end (struct iovec *iov, uint8_t *iovlen, int bytes)
 Remove data from the end of an iovec. More...
 

Detailed Description

sc_iovec_ptr: Supports iterating over a 'struct iovec'.

Function Documentation

static void sc_iovec_copy_from_end ( void *  dest_buf,
const struct iovec *  iov,
int  iovlen,
int  bytes 
)
inlinestatic

Copy data out of the end of a sc_iovec_ptr.

Parameters
dest_bufBuffer to copy to.
iovA pointer to an array of iovec objects.
iovlenThe number of iovec objects in iov. This must be > 0.
bytesNumber of bytes to copy.

Note: The caller must ensure that at least bytes of data are available in iov

static void sc_iovec_copy_from_end_offset ( void *  dest_buf,
const struct iovec *  iov,
int  iovlen,
int  bytes,
int  offset 
)
inlinestatic

Copy data out of the end with the offset of a sc_iovec_ptr.

Parameters
dest_bufBuffer to copy to.
iovA pointer to an array of iovec objects.
iovlenThe number of iovec objects in iov. This must be > 0.
bytesNumber of bytes to copy.
offsetNumber of bytes to offset.

Note: The caller must ensure that at least bytes + offset of data are available in iov

static void sc_iovec_copy_to_end_offset ( struct iovec *  iov,
const void *  src_buf,
int  iovlen,
int  bytes,
int  offset 
)
inlinestatic

Copy data to the end with the offset of a sc_iovec_ptr, overwriting any existing data.

Parameters
iovA pointer to an array of iovec objects.
src_bufBuffer to copy from.
iovlenThe number of iovec objects in iov. This must be > 0.
bytesNumber of bytes to copy.
offsetNumber of bytes to offset.

Note: The caller must ensure that at least bytes + offset of data are available in iov

static int sc_iovec_ptr_bytes ( const struct sc_iovec_ptr iovp)
inlinestatic

Returns the number of bytes represented by an sc_iovec_ptr.

Parameters
iovpThe sc_iovec_ptr
Returns
The number of bytes represented by the sc_iovec_ptr
int sc_iovec_ptr_copy_out ( void *  dest,
struct sc_iovec_ptr iovp,
int  max_bytes 
)

Copy data out of an sc_iovec_ptr.

Parameters
destBuffer to copy to
iovpAn sc_iovec_ptr
max_bytesMax number of bytes to copy (length of dest)
Returns
The number of bytes copied.
int sc_iovec_ptr_find_chr ( const struct sc_iovec_ptr iovp,
int  c 
)

Find offset of character in iovec.

Parameters
iovpAn sc_iovec_ptr
cCharacter to find
Returns
The offset of first occurrence of character c in the memory reference by iovp, or -1 if not found.
static void sc_iovec_ptr_init ( struct sc_iovec_ptr iovp,
const struct iovec *  iov,
int  iovlen 
)
inlinestatic

Initialise a struct sc_iovec_ptr.

Parameters
iovpThe sc_iovec_ptr to initialise
iovPointer to array of 'struct iovec's
iovlenLength of the iov array
static void sc_iovec_ptr_init_buf ( struct sc_iovec_ptr iovp,
void *  buf,
int  len 
)
inlinestatic

Initialise a struct sc_iovec_ptr with a contiguous buffer.

Parameters
iovpThe sc_iovec_ptr to initialise
bufPointer to the start of the buffer
lenLength of the buffer
static void sc_iovec_ptr_init_packet ( struct sc_iovec_ptr iovp,
const struct sc_packet packet 
)
inlinestatic

Initialise a struct sc_iovec_ptr to point at packet data.

Parameters
iovpThe sc_iovec_ptr to initialise
packetThe packet
int sc_iovec_ptr_skip ( struct sc_iovec_ptr iovp,
int  bytes_to_skip 
)

Skip forward over an iovec.

Parameters
iovpAn sc_iovec_ptr
bytes_to_skipNumber of bytes to skip over
Returns
The number of bytes skipped, which may be fewer than bytes_to_skip if the total amount of memory referenced by iovp is less.
static void sc_iovec_trim_end ( struct iovec *  iov,
uint8_t *  iovlen,
int  bytes 
)
inlinestatic

Remove data from the end of an iovec.

Parameters
iovA pointer to an array of iovec objects.
iovlenThe number of iovec objects in iov.
bytesThe number of bytes to trim.

Note: Caller must ensure that at least bytes of data are available in iov.