|
version 1.2, 2010/03/09 09:26:27
|
version 1.3.6.2, 2010/09/28 07:38:19
|
|
Line 16
|
Line 16
|
| * return: 0 error format not find tech:// and return URL like path; |
* return: 0 error format not find tech:// and return URL like path; |
| -1 error:: can`t read; >0 ok, up bits for known elements |
-1 error:: can`t read; >0 ok, up bits for known elements |
| */ |
*/ |
| int ioURLGet(const char *csURL, struct tagIOURL *url) | int |
| | ioURLGet(const char *csURL, struct tagIOURL *url) |
| { |
{ |
| char *pos, *at, *cl, *sl; |
char *pos, *at, *cl, *sl; |
| int ret = 0; |
int ret = 0; |
|
Line 115 int ioURLGet(const char *csURL, struct tagIOURL *url)
|
Line 116 int ioURLGet(const char *csURL, struct tagIOURL *url)
|
| } |
} |
| |
|
| /* |
/* |
| * io_MakeArray() Parse and make array of arguments values | * io_MakeArray() Parse and make array of arguments values ... |
| * @psArgs = Input arguments line | * (input string will be modified! and output array must be free) |
| | * @psArgs = Input arguments line, after execute string is modified!!! |
| * @csDelim = Delimiter(s) for separate |
* @csDelim = Delimiter(s) for separate |
| * @args = Output array of arguments ... (must be free() after procced function!) |
* @args = Output array of arguments ... (must be free() after procced function!) |
| * @nargs = Requested count of arguments | * @nargs = Maximum requested count of arguments from input string psArgs |
| * return: 0 error format; -1 error:: can`t read; >0 ok, number of readed items |
* return: 0 error format; -1 error:: can`t read; >0 ok, number of readed items |
| */ |
*/ |
| inline int io_MakeArray(char * __restrict psArgs, const char *csDelim, char *** __restrict args, int nargs) | inline int |
| | io_MakeArray(char * __restrict psArgs, const char *csDelim, char *** __restrict args, int nargs) |
| { |
{ |
| char **app; |
char **app; |
| register int i; |
register int i; |
|
Line 145 inline int io_MakeArray(char * __restrict psArgs, cons
|
Line 148 inline int io_MakeArray(char * __restrict psArgs, cons
|
| * @csDelim = Delimiter(s) for separate |
* @csDelim = Delimiter(s) for separate |
| * return: 0 error format; -1 error:: can`t read; >0 ok, number of items |
* return: 0 error format; -1 error:: can`t read; >0 ok, number of items |
| */ |
*/ |
| inline int io_SizeArray(const char *csArgs, const char *csDelim) | inline int |
| | io_SizeArray(const char *csArgs, const char *csDelim) |
| { |
{ |
| register int res; |
register int res; |
| char *pos; |
char *pos; |
|
Line 166 inline int io_SizeArray(const char *csArgs, const char
|
Line 170 inline int io_SizeArray(const char *csArgs, const char
|
| * @valLen = Size of value array |
* @valLen = Size of value array |
| * return: 0 error format; -1 error:: can`t read; >0 ok, number of readed items |
* return: 0 error format; -1 error:: can`t read; >0 ok, number of readed items |
| */ |
*/ |
| inline int io_MakeAV(const char * __restrict csArgs, const char *csDelim, | inline int |
| | io_MakeAV(const char * __restrict csArgs, const char *csDelim, |
| char * __restrict psAttr, int attrLen, char * __restrict psValue, int valLen) |
char * __restrict psAttr, int attrLen, char * __restrict psValue, int valLen) |
| { |
{ |
| register int ret = 0; |
register int ret = 0; |
|
Line 209 inline int io_MakeAV(const char * __restrict csArgs, c
|
Line 214 inline int io_MakeAV(const char * __restrict csArgs, c
|
| * @fileLen = Size of file array |
* @fileLen = Size of file array |
| * return: 0 error format; -1 error:: can`t read; >0 ok, number of readed items |
* return: 0 error format; -1 error:: can`t read; >0 ok, number of readed items |
| */ |
*/ |
| inline int io_Path2File(const char * __restrict csArgs, char * __restrict psPath, int pathLen, | inline int |
| | io_Path2File(const char * __restrict csArgs, char * __restrict psPath, int pathLen, |
| char * __restrict psFile, int fileLen) |
char * __restrict psFile, int fileLen) |
| { |
{ |
| char *pos, *psBuf; |
char *pos, *psBuf; |
|
Line 251 inline int io_Path2File(const char * __restrict csArgs
|
Line 257 inline int io_Path2File(const char * __restrict csArgs
|
| * @valLen = Size of psValue array |
* @valLen = Size of psValue array |
| * return: 0 error attribute not find; -1 error:: can`t read; >0 ok, find at position |
* return: 0 error attribute not find; -1 error:: can`t read; >0 ok, find at position |
| */ |
*/ |
| int ioURLGetValue(struct tagIOURL *url, const char *csAttr, char * __restrict psValue, int valLen) | int |
| | ioURLGetValue(struct tagIOURL *url, const char *csAttr, char * __restrict psValue, int valLen) |
| { |
{ |
| register int i, ret = 0; |
register int i, ret = 0; |
| char szBuf[BUFSIZ], **items, szElem[2][BUFSIZ]; |
char szBuf[BUFSIZ], **items, szElem[2][BUFSIZ]; |
|
Line 287 int ioURLGetValue(struct tagIOURL *url, const char *cs
|
Line 294 int ioURLGetValue(struct tagIOURL *url, const char *cs
|
| * @valLen = Size of psValue array |
* @valLen = Size of psValue array |
| * return: -1 error:: can`t read; 0 ok |
* return: -1 error:: can`t read; 0 ok |
| */ |
*/ |
| int ioURLGetFile(struct tagIOURL *url, char * __restrict psValue, int valLen) | int |
| | ioURLGetFile(struct tagIOURL *url, char * __restrict psValue, int valLen) |
| { |
{ |
| if (!url || !psValue || !valLen) |
if (!url || !psValue || !valLen) |
| return -1; |
return -1; |
|
Line 299 int ioURLGetFile(struct tagIOURL *url, char * __restri
|
Line 307 int ioURLGetFile(struct tagIOURL *url, char * __restri
|
| if (!*psValue) |
if (!*psValue) |
| strlcpy(psValue, "/", valLen); |
strlcpy(psValue, "/", valLen); |
| return 0; |
return 0; |
| |
} |
| |
|
| |
// ------------------------------------------ |
| |
|
| |
/* |
| |
* ioXMLGet() Parse and get data from input XML request string [ns:]container[|attribute[=value]][?data] |
| |
* @csXML = Input XML request line |
| |
* @xml = Output parsed XML request |
| |
* return: 0 error format incorrect, -1 error:: can`t read; >0 ok readed elements bits |
| |
*/ |
| |
int |
| |
ioXMLGet(const char *csXML, struct tagReqXML *xml) |
| |
{ |
| |
char *pos, *p, *end; |
| |
int ret = 0; |
| |
|
| |
if (!csXML || !xml) |
| |
return -1; |
| |
else |
| |
memset(xml, 0, sizeof *xml); |
| |
|
| |
strlcpy((char*) xml->xml_line, csXML, BUFSIZ); |
| |
// if namespace present |
| |
if ((pos = strchr((char*) xml->xml_line, ':'))) { |
| |
xml->xml_namespace.value = (char*) xml->xml_line; |
| |
xml->xml_namespace.vallen = pos - (char*) xml->xml_line; |
| |
if (xml->xml_namespace.vallen) |
| |
ret |= 1; |
| |
*pos++ = 0; |
| |
} else |
| |
pos = (char*) xml->xml_line; |
| |
// if container is path |
| |
if (*pos == '/') { |
| |
xml->xml_node.path.value = pos; |
| |
xml->xml_node.path.vallen = strlen(pos); |
| |
if (!xml->xml_node.path.vallen) |
| |
ret = 0; |
| |
else |
| |
ret |= 32; |
| |
return ret; |
| |
} else { |
| |
// container |
| |
xml->xml_node.container.value = pos; |
| |
xml->xml_node.container.vallen = strlen(pos); |
| |
if (!xml->xml_node.container.vallen) |
| |
return 0; |
| |
else |
| |
ret |= 2; |
| |
} |
| |
end = strchr(pos, '?'); |
| |
// if attribute present |
| |
if (pos && (p = strchr(pos, '|')) && (!end || end > p)) { |
| |
pos = p; |
| |
*pos++ = 0; |
| |
xml->xml_node.container.vallen = strlen(xml->xml_node.container.value); |
| |
if (!xml->xml_node.container.vallen) |
| |
return 0; |
| |
|
| |
xml->xml_attribute.value = pos; |
| |
xml->xml_attribute.vallen = strlen(pos); |
| |
if (xml->xml_attribute.vallen) |
| |
ret |= 4; |
| |
} |
| |
// if value present |
| |
if (pos && (p = strchr(pos, '=')) && (!end || end > p)) { |
| |
if (!(ret & 4)) |
| |
return 0; |
| |
else |
| |
pos = p; |
| |
*pos++ = 0; |
| |
xml->xml_attribute.vallen = strlen(xml->xml_attribute.value); |
| |
if (!xml->xml_attribute.vallen) |
| |
return 0; |
| |
|
| |
xml->xml_value.value = pos; |
| |
xml->xml_value.vallen = strlen(pos); |
| |
if (xml->xml_value.vallen) |
| |
ret |= 8; |
| |
} |
| |
// if data present |
| |
if (pos && end) { |
| |
if (ret < 2) |
| |
return 0; |
| |
else |
| |
pos = end; |
| |
*pos++ = 0; |
| |
if (ret & 8) { |
| |
xml->xml_value.vallen = strlen(xml->xml_value.value); |
| |
if (!xml->xml_value.vallen) |
| |
return 0; |
| |
} else if (ret & 4) { |
| |
xml->xml_attribute.vallen = strlen(xml->xml_attribute.value); |
| |
if (!xml->xml_attribute.vallen) |
| |
return 0; |
| |
} else if (ret & 2) { |
| |
xml->xml_node.container.vallen = strlen(xml->xml_node.container.value); |
| |
if (!xml->xml_node.container.vallen) |
| |
return 0; |
| |
} else |
| |
return 0; |
| |
|
| |
xml->xml_data.value = pos; |
| |
xml->xml_data.vallen = strlen(pos); |
| |
if (xml->xml_data.vallen) |
| |
ret |= 16; |
| |
} |
| |
|
| |
return ret; |
| } |
} |