File:  [ELWIX - Embedded LightWeight unIX -] / libelwix / inc / elwix / aiov.h
Revision 1.3: download - view: text, annotated - select for diffs - revision graph
Thu Aug 21 15:43:00 2025 UTC (3 weeks, 4 days ago) by misho
Branches: MAIN
CVS tags: elwix6_9, elwix6_8, HEAD, ELWIX6_8, ELWIX6_7
Version 6.7

    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.3 2025/08/21 15:43:00 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 - 2024
   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: #ifdef __cplusplus
   60: extern "C" {
   61: #endif
   62: 
   63: /*
   64:  * iov_Init() - Init new iovec array
   65:  *
   66:  * return: =NULL error, !=NULL ready array
   67:  */
   68: iovec_t *iov_Init();
   69: /*
   70:  * iov_Destroy() - Destroy iovec array
   71:  *
   72:  * @iov = iovec array
   73:  * return: none
   74:  */
   75: void iov_Destroy(iovec_t ** __restrict iov);
   76: /*
   77:  * iov_Get() - Get data and length from position
   78:  *
   79:  * @iov = iovec array
   80:  * @pos = position
   81:  * @data = data
   82:  * @datlen = data length
   83:  * return: -1 error, 0 ok
   84:  */
   85: int iov_Get(iovec_t * __restrict iov, unsigned int pos, void *data, size_t *datlen);
   86: /*
   87:  * iov_Insert() - Insert data at position into array
   88:  *
   89:  * @iov = iovec array
   90:  * @pos = position
   91:  * @data = data
   92:  * @datlen = data length
   93:  * return: -1 error, 0 ok
   94:  */
   95: int iov_Insert(iovec_t * __restrict iov, unsigned int pos, void *data, size_t datlen);
   96: /*
   97:  * iov_Delete() - Delete data at position into array
   98:  *
   99:  * @iov = iovec array
  100:  * @pos = position
  101:  * @mustfree = data must be free before delete
  102:  * return: -1 error, 0 ok
  103:  */
  104: int iov_Delete(iovec_t * __restrict iov, unsigned int pos, int mustfree);
  105: /*
  106:  * iov_Push() - Push data on first free position
  107:  *
  108:  * @iov = iovec array
  109:  * @data = data
  110:  * @datlen = data length
  111:  * return: -1 error, !=-1 pushed at position
  112:  */
  113: int iov_Push(iovec_t * __restrict iov, void *data, size_t datlen);
  114: /*
  115:  * iov_Pop() - Pop data from last used position
  116:  *
  117:  * @iov = iovec array
  118:  * @data = data
  119:  * @datlen = data length
  120:  * @mustfree = data must be free before delete
  121:  * return: -1 error, !=-1 poped from position
  122:  */
  123: int iov_Pop(iovec_t * __restrict iov, void *data, size_t *datlen, int mustfree);
  124: /*
  125:  * iov_PushPair() - Push pair/named data on first free position
  126:  *
  127:  * @iov = iovec array
  128:  * @name = name of data
  129:  * @data = data
  130:  * @datlen = data length
  131:  * return: -1 error, !=-1 pushed at position
  132:  */
  133: int iov_PushPair(iovec_t * __restrict iov, const char *name, void *data, size_t datlen);
  134: /*
  135:  * iov_PopPair() - Pop pair/named data from last used position
  136:  *
  137:  * @iov = iovec array
  138:  * @name = name of data
  139:  * @namlen = name length
  140:  * @data = data
  141:  * @datlen = data length
  142:  * @mustfree = data must be free before delete
  143:  * return: -1 error, !=-1 poped from position
  144:  */
  145: int iov_PopPair(iovec_t * __restrict iov, char *name, size_t *namlen, 
  146: 		void *data, size_t *datlen, int mustfree);
  147: /*
  148:  * iov_FreePairs() - Free pairs/named data in iovec array
  149:  *
  150:  * @iov = iovec array
  151:  * @mustfree = data must be free before delete
  152:  * return: -1 error or 0 ok
  153:  */
  154: int iov_FreePairs(iovec_t * __restrict iov, int mustfree);
  155: 
  156: /*
  157:  * iov_Debug() - Debug of iovec array
  158:  *
  159:  * @iov = iovec array
  160:  * return: none
  161:  */
  162: void iov_Debug(iovec_t * __restrict iov);
  163: 
  164: #ifdef __cplusplus
  165: }
  166: #endif
  167: 
  168: #endif

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