--- libaitwww/inc/aitwww.h 2012/03/08 23:40:21 1.1 +++ libaitwww/inc/aitwww.h 2012/03/15 01:59:37 1.3 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitwww.h,v 1.1 2012/03/08 23:40:21 misho Exp $ +* $Id: aitwww.h,v 1.3 2012/03/15 01:59:37 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -47,6 +47,47 @@ SUCH DAMAGE. #define __AITWWW_H +#include +#include +#include + + +/* URL staff ... */ + +typedef struct _tagURLItem { + int vallen; + char *value; +} url_Item_t; + +struct tagIOURL { + unsigned char url_line[BUFSIZ]; + + url_Item_t url_tech; + url_Item_t url_user; + url_Item_t url_pass; + url_Item_t url_host; + url_Item_t url_port; + url_Item_t url_path; + url_Item_t url_args; + + char *url_reserved; +}; + +struct tagReqXML { + unsigned char xml_line[BUFSIZ]; + + url_Item_t xml_namespace; + union { + url_Item_t container; + url_Item_t path; + } xml_node; + url_Item_t xml_data; + url_Item_t xml_attribute; + url_Item_t xml_value; +}; + +/* CGI variables */ + struct tagCGI { char *cgi_name; char *cgi_value; @@ -70,7 +111,15 @@ struct tagMIME { SLIST_ENTRY(tagMIME) mime_node; }; +typedef int (*list_cb_t)(struct tagCGI *, void *); + +// www_GetErrno() Get error code of last operation +inline int www_GetErrno(); +// www_GetError() Get error text of last operation +inline const char *www_GetError(); + + /* * www_initCGI() - Init CGI program * @@ -125,6 +174,15 @@ int www_addValue(cgi_t * __restrict cgi, const char *n * return: -1 error, 0 not found or 1 deleted ok */ int www_delPair(cgi_t * __restrict cgi, const char *name); +/* + * www_listPairs() - Walk over CGI session variables + * + * @cgi = Cgi session + * @func = If !=NULL call function for each element + * @arg = Optional argument pass through callback + * return: -1 error or >-1 number of elements + */ +inline int www_listPairs(cgi_t * __restrict cgi, list_cb_t func, void *arg); /* * www_header() - Output initial html header @@ -156,6 +214,36 @@ inline void www_freeAttributes(cgi_t ** __restrict att * return: NULL not found or !=NULL attribute value */ inline const char *www_getAttribute(cgi_t * __restrict attr, const char *name); + + +/* + * www_URLGet() - Parse and get data from input URL + * + * @csURL = Input URL line + * @url = Output parsed URL + * return: 0 error format not find tech:// and return URL like path; + * -1 error:: can`t read; >0 ok, up bits for known elements + */ +int www_URLGet(const char *csURL, struct tagIOURL *url); +/* + * www_URLGetFile() - Get file from parsed URL + * + * @url = Input parsed URL + * @psValue = Return filename, if not specified file in url path, replace with / + * @valLen = Size of psValue array + * return: -1 error:: can`t read; 0 ok + */ +int www_URLGetFile(struct tagIOURL *url, char * __restrict psValue, int valLen); + +/* + * www_XMLGet() - 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 www_XMLGet(const char *csXML, struct tagReqXML *xml); #endif