--- libaitwww/inc/aitwww.h 2012/03/10 15:00:45 1.2.2.1 +++ libaitwww/inc/aitwww.h 2012/08/06 12:02:05 1.4.2.3 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitwww.h,v 1.2.2.1 2012/03/10 15:00:45 misho Exp $ +* $Id: aitwww.h,v 1.4.2.3 2012/08/06 12:02:05 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -50,6 +50,7 @@ SUCH DAMAGE. #include #include #include +#include /* URL staff ... */ @@ -89,8 +90,8 @@ struct tagReqXML { /* CGI variables */ struct tagCGI { - char *cgi_name; - char *cgi_value; + ait_val_t *cgi_name; + ait_val_t *cgi_value; SLIST_ENTRY(tagCGI) cgi_node; }; @@ -133,6 +134,7 @@ cgi_t *www_initCGI(void); * return: none */ void www_closeCGI(cgi_t ** __restrict cgi); +#define www_freeAttributes www_closeCGI /* * www_parseQuery() - Parse CGI query string * @@ -200,20 +202,60 @@ inline int www_header(FILE *output); */ inline cgi_t *www_parseAttributes(const char **ct); /* - * www_freeAttributes() - Free attributes + * www_getAttribute() - Get Attribute from attribute session * - * @attr = Attributes + * @cgi = Inited attribute session + * @name = Name of attribute variable + * return: NULL not found or !=NULL value + */ +inline ait_val_t *www_getAttribute(cgi_t * __restrict cgi, const char *name); + + +/* + * www_cmp() - Compare two string + * + * @ct = content text from www + * @s = string + * return: 0 are equal or !0 are different + */ +int www_cmp(const char *ct, const char *s); +/* + * www_cmptype() - Compare context type + * + * @ct = content text from www + * @type = content type + * return: 0 are equal or !0 are different + */ +int www_cmptype(const char *ct, const char *type); +/* + * www_getpair() - Get AV pair from WWW query string + * + * @str = query string + * @delim = delimiter + * return: NULL error or AV pair, must be io_free() after use! + */ +ait_val_t *www_getpair(char ** __restrict str, const char *delim); +/* + * www_x2c() - Hex from string to digit + * + * @str = string + * return: digit + */ +inline char www_x2c(const char *str); +/* + * www_unescape() - Unescape/decode WWW query string to host string + * + * @str = string * return: none */ -inline void www_freeAttributes(cgi_t ** __restrict attr); +inline void www_unescape(char * __restrict str); /* - * www_getAttribute() - Get attribute by name + * www_undot() - Undotted and clean WWW query filename * - * @attr = Attributes - * @name = Name of attribute - * return: NULL not found or !=NULL attribute value + * @pname = query filename + * return: =NULL error or !=NULL allocated valid filename, after use you must call io_freeVar() */ -inline const char *www_getAttribute(cgi_t * __restrict attr, const char *name); +ait_val_t *www_undot(const char * __restrict pname); /* @@ -234,19 +276,6 @@ int www_URLGet(const char *csURL, struct tagIOURL *url * return: -1 error:: can`t read; 0 ok */ int www_URLGetFile(struct tagIOURL *url, char * __restrict psValue, int valLen); - -/* - * www_Path2File() - Parse and make path/filename pair - * - * @csArgs = Input argument line - * @psPath = Output Path, if ==NULL path not returned - * @pathLen = Size of path array - * @psFile = Output File - * @fileLen = Size of file array - * return: 0 error format; -1 error:: can`t read; >0 ok, number of readed items - */ -inline int www_Path2File(const char * __restrict csArgs, char * __restrict psPath, - int pathLen, char * __restrict psFile, int fileLen); /* * www_XMLGet() - Parse and get data from input XML request string