File:  [ELWIX - Embedded LightWeight unIX -] / libelwix / inc / elwix / astr.h
Revision 1.10: 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) 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.10 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 __ASTR_H
   47: #define __ASTR_H
   48: 
   49: #ifdef __cplusplus
   50: extern "C" {
   51: #endif
   52: 
   53: /*
   54:  * str_FreeNullTerm() - Free dynamic allocated null terminated array with strings
   55:  *
   56:  * @arr = Pointer to array for free
   57:  * return: none
   58:  */
   59: void str_FreeNullTerm(char *** __restrict arr);
   60: /*
   61:  * str_ArgsNum() - Parse and calculate number of arguments
   62:  *
   63:  * @csArgs = Input arguments line
   64:  * @csDelim = Delimiter(s) for separate
   65:  * return: 0 error format; -1 error:: can`t read; >0 ok, number of items
   66:  */
   67: int str_ArgsNum(const char *csArgs, const char *csDelim);
   68: /*
   69:  * str_ExecArgs() - Build exec arguments from other array
   70:  *
   71:  * @psProg = Program name for execute
   72:  * @oldarg = Arguments array
   73:  * return: NULL error; !=NULL Allocated execution array(must be e_free)
   74:  */
   75: char **str_ExecArgs(const char *psProg, const char **oldarg);
   76: /*
   77:  * str_CopyEnv() - Copy environment to new environment array;
   78:  *
   79:  * @oldenv = Environment array
   80:  * return: NULL error; !=NULL Allocated new environment array(must be e_free)
   81:  */
   82: char **str_CopyEnv(const char **oldenv);
   83: 
   84: /*
   85:  * str_Ast() - Function for evaluate string like asterisk variable "{text[:[-]#[:#]]}"
   86:  *
   87:  * @csString = Input string
   88:  * return: NULL error, !=NULL Allocated new string evaluated from input string, 
   89:  * 		must be ait_freeVar()
   90:  */
   91: ait_val_t *str_Ast(const char *csString);
   92: 
   93: /*
   94:  * str_LTrim() - Remove left whitespaces from text string
   95:  *
   96:  * @psLine = Text string
   97:  * return: 0 nothing to do; !=0 Removed bytes
   98:  */
   99: int str_LTrim(char * __restrict psLine);
  100: /*
  101:  * str_RTrim() - Remove right whitespaces from text string
  102:  *
  103:  * @psLine = Text string
  104:  * return: 0 nothing to do; !=0 Removed bytes
  105:  */
  106: int str_RTrim(char * __restrict psLine);
  107: /*
  108:  * str_Trim() - Remove left and right whitespaces from text string
  109:  *
  110:  * @psLine = Text string
  111:  * return: 0 nothing to do; !=0 Removed bytes
  112:  */
  113: int str_Trim(char * __restrict psLine);
  114: /*
  115:  * str_Unquot() - Remove quots from input text string 
  116:  *
  117:  * @psLine = Text string
  118:  * return: 0 nothing to do; 1 successful unquoted string
  119:  */
  120: int str_Unquot(char * __restrict psLine);
  121: /*
  122:  * str_Upper() - Convert all lower characters to upper
  123:  *
  124:  * @psLine = Text string
  125:  * return: 0 nothing to do; !=0 converted chars
  126:  */
  127: int str_Upper(char * __restrict psLine);
  128: /*
  129:  * str_Lower() - Convert all upper characters to lower
  130:  *
  131:  * @psLine = Text string
  132:  * return: 0 nothing to do; !=0 converted chars
  133:  */
  134: int str_Lower(char * __restrict psLine);
  135: 
  136: /*
  137:  * str_Hex2Dig() - Convert from Hex string to digit array
  138:  *
  139:  * @psLine = Text string
  140:  * return: NULL nothing to do or error; 
  141:  * 		!=0 Allocated new converted data (must be ait_freeVar())
  142:  */
  143: ait_val_t *str_Hex2Dig(const char *psLine);
  144: /*
  145:  * str_Dig2Hex() - Convert from digit array to Hex string
  146:  *
  147:  * @digz = Digits
  148:  * return: NULL nothing to do or error; 
  149:  * 		!=0 Allocated new converted string (must be e_free())
  150: */
  151: char *str_Dig2Hex(ait_val_t *digz);
  152: /*
  153:  * str_Dig2Hex2() - Convert from digit array to Hex string
  154:  *
  155:  * @digz = Digits array
  156:  * @diglen = Array length
  157:  * return: NULL nothing to do or error; 
  158:  * 		!=0 Allocated new converted string (must be e_free())
  159: */
  160: char *str_Dig2Hex2(u_char *digz, int diglen);
  161: 
  162: /*
  163:  * str_getString() - Get NULL delimited string from data buffer
  164:  *
  165:  * @data = Const data buffer
  166:  * @dlen = Data length
  167:  * @next = Return next position after string if !=NULL
  168:  * return: -1 error or size of string 
  169:  */
  170: int str_getString(const unsigned char * __restrict data, int dlen, 
  171: 		char ** __restrict next);
  172: /*
  173:  * str_getString2() - Get string from data buffer with delimiter
  174:  *
  175:  * @data = Data buffer
  176:  * @dlen = Data length
  177:  * @delim = Data delimiter
  178:  * @next = Return next position after delimited string if !=NULL
  179:  * return: -1 error or size of string 
  180:  */
  181: int str_getString2(char * __restrict data, int dlen, char delim, 
  182: 		char ** __restrict next);
  183: 
  184: /*
  185:  * str_find2replace() - Search find string into data and replace
  186:  *
  187:  * @data = input string
  188:  * @find = search for string
  189:  * @replace = replace to string. If it is NULL then deletes found search string
  190:  * @str = new produced allocate string. If it is NULL then just return found occurances of find
  191:  * @mlen = allocated memory size for new string
  192:  * return: -1 error, 0 not found or >0 how many occurances we have for find string
  193:  */
  194: int str_find2replace(const char *data, const char *find, const char *replace, char **str, int *mlen);
  195: 
  196: #ifdef __cplusplus
  197: }
  198: #endif
  199: 
  200: #endif

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