File:  [ELWIX - Embedded LightWeight unIX -] / libelwix / inc / elwix / astr.h
Revision 1.8: download - view: text, annotated - select for diffs - revision graph
Wed Jan 23 13:26:28 2019 UTC (5 years, 3 months ago) by misho
Branches: MAIN
CVS tags: elwix5_9, elwix5_8, elwix5_7, elwix5_6, elwix5_5, elwix5_4, elwix5_3, elwix5_2, elwix5_12, elwix5_11, elwix5_10, elwix5_1, elwix5_0, elwix4_26, elwix4_25, elwix4_24, elwix4_23, elwix4_22, elwix4_21, elwix4_20, HEAD, ELWIX5_9, ELWIX5_8, ELWIX5_7, ELWIX5_6, ELWIX5_5, ELWIX5_4, ELWIX5_3, ELWIX5_2, ELWIX5_11, ELWIX5_10, ELWIX5_1, ELWIX5_0, ELWIX4_26, ELWIX4_25, ELWIX4_24, ELWIX4_23, ELWIX4_22, ELWIX4_21, ELWIX4_20, ELWIX4_19
ver 4.19

/*************************************************************************
* (C) 2013 AITNET ltd - Sofia/Bulgaria - <misho@aitnet.org>
*  by Michael Pounov <misho@elwix.org>
*
* $Author: misho $
* $Id: astr.h,v 1.8 2019/01/23 13:26:28 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 - 2019
	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);


#endif

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