/* get a EBCDIC string in upper/lower case, find out characters in lower/upper case separated by a special character, modifiy original string, returns length of resulting string  */
static int sclp_switch_cases(unsigned char *buf, int count)
/* get a EBCDIC string in upper/lower case, find out characters in lower/upper case separated by a special character, modifiy original string, returns length of resulting string  */
static int sclp_switch_cases(unsigned char *buf, int count)
{
	unsigned char *ip, *op;
	int toggle;
	toggle = 0;
	ip = op = buf;
	while (count-- > 0) {
		if (*ip == CASE_DELIMITER) {
			if (count && ip[1] == CASE_DELIMITER) {
				*op++ = *ip++;
				count--;
			} else
				toggle = ~toggle;
			ip++;
		} else
			if (toggle)
				if (sclp_tty_tolower)
					*op++ = _ebc_toupper[(int) *ip++];
				else
					*op++ = _ebc_tolower[(int) *ip++];
			else
				*op++ = *ip++;
	}
	return op - buf;
}