Annotation of libelwix/inc/elwix/astr.h, revision 1.10.28.1

1.1       misho       1: /*************************************************************************
                      2: * (C) 2013 AITNET ltd - Sofia/Bulgaria - <misho@aitnet.org>
                      3: *  by Michael Pounov <misho@elwix.org>
                      4: *
                      5: * $Author: misho $
1.10.28.1! misho       6: * $Id: astr.h,v 1.10 2025/08/21 15:43:00 misho Exp $
1.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: 
1.10.28.1! misho      15: Copyright 2004 - 2026
1.1       misho      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: 
1.10      misho      49: #ifdef __cplusplus
                     50: extern "C" {
                     51: #endif
1.1       misho      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:  */
1.3       misho      59: void str_FreeNullTerm(char *** __restrict arr);
1.1       misho      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:  */
1.3       misho      67: int str_ArgsNum(const char *csArgs, const char *csDelim);
1.1       misho      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: /*
1.10.28.1! misho      94:  * str_makeup() - Makeup the string, delete character or replace it
        !            95:  *
        !            96:  * @str = String for makeup
        !            97:  * @ch = Find character
        !            98:  * @replace = Replace found character with this one if it !=0
        !            99:  * return: how many replaces are done or -1 error
        !           100:  */
        !           101: int str_makeup(char * __restrict str, char ch, char replace);
        !           102: /*
1.1       misho     103:  * str_LTrim() - Remove left whitespaces from text string
                    104:  *
                    105:  * @psLine = Text string
                    106:  * return: 0 nothing to do; !=0 Removed bytes
                    107:  */
1.3       misho     108: int str_LTrim(char * __restrict psLine);
1.1       misho     109: /*
                    110:  * str_RTrim() - Remove right whitespaces from text string
                    111:  *
                    112:  * @psLine = Text string
                    113:  * return: 0 nothing to do; !=0 Removed bytes
                    114:  */
1.3       misho     115: int str_RTrim(char * __restrict psLine);
1.1       misho     116: /*
                    117:  * str_Trim() - Remove left and right whitespaces from text string
                    118:  *
                    119:  * @psLine = Text string
                    120:  * return: 0 nothing to do; !=0 Removed bytes
                    121:  */
1.3       misho     122: int str_Trim(char * __restrict psLine);
1.1       misho     123: /*
                    124:  * str_Unquot() - Remove quots from input text string 
                    125:  *
                    126:  * @psLine = Text string
                    127:  * return: 0 nothing to do; 1 successful unquoted string
                    128:  */
1.3       misho     129: int str_Unquot(char * __restrict psLine);
1.2       misho     130: /*
                    131:  * str_Upper() - Convert all lower characters to upper
                    132:  *
                    133:  * @psLine = Text string
                    134:  * return: 0 nothing to do; !=0 converted chars
                    135:  */
1.3       misho     136: int str_Upper(char * __restrict psLine);
1.2       misho     137: /*
                    138:  * str_Lower() - Convert all upper characters to lower
                    139:  *
                    140:  * @psLine = Text string
                    141:  * return: 0 nothing to do; !=0 converted chars
                    142:  */
1.3       misho     143: int str_Lower(char * __restrict psLine);
1.1       misho     144: 
                    145: /*
                    146:  * str_Hex2Dig() - Convert from Hex string to digit array
                    147:  *
                    148:  * @psLine = Text string
                    149:  * return: NULL nothing to do or error; 
                    150:  *             !=0 Allocated new converted data (must be ait_freeVar())
                    151:  */
                    152: ait_val_t *str_Hex2Dig(const char *psLine);
                    153: /*
                    154:  * str_Dig2Hex() - Convert from digit array to Hex string
                    155:  *
                    156:  * @digz = Digits
                    157:  * return: NULL nothing to do or error; 
                    158:  *             !=0 Allocated new converted string (must be e_free())
                    159: */
                    160: char *str_Dig2Hex(ait_val_t *digz);
1.8       misho     161: /*
                    162:  * str_Dig2Hex2() - Convert from digit array to Hex string
                    163:  *
                    164:  * @digz = Digits array
                    165:  * @diglen = Array length
                    166:  * return: NULL nothing to do or error; 
                    167:  *             !=0 Allocated new converted string (must be e_free())
                    168: */
                    169: char *str_Dig2Hex2(u_char *digz, int diglen);
1.1       misho     170: 
1.5       misho     171: /*
1.7       misho     172:  * str_getString() - Get NULL delimited string from data buffer
1.5       misho     173:  *
1.7       misho     174:  * @data = Const data buffer
1.5       misho     175:  * @dlen = Data length
                    176:  * @next = Return next position after string if !=NULL
                    177:  * return: -1 error or size of string 
                    178:  */
                    179: int str_getString(const unsigned char * __restrict data, int dlen, 
1.7       misho     180:                char ** __restrict next);
                    181: /*
                    182:  * str_getString2() - Get string from data buffer with delimiter
                    183:  *
                    184:  * @data = Data buffer
                    185:  * @dlen = Data length
                    186:  * @delim = Data delimiter
                    187:  * @next = Return next position after delimited string if !=NULL
                    188:  * return: -1 error or size of string 
                    189:  */
                    190: int str_getString2(char * __restrict data, int dlen, char delim, 
1.5       misho     191:                char ** __restrict next);
                    192: 
1.9       misho     193: /*
                    194:  * str_find2replace() - Search find string into data and replace
                    195:  *
                    196:  * @data = input string
                    197:  * @find = search for string
                    198:  * @replace = replace to string. If it is NULL then deletes found search string
                    199:  * @str = new produced allocate string. If it is NULL then just return found occurances of find
                    200:  * @mlen = allocated memory size for new string
                    201:  * return: -1 error, 0 not found or >0 how many occurances we have for find string
                    202:  */
                    203: int str_find2replace(const char *data, const char *find, const char *replace, char **str, int *mlen);
                    204: 
1.10      misho     205: #ifdef __cplusplus
                    206: }
                    207: #endif
1.1       misho     208: 
                    209: #endif

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