--- libaitwww/src/tools.c 2012/03/09 12:33:07 1.1.1.1.2.1 +++ libaitwww/src/tools.c 2012/07/31 11:56:16 1.2.6.1 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: tools.c,v 1.1.1.1.2.1 2012/03/09 12:33:07 misho Exp $ +* $Id: tools.c,v 1.2.6.1 2012/07/31 11:56:16 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -44,9 +44,15 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF TH SUCH DAMAGE. */ #include "global.h" -#include "tools.h" +/* + * 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) { @@ -67,6 +73,13 @@ www_cmp(const char *ct, const char *s) return strncasecmp(ct, s, sc - ct); } +/* + * 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) { @@ -85,6 +98,13 @@ www_cmptype(const char *ct, const char *type) return strncasecmp(ct, type, sl - ct); } +/* + * www_getpair() - Get AV pair from WWW query string + * + * @str = query string + * @delim = delimiter + * return: NULL error or AV pair, must be free() after use! + */ char * www_getpair(char ** __restrict str, const char *delim) { @@ -100,10 +120,8 @@ www_getpair(char ** __restrict str, const char *delim) if (!s) { LOGERR; return NULL; - } else { - strncpy(s, *str, cx); - s[cx] = 0; - } + } else + strlcpy(s, *str, cx + 1); *str = tr; if (**str) @@ -112,6 +130,12 @@ www_getpair(char ** __restrict str, const char *delim) return s; } +/* + * www_x2c() - Hex from string to digit + * + * @str = string + * return: digit + */ inline char www_x2c(const char *str) { @@ -126,6 +150,12 @@ www_x2c(const char *str) return digit; } +/* + * www_unescape() - Unescape/decode WWW query string to host string + * + * @str = string + * return: none + */ inline void www_unescape(char * __restrict str) {