--- libaitwww/inc/aitwww.h 2012/08/06 12:02:05 1.4.2.3 +++ libaitwww/inc/aitwww.h 2013/05/26 20:30:42 1.5.4.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitwww.h,v 1.4.2.3 2012/08/06 12:02:05 misho Exp $ +* $Id: aitwww.h,v 1.5.4.2 2013/05/26 20:30:42 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 +Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -50,7 +50,7 @@ SUCH DAMAGE. #include #include #include -#include +#include /* URL staff ... */ @@ -61,17 +61,17 @@ typedef struct _tagURLItem { } url_Item_t; struct tagIOURL { - unsigned char url_line[BUFSIZ]; + ait_val_t url_line; - 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; + ait_val_t url_tech; + ait_val_t url_user; + ait_val_t url_pass; + ait_val_t url_host; + ait_val_t url_port; + ait_val_t url_path; + ait_val_t url_args; - char *url_reserved; + unsigned char *url_reserved; }; struct tagReqXML { @@ -116,9 +116,9 @@ typedef int (*list_cb_t)(struct tagCGI *, void *); // www_GetErrno() Get error code of last operation -inline int www_GetErrno(); +int www_GetErrno(); // www_GetError() Get error text of last operation -inline const char *www_GetError(); +const char *www_GetError(); /* @@ -158,7 +158,7 @@ cgi_t *www_parseMultiPart(const char *str, int ctlen, * @name = Name of cgi variable * 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 * @@ -184,7 +184,7 @@ int www_delPair(cgi_t * __restrict cgi, const char *na * @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); +int www_listPairs(cgi_t * __restrict cgi, list_cb_t func, void *arg); /* * www_header() - Output initial html header @@ -192,7 +192,7 @@ inline int www_listPairs(cgi_t * __restrict cgi, list_ * @output = file handle * return: <1 error or >0 writed bytes */ -inline int www_header(FILE *output); +int www_header(FILE *output); /* * www_parseAttributes() - Parse attributes @@ -200,7 +200,7 @@ inline int www_header(FILE *output); * @ct = Content type * return: NULL error or !=NULL attributes */ -inline cgi_t *www_parseAttributes(const char **ct); +cgi_t *www_parseAttributes(const char **ct); /* * www_getAttribute() - Get Attribute from attribute session * @@ -208,7 +208,7 @@ inline cgi_t *www_parseAttributes(const char **ct); * @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); +ait_val_t *www_getAttribute(cgi_t * __restrict cgi, const char *name); /* @@ -232,7 +232,7 @@ int www_cmptype(const char *ct, const char *type); * * @str = query string * @delim = delimiter - * return: NULL error or AV pair, must be io_free() after use! + * return: NULL error or AV pair, must be e_free() after use! */ ait_val_t *www_getpair(char ** __restrict str, const char *delim); /* @@ -241,24 +241,38 @@ ait_val_t *www_getpair(char ** __restrict str, const c * @str = string * return: digit */ -inline char www_x2c(const char *str); +char www_x2c(const char *str); /* * www_unescape() - Unescape/decode WWW query string to host string * * @str = string * return: none */ -inline void www_unescape(char * __restrict str); +void www_unescape(char * __restrict str); /* * www_undot() - Undotted and clean WWW query filename * * @pname = query filename - * return: =NULL error or !=NULL allocated valid filename, after use you must call io_freeVar() + * return: =NULL error or !=NULL allocated valid filename, after use you must call ait_freeVar() */ 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 * * @csURL = Input URL line @@ -266,16 +280,15 @@ ait_val_t *www_undot(const char * __restrict pname); * 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); +int www_URLGet(const char *csURL, struct tagIOURL * __restrict 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 + * @value = Return filename, if not specified file in url path, replace with / + * return: -1 error, 0 filename from path, 1 filename or 2 not specified filename */ -int www_URLGetFile(struct tagIOURL *url, char * __restrict psValue, int valLen); +int www_URLGetFile(struct tagIOURL * __restrict url, ait_val_t * __restrict value); /* * www_XMLGet() - Parse and get data from input XML request string @@ -286,6 +299,21 @@ int www_URLGetFile(struct tagIOURL *url, char * __rest * return: 0 error format incorrect, -1 error:: can`t read; >0 ok readed elements bits */ 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