|
version 1.2.2.1, 2012/03/10 15:00:45
|
version 1.6, 2013/05/30 09:25:35
|
|
Line 12 terms:
|
Line 12 terms:
|
| All of the documentation and software included in the ELWIX and AITNET |
All of the documentation and software included in the ELWIX and AITNET |
| Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
| |
|
| Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 | Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 |
| by Michael Pounov <misho@elwix.org>. All rights reserved. |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
| |
|
| Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
|
Line 50 SUCH DAMAGE.
|
Line 50 SUCH DAMAGE.
|
| #include <sys/types.h> |
#include <sys/types.h> |
| #include <sys/queue.h> |
#include <sys/queue.h> |
| #include <sys/uio.h> |
#include <sys/uio.h> |
| |
#include <elwix.h> |
| |
|
| |
|
| /* URL staff ... */ |
/* URL staff ... */ |
|
Line 60 typedef struct _tagURLItem {
|
Line 61 typedef struct _tagURLItem {
|
| } url_Item_t; |
} url_Item_t; |
| |
|
| struct tagIOURL { |
struct tagIOURL { |
| unsigned char url_line[BUFSIZ]; | ait_val_t url_line; |
| |
|
| url_Item_t url_tech; | ait_val_t url_tech; |
| url_Item_t url_user; | ait_val_t url_user; |
| url_Item_t url_pass; | ait_val_t url_pass; |
| url_Item_t url_host; | ait_val_t url_host; |
| url_Item_t url_port; | ait_val_t url_port; |
| url_Item_t url_path; | ait_val_t url_path; |
| url_Item_t url_args; | ait_val_t url_args; |
| |
|
| char *url_reserved; | unsigned char *url_reserved; |
| }; |
}; |
| |
|
| struct tagReqXML { |
struct tagReqXML { |
|
Line 89 struct tagReqXML {
|
Line 90 struct tagReqXML {
|
| /* CGI variables */ |
/* 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 115 typedef int (*list_cb_t)(struct tagCGI *, void *);
|
Line 116 typedef int (*list_cb_t)(struct tagCGI *, void *);
|
| |
|
| |
|
| // www_GetErrno() Get error code of last operation |
// www_GetErrno() Get error code of last operation |
| inline int www_GetErrno(); | int www_GetErrno(); |
| // www_GetError() Get error text of last operation |
// www_GetError() Get error text of last operation |
| inline const char *www_GetError(); | const char *www_GetError(); |
| |
|
| |
|
| /* |
/* |
|
Line 133 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 156 cgi_t *www_parseMultiPart(const char *str, int ctlen,
|
Line 158 cgi_t *www_parseMultiPart(const char *str, int ctlen,
|
| * @name = Name of cgi variable |
* @name = Name of cgi variable |
| * return: NULL not found or !=NULL value |
* return: NULL not found or !=NULL value |
| */ |
*/ |
| inline const char *www_getValue(cgi_t * __restrict cgi, const char *name); | const char *www_getValue(cgi_t * __restrict cgi, const char *name); |
| /* |
/* |
| * www_addValue() - Add new or update if exists CGI variable |
* www_addValue() - Add new or update if exists CGI variable |
| * |
* |
|
Line 182 int www_delPair(cgi_t * __restrict cgi, const char *na
|
Line 184 int www_delPair(cgi_t * __restrict cgi, const char *na
|
| * @arg = Optional argument pass through callback |
* @arg = Optional argument pass through callback |
| * return: -1 error or >-1 number of elements |
* return: -1 error or >-1 number of elements |
| */ |
*/ |
| inline int www_listPairs(cgi_t * __restrict cgi, list_cb_t func, void *arg); | 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 190 inline int www_listPairs(cgi_t * __restrict cgi, list_
|
Line 192 inline int www_listPairs(cgi_t * __restrict cgi, list_
|
| * @output = file handle |
* @output = file handle |
| * return: <1 error or >0 writed bytes |
* return: <1 error or >0 writed bytes |
| */ |
*/ |
| inline int www_header(FILE *output); | int www_header(FILE *output); |
| |
|
| /* |
/* |
| * www_parseAttributes() - Parse attributes |
* www_parseAttributes() - Parse attributes |
|
Line 198 inline int www_header(FILE *output);
|
Line 200 inline int www_header(FILE *output);
|
| * @ct = Content type |
* @ct = Content type |
| * return: NULL error or !=NULL attributes |
* return: NULL error or !=NULL attributes |
| */ |
*/ |
| inline cgi_t *www_parseAttributes(const char **ct); | 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 |
| | */ |
| | 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 e_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 |
| | */ |
| | 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); | void www_unescape(char * __restrict str); |
| /* |
/* |
| * www_getAttribute() - Get attribute by name | * www_undot() - Undotted and clean WWW query filename |
| * |
* |
| * @attr = Attributes | * @pname = query filename |
| * @name = Name of attribute | * return: =NULL error or !=NULL allocated valid filename, after use you must call ait_freeVar() |
| * return: NULL not found or !=NULL attribute value | |
| */ |
*/ |
| inline const char *www_getAttribute(cgi_t * __restrict attr, const char *name); | ait_val_t *www_undot(const char * __restrict pname); |
| |
|
| |
|
| /* |
/* |
| |
* www_URLInit() - Init URL structure and free old one |
| |
* |
| |
* @url = Input URL |
| |
* return: -1 error or 0 ok |
| |
*/ |
| |
int www_URLInit(struct tagIOURL * __restrict url); |
| |
/* |
| |
* www_URLFree() - URL free structure |
| |
* |
| |
* @url = Input parsed URL |
| |
* return: none |
| |
*/ |
| |
void www_URLFree(struct tagIOURL * __restrict url); |
| |
/* |
| * www_URLGet() - Parse and get data from input URL |
* www_URLGet() - Parse and get data from input URL |
| * |
* |
| * @csURL = Input URL line |
* @csURL = Input URL line |
|
Line 224 inline const char *www_getAttribute(cgi_t * __restrict
|
Line 280 inline const char *www_getAttribute(cgi_t * __restrict
|
| * 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 www_URLGet(const char *csURL, struct tagIOURL *url); | int www_URLGet(const char *csURL, struct tagIOURL * __restrict url); |
| /* |
/* |
| * www_URLGetFile() - Get file from parsed URL |
* www_URLGetFile() - Get file from parsed URL |
| * |
* |
| * @url = Input parsed URL |
* @url = Input parsed URL |
| * @psValue = Return filename, if not specified file in url path, replace with / | * @value = Return filename, if not specified file in url path, replace with / |
| * @valLen = Size of psValue array | * return: -1 error, 0 filename from path, 1 filename or 2 not specified filename |
| * return: -1 error:: can`t read; 0 ok | |
| */ |
*/ |
| int www_URLGetFile(struct tagIOURL *url, char * __restrict psValue, int valLen); | int www_URLGetFile(struct tagIOURL * __restrict url, ait_val_t * __restrict value); |
| |
|
| /* |
/* |
| * 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 |
* www_XMLGet() - Parse and get data from input XML request string |
| * [ns:]container[|attribute[=value]][?data] |
* [ns:]container[|attribute[=value]][?data] |
| * |
* |
|
Line 257 inline int www_Path2File(const char * __restrict csArg
|
Line 299 inline int www_Path2File(const char * __restrict csArg
|
| * return: 0 error format incorrect, -1 error:: can`t read; >0 ok readed elements bits |
* return: 0 error format incorrect, -1 error:: can`t read; >0 ok readed elements bits |
| */ |
*/ |
| int www_XMLGet(const char *csXML, struct tagReqXML *xml); |
int www_XMLGet(const char *csXML, struct tagReqXML *xml); |
| |
|
| |
/* |
| |
* www_b64encode() - Base64 encode function |
| |
* |
| |
* @src = source data |
| |
* return: NULL error or !=NULL encoded variable, after use call ait_freeVar() |
| |
*/ |
| |
ait_val_t *www_b64encode(ait_val_t * __restrict src); |
| |
/* |
| |
* www_b64decode() - Base64 decode function |
| |
* |
| |
* @src = source encoded data |
| |
* return: NULL error or !=NULL decoded variable, after use call ait_freeVar() |
| |
*/ |
| |
ait_val_t *www_b64decode(ait_val_t * __restrict src); |
| |
|
| |
|
| #endif |
#endif |