Annotation of libelwix/inc/elwix/aiov.h, revision 1.1.2.2

1.1.2.1   misho       1: /*************************************************************************
                      2: * (C) 2021 AITNET ltd - Sofia/Bulgaria - <misho@aitnet.org>
                      3: *  by Michael Pounov <misho@elwix.org>
                      4: *
                      5: * $Author: misho $
1.1.2.2 ! misho       6: * $Id: aiov.h,v 1.1.2.1 2021/03/18 13:57:21 misho Exp $
1.1.2.1   misho       7: *
                      8: **************************************************************************
                      9: The ELWIX and AITNET software is distributed under the following
                     10: terms:
                     11: 
                     12: All of the documentation and software included in the ELWIX and AITNET
                     13: Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>
                     14: 
                     15: Copyright 2004 - 2021
                     16:        by Michael Pounov <misho@elwix.org>.  All rights reserved.
                     17: 
                     18: Redistribution and use in source and binary forms, with or without
                     19: modification, are permitted provided that the following conditions
                     20: are met:
                     21: 1. Redistributions of source code must retain the above copyright
                     22:    notice, this list of conditions and the following disclaimer.
                     23: 2. Redistributions in binary form must reproduce the above copyright
                     24:    notice, this list of conditions and the following disclaimer in the
                     25:    documentation and/or other materials provided with the distribution.
                     26: 3. All advertising materials mentioning features or use of this software
                     27:    must display the following acknowledgement:
                     28: This product includes software developed by Michael Pounov <misho@elwix.org>
                     29: ELWIX - Embedded LightWeight unIX and its contributors.
                     30: 4. Neither the name of AITNET nor the names of its contributors
                     31:    may be used to endorse or promote products derived from this software
                     32:    without specific prior written permission.
                     33: 
                     34: THIS SOFTWARE IS PROVIDED BY AITNET AND CONTRIBUTORS ``AS IS'' AND
                     35: ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     36: IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     37: ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     38: FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     39: DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     40: OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     41: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     42: LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     43: OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     44: SUCH DAMAGE.
                     45: */
                     46: #ifndef __AIOV_H
                     47: #define __AIOV_H
                     48: 
                     49: 
1.1.2.2 ! misho      50: struct tagIOV {
        !            51:        size_t          iov_size;
        !            52:        struct iovec    *iov_array;
        !            53: };
        !            54: typedef struct tagIOV iovec_t;
        !            55: 
        !            56: #define iov_Size(x)    (x)->iov_size
        !            57: 
        !            58: /*
        !            59:  * iov_Init() - Init new iovec array
        !            60:  *
        !            61:  * return: =NULL error, !=NULL ready array
        !            62:  */
        !            63: iovec_t *iov_Init();
        !            64: /*
        !            65:  * iov_Destroy() - Destroy iovec array
        !            66:  *
        !            67:  * @iov = iovec array
        !            68:  * return: none
        !            69:  */
        !            70: void iov_Destroy(iovec_t ** __restrict iov);
        !            71: /*
        !            72:  * iov_Get() - Get data and length from position
        !            73:  *
        !            74:  * @iov = iovec array
        !            75:  * @pos = position
        !            76:  * @data = data
        !            77:  * @datlen = data length
        !            78:  * return: -1 error, 0 ok
        !            79:  */
        !            80: int iov_Get(iovec_t * __restrict iov, unsigned int pos, void **data, size_t *datlen);
        !            81: /*
        !            82:  * iov_Insert() - Insert data at position into array
        !            83:  *
        !            84:  * @iov = iovec array
        !            85:  * @pos = position
        !            86:  * @data = data
        !            87:  * @datlen = data length
        !            88:  * return: -1 error, 0 ok
        !            89:  */
        !            90: int iov_Insert(iovec_t * __restrict iov, unsigned int pos, void *data, size_t datlen);
        !            91: /*
        !            92:  * iov_Delete() - Delete data at position into array
        !            93:  *
        !            94:  * @iov = iovec array
        !            95:  * @pos = position
        !            96:  * @mustfree = data must be free before delete
        !            97:  * return: -1 error, 0 ok
        !            98:  */
        !            99: int iov_Delete(iovec_t * __restrict iov, unsigned int pos, int mustfree);
        !           100: /*
        !           101:  * iov_Push() - Push data on first free position
        !           102:  *
        !           103:  * @iov = iovec array
        !           104:  * @data = data
        !           105:  * @datlen = data length
        !           106:  * return: -1 error, !=-1 pushed at position
        !           107:  */
        !           108: int iov_Push(iovec_t * __restrict iov, void *data, size_t datlen);
        !           109: /*
        !           110:  * iov_Pop() - Pop data from last used position
        !           111:  *
        !           112:  * @iov = iovec array
        !           113:  * @data = data
        !           114:  * @datlen = data length
        !           115:  * @mustfree = data must be free before delete
        !           116:  * return: -1 error, !=-1 poped from position
        !           117:  */
        !           118: int iov_Pop(iovec_t * __restrict iov, void **data, size_t *datlen, int mustfree);
        !           119: /*
        !           120:  * iov_PushPair() - Push pair/named data on first free position
        !           121:  *
        !           122:  * @iov = iovec array
        !           123:  * @name = name of data
        !           124:  * @data = data
        !           125:  * @datlen = data length
        !           126:  * return: -1 error, !=-1 pushed at position
        !           127:  */
        !           128: int iov_PushPair(iovec_t * __restrict iov, const char *name, void *data, size_t datlen);
        !           129: /*
        !           130:  * iov_PopPair() - Pop pair/named data from last used position
        !           131:  *
        !           132:  * @iov = iovec array
        !           133:  * @name = name of data
        !           134:  * @namlen = name length
        !           135:  * @data = data
        !           136:  * @datlen = data length
        !           137:  * @mustfree = data must be free before delete
        !           138:  * return: -1 error, !=-1 poped from position
        !           139:  */
        !           140: int iov_PopPair(iovec_t * __restrict iov, char **name, size_t *namlen, 
        !           141:                void **data, size_t *datlen);
        !           142: 
        !           143: /*
        !           144:  * iov_Debug() - Debug of iovec array
        !           145:  *
        !           146:  * @iov = iovec array
        !           147:  * return: none
        !           148:  */
        !           149: void iov_Debug(iovec_t * __restrict iov);
        !           150: 
        !           151: 
1.1.2.1   misho     152: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>