--- libelwix/inc/elwix/aav.h 2013/02/04 16:42:18 1.1 +++ libelwix/inc/elwix/aav.h 2013/03/07 16:24:32 1.2 @@ -0,0 +1,111 @@ +/************************************************************************* +* (C) 2013 AITNET ltd - Sofia/Bulgaria - +* by Michael Pounov +* +* $Author: misho $ +* $Id: aav.h,v 1.2 2013/03/07 16:24:32 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 + +Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 + by Michael Pounov . 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 +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 __AV_H +#define __AV_H + + +/* + * av_Path2File() - Parse and make path/filename pair + * + * @csArgs = Input argument line + * @psPath = Output Path, if ==NULL path not returned + * @pathLen = Size of path array + * @psFile = Output File + * @fileLen = Size of file array + * return: 0 error format; -1 error:: can`t read; >0 ok, number of readed items + */ +int av_Path2File(const char * __restrict csArgs, char * __restrict psPath, + int pathLen, char * __restrict psFile, int fileLen); + +/* + * av_Make() - Parse and make attribute/value pair + * + * @csArgs = Input argument line + * @csDelim = Delimiter for separate + * @psAttr = Output Attribute + * @attrLen = Size of attribute array + * @psValue = Output Value, if ==NULL this element not present value or not wanted for return + * @valLen = Size of value array + * return: 0 error format; -1 error:: can`t read; >0 ok, number of readed items +*/ +int av_Make(const char * __restrict csArgs, const char *csDelim, + char * __restrict psAttr, int attrLen, char * __restrict psValue, int valLen); +/* + * av_MakeExt() - Parse and make attribute/value pair over input string + * + * @csArgs = Input argument line, will be modified! + * @csDelim = Delimiter for separate + * @psAttr = Output Attribute + * @psValue = Output Value, if ==NULL this element not present value or not wanted for return + * return: 0 error format; -1 error:: can`t read; >0 ok, number of readed items +*/ +int av_MakeExt(char * __restrict psArgs, const char *csDelim, + char ** __restrict psAttr, char ** __restrict psValue); +/* + * av_Save() - Attribute/Value pair store to file + * + * @csPath = Directory + * @csAttr = Attribute + * @csVal = Value + * @update = Update if a/v exists + * @perm = File permissions, if =0 set default perm=0600 + * return: -1 error or >-1 written bytes + */ +int av_Save(const char *csPath, const char *csAttr, const char *csVal, int update, int perm); +/* + * av_Load() - Get stored Attribute/Value + * + * @csPath = Directory + * @csAttr = Attribute + * @psVal = Value + * @valLen = Value length + * @del = Delete a/v pair after read + * return: -1 error or >-1 readed bytes + */ +int av_Load(const char *csPath, const char *csAttr, char *psVal, int valLen, int del); + + +#endif