/*************************************************************************
* (C) 2013 AITNET ltd - Sofia/Bulgaria - <misho@aitnet.org>
* by Michael Pounov <misho@elwix.org>
*
* $Author: misho $
* $Id: astr.h,v 1.8.48.1 2024/10/26 14:40:36 misho Exp $
*
**************************************************************************
The ELWIX and AITNET software is distributed under the following
terms:
All of the documentation and software included in the ELWIX and AITNET
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>
Copyright 2004 - 2024
by Michael Pounov <misho@elwix.org>. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by Michael Pounov <misho@elwix.org>
ELWIX - Embedded LightWeight unIX and its contributors.
4. Neither the name of AITNET nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY AITNET AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#ifndef __ASTR_H
#define __ASTR_H
/*
* str_FreeNullTerm() - Free dynamic allocated null terminated array with strings
*
* @arr = Pointer to array for free
* return: none
*/
void str_FreeNullTerm(char *** __restrict arr);
/*
* str_ArgsNum() - Parse and calculate number of arguments
*
* @csArgs = Input arguments line
* @csDelim = Delimiter(s) for separate
* return: 0 error format; -1 error:: can`t read; >0 ok, number of items
*/
int str_ArgsNum(const char *csArgs, const char *csDelim);
/*
* str_ExecArgs() - Build exec arguments from other array
*
* @psProg = Program name for execute
* @oldarg = Arguments array
* return: NULL error; !=NULL Allocated execution array(must be e_free)
*/
char **str_ExecArgs(const char *psProg, const char **oldarg);
/*
* str_CopyEnv() - Copy environment to new environment array;
*
* @oldenv = Environment array
* return: NULL error; !=NULL Allocated new environment array(must be e_free)
*/
char **str_CopyEnv(const char **oldenv);
/*
* str_Ast() - Function for evaluate string like asterisk variable "{text[:[-]#[:#]]}"
*
* @csString = Input string
* return: NULL error, !=NULL Allocated new string evaluated from input string,
* must be ait_freeVar()
*/
ait_val_t *str_Ast(const char *csString);
/*
* str_LTrim() - Remove left whitespaces from text string
*
* @psLine = Text string
* return: 0 nothing to do; !=0 Removed bytes
*/
int str_LTrim(char * __restrict psLine);
/*
* str_RTrim() - Remove right whitespaces from text string
*
* @psLine = Text string
* return: 0 nothing to do; !=0 Removed bytes
*/
int str_RTrim(char * __restrict psLine);
/*
* str_Trim() - Remove left and right whitespaces from text string
*
* @psLine = Text string
* return: 0 nothing to do; !=0 Removed bytes
*/
int str_Trim(char * __restrict psLine);
/*
* str_Unquot() - Remove quots from input text string
*
* @psLine = Text string
* return: 0 nothing to do; 1 successful unquoted string
*/
int str_Unquot(char * __restrict psLine);
/*
* str_Upper() - Convert all lower characters to upper
*
* @psLine = Text string
* return: 0 nothing to do; !=0 converted chars
*/
int str_Upper(char * __restrict psLine);
/*
* str_Lower() - Convert all upper characters to lower
*
* @psLine = Text string
* return: 0 nothing to do; !=0 converted chars
*/
int str_Lower(char * __restrict psLine);
/*
* str_Hex2Dig() - Convert from Hex string to digit array
*
* @psLine = Text string
* return: NULL nothing to do or error;
* !=0 Allocated new converted data (must be ait_freeVar())
*/
ait_val_t *str_Hex2Dig(const char *psLine);
/*
* str_Dig2Hex() - Convert from digit array to Hex string
*
* @digz = Digits
* return: NULL nothing to do or error;
* !=0 Allocated new converted string (must be e_free())
*/
char *str_Dig2Hex(ait_val_t *digz);
/*
* str_Dig2Hex2() - Convert from digit array to Hex string
*
* @digz = Digits array
* @diglen = Array length
* return: NULL nothing to do or error;
* !=0 Allocated new converted string (must be e_free())
*/
char *str_Dig2Hex2(u_char *digz, int diglen);
/*
* str_getString() - Get NULL delimited string from data buffer
*
* @data = Const data buffer
* @dlen = Data length
* @next = Return next position after string if !=NULL
* return: -1 error or size of string
*/
int str_getString(const unsigned char * __restrict data, int dlen,
char ** __restrict next);
/*
* str_getString2() - Get string from data buffer with delimiter
*
* @data = Data buffer
* @dlen = Data length
* @delim = Data delimiter
* @next = Return next position after delimited string if !=NULL
* return: -1 error or size of string
*/
int str_getString2(char * __restrict data, int dlen, char delim,
char ** __restrict next);
/*
* str_find2replace() - Search find string into data and replace
*
* @data = input string
* @find = search for string
* @replace = replace to string. If it is NULL then deletes found search string
* @str = new produced allocate string. If it is NULL then just return found occurances of find
* @mlen = allocated memory size for new string
* return: -1 error, 0 not found or >0 how many occurances we have for find string
*/
int str_find2replace(const char *data, const char *find, const char *replace, char **str, int *mlen);
#endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>