char ch;
int decode_codepage(char *cp_name){    char *s, *d;    struct cp_list_item *cpi;    int codepage = -1;    char ch;    CPINFO cpinfo;    if (cp_name && *cp_name)	for (cpi = cp_list; cpi->name; cpi++) {	    s = cp_name;	    d = cpi->name;	    for (;;) {		while (*s && !isalnum(*s) && *s != ':')		    s++;		while (*d && !isalnum(*d) && *d != ':')		    d++;		if (*s == 0) {		    codepage = cpi->codepage;		    if (codepage == CP_UTF8)			goto break_break;		    if (codepage == 0) {			codepage = 65536 + (cpi - cp_list);			goto break_break;		    }		    if (GetCPInfo(codepage, &cpinfo) != 0)			goto break_break;		}		if (islower(*s))		    ch = toupper(*s++);		else		    ch = *s++;		if (ch != *d++)		    break;	    }	}    if (cp_name && *cp_name) {	d = cp_name;	if (strnicmp(d, "cp", 2) == 0)	    d += 2;	if (strnicmp(d, "ibm", 3) == 0)	    d += 3;	for (s = d; *s >= '0' && *s <= '9'; s++);	if (*s == 0 && s != d)	    codepage = atoi(d);	       /* CP999 or IBM999 */	if (codepage == CP_ACP)	    codepage = GetACP();	if (codepage == CP_OEMCP)	    codepage = GetOEMCP();	if (codepage > 65535)	    codepage = -2;    }  break_break:;    if (codepage != -1) {	if (codepage != CP_UTF8 && codepage < 65536) {	    if (GetCPInfo(codepage, &cpinfo) == 0) {		codepage = -2;	    } else if (cpinfo.MaxCharSize > 1)		codepage = -3;	}    }    if (codepage == -1 && *cp_name)	codepage = -2;    return codepage;}