1
/* $Xorg: lcPublic.c,v 1.4 2000/12/12 12:44:05 coskrey Exp $ */
3
* Copyright 1992, 1993 by TOSHIBA Corp.
5
* Permission to use, copy, modify, and distribute this software and its
6
* documentation for any purpose and without fee is hereby granted, provided
7
* that the above copyright notice appear in all copies and that both that
8
* copyright notice and this permission notice appear in supporting
9
* documentation, and that the name of TOSHIBA not be used in advertising
10
* or publicity pertaining to distribution of the software without specific,
11
* written prior permission. TOSHIBA make no representations about the
12
* suitability of this software for any purpose. It is provided "as is"
13
* without express or implied warranty.
15
* TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
16
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
17
* TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
18
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
19
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
20
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
23
* Author: Katsuhisa Yano TOSHIBA Corp.
24
* mopi@osa.ilab.toshiba.co.jp
26
/* $XFree86: xc/lib/X11/lcPublic.c,v 1.11 2001/11/16 00:52:28 dawes Exp $ */
36
return XLC_PUBLIC(lcd, default_string);
39
static XLCd create (const char *name, XLCdMethods methods);
40
static Bool initialize (XLCd lcd);
41
static void destroy (XLCd lcd);
42
static char *get_values (XLCd lcd, XlcArgList args, int num_args);
44
static XLCdPublicMethodsRec publicMethods = {
47
_XlcDefaultMapModifiers,
50
_XrmDefaultInitParseInfo,
51
_XmbTextPropertyToTextList,
52
_XwcTextPropertyToTextList,
53
_Xutf8TextPropertyToTextList,
54
_XmbTextListToTextProperty,
55
_XwcTextListToTextProperty,
56
_Xutf8TextListToTextProperty,
72
XLCdMethods _XlcPublicMethods = (XLCdMethods) &publicMethods;
80
XLCdPublicMethods new;
82
lcd = (XLCd) Xmalloc(sizeof(XLCdRec));
85
bzero((char *) lcd, sizeof(XLCdRec));
87
lcd->core = (XLCdCore) Xmalloc(sizeof(XLCdPublicRec));
88
if (lcd->core == NULL)
90
bzero((char *) lcd->core, sizeof(XLCdPublicRec));
92
new = (XLCdPublicMethods) Xmalloc(sizeof(XLCdPublicMethodsRec));
95
memcpy(new,methods,sizeof(XLCdPublicMethodsRec));
96
lcd->methods = (XLCdMethods) new;
109
XLCdPublicPart *pub = XLC_PUBLIC_PART(lcd);
113
if(_XlcCreateLocaleDataBase(lcd) == NULL)
116
_XlcGetResource(lcd, "XLC_XLOCALE", "mb_cur_max", &values, &num);
118
pub->mb_cur_max = atoi(values[0]);
119
if (pub->mb_cur_max < 1)
124
_XlcGetResource(lcd, "XLC_XLOCALE", "state_depend_encoding", &values, &num);
125
if (num > 0 && !_XlcCompareISOLatin1(values[0], "True"))
126
pub->is_state_depend = True;
128
pub->is_state_depend = False;
130
_XlcGetResource(lcd, "XLC_XLOCALE", "encoding_name", &values, &num);
131
str = (num > 0) ? values[0] : "STRING";
132
pub->encoding_name = (char*) Xmalloc(strlen(str) + 1);
133
if (pub->encoding_name == NULL)
135
strcpy(pub->encoding_name, str);
144
XLCdMethods methods = lcd->methods;
145
XLCdMethods core = &publicMethods.core;
147
if (methods->close == NULL)
148
methods->close = core->close;
150
if (methods->map_modifiers == NULL)
151
methods->map_modifiers = core->map_modifiers;
153
if (methods->open_om == NULL)
154
#ifdef USE_DYNAMIC_LC
155
_XInitDefaultOM(lcd);
160
if (methods->open_im == NULL)
161
#ifdef USE_DYNAMIC_LC
162
_XInitDefaultIM(lcd);
167
if (methods->init_parse_info == NULL)
168
methods->init_parse_info = core->init_parse_info;
170
if (methods->mb_text_prop_to_list == NULL)
171
methods->mb_text_prop_to_list = core->mb_text_prop_to_list;
173
if (methods->wc_text_prop_to_list == NULL)
174
methods->wc_text_prop_to_list = core->wc_text_prop_to_list;
176
if (methods->utf8_text_prop_to_list == NULL)
177
methods->utf8_text_prop_to_list = core->utf8_text_prop_to_list;
179
if (methods->mb_text_list_to_prop == NULL)
180
methods->mb_text_list_to_prop = core->mb_text_list_to_prop;
182
if (methods->wc_text_list_to_prop == NULL)
183
methods->wc_text_list_to_prop = core->wc_text_list_to_prop;
185
if (methods->utf8_text_list_to_prop == NULL)
186
methods->utf8_text_list_to_prop = core->utf8_text_list_to_prop;
188
if (methods->wc_free_string_list == NULL)
189
methods->wc_free_string_list = core->wc_free_string_list;
191
if (methods->default_string == NULL)
192
methods->default_string = core->default_string;
201
XLCdPublicMethodsPart *methods = XLC_PUBLIC_METHODS(lcd);
202
XLCdPublicMethodsPart *pub_methods = &publicMethods.pub;
203
XLCdPublicPart *pub = XLC_PUBLIC_PART(lcd);
205
#if !defined(X_LOCALE)
209
char *_XlcMapOSLocaleName();
214
if (initialize_core(lcd) == False)
217
name = lcd->core->name;
218
#if !defined(X_LOCALE)
220
* _XlMapOSLocaleName will return the same string or a substring
221
* of name, so strlen(name) is okay
223
if ((len = strlen(name)) < sizeof sinamebuf)
226
siname = Xmalloc (len + 1);
229
name = _XlcMapOSLocaleName(name, siname);
231
/* _XlcResolveLocaleName will lookup the SI's name for the locale */
232
if (_XlcResolveLocaleName(name, pub) == 0) {
233
#if !defined(X_LOCALE)
234
if (siname != sinamebuf) Xfree (siname);
238
#if !defined(X_LOCALE)
239
if (siname != sinamebuf)
243
if (pub->default_string == NULL)
244
pub->default_string = "";
246
if (methods->get_values == NULL)
247
methods->get_values = pub_methods->get_values;
249
if (methods->get_resource == NULL)
250
methods->get_resource = pub_methods->get_resource;
252
return load_public(lcd);
261
Xfree(lcd->core->name);
275
XLCdPublicPart *pub = XLC_PUBLIC_PART(lcd);
277
_XlcDestroyLocaleDataBase(lcd);
281
if (pub->encoding_name)
282
Xfree(pub->encoding_name);
287
static XlcResource resources[] = {
288
{ XlcNCodeset, NULLQUARK, sizeof(char *),
289
XOffsetOf(XLCdPublicRec, pub.codeset), XlcGetMask },
290
{ XlcNDefaultString, NULLQUARK, sizeof(char *),
291
XOffsetOf(XLCdPublicRec, pub.default_string), XlcGetMask },
292
{ XlcNEncodingName, NULLQUARK, sizeof(char *),
293
XOffsetOf(XLCdPublicRec, pub.encoding_name), XlcGetMask },
294
{ XlcNLanguage, NULLQUARK, sizeof(char *),
295
XOffsetOf(XLCdPublicRec, pub.language), XlcGetMask },
296
{ XlcNMbCurMax, NULLQUARK, sizeof(int),
297
XOffsetOf(XLCdPublicRec, pub.mb_cur_max), XlcGetMask },
298
{ XlcNStateDependentEncoding, NULLQUARK, sizeof(Bool),
299
XOffsetOf(XLCdPublicRec, pub.is_state_depend), XlcGetMask },
300
{ XlcNTerritory, NULLQUARK, sizeof(char *),
301
XOffsetOf(XLCdPublicRec, pub.territory), XlcGetMask }
310
XLCdPublic pub = (XLCdPublic) lcd->core;
312
if (resources[0].xrm_name == NULLQUARK)
313
_XlcCompileResourceList(resources, XlcNumber(resources));
315
return _XlcGetValues((XPointer) pub, resources, XlcNumber(resources), args,
316
num_args, XlcGetMask);