char tmp[128];
load_generic(lcd)    XLCd lcd;{    XLCdGenericPart *gen = XLC_GENERIC_PART(lcd);    char **value;    int num;    unsigned long l;    int i;    int M,ii;    gen->codeset_num = 0;    /***** wc_encoding_mask *****/    _XlcGetResource(lcd, "XLC_XLOCALE", "wc_encoding_mask", &value, &num);    if (num > 0) {	if (string_to_ulong(value[0], &l) == False) 	    goto err;	gen->wc_encode_mask = l;    }    /***** wc_shift_bits *****/    _XlcGetResource(lcd, "XLC_XLOCALE", "wc_shift_bits", &value, &num);    if (num > 0)	gen->wc_shift_bits = atoi(value[0]);    if (gen->wc_shift_bits < 1)	gen->wc_shift_bits = 8;#ifndef X_NOT_STDC_ENV    /***** use_stdc_env *****/    _XlcGetResource(lcd, "XLC_XLOCALE", "use_stdc_env", &value, &num);    if (num > 0 && !_XlcCompareISOLatin1(value[0], "True"))	gen->use_stdc_env = True;    else	gen->use_stdc_env = False;    /***** force_convert_to_mb *****/    _XlcGetResource(lcd, "XLC_XLOCALE", "force_convert_to_mb", &value, &num);    if (num > 0 && !_XlcCompareISOLatin1(value[0], "True"))	gen->force_convert_to_mb = True;    else	gen->force_convert_to_mb = False;#endif        for (i = 0; ; i++) {	CodeSetRec *codeset = NULL;	char cs[16];	char name[BUFSIZ];	sprintf(cs, "cs%d", i);	/***** codeset.side *****/	sprintf(name, "%s.%s", cs , "side");	_XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);	if (num > 0) {	    char *tmp;	    if (codeset == NULL && (codeset = add_codeset(gen)) == NULL)		goto err;            /* 3.4.1 side */            if( !_XlcNCompareISOLatin1(value[0], "none", 4) ){                codeset->side =  XlcNONE ;            } else            if( !_XlcNCompareISOLatin1(value[0], "GL", 2) ){                codeset->side =  XlcGL ;            } else {                codeset->side =  XlcGR ;            }	    tmp = strrchr(value[0], ':');	    if (tmp != NULL && !_XlcCompareISOLatin1(tmp + 1, "Default")) {		if (codeset->side == XlcGR)		    gen->initial_state_GR = codeset;		else		    gen->initial_state_GL = codeset;	    }	}	/***** codeset.length *****/	sprintf(name, "%s.%s", cs , "length");	_XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);	if (num > 0) {	    if (codeset == NULL && (codeset = add_codeset(gen)) == NULL)		goto err;	    codeset->length = atoi(value[0]);	    if (codeset->length < 1)		codeset->length = 1;	}	/***** codeset.mb_encoding *****/	sprintf(name, "%s.%s", cs, "mb_encoding");	_XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);	if (num > 0) {	    static struct { 		char *str;		int type;	    } shifts[] = {		{"<SS>", E_SS},		{"<LSL>", E_LSL},		{"<LSR>", E_LSR},		0	    };	    int j;	    if (codeset == NULL && (codeset = add_codeset(gen)) == NULL)		goto err;	    for ( ; num-- > 0; value++) {		char encoding[256];		char *tmp = *value;		int type = E_SS;    /* for BC */		for (j = 0; shifts[j].str; j++) {		    if (!_XlcNCompareISOLatin1(tmp, shifts[j].str,					       strlen(shifts[j].str))) {			type = shifts[j].type;			tmp += strlen(shifts[j].str);			break;		    }		}		if (string_to_encoding(tmp, encoding) == False)			goto err;		add_parse_list(gen, type, encoding, codeset);	    }	}	/***** codeset.wc_encoding *****/	sprintf(name, "%s.%s", cs, "wc_encoding");	_XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);	if (num > 0) {	    if (codeset == NULL && (codeset = add_codeset(gen)) == NULL)		goto err;	    if (string_to_ulong(value[0], &l) == False) 		goto err;	    codeset->wc_encoding = l;	}  	/***** codeset.ct_encoding *****/	sprintf(name, "%s.%s", cs, "ct_encoding");	_XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);	if (num > 0) {	    XlcCharSet charset;	    char *encoding;	    if (codeset == NULL && (codeset = add_codeset(gen)) == NULL)		goto err;	    for ( ; num-- > 0; value++) {		string_to_encoding(*value, name);		charset = NULL;		if ((encoding = strchr(name, ':')) &&		    (encoding = strchr(encoding + 1, ':'))) {		    *encoding++ = '\0';		    charset = _XlcAddCT(name, encoding);		}		if (charset == NULL) {		    charset = _XlcGetCharSet(name);		    if (charset == NULL &&			(charset = _XlcCreateDefaultCharSet(name, ""))) {			charset->side = codeset->side;			charset->char_size = codeset->length;			_XlcAddCharSet(charset);		    }		}		if (charset) {		    if (add_charset(codeset, charset) == False)			goto err;		}	    }	}	if (codeset == NULL)	    break;	codeset->cs_num = i;        /* For VW/UDC */        /***** 3.4.2 byteM (1 <= M <= length)*****/        for(M=1; M-1  < codeset->length; M++){            long start,end;            ByteInfo tmpb;            sprintf(name,"%s.%s%d",cs,"byte",M);            _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);            if( M == 1){                if(num < 1) {                    codeset->byteM = NULL ;                    break ;                }                codeset->byteM =                    (ByteInfoListRec *)Xmalloc(                         (codeset->length)*sizeof(ByteInfoListRec));                if(codeset->byteM == NULL){                    goto err;                }            }            if(num > 0){                _XlcDbg_printValue(name,value,num);                (codeset->byteM)[M-1].M = M;                (codeset->byteM)[M-1].byteinfo_num = num;                (codeset->byteM)[M-1].byteinfo =                    (ByteInfo)Xmalloc( num * sizeof(ByteInfoRec));                for(ii = 0 ; ii < num ; ii++){                    char tmp[128];                    tmpb = (codeset->byteM)[M-1].byteinfo ;                    /* default 0x00 - 0xff */                    sscanf(value[ii],"\\x%lx,\\x%lx",&start,&end);                    tmpb[ii].start = (unsigned char)start;                    tmpb[ii].end  = (unsigned char)end;                }            }            /* .... */        }        /***** codeset.mb_conversion *****/        sprintf(name, "%s.%s", cs, "mb_conversion");        _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);        if (num > 0) {                _XlcDbg_printValue(name,value,num);                codeset->mbconv = Xmalloc(sizeof(ConversionRec));                codeset->mbconv->convlist =                _XlcParse_scopemaps(value[0],&(codeset->mbconv->conv_num));                dmpscope("mb_conv",codeset->mbconv->convlist,                        codeset->mbconv->conv_num);                /* [\x%x,\x%x]->\x%x,... */        }        /***** codeset.ct_conversion *****/        sprintf(name, "%s.%s", cs, "ct_conversion");        _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);        if (num > 0) {                _XlcDbg_printValue(name,value,num);                codeset->ctconv = Xmalloc(sizeof(ConversionRec));                codeset->ctconv->convlist =                _XlcParse_scopemaps(value[0],&(codeset->ctconv->conv_num));                dmpscope("ctconv",codeset->ctconv->convlist,                        codeset->ctconv->conv_num);                /* [\x%x,\x%x]->\x%x,... */        }        /***** codeset.ct_conversion_file *****/        sprintf(name, "%s.%s", cs, "ct_conversion_file");        _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);        if (num > 0) {                _XlcDbg_printValue(name,value,num);                /* [\x%x,\x%x]->\x%x,... */        }        /***** codeset.ct_extended_segment *****/        sprintf(name, "%s.%s", cs, "ct_extended_segment");        _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);        if (num > 0) {                _XlcDbg_printValue(name,value,num);                codeset->ctextseg = create_ctextseg(value,num);                /* [\x%x,\x%x]->\x%x,... */        }        /* For VW/UDC end */    }	     read_charset_define(lcd,gen);       /* For VW/UDC */    read_segmentconversion(lcd,gen);    /* For VW/UDC */    return True;err:    free_charset(lcd);    return False;}