Esempio n. 1
0
XLCd
_XlcCreateLC(
    const char *name,
    XLCdMethods methods)
{
    XLCdPublicMethods pub_methods = (XLCdPublicMethods) methods;
    XLCd lcd;

    lcd = (*pub_methods->pub.create)(name, methods);
    if (lcd == NULL)
        return (XLCd) NULL;

    if (lcd->core->name == NULL) {
        lcd->core->name = (char*) Xmalloc(strlen(name) + 1);
        if (lcd->core->name == NULL)
            goto err;
        strcpy(lcd->core->name, name);
    }

    if (lcd->methods == NULL)
        lcd->methods = methods;

    if ((*pub_methods->pub.initialize)(lcd) == False)
        goto err;

    return lcd;

err:
    _XlcDestroyLC(lcd);

    return (XLCd) NULL;
}
Esempio n. 2
0
XLCd
_XlcUtf8Loader(
    const char *name)
{
    XLCd lcd;

    lcd = _XlcCreateLC(name, _XlcGenericMethods);
    if (lcd == (XLCd) NULL)
	return lcd;

    /* The official IANA name for UTF-8 is "UTF-8" in upper case with a dash. */
    if (!XLC_PUBLIC_PART(lcd)->codeset ||
	(_XlcCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "UTF-8"))) {
	_XlcDestroyLC(lcd);
	return (XLCd) NULL;
    }

    _XlcAddUtf8LocaleConverters(lcd);
    _XlcAddUtf8Converters(lcd);

    return lcd;
}