Annotation of libaitio/inc/aitio.h, revision 1.1.1.1.2.5
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.5! misho 6: * $Id: aitio.h,v 1.1.1.1.2.4 2010/03/04 09:54:23 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.5! misho 86: * io_Path2File() Parse and make path/filename pair
! 87: * @csArgs = Input argument line
! 88: * @psPath = Output Path, if ==NULL path not returned
! 89: * @pathLen = Size of path array
! 90: * @psFile = Output File
! 91: * @fileLen = Size of file array
! 92: * return: 0 error format; -1 error:: can`t read; >0 ok, number of readed items
! 93: */
! 94: inline int io_Path2File(const char * __restrict csArgs, char * __restrict psPath, int pathLen,
! 95: char * __restrict psFile, int fileLen);
! 96: /*
1.1.1.1.2.4 misho 97: * io_MakeAV() Parse and make attribute/value pair
98: * @csArgs = Input argument line
99: * @csDelim = Delimiter for separate
100: * @psAttr = Output Attribute
1.1.1.1.2.5! misho 101: * @attrLen = Size of attribute array
1.1.1.1.2.4 misho 102: * @psValue = Output Value, if ==NULL this element not present value or not wanted for return
1.1.1.1.2.5! misho 103: * @valLen = Size of value array
1.1.1.1.2.4 misho 104: * return: 0 error format; -1 error:: can`t read; >0 ok, number of readed items
105: */
106: inline int io_MakeAV(const char * __restrict csArgs, const char *csDelim,
107: char * __restrict psAttr, int attrLen, char * __restrict psValue, int valLen);
108: /*
109: * io_SizeArray() Parse and calculate size of array
110: * @csArgs = Input arguments line
111: * @csDelim = Delimiter(s) for separate
112: * return: 0 error format; -1 error:: can`t read; >0 ok, number of items
113: */
114: inline int io_SizeArray(const char *csArgs, const char *csDelim);
115: /*
1.1.1.1.2.2 misho 116: * io_MakeArray() Parse and make array of arguments values
1.1.1.1.2.3 misho 117: * @psArgs = Input arguments line
1.1.1.1.2.2 misho 118: * @csDelim = Delimiter(s) for separate
1.1.1.1.2.3 misho 119: * @args = Output array of arguments ... (must be free() after procced function!)
1.1.1.1.2.2 misho 120: * @nargs = Requested count of arguments
121: * return: 0 error format; -1 error:: can`t read; >0 ok, number of readed items
122: */
1.1.1.1.2.4 misho 123: inline int io_MakeArray(char * __restrict psArgs, const char *csDelim,
124: char *** __restrict args, int nargs);
1.1.1.1.2.2 misho 125:
126: /*
1.1.1.1.2.1 misho 127: * ioURLGet() Parse and get data from input URL
128: * @csURL = Input URL line
129: * @url = Output parsed URL
130: * return: 0 error format not find tech:// and return URL like path;
131: -1 error:: can`t read; >0 ok, up bits for known elements
132: */
133: int ioURLGet(const char *csURL, struct tagIOURL *url);
1.1.1.1.2.4 misho 134: /*
135: * ioURLGetValue() Get value from parsed URL
136: * @url = Input parsed URL
137: * @csAttr = Attribute for search
138: * @psValue = Return value of attribute, if ==NULL only check for existence of attribute
139: * @valLen = Size of psValue array
140: * return: 0 error attribute not find; -1 error:: can`t read; >0 ok, find at position
141: */
142: int ioURLGetValue(struct tagIOURL *url, const char *csAttr, char * __restrict psValue, int valLen);
1.1.1.1.2.5! misho 143: /*
! 144: * ioURLGetFile() Get file from parsed URL
! 145: * @url = Input parsed URL
! 146: * @psValue = Return filename, if not specified file in url path, replace with /
! 147: * @valLen = Size of psValue array
! 148: * return: -1 error:: can`t read; 0 ok
! 149: */
! 150: int ioURLGetFile(struct tagIOURL *url, char * __restrict psValue, int valLen);
1.1.1.1.2.1 misho 151:
1.1 misho 152:
153: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>