static char poorman_vt100[] = "*#****o~**+++++-----++++|****L.";
static const char poorman_vt100[] = "*#****o~**+++++-----++++|****L.";
void init_ucs(Config *cfg, struct unicode_data *ucsdata){    int i, j;    int used_dtf = 0;    char tbuf[256];    for (i = 0; i < 256; i++)	tbuf[i] = i;    /* Decide on the Line and Font codepages */    ucsdata->line_codepage = decode_codepage(cfg->line_codepage);    if (ucsdata->font_codepage <= 0) { 	ucsdata->font_codepage=0; 	ucsdata->dbcs_screenfont=0;     }    if (cfg->vtmode == VT_OEMONLY) {	ucsdata->font_codepage = 437;	ucsdata->dbcs_screenfont = 0;	if (ucsdata->line_codepage <= 0)	    ucsdata->line_codepage = GetACP();    } else if (ucsdata->line_codepage <= 0)	ucsdata->line_codepage = ucsdata->font_codepage;    /* Collect screen font ucs table */    if (ucsdata->dbcs_screenfont || ucsdata->font_codepage == 0) {	get_unitab(ucsdata->font_codepage, ucsdata->unitab_font, 2);	for (i = 128; i < 256; i++)	    ucsdata->unitab_font[i] = (WCHAR) (ATTR_ACP + i);    } else {	get_unitab(ucsdata->font_codepage, ucsdata->unitab_font, 1);	/* CP437 fonts are often broken ... */	if (ucsdata->font_codepage == 437)	    ucsdata->unitab_font[0] = ucsdata->unitab_font[255] = 0xFFFF;    }    if (cfg->vtmode == VT_XWINDOWS)	memcpy(ucsdata->unitab_font + 1, unitab_xterm_std,	       sizeof(unitab_xterm_std));    /* Collect OEMCP ucs table */    get_unitab(CP_OEMCP, ucsdata->unitab_oemcp, 1);    /* Collect CP437 ucs table for SCO acs */    if (cfg->vtmode == VT_OEMANSI || cfg->vtmode == VT_XWINDOWS)	memcpy(ucsdata->unitab_scoacs, ucsdata->unitab_oemcp,	       sizeof(ucsdata->unitab_scoacs));    else	get_unitab(437, ucsdata->unitab_scoacs, 1);    /* Collect line set ucs table */    if (ucsdata->line_codepage == ucsdata->font_codepage &&	(ucsdata->dbcs_screenfont ||	 cfg->vtmode == VT_POORMAN || ucsdata->font_codepage==0)) {	/* For DBCS and POOR fonts force direct to font */	used_dtf = 1;	for (i = 0; i < 32; i++)	    ucsdata->unitab_line[i] = (WCHAR) i;	for (i = 32; i < 256; i++)	    ucsdata->unitab_line[i] = (WCHAR) (ATTR_ACP + i);	ucsdata->unitab_line[127] = (WCHAR) 127;    } else {	get_unitab(ucsdata->line_codepage, ucsdata->unitab_line, 0);    }#if 0    debug(	  ("Line cp%d, Font cp%d%s\n", ucsdata->line_codepage,	   ucsdata->font_codepage, ucsdata->dbcs_screenfont ? " DBCS" : ""));    for (i = 0; i < 256; i += 16) {	for (j = 0; j < 16; j++) {	    debug(("%04x%s", ucsdata->unitab_line[i + j], j == 15 ? "" : ","));	}	debug(("\n"));    }#endif    /* VT100 graphics - NB: Broken for non-ascii CP's */    memcpy(ucsdata->unitab_xterm, ucsdata->unitab_line,	   sizeof(ucsdata->unitab_xterm));    memcpy(ucsdata->unitab_xterm + '`', unitab_xterm_std,	   sizeof(unitab_xterm_std));    ucsdata->unitab_xterm['_'] = ' ';    /* Generate UCS ->line page table. */    if (ucsdata->uni_tbl) {	for (i = 0; i < 256; i++)	    if (ucsdata->uni_tbl[i])		sfree(ucsdata->uni_tbl[i]);	sfree(ucsdata->uni_tbl);	ucsdata->uni_tbl = 0;    }    if (!used_dtf) {	for (i = 0; i < 256; i++) {	    if (DIRECT_CHAR(ucsdata->unitab_line[i]))		continue;	    if (DIRECT_FONT(ucsdata->unitab_line[i]))		continue;	    if (!ucsdata->uni_tbl) {		ucsdata->uni_tbl = smalloc(256 * sizeof(char *));		memset(ucsdata->uni_tbl, 0, 256 * sizeof(char *));	    }	    j = ((ucsdata->unitab_line[i] >> 8) & 0xFF);	    if (!ucsdata->uni_tbl[j]) {		ucsdata->uni_tbl[j] = smalloc(256 * sizeof(char));		memset(ucsdata->uni_tbl[j], 0, 256 * sizeof(char));	    }	    ucsdata->uni_tbl[j][ucsdata->unitab_line[i] & 0xFF] = i;	}    }    /* Find the line control characters. */    for (i = 0; i < 256; i++)	if (ucsdata->unitab_line[i] < ' '	    || (ucsdata->unitab_line[i] >= 0x7F && 		ucsdata->unitab_line[i] < 0xA0))	    ucsdata->unitab_ctrl[i] = i;	else	    ucsdata->unitab_ctrl[i] = 0xFF;    /* Generate line->screen direct conversion links. */    if (cfg->vtmode == VT_OEMANSI || cfg->vtmode == VT_XWINDOWS)	link_font(ucsdata->unitab_scoacs, ucsdata->unitab_oemcp, ATTR_OEMCP);    link_font(ucsdata->unitab_line, ucsdata->unitab_font, ATTR_ACP);    link_font(ucsdata->unitab_scoacs, ucsdata->unitab_font, ATTR_ACP);    link_font(ucsdata->unitab_xterm, ucsdata->unitab_font, ATTR_ACP);    if (cfg->vtmode == VT_OEMANSI || cfg->vtmode == VT_XWINDOWS) {	link_font(ucsdata->unitab_line, ucsdata->unitab_oemcp, ATTR_OEMCP);	link_font(ucsdata->unitab_xterm, ucsdata->unitab_oemcp, ATTR_OEMCP);    }    if (ucsdata->dbcs_screenfont &&	ucsdata->font_codepage != ucsdata->line_codepage) {	/* F***ing Microsoft fonts, Japanese and Korean codepage fonts	 * have a currency symbol at 0x5C but their unicode value is 	 * still given as U+005C not the correct U+00A5. */	ucsdata->unitab_line['\\'] = ATTR_OEMCP + '\\';    }    /* Last chance, if !unicode then try poorman links. */    if (cfg->vtmode != VT_UNICODE) {	static char poorman_scoacs[] = 	    "CueaaaaceeeiiiAAE**ooouuyOUc$YPsaiounNao?++**!<>###||||++||++++++--|-+||++--|-+----++++++++##||#aBTPEsyt******EN=+><++-=... n2* ";	static char poorman_latin1[] =	    " !cL.Y|S\"Ca<--R~o+23'u|.,1o>///?AAAAAAACEEEEIIIIDNOOOOOxOUUUUYPBaaaaaaaceeeeiiiionooooo/ouuuuypy";	static char poorman_vt100[] = "*#****o~**+++++-----++++|****L.";	for (i = 160; i < 256; i++)	    if (!DIRECT_FONT(ucsdata->unitab_line[i]) &&		ucsdata->unitab_line[i] >= 160 &&		ucsdata->unitab_line[i] < 256) {		ucsdata->unitab_line[i] =		    (WCHAR) (ATTR_ACP +			     poorman_latin1[ucsdata->unitab_line[i] - 160]);	    }	for (i = 96; i < 127; i++)	    if (!DIRECT_FONT(ucsdata->unitab_xterm[i]))		ucsdata->unitab_xterm[i] =	    (WCHAR) (ATTR_ACP + poorman_vt100[i - 96]);	for(i=128;i<256;i++) 	    if (!DIRECT_FONT(ucsdata->unitab_scoacs[i]))		ucsdata->unitab_scoacs[i] = 		    (WCHAR) (ATTR_ACP + poorman_scoacs[i - 128]);    }}