Annotation of libaitio/inc/aitio.h, revision 1.4.2.1

1.1       misho       1: /*************************************************************************
                      2: * (C) 2010 AITNET ltd - Sofia/Bulgaria - <misho@aitbg.com>
                      3: *  by Michael Pounov <misho@openbsd-bg.org>
                      4: *
                      5: * $Author: misho $
1.4.2.1 ! misho       6: * $Id: aitio.h,v 1.4 2010/04/16 13:25:27 misho Exp $
1.1       misho       7: *
                      8: *************************************************************************/
                      9: #ifndef __AITIO_H
                     10: #define __AITIO_H
                     11: 
                     12: 
1.2       misho      13: typedef struct _tagURLItem {
                     14:        int     vallen;
                     15:        char    *value;
                     16: } url_Item_t;
                     17: 
                     18: struct tagIOURL {
                     19:        unsigned char   url_line[BUFSIZ];
                     20: 
                     21:        url_Item_t      url_tech;
                     22:        url_Item_t      url_user;
                     23:        url_Item_t      url_pass;
                     24:        url_Item_t      url_host;
                     25:        url_Item_t      url_port;
                     26:        url_Item_t      url_path;
                     27:        url_Item_t      url_args;
                     28: 
                     29:        char            *url_reserved;
                     30: };
                     31: 
1.3       misho      32: 
1.1       misho      33: // io_GetErrno() Get error code of last operation
                     34: inline int io_GetErrno();
                     35: // io_GetError() Get error text of last operation
                     36: inline const char *io_GetError();
                     37: 
                     38: 
                     39: /*
                     40:  * ioPromptRead() Read data from input h[0] with prompt to output h[1]
                     41:  * @h = file handles h[0] = input, h[1] = output, if NULL use stdin, stdout
                     42:  * @csPrompt = Prompt before input, may be NULL
                     43:  * @psData = Readed data
                     44:  * @dataLen = Length of data
                     45:  * return: 0 EOF; -1 error:: can`t read; >0 count of readed chars
                     46: */
                     47: int ioPromptRead(int *h, const char *csPrompt, char * __restrict psData, int dataLen);
                     48: /*
                     49:  * ioPromptPassword() Read password from input h[0] with prompt to output h[1]
                     50:  * @h = file handles h[0] = input, h[1] = output, if NULL use stdin, stdout
                     51:  * @csPrompt = Prompt before input, may be NULL
                     52:  * @psPass = Readed password
                     53:  * @passLen = Length of password
                     54:  * @confirm = Confirm password, 0 - get password, !=0 Ask for confirmation
                     55:  * return: 0 EOF; -1 error:: can`t read; >0 count of readed chars
                     56: */
                     57: int ioPromptPassword(int *h, const char *csPrompt, char * __restrict psPass, int passLen, int confirm);
                     58: 
                     59: /*
                     60:  * ioRegexVerify() Function for verify data match in regex expression
                     61:  * @csRegex = Regulare expression pattern
                     62:  * @csData = Data for check and verify
                     63:  * @startPos = Return start positions
                     64:  * @endPos = Return end positions
                     65:  * return: NULL not match or error; !=NULL begin of matched data
                     66: */
                     67: const char *ioRegexVerify(const char *csRegex, const char *csData, int *startPos, int *endPos);
                     68: /*
                     69:  * ioRegexGet() Function for get data match in regex expression
                     70:  * @csRegex = Regulare expression pattern
                     71:  * @csData = Data from get
                     72:  * @psString = Returned string if match
                     73:  * @strLen = Length of string
                     74:  * return: 0 not match; >0 count of returned chars
                     75: */
                     76: int ioRegexGet(const char *csRegex, const char *csData, char * __restrict psString, int strLen);
                     77: /*
                     78:  * ioRegexReplace() Function for replace data match in regex expression with newdata
                     79:  * @csRegex = Regulare expression pattern
                     80:  * @csData = Source data
                     81:  * @csNew = Data for replace
                     82:  * return: NULL not match or error; !=NULL allocated new string, must be free after use!
                     83: */
                     84: char *ioRegexReplace(const char *csRegex, const char *csData, const char *csNew);
                     85: 
1.2       misho      86: /*
                     87:  * io_Path2File() Parse and make path/filename pair
                     88:  * @csArgs = Input argument line
                     89:  * @psPath = Output Path, if ==NULL path not returned
                     90:  * @pathLen = Size of path array
                     91:  * @psFile = Output File
                     92:  * @fileLen = Size of file array
                     93:  * return: 0 error format; -1 error:: can`t read; >0 ok, number of readed items
                     94: */
                     95: inline int io_Path2File(const char * __restrict csArgs, char * __restrict psPath, int pathLen, 
                     96:                char * __restrict psFile, int fileLen);
                     97: /*
                     98:  * io_MakeAV() Parse and make attribute/value pair
                     99:  * @csArgs = Input argument line
                    100:  * @csDelim = Delimiter for separate
                    101:  * @psAttr = Output Attribute
                    102:  * @attrLen = Size of attribute array
                    103:  * @psValue = Output Value, if ==NULL this element not present value or not wanted for return
                    104:  * @valLen = Size of value array
                    105:  * return: 0 error format; -1 error:: can`t read; >0 ok, number of readed items
                    106: */
                    107: inline int io_MakeAV(const char * __restrict csArgs, const char *csDelim, 
                    108:                char * __restrict psAttr, int attrLen, char * __restrict psValue, int valLen);
                    109: /*
                    110:  * io_SizeArray() Parse and calculate size of array
                    111:  * @csArgs = Input arguments line
                    112:  * @csDelim = Delimiter(s) for separate
                    113:  * return: 0 error format; -1 error:: can`t read; >0 ok, number of items
                    114: */
                    115: inline int io_SizeArray(const char *csArgs, const char *csDelim);
                    116: /*
1.3       misho     117:  * io_MakeArray() Parse and make array of arguments values ... 
                    118:  *     (input string will be modified! and output array must be free)
                    119:  * @psArgs = Input arguments line, after execute string is modified!!!
1.2       misho     120:  * @csDelim = Delimiter(s) for separate
                    121:  * @args = Output array of arguments ... (must be free() after procced function!)
1.3       misho     122:  * @nargs = Maximum requested count of arguments from input string psArgs
1.2       misho     123:  * return: 0 error format; -1 error:: can`t read; >0 ok, number of readed items
                    124: */
                    125: inline int io_MakeArray(char * __restrict psArgs, const char *csDelim, 
                    126:                char *** __restrict args, int nargs);
                    127: 
                    128: /*
1.4       misho     129:  * io_UnquotStr() Remove quots from input text string 
                    130:  * @psLine = Text string
                    131:  * return: 0 nothing to do; 1 successful unquoted string
                    132: */
1.4.2.1 ! misho     133: inline int io_UnquotStr(unsigned char * __restrict psLine);
1.4       misho     134: /*
                    135:  * io_LTrimStr() Remove left whitespaces from text string
                    136:  * @psLine = Text string
                    137:  * return: 0 nothing to do; !=0 Removed bytes
                    138: */
1.4.2.1 ! misho     139: inline int io_LTrimStr(unsigned char * __restrict psLine);
1.4       misho     140: /*
                    141:  * io_RTrimStr() Remove right whitespaces from text string
                    142:  * @psLine = Text string
                    143:  * return: 0 nothing to do; !=0 Removed bytes
                    144: */
1.4.2.1 ! misho     145: inline int io_RTrimStr(unsigned char * __restrict psLine);
1.4       misho     146: /*
                    147:  * io_TrimStr() Remove left and right whitespaces from text string
                    148:  * @psLine = Text string
                    149:  * return: 0 nothing to do; !=0 Removed bytes
                    150: */
1.4.2.1 ! misho     151: inline int io_TrimStr(unsigned char * __restrict psLine);
1.4       misho     152: /*
                    153:  * io_Char2Hex() Convert from Char string to Hex string
                    154:  * @psLine = Text string
                    155:  * @lineLen = Length of Text string
                    156:  * return: NULL nothing to do or error; !=0 Allocated new converted string(must be free)
                    157: */
                    158: inline char *io_Char2Hex(unsigned char *psLine, int lineLen);
                    159: /*
                    160:  * io_Hex2Char() Convert from Hex string to Char string
                    161:  * @psLine = Text string
                    162:  * @lineLen = Length of Text string
                    163:  * return: NULL nothing to do or error; !=0 Allocated new converted string(must be free)
                    164: */
                    165: inline char *io_Hex2Char(unsigned char *psLine, int lineLen);
                    166: 
                    167: /*
1.2       misho     168:  * ioURLGet() Parse and get data from input URL
                    169:  * @csURL = Input URL line
                    170:  * @url = Output parsed URL
                    171:  * return: 0 error format not find tech:// and return URL like path; 
                    172:                -1 error:: can`t read; >0 ok, up bits for known elements
                    173: */
                    174: int ioURLGet(const char *csURL, struct tagIOURL *url);
                    175: /*
                    176:  * ioURLGetValue() Get value from parsed URL
                    177:  * @url = Input parsed URL
                    178:  * @csAttr = Attribute for search
                    179:  * @psValue = Return value of attribute, if ==NULL only check for existence of attribute
                    180:  * @valLen = Size of psValue array
                    181:  * return: 0 error attribute not find; -1 error:: can`t read; >0 ok, find at position
                    182: */
                    183: int ioURLGetValue(struct tagIOURL *url, const char *csAttr, char * __restrict psValue, int valLen);
                    184: /*
                    185:  * ioURLGetFile() Get file from parsed URL
                    186:  * @url = Input parsed URL
                    187:  * @psValue = Return filename, if not specified file in url path, replace with /
                    188:  * @valLen = Size of psValue array
                    189:  * return: -1 error:: can`t read; 0 ok
                    190: */
                    191: int ioURLGetFile(struct tagIOURL *url, char * __restrict psValue, int valLen);
                    192: 
1.1       misho     193: 
                    194: #endif

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