File:  [ELWIX - Embedded LightWeight unIX -] / libelwix / inc / elwix / aiov.h
Revision 1.2: download - view: text, annotated - select for diffs - revision graph
Sun Mar 21 01:32:04 2021 UTC (3 years, 3 months ago) by misho
Branches: MAIN
CVS tags: elwix5_9, elwix5_8, elwix5_7, elwix5_6, elwix5_5, elwix5_4, elwix5_3, elwix5_2, elwix5_12, elwix5_11, elwix5_10, elwix5_1, elwix5_0, HEAD, ELWIX5_9, ELWIX5_8, ELWIX5_7, ELWIX5_6, ELWIX5_5, ELWIX5_4, ELWIX5_3, ELWIX5_2, ELWIX5_11, ELWIX5_10, ELWIX5_1, ELWIX5_0, ELWIX4_26
ver 4.26

    1: /*************************************************************************
    2: * (C) 2021 AITNET ltd - Sofia/Bulgaria - <misho@aitnet.org>
    3: *  by Michael Pounov <misho@elwix.org>
    4: *
    5: * $Author: misho $
    6: * $Id: aiov.h,v 1.2 2021/03/21 01:32:04 misho Exp $
    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: 
   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: #define iov_Array(x)	(x)->iov_array
   58: 
   59: /*
   60:  * iov_Init() - Init new iovec array
   61:  *
   62:  * return: =NULL error, !=NULL ready array
   63:  */
   64: iovec_t *iov_Init();
   65: /*
   66:  * iov_Destroy() - Destroy iovec array
   67:  *
   68:  * @iov = iovec array
   69:  * return: none
   70:  */
   71: void iov_Destroy(iovec_t ** __restrict iov);
   72: /*
   73:  * iov_Get() - Get data and length from position
   74:  *
   75:  * @iov = iovec array
   76:  * @pos = position
   77:  * @data = data
   78:  * @datlen = data length
   79:  * return: -1 error, 0 ok
   80:  */
   81: int iov_Get(iovec_t * __restrict iov, unsigned int pos, void *data, size_t *datlen);
   82: /*
   83:  * iov_Insert() - Insert data at position into array
   84:  *
   85:  * @iov = iovec array
   86:  * @pos = position
   87:  * @data = data
   88:  * @datlen = data length
   89:  * return: -1 error, 0 ok
   90:  */
   91: int iov_Insert(iovec_t * __restrict iov, unsigned int pos, void *data, size_t datlen);
   92: /*
   93:  * iov_Delete() - Delete data at position into array
   94:  *
   95:  * @iov = iovec array
   96:  * @pos = position
   97:  * @mustfree = data must be free before delete
   98:  * return: -1 error, 0 ok
   99:  */
  100: int iov_Delete(iovec_t * __restrict iov, unsigned int pos, int mustfree);
  101: /*
  102:  * iov_Push() - Push data on first free position
  103:  *
  104:  * @iov = iovec array
  105:  * @data = data
  106:  * @datlen = data length
  107:  * return: -1 error, !=-1 pushed at position
  108:  */
  109: int iov_Push(iovec_t * __restrict iov, void *data, size_t datlen);
  110: /*
  111:  * iov_Pop() - Pop data from last used position
  112:  *
  113:  * @iov = iovec array
  114:  * @data = data
  115:  * @datlen = data length
  116:  * @mustfree = data must be free before delete
  117:  * return: -1 error, !=-1 poped from position
  118:  */
  119: int iov_Pop(iovec_t * __restrict iov, void *data, size_t *datlen, int mustfree);
  120: /*
  121:  * iov_PushPair() - Push pair/named data on first free position
  122:  *
  123:  * @iov = iovec array
  124:  * @name = name of data
  125:  * @data = data
  126:  * @datlen = data length
  127:  * return: -1 error, !=-1 pushed at position
  128:  */
  129: int iov_PushPair(iovec_t * __restrict iov, const char *name, void *data, size_t datlen);
  130: /*
  131:  * iov_PopPair() - Pop pair/named data from last used position
  132:  *
  133:  * @iov = iovec array
  134:  * @name = name of data
  135:  * @namlen = name length
  136:  * @data = data
  137:  * @datlen = data length
  138:  * @mustfree = data must be free before delete
  139:  * return: -1 error, !=-1 poped from position
  140:  */
  141: int iov_PopPair(iovec_t * __restrict iov, char *name, size_t *namlen, 
  142: 		void *data, size_t *datlen, int mustfree);
  143: /*
  144:  * iov_FreePairs() - Free pairs/named data in iovec array
  145:  *
  146:  * @iov = iovec array
  147:  * @mustfree = data must be free before delete
  148:  * return: -1 error or 0 ok
  149:  */
  150: int iov_FreePairs(iovec_t * __restrict iov, int mustfree);
  151: 
  152: /*
  153:  * iov_Debug() - Debug of iovec array
  154:  *
  155:  * @iov = iovec array
  156:  * return: none
  157:  */
  158: void iov_Debug(iovec_t * __restrict iov);
  159: 
  160: 
  161: #endif

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