version 1.1.1.1, 2012/03/08 23:40:21
|
version 1.4, 2012/08/01 00:40:40
|
Line 47 SUCH DAMAGE.
|
Line 47 SUCH DAMAGE.
|
#define __AITWWW_H |
#define __AITWWW_H |
|
|
|
|
|
#include <sys/types.h> |
|
#include <sys/queue.h> |
|
#include <sys/uio.h> |
|
#include <aitio.h> |
|
|
|
|
|
/* 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 { |
struct tagCGI { |
char *cgi_name; | ait_val_t *cgi_name; |
char *cgi_value; | ait_val_t *cgi_value; |
|
|
SLIST_ENTRY(tagCGI) cgi_node; |
SLIST_ENTRY(tagCGI) cgi_node; |
}; |
}; |
Line 70 struct tagMIME {
|
Line 112 struct tagMIME {
|
SLIST_ENTRY(tagMIME) mime_node; |
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 |
* www_initCGI() - Init CGI program |
* |
* |
Line 84 cgi_t *www_initCGI(void);
|
Line 134 cgi_t *www_initCGI(void);
|
* return: none |
* return: none |
*/ |
*/ |
void www_closeCGI(cgi_t ** __restrict cgi); |
void www_closeCGI(cgi_t ** __restrict cgi); |
|
#define www_freeAttributes www_closeCGI |
/* |
/* |
* www_parseQuery() - Parse CGI query string |
* www_parseQuery() - Parse CGI query string |
* |
* |
Line 125 int www_addValue(cgi_t * __restrict cgi, const char *n
|
Line 176 int www_addValue(cgi_t * __restrict cgi, const char *n
|
* return: -1 error, 0 not found or 1 deleted ok |
* return: -1 error, 0 not found or 1 deleted ok |
*/ |
*/ |
int www_delPair(cgi_t * __restrict cgi, const char *name); |
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 |
* www_header() - Output initial html header |
Line 142 inline int www_header(FILE *output);
|
Line 202 inline int www_header(FILE *output);
|
*/ |
*/ |
inline cgi_t *www_parseAttributes(const char **ct); |
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 |
* return: none |
*/ |
*/ |
inline void www_freeAttributes(cgi_t ** __restrict attr); | inline void www_unescape(char * __restrict str); |
| |
| |
/* |
/* |
* www_getAttribute() - Get attribute by name | * www_URLGet() - Parse and get data from input URL |
* |
* |
* @attr = Attributes | * @csURL = Input URL line |
* @name = Name of attribute | * @url = Output parsed URL |
* return: NULL not found or !=NULL attribute value | * return: 0 error format not find tech:// and return URL like path; |
| * -1 error:: can`t read; >0 ok, up bits for known elements |
*/ |
*/ |
inline const char *www_getAttribute(cgi_t * __restrict attr, const char *name); | 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 |
#endif |