--- libelwix/inc/elwix/aiov.h 2021/03/18 13:57:21 1.1.2.1 +++ libelwix/inc/elwix/aiov.h 2021/03/19 00:40:28 1.1.2.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aiov.h,v 1.1.2.1 2021/03/18 13:57:21 misho Exp $ +* $Id: aiov.h,v 1.1.2.2 2021/03/19 00:40:28 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -45,6 +45,108 @@ SUCH DAMAGE. */ #ifndef __AIOV_H #define __AIOV_H + + +struct tagIOV { + size_t iov_size; + struct iovec *iov_array; +}; +typedef struct tagIOV iovec_t; + +#define iov_Size(x) (x)->iov_size + +/* + * iov_Init() - Init new iovec array + * + * return: =NULL error, !=NULL ready array + */ +iovec_t *iov_Init(); +/* + * iov_Destroy() - Destroy iovec array + * + * @iov = iovec array + * return: none + */ +void iov_Destroy(iovec_t ** __restrict iov); +/* + * iov_Get() - Get data and length from position + * + * @iov = iovec array + * @pos = position + * @data = data + * @datlen = data length + * return: -1 error, 0 ok + */ +int iov_Get(iovec_t * __restrict iov, unsigned int pos, void **data, size_t *datlen); +/* + * iov_Insert() - Insert data at position into array + * + * @iov = iovec array + * @pos = position + * @data = data + * @datlen = data length + * return: -1 error, 0 ok + */ +int iov_Insert(iovec_t * __restrict iov, unsigned int pos, void *data, size_t datlen); +/* + * iov_Delete() - Delete data at position into array + * + * @iov = iovec array + * @pos = position + * @mustfree = data must be free before delete + * return: -1 error, 0 ok + */ +int iov_Delete(iovec_t * __restrict iov, unsigned int pos, int mustfree); +/* + * iov_Push() - Push data on first free position + * + * @iov = iovec array + * @data = data + * @datlen = data length + * return: -1 error, !=-1 pushed at position + */ +int iov_Push(iovec_t * __restrict iov, void *data, size_t datlen); +/* + * iov_Pop() - Pop data from last used position + * + * @iov = iovec array + * @data = data + * @datlen = data length + * @mustfree = data must be free before delete + * return: -1 error, !=-1 poped from position + */ +int iov_Pop(iovec_t * __restrict iov, void **data, size_t *datlen, int mustfree); +/* + * iov_PushPair() - Push pair/named data on first free position + * + * @iov = iovec array + * @name = name of data + * @data = data + * @datlen = data length + * return: -1 error, !=-1 pushed at position + */ +int iov_PushPair(iovec_t * __restrict iov, const char *name, void *data, size_t datlen); +/* + * iov_PopPair() - Pop pair/named data from last used position + * + * @iov = iovec array + * @name = name of data + * @namlen = name length + * @data = data + * @datlen = data length + * @mustfree = data must be free before delete + * return: -1 error, !=-1 poped from position + */ +int iov_PopPair(iovec_t * __restrict iov, char **name, size_t *namlen, + void **data, size_t *datlen); + +/* + * iov_Debug() - Debug of iovec array + * + * @iov = iovec array + * return: none + */ +void iov_Debug(iovec_t * __restrict iov); #endif