/************************************************************************* * (C) 2010 AITNET ltd - Sofia/Bulgaria - * by Michael Pounov * * $Author: misho $ * $Id: aitio.h,v 1.1 2010/02/23 22:54:52 misho Exp $ * *************************************************************************/ #ifndef __AITIO_H #define __AITIO_H // io_GetErrno() Get error code of last operation inline int io_GetErrno(); // io_GetError() Get error text of last operation inline const char *io_GetError(); /* * ioPromptRead() Read data from input h[0] with prompt to output h[1] * @h = file handles h[0] = input, h[1] = output, if NULL use stdin, stdout * @csPrompt = Prompt before input, may be NULL * @psData = Readed data * @dataLen = Length of data * return: 0 EOF; -1 error:: can`t read; >0 count of readed chars */ int ioPromptRead(int *h, const char *csPrompt, char * __restrict psData, int dataLen); /* * ioPromptPassword() Read password from input h[0] with prompt to output h[1] * @h = file handles h[0] = input, h[1] = output, if NULL use stdin, stdout * @csPrompt = Prompt before input, may be NULL * @psPass = Readed password * @passLen = Length of password * @confirm = Confirm password, 0 - get password, !=0 Ask for confirmation * return: 0 EOF; -1 error:: can`t read; >0 count of readed chars */ int ioPromptPassword(int *h, const char *csPrompt, char * __restrict psPass, int passLen, int confirm); /* * ioRegexVerify() Function for verify data match in regex expression * @csRegex = Regulare expression pattern * @csData = Data for check and verify * @startPos = Return start positions * @endPos = Return end positions * return: NULL not match or error; !=NULL begin of matched data */ const char *ioRegexVerify(const char *csRegex, const char *csData, int *startPos, int *endPos); /* * ioRegexGet() Function for get data match in regex expression * @csRegex = Regulare expression pattern * @csData = Data from get * @psString = Returned string if match * @strLen = Length of string * return: 0 not match; >0 count of returned chars */ int ioRegexGet(const char *csRegex, const char *csData, char * __restrict psString, int strLen); /* * ioRegexReplace() Function for replace data match in regex expression with newdata * @csRegex = Regulare expression pattern * @csData = Source data * @csNew = Data for replace * return: NULL not match or error; !=NULL allocated new string, must be free after use! */ char *ioRegexReplace(const char *csRegex, const char *csData, const char *csNew); #endif