X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=miscutil.c;h=831f3c5d60f2a2c51ada6c6343b5e3d719f9f66f;hp=499579f7f4b2eda4162174383f3d2be7cb512e2b;hb=34a6a841e529579e2be4457ea0d4cb1befbc840a;hpb=afa231b8e31bbf0489303df30d103db2d737cd18 diff --git a/miscutil.c b/miscutil.c index 499579f7..831f3c5d 100644 --- a/miscutil.c +++ b/miscutil.c @@ -242,7 +242,7 @@ void write_pid_file(const char *pid_file) * * Function : hash_string * - * Description : Take a string and compute a (hopefuly) unique numeric + * Description : Take a string and compute a (hopefully) unique numeric * integer value. This is useful to "switch" a string. * * Parameters : @@ -560,6 +560,43 @@ char *string_toupper(const char *string) } +/********************************************************************* + * + * Function : string_tolower + * + * Description : Produce a copy of string with all convertible + * characters converted to lowercase. + * + * Parameters : + * 1 : string = string to convert + * + * Returns : Lowercase copy of string if possible, + * NULL on out-of-memory or if string was NULL. + * + *********************************************************************/ +char *string_tolower(const char *string) +{ + char *result, *p; + const char *q; + + if (!string || ((result = (char *)zalloc(strlen(string) + 1)) == NULL)) + { + return NULL; + } + + q = string; + p = result; + + while (*q != '\0') + { + *p++ = (char)privoxy_tolower(*q++); + } + + return result; + +} + + /********************************************************************* * * Function : string_move @@ -596,7 +633,7 @@ void string_move(char *dst, char *src) * 1 : string = string to be duplicated * 2 : len = number of bytes to duplicate * - * Returns : pointer to copy, or NULL if failiure + * Returns : pointer to copy, or NULL if failure * *********************************************************************/ char *bindup(const char *string, size_t len)