--- libelwix/src/str.c 2013/01/17 10:05:35 1.1 +++ libelwix/src/str.c 2013/03/07 16:24:32 1.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: str.c,v 1.1 2013/01/17 10:05:35 misho Exp $ +* $Id: str.c,v 1.2 2013/03/07 16:24:32 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -383,3 +383,50 @@ str_Unquot(char * __restrict psLine) return 0; } +/* + * str_Upper() - Convert all lower characters to upper + * + * @psLine = Text string + * return: 0 nothing to do; !=0 converted chars + */ +inline int +str_Upper(char * __restrict psLine) +{ + char *s; + register int cx = 0; + + if (!psLine || !*psLine) + return 0; + + for (s = psLine; *s; s++) + if (islower(*s)) { + *s = toupper(*s); + cx++; + } + + return cx; +} + +/* + * str_Lower() - Convert all upper characters to lower + * + * @psLine = Text string + * return: 0 nothing to do; !=0 converted chars + */ +inline int +str_Lower(char * __restrict psLine) +{ + char *s; + register int cx = 0; + + if (!psLine || !*psLine) + return 0; + + for (s = psLine; *s; s++) + if (isupper(*s)) { + *s = tolower(*s); + cx++; + } + + return cx; +}