Annotation of libaitio/inc/aitio.h, revision 1.1.1.1.2.4
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.1.1.1.2.4! misho 6: * $Id: aitio.h,v 1.1.1.1.2.3 2010/03/04 08:10:57 misho Exp $
1.1 misho 7: *
8: *************************************************************************/
9: #ifndef __AITIO_H
10: #define __AITIO_H
11:
12:
1.1.1.1.2.1 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.1 misho 32: // io_GetErrno() Get error code of last operation
33: inline int io_GetErrno();
34: // io_GetError() Get error text of last operation
35: inline const char *io_GetError();
36:
37:
38: /*
39: * ioPromptRead() Read data from input h[0] with prompt to output h[1]
40: * @h = file handles h[0] = input, h[1] = output, if NULL use stdin, stdout
41: * @csPrompt = Prompt before input, may be NULL
42: * @psData = Readed data
43: * @dataLen = Length of data
44: * return: 0 EOF; -1 error:: can`t read; >0 count of readed chars
45: */
46: int ioPromptRead(int *h, const char *csPrompt, char * __restrict psData, int dataLen);
47: /*
48: * ioPromptPassword() Read password from input h[0] with prompt to output h[1]
49: * @h = file handles h[0] = input, h[1] = output, if NULL use stdin, stdout
50: * @csPrompt = Prompt before input, may be NULL
51: * @psPass = Readed password
52: * @passLen = Length of password
53: * @confirm = Confirm password, 0 - get password, !=0 Ask for confirmation
54: * return: 0 EOF; -1 error:: can`t read; >0 count of readed chars
55: */
56: int ioPromptPassword(int *h, const char *csPrompt, char * __restrict psPass, int passLen, int confirm);
57:
58: /*
59: * ioRegexVerify() Function for verify data match in regex expression
60: * @csRegex = Regulare expression pattern
61: * @csData = Data for check and verify
62: * @startPos = Return start positions
63: * @endPos = Return end positions
64: * return: NULL not match or error; !=NULL begin of matched data
65: */
66: const char *ioRegexVerify(const char *csRegex, const char *csData, int *startPos, int *endPos);
67: /*
68: * ioRegexGet() Function for get data match in regex expression
69: * @csRegex = Regulare expression pattern
70: * @csData = Data from get
71: * @psString = Returned string if match
72: * @strLen = Length of string
73: * return: 0 not match; >0 count of returned chars
74: */
75: int ioRegexGet(const char *csRegex, const char *csData, char * __restrict psString, int strLen);
76: /*
77: * ioRegexReplace() Function for replace data match in regex expression with newdata
78: * @csRegex = Regulare expression pattern
79: * @csData = Source data
80: * @csNew = Data for replace
81: * return: NULL not match or error; !=NULL allocated new string, must be free after use!
82: */
83: char *ioRegexReplace(const char *csRegex, const char *csData, const char *csNew);
84:
1.1.1.1.2.1 misho 85: /*
1.1.1.1.2.4! misho 86: * io_MakeAV() Parse and make attribute/value pair
! 87: * @csArgs = Input argument line
! 88: * @csDelim = Delimiter for separate
! 89: * @psAttr = Output Attribute
! 90: * @psValue = Output Value, if ==NULL this element not present value or not wanted for return
! 91: * return: 0 error format; -1 error:: can`t read; >0 ok, number of readed items
! 92: */
! 93: inline int io_MakeAV(const char * __restrict csArgs, const char *csDelim,
! 94: char * __restrict psAttr, int attrLen, char * __restrict psValue, int valLen);
! 95: /*
! 96: * io_SizeArray() Parse and calculate size of array
! 97: * @csArgs = Input arguments line
! 98: * @csDelim = Delimiter(s) for separate
! 99: * return: 0 error format; -1 error:: can`t read; >0 ok, number of items
! 100: */
! 101: inline int io_SizeArray(const char *csArgs, const char *csDelim);
! 102: /*
1.1.1.1.2.2 misho 103: * io_MakeArray() Parse and make array of arguments values
1.1.1.1.2.3 misho 104: * @psArgs = Input arguments line
1.1.1.1.2.2 misho 105: * @csDelim = Delimiter(s) for separate
1.1.1.1.2.3 misho 106: * @args = Output array of arguments ... (must be free() after procced function!)
1.1.1.1.2.2 misho 107: * @nargs = Requested count of arguments
108: * return: 0 error format; -1 error:: can`t read; >0 ok, number of readed items
109: */
1.1.1.1.2.4! misho 110: inline int io_MakeArray(char * __restrict psArgs, const char *csDelim,
! 111: char *** __restrict args, int nargs);
1.1.1.1.2.2 misho 112:
113: /*
1.1.1.1.2.1 misho 114: * ioURLGet() Parse and get data from input URL
115: * @csURL = Input URL line
116: * @url = Output parsed URL
117: * return: 0 error format not find tech:// and return URL like path;
118: -1 error:: can`t read; >0 ok, up bits for known elements
119: */
120: int ioURLGet(const char *csURL, struct tagIOURL *url);
1.1.1.1.2.4! misho 121: /*
! 122: * ioURLGetValue() Get value from parsed URL
! 123: * @url = Input parsed URL
! 124: * @csAttr = Attribute for search
! 125: * @psValue = Return value of attribute, if ==NULL only check for existence of attribute
! 126: * @valLen = Size of psValue array
! 127: * return: 0 error attribute not find; -1 error:: can`t read; >0 ok, find at position
! 128: */
! 129: int ioURLGetValue(struct tagIOURL *url, const char *csAttr, char * __restrict psValue, int valLen);
1.1.1.1.2.1 misho 130:
1.1 misho 131:
132: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>