version 1.1, 2021/03/18 13:57:21
|
version 1.2, 2021/03/21 01:32:04
|
Line 0
|
Line 1
|
|
/************************************************************************* |
|
* (C) 2021 AITNET ltd - Sofia/Bulgaria - <misho@aitnet.org> |
|
* by Michael Pounov <misho@elwix.org> |
|
* |
|
* $Author$ |
|
* $Id$ |
|
* |
|
************************************************************************** |
|
The ELWIX and AITNET software is distributed under the following |
|
terms: |
|
|
|
All of the documentation and software included in the ELWIX and AITNET |
|
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
|
|
|
Copyright 2004 - 2021 |
|
by Michael Pounov <misho@elwix.org>. All rights reserved. |
|
|
|
Redistribution and use in source and binary forms, with or without |
|
modification, are permitted provided that the following conditions |
|
are met: |
|
1. Redistributions of source code must retain the above copyright |
|
notice, this list of conditions and the following disclaimer. |
|
2. Redistributions in binary form must reproduce the above copyright |
|
notice, this list of conditions and the following disclaimer in the |
|
documentation and/or other materials provided with the distribution. |
|
3. All advertising materials mentioning features or use of this software |
|
must display the following acknowledgement: |
|
This product includes software developed by Michael Pounov <misho@elwix.org> |
|
ELWIX - Embedded LightWeight unIX and its contributors. |
|
4. Neither the name of AITNET nor the names of its contributors |
|
may be used to endorse or promote products derived from this software |
|
without specific prior written permission. |
|
|
|
THIS SOFTWARE IS PROVIDED BY AITNET AND CONTRIBUTORS ``AS IS'' AND |
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
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 |
|
#define iov_Array(x) (x)->iov_array |
|
|
|
/* |
|
* 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, int mustfree); |
|
/* |
|
* iov_FreePairs() - Free pairs/named data in iovec array |
|
* |
|
* @iov = iovec array |
|
* @mustfree = data must be free before delete |
|
* return: -1 error or 0 ok |
|
*/ |
|
int iov_FreePairs(iovec_t * __restrict iov, int mustfree); |
|
|
|
/* |
|
* iov_Debug() - Debug of iovec array |
|
* |
|
* @iov = iovec array |
|
* return: none |
|
*/ |
|
void iov_Debug(iovec_t * __restrict iov); |
|
|
|
|
|
#endif |