From a0fa440dee24b4b39d30c1b04579691d42efba65 Mon Sep 17 00:00:00 2001 From: marha Date: Sat, 4 Sep 2010 16:22:11 +0000 Subject: libx11 git update 4/9/2010 --- libX11/src/xlibi18n/XDefaultIMIF.c | 2 +- libX11/src/xlibi18n/XDefaultOMIF.c | 2564 ++++++++++++++++++------------------ libX11/src/xlibi18n/XimTrInt.h | 170 +-- libX11/src/xlibi18n/XimTrX.h | 170 +-- libX11/src/xlibi18n/XimTrans.h | 272 ++-- libX11/src/xlibi18n/XimintP.h | 636 ++++----- libX11/src/xlibi18n/XlcDL.c | 1304 +++++++++--------- libX11/src/xlibi18n/XlcSL.c | 192 +-- libX11/src/xlibi18n/lcInit.c | 394 +++--- 9 files changed, 2852 insertions(+), 2852 deletions(-) (limited to 'libX11/src/xlibi18n') diff --git a/libX11/src/xlibi18n/XDefaultIMIF.c b/libX11/src/xlibi18n/XDefaultIMIF.c index c6f3f2e37..c7a2fe9d3 100644 --- a/libX11/src/xlibi18n/XDefaultIMIF.c +++ b/libX11/src/xlibi18n/XDefaultIMIF.c @@ -37,7 +37,7 @@ Sun Microsystems, Inc. or its licensors is granted. */ /* - * Copyright 2000 Sun Microsystems, Inc. All rights reserved. + * Copyright 2000 Oracle and/or its affiliates. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), diff --git a/libX11/src/xlibi18n/XDefaultOMIF.c b/libX11/src/xlibi18n/XDefaultOMIF.c index be9977d38..c7511e608 100644 --- a/libX11/src/xlibi18n/XDefaultOMIF.c +++ b/libX11/src/xlibi18n/XDefaultOMIF.c @@ -1,1282 +1,1282 @@ -/* -Copyright 1985, 1986, 1987, 1991, 1998 The Open Group - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: The above copyright notice and this -permission notice shall be included in all copies or substantial -portions of the Software. - - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE -EVEN IF ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES. - - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - -X Window System is a trademark of The Open Group - -OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF -logo, LBX, X Window System, and Xinerama are trademarks of the Open -Group. All other trademarks and registered trademarks mentioned herein -are the property of their respective owners. No right, title or -interest in or to any trademark, service mark, logo or trade name of -Sun Microsystems, Inc. or its licensors is granted. - -*/ -/* - * Copyright 2000 Sun Microsystems, Inc. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -#ifdef HAVE_CONFIG_H -#include -#endif -#include "Xlibint.h" -#include "Xlcint.h" -#include "XlcPublic.h" -#include -#include -#include - -#define MAXFONTS 100 - -#define XOM_GENERIC(om) (&((XOMGeneric) om)->gen) -#define XOC_GENERIC(font_set) (&((XOCGeneric) font_set)->gen) - -#define DefineLocalBuf char local_buf[BUFSIZ] -#define AllocLocalBuf(length) (length > BUFSIZ ? (char *)Xmalloc(length) : local_buf) -#define FreeLocalBuf(ptr) if (ptr != local_buf) Xfree(ptr) - -typedef struct _FontDataRec { - char *name; -} FontDataRec, *FontData; - -typedef struct _OMDataRec { - int font_data_count; - FontData font_data; -} OMDataRec, *OMData; - -typedef struct _XOMGenericPart { - OMData data; -} XOMGenericPart; - -typedef struct _XOMGenericRec { - XOMMethods methods; - XOMCoreRec core; - XOMGenericPart gen; -} XOMGenericRec, *XOMGeneric; - -typedef struct _FontSetRec { - int id; - int font_data_count; - FontData font_data; - char *font_name; - XFontStruct *info; - XFontStruct *font; -} FontSetRec, *FontSet; - -typedef struct _XOCGenericPart { - XlcConv wcs_to_cs; - FontSet font_set; -} XOCGenericPart; - -typedef struct _XOCGenericRec { - XOCMethods methods; - XOCCoreRec core; - XOCGenericPart gen; -} XOCGenericRec, *XOCGeneric; - -static Bool -init_fontset( - XOC oc) -{ - XOCGenericPart *gen; - FontSet font_set; - OMData data; - - data = XOM_GENERIC(oc->core.om)->data; - - font_set = (FontSet) Xmalloc(sizeof(FontSetRec)); - if (font_set == NULL) - return False; - bzero((char *) font_set, sizeof(FontSetRec)); - - gen = XOC_GENERIC(oc); - gen->font_set = font_set; - - font_set->font_data_count = data->font_data_count; - font_set->font_data = data->font_data; - - return True; -} - -static char * -get_prop_name( - Display *dpy, - XFontStruct *fs) -{ - unsigned long fp; - - if (XGetFontProperty(fs, XA_FONT, &fp)) - return XGetAtomName(dpy, fp); - - return (char *) NULL; -} - -static FontData -check_charset( - FontSet font_set, - char *font_name) -{ - FontData font_data; - char *last; - int count; - ssize_t length, name_len; - - name_len = strlen(font_name); - last = font_name + name_len; - - count = font_set->font_data_count; - font_data = font_set->font_data; - - for ( ; count-- > 0; font_data++) { - length = strlen(font_data->name); - - if (length > name_len) - return(NULL); - - if (_XlcCompareISOLatin1(last - length, font_data->name) == 0) - return font_data; - } - return (FontData) NULL; -} - -#if 0 /* Unused */ -static int -check_fontname( - XOC oc, - char *name) -{ - Display *dpy = oc->core.om->core.display; - XOCGenericPart *gen = XOC_GENERIC(oc); - FontData data; - FontSet font_set; - XFontStruct *fs_list; - char **fn_list, *fname, *prop_fname = NULL; - int list_num, i; - int list2_num; - char **fn2_list = NULL; - int found_num = 0; - - fn_list = XListFonts(dpy, name, MAXFONTS, &list_num); - if (fn_list == NULL) - return found_num; - - for (i = 0; i < list_num; i++) { - fname = fn_list[i]; - - font_set = gen->font_set; - - if ((data = check_charset(font_set, fname)) == NULL) { - if ((fn2_list = XListFontsWithInfo(dpy, name, MAXFONTS, - &list2_num, &fs_list)) - && (prop_fname = get_prop_name(dpy, fs_list)) - && (data = check_charset(font_set, prop_fname))) - fname = prop_fname; - } - if (data) { - font_set->font_name = (char *) Xmalloc(strlen(fname) + 1); - if (font_set->font_name) { - strcpy(font_set->font_name, fname); - found_num++; - } - } - if (fn2_list) { - XFreeFontInfo(fn2_list, fs_list, list2_num); - fn2_list = NULL; - if (prop_fname) { - Xfree(prop_fname); - prop_fname = NULL; - } - } - if (found_num == 1) - break; - } - XFreeFontNames(fn_list); - return found_num; -} -#endif - -static Bool -load_font( - XOC oc) -{ - Display *dpy = oc->core.om->core.display; - XOCGenericPart *gen = XOC_GENERIC(oc); - FontSet font_set = gen->font_set; - - if (font_set->font_name == NULL) - return False; - - if (font_set->font == NULL) { - font_set->font = XLoadQueryFont(dpy, font_set->font_name); - if (font_set->font == NULL) - return False; - } - return True; -} - -#if 0 -static Bool -load_font_info( - XOC oc) -{ - Display *dpy = oc->core.om->core.display; - XOCGenericPart *gen = XOC_GENERIC(oc); - FontSet font_set = gen->font_set; - char **fn_list; - int fn_num; - - if (font_set->font_name == NULL) - return False; - - if (font_set->info == NULL) { - fn_list = XListFontsWithInfo(dpy, font_set->font_name, 1, &fn_num, - &font_set->info); - if (font_set->info == NULL) - return False; - if (fn_num > 0) - font_set->info->fid = XLoadFont(dpy, font_set->font_name); - - if (fn_list) XFreeFontNames(fn_list); - } - return True; -} -#endif - -static void -set_fontset_extents( - XOC oc) -{ - XRectangle *ink = &oc->core.font_set_extents.max_ink_extent; - XRectangle *logical = &oc->core.font_set_extents.max_logical_extent; - XFontStruct **font_list, *font; - XCharStruct overall; - int logical_ascent, logical_descent; - - font_list = oc->core.font_info.font_struct_list; - font = *font_list++; - overall = font->max_bounds; - overall.lbearing = font->min_bounds.lbearing; - logical_ascent = font->ascent; - logical_descent = font->descent; - - ink->x = overall.lbearing; - ink->y = -(overall.ascent); - ink->width = overall.rbearing - overall.lbearing; - ink->height = overall.ascent + overall.descent; - - logical->x = 0; - logical->y = -(logical_ascent); - logical->width = overall.width; - logical->height = logical_ascent + logical_descent; -} - -static Bool -init_core_part( - XOC oc) -{ - XOCGenericPart *gen = XOC_GENERIC(oc); - FontSet font_set; - XFontStruct **font_struct_list; - char **font_name_list, *font_name_buf; - int count, length; - - font_set = gen->font_set; - count = length = 0; - - if (font_set->font_name != NULL) { - length += strlen(font_set->font_name) + 1; - count++; - } - if (count == 0) - return False; - - font_struct_list = (XFontStruct **) Xmalloc(sizeof(XFontStruct *)); - if (font_struct_list == NULL) - return False; - - font_name_list = (char **) Xmalloc(sizeof(char *)); - if (font_name_list == NULL) - goto err; - - font_name_buf = (char *) Xmalloc(length); - if (font_name_buf == NULL) - goto err; - - oc->core.font_info.num_font = 1; - oc->core.font_info.font_name_list = font_name_list; - oc->core.font_info.font_struct_list = font_struct_list; - - font_set = gen->font_set; - - if (font_set->font_name != NULL) { - font_set->id = 1; - if (font_set->font) - *font_struct_list++ = font_set->font; - else - *font_struct_list++ = font_set->info; - strcpy(font_name_buf, font_set->font_name); - Xfree(font_set->font_name); - *font_name_list++ = font_set->font_name = font_name_buf; - font_name_buf += strlen(font_name_buf) + 1; - } - - set_fontset_extents(oc); - - return True; - -err: - if (font_name_list) - Xfree(font_name_list); - Xfree(font_struct_list); - - return False; -} - -static char * -get_font_name( - XOC oc, - char *pattern) -{ - char **list, *name, *prop_name; - int count; - XFontStruct *fs; - Display *dpy = oc->core.om->core.display; - - list = XListFonts(dpy, pattern, 1, &count); - if (list != NULL) { - name = (char *) Xmalloc(strlen(*list) + 1); - if (name) - strcpy(name, *list); - - XFreeFontNames(list); - } else { - fs = XLoadQueryFont(dpy, pattern); - if (fs == NULL) return NULL; - - prop_name = get_prop_name(dpy, fs); - if (prop_name == NULL) return NULL; - - name = (char*) Xmalloc(strlen(prop_name) + 1); - if (name) - strcpy(name, prop_name); - - XFreeFont(dpy, fs); - } - return name; -} - -static int -parse_fontname( - XOC oc) -{ - XOCGenericPart *gen = XOC_GENERIC(oc); - FontSet font_set; - FontData font_data; - char *pattern, *last, buf[BUFSIZ]; - int font_data_count, found_num = 0; - ssize_t length; - int count, num_fields; - char *base_name, *font_name, **name_list, **cur_name_list; - char *charset_p = NULL; - Bool append_charset; - /* - append_charset flag should be set to True when the XLFD fontname - doesn't contain a chaset part. - */ - - name_list = _XParseBaseFontNameList(oc->core.base_name_list, &count); - if (name_list == NULL) - return -1; - cur_name_list = name_list; - - while (count-- > 0) { - pattern = *cur_name_list++; - if (pattern == NULL || *pattern == '\0') - continue; - - append_charset = False; - - if (strchr(pattern, '*') == NULL && - (font_name = get_font_name(oc, pattern))) { - - font_set = gen->font_set; - - font_data = check_charset(font_set, font_name); - if (font_data == NULL) { - Display *dpy = oc->core.om->core.display; - char **fn_list = NULL, *prop_fname = NULL; - int list_num; - XFontStruct *fs_list; - if ((fn_list = XListFontsWithInfo(dpy, font_name, - MAXFONTS, - &list_num, &fs_list)) - && (prop_fname = get_prop_name(dpy, fs_list)) - && (font_data = check_charset(font_set, prop_fname))) { - if (fn_list) { - XFreeFontInfo(fn_list, fs_list, list_num); - fn_list = NULL; - } - font_name = prop_fname; - } - } - if (font_data == NULL) - continue; - - font_set->font_name = (char *) Xmalloc(strlen(font_name) + 1); - if (font_set->font_name == NULL) { - Xfree(font_name); - goto err; - } - strcpy(font_set->font_name, font_name); - Xfree(font_name); - found_num++; - goto found; - } -/* -1266793 -Limit the length of the string copy to prevent stack corruption. - strcpy(buf, pattern); -*/ - strncpy(buf, pattern, BUFSIZ); - buf[BUFSIZ-1] = '\0'; - length = strlen(buf); - last = buf + length - 1; - - for (num_fields = 0, base_name = buf; *base_name != '\0'; base_name++) - if (*base_name == '-') num_fields++; - if (strchr(pattern, '*') == NULL) { - if (num_fields == 12) { - append_charset = True; - *++last = '-'; - last++; - } else - continue; - } else { - if (num_fields == 13 || num_fields == 14) { - /* - * There are 14 fields in an XLFD name -- make certain the - * charset (& encoding) is placed in the correct field. - */ - append_charset = True; - last = strrchr (buf, '-'); - if (num_fields == 14) { - *last = '\0'; - last = strrchr (buf, '-'); - } - last++; - } else if (*last == '*') { - append_charset = True; - if (length > 3 && *(last-3) == '-' && *(last-2) == '*' - && *(last-1) == '-') { - last -= 2; - } - *++last = '-'; - last++; - } else { - last = strrchr (buf, '-'); - charset_p = last; - charset_p = strrchr (buf, '-'); - while (*(--charset_p) != '-'); - charset_p++; - } - } - - font_set = gen->font_set; - - font_data = font_set->font_data; - font_data_count = font_set->font_data_count; - for ( ; font_data_count-- > 0; font_data++) { - if (append_charset) - { -/* -1266793 -Limit the length of the string copy to prevent stack corruption. - strcpy(last, font_data->name); -*/ - strncpy(last, font_data->name, BUFSIZ - length); - buf[BUFSIZ-1] = '\0'; - } - else { - if (_XlcCompareISOLatin1(charset_p, - font_data->name)) { - continue; - } - } - if ((font_set->font_name = get_font_name(oc, buf))) - break; - } - if (font_set->font_name != NULL) { - found_num++; - goto found; - } - } - found: - base_name = (char *) Xmalloc(strlen(oc->core.base_name_list) + 1); - if (base_name == NULL) - goto err; - - strcpy(base_name, oc->core.base_name_list); - oc->core.base_name_list = base_name; - - XFreeStringList(name_list); - - return found_num; -err: - XFreeStringList(name_list); - - return -1; -} - -static Bool -set_missing_list( - XOC oc) -{ - XOCGenericPart *gen = XOC_GENERIC(oc); - FontSet font_set; - char **charset_list, *charset_buf; - int count, length; - - font_set = gen->font_set; - count = length = 0; - - if (!font_set->info && !font_set->font) { - length += strlen(font_set->font_data->name) + 1; - count++; - } - - if (count == 0) - return True; - - charset_list = (char **) Xmalloc(sizeof(char *)); - if (charset_list == NULL) - return False; - - charset_buf = (char *) Xmalloc(length); - if (charset_buf == NULL) { - Xfree(charset_list); - return False; - } - - oc->core.missing_list.charset_list = charset_list; - - font_set = gen->font_set; - - if (!font_set->info && !font_set->font) { - strcpy(charset_buf, font_set->font_data->name); - *charset_list++ = charset_buf; - charset_buf += strlen(charset_buf) + 1; - } - return True; -} - -static Bool -create_fontset( - XOC oc) -{ - int found_num; - - if (init_fontset(oc) == False) - return False; - - found_num = parse_fontname(oc); - if (found_num <= 0) { - if (found_num == 0) - set_missing_list(oc); - return False; - } - - if (load_font(oc) == False) - return False; - - if (init_core_part(oc) == False) - return False; - - if (set_missing_list(oc) == False) - return False; - - return True; -} - -static void -destroy_oc( - XOC oc) -{ - Display *dpy = oc->core.om->core.display; - XOCGenericPart *gen = XOC_GENERIC(oc); - XFontStruct **font_list, *font; - - if (gen->font_set) - Xfree(gen->font_set); - - if (oc->core.base_name_list) - Xfree(oc->core.base_name_list); - - if (oc->core.font_info.font_name_list) - XFreeStringList(oc->core.font_info.font_name_list); - - if ((font_list = oc->core.font_info.font_struct_list)) { - if ((font = *font_list)) { - if (font->fid) - XFreeFont(dpy, font); - else - XFreeFontInfo(NULL, font, 1); - } - Xfree(oc->core.font_info.font_struct_list); - } - - if (oc->core.missing_list.charset_list) - XFreeStringList(oc->core.missing_list.charset_list); - -#ifdef notdef - if (oc->core.res_name) - Xfree(oc->core.res_name); - if (oc->core.res_class) - Xfree(oc->core.res_class); -#endif - - Xfree(oc); -} - -static char * -set_oc_values( - XOC oc, - XlcArgList args, - int num_args) -{ - if (oc->core.resources == NULL) - return NULL; - - return _XlcSetValues((XPointer) oc, oc->core.resources, - oc->core.num_resources, args, num_args, XlcSetMask); -} - -static char * -get_oc_values( - XOC oc, - XlcArgList args, - int num_args) -{ - if (oc->core.resources == NULL) - return NULL; - - return _XlcGetValues((XPointer) oc, oc->core.resources, - oc->core.num_resources, args, num_args, XlcGetMask); -} - -static Bool -wcs_to_mbs( - XOC oc, - char *to, - _Xconst wchar_t *from, - int length) -{ - XlcConv conv = XOC_GENERIC(oc)->wcs_to_cs; - XLCd lcd; - int ret, to_left = length; - - if (conv == NULL) { - lcd = oc->core.om->core.lcd; - conv = _XlcOpenConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte); - if (conv == NULL) - return False; - XOC_GENERIC(oc)->wcs_to_cs = conv; - } else - _XlcResetConverter(conv); - - ret = _XlcConvert(conv, (XPointer *) &from, &length, (XPointer *) &to, - &to_left, NULL, 0); - if (ret != 0 || length > 0) - return False; - - return True; -} - -static int -_XmbDefaultTextEscapement(XOC oc, _Xconst char *text, int length) -{ - return XTextWidth(*oc->core.font_info.font_struct_list, text, length); -} - -static int -_XwcDefaultTextEscapement(XOC oc, _Xconst wchar_t *text, int length) -{ - DefineLocalBuf; - char *buf = AllocLocalBuf(length); - int ret = 0; - - if (buf == NULL) - return 0; - - if (wcs_to_mbs(oc, buf, text, length) == False) - goto err; - - ret = _XmbDefaultTextEscapement(oc, buf, length); - -err: - FreeLocalBuf(buf); - - return ret; -} - -static int -_XmbDefaultTextExtents(XOC oc, _Xconst char *text, int length, - XRectangle *overall_ink, XRectangle *overall_logical) -{ - int direction, logical_ascent, logical_descent; - XCharStruct overall; - - XTextExtents(*oc->core.font_info.font_struct_list, text, length, &direction, - &logical_ascent, &logical_descent, &overall); - - if (overall_ink) { - overall_ink->x = overall.lbearing; - overall_ink->y = -(overall.ascent); - overall_ink->width = overall.rbearing - overall.lbearing; - overall_ink->height = overall.ascent + overall.descent; - } - - if (overall_logical) { - overall_logical->x = 0; - overall_logical->y = -(logical_ascent); - overall_logical->width = overall.width; - overall_logical->height = logical_ascent + logical_descent; - } - - return overall.width; -} - -static int -_XwcDefaultTextExtents(XOC oc, _Xconst wchar_t *text, int length, - XRectangle *overall_ink, XRectangle *overall_logical) -{ - DefineLocalBuf; - char *buf = AllocLocalBuf(length); - int ret = 0; - - if (buf == NULL) - return 0; - - if (wcs_to_mbs(oc, buf, text, length) == False) - goto err; - - ret = _XmbDefaultTextExtents(oc, buf, length, overall_ink, overall_logical); - -err: - FreeLocalBuf(buf); - - return ret; -} - -static Status -_XmbDefaultTextPerCharExtents(XOC oc, _Xconst char *text, int length, - XRectangle *ink_buf, XRectangle *logical_buf, - int buf_size, int *num_chars, - XRectangle *overall_ink, - XRectangle *overall_logical) -{ - XFontStruct *font = *oc->core.font_info.font_struct_list; - XCharStruct *def, *cs, overall; - Bool first = True; - - if (buf_size < length) - return 0; - - bzero((char *) &overall, sizeof(XCharStruct)); - *num_chars = 0; - - CI_GET_DEFAULT_INFO_1D(font, def) - - while (length-- > 0) { - CI_GET_CHAR_INFO_1D(font, *text, def, cs) - text++; - if (cs == NULL) - continue; - - ink_buf->x = overall.width + cs->lbearing; - ink_buf->y = -(cs->ascent); - ink_buf->width = cs->rbearing - cs->lbearing; - ink_buf->height = cs->ascent + cs->descent; - ink_buf++; - - logical_buf->x = overall.width; - logical_buf->y = -(font->ascent); - logical_buf->width = cs->width; - logical_buf->height = font->ascent + font->descent; - logical_buf++; - - if (first) { - overall = *cs; - first = False; - } else { - overall.ascent = max(overall.ascent, cs->ascent); - overall.descent = max(overall.descent, cs->descent); - overall.lbearing = min(overall.lbearing, overall.width + - cs->lbearing); - overall.rbearing = max(overall.rbearing, overall.width + - cs->rbearing); - overall.width += cs->width; - } - (*num_chars)++; - } - - if (overall_ink) { - overall_ink->x = overall.lbearing; - overall_ink->y = -(overall.ascent); - overall_ink->width = overall.rbearing - overall.lbearing; - overall_ink->height = overall.ascent + overall.descent; - } - - if (overall_logical) { - overall_logical->x = 0; - overall_logical->y = -(font->ascent); - overall_logical->width = overall.width; - overall_logical->height = font->ascent + font->descent; - } - - return 1; -} - -static Status -_XwcDefaultTextPerCharExtents(XOC oc, _Xconst wchar_t *text, int length, - XRectangle *ink_buf, XRectangle *logical_buf, - int buf_size, int *num_chars, - XRectangle *overall_ink, - XRectangle *overall_logical) -{ - DefineLocalBuf; - char *buf = AllocLocalBuf(length); - Status ret = 0; - - if (buf == NULL) - return 0; - - if (wcs_to_mbs(oc, buf, text, length) == False) - goto err; - - ret = _XmbDefaultTextPerCharExtents(oc, buf, length, ink_buf, logical_buf, - buf_size, num_chars, overall_ink, - overall_logical); - -err: - FreeLocalBuf(buf); - - return ret; -} - -static int -_XmbDefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y, - _Xconst char *text, int length) -{ - XFontStruct *font = *oc->core.font_info.font_struct_list; - - XSetFont(dpy, gc, font->fid); - XDrawString(dpy, d, gc, x, y, text, length); - - return XTextWidth(font, text, length); -} - -static int -_XwcDefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y, - _Xconst wchar_t *text, int length) -{ - DefineLocalBuf; - char *buf = AllocLocalBuf(length); - int ret = 0; - - if (buf == NULL) - return 0; - - if (wcs_to_mbs(oc, buf, text, length) == False) - goto err; - - ret = _XmbDefaultDrawString(dpy, d, oc, gc, x, y, buf, length); - -err: - FreeLocalBuf(buf); - - return ret; -} - -static void -_XmbDefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x, - int y, _Xconst char *text, int length) -{ - XSetFont(dpy, gc, (*oc->core.font_info.font_struct_list)->fid); - XDrawImageString(dpy, d, gc, x, y, text, length); -} - -static void -_XwcDefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x, - int y, _Xconst wchar_t *text, int length) -{ - DefineLocalBuf; - char *buf = AllocLocalBuf(length); - - if (buf == NULL) - return; - - if (wcs_to_mbs(oc, buf, text, length) == False) - goto err; - - _XmbDefaultDrawImageString(dpy, d, oc, gc, x, y, buf, length); - -err: - FreeLocalBuf(buf); -} - -static _Xconst XOCMethodsRec oc_default_methods = { - destroy_oc, - set_oc_values, - get_oc_values, - _XmbDefaultTextEscapement, - _XmbDefaultTextExtents, - _XmbDefaultTextPerCharExtents, - _XmbDefaultDrawString, - _XmbDefaultDrawImageString, - _XwcDefaultTextEscapement, - _XwcDefaultTextExtents, - _XwcDefaultTextPerCharExtents, - _XwcDefaultDrawString, - _XwcDefaultDrawImageString -}; - -static XlcResource oc_resources[] = { - { XNBaseFontName, NULLQUARK, sizeof(char *), - XOffsetOf(XOCRec, core.base_name_list), XlcCreateMask | XlcGetMask }, - { XNOMAutomatic, NULLQUARK, sizeof(Bool), - XOffsetOf(XOCRec, core.om_automatic), XlcGetMask }, - { XNMissingCharSet, NULLQUARK, sizeof(XOMCharSetList), - XOffsetOf(XOCRec, core.missing_list), XlcGetMask }, - { XNDefaultString, NULLQUARK, sizeof(char *), - XOffsetOf(XOCRec, core.default_string), XlcGetMask }, - { XNOrientation, NULLQUARK, sizeof(XOrientation), - XOffsetOf(XOCRec, core.orientation), XlcSetMask | XlcGetMask }, - { XNResourceName, NULLQUARK, sizeof(char *), - XOffsetOf(XOCRec, core.res_name), XlcSetMask | XlcGetMask }, - { XNResourceClass, NULLQUARK, sizeof(char *), - XOffsetOf(XOCRec, core.res_class), XlcSetMask | XlcGetMask }, - { XNFontInfo, NULLQUARK, sizeof(XOMFontInfo), - XOffsetOf(XOCRec, core.font_info), XlcGetMask } -}; - -static XOC -create_oc( - XOM om, - XlcArgList args, - int num_args) -{ - XOC oc; - - oc = (XOC) Xmalloc(sizeof(XOCGenericRec)); - if (oc == NULL) - return (XOC) NULL; - bzero((char *) oc, sizeof(XOCGenericRec)); - - oc->core.om = om; - - if (oc_resources[0].xrm_name == NULLQUARK) - _XlcCompileResourceList(oc_resources, XlcNumber(oc_resources)); - - if (_XlcSetValues((XPointer) oc, oc_resources, XlcNumber(oc_resources), - args, num_args, XlcCreateMask | XlcDefaultMask)) - goto err; - - if (oc->core.base_name_list == NULL) - goto err; - - oc->core.resources = oc_resources; - oc->core.num_resources = XlcNumber(oc_resources); - - if (create_fontset(oc) == False) - goto err; - - oc->methods = (XOCMethods)&oc_default_methods; - - return oc; - -err: - destroy_oc(oc); - - return (XOC) NULL; -} - -static Status -close_om( - XOM om) -{ - XOMGenericPart *gen = XOM_GENERIC(om); - OMData data; - FontData font_data; - int count; - - if ((data = gen->data)) { - if (data->font_data) { - for (font_data = data->font_data, count = data->font_data_count; - count-- > 0 ; font_data++) { - if (font_data->name) - Xfree(font_data->name); - } - Xfree(data->font_data); - } - Xfree(gen->data); - } - - if (om->core.res_name) - Xfree(om->core.res_name); - if (om->core.res_class) - Xfree(om->core.res_class); - if (om->core.required_charset.charset_list) - XFreeStringList(om->core.required_charset.charset_list); - else - Xfree((char*)om->core.required_charset.charset_list); - if (om->core.orientation_list.orientation) - Xfree(om->core.orientation_list.orientation); - - Xfree(om); - - return 1; -} - -static char * -set_om_values( - XOM om, - XlcArgList args, - int num_args) -{ - if (om->core.resources == NULL) - return NULL; - - return _XlcSetValues((XPointer) om, om->core.resources, - om->core.num_resources, args, num_args, XlcSetMask); -} - -static char * -get_om_values( - XOM om, - XlcArgList args, - int num_args) -{ - if (om->core.resources == NULL) - return NULL; - - return _XlcGetValues((XPointer) om, om->core.resources, - om->core.num_resources, args, num_args, XlcGetMask); -} - -static _Xconst XOMMethodsRec methods = { - close_om, - set_om_values, - get_om_values, - create_oc -}; - -static XlcResource om_resources[] = { - { XNRequiredCharSet, NULLQUARK, sizeof(XOMCharSetList), - XOffsetOf(XOMRec, core.required_charset), XlcGetMask }, - { XNQueryOrientation, NULLQUARK, sizeof(XOMOrientation), - XOffsetOf(XOMRec, core.orientation_list), XlcGetMask }, - { XNDirectionalDependentDrawing, NULLQUARK, sizeof(Bool), - XOffsetOf(XOMRec, core.directional_dependent), XlcGetMask }, - { XNContextualDrawing, NULLQUARK, sizeof(Bool), - XOffsetOf(XOMRec, core.contextual_drawing), XlcGetMask } -}; - -static OMData -add_data( - XOM om) -{ - XOMGenericPart *gen = XOM_GENERIC(om); - OMData new; - - new = (OMData) Xmalloc(sizeof(OMDataRec)); - - if (new == NULL) - return NULL; - - gen->data = new; - - bzero((char *) new, sizeof(OMDataRec)); - - return new; -} - -static _Xconst char *supported_charset_list[] = { - "ISO8859-1", -/* fix for bug4332979 */ - "adobe-fontspecific", -/* fix for bug4237353: "JISX0201.1976-0" entry should be removed from - supported_charset_list because it is not a supported_charset for C locale - "JISX0201.1976-0", */ - "SUNOLCURSOR-1", - "SUNOLGLYPH-1" -}; - -static Bool -init_om( - XOM om) -{ - XOMGenericPart *gen = XOM_GENERIC(om); - OMData data; - FontData font_data; - char **required_list; - XOrientation *orientation; - char **value, buf[BUFSIZ], *bufptr; - int count, length = 0; - - value = (char**)supported_charset_list; - count = XlcNumber(supported_charset_list); - - data = add_data(om); - if (data == NULL) - return False; - - font_data = (FontData) Xmalloc(sizeof(FontDataRec) * count); - if (font_data == NULL) - return False; - bzero((char *) font_data, sizeof(FontDataRec) * count); - data->font_data = font_data; - data->font_data_count = count; - - for ( ; count-- > 0; font_data++) { -/* -1266793 -This one is fine. *value points to one of the local strings in -supported_charset_list[]. -*/ - strcpy(buf, *value++); - font_data->name = (char *) Xmalloc(strlen(buf) + 1); - if (font_data->name == NULL) - return False; - strcpy(font_data->name, buf); - } - - length += strlen(data->font_data->name) + 1; - - /* required charset list */ - required_list = (char **) Xmalloc(sizeof(char *)); - if (required_list == NULL) - return False; - - bufptr = (char *) Xmalloc(length); - if (bufptr == NULL) { - Xfree(required_list); - return False; - } - - om->core.required_charset.charset_list = required_list; - om->core.required_charset.charset_count = 1; /* always 1 */ - - data = gen->data; - - strcpy(bufptr, data->font_data->name); - *required_list++ = bufptr; - bufptr += strlen(bufptr) + 1; - - /* orientation list */ - orientation = (XOrientation *) Xmalloc(sizeof(XOrientation)); - if (orientation == NULL) - return False; - - *orientation = XOMOrientation_LTR_TTB; - om->core.orientation_list.orientation = orientation; - om->core.orientation_list.num_orientation = 1; - - /* directional dependent drawing */ - om->core.directional_dependent = False; - - /* contexual drawing */ - om->core.contextual_drawing = False; - - /* context dependent */ - om->core.context_dependent = False; - - return True; -} - -XOM -_XDefaultOpenOM(XLCd lcd, Display *dpy, XrmDatabase rdb, - _Xconst char *res_name, _Xconst char *res_class) -{ - XOM om; - - om = (XOM) Xmalloc(sizeof(XOMGenericRec)); - if (om == NULL) - return (XOM) NULL; - bzero((char *) om, sizeof(XOMGenericRec)); - - om->methods = (XOMMethods)&methods; - om->core.lcd = lcd; - om->core.display = dpy; - om->core.rdb = rdb; - if (res_name) { - om->core.res_name = (char *)Xmalloc(strlen(res_name) + 1); - if (om->core.res_name == NULL) - goto err; - strcpy(om->core.res_name, res_name); - } - if (res_class) { - om->core.res_class = (char *)Xmalloc(strlen(res_class) + 1); - if (om->core.res_class == NULL) - goto err; - strcpy(om->core.res_class, res_class); - } - - if (om_resources[0].xrm_name == NULLQUARK) - _XlcCompileResourceList(om_resources, XlcNumber(om_resources)); - - om->core.resources = om_resources; - om->core.num_resources = XlcNumber(om_resources); - - if (init_om(om) == False) - goto err; - - return om; -err: - close_om(om); - - return (XOM) NULL; -} +/* +Copyright 1985, 1986, 1987, 1991, 1998 The Open Group + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: The above copyright notice and this +permission notice shall be included in all copies or substantial +portions of the Software. + + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE +EVEN IF ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES. + + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + + +X Window System is a trademark of The Open Group + +OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF +logo, LBX, X Window System, and Xinerama are trademarks of the Open +Group. All other trademarks and registered trademarks mentioned herein +are the property of their respective owners. No right, title or +interest in or to any trademark, service mark, logo or trade name of +Sun Microsystems, Inc. or its licensors is granted. + +*/ +/* + * Copyright 2000 Oracle and/or its affiliates. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "Xlibint.h" +#include "Xlcint.h" +#include "XlcPublic.h" +#include +#include +#include + +#define MAXFONTS 100 + +#define XOM_GENERIC(om) (&((XOMGeneric) om)->gen) +#define XOC_GENERIC(font_set) (&((XOCGeneric) font_set)->gen) + +#define DefineLocalBuf char local_buf[BUFSIZ] +#define AllocLocalBuf(length) (length > BUFSIZ ? (char *)Xmalloc(length) : local_buf) +#define FreeLocalBuf(ptr) if (ptr != local_buf) Xfree(ptr) + +typedef struct _FontDataRec { + char *name; +} FontDataRec, *FontData; + +typedef struct _OMDataRec { + int font_data_count; + FontData font_data; +} OMDataRec, *OMData; + +typedef struct _XOMGenericPart { + OMData data; +} XOMGenericPart; + +typedef struct _XOMGenericRec { + XOMMethods methods; + XOMCoreRec core; + XOMGenericPart gen; +} XOMGenericRec, *XOMGeneric; + +typedef struct _FontSetRec { + int id; + int font_data_count; + FontData font_data; + char *font_name; + XFontStruct *info; + XFontStruct *font; +} FontSetRec, *FontSet; + +typedef struct _XOCGenericPart { + XlcConv wcs_to_cs; + FontSet font_set; +} XOCGenericPart; + +typedef struct _XOCGenericRec { + XOCMethods methods; + XOCCoreRec core; + XOCGenericPart gen; +} XOCGenericRec, *XOCGeneric; + +static Bool +init_fontset( + XOC oc) +{ + XOCGenericPart *gen; + FontSet font_set; + OMData data; + + data = XOM_GENERIC(oc->core.om)->data; + + font_set = (FontSet) Xmalloc(sizeof(FontSetRec)); + if (font_set == NULL) + return False; + bzero((char *) font_set, sizeof(FontSetRec)); + + gen = XOC_GENERIC(oc); + gen->font_set = font_set; + + font_set->font_data_count = data->font_data_count; + font_set->font_data = data->font_data; + + return True; +} + +static char * +get_prop_name( + Display *dpy, + XFontStruct *fs) +{ + unsigned long fp; + + if (XGetFontProperty(fs, XA_FONT, &fp)) + return XGetAtomName(dpy, fp); + + return (char *) NULL; +} + +static FontData +check_charset( + FontSet font_set, + char *font_name) +{ + FontData font_data; + char *last; + int count; + ssize_t length, name_len; + + name_len = strlen(font_name); + last = font_name + name_len; + + count = font_set->font_data_count; + font_data = font_set->font_data; + + for ( ; count-- > 0; font_data++) { + length = strlen(font_data->name); + + if (length > name_len) + return(NULL); + + if (_XlcCompareISOLatin1(last - length, font_data->name) == 0) + return font_data; + } + return (FontData) NULL; +} + +#if 0 /* Unused */ +static int +check_fontname( + XOC oc, + char *name) +{ + Display *dpy = oc->core.om->core.display; + XOCGenericPart *gen = XOC_GENERIC(oc); + FontData data; + FontSet font_set; + XFontStruct *fs_list; + char **fn_list, *fname, *prop_fname = NULL; + int list_num, i; + int list2_num; + char **fn2_list = NULL; + int found_num = 0; + + fn_list = XListFonts(dpy, name, MAXFONTS, &list_num); + if (fn_list == NULL) + return found_num; + + for (i = 0; i < list_num; i++) { + fname = fn_list[i]; + + font_set = gen->font_set; + + if ((data = check_charset(font_set, fname)) == NULL) { + if ((fn2_list = XListFontsWithInfo(dpy, name, MAXFONTS, + &list2_num, &fs_list)) + && (prop_fname = get_prop_name(dpy, fs_list)) + && (data = check_charset(font_set, prop_fname))) + fname = prop_fname; + } + if (data) { + font_set->font_name = (char *) Xmalloc(strlen(fname) + 1); + if (font_set->font_name) { + strcpy(font_set->font_name, fname); + found_num++; + } + } + if (fn2_list) { + XFreeFontInfo(fn2_list, fs_list, list2_num); + fn2_list = NULL; + if (prop_fname) { + Xfree(prop_fname); + prop_fname = NULL; + } + } + if (found_num == 1) + break; + } + XFreeFontNames(fn_list); + return found_num; +} +#endif + +static Bool +load_font( + XOC oc) +{ + Display *dpy = oc->core.om->core.display; + XOCGenericPart *gen = XOC_GENERIC(oc); + FontSet font_set = gen->font_set; + + if (font_set->font_name == NULL) + return False; + + if (font_set->font == NULL) { + font_set->font = XLoadQueryFont(dpy, font_set->font_name); + if (font_set->font == NULL) + return False; + } + return True; +} + +#if 0 +static Bool +load_font_info( + XOC oc) +{ + Display *dpy = oc->core.om->core.display; + XOCGenericPart *gen = XOC_GENERIC(oc); + FontSet font_set = gen->font_set; + char **fn_list; + int fn_num; + + if (font_set->font_name == NULL) + return False; + + if (font_set->info == NULL) { + fn_list = XListFontsWithInfo(dpy, font_set->font_name, 1, &fn_num, + &font_set->info); + if (font_set->info == NULL) + return False; + if (fn_num > 0) + font_set->info->fid = XLoadFont(dpy, font_set->font_name); + + if (fn_list) XFreeFontNames(fn_list); + } + return True; +} +#endif + +static void +set_fontset_extents( + XOC oc) +{ + XRectangle *ink = &oc->core.font_set_extents.max_ink_extent; + XRectangle *logical = &oc->core.font_set_extents.max_logical_extent; + XFontStruct **font_list, *font; + XCharStruct overall; + int logical_ascent, logical_descent; + + font_list = oc->core.font_info.font_struct_list; + font = *font_list++; + overall = font->max_bounds; + overall.lbearing = font->min_bounds.lbearing; + logical_ascent = font->ascent; + logical_descent = font->descent; + + ink->x = overall.lbearing; + ink->y = -(overall.ascent); + ink->width = overall.rbearing - overall.lbearing; + ink->height = overall.ascent + overall.descent; + + logical->x = 0; + logical->y = -(logical_ascent); + logical->width = overall.width; + logical->height = logical_ascent + logical_descent; +} + +static Bool +init_core_part( + XOC oc) +{ + XOCGenericPart *gen = XOC_GENERIC(oc); + FontSet font_set; + XFontStruct **font_struct_list; + char **font_name_list, *font_name_buf; + int count, length; + + font_set = gen->font_set; + count = length = 0; + + if (font_set->font_name != NULL) { + length += strlen(font_set->font_name) + 1; + count++; + } + if (count == 0) + return False; + + font_struct_list = (XFontStruct **) Xmalloc(sizeof(XFontStruct *)); + if (font_struct_list == NULL) + return False; + + font_name_list = (char **) Xmalloc(sizeof(char *)); + if (font_name_list == NULL) + goto err; + + font_name_buf = (char *) Xmalloc(length); + if (font_name_buf == NULL) + goto err; + + oc->core.font_info.num_font = 1; + oc->core.font_info.font_name_list = font_name_list; + oc->core.font_info.font_struct_list = font_struct_list; + + font_set = gen->font_set; + + if (font_set->font_name != NULL) { + font_set->id = 1; + if (font_set->font) + *font_struct_list++ = font_set->font; + else + *font_struct_list++ = font_set->info; + strcpy(font_name_buf, font_set->font_name); + Xfree(font_set->font_name); + *font_name_list++ = font_set->font_name = font_name_buf; + font_name_buf += strlen(font_name_buf) + 1; + } + + set_fontset_extents(oc); + + return True; + +err: + if (font_name_list) + Xfree(font_name_list); + Xfree(font_struct_list); + + return False; +} + +static char * +get_font_name( + XOC oc, + char *pattern) +{ + char **list, *name, *prop_name; + int count; + XFontStruct *fs; + Display *dpy = oc->core.om->core.display; + + list = XListFonts(dpy, pattern, 1, &count); + if (list != NULL) { + name = (char *) Xmalloc(strlen(*list) + 1); + if (name) + strcpy(name, *list); + + XFreeFontNames(list); + } else { + fs = XLoadQueryFont(dpy, pattern); + if (fs == NULL) return NULL; + + prop_name = get_prop_name(dpy, fs); + if (prop_name == NULL) return NULL; + + name = (char*) Xmalloc(strlen(prop_name) + 1); + if (name) + strcpy(name, prop_name); + + XFreeFont(dpy, fs); + } + return name; +} + +static int +parse_fontname( + XOC oc) +{ + XOCGenericPart *gen = XOC_GENERIC(oc); + FontSet font_set; + FontData font_data; + char *pattern, *last, buf[BUFSIZ]; + int font_data_count, found_num = 0; + ssize_t length; + int count, num_fields; + char *base_name, *font_name, **name_list, **cur_name_list; + char *charset_p = NULL; + Bool append_charset; + /* + append_charset flag should be set to True when the XLFD fontname + doesn't contain a chaset part. + */ + + name_list = _XParseBaseFontNameList(oc->core.base_name_list, &count); + if (name_list == NULL) + return -1; + cur_name_list = name_list; + + while (count-- > 0) { + pattern = *cur_name_list++; + if (pattern == NULL || *pattern == '\0') + continue; + + append_charset = False; + + if (strchr(pattern, '*') == NULL && + (font_name = get_font_name(oc, pattern))) { + + font_set = gen->font_set; + + font_data = check_charset(font_set, font_name); + if (font_data == NULL) { + Display *dpy = oc->core.om->core.display; + char **fn_list = NULL, *prop_fname = NULL; + int list_num; + XFontStruct *fs_list; + if ((fn_list = XListFontsWithInfo(dpy, font_name, + MAXFONTS, + &list_num, &fs_list)) + && (prop_fname = get_prop_name(dpy, fs_list)) + && (font_data = check_charset(font_set, prop_fname))) { + if (fn_list) { + XFreeFontInfo(fn_list, fs_list, list_num); + fn_list = NULL; + } + font_name = prop_fname; + } + } + if (font_data == NULL) + continue; + + font_set->font_name = (char *) Xmalloc(strlen(font_name) + 1); + if (font_set->font_name == NULL) { + Xfree(font_name); + goto err; + } + strcpy(font_set->font_name, font_name); + Xfree(font_name); + found_num++; + goto found; + } +/* +1266793 +Limit the length of the string copy to prevent stack corruption. + strcpy(buf, pattern); +*/ + strncpy(buf, pattern, BUFSIZ); + buf[BUFSIZ-1] = '\0'; + length = strlen(buf); + last = buf + length - 1; + + for (num_fields = 0, base_name = buf; *base_name != '\0'; base_name++) + if (*base_name == '-') num_fields++; + if (strchr(pattern, '*') == NULL) { + if (num_fields == 12) { + append_charset = True; + *++last = '-'; + last++; + } else + continue; + } else { + if (num_fields == 13 || num_fields == 14) { + /* + * There are 14 fields in an XLFD name -- make certain the + * charset (& encoding) is placed in the correct field. + */ + append_charset = True; + last = strrchr (buf, '-'); + if (num_fields == 14) { + *last = '\0'; + last = strrchr (buf, '-'); + } + last++; + } else if (*last == '*') { + append_charset = True; + if (length > 3 && *(last-3) == '-' && *(last-2) == '*' + && *(last-1) == '-') { + last -= 2; + } + *++last = '-'; + last++; + } else { + last = strrchr (buf, '-'); + charset_p = last; + charset_p = strrchr (buf, '-'); + while (*(--charset_p) != '-'); + charset_p++; + } + } + + font_set = gen->font_set; + + font_data = font_set->font_data; + font_data_count = font_set->font_data_count; + for ( ; font_data_count-- > 0; font_data++) { + if (append_charset) + { +/* +1266793 +Limit the length of the string copy to prevent stack corruption. + strcpy(last, font_data->name); +*/ + strncpy(last, font_data->name, BUFSIZ - length); + buf[BUFSIZ-1] = '\0'; + } + else { + if (_XlcCompareISOLatin1(charset_p, + font_data->name)) { + continue; + } + } + if ((font_set->font_name = get_font_name(oc, buf))) + break; + } + if (font_set->font_name != NULL) { + found_num++; + goto found; + } + } + found: + base_name = (char *) Xmalloc(strlen(oc->core.base_name_list) + 1); + if (base_name == NULL) + goto err; + + strcpy(base_name, oc->core.base_name_list); + oc->core.base_name_list = base_name; + + XFreeStringList(name_list); + + return found_num; +err: + XFreeStringList(name_list); + + return -1; +} + +static Bool +set_missing_list( + XOC oc) +{ + XOCGenericPart *gen = XOC_GENERIC(oc); + FontSet font_set; + char **charset_list, *charset_buf; + int count, length; + + font_set = gen->font_set; + count = length = 0; + + if (!font_set->info && !font_set->font) { + length += strlen(font_set->font_data->name) + 1; + count++; + } + + if (count == 0) + return True; + + charset_list = (char **) Xmalloc(sizeof(char *)); + if (charset_list == NULL) + return False; + + charset_buf = (char *) Xmalloc(length); + if (charset_buf == NULL) { + Xfree(charset_list); + return False; + } + + oc->core.missing_list.charset_list = charset_list; + + font_set = gen->font_set; + + if (!font_set->info && !font_set->font) { + strcpy(charset_buf, font_set->font_data->name); + *charset_list++ = charset_buf; + charset_buf += strlen(charset_buf) + 1; + } + return True; +} + +static Bool +create_fontset( + XOC oc) +{ + int found_num; + + if (init_fontset(oc) == False) + return False; + + found_num = parse_fontname(oc); + if (found_num <= 0) { + if (found_num == 0) + set_missing_list(oc); + return False; + } + + if (load_font(oc) == False) + return False; + + if (init_core_part(oc) == False) + return False; + + if (set_missing_list(oc) == False) + return False; + + return True; +} + +static void +destroy_oc( + XOC oc) +{ + Display *dpy = oc->core.om->core.display; + XOCGenericPart *gen = XOC_GENERIC(oc); + XFontStruct **font_list, *font; + + if (gen->font_set) + Xfree(gen->font_set); + + if (oc->core.base_name_list) + Xfree(oc->core.base_name_list); + + if (oc->core.font_info.font_name_list) + XFreeStringList(oc->core.font_info.font_name_list); + + if ((font_list = oc->core.font_info.font_struct_list)) { + if ((font = *font_list)) { + if (font->fid) + XFreeFont(dpy, font); + else + XFreeFontInfo(NULL, font, 1); + } + Xfree(oc->core.font_info.font_struct_list); + } + + if (oc->core.missing_list.charset_list) + XFreeStringList(oc->core.missing_list.charset_list); + +#ifdef notdef + if (oc->core.res_name) + Xfree(oc->core.res_name); + if (oc->core.res_class) + Xfree(oc->core.res_class); +#endif + + Xfree(oc); +} + +static char * +set_oc_values( + XOC oc, + XlcArgList args, + int num_args) +{ + if (oc->core.resources == NULL) + return NULL; + + return _XlcSetValues((XPointer) oc, oc->core.resources, + oc->core.num_resources, args, num_args, XlcSetMask); +} + +static char * +get_oc_values( + XOC oc, + XlcArgList args, + int num_args) +{ + if (oc->core.resources == NULL) + return NULL; + + return _XlcGetValues((XPointer) oc, oc->core.resources, + oc->core.num_resources, args, num_args, XlcGetMask); +} + +static Bool +wcs_to_mbs( + XOC oc, + char *to, + _Xconst wchar_t *from, + int length) +{ + XlcConv conv = XOC_GENERIC(oc)->wcs_to_cs; + XLCd lcd; + int ret, to_left = length; + + if (conv == NULL) { + lcd = oc->core.om->core.lcd; + conv = _XlcOpenConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte); + if (conv == NULL) + return False; + XOC_GENERIC(oc)->wcs_to_cs = conv; + } else + _XlcResetConverter(conv); + + ret = _XlcConvert(conv, (XPointer *) &from, &length, (XPointer *) &to, + &to_left, NULL, 0); + if (ret != 0 || length > 0) + return False; + + return True; +} + +static int +_XmbDefaultTextEscapement(XOC oc, _Xconst char *text, int length) +{ + return XTextWidth(*oc->core.font_info.font_struct_list, text, length); +} + +static int +_XwcDefaultTextEscapement(XOC oc, _Xconst wchar_t *text, int length) +{ + DefineLocalBuf; + char *buf = AllocLocalBuf(length); + int ret = 0; + + if (buf == NULL) + return 0; + + if (wcs_to_mbs(oc, buf, text, length) == False) + goto err; + + ret = _XmbDefaultTextEscapement(oc, buf, length); + +err: + FreeLocalBuf(buf); + + return ret; +} + +static int +_XmbDefaultTextExtents(XOC oc, _Xconst char *text, int length, + XRectangle *overall_ink, XRectangle *overall_logical) +{ + int direction, logical_ascent, logical_descent; + XCharStruct overall; + + XTextExtents(*oc->core.font_info.font_struct_list, text, length, &direction, + &logical_ascent, &logical_descent, &overall); + + if (overall_ink) { + overall_ink->x = overall.lbearing; + overall_ink->y = -(overall.ascent); + overall_ink->width = overall.rbearing - overall.lbearing; + overall_ink->height = overall.ascent + overall.descent; + } + + if (overall_logical) { + overall_logical->x = 0; + overall_logical->y = -(logical_ascent); + overall_logical->width = overall.width; + overall_logical->height = logical_ascent + logical_descent; + } + + return overall.width; +} + +static int +_XwcDefaultTextExtents(XOC oc, _Xconst wchar_t *text, int length, + XRectangle *overall_ink, XRectangle *overall_logical) +{ + DefineLocalBuf; + char *buf = AllocLocalBuf(length); + int ret = 0; + + if (buf == NULL) + return 0; + + if (wcs_to_mbs(oc, buf, text, length) == False) + goto err; + + ret = _XmbDefaultTextExtents(oc, buf, length, overall_ink, overall_logical); + +err: + FreeLocalBuf(buf); + + return ret; +} + +static Status +_XmbDefaultTextPerCharExtents(XOC oc, _Xconst char *text, int length, + XRectangle *ink_buf, XRectangle *logical_buf, + int buf_size, int *num_chars, + XRectangle *overall_ink, + XRectangle *overall_logical) +{ + XFontStruct *font = *oc->core.font_info.font_struct_list; + XCharStruct *def, *cs, overall; + Bool first = True; + + if (buf_size < length) + return 0; + + bzero((char *) &overall, sizeof(XCharStruct)); + *num_chars = 0; + + CI_GET_DEFAULT_INFO_1D(font, def) + + while (length-- > 0) { + CI_GET_CHAR_INFO_1D(font, *text, def, cs) + text++; + if (cs == NULL) + continue; + + ink_buf->x = overall.width + cs->lbearing; + ink_buf->y = -(cs->ascent); + ink_buf->width = cs->rbearing - cs->lbearing; + ink_buf->height = cs->ascent + cs->descent; + ink_buf++; + + logical_buf->x = overall.width; + logical_buf->y = -(font->ascent); + logical_buf->width = cs->width; + logical_buf->height = font->ascent + font->descent; + logical_buf++; + + if (first) { + overall = *cs; + first = False; + } else { + overall.ascent = max(overall.ascent, cs->ascent); + overall.descent = max(overall.descent, cs->descent); + overall.lbearing = min(overall.lbearing, overall.width + + cs->lbearing); + overall.rbearing = max(overall.rbearing, overall.width + + cs->rbearing); + overall.width += cs->width; + } + (*num_chars)++; + } + + if (overall_ink) { + overall_ink->x = overall.lbearing; + overall_ink->y = -(overall.ascent); + overall_ink->width = overall.rbearing - overall.lbearing; + overall_ink->height = overall.ascent + overall.descent; + } + + if (overall_logical) { + overall_logical->x = 0; + overall_logical->y = -(font->ascent); + overall_logical->width = overall.width; + overall_logical->height = font->ascent + font->descent; + } + + return 1; +} + +static Status +_XwcDefaultTextPerCharExtents(XOC oc, _Xconst wchar_t *text, int length, + XRectangle *ink_buf, XRectangle *logical_buf, + int buf_size, int *num_chars, + XRectangle *overall_ink, + XRectangle *overall_logical) +{ + DefineLocalBuf; + char *buf = AllocLocalBuf(length); + Status ret = 0; + + if (buf == NULL) + return 0; + + if (wcs_to_mbs(oc, buf, text, length) == False) + goto err; + + ret = _XmbDefaultTextPerCharExtents(oc, buf, length, ink_buf, logical_buf, + buf_size, num_chars, overall_ink, + overall_logical); + +err: + FreeLocalBuf(buf); + + return ret; +} + +static int +_XmbDefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y, + _Xconst char *text, int length) +{ + XFontStruct *font = *oc->core.font_info.font_struct_list; + + XSetFont(dpy, gc, font->fid); + XDrawString(dpy, d, gc, x, y, text, length); + + return XTextWidth(font, text, length); +} + +static int +_XwcDefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y, + _Xconst wchar_t *text, int length) +{ + DefineLocalBuf; + char *buf = AllocLocalBuf(length); + int ret = 0; + + if (buf == NULL) + return 0; + + if (wcs_to_mbs(oc, buf, text, length) == False) + goto err; + + ret = _XmbDefaultDrawString(dpy, d, oc, gc, x, y, buf, length); + +err: + FreeLocalBuf(buf); + + return ret; +} + +static void +_XmbDefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x, + int y, _Xconst char *text, int length) +{ + XSetFont(dpy, gc, (*oc->core.font_info.font_struct_list)->fid); + XDrawImageString(dpy, d, gc, x, y, text, length); +} + +static void +_XwcDefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x, + int y, _Xconst wchar_t *text, int length) +{ + DefineLocalBuf; + char *buf = AllocLocalBuf(length); + + if (buf == NULL) + return; + + if (wcs_to_mbs(oc, buf, text, length) == False) + goto err; + + _XmbDefaultDrawImageString(dpy, d, oc, gc, x, y, buf, length); + +err: + FreeLocalBuf(buf); +} + +static _Xconst XOCMethodsRec oc_default_methods = { + destroy_oc, + set_oc_values, + get_oc_values, + _XmbDefaultTextEscapement, + _XmbDefaultTextExtents, + _XmbDefaultTextPerCharExtents, + _XmbDefaultDrawString, + _XmbDefaultDrawImageString, + _XwcDefaultTextEscapement, + _XwcDefaultTextExtents, + _XwcDefaultTextPerCharExtents, + _XwcDefaultDrawString, + _XwcDefaultDrawImageString +}; + +static XlcResource oc_resources[] = { + { XNBaseFontName, NULLQUARK, sizeof(char *), + XOffsetOf(XOCRec, core.base_name_list), XlcCreateMask | XlcGetMask }, + { XNOMAutomatic, NULLQUARK, sizeof(Bool), + XOffsetOf(XOCRec, core.om_automatic), XlcGetMask }, + { XNMissingCharSet, NULLQUARK, sizeof(XOMCharSetList), + XOffsetOf(XOCRec, core.missing_list), XlcGetMask }, + { XNDefaultString, NULLQUARK, sizeof(char *), + XOffsetOf(XOCRec, core.default_string), XlcGetMask }, + { XNOrientation, NULLQUARK, sizeof(XOrientation), + XOffsetOf(XOCRec, core.orientation), XlcSetMask | XlcGetMask }, + { XNResourceName, NULLQUARK, sizeof(char *), + XOffsetOf(XOCRec, core.res_name), XlcSetMask | XlcGetMask }, + { XNResourceClass, NULLQUARK, sizeof(char *), + XOffsetOf(XOCRec, core.res_class), XlcSetMask | XlcGetMask }, + { XNFontInfo, NULLQUARK, sizeof(XOMFontInfo), + XOffsetOf(XOCRec, core.font_info), XlcGetMask } +}; + +static XOC +create_oc( + XOM om, + XlcArgList args, + int num_args) +{ + XOC oc; + + oc = (XOC) Xmalloc(sizeof(XOCGenericRec)); + if (oc == NULL) + return (XOC) NULL; + bzero((char *) oc, sizeof(XOCGenericRec)); + + oc->core.om = om; + + if (oc_resources[0].xrm_name == NULLQUARK) + _XlcCompileResourceList(oc_resources, XlcNumber(oc_resources)); + + if (_XlcSetValues((XPointer) oc, oc_resources, XlcNumber(oc_resources), + args, num_args, XlcCreateMask | XlcDefaultMask)) + goto err; + + if (oc->core.base_name_list == NULL) + goto err; + + oc->core.resources = oc_resources; + oc->core.num_resources = XlcNumber(oc_resources); + + if (create_fontset(oc) == False) + goto err; + + oc->methods = (XOCMethods)&oc_default_methods; + + return oc; + +err: + destroy_oc(oc); + + return (XOC) NULL; +} + +static Status +close_om( + XOM om) +{ + XOMGenericPart *gen = XOM_GENERIC(om); + OMData data; + FontData font_data; + int count; + + if ((data = gen->data)) { + if (data->font_data) { + for (font_data = data->font_data, count = data->font_data_count; + count-- > 0 ; font_data++) { + if (font_data->name) + Xfree(font_data->name); + } + Xfree(data->font_data); + } + Xfree(gen->data); + } + + if (om->core.res_name) + Xfree(om->core.res_name); + if (om->core.res_class) + Xfree(om->core.res_class); + if (om->core.required_charset.charset_list) + XFreeStringList(om->core.required_charset.charset_list); + else + Xfree((char*)om->core.required_charset.charset_list); + if (om->core.orientation_list.orientation) + Xfree(om->core.orientation_list.orientation); + + Xfree(om); + + return 1; +} + +static char * +set_om_values( + XOM om, + XlcArgList args, + int num_args) +{ + if (om->core.resources == NULL) + return NULL; + + return _XlcSetValues((XPointer) om, om->core.resources, + om->core.num_resources, args, num_args, XlcSetMask); +} + +static char * +get_om_values( + XOM om, + XlcArgList args, + int num_args) +{ + if (om->core.resources == NULL) + return NULL; + + return _XlcGetValues((XPointer) om, om->core.resources, + om->core.num_resources, args, num_args, XlcGetMask); +} + +static _Xconst XOMMethodsRec methods = { + close_om, + set_om_values, + get_om_values, + create_oc +}; + +static XlcResource om_resources[] = { + { XNRequiredCharSet, NULLQUARK, sizeof(XOMCharSetList), + XOffsetOf(XOMRec, core.required_charset), XlcGetMask }, + { XNQueryOrientation, NULLQUARK, sizeof(XOMOrientation), + XOffsetOf(XOMRec, core.orientation_list), XlcGetMask }, + { XNDirectionalDependentDrawing, NULLQUARK, sizeof(Bool), + XOffsetOf(XOMRec, core.directional_dependent), XlcGetMask }, + { XNContextualDrawing, NULLQUARK, sizeof(Bool), + XOffsetOf(XOMRec, core.contextual_drawing), XlcGetMask } +}; + +static OMData +add_data( + XOM om) +{ + XOMGenericPart *gen = XOM_GENERIC(om); + OMData new; + + new = (OMData) Xmalloc(sizeof(OMDataRec)); + + if (new == NULL) + return NULL; + + gen->data = new; + + bzero((char *) new, sizeof(OMDataRec)); + + return new; +} + +static _Xconst char *supported_charset_list[] = { + "ISO8859-1", +/* fix for bug4332979 */ + "adobe-fontspecific", +/* fix for bug4237353: "JISX0201.1976-0" entry should be removed from + supported_charset_list because it is not a supported_charset for C locale + "JISX0201.1976-0", */ + "SUNOLCURSOR-1", + "SUNOLGLYPH-1" +}; + +static Bool +init_om( + XOM om) +{ + XOMGenericPart *gen = XOM_GENERIC(om); + OMData data; + FontData font_data; + char **required_list; + XOrientation *orientation; + char **value, buf[BUFSIZ], *bufptr; + int count, length = 0; + + value = (char**)supported_charset_list; + count = XlcNumber(supported_charset_list); + + data = add_data(om); + if (data == NULL) + return False; + + font_data = (FontData) Xmalloc(sizeof(FontDataRec) * count); + if (font_data == NULL) + return False; + bzero((char *) font_data, sizeof(FontDataRec) * count); + data->font_data = font_data; + data->font_data_count = count; + + for ( ; count-- > 0; font_data++) { +/* +1266793 +This one is fine. *value points to one of the local strings in +supported_charset_list[]. +*/ + strcpy(buf, *value++); + font_data->name = (char *) Xmalloc(strlen(buf) + 1); + if (font_data->name == NULL) + return False; + strcpy(font_data->name, buf); + } + + length += strlen(data->font_data->name) + 1; + + /* required charset list */ + required_list = (char **) Xmalloc(sizeof(char *)); + if (required_list == NULL) + return False; + + bufptr = (char *) Xmalloc(length); + if (bufptr == NULL) { + Xfree(required_list); + return False; + } + + om->core.required_charset.charset_list = required_list; + om->core.required_charset.charset_count = 1; /* always 1 */ + + data = gen->data; + + strcpy(bufptr, data->font_data->name); + *required_list++ = bufptr; + bufptr += strlen(bufptr) + 1; + + /* orientation list */ + orientation = (XOrientation *) Xmalloc(sizeof(XOrientation)); + if (orientation == NULL) + return False; + + *orientation = XOMOrientation_LTR_TTB; + om->core.orientation_list.orientation = orientation; + om->core.orientation_list.num_orientation = 1; + + /* directional dependent drawing */ + om->core.directional_dependent = False; + + /* contexual drawing */ + om->core.contextual_drawing = False; + + /* context dependent */ + om->core.context_dependent = False; + + return True; +} + +XOM +_XDefaultOpenOM(XLCd lcd, Display *dpy, XrmDatabase rdb, + _Xconst char *res_name, _Xconst char *res_class) +{ + XOM om; + + om = (XOM) Xmalloc(sizeof(XOMGenericRec)); + if (om == NULL) + return (XOM) NULL; + bzero((char *) om, sizeof(XOMGenericRec)); + + om->methods = (XOMMethods)&methods; + om->core.lcd = lcd; + om->core.display = dpy; + om->core.rdb = rdb; + if (res_name) { + om->core.res_name = (char *)Xmalloc(strlen(res_name) + 1); + if (om->core.res_name == NULL) + goto err; + strcpy(om->core.res_name, res_name); + } + if (res_class) { + om->core.res_class = (char *)Xmalloc(strlen(res_class) + 1); + if (om->core.res_class == NULL) + goto err; + strcpy(om->core.res_class, res_class); + } + + if (om_resources[0].xrm_name == NULLQUARK) + _XlcCompileResourceList(om_resources, XlcNumber(om_resources)); + + om->core.resources = om_resources; + om->core.num_resources = XlcNumber(om_resources); + + if (init_om(om) == False) + goto err; + + return om; +err: + close_om(om); + + return (XOM) NULL; +} diff --git a/libX11/src/xlibi18n/XimTrInt.h b/libX11/src/xlibi18n/XimTrInt.h index b7e4439d2..83919ddfa 100644 --- a/libX11/src/xlibi18n/XimTrInt.h +++ b/libX11/src/xlibi18n/XimTrInt.h @@ -1,85 +1,85 @@ -/* - * Copyright 1992 Sun Microsystems, Inc. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -/****************************************************************** - - Copyright 1993, 1994 by FUJITSU LIMITED - -Permission to use, copy, modify, distribute, and sell this software -and its documentation for any purpose is hereby granted without fee, -provided that the above copyright notice appear in all copies and -that both that copyright notice and this permission notice appear -in supporting documentation, and that the name of FUJITSU LIMITED -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. -FUJITSU LIMITED makes no representations about the suitability of -this software for any purpose. -It is provided "as is" without express or implied warranty. - -FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -EVENT SHALL FUJITSU LIMITED BE LIABLE FOR ANY SPECIAL, INDIRECT OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. - - Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc. - Takashi Fujiwara FUJITSU LIMITED - fujiwara@a80.tech.yk.fujitsu.co.jp - -******************************************************************/ - -#ifndef _XIMTRINT_H -#define _XIMTRINT_H - -#include "Ximint.h" - -typedef struct { - const char *transportname; - Bool (*config)( - Xim, - char * - ); -} TransportSW; - -extern TransportSW _XimTransportRec[]; - -/* - * Global symbols - */ - -extern Bool _XimXConf( - Xim im, - char *address -); - -#if defined(TCPCONN) || defined(UNIXCONN) || defined(DNETCONN) || defined(STREAMSCONN) - -extern Bool _XimTransConf( - Xim im, - char *address -); - -#endif - -#endif /* _XIMTRINT_H */ +/* + * Copyright 1992 Oracle and/or its affiliates. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +/****************************************************************** + + Copyright 1993, 1994 by FUJITSU LIMITED + +Permission to use, copy, modify, distribute, and sell this software +and its documentation for any purpose is hereby granted without fee, +provided that the above copyright notice appear in all copies and +that both that copyright notice and this permission notice appear +in supporting documentation, and that the name of FUJITSU LIMITED +not be used in advertising or publicity pertaining to distribution +of the software without specific, written prior permission. +FUJITSU LIMITED makes no representations about the suitability of +this software for any purpose. +It is provided "as is" without express or implied warranty. + +FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +EVENT SHALL FUJITSU LIMITED BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + + Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc. + Takashi Fujiwara FUJITSU LIMITED + fujiwara@a80.tech.yk.fujitsu.co.jp + +******************************************************************/ + +#ifndef _XIMTRINT_H +#define _XIMTRINT_H + +#include "Ximint.h" + +typedef struct { + const char *transportname; + Bool (*config)( + Xim, + char * + ); +} TransportSW; + +extern TransportSW _XimTransportRec[]; + +/* + * Global symbols + */ + +extern Bool _XimXConf( + Xim im, + char *address +); + +#if defined(TCPCONN) || defined(UNIXCONN) || defined(DNETCONN) || defined(STREAMSCONN) + +extern Bool _XimTransConf( + Xim im, + char *address +); + +#endif + +#endif /* _XIMTRINT_H */ diff --git a/libX11/src/xlibi18n/XimTrX.h b/libX11/src/xlibi18n/XimTrX.h index 1c24fe368..c4c3be769 100644 --- a/libX11/src/xlibi18n/XimTrX.h +++ b/libX11/src/xlibi18n/XimTrX.h @@ -1,85 +1,85 @@ -/* - * Copyright 1992 Sun Microsystems, Inc. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -/****************************************************************** - - Copyright 1992, 1993, 1994 by FUJITSU LIMITED - -Permission to use, copy, modify, distribute, and sell this software -and its documentation for any purpose is hereby granted without fee, -provided that the above copyright notice appear in all copies and -that both that copyright notice and this permission notice appear -in supporting documentation, and that the name of FUJITSU LIMITED -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. -FUJITSU LIMITED makes no representations about the suitability of -this software for any purpose. -It is provided "as is" without express or implied warranty. - -FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -EVENT SHALL FUJITSU LIMITED BE LIABLE FOR ANY SPECIAL, INDIRECT OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. - - Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc. - Takashi Fujiwara FUJITSU LIMITED - fujiwara@a80.tech.yk.fujitsu.co.jp - -******************************************************************/ - -#ifndef _XIMTRX_H -#define _XIMTRX_H - -typedef struct _XIntrCallbackRec *XIntrCallbackPtr; - -typedef struct _XIntrCallbackRec { - Bool (*func)( - Xim, INT16, XPointer, XPointer -); - XPointer call_data; - XIntrCallbackPtr next; -} XIntrCallbackRec ; - -typedef struct _XSpecRec { - XIntrCallbackPtr intr_cb; - Atom imconnectid; - Atom improtocolid; - Atom immoredataid; - Window lib_connect_wid; - Window ims_connect_wid; - XPointer ev; - CARD32 major_code; - CARD32 minor_code; - CARD32 BoundarySize; -} XSpecRec; - -#define _XIM_PROTOCOL "_XIM_PROTOCOL" -#define _XIM_XCONNECT "_XIM_XCONNECT" -#define _XIM_MOREDATA "_XIM_MOREDATA" - -#define MAJOR_TRANSPORT_VERSION 0 -#define MINOR_TRANSPORT_VERSION 0 - -#endif /* _XIMTRX_H */ +/* + * Copyright 1992 Oracle and/or its affiliates. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +/****************************************************************** + + Copyright 1992, 1993, 1994 by FUJITSU LIMITED + +Permission to use, copy, modify, distribute, and sell this software +and its documentation for any purpose is hereby granted without fee, +provided that the above copyright notice appear in all copies and +that both that copyright notice and this permission notice appear +in supporting documentation, and that the name of FUJITSU LIMITED +not be used in advertising or publicity pertaining to distribution +of the software without specific, written prior permission. +FUJITSU LIMITED makes no representations about the suitability of +this software for any purpose. +It is provided "as is" without express or implied warranty. + +FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +EVENT SHALL FUJITSU LIMITED BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + + Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc. + Takashi Fujiwara FUJITSU LIMITED + fujiwara@a80.tech.yk.fujitsu.co.jp + +******************************************************************/ + +#ifndef _XIMTRX_H +#define _XIMTRX_H + +typedef struct _XIntrCallbackRec *XIntrCallbackPtr; + +typedef struct _XIntrCallbackRec { + Bool (*func)( + Xim, INT16, XPointer, XPointer +); + XPointer call_data; + XIntrCallbackPtr next; +} XIntrCallbackRec ; + +typedef struct _XSpecRec { + XIntrCallbackPtr intr_cb; + Atom imconnectid; + Atom improtocolid; + Atom immoredataid; + Window lib_connect_wid; + Window ims_connect_wid; + XPointer ev; + CARD32 major_code; + CARD32 minor_code; + CARD32 BoundarySize; +} XSpecRec; + +#define _XIM_PROTOCOL "_XIM_PROTOCOL" +#define _XIM_XCONNECT "_XIM_XCONNECT" +#define _XIM_MOREDATA "_XIM_MOREDATA" + +#define MAJOR_TRANSPORT_VERSION 0 +#define MINOR_TRANSPORT_VERSION 0 + +#endif /* _XIMTRX_H */ diff --git a/libX11/src/xlibi18n/XimTrans.h b/libX11/src/xlibi18n/XimTrans.h index 987b5ee33..8de1465aa 100644 --- a/libX11/src/xlibi18n/XimTrans.h +++ b/libX11/src/xlibi18n/XimTrans.h @@ -1,136 +1,136 @@ -/* - * Copyright 1992 Sun Microsystems, Inc. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -/****************************************************************** - - Copyright 1992, 1993, 1994 by FUJITSU LIMITED - -Permission to use, copy, modify, distribute, and sell this software -and its documentation for any purpose is hereby granted without fee, -provided that the above copyright notice appear in all copies and -that both that copyright notice and this permission notice appear -in supporting documentation, and that the name of FUJITSU LIMITED -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. -FUJITSU LIMITED makes no representations about the suitability of -this software for any purpose. -It is provided "as is" without express or implied warranty. - -FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -EVENT SHALL FUJITSU LIMITED BE LIABLE FOR ANY SPECIAL, INDIRECT OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. - - Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc. - Takashi Fujiwara FUJITSU LIMITED - fujiwara@a80.tech.yk.fujitsu.co.jp - -******************************************************************/ - -#ifndef _XIMTRANS_H -#define _XIMTRANS_H - -typedef struct _TransIntrCallbackRec *TransIntrCallbackPtr; - -typedef struct _TransIntrCallbackRec { - Bool (*func)( - Xim, INT16, XPointer, XPointer - ); - XPointer call_data; - TransIntrCallbackPtr next; -} TransIntrCallbackRec ; - -typedef struct { - TransIntrCallbackPtr intr_cb; - struct _XtransConnInfo *trans_conn; /* transport connection object */ - int fd; - char *address; - Window window; - Bool is_putback; -} TransSpecRec; - - -/* - * Prototypes - */ - -extern Bool _XimTransRegisterDispatcher( - Xim im, - Bool (*callback)( - Xim, INT16, XPointer, XPointer - ), - XPointer call_data -); - - -extern Bool _XimTransIntrCallback( - Xim im, - Bool (*callback)( - Xim, INT16, XPointer, XPointer - ), - XPointer call_data -); - -extern Bool _XimTransCallDispatcher( - Xim im, - INT16 len, - XPointer data -); - -extern void _XimFreeTransIntrCallback( - Xim im -); - -extern Bool _XimTransFilterWaitEvent( - Display *d, - Window w, - XEvent *ev, - XPointer arg -); - -extern void _XimTransInternalConnection( - Display *d, - int fd, - XPointer arg -); - -extern Bool _XimTransWrite( - Xim im, - INT16 len, - XPointer data -); - -extern Bool _XimTransRead( - Xim im, - XPointer recv_buf, - int buf_len, - int *ret_len -); - -extern void _XimTransFlush( - Xim im -); - -#endif /* _XIMTRANS__H */ +/* + * Copyright 1992 Oracle and/or its affiliates. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +/****************************************************************** + + Copyright 1992, 1993, 1994 by FUJITSU LIMITED + +Permission to use, copy, modify, distribute, and sell this software +and its documentation for any purpose is hereby granted without fee, +provided that the above copyright notice appear in all copies and +that both that copyright notice and this permission notice appear +in supporting documentation, and that the name of FUJITSU LIMITED +not be used in advertising or publicity pertaining to distribution +of the software without specific, written prior permission. +FUJITSU LIMITED makes no representations about the suitability of +this software for any purpose. +It is provided "as is" without express or implied warranty. + +FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +EVENT SHALL FUJITSU LIMITED BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + + Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc. + Takashi Fujiwara FUJITSU LIMITED + fujiwara@a80.tech.yk.fujitsu.co.jp + +******************************************************************/ + +#ifndef _XIMTRANS_H +#define _XIMTRANS_H + +typedef struct _TransIntrCallbackRec *TransIntrCallbackPtr; + +typedef struct _TransIntrCallbackRec { + Bool (*func)( + Xim, INT16, XPointer, XPointer + ); + XPointer call_data; + TransIntrCallbackPtr next; +} TransIntrCallbackRec ; + +typedef struct { + TransIntrCallbackPtr intr_cb; + struct _XtransConnInfo *trans_conn; /* transport connection object */ + int fd; + char *address; + Window window; + Bool is_putback; +} TransSpecRec; + + +/* + * Prototypes + */ + +extern Bool _XimTransRegisterDispatcher( + Xim im, + Bool (*callback)( + Xim, INT16, XPointer, XPointer + ), + XPointer call_data +); + + +extern Bool _XimTransIntrCallback( + Xim im, + Bool (*callback)( + Xim, INT16, XPointer, XPointer + ), + XPointer call_data +); + +extern Bool _XimTransCallDispatcher( + Xim im, + INT16 len, + XPointer data +); + +extern void _XimFreeTransIntrCallback( + Xim im +); + +extern Bool _XimTransFilterWaitEvent( + Display *d, + Window w, + XEvent *ev, + XPointer arg +); + +extern void _XimTransInternalConnection( + Display *d, + int fd, + XPointer arg +); + +extern Bool _XimTransWrite( + Xim im, + INT16 len, + XPointer data +); + +extern Bool _XimTransRead( + Xim im, + XPointer recv_buf, + int buf_len, + int *ret_len +); + +extern void _XimTransFlush( + Xim im +); + +#endif /* _XIMTRANS__H */ diff --git a/libX11/src/xlibi18n/XimintP.h b/libX11/src/xlibi18n/XimintP.h index 89b7c214f..214621d66 100644 --- a/libX11/src/xlibi18n/XimintP.h +++ b/libX11/src/xlibi18n/XimintP.h @@ -1,318 +1,318 @@ -/* - * Copyright 1991, 1992 Sun Microsystems, Inc. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -/****************************************************************** - - Copyright 1992, 1993, 1994 by FUJITSU LIMITED - Copyright 1993, 1994 by Sony Corporation - -Permission to use, copy, modify, distribute, and sell this software and -its documentation for any purpose is hereby granted without fee, provided -that the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation, and that the name of FUJITSU LIMITED and Sony Corporation -not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. FUJITSU LIMITED and -Sony Corporation makes no representations about the suitability of this -software for any purpose. It is provided "as is" without express or -implied warranty. - -FUJITSU LIMITED AND SONY CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD -TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL FUJITSU LIMITED OR SONY CORPORATION BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER -RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, -NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE -USE OR PERFORMANCE OF THIS SOFTWARE. - - Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc. - Takashi Fujiwara FUJITSU LIMITED - fujiwara@a80.tech.yk.fujitsu.co.jp - Makoto Wakamatsu Sony Corporation - makoto@sm.sony.co.jp - Hiroyuki Miyamoto Digital Equipment Corporation - miyamoto@jrd.dec.com - -******************************************************************/ - -#ifndef _XIMINTP_H -#define _XIMINTP_H - -#include "XimProto.h" -#include "XlcPublic.h" - -/* - * for protocol layer callback function - */ -typedef Bool (*XimProtoIntrProc)( - Xim, INT16, XPointer, XPointer -); -typedef struct _XimProtoIntrRec { - XimProtoIntrProc func; - CARD16 major_code; - CARD16 minor_code; - XPointer call_data; - struct _XimProtoIntrRec *next; -} XimProtoIntrRec; - -/* - * for transport layer methods - */ -typedef Bool (*XimTransConnectProc)( - Xim -); -typedef Bool (*XimTransShutdownProc)( - Xim -); -typedef Bool (*XimTransWriteProc)( - Xim, INT16, XPointer -); -typedef Bool (*XimTransReadProc)( - Xim, XPointer, int, int * -); -typedef void (*XimTransFlushProc)( - Xim -); -typedef Bool (*XimTransRegDispatcher)( - Xim, Bool (*)(Xim, INT16, XPointer, XPointer), XPointer -); -typedef Bool (*XimTransCallDispatcher)( - Xim, INT16, XPointer -); - -/* - * private part of IM - */ -typedef struct _XimProtoPrivateRec { - /* The first fields are identical with XimCommonPrivateRec. */ - XlcConv ctom_conv; - XlcConv ctow_conv; - XlcConv ctoutf8_conv; - XlcConv cstomb_conv; - XlcConv cstowc_conv; - XlcConv cstoutf8_conv; - XlcConv ucstoc_conv; - XlcConv ucstoutf8_conv; - - Window im_window; - XIMID imid; - CARD16 unused; - XIMStyles *default_styles; - CARD32 *im_onkeylist; - CARD32 *im_offkeylist; - BITMASK32 flag; - - BITMASK32 registed_filter_event; - EVENTMASK forward_event_mask; - EVENTMASK synchronous_event_mask; - - XimProtoIntrRec *intrproto; - XIMResourceList im_inner_resources; - unsigned int im_num_inner_resources; - XIMResourceList ic_inner_resources; - unsigned int ic_num_inner_resources; - char *hold_data; - int hold_data_len; - char *locale_name; - CARD16 protocol_major_version; - CARD16 protocol_minor_version; - XrmQuark *saved_imvalues; - int num_saved_imvalues; - - /* - * transport specific - */ - XimTransConnectProc connect; - XimTransShutdownProc shutdown; - XimTransWriteProc write; - XimTransReadProc read; - XimTransFlushProc flush; - XimTransRegDispatcher register_dispatcher; - XimTransCallDispatcher call_dispatcher; - XPointer spec; -} XimProtoPrivateRec; - -/* - * bit mask for the flag of XIMPrivateRec - */ -#define SERVER_CONNECTED (1L) -#define DYNAMIC_EVENT_FLOW (1L << 1) -#define USE_AUTHORIZATION_FUNC (1L << 2) -#ifdef XIM_CONNECTABLE -#define DELAYBINDABLE (1L << 3) -#define RECONNECTABLE (1L << 4) -#endif /* XIM_CONNECTABLE */ - -/* - * macro for the flag of XIMPrivateRec - */ -#define IS_SERVER_CONNECTED(im) \ - ((((Xim)im))->private.proto.flag & SERVER_CONNECTED) -#define MARK_SERVER_CONNECTED(im) \ - ((((Xim)im))->private.proto.flag |= SERVER_CONNECTED) -#define UNMARK_SERVER_CONNECTED(im) \ - ((((Xim)im))->private.proto.flag &= ~SERVER_CONNECTED) - -#define IS_DYNAMIC_EVENT_FLOW(im) \ - (((Xim)im)->private.proto.flag & DYNAMIC_EVENT_FLOW) -#define MARK_DYNAMIC_EVENT_FLOW(im) \ - (((Xim)im)->private.proto.flag |= DYNAMIC_EVENT_FLOW) - -#define IS_USE_AUTHORIZATION_FUNC(im) \ - (((Xim)im)->private.proto.flag & USE_AUTHORIZATION_FUNC) -#define MARK_USE_AUTHORIZATION_FUNC(im) \ - (((Xim)im)->private.proto.flag |= USE_AUTHORIZATION_FUNC) - -#ifdef XIM_CONNECTABLE -#define IS_DELAYBINDABLE(im) \ - (((Xim)im)->private.proto.flag & DELAYBINDABLE) -#define MARK_DELAYBINDABLE(im) \ - (((Xim)im)->private.proto.flag |= DELAYBINDABLE) - -#define IS_RECONNECTABLE(im) \ - (((Xim)im)->private.proto.flag & RECONNECTABLE) -#define MARK_RECONNECTABLE(im) \ - (((Xim)im)->private.proto.flag |= RECONNECTABLE) - -#define IS_CONNECTABLE(im) \ - (((Xim)im)->private.proto.flag & (DELAYBINDABLE|RECONNECTABLE)) -#define UNMAKE_CONNECTABLE(im) \ - (((Xim)im)->private.proto.flag &= ~(DELAYBINDABLE|RECONNECTABLE)) -#endif /* XIM_CONNECTABLE */ - -/* - * bit mask for the register_filter_event of XIMPrivateRec/XICPrivateRec - */ -#define KEYPRESS_MASK (1L) -#define KEYRELEASE_MASK (1L << 1) -#define DESTROYNOTIFY_MASK (1L << 2) - -typedef struct _XimCommitInfoRec { - struct _XimCommitInfoRec *next; - char *string; - int string_len; - KeySym *keysym; - int keysym_len; -} XimCommitInfoRec, *XimCommitInfo; - -typedef struct _XimPendingCallback { - int major_opcode; - Xim im; - Xic ic; - char *proto; - int proto_len; - struct _XimPendingCallback *next; -} XimPendingCallbackRec, *XimPendingCallback; - - -/* - * private part of IC - */ -typedef struct _XicProtoPrivateRec { - XICID icid; /* ICID */ - CARD16 dmy; - BITMASK32 flag; /* Input Mode */ - - BITMASK32 registed_filter_event; /* registed filter mask */ - EVENTMASK forward_event_mask; /* forward event mask */ - EVENTMASK synchronous_event_mask;/* sync event mask */ - EVENTMASK filter_event_mask; /* negrect event mask */ - EVENTMASK intercept_event_mask; /* deselect event mask */ - EVENTMASK select_event_mask; /* select event mask */ - - char *preedit_font; /* Base font name list */ - int preedit_font_length; /* length of base font name */ - char *status_font; /* Base font name list */ - int status_font_length; /* length of base font name */ - - XimCommitInfo commit_info; - XIMResourceList ic_resources; - unsigned int ic_num_resources; - XIMResourceList ic_inner_resources; - unsigned int ic_num_inner_resources; - XrmQuark *saved_icvalues; - int num_saved_icvalues; - XimPendingCallback pend_cb_que; - Bool waitCallback; -} XicProtoPrivateRec ; - -/* - * bit mask for the flag of XICPrivateRec - */ -#define IC_CONNECTED (1L) -#define FABLICATED (1L << 1) -#define NEED_SYNC_REPLY (1L << 2) -#define FOCUSED (1L << 3) - -/* - * macro for the flag of XICPrivateRec - */ -#define IS_IC_CONNECTED(ic) \ - (((Xic)ic)->private.proto.flag & IC_CONNECTED) -#define MARK_IC_CONNECTED(ic) \ - (((Xic)ic)->private.proto.flag |= IC_CONNECTED) -#define UNMARK_IC_CONNECTED(ic) \ - (((Xic)ic)->private.proto.flag &= ~IC_CONNECTED) - -#define IS_FABLICATED(ic) \ - (((Xic)ic)->private.proto.flag & FABLICATED) -#define MARK_FABLICATED(ic) \ - (((Xic)ic)->private.proto.flag |= FABLICATED) -#define UNMARK_FABLICATED(ic) \ - (((Xic)ic)->private.proto.flag &= ~FABLICATED) - -#define IS_NEED_SYNC_REPLY(ic) \ - (((Xic)ic)->private.proto.flag & NEED_SYNC_REPLY) -#define MARK_NEED_SYNC_REPLY(ic) \ - (((Xic)ic)->private.proto.flag |= NEED_SYNC_REPLY) -#define UNMARK_NEED_SYNC_REPLY(ic) \ - (((Xic)ic)->private.proto.flag &= ~NEED_SYNC_REPLY) - -#define IS_FOCUSED(ic) \ - (((Xic)ic)->private.proto.flag & FOCUSED) -#define MARK_FOCUSED(ic) \ - (((Xic)ic)->private.proto.flag |= FOCUSED) -#define UNMARK_FOCUSED(ic) \ - (((Xic)ic)->private.proto.flag &= ~FOCUSED) - -/* - * macro for the filter_event_mask of XICPrivateRec - */ -#define IS_NEGLECT_EVENT(ic, mask) \ - (((Xic)ic)->private.proto.filter_event_mask & (mask)) - -/* - * macro for the forward_event_mask of XICPrivateRec - */ -#define IS_FORWARD_EVENT(ic, mask) \ - (((Xic)ic)->private.proto.forward_event_mask & (mask)) - -/* - * macro for the synchronous_event_mask of XICPrivateRec - */ -#define IS_SYNCHRONOUS_EVENT(ic, mask) \ - ((((Xic)ic)->private.proto.synchronous_event_mask & (mask)) ? True: False) - -#define XIM_MAXIMNAMELEN 64 -#define XIM_MAXLCNAMELEN 64 - -#endif /* _XIMINTP_H */ +/* + * Copyright 1991, 1992 Oracle and/or its affiliates. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +/****************************************************************** + + Copyright 1992, 1993, 1994 by FUJITSU LIMITED + Copyright 1993, 1994 by Sony Corporation + +Permission to use, copy, modify, distribute, and sell this software and +its documentation for any purpose is hereby granted without fee, provided +that the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation, and that the name of FUJITSU LIMITED and Sony Corporation +not be used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. FUJITSU LIMITED and +Sony Corporation makes no representations about the suitability of this +software for any purpose. It is provided "as is" without express or +implied warranty. + +FUJITSU LIMITED AND SONY CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD +TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS, IN NO EVENT SHALL FUJITSU LIMITED OR SONY CORPORATION BE LIABLE +FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER +RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, +NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE +USE OR PERFORMANCE OF THIS SOFTWARE. + + Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc. + Takashi Fujiwara FUJITSU LIMITED + fujiwara@a80.tech.yk.fujitsu.co.jp + Makoto Wakamatsu Sony Corporation + makoto@sm.sony.co.jp + Hiroyuki Miyamoto Digital Equipment Corporation + miyamoto@jrd.dec.com + +******************************************************************/ + +#ifndef _XIMINTP_H +#define _XIMINTP_H + +#include "XimProto.h" +#include "XlcPublic.h" + +/* + * for protocol layer callback function + */ +typedef Bool (*XimProtoIntrProc)( + Xim, INT16, XPointer, XPointer +); +typedef struct _XimProtoIntrRec { + XimProtoIntrProc func; + CARD16 major_code; + CARD16 minor_code; + XPointer call_data; + struct _XimProtoIntrRec *next; +} XimProtoIntrRec; + +/* + * for transport layer methods + */ +typedef Bool (*XimTransConnectProc)( + Xim +); +typedef Bool (*XimTransShutdownProc)( + Xim +); +typedef Bool (*XimTransWriteProc)( + Xim, INT16, XPointer +); +typedef Bool (*XimTransReadProc)( + Xim, XPointer, int, int * +); +typedef void (*XimTransFlushProc)( + Xim +); +typedef Bool (*XimTransRegDispatcher)( + Xim, Bool (*)(Xim, INT16, XPointer, XPointer), XPointer +); +typedef Bool (*XimTransCallDispatcher)( + Xim, INT16, XPointer +); + +/* + * private part of IM + */ +typedef struct _XimProtoPrivateRec { + /* The first fields are identical with XimCommonPrivateRec. */ + XlcConv ctom_conv; + XlcConv ctow_conv; + XlcConv ctoutf8_conv; + XlcConv cstomb_conv; + XlcConv cstowc_conv; + XlcConv cstoutf8_conv; + XlcConv ucstoc_conv; + XlcConv ucstoutf8_conv; + + Window im_window; + XIMID imid; + CARD16 unused; + XIMStyles *default_styles; + CARD32 *im_onkeylist; + CARD32 *im_offkeylist; + BITMASK32 flag; + + BITMASK32 registed_filter_event; + EVENTMASK forward_event_mask; + EVENTMASK synchronous_event_mask; + + XimProtoIntrRec *intrproto; + XIMResourceList im_inner_resources; + unsigned int im_num_inner_resources; + XIMResourceList ic_inner_resources; + unsigned int ic_num_inner_resources; + char *hold_data; + int hold_data_len; + char *locale_name; + CARD16 protocol_major_version; + CARD16 protocol_minor_version; + XrmQuark *saved_imvalues; + int num_saved_imvalues; + + /* + * transport specific + */ + XimTransConnectProc connect; + XimTransShutdownProc shutdown; + XimTransWriteProc write; + XimTransReadProc read; + XimTransFlushProc flush; + XimTransRegDispatcher register_dispatcher; + XimTransCallDispatcher call_dispatcher; + XPointer spec; +} XimProtoPrivateRec; + +/* + * bit mask for the flag of XIMPrivateRec + */ +#define SERVER_CONNECTED (1L) +#define DYNAMIC_EVENT_FLOW (1L << 1) +#define USE_AUTHORIZATION_FUNC (1L << 2) +#ifdef XIM_CONNECTABLE +#define DELAYBINDABLE (1L << 3) +#define RECONNECTABLE (1L << 4) +#endif /* XIM_CONNECTABLE */ + +/* + * macro for the flag of XIMPrivateRec + */ +#define IS_SERVER_CONNECTED(im) \ + ((((Xim)im))->private.proto.flag & SERVER_CONNECTED) +#define MARK_SERVER_CONNECTED(im) \ + ((((Xim)im))->private.proto.flag |= SERVER_CONNECTED) +#define UNMARK_SERVER_CONNECTED(im) \ + ((((Xim)im))->private.proto.flag &= ~SERVER_CONNECTED) + +#define IS_DYNAMIC_EVENT_FLOW(im) \ + (((Xim)im)->private.proto.flag & DYNAMIC_EVENT_FLOW) +#define MARK_DYNAMIC_EVENT_FLOW(im) \ + (((Xim)im)->private.proto.flag |= DYNAMIC_EVENT_FLOW) + +#define IS_USE_AUTHORIZATION_FUNC(im) \ + (((Xim)im)->private.proto.flag & USE_AUTHORIZATION_FUNC) +#define MARK_USE_AUTHORIZATION_FUNC(im) \ + (((Xim)im)->private.proto.flag |= USE_AUTHORIZATION_FUNC) + +#ifdef XIM_CONNECTABLE +#define IS_DELAYBINDABLE(im) \ + (((Xim)im)->private.proto.flag & DELAYBINDABLE) +#define MARK_DELAYBINDABLE(im) \ + (((Xim)im)->private.proto.flag |= DELAYBINDABLE) + +#define IS_RECONNECTABLE(im) \ + (((Xim)im)->private.proto.flag & RECONNECTABLE) +#define MARK_RECONNECTABLE(im) \ + (((Xim)im)->private.proto.flag |= RECONNECTABLE) + +#define IS_CONNECTABLE(im) \ + (((Xim)im)->private.proto.flag & (DELAYBINDABLE|RECONNECTABLE)) +#define UNMAKE_CONNECTABLE(im) \ + (((Xim)im)->private.proto.flag &= ~(DELAYBINDABLE|RECONNECTABLE)) +#endif /* XIM_CONNECTABLE */ + +/* + * bit mask for the register_filter_event of XIMPrivateRec/XICPrivateRec + */ +#define KEYPRESS_MASK (1L) +#define KEYRELEASE_MASK (1L << 1) +#define DESTROYNOTIFY_MASK (1L << 2) + +typedef struct _XimCommitInfoRec { + struct _XimCommitInfoRec *next; + char *string; + int string_len; + KeySym *keysym; + int keysym_len; +} XimCommitInfoRec, *XimCommitInfo; + +typedef struct _XimPendingCallback { + int major_opcode; + Xim im; + Xic ic; + char *proto; + int proto_len; + struct _XimPendingCallback *next; +} XimPendingCallbackRec, *XimPendingCallback; + + +/* + * private part of IC + */ +typedef struct _XicProtoPrivateRec { + XICID icid; /* ICID */ + CARD16 dmy; + BITMASK32 flag; /* Input Mode */ + + BITMASK32 registed_filter_event; /* registed filter mask */ + EVENTMASK forward_event_mask; /* forward event mask */ + EVENTMASK synchronous_event_mask;/* sync event mask */ + EVENTMASK filter_event_mask; /* negrect event mask */ + EVENTMASK intercept_event_mask; /* deselect event mask */ + EVENTMASK select_event_mask; /* select event mask */ + + char *preedit_font; /* Base font name list */ + int preedit_font_length; /* length of base font name */ + char *status_font; /* Base font name list */ + int status_font_length; /* length of base font name */ + + XimCommitInfo commit_info; + XIMResourceList ic_resources; + unsigned int ic_num_resources; + XIMResourceList ic_inner_resources; + unsigned int ic_num_inner_resources; + XrmQuark *saved_icvalues; + int num_saved_icvalues; + XimPendingCallback pend_cb_que; + Bool waitCallback; +} XicProtoPrivateRec ; + +/* + * bit mask for the flag of XICPrivateRec + */ +#define IC_CONNECTED (1L) +#define FABLICATED (1L << 1) +#define NEED_SYNC_REPLY (1L << 2) +#define FOCUSED (1L << 3) + +/* + * macro for the flag of XICPrivateRec + */ +#define IS_IC_CONNECTED(ic) \ + (((Xic)ic)->private.proto.flag & IC_CONNECTED) +#define MARK_IC_CONNECTED(ic) \ + (((Xic)ic)->private.proto.flag |= IC_CONNECTED) +#define UNMARK_IC_CONNECTED(ic) \ + (((Xic)ic)->private.proto.flag &= ~IC_CONNECTED) + +#define IS_FABLICATED(ic) \ + (((Xic)ic)->private.proto.flag & FABLICATED) +#define MARK_FABLICATED(ic) \ + (((Xic)ic)->private.proto.flag |= FABLICATED) +#define UNMARK_FABLICATED(ic) \ + (((Xic)ic)->private.proto.flag &= ~FABLICATED) + +#define IS_NEED_SYNC_REPLY(ic) \ + (((Xic)ic)->private.proto.flag & NEED_SYNC_REPLY) +#define MARK_NEED_SYNC_REPLY(ic) \ + (((Xic)ic)->private.proto.flag |= NEED_SYNC_REPLY) +#define UNMARK_NEED_SYNC_REPLY(ic) \ + (((Xic)ic)->private.proto.flag &= ~NEED_SYNC_REPLY) + +#define IS_FOCUSED(ic) \ + (((Xic)ic)->private.proto.flag & FOCUSED) +#define MARK_FOCUSED(ic) \ + (((Xic)ic)->private.proto.flag |= FOCUSED) +#define UNMARK_FOCUSED(ic) \ + (((Xic)ic)->private.proto.flag &= ~FOCUSED) + +/* + * macro for the filter_event_mask of XICPrivateRec + */ +#define IS_NEGLECT_EVENT(ic, mask) \ + (((Xic)ic)->private.proto.filter_event_mask & (mask)) + +/* + * macro for the forward_event_mask of XICPrivateRec + */ +#define IS_FORWARD_EVENT(ic, mask) \ + (((Xic)ic)->private.proto.forward_event_mask & (mask)) + +/* + * macro for the synchronous_event_mask of XICPrivateRec + */ +#define IS_SYNCHRONOUS_EVENT(ic, mask) \ + ((((Xic)ic)->private.proto.synchronous_event_mask & (mask)) ? True: False) + +#define XIM_MAXIMNAMELEN 64 +#define XIM_MAXLCNAMELEN 64 + +#endif /* _XIMINTP_H */ diff --git a/libX11/src/xlibi18n/XlcDL.c b/libX11/src/xlibi18n/XlcDL.c index 879bc51eb..58e9ade87 100644 --- a/libX11/src/xlibi18n/XlcDL.c +++ b/libX11/src/xlibi18n/XlcDL.c @@ -1,652 +1,652 @@ -/* -Copyright 1985, 1986, 1987, 1991, 1998 The Open Group - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: The above copyright notice and this -permission notice shall be included in all copies or substantial -portions of the Software. - - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE -EVEN IF ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES. - - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - -X Window System is a trademark of The Open Group - -OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF -logo, LBX, X Window System, and Xinerama are trademarks of the Open -Group. All other trademarks and registered trademarks mentioned herein -are the property of their respective owners. No right, title or -interest in or to any trademark, service mark, logo or trade name of -Sun Microsystems, Inc. or its licensors is granted. - -*/ -/* - * Copyright 2000 Sun Microsystems, Inc. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -#ifdef HAVE_CONFIG_H -# include -#else -# if defined(hpux) -# define HAVE_DL_H -# else -# define HAVE_DLFCN_H -# endif -#endif - -#include - -#ifdef HAVE_DL_H -#include -#endif - -#ifdef HAVE_DLFCN_H -#include -#endif - -#include - -#include "Xlibint.h" -#include "XlcPublic.h" -#include "XlcPubI.h" - -#if defined(_LP64) && defined(__sparcv9) -# define _MACH64_NAME "sparcv9" -#else -# undef _MACH64_NAME -#endif /* defined(_LP64) && defined(__sparcv9) */ - -#ifdef _MACH64_NAME -# define _MACH64_NAME_LEN (sizeof (_MACH64_NAME) - 1) -#endif - -#define XI18N_DLREL 2 - -#define iscomment(ch) ((ch) == '\0' || (ch) == '#') - -typedef enum { - XLC_OBJECT, - XIM_OBJECT, - XOM_OBJECT -} XI18NDLType; - -typedef struct { - XI18NDLType type; - int locale_name_len; - char *locale_name; - char *dl_name; - char *open; - char *im_register; - char *im_unregister; - int dl_release; - unsigned int refcount; -#if defined(hpux) - shl_t dl_module; -#else - void *dl_module; -#endif -} XI18NObjectsListRec, *XI18NObjectsList; - -#define OBJECT_INIT_LEN 8 -#define OBJECT_INC_LEN 4 -static int lc_len = 0; -static XI18NObjectsListRec *xi18n_objects_list = NULL; -static int lc_count = 0; - -static int -parse_line(char *line, char **argv, int argsize) -{ - int argc = 0; - char *p = line; - - while (argc < argsize) { - while (isspace(*p)) { - ++p; - } - if (iscomment(*p)){ - break; - } - argv[argc++] = p; - while (!isspace(*p)) { - ++p; - } - if (iscomment(*p)) { - break; - } - *p++ = '\0'; - } - return argc; -} - -static char * -strdup_with_underscore(const char *symbol) -{ - char *result; - - if ((result = malloc(strlen(symbol) + 2)) == NULL) - return NULL; - result[0] = '_'; - strcpy(result + 1, symbol); - return result; -} - -#ifndef hpux -static void * -try_both_dlsym (void *handle, char *name) -{ - void *ret; - - ret = dlsym (handle, name); - if (!ret) - { - name = strdup_with_underscore (name); - if (name) - { - ret = dlsym (handle, name); - free (name); - } - } - return ret; -} -#endif - -static void -resolve_object(char *path, const char *lc_name) -{ - char filename[BUFSIZ]; - FILE *fp; - char buf[BUFSIZ]; - - if (lc_len == 0) { /* True only for the 1st time */ - lc_len = OBJECT_INIT_LEN; - xi18n_objects_list = (XI18NObjectsList) - Xmalloc(sizeof(XI18NObjectsListRec) * lc_len); - if (!xi18n_objects_list) return; - } -/* -1266793 -Limit the length of path to prevent stack buffer corruption. - sprintf(filename, "%s/%s", path, "XI18N_OBJS"); -*/ - sprintf(filename, "%.*s/%s", BUFSIZ - 12, path, "XI18N_OBJS"); - fp = fopen(filename, "r"); - if (fp == (FILE *)NULL){ - return; - } - - while (fgets(buf, BUFSIZ, fp) != NULL){ - char *p = buf; - int n; - char *args[6]; - while (isspace(*p)){ - ++p; - } - if (iscomment(*p)){ - continue; - } - - if (lc_count == lc_len) { - lc_len += OBJECT_INC_LEN; - xi18n_objects_list = (XI18NObjectsList) - Xrealloc(xi18n_objects_list, - sizeof(XI18NObjectsListRec) * lc_len); - if (!xi18n_objects_list) return; - } - n = parse_line(p, args, 6); - - if (n == 3 || n == 5) { - if (!strcmp(args[0], "XLC")){ - xi18n_objects_list[lc_count].type = XLC_OBJECT; - } else if (!strcmp(args[0], "XOM")){ - xi18n_objects_list[lc_count].type = XOM_OBJECT; - } else if (!strcmp(args[0], "XIM")){ - xi18n_objects_list[lc_count].type = XIM_OBJECT; - } - xi18n_objects_list[lc_count].dl_name = strdup(args[1]); - xi18n_objects_list[lc_count].open = strdup(args[2]); - xi18n_objects_list[lc_count].dl_release = XI18N_DLREL; - xi18n_objects_list[lc_count].locale_name = strdup(lc_name); - xi18n_objects_list[lc_count].refcount = 0; - xi18n_objects_list[lc_count].dl_module = (void*)NULL; - if (n == 5) { - xi18n_objects_list[lc_count].im_register = strdup(args[3]); - xi18n_objects_list[lc_count].im_unregister = strdup(args[4]); - } else { - xi18n_objects_list[lc_count].im_register = NULL; - xi18n_objects_list[lc_count].im_unregister = NULL; - } - lc_count++; - } - } - fclose(fp); -} - -static char* -__lc_path(const char *dl_name, const char *lc_dir) -{ - char *path; - size_t len; - - /* - * reject this for possible security issue - */ - if (strstr (dl_name, "../")) - return NULL; - -#if defined (_LP64) && defined (_MACH64_NAME) - len = (lc_dir ? strlen(lc_dir) : 0 ) + - (dl_name ? strlen(dl_name) : 0) + _MACH64_NAME_LEN + 10; - path = Xmalloc(len + 1); - - if (strchr(dl_name, '/') != NULL) { - char *tmp = strdup(dl_name); - char *dl_dir, *dl_file; - char *slash_p; - slash_p = strchr(tmp, '/'); - *slash_p = '\0'; - dl_dir = tmp; - dl_file = ++slash_p; - - slash_p = strrchr(lc_dir, '/'); - *slash_p = '\0'; - strcpy(path, lc_dir); strcat(path, "/"); - strcat(path, dl_dir); strcat(path, "/"); - strcat(path, _MACH64_NAME); strcat(path, "/"); - strcat(path, dl_file); strcat(path, ".so.2"); - - *slash_p = '/'; - Xfree(tmp); - } else { - strcpy(path, lc_dir); strcat(path, "/"); - strcat(path, _MACH64_NAME); strcat(path, "/"); - strcat(path, dl_name); strcat(path, ".so.2"); - } -#else - len = (lc_dir ? strlen(lc_dir) : 0 ) + - (dl_name ? strlen(dl_name) : 0) + 10; -#if defined POSTLOCALELIBDIR - len += (strlen(POSTLOCALELIBDIR) + 1); -#endif - path = Xmalloc(len + 1); - - if (strchr(dl_name, '/') != NULL) { - char *slash_p; - slash_p = strrchr(lc_dir, '/'); - *slash_p = '\0'; - strcpy(path, lc_dir); strcat(path, "/"); -#if defined POSTLOCALELIBDIR - strcat(path, POSTLOCALELIBDIR); strcat(path, "/"); -#endif - strcat(path, dl_name); strcat(path, ".so.2"); - *slash_p = '/'; - } else { - strcpy(path, lc_dir); strcat(path, "/"); -#if defined POSTLOCALELIBDIR - strcat(path, POSTLOCALELIBDIR); strcat(path, "/"); -#endif - strcat(path, dl_name); strcat(path, ".so.2"); - } -#endif - return path; -} - -/* We reference count dlopen() and dlclose() of modules; unfortunately, - * since XCloseIM, XCloseOM, XlcClose aren't wrapped, but directly - * call the close method of the object, we leak a reference count every - * time we open then close a module. Fixing this would require - * either creating proxy objects or hooks for close_im/close_om - * in XLCd - */ -static Bool -open_object( - XI18NObjectsList object, - char *lc_dir) -{ - char *path; - - if (object->refcount == 0) { - path = __lc_path(object->dl_name, lc_dir); - if (!path) - return False; -#if defined(hpux) - object->dl_module = shl_load(path, BIND_DEFERRED, 0L); -#else - object->dl_module = dlopen(path, RTLD_LAZY); -#endif - Xfree(path); - - if (!object->dl_module) - return False; - } - - object->refcount++; - return True; -} - -static void * -fetch_symbol( - XI18NObjectsList object, - char *symbol) -{ - void *result = NULL; -#if defined(hpux) - int getsyms_cnt, i; - struct shl_symbol *symbols; -#endif - - if (symbol == NULL) - return NULL; - -#if defined(hpux) - getsyms_cnt = shl_getsymbols(object->dl_module, TYPE_PROCEDURE, - EXPORT_SYMBOLS, malloc, &symbols); - - for(i=0; i 0) { - free(symbols); - } -#else - result = try_both_dlsym(object->dl_module, symbol); -#endif - - return result; -} - -static void -close_object(XI18NObjectsList object) -{ - object->refcount--; - if (object->refcount == 0) - { -#if defined(hpux) - shl_unload(object->dl_module); -#else - dlclose(object->dl_module); -#endif - object->dl_module = NULL; - } -} - - -typedef XLCd (*dynamicLoadProc)(const char *); - -XLCd -_XlcDynamicLoad(const char *lc_name) -{ - XLCd lcd = (XLCd)NULL; - dynamicLoadProc lc_loader = (dynamicLoadProc)NULL; - int count; - XI18NObjectsList objects_list; - char lc_dir[BUFSIZE], lc_lib_dir[BUFSIZE]; - - if (lc_name == NULL) return (XLCd)NULL; - - if (_XlcLocaleDirName(lc_dir, BUFSIZE, (char *)lc_name) == (char *)NULL) - return (XLCd)NULL; - if (_XlcLocaleLibDirName(lc_lib_dir, BUFSIZE, (char *)lc_name) == (char*)NULL) - return (XLCd)NULL; - - resolve_object(lc_dir, lc_name); - resolve_object(lc_lib_dir, lc_name); - - objects_list = xi18n_objects_list; - count = lc_count; - for (; count-- > 0; objects_list++) { - if (objects_list->type != XLC_OBJECT || - strcmp(objects_list->locale_name, lc_name)) continue; - if (!open_object (objects_list, lc_dir) && \ - !open_object (objects_list, lc_lib_dir)) - continue; - - lc_loader = (dynamicLoadProc)fetch_symbol (objects_list, objects_list->open); - if (!lc_loader) continue; - lcd = (*lc_loader)(lc_name); - if (lcd != (XLCd)NULL) { - break; - } - - close_object (objects_list); - } - return (XLCd)lcd; -} - - -typedef XIM (*dynamicOpenProcp)(XLCd, Display *, XrmDatabase, char *, char *); - -static XIM -_XDynamicOpenIM(XLCd lcd, Display *display, XrmDatabase rdb, - char *res_name, char *res_class) -{ - XIM im = (XIM)NULL; - char lc_dir[BUFSIZE]; - char *lc_name; - dynamicOpenProcp im_openIM = (dynamicOpenProcp)NULL; - int count; - XI18NObjectsList objects_list = xi18n_objects_list; - - lc_name = lcd->core->name; - - if (_XlcLocaleLibDirName(lc_dir, BUFSIZE, lc_name) == NULL) return (XIM)0; - - count = lc_count; - for (; count-- > 0; objects_list++) { - if (objects_list->type != XIM_OBJECT || - strcmp(objects_list->locale_name, lc_name)) continue; - - if (!open_object (objects_list, lc_dir)) - continue; - - im_openIM = (dynamicOpenProcp)fetch_symbol(objects_list, objects_list->open); - if (!im_openIM) continue; - im = (*im_openIM)(lcd, display, rdb, res_name, res_class); - if (im != (XIM)NULL) { - break; - } - - close_object (objects_list); - } - return (XIM)im; -} - -typedef Bool (*dynamicRegisterCBProcp)( - XLCd, Display *, XrmDatabase, char *, char *, XIDProc, XPointer); - -static Bool -_XDynamicRegisterIMInstantiateCallback( - XLCd lcd, - Display *display, - XrmDatabase rdb, - char *res_name, - char *res_class, - XIDProc callback, - XPointer client_data) -{ - char lc_dir[BUFSIZE]; - char *lc_name; - dynamicRegisterCBProcp im_registerIM = (dynamicRegisterCBProcp)NULL; - Bool ret_flag = False; - int count; - XI18NObjectsList objects_list = xi18n_objects_list; -#if defined(hpux) - int getsyms_cnt, i; - struct shl_symbol *symbols; -#endif - - lc_name = lcd->core->name; - - if (_XlcLocaleLibDirName(lc_dir, BUFSIZE, lc_name) == NULL) return False; - - count = lc_count; - for (; count-- > 0; objects_list++) { - if (objects_list->type != XIM_OBJECT || - strcmp(objects_list->locale_name, lc_name)) continue; - - if (!open_object (objects_list, lc_dir)) - continue; - im_registerIM = (dynamicRegisterCBProcp)fetch_symbol(objects_list, - objects_list->im_register); - if (!im_registerIM) continue; - ret_flag = (*im_registerIM)(lcd, display, rdb, - res_name, res_class, - callback, client_data); - if (ret_flag) break; - - close_object (objects_list); - } - return (Bool)ret_flag; -} - -typedef Bool (*dynamicUnregisterProcp)( - XLCd, Display *, XrmDatabase, char *, char *, XIDProc, XPointer); - -static Bool -_XDynamicUnRegisterIMInstantiateCallback( - XLCd lcd, - Display *display, - XrmDatabase rdb, - char *res_name, - char *res_class, - XIDProc callback, - XPointer client_data) -{ - char lc_dir[BUFSIZE]; - char *lc_name; - dynamicUnregisterProcp im_unregisterIM = (dynamicUnregisterProcp)NULL; - Bool ret_flag = False; - int count; - XI18NObjectsList objects_list = xi18n_objects_list; -#if defined(hpux) - int getsyms_cnt, i; - struct shl_symbol *symbols; -#endif - - lc_name = lcd->core->name; - if (_XlcLocaleDirName(lc_dir, BUFSIZE, lc_name) == NULL) return False; - - count = lc_count; - for (; count-- > 0; objects_list++) { - if (objects_list->type != XIM_OBJECT || - strcmp(objects_list->locale_name, lc_name)) continue; - - if (!objects_list->refcount) /* Must already be opened */ - continue; - - im_unregisterIM = (dynamicUnregisterProcp)fetch_symbol(objects_list, - objects_list->im_unregister); - - if (!im_unregisterIM) continue; - ret_flag = (*im_unregisterIM)(lcd, display, rdb, - res_name, res_class, - callback, client_data); - if (ret_flag) { - close_object (objects_list); /* opened in RegisterIMInstantiateCallback */ - break; - } - } - return (Bool)ret_flag; -} - -Bool -_XInitDynamicIM(XLCd lcd) -{ - if(lcd == (XLCd)NULL) - return False; - lcd->methods->open_im = _XDynamicOpenIM; - lcd->methods->register_callback = _XDynamicRegisterIMInstantiateCallback; - lcd->methods->unregister_callback = _XDynamicUnRegisterIMInstantiateCallback; - return True; -} - - -typedef XOM (*dynamicIOpenProcp)( - XLCd, Display *, XrmDatabase, _Xconst char *, _Xconst char *); - -static XOM -_XDynamicOpenOM(XLCd lcd, Display *display, XrmDatabase rdb, - _Xconst char *res_name, _Xconst char *res_class) -{ - XOM om = (XOM)NULL; - int count; - char lc_dir[BUFSIZE]; - char *lc_name; - dynamicIOpenProcp om_openOM = (dynamicIOpenProcp)NULL; - XI18NObjectsList objects_list = xi18n_objects_list; -#if defined(hpux) - int getsyms_cnt, i; - struct shl_symbol *symbols; -#endif - - lc_name = lcd->core->name; - - if (_XlcLocaleLibDirName(lc_dir, BUFSIZE, lc_name) == NULL) return (XOM)0; - - count = lc_count; - for (; count-- > 0; objects_list++) { - if (objects_list->type != XOM_OBJECT || - strcmp(objects_list->locale_name, lc_name)) continue; - if (!open_object (objects_list, lc_dir)) - continue; - - om_openOM = (dynamicIOpenProcp)fetch_symbol(objects_list, objects_list->open); - if (!om_openOM) continue; - om = (*om_openOM)(lcd, display, rdb, res_name, res_class); - if (om != (XOM)NULL) { - break; - } - close_object(objects_list); - } - return (XOM)om; -} - -Bool -_XInitDynamicOM(XLCd lcd) -{ - if(lcd == (XLCd)NULL) - return False; - - lcd->methods->open_om = _XDynamicOpenOM; - - return True; -} +/* +Copyright 1985, 1986, 1987, 1991, 1998 The Open Group + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: The above copyright notice and this +permission notice shall be included in all copies or substantial +portions of the Software. + + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE +EVEN IF ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES. + + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + + +X Window System is a trademark of The Open Group + +OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF +logo, LBX, X Window System, and Xinerama are trademarks of the Open +Group. All other trademarks and registered trademarks mentioned herein +are the property of their respective owners. No right, title or +interest in or to any trademark, service mark, logo or trade name of +Sun Microsystems, Inc. or its licensors is granted. + +*/ +/* + * Copyright 2000 Oracle and/or its affiliates. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + + +#ifdef HAVE_CONFIG_H +# include +#else +# if defined(hpux) +# define HAVE_DL_H +# else +# define HAVE_DLFCN_H +# endif +#endif + +#include + +#ifdef HAVE_DL_H +#include +#endif + +#ifdef HAVE_DLFCN_H +#include +#endif + +#include + +#include "Xlibint.h" +#include "XlcPublic.h" +#include "XlcPubI.h" + +#if defined(_LP64) && defined(__sparcv9) +# define _MACH64_NAME "sparcv9" +#else +# undef _MACH64_NAME +#endif /* defined(_LP64) && defined(__sparcv9) */ + +#ifdef _MACH64_NAME +# define _MACH64_NAME_LEN (sizeof (_MACH64_NAME) - 1) +#endif + +#define XI18N_DLREL 2 + +#define iscomment(ch) ((ch) == '\0' || (ch) == '#') + +typedef enum { + XLC_OBJECT, + XIM_OBJECT, + XOM_OBJECT +} XI18NDLType; + +typedef struct { + XI18NDLType type; + int locale_name_len; + char *locale_name; + char *dl_name; + char *open; + char *im_register; + char *im_unregister; + int dl_release; + unsigned int refcount; +#if defined(hpux) + shl_t dl_module; +#else + void *dl_module; +#endif +} XI18NObjectsListRec, *XI18NObjectsList; + +#define OBJECT_INIT_LEN 8 +#define OBJECT_INC_LEN 4 +static int lc_len = 0; +static XI18NObjectsListRec *xi18n_objects_list = NULL; +static int lc_count = 0; + +static int +parse_line(char *line, char **argv, int argsize) +{ + int argc = 0; + char *p = line; + + while (argc < argsize) { + while (isspace(*p)) { + ++p; + } + if (iscomment(*p)){ + break; + } + argv[argc++] = p; + while (!isspace(*p)) { + ++p; + } + if (iscomment(*p)) { + break; + } + *p++ = '\0'; + } + return argc; +} + +static char * +strdup_with_underscore(const char *symbol) +{ + char *result; + + if ((result = malloc(strlen(symbol) + 2)) == NULL) + return NULL; + result[0] = '_'; + strcpy(result + 1, symbol); + return result; +} + +#ifndef hpux +static void * +try_both_dlsym (void *handle, char *name) +{ + void *ret; + + ret = dlsym (handle, name); + if (!ret) + { + name = strdup_with_underscore (name); + if (name) + { + ret = dlsym (handle, name); + free (name); + } + } + return ret; +} +#endif + +static void +resolve_object(char *path, const char *lc_name) +{ + char filename[BUFSIZ]; + FILE *fp; + char buf[BUFSIZ]; + + if (lc_len == 0) { /* True only for the 1st time */ + lc_len = OBJECT_INIT_LEN; + xi18n_objects_list = (XI18NObjectsList) + Xmalloc(sizeof(XI18NObjectsListRec) * lc_len); + if (!xi18n_objects_list) return; + } +/* +1266793 +Limit the length of path to prevent stack buffer corruption. + sprintf(filename, "%s/%s", path, "XI18N_OBJS"); +*/ + sprintf(filename, "%.*s/%s", BUFSIZ - 12, path, "XI18N_OBJS"); + fp = fopen(filename, "r"); + if (fp == (FILE *)NULL){ + return; + } + + while (fgets(buf, BUFSIZ, fp) != NULL){ + char *p = buf; + int n; + char *args[6]; + while (isspace(*p)){ + ++p; + } + if (iscomment(*p)){ + continue; + } + + if (lc_count == lc_len) { + lc_len += OBJECT_INC_LEN; + xi18n_objects_list = (XI18NObjectsList) + Xrealloc(xi18n_objects_list, + sizeof(XI18NObjectsListRec) * lc_len); + if (!xi18n_objects_list) return; + } + n = parse_line(p, args, 6); + + if (n == 3 || n == 5) { + if (!strcmp(args[0], "XLC")){ + xi18n_objects_list[lc_count].type = XLC_OBJECT; + } else if (!strcmp(args[0], "XOM")){ + xi18n_objects_list[lc_count].type = XOM_OBJECT; + } else if (!strcmp(args[0], "XIM")){ + xi18n_objects_list[lc_count].type = XIM_OBJECT; + } + xi18n_objects_list[lc_count].dl_name = strdup(args[1]); + xi18n_objects_list[lc_count].open = strdup(args[2]); + xi18n_objects_list[lc_count].dl_release = XI18N_DLREL; + xi18n_objects_list[lc_count].locale_name = strdup(lc_name); + xi18n_objects_list[lc_count].refcount = 0; + xi18n_objects_list[lc_count].dl_module = (void*)NULL; + if (n == 5) { + xi18n_objects_list[lc_count].im_register = strdup(args[3]); + xi18n_objects_list[lc_count].im_unregister = strdup(args[4]); + } else { + xi18n_objects_list[lc_count].im_register = NULL; + xi18n_objects_list[lc_count].im_unregister = NULL; + } + lc_count++; + } + } + fclose(fp); +} + +static char* +__lc_path(const char *dl_name, const char *lc_dir) +{ + char *path; + size_t len; + + /* + * reject this for possible security issue + */ + if (strstr (dl_name, "../")) + return NULL; + +#if defined (_LP64) && defined (_MACH64_NAME) + len = (lc_dir ? strlen(lc_dir) : 0 ) + + (dl_name ? strlen(dl_name) : 0) + _MACH64_NAME_LEN + 10; + path = Xmalloc(len + 1); + + if (strchr(dl_name, '/') != NULL) { + char *tmp = strdup(dl_name); + char *dl_dir, *dl_file; + char *slash_p; + slash_p = strchr(tmp, '/'); + *slash_p = '\0'; + dl_dir = tmp; + dl_file = ++slash_p; + + slash_p = strrchr(lc_dir, '/'); + *slash_p = '\0'; + strcpy(path, lc_dir); strcat(path, "/"); + strcat(path, dl_dir); strcat(path, "/"); + strcat(path, _MACH64_NAME); strcat(path, "/"); + strcat(path, dl_file); strcat(path, ".so.2"); + + *slash_p = '/'; + Xfree(tmp); + } else { + strcpy(path, lc_dir); strcat(path, "/"); + strcat(path, _MACH64_NAME); strcat(path, "/"); + strcat(path, dl_name); strcat(path, ".so.2"); + } +#else + len = (lc_dir ? strlen(lc_dir) : 0 ) + + (dl_name ? strlen(dl_name) : 0) + 10; +#if defined POSTLOCALELIBDIR + len += (strlen(POSTLOCALELIBDIR) + 1); +#endif + path = Xmalloc(len + 1); + + if (strchr(dl_name, '/') != NULL) { + char *slash_p; + slash_p = strrchr(lc_dir, '/'); + *slash_p = '\0'; + strcpy(path, lc_dir); strcat(path, "/"); +#if defined POSTLOCALELIBDIR + strcat(path, POSTLOCALELIBDIR); strcat(path, "/"); +#endif + strcat(path, dl_name); strcat(path, ".so.2"); + *slash_p = '/'; + } else { + strcpy(path, lc_dir); strcat(path, "/"); +#if defined POSTLOCALELIBDIR + strcat(path, POSTLOCALELIBDIR); strcat(path, "/"); +#endif + strcat(path, dl_name); strcat(path, ".so.2"); + } +#endif + return path; +} + +/* We reference count dlopen() and dlclose() of modules; unfortunately, + * since XCloseIM, XCloseOM, XlcClose aren't wrapped, but directly + * call the close method of the object, we leak a reference count every + * time we open then close a module. Fixing this would require + * either creating proxy objects or hooks for close_im/close_om + * in XLCd + */ +static Bool +open_object( + XI18NObjectsList object, + char *lc_dir) +{ + char *path; + + if (object->refcount == 0) { + path = __lc_path(object->dl_name, lc_dir); + if (!path) + return False; +#if defined(hpux) + object->dl_module = shl_load(path, BIND_DEFERRED, 0L); +#else + object->dl_module = dlopen(path, RTLD_LAZY); +#endif + Xfree(path); + + if (!object->dl_module) + return False; + } + + object->refcount++; + return True; +} + +static void * +fetch_symbol( + XI18NObjectsList object, + char *symbol) +{ + void *result = NULL; +#if defined(hpux) + int getsyms_cnt, i; + struct shl_symbol *symbols; +#endif + + if (symbol == NULL) + return NULL; + +#if defined(hpux) + getsyms_cnt = shl_getsymbols(object->dl_module, TYPE_PROCEDURE, + EXPORT_SYMBOLS, malloc, &symbols); + + for(i=0; i 0) { + free(symbols); + } +#else + result = try_both_dlsym(object->dl_module, symbol); +#endif + + return result; +} + +static void +close_object(XI18NObjectsList object) +{ + object->refcount--; + if (object->refcount == 0) + { +#if defined(hpux) + shl_unload(object->dl_module); +#else + dlclose(object->dl_module); +#endif + object->dl_module = NULL; + } +} + + +typedef XLCd (*dynamicLoadProc)(const char *); + +XLCd +_XlcDynamicLoad(const char *lc_name) +{ + XLCd lcd = (XLCd)NULL; + dynamicLoadProc lc_loader = (dynamicLoadProc)NULL; + int count; + XI18NObjectsList objects_list; + char lc_dir[BUFSIZE], lc_lib_dir[BUFSIZE]; + + if (lc_name == NULL) return (XLCd)NULL; + + if (_XlcLocaleDirName(lc_dir, BUFSIZE, (char *)lc_name) == (char *)NULL) + return (XLCd)NULL; + if (_XlcLocaleLibDirName(lc_lib_dir, BUFSIZE, (char *)lc_name) == (char*)NULL) + return (XLCd)NULL; + + resolve_object(lc_dir, lc_name); + resolve_object(lc_lib_dir, lc_name); + + objects_list = xi18n_objects_list; + count = lc_count; + for (; count-- > 0; objects_list++) { + if (objects_list->type != XLC_OBJECT || + strcmp(objects_list->locale_name, lc_name)) continue; + if (!open_object (objects_list, lc_dir) && \ + !open_object (objects_list, lc_lib_dir)) + continue; + + lc_loader = (dynamicLoadProc)fetch_symbol (objects_list, objects_list->open); + if (!lc_loader) continue; + lcd = (*lc_loader)(lc_name); + if (lcd != (XLCd)NULL) { + break; + } + + close_object (objects_list); + } + return (XLCd)lcd; +} + + +typedef XIM (*dynamicOpenProcp)(XLCd, Display *, XrmDatabase, char *, char *); + +static XIM +_XDynamicOpenIM(XLCd lcd, Display *display, XrmDatabase rdb, + char *res_name, char *res_class) +{ + XIM im = (XIM)NULL; + char lc_dir[BUFSIZE]; + char *lc_name; + dynamicOpenProcp im_openIM = (dynamicOpenProcp)NULL; + int count; + XI18NObjectsList objects_list = xi18n_objects_list; + + lc_name = lcd->core->name; + + if (_XlcLocaleLibDirName(lc_dir, BUFSIZE, lc_name) == NULL) return (XIM)0; + + count = lc_count; + for (; count-- > 0; objects_list++) { + if (objects_list->type != XIM_OBJECT || + strcmp(objects_list->locale_name, lc_name)) continue; + + if (!open_object (objects_list, lc_dir)) + continue; + + im_openIM = (dynamicOpenProcp)fetch_symbol(objects_list, objects_list->open); + if (!im_openIM) continue; + im = (*im_openIM)(lcd, display, rdb, res_name, res_class); + if (im != (XIM)NULL) { + break; + } + + close_object (objects_list); + } + return (XIM)im; +} + +typedef Bool (*dynamicRegisterCBProcp)( + XLCd, Display *, XrmDatabase, char *, char *, XIDProc, XPointer); + +static Bool +_XDynamicRegisterIMInstantiateCallback( + XLCd lcd, + Display *display, + XrmDatabase rdb, + char *res_name, + char *res_class, + XIDProc callback, + XPointer client_data) +{ + char lc_dir[BUFSIZE]; + char *lc_name; + dynamicRegisterCBProcp im_registerIM = (dynamicRegisterCBProcp)NULL; + Bool ret_flag = False; + int count; + XI18NObjectsList objects_list = xi18n_objects_list; +#if defined(hpux) + int getsyms_cnt, i; + struct shl_symbol *symbols; +#endif + + lc_name = lcd->core->name; + + if (_XlcLocaleLibDirName(lc_dir, BUFSIZE, lc_name) == NULL) return False; + + count = lc_count; + for (; count-- > 0; objects_list++) { + if (objects_list->type != XIM_OBJECT || + strcmp(objects_list->locale_name, lc_name)) continue; + + if (!open_object (objects_list, lc_dir)) + continue; + im_registerIM = (dynamicRegisterCBProcp)fetch_symbol(objects_list, + objects_list->im_register); + if (!im_registerIM) continue; + ret_flag = (*im_registerIM)(lcd, display, rdb, + res_name, res_class, + callback, client_data); + if (ret_flag) break; + + close_object (objects_list); + } + return (Bool)ret_flag; +} + +typedef Bool (*dynamicUnregisterProcp)( + XLCd, Display *, XrmDatabase, char *, char *, XIDProc, XPointer); + +static Bool +_XDynamicUnRegisterIMInstantiateCallback( + XLCd lcd, + Display *display, + XrmDatabase rdb, + char *res_name, + char *res_class, + XIDProc callback, + XPointer client_data) +{ + char lc_dir[BUFSIZE]; + char *lc_name; + dynamicUnregisterProcp im_unregisterIM = (dynamicUnregisterProcp)NULL; + Bool ret_flag = False; + int count; + XI18NObjectsList objects_list = xi18n_objects_list; +#if defined(hpux) + int getsyms_cnt, i; + struct shl_symbol *symbols; +#endif + + lc_name = lcd->core->name; + if (_XlcLocaleDirName(lc_dir, BUFSIZE, lc_name) == NULL) return False; + + count = lc_count; + for (; count-- > 0; objects_list++) { + if (objects_list->type != XIM_OBJECT || + strcmp(objects_list->locale_name, lc_name)) continue; + + if (!objects_list->refcount) /* Must already be opened */ + continue; + + im_unregisterIM = (dynamicUnregisterProcp)fetch_symbol(objects_list, + objects_list->im_unregister); + + if (!im_unregisterIM) continue; + ret_flag = (*im_unregisterIM)(lcd, display, rdb, + res_name, res_class, + callback, client_data); + if (ret_flag) { + close_object (objects_list); /* opened in RegisterIMInstantiateCallback */ + break; + } + } + return (Bool)ret_flag; +} + +Bool +_XInitDynamicIM(XLCd lcd) +{ + if(lcd == (XLCd)NULL) + return False; + lcd->methods->open_im = _XDynamicOpenIM; + lcd->methods->register_callback = _XDynamicRegisterIMInstantiateCallback; + lcd->methods->unregister_callback = _XDynamicUnRegisterIMInstantiateCallback; + return True; +} + + +typedef XOM (*dynamicIOpenProcp)( + XLCd, Display *, XrmDatabase, _Xconst char *, _Xconst char *); + +static XOM +_XDynamicOpenOM(XLCd lcd, Display *display, XrmDatabase rdb, + _Xconst char *res_name, _Xconst char *res_class) +{ + XOM om = (XOM)NULL; + int count; + char lc_dir[BUFSIZE]; + char *lc_name; + dynamicIOpenProcp om_openOM = (dynamicIOpenProcp)NULL; + XI18NObjectsList objects_list = xi18n_objects_list; +#if defined(hpux) + int getsyms_cnt, i; + struct shl_symbol *symbols; +#endif + + lc_name = lcd->core->name; + + if (_XlcLocaleLibDirName(lc_dir, BUFSIZE, lc_name) == NULL) return (XOM)0; + + count = lc_count; + for (; count-- > 0; objects_list++) { + if (objects_list->type != XOM_OBJECT || + strcmp(objects_list->locale_name, lc_name)) continue; + if (!open_object (objects_list, lc_dir)) + continue; + + om_openOM = (dynamicIOpenProcp)fetch_symbol(objects_list, objects_list->open); + if (!om_openOM) continue; + om = (*om_openOM)(lcd, display, rdb, res_name, res_class); + if (om != (XOM)NULL) { + break; + } + close_object(objects_list); + } + return (XOM)om; +} + +Bool +_XInitDynamicOM(XLCd lcd) +{ + if(lcd == (XLCd)NULL) + return False; + + lcd->methods->open_om = _XDynamicOpenOM; + + return True; +} diff --git a/libX11/src/xlibi18n/XlcSL.c b/libX11/src/xlibi18n/XlcSL.c index 526f677fb..abf018524 100644 --- a/libX11/src/xlibi18n/XlcSL.c +++ b/libX11/src/xlibi18n/XlcSL.c @@ -1,96 +1,96 @@ -/* -Copyright 1985, 1986, 1987, 1991, 1998 The Open Group - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: The above copyright notice and this -permission notice shall be included in all copies or substantial -portions of the Software. - - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE -EVEN IF ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES. - - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - -X Window System is a trademark of The Open Group - -OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF -logo, LBX, X Window System, and Xinerama are trademarks of the Open -Group. All other trademarks and registered trademarks mentioned herein -are the property of their respective owners. No right, title or -interest in or to any trademark, service mark, logo or trade name of -Sun Microsystems, Inc. or its licensors is granted. - -*/ -/* - * Copyright 2000 Sun Microsystems, Inc. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -#ifdef HAVE_CONFIG_H -#include -#endif -#include "Xlibint.h" -#include "Xlcint.h" - -extern XIM _XDefaultOpenIM( - XLCd, Display *, XrmDatabase, char *, char * - ); - -Bool -_XInitDefaultIM(lcd) -XLCd lcd; -{ - if(lcd == (XLCd)NULL) - return False; - - lcd->methods->open_im = _XDefaultOpenIM; - lcd->methods->register_callback = NULL; - lcd->methods->unregister_callback = NULL; - return True; -} - -extern XOM _XDefaultOpenOM( - XLCd, Display*, XrmDatabase, _Xconst char*, _Xconst char* - ); - -Bool -_XInitDefaultOM(lcd) - XLCd lcd; -{ - lcd->methods->open_om = _XDefaultOpenOM; - return True; -} +/* +Copyright 1985, 1986, 1987, 1991, 1998 The Open Group + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: The above copyright notice and this +permission notice shall be included in all copies or substantial +portions of the Software. + + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE +EVEN IF ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES. + + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + + +X Window System is a trademark of The Open Group + +OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF +logo, LBX, X Window System, and Xinerama are trademarks of the Open +Group. All other trademarks and registered trademarks mentioned herein +are the property of their respective owners. No right, title or +interest in or to any trademark, service mark, logo or trade name of +Sun Microsystems, Inc. or its licensors is granted. + +*/ +/* + * Copyright 2000 Oracle and/or its affiliates. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "Xlibint.h" +#include "Xlcint.h" + +extern XIM _XDefaultOpenIM( + XLCd, Display *, XrmDatabase, char *, char * + ); + +Bool +_XInitDefaultIM(lcd) +XLCd lcd; +{ + if(lcd == (XLCd)NULL) + return False; + + lcd->methods->open_im = _XDefaultOpenIM; + lcd->methods->register_callback = NULL; + lcd->methods->unregister_callback = NULL; + return True; +} + +extern XOM _XDefaultOpenOM( + XLCd, Display*, XrmDatabase, _Xconst char*, _Xconst char* + ); + +Bool +_XInitDefaultOM(lcd) + XLCd lcd; +{ + lcd->methods->open_om = _XDefaultOpenOM; + return True; +} diff --git a/libX11/src/xlibi18n/lcInit.c b/libX11/src/xlibi18n/lcInit.c index ee66b8c92..b9a602b4b 100644 --- a/libX11/src/xlibi18n/lcInit.c +++ b/libX11/src/xlibi18n/lcInit.c @@ -1,197 +1,197 @@ -/* -Copyright 1985, 1986, 1987, 1991, 1998 The Open Group - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: The above copyright notice and this -permission notice shall be included in all copies or substantial -portions of the Software. - - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE -EVEN IF ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES. - - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - -X Window System is a trademark of The Open Group - -OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF -logo, LBX, X Window System, and Xinerama are trademarks of the Open -Group. All other trademarks and registered trademarks mentioned herein -are the property of their respective owners. No right, title or -interest in or to any trademark, service mark, logo or trade name of -Sun Microsystems, Inc. or its licensors is granted. - -*/ -/* - * Copyright 2000 Sun Microsystems, Inc. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/* - * Copyright 1992, 1993 by TOSHIBA Corp. - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, provided - * that the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of TOSHIBA not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * written prior permission. TOSHIBA make no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING - * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL - * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR - * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, - * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - * - * Author: Katsuhisa Yano TOSHIBA Corp. - * mopi@osa.ilab.toshiba.co.jp - */ -/* - * (c) Copyright 1995 FUJITSU LIMITED - * This is source code modified by FUJITSU LIMITED under the Joint - * Development Agreement for the CDE/Motif PST. - * - * Modifier: Masayoshi Shimamura FUJITSU LIMITED - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif -#include "Xlibint.h" -#include "Xlcint.h" - -#ifdef USE_DYNAMIC_LC -#undef USE_DEFAULT_LOADER -#undef USE_GENERIC_LOADER -#undef USE_UTF8_LOADER -#else -#define USE_GENERIC_LOADER -#define USE_DEFAULT_LOADER -#define USE_UTF8_LOADER -#ifdef X_LOCALE -# define USE_EUC_LOADER -# define USE_SJIS_LOADER -# define USE_JIS_LOADER -#endif -#endif - -/* - * The _XlcInitLoader function initializes the locale object loader list - * with vendor specific manner. - */ - -void -_XlcInitLoader(void) -{ - -#ifdef USE_DYNAMIC_LC - _XlcAddLoader(_XlcDynamicLoad, XlcHead); -#else /* USE_DYNAMIC_LC */ - -#ifdef USE_GENERIC_LOADER - _XlcAddLoader(_XlcGenericLoader, XlcHead); -#endif - -#ifdef USE_DEFAULT_LOADER - _XlcAddLoader(_XlcDefaultLoader, XlcHead); -#endif - -#ifdef USE_UTF8_LOADER - _XlcAddLoader(_XlcUtf8Loader, XlcHead); -#endif - -#ifdef USE_EUC_LOADER - _XlcAddLoader(_XlcEucLoader, XlcHead); -#endif - -#ifdef USE_SJIS_LOADER - _XlcAddLoader(_XlcSjisLoader, XlcHead); -#endif - -#ifdef USE_JIS_LOADER - _XlcAddLoader(_XlcJisLoader, XlcHead); -#endif - -#ifdef USE_DYNAMIC_LOADER - _XlcAddLoader(_XlcDynamicLoader, XlcHead); -#endif - -#endif /* USE_DYNAMIC_LC */ -} - -void -_XlcDeInitLoader(void) -{ - -#ifdef USE_DYNAMIC_LC - _XlcRemoveLoader(_XlcDynamicLoad); -#else /* USE_DYNAMIC_LC */ - -#ifdef USE_GENERIC_LOADER - _XlcRemoveLoader(_XlcGenericLoader); -#endif - -#ifdef USE_DEFAULT_LOADER - _XlcRemoveLoader(_XlcDefaultLoader); -#endif - -#ifdef USE_UTF8_LOADER - _XlcRemoveLoader(_XlcUtf8Loader); -#endif - -#ifdef USE_EUC_LOADER - _XlcRemoveLoader(_XlcEucLoader); -#endif - -#ifdef USE_SJIS_LOADER - _XlcRemoveLoader(_XlcSjisLoader); -#endif - -#ifdef USE_JIS_LOADER - _XlcRemoveLoader(_XlcJisLoader); -#endif - -#ifdef USE_DYNAMIC_LOADER - _XlcRemoveLoader(_XlcDynamicLoader); -#endif - -#endif /* USE_DYNAMIC_LC */ -} +/* +Copyright 1985, 1986, 1987, 1991, 1998 The Open Group + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: The above copyright notice and this +permission notice shall be included in all copies or substantial +portions of the Software. + + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE +EVEN IF ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES. + + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + + +X Window System is a trademark of The Open Group + +OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF +logo, LBX, X Window System, and Xinerama are trademarks of the Open +Group. All other trademarks and registered trademarks mentioned herein +are the property of their respective owners. No right, title or +interest in or to any trademark, service mark, logo or trade name of +Sun Microsystems, Inc. or its licensors is granted. + +*/ +/* + * Copyright 2000 Oracle and/or its affiliates. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/* + * Copyright 1992, 1993 by TOSHIBA Corp. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of TOSHIBA not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. TOSHIBA make no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Author: Katsuhisa Yano TOSHIBA Corp. + * mopi@osa.ilab.toshiba.co.jp + */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDE/Motif PST. + * + * Modifier: Masayoshi Shimamura FUJITSU LIMITED + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "Xlibint.h" +#include "Xlcint.h" + +#ifdef USE_DYNAMIC_LC +#undef USE_DEFAULT_LOADER +#undef USE_GENERIC_LOADER +#undef USE_UTF8_LOADER +#else +#define USE_GENERIC_LOADER +#define USE_DEFAULT_LOADER +#define USE_UTF8_LOADER +#ifdef X_LOCALE +# define USE_EUC_LOADER +# define USE_SJIS_LOADER +# define USE_JIS_LOADER +#endif +#endif + +/* + * The _XlcInitLoader function initializes the locale object loader list + * with vendor specific manner. + */ + +void +_XlcInitLoader(void) +{ + +#ifdef USE_DYNAMIC_LC + _XlcAddLoader(_XlcDynamicLoad, XlcHead); +#else /* USE_DYNAMIC_LC */ + +#ifdef USE_GENERIC_LOADER + _XlcAddLoader(_XlcGenericLoader, XlcHead); +#endif + +#ifdef USE_DEFAULT_LOADER + _XlcAddLoader(_XlcDefaultLoader, XlcHead); +#endif + +#ifdef USE_UTF8_LOADER + _XlcAddLoader(_XlcUtf8Loader, XlcHead); +#endif + +#ifdef USE_EUC_LOADER + _XlcAddLoader(_XlcEucLoader, XlcHead); +#endif + +#ifdef USE_SJIS_LOADER + _XlcAddLoader(_XlcSjisLoader, XlcHead); +#endif + +#ifdef USE_JIS_LOADER + _XlcAddLoader(_XlcJisLoader, XlcHead); +#endif + +#ifdef USE_DYNAMIC_LOADER + _XlcAddLoader(_XlcDynamicLoader, XlcHead); +#endif + +#endif /* USE_DYNAMIC_LC */ +} + +void +_XlcDeInitLoader(void) +{ + +#ifdef USE_DYNAMIC_LC + _XlcRemoveLoader(_XlcDynamicLoad); +#else /* USE_DYNAMIC_LC */ + +#ifdef USE_GENERIC_LOADER + _XlcRemoveLoader(_XlcGenericLoader); +#endif + +#ifdef USE_DEFAULT_LOADER + _XlcRemoveLoader(_XlcDefaultLoader); +#endif + +#ifdef USE_UTF8_LOADER + _XlcRemoveLoader(_XlcUtf8Loader); +#endif + +#ifdef USE_EUC_LOADER + _XlcRemoveLoader(_XlcEucLoader); +#endif + +#ifdef USE_SJIS_LOADER + _XlcRemoveLoader(_XlcSjisLoader); +#endif + +#ifdef USE_JIS_LOADER + _XlcRemoveLoader(_XlcJisLoader); +#endif + +#ifdef USE_DYNAMIC_LOADER + _XlcRemoveLoader(_XlcDynamicLoader); +#endif + +#endif /* USE_DYNAMIC_LC */ +} -- cgit v1.2.3