File:  [ELWIX - Embedded LightWeight unIX -] / libelwix / inc / elwix / astr.h
Revision 1.7: download - view: text, annotated - select for diffs - revision graph
Thu May 31 15:35:16 2018 UTC (5 years, 11 months ago) by misho
Branches: MAIN
CVS tags: elwix4_19, elwix4_18, elwix4_17, elwix4_16, elwix4_15, HEAD, ELWIX4_18, ELWIX4_17, ELWIX4_16, ELWIX4_15, ELWIX4_14
version 4.14

    1: /*************************************************************************
    2: * (C) 2013 AITNET ltd - Sofia/Bulgaria - <misho@aitnet.org>
    3: *  by Michael Pounov <misho@elwix.org>
    4: *
    5: * $Author: misho $
    6: * $Id: astr.h,v 1.7 2018/05/31 15:35:16 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 - 2018
   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 __ASTR_H
   47: #define __ASTR_H
   48: 
   49: 
   50: /*
   51:  * str_FreeNullTerm() - Free dynamic allocated null terminated array with strings
   52:  *
   53:  * @arr = Pointer to array for free
   54:  * return: none
   55:  */
   56: void str_FreeNullTerm(char *** __restrict arr);
   57: /*
   58:  * str_ArgsNum() - Parse and calculate number of arguments
   59:  *
   60:  * @csArgs = Input arguments line
   61:  * @csDelim = Delimiter(s) for separate
   62:  * return: 0 error format; -1 error:: can`t read; >0 ok, number of items
   63:  */
   64: int str_ArgsNum(const char *csArgs, const char *csDelim);
   65: /*
   66:  * str_ExecArgs() - Build exec arguments from other array
   67:  *
   68:  * @psProg = Program name for execute
   69:  * @oldarg = Arguments array
   70:  * return: NULL error; !=NULL Allocated execution array(must be e_free)
   71:  */
   72: char **str_ExecArgs(const char *psProg, const char **oldarg);
   73: /*
   74:  * str_CopyEnv() - Copy environment to new environment array;
   75:  *
   76:  * @oldenv = Environment array
   77:  * return: NULL error; !=NULL Allocated new environment array(must be e_free)
   78:  */
   79: char **str_CopyEnv(const char **oldenv);
   80: 
   81: /*
   82:  * str_Ast() - Function for evaluate string like asterisk variable "{text[:[-]#[:#]]}"
   83:  *
   84:  * @csString = Input string
   85:  * return: NULL error, !=NULL Allocated new string evaluated from input string, 
   86:  * 		must be ait_freeVar()
   87:  */
   88: ait_val_t *str_Ast(const char *csString);
   89: 
   90: /*
   91:  * str_LTrim() - Remove left whitespaces from text string
   92:  *
   93:  * @psLine = Text string
   94:  * return: 0 nothing to do; !=0 Removed bytes
   95:  */
   96: int str_LTrim(char * __restrict psLine);
   97: /*
   98:  * str_RTrim() - Remove right whitespaces from text string
   99:  *
  100:  * @psLine = Text string
  101:  * return: 0 nothing to do; !=0 Removed bytes
  102:  */
  103: int str_RTrim(char * __restrict psLine);
  104: /*
  105:  * str_Trim() - Remove left and right whitespaces from text string
  106:  *
  107:  * @psLine = Text string
  108:  * return: 0 nothing to do; !=0 Removed bytes
  109:  */
  110: int str_Trim(char * __restrict psLine);
  111: /*
  112:  * str_Unquot() - Remove quots from input text string 
  113:  *
  114:  * @psLine = Text string
  115:  * return: 0 nothing to do; 1 successful unquoted string
  116:  */
  117: int str_Unquot(char * __restrict psLine);
  118: /*
  119:  * str_Upper() - Convert all lower characters to upper
  120:  *
  121:  * @psLine = Text string
  122:  * return: 0 nothing to do; !=0 converted chars
  123:  */
  124: int str_Upper(char * __restrict psLine);
  125: /*
  126:  * str_Lower() - Convert all upper characters to lower
  127:  *
  128:  * @psLine = Text string
  129:  * return: 0 nothing to do; !=0 converted chars
  130:  */
  131: int str_Lower(char * __restrict psLine);
  132: 
  133: /*
  134:  * str_Hex2Dig() - Convert from Hex string to digit array
  135:  *
  136:  * @psLine = Text string
  137:  * return: NULL nothing to do or error; 
  138:  * 		!=0 Allocated new converted data (must be ait_freeVar())
  139:  */
  140: ait_val_t *str_Hex2Dig(const char *psLine);
  141: /*
  142:  * str_Dig2Hex() - Convert from digit array to Hex string
  143:  *
  144:  * @digz = Digits
  145:  * return: NULL nothing to do or error; 
  146:  * 		!=0 Allocated new converted string (must be e_free())
  147: */
  148: char *str_Dig2Hex(ait_val_t *digz);
  149: 
  150: /*
  151:  * str_getString() - Get NULL delimited string from data buffer
  152:  *
  153:  * @data = Const data buffer
  154:  * @dlen = Data length
  155:  * @next = Return next position after string if !=NULL
  156:  * return: -1 error or size of string 
  157:  */
  158: int str_getString(const unsigned char * __restrict data, int dlen, 
  159: 		char ** __restrict next);
  160: /*
  161:  * str_getString2() - Get string from data buffer with delimiter
  162:  *
  163:  * @data = Data buffer
  164:  * @dlen = Data length
  165:  * @delim = Data delimiter
  166:  * @next = Return next position after delimited string if !=NULL
  167:  * return: -1 error or size of string 
  168:  */
  169: int str_getString2(char * __restrict data, int dlen, char delim, 
  170: 		char ** __restrict next);
  171: 
  172: 
  173: #endif

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