diff options
author | marha <marha@users.sourceforge.net> | 2010-05-19 09:25:26 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2010-05-19 09:25:26 +0000 |
commit | 153f5cafa19da4e4c0cf21e9c909958359ed8ebd (patch) | |
tree | afb02018d05d75ebc99738b71bd315bdd58fb9b2 /libX11/modules/im | |
parent | 044f55eb2a3827716a6798f8d6226e6ea94032fd (diff) | |
download | vcxsrv-153f5cafa19da4e4c0cf21e9c909958359ed8ebd.tar.gz vcxsrv-153f5cafa19da4e4c0cf21e9c909958359ed8ebd.tar.bz2 vcxsrv-153f5cafa19da4e4c0cf21e9c909958359ed8ebd.zip |
libX11 git update 19/10/2010
Diffstat (limited to 'libX11/modules/im')
-rw-r--r-- | libX11/modules/im/Makefile.in | 614 | ||||
-rw-r--r-- | libX11/modules/im/ximcp/Makefile.am | 119 | ||||
-rw-r--r-- | libX11/modules/im/ximcp/Makefile.in | 690 | ||||
-rw-r--r-- | libX11/modules/im/ximcp/imLcIm.c | 1458 | ||||
-rw-r--r-- | libX11/modules/im/ximcp/imLcPrs.c | 1373 | ||||
-rw-r--r-- | libX11/modules/im/ximcp/imRm.c | 6410 |
6 files changed, 4678 insertions, 5986 deletions
diff --git a/libX11/modules/im/Makefile.in b/libX11/modules/im/Makefile.in deleted file mode 100644 index bc6c8d1a8..000000000 --- a/libX11/modules/im/Makefile.in +++ /dev/null @@ -1,614 +0,0 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = modules/im -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ - $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/src/config.h \ - $(top_builddir)/include/X11/XlibConf.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -AM_V_GEN = $(am__v_GEN_$(V)) -am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) -am__v_GEN_0 = @echo " GEN " $@; -AM_V_at = $(am__v_at_$(V)) -am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) -am__v_at_0 = @ -SOURCES = -DIST_SOURCES = -RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ - html-recursive info-recursive install-data-recursive \ - install-dvi-recursive install-exec-recursive \ - install-html-recursive install-info-recursive \ - install-pdf-recursive install-ps-recursive install-recursive \ - installcheck-recursive installdirs-recursive pdf-recursive \ - ps-recursive uninstall-recursive -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ - $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ - distdir -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -ACLOCAL = @ACLOCAL@ -ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ -ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -APP_MAN_DIR = @APP_MAN_DIR@ -APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BIGFONT_CFLAGS = @BIGFONT_CFLAGS@ -BIGFONT_LIBS = @BIGFONT_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CC_FOR_BUILD = @CC_FOR_BUILD@ -CFLAGS = @CFLAGS@ -CHANGELOG_CMD = @CHANGELOG_CMD@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CWARNFLAGS = @CWARNFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DOLT_BASH = @DOLT_BASH@ -DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ -DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ -DSYMUTIL = @DSYMUTIL@ -ECHO = @ECHO@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -F77 = @F77@ -FFLAGS = @FFLAGS@ -FILE_MAN_DIR = @FILE_MAN_DIR@ -FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ -GREP = @GREP@ -GROFF = @GROFF@ -I18N_MODULE_LIBS = @I18N_MODULE_LIBS@ -INSTALL = @INSTALL@ -INSTALL_CMD = @INSTALL_CMD@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -KEYSYMDEF = @KEYSYMDEF@ -LAUNCHD = @LAUNCHD@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIB_MAN_DIR = @LIB_MAN_DIR@ -LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ -LINT = @LINT@ -LINTLIB = @LINTLIB@ -LINT_FLAGS = @LINT_FLAGS@ -LN_S = @LN_S@ -LTCOMPILE = @LTCOMPILE@ -LTCXXCOMPILE = @LTCXXCOMPILE@ -LTLIBOBJS = @LTLIBOBJS@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MALLOC_ZERO_CFLAGS = @MALLOC_ZERO_CFLAGS@ -MISC_MAN_DIR = @MISC_MAN_DIR@ -MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ -MKDIR_P = @MKDIR_P@ -NMEDIT = @NMEDIT@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PS2PDF = @PS2PDF@ -RANLIB = @RANLIB@ -RAWCPP = @RAWCPP@ -RAWCPPFLAGS = @RAWCPPFLAGS@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -WCHAR32 = @WCHAR32@ -X11_CFLAGS = @X11_CFLAGS@ -X11_DATADIR = @X11_DATADIR@ -X11_EXTRA_DEPS = @X11_EXTRA_DEPS@ -X11_LIBDIR = @X11_LIBDIR@ -X11_LIBS = @X11_LIBS@ -X11_LOCALEDATADIR = @X11_LOCALEDATADIR@ -X11_LOCALEDIR = @X11_LOCALEDIR@ -X11_LOCALELIBDIR = @X11_LOCALELIBDIR@ -XDMCP_CFLAGS = @XDMCP_CFLAGS@ -XDMCP_LIBS = @XDMCP_LIBS@ -XERRORDB = @XERRORDB@ -XKBPROTO_REQUIRES = @XKBPROTO_REQUIRES@ -XKEYSYMDB = @XKEYSYMDB@ -XLOCALEDATADIR = @XLOCALEDATADIR@ -XLOCALEDIR = @XLOCALEDIR@ -XLOCALELIBDIR = @XLOCALELIBDIR@ -XMALLOC_ZERO_CFLAGS = @XMALLOC_ZERO_CFLAGS@ -XTHREADLIB = @XTHREADLIB@ -XTHREAD_CFLAGS = @XTHREAD_CFLAGS@ -XTMALLOC_ZERO_CFLAGS = @XTMALLOC_ZERO_CFLAGS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_F77 = @ac_ct_F77@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -SUBDIRS = ximcp -all: all-recursive - -.SUFFIXES: -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign modules/im/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign modules/im/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -# This directory's subdirectories are mostly independent; you can cd -# into them and run `make' without going through this Makefile. -# To change the values of `make' variables: instead of editing Makefiles, -# (1) if the variable is set in `config.status', edit `config.status' -# (which will cause the Makefiles to be regenerated when you run `make'); -# (2) otherwise, pass the desired values on the `make' command line. -$(RECURSIVE_TARGETS): - @fail= failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -$(RECURSIVE_CLEAN_TARGETS): - @fail= failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - rev=''; for subdir in $$list; do \ - if test "$$subdir" = "."; then :; else \ - rev="$$subdir $$rev"; \ - fi; \ - done; \ - rev="$$rev ."; \ - target=`echo $@ | sed s/-recursive//`; \ - for subdir in $$rev; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done && test -z "$$fail" -tags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ - done -ctags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ - done - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: CTAGS -CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-recursive -all-am: Makefile -installdirs: installdirs-recursive -installdirs-am: -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic clean-libtool mostlyclean-am - -distclean: distclean-recursive - -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-generic mostlyclean-libtool - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: - -.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ - install-am install-strip tags-recursive - -.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ - all all-am check check-am clean clean-generic clean-libtool \ - ctags ctags-recursive distclean distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \ - uninstall uninstall-am - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/libX11/modules/im/ximcp/Makefile.am b/libX11/modules/im/ximcp/Makefile.am index 0dc8dfbfb..d696b867c 100644 --- a/libX11/modules/im/ximcp/Makefile.am +++ b/libX11/modules/im/ximcp/Makefile.am @@ -1,59 +1,60 @@ -AM_CPPFLAGS= \ - -I$(top_srcdir)/include \ - -I$(top_srcdir)/include/X11 \ - -I$(top_builddir)/include \ - -I$(top_builddir)/include/X11 \ - -I$(top_srcdir)/src/xcms \ - -I$(top_srcdir)/src/xkb \ - -I$(top_srcdir)/src/xlibi18n \ - -D_BSD_SOURCE -DXIM_t -DTRANS_CLIENT - -AM_CFLAGS= \ - $(X11_CFLAGS) \ - $(BIGFONT_CFLAGS) \ - $(XDMCP_CFLAGS) \ - $(MALLOC_ZERO_CFLAGS) - -if XLIB_LOADABLE_I18N - -commonlibdir = $(X11_LOCALELIBDIR)/common -commonlib_LTLIBRARIES=ximcp.la -ximcp_la_LDFLAGS = -module -version-number 2:0:0 -ximcp_la_LIBADD = $(I18N_MODULE_LIBS) - -else - -noinst_LTLIBRARIES=libximcp.la - -endif - - -ximcp_la_SOURCES = \ - imCallbk.c \ - imDefFlt.c \ - imDefIc.c \ - imDefIm.c \ - imDefLkup.c \ - imDispch.c \ - imEvToWire.c \ - imExten.c \ - imImSw.c \ - imInsClbk.c \ - imInt.c \ - imLcFlt.c \ - imLcGIc.c \ - imLcIc.c \ - imLcIm.c \ - imLcLkup.c \ - imLcPrs.c \ - imLcSIc.c \ - imRmAttr.c \ - imRm.c \ - imThaiFlt.c \ - imThaiIc.c \ - imThaiIm.c \ - imTrans.c \ - imTransR.c \ - imTrX.c - -libximcp_la_SOURCES = $(ximcp_la_SOURCES) +AM_CPPFLAGS= \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/include/X11 \
+ -I$(top_builddir)/include \
+ -I$(top_builddir)/include/X11 \
+ -I$(top_srcdir)/src/xcms \
+ -I$(top_srcdir)/src/xkb \
+ -I$(top_srcdir)/src/xlibi18n \
+ -D_BSD_SOURCE -DXIM_t -DTRANS_CLIENT
+
+AM_CFLAGS= \
+ $(X11_CFLAGS) \
+ $(BIGFONT_CFLAGS) \
+ $(XDMCP_CFLAGS) \
+ $(MALLOC_ZERO_CFLAGS) \
+ $(CWARNFLAGS)
+
+if XLIB_LOADABLE_I18N
+
+commonlibdir = $(X11_LOCALELIBDIR)/common
+commonlib_LTLIBRARIES=ximcp.la
+ximcp_la_LDFLAGS = -module -version-number 2:0:0
+ximcp_la_LIBADD = $(I18N_MODULE_LIBS)
+
+else
+
+noinst_LTLIBRARIES=libximcp.la
+
+endif
+
+
+ximcp_la_SOURCES = \
+ imCallbk.c \
+ imDefFlt.c \
+ imDefIc.c \
+ imDefIm.c \
+ imDefLkup.c \
+ imDispch.c \
+ imEvToWire.c \
+ imExten.c \
+ imImSw.c \
+ imInsClbk.c \
+ imInt.c \
+ imLcFlt.c \
+ imLcGIc.c \
+ imLcIc.c \
+ imLcIm.c \
+ imLcLkup.c \
+ imLcPrs.c \
+ imLcSIc.c \
+ imRmAttr.c \
+ imRm.c \
+ imThaiFlt.c \
+ imThaiIc.c \
+ imThaiIm.c \
+ imTrans.c \
+ imTransR.c \
+ imTrX.c
+
+libximcp_la_SOURCES = $(ximcp_la_SOURCES)
diff --git a/libX11/modules/im/ximcp/Makefile.in b/libX11/modules/im/ximcp/Makefile.in deleted file mode 100644 index 5a8a34d80..000000000 --- a/libX11/modules/im/ximcp/Makefile.in +++ /dev/null @@ -1,690 +0,0 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = modules/im/ximcp -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ - $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/src/config.h \ - $(top_builddir)/include/X11/XlibConf.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__installdirs = "$(DESTDIR)$(commonlibdir)" -LTLIBRARIES = $(commonlib_LTLIBRARIES) $(noinst_LTLIBRARIES) -libximcp_la_LIBADD = -am__objects_1 = imCallbk.lo imDefFlt.lo imDefIc.lo imDefIm.lo \ - imDefLkup.lo imDispch.lo imEvToWire.lo imExten.lo imImSw.lo \ - imInsClbk.lo imInt.lo imLcFlt.lo imLcGIc.lo imLcIc.lo \ - imLcIm.lo imLcLkup.lo imLcPrs.lo imLcSIc.lo imRmAttr.lo \ - imRm.lo imThaiFlt.lo imThaiIc.lo imThaiIm.lo imTrans.lo \ - imTransR.lo imTrX.lo -am_libximcp_la_OBJECTS = $(am__objects_1) -libximcp_la_OBJECTS = $(am_libximcp_la_OBJECTS) -AM_V_lt = $(am__v_lt_$(V)) -am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) -am__v_lt_0 = --silent -@XLIB_LOADABLE_I18N_FALSE@am_libximcp_la_rpath = -am__DEPENDENCIES_1 = -@XLIB_LOADABLE_I18N_TRUE@ximcp_la_DEPENDENCIES = \ -@XLIB_LOADABLE_I18N_TRUE@ $(am__DEPENDENCIES_1) -am_ximcp_la_OBJECTS = imCallbk.lo imDefFlt.lo imDefIc.lo imDefIm.lo \ - imDefLkup.lo imDispch.lo imEvToWire.lo imExten.lo imImSw.lo \ - imInsClbk.lo imInt.lo imLcFlt.lo imLcGIc.lo imLcIc.lo \ - imLcIm.lo imLcLkup.lo imLcPrs.lo imLcSIc.lo imRmAttr.lo \ - imRm.lo imThaiFlt.lo imThaiIc.lo imThaiIm.lo imTrans.lo \ - imTransR.lo imTrX.lo -ximcp_la_OBJECTS = $(am_ximcp_la_OBJECTS) -ximcp_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(ximcp_la_LDFLAGS) $(LDFLAGS) -o $@ -@XLIB_LOADABLE_I18N_TRUE@am_ximcp_la_rpath = -rpath $(commonlibdir) -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src -I$(top_builddir)/include/X11 -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_$(V)) -am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) -am__v_CC_0 = @echo " CC " $@; -AM_V_at = $(am__v_at_$(V)) -am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) -am__v_at_0 = @ -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_$(V)) -am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) -am__v_CCLD_0 = @echo " CCLD " $@; -AM_V_GEN = $(am__v_GEN_$(V)) -am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) -am__v_GEN_0 = @echo " GEN " $@; -SOURCES = $(libximcp_la_SOURCES) $(ximcp_la_SOURCES) -DIST_SOURCES = $(libximcp_la_SOURCES) $(ximcp_la_SOURCES) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ -ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -APP_MAN_DIR = @APP_MAN_DIR@ -APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BIGFONT_CFLAGS = @BIGFONT_CFLAGS@ -BIGFONT_LIBS = @BIGFONT_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CC_FOR_BUILD = @CC_FOR_BUILD@ -CFLAGS = @CFLAGS@ -CHANGELOG_CMD = @CHANGELOG_CMD@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CWARNFLAGS = @CWARNFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DOLT_BASH = @DOLT_BASH@ -DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ -DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ -DSYMUTIL = @DSYMUTIL@ -ECHO = @ECHO@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -F77 = @F77@ -FFLAGS = @FFLAGS@ -FILE_MAN_DIR = @FILE_MAN_DIR@ -FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ -GREP = @GREP@ -GROFF = @GROFF@ -I18N_MODULE_LIBS = @I18N_MODULE_LIBS@ -INSTALL = @INSTALL@ -INSTALL_CMD = @INSTALL_CMD@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -KEYSYMDEF = @KEYSYMDEF@ -LAUNCHD = @LAUNCHD@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIB_MAN_DIR = @LIB_MAN_DIR@ -LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ -LINT = @LINT@ -LINTLIB = @LINTLIB@ -LINT_FLAGS = @LINT_FLAGS@ -LN_S = @LN_S@ -LTCOMPILE = @LTCOMPILE@ -LTCXXCOMPILE = @LTCXXCOMPILE@ -LTLIBOBJS = @LTLIBOBJS@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MALLOC_ZERO_CFLAGS = @MALLOC_ZERO_CFLAGS@ -MISC_MAN_DIR = @MISC_MAN_DIR@ -MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ -MKDIR_P = @MKDIR_P@ -NMEDIT = @NMEDIT@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PS2PDF = @PS2PDF@ -RANLIB = @RANLIB@ -RAWCPP = @RAWCPP@ -RAWCPPFLAGS = @RAWCPPFLAGS@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -WCHAR32 = @WCHAR32@ -X11_CFLAGS = @X11_CFLAGS@ -X11_DATADIR = @X11_DATADIR@ -X11_EXTRA_DEPS = @X11_EXTRA_DEPS@ -X11_LIBDIR = @X11_LIBDIR@ -X11_LIBS = @X11_LIBS@ -X11_LOCALEDATADIR = @X11_LOCALEDATADIR@ -X11_LOCALEDIR = @X11_LOCALEDIR@ -X11_LOCALELIBDIR = @X11_LOCALELIBDIR@ -XDMCP_CFLAGS = @XDMCP_CFLAGS@ -XDMCP_LIBS = @XDMCP_LIBS@ -XERRORDB = @XERRORDB@ -XKBPROTO_REQUIRES = @XKBPROTO_REQUIRES@ -XKEYSYMDB = @XKEYSYMDB@ -XLOCALEDATADIR = @XLOCALEDATADIR@ -XLOCALEDIR = @XLOCALEDIR@ -XLOCALELIBDIR = @XLOCALELIBDIR@ -XMALLOC_ZERO_CFLAGS = @XMALLOC_ZERO_CFLAGS@ -XTHREADLIB = @XTHREADLIB@ -XTHREAD_CFLAGS = @XTHREAD_CFLAGS@ -XTMALLOC_ZERO_CFLAGS = @XTMALLOC_ZERO_CFLAGS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_F77 = @ac_ct_F77@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -AM_CPPFLAGS = \ - -I$(top_srcdir)/include \ - -I$(top_srcdir)/include/X11 \ - -I$(top_builddir)/include \ - -I$(top_builddir)/include/X11 \ - -I$(top_srcdir)/src/xcms \ - -I$(top_srcdir)/src/xkb \ - -I$(top_srcdir)/src/xlibi18n \ - -D_BSD_SOURCE -DXIM_t -DTRANS_CLIENT - -AM_CFLAGS = \ - $(X11_CFLAGS) \ - $(BIGFONT_CFLAGS) \ - $(XDMCP_CFLAGS) \ - $(MALLOC_ZERO_CFLAGS) - -@XLIB_LOADABLE_I18N_TRUE@commonlibdir = $(X11_LOCALELIBDIR)/common -@XLIB_LOADABLE_I18N_TRUE@commonlib_LTLIBRARIES = ximcp.la -@XLIB_LOADABLE_I18N_TRUE@ximcp_la_LDFLAGS = -module -version-number 2:0:0 -@XLIB_LOADABLE_I18N_TRUE@ximcp_la_LIBADD = $(I18N_MODULE_LIBS) -@XLIB_LOADABLE_I18N_FALSE@noinst_LTLIBRARIES = libximcp.la -ximcp_la_SOURCES = \ - imCallbk.c \ - imDefFlt.c \ - imDefIc.c \ - imDefIm.c \ - imDefLkup.c \ - imDispch.c \ - imEvToWire.c \ - imExten.c \ - imImSw.c \ - imInsClbk.c \ - imInt.c \ - imLcFlt.c \ - imLcGIc.c \ - imLcIc.c \ - imLcIm.c \ - imLcLkup.c \ - imLcPrs.c \ - imLcSIc.c \ - imRmAttr.c \ - imRm.c \ - imThaiFlt.c \ - imThaiIc.c \ - imThaiIm.c \ - imTrans.c \ - imTransR.c \ - imTrX.c - -libximcp_la_SOURCES = $(ximcp_la_SOURCES) -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign modules/im/ximcp/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign modules/im/ximcp/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): -install-commonlibLTLIBRARIES: $(commonlib_LTLIBRARIES) - @$(NORMAL_INSTALL) - test -z "$(commonlibdir)" || $(MKDIR_P) "$(DESTDIR)$(commonlibdir)" - @list='$(commonlib_LTLIBRARIES)'; test -n "$(commonlibdir)" || list=; \ - list2=; for p in $$list; do \ - if test -f $$p; then \ - list2="$$list2 $$p"; \ - else :; fi; \ - done; \ - test -z "$$list2" || { \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(commonlibdir)'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(commonlibdir)"; \ - } - -uninstall-commonlibLTLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(commonlib_LTLIBRARIES)'; test -n "$(commonlibdir)" || list=; \ - for p in $$list; do \ - $(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(commonlibdir)/$$f'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(commonlibdir)/$$f"; \ - done - -clean-commonlibLTLIBRARIES: - -test -z "$(commonlib_LTLIBRARIES)" || rm -f $(commonlib_LTLIBRARIES) - @list='$(commonlib_LTLIBRARIES)'; for p in $$list; do \ - dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ - test "$$dir" != "$$p" || dir=.; \ - echo "rm -f \"$${dir}/so_locations\""; \ - rm -f "$${dir}/so_locations"; \ - done - -clean-noinstLTLIBRARIES: - -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) - @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ - dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ - test "$$dir" != "$$p" || dir=.; \ - echo "rm -f \"$${dir}/so_locations\""; \ - rm -f "$${dir}/so_locations"; \ - done -libximcp.la: $(libximcp_la_OBJECTS) $(libximcp_la_DEPENDENCIES) - $(AM_V_CCLD)$(LINK) $(am_libximcp_la_rpath) $(libximcp_la_OBJECTS) $(libximcp_la_LIBADD) $(LIBS) -ximcp.la: $(ximcp_la_OBJECTS) $(ximcp_la_DEPENDENCIES) - $(AM_V_CCLD)$(ximcp_la_LINK) $(am_ximcp_la_rpath) $(ximcp_la_OBJECTS) $(ximcp_la_LIBADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imCallbk.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imDefFlt.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imDefIc.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imDefIm.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imDefLkup.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imDispch.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imEvToWire.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imExten.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imImSw.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imInsClbk.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imInt.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imLcFlt.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imLcGIc.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imLcIc.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imLcIm.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imLcLkup.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imLcPrs.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imLcSIc.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imRm.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imRmAttr.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imThaiFlt.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imThaiIc.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imThaiIm.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imTrX.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imTrans.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imTransR.Plo@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - set x; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(LTLIBRARIES) -installdirs: - for dir in "$(DESTDIR)$(commonlibdir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-commonlibLTLIBRARIES clean-generic clean-libtool \ - clean-noinstLTLIBRARIES mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: install-commonlibLTLIBRARIES - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-commonlibLTLIBRARIES - -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS all all-am check check-am clean \ - clean-commonlibLTLIBRARIES clean-generic clean-libtool \ - clean-noinstLTLIBRARIES ctags distclean distclean-compile \ - distclean-generic distclean-libtool distclean-tags distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-commonlibLTLIBRARIES install-data install-data-am \ - install-dvi install-dvi-am install-exec install-exec-am \ - install-html install-html-am install-info install-info-am \ - install-man install-pdf install-pdf-am install-ps \ - install-ps-am install-strip installcheck installcheck-am \ - installdirs maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ - uninstall-am uninstall-commonlibLTLIBRARIES - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/libX11/modules/im/ximcp/imLcIm.c b/libX11/modules/im/ximcp/imLcIm.c index eb41603e7..430e318d2 100644 --- a/libX11/modules/im/ximcp/imLcIm.c +++ b/libX11/modules/im/ximcp/imLcIm.c @@ -1,729 +1,729 @@ -/****************************************************************** - - Copyright 1992, 1993, 1994 by FUJITSU LIMITED - Copyright 1993 by Digital Equipment 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 -Digital Equipment Corporation not be used in advertising or publicity -pertaining to distribution of the software without specific, written -prior permission. FUJITSU LIMITED and Digital Equipment 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 DIGITAL EQUIPMENT CORPORATION DISCLAIM ALL -WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -FUJITSU LIMITED AND DIGITAL EQUIPMENT 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: Takashi Fujiwara FUJITSU LIMITED - fujiwara@a80.tech.yk.fujitsu.co.jp - Modifier: Franky Ling Digital Equipment Corporation - frankyling@hgrd01.enet.dec.com - -******************************************************************/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <stdio.h> - -#include <X11/Xmd.h> -#include <X11/Xatom.h> -#include <X11/Xos.h> -#include "Xlibint.h" -#include "Xlcint.h" -#include "XlcPublic.h" -#include "XlcPubI.h" -#include "Ximint.h" -#include <ctype.h> -#include <assert.h> - -#ifdef COMPOSECACHE -# include <sys/types.h> -# include <sys/stat.h> -# include <sys/mman.h> -# include <langinfo.h> -#endif - - -#ifdef COMPOSECACHE - -/* include trailing '/' for cache directory, file prefix otherwise */ -#define XIM_GLOBAL_CACHE_DIR "/var/cache/libx11/compose/" -#define XIM_HOME_CACHE_DIR "/.compose-cache/" -#define XIM_CACHE_MAGIC ('X' | 'i'<<8 | 'm'<<16 | 'C'<<24) -#define XIM_CACHE_VERSION 4 -#define XIM_CACHE_TREE_ALIGNMENT 4 - -#define XIM_HASH_PRIME_1 13 -#define XIM_HASH_PRIME_2 1234096939 - -typedef INT32 DTStructIndex; -struct _XimCacheStruct { - INT32 id; - INT32 version; - DTStructIndex tree; - DTStructIndex mb; - DTStructIndex wc; - DTStructIndex utf8; - DTStructIndex size; - DTIndex top; - DTIndex treeused; - DTCharIndex mbused; - DTCharIndex wcused; - DTCharIndex utf8used; - char fname[1]; - /* char encoding[1] */ -}; - -Private struct _XimCacheStruct* _XimCache_mmap = NULL; -Private DefTreeBase _XimCachedDefaultTreeBase; -Private int _XimCachedDefaultTreeRefcount = 0; - -#endif - - -Public Bool -_XimCheckIfLocalProcessing(Xim im) -{ - FILE *fp; - char *name; - - if(strcmp(im->core.im_name, "") == 0) { - name = _XlcFileName(im->core.lcd, COMPOSE_FILE); - if (name != (char *)NULL) { - fp = _XFopenFile (name, "r"); - Xfree(name); - if (fp != (FILE *)NULL) { - fclose(fp); - return(True); - } - } - return(False); - } else if(strcmp(im->core.im_name, "local") == 0 || - strcmp(im->core.im_name, "none" ) == 0 ) { - return(True); - } - return(False); -} - -Private void -XimFreeDefaultTree( - DefTreeBase *b) -{ - if (!b) return; - if (b->tree == NULL) return; -#ifdef COMPOSECACHE - if (b->tree == _XimCachedDefaultTreeBase.tree) { - _XimCachedDefaultTreeRefcount--; - /* No deleting, it's a cache after all. */ - return; - } -#endif - Xfree (b->tree); - if (b->mb) Xfree (b->mb); - if (b->wc) Xfree (b->wc); - if (b->utf8) Xfree (b->utf8); - b->tree = NULL; - b->mb = NULL; - b->wc = NULL; - b->utf8 = NULL; - b->treeused = b->treesize = 0; - b->mbused = b->mbsize = 0; - b->wcused = b->wcsize = 0; - b->utf8used = b->utf8size = 0; -} - -Public void -_XimLocalIMFree( - Xim im) -{ - XimFreeDefaultTree(&im->private.local.base); - im->private.local.top = 0; - - if(im->core.im_resources) { - Xfree(im->core.im_resources); - im->core.im_resources = NULL; - } - if(im->core.ic_resources) { - Xfree(im->core.ic_resources); - im->core.ic_resources = NULL; - } - if(im->core.im_values_list) { - Xfree(im->core.im_values_list); - im->core.im_values_list = NULL; - } - if(im->core.ic_values_list) { - Xfree(im->core.ic_values_list); - im->core.ic_values_list = NULL; - } - if(im->core.styles) { - Xfree(im->core.styles); - im->core.styles = NULL; - } - if(im->core.res_name) { - Xfree(im->core.res_name); - im->core.res_name = NULL; - } - if(im->core.res_class) { - Xfree(im->core.res_class); - im->core.res_class = NULL; - } - if(im->core.im_name) { - Xfree(im->core.im_name); - im->core.im_name = NULL; - } - if (im->private.local.ctom_conv) { - _XlcCloseConverter(im->private.local.ctom_conv); - im->private.local.ctom_conv = NULL; - } - if (im->private.local.ctow_conv) { - _XlcCloseConverter(im->private.local.ctow_conv); - im->private.local.ctow_conv = NULL; - } - if (im->private.local.ctoutf8_conv) { - _XlcCloseConverter(im->private.local.ctoutf8_conv); - im->private.local.ctoutf8_conv = NULL; - } - if (im->private.local.cstomb_conv) { - _XlcCloseConverter(im->private.local.cstomb_conv); - im->private.local.cstomb_conv = NULL; - } - if (im->private.local.cstowc_conv) { - _XlcCloseConverter(im->private.local.cstowc_conv); - im->private.local.cstowc_conv = NULL; - } - if (im->private.local.cstoutf8_conv) { - _XlcCloseConverter(im->private.local.cstoutf8_conv); - im->private.local.cstoutf8_conv = NULL; - } - if (im->private.local.ucstoc_conv) { - _XlcCloseConverter(im->private.local.ucstoc_conv); - im->private.local.ucstoc_conv = NULL; - } - if (im->private.local.ucstoutf8_conv) { - _XlcCloseConverter(im->private.local.ucstoutf8_conv); - im->private.local.ucstoutf8_conv = NULL; - } - return; -} - -Private Status -_XimLocalCloseIM( - XIM xim) -{ - Xim im = (Xim)xim; - XIC ic; - XIC next; - - ic = im->core.ic_chain; - im->core.ic_chain = NULL; - while (ic) { - (*ic->methods->destroy) (ic); - next = ic->core.next; - Xfree ((char *) ic); - ic = next; - } - _XimLocalIMFree(im); - _XimDestroyIMStructureList(im); - return(True); -} - -Public char * -_XimLocalGetIMValues( - XIM xim, - XIMArg *values) -{ - Xim im = (Xim)xim; - XimDefIMValues im_values; - - _XimGetCurrentIMValues(im, &im_values); - return(_XimGetIMValueData(im, (XPointer)&im_values, values, - im->core.im_resources, im->core.im_num_resources)); -} - -Public char * -_XimLocalSetIMValues( - XIM xim, - XIMArg *values) -{ - Xim im = (Xim)xim; - XimDefIMValues im_values; - char *name = (char *)NULL; - - _XimGetCurrentIMValues(im, &im_values); - name = _XimSetIMValueData(im, (XPointer)&im_values, values, - im->core.im_resources, im->core.im_num_resources); - _XimSetCurrentIMValues(im, &im_values); - return(name); -} - - -#ifdef COMPOSECACHE - -Private Bool -_XimReadCachedDefaultTree( - int fd_cache, - const char *name, - const char *encoding, - DTStructIndex size) -{ - struct _XimCacheStruct* m; - int namelen = strlen (name) + 1; - int encodinglen = strlen (encoding) + 1; - - m = mmap (NULL, size, PROT_READ, MAP_PRIVATE, fd_cache, 0); - if (m == NULL || m == MAP_FAILED) - return False; - assert (m->id == XIM_CACHE_MAGIC); - assert (m->version == XIM_CACHE_VERSION); - if (size != m->size || - size < XOffsetOf (struct _XimCacheStruct, fname) + namelen + encodinglen) { - fprintf (stderr, "Ignoring broken XimCache %s [%s]\n", name, encoding); - munmap (m, size); - return False; - } - if (strncmp (name, m->fname, namelen) != 0) { - /* m->fname may *not* be terminated - but who cares here */ - fprintf (stderr, "Filename hash clash - expected %s, got %s\n", - name, m->fname); - munmap (m, size); - return False; - } - if (strncmp (encoding, m->fname + namelen, encodinglen) != 0) { - /* m->fname+namelen may *not* be terminated - but who cares here */ - fprintf (stderr, "Enoding hash clash - expected %s, got %s\n", - encoding, m->fname + namelen); - munmap (m, size); - return False; - } - _XimCache_mmap = m; - _XimCachedDefaultTreeBase.tree = (DefTree *) (((char *) m) + m->tree); - _XimCachedDefaultTreeBase.mb = (((char *) m) + m->mb); - _XimCachedDefaultTreeBase.wc = (wchar_t *) (((char *) m) + m->wc); - _XimCachedDefaultTreeBase.utf8 = (((char *) m) + m->utf8); - _XimCachedDefaultTreeBase.treeused = m->treeused; - _XimCachedDefaultTreeBase.mbused = m->mbused; - _XimCachedDefaultTreeBase.wcused = m->wcused; - _XimCachedDefaultTreeBase.utf8used = m->utf8used; - /* treesize etc. is ignored because only used during parsing */ - _XimCachedDefaultTreeRefcount = 0; -/* fprintf (stderr, "read cached tree at %p: %s\n", (void *) m, name); */ - return True; -} - -Private unsigned int strToHash ( - const char *name) -{ - unsigned int hash = 0; - while (*name) - hash = hash * XIM_HASH_PRIME_1 + *(unsigned const char *)name++; - return hash % XIM_HASH_PRIME_2; -} - - -/* Returns read-only fd of cache file, -1 if none. - * Sets *res to cache filename if safe. Sets *size to file size of cache. */ -Private int _XimCachedFileName ( - const char *dir, const char *name, - const char *intname, const char *encoding, - uid_t uid, int isglobal, char **res, off_t *size) -{ - struct stat st_name, st; - int fd; - unsigned int len, hash, hash2; - struct _XimCacheStruct *m; - /* There are some races here with 'dir', but we are either in our own home - * or the global cache dir, and not inside some public writable dir */ -/* fprintf (stderr, "XimCachedFileName for dir %s name %s intname %s encoding %s uid %d\n", dir, name, intname, encoding, uid); */ - if (stat (name, &st_name) == -1 || ! S_ISREG (st_name.st_mode) - || stat (dir, &st) == -1 || ! S_ISDIR (st.st_mode) || st.st_uid != uid - || (st.st_mode & 0022) != 0000) { - *res = NULL; - return -1; - } - len = strlen (dir); - hash = strToHash (intname); - hash2 = strToHash (encoding); - *res = Xmalloc (len + 1 + 27 + 1); /* Max VERSION 9999 */ - - if (len == 0 || dir [len-1] != '/') - sprintf (*res, "%s/%c%d_%03x_%08x_%08x", dir, _XimGetMyEndian(), - XIM_CACHE_VERSION, sizeof (DefTree), hash, hash2); - else - sprintf (*res, "%s%c%d_%03x_%08x_%08x", dir, _XimGetMyEndian(), - XIM_CACHE_VERSION, sizeof (DefTree), hash, hash2); - -/* fprintf (stderr, "-> %s\n", *res); */ - if ( (fd = _XOpenFile (*res, O_RDONLY)) == -1) - return -1; - - if (fstat (fd, &st) == -1) { - Xfree (*res); - *res = NULL; - close (fd); - return -1; - } - *size = st.st_size; - - if (! S_ISREG (st.st_mode) || st.st_uid != uid - || (st.st_mode & 0022) != 0000 || st.st_mtime <= st_name.st_mtime - || (st.st_mtime < time (NULL) - 24*60*60 && ! isglobal)) { - - close (fd); - if (unlink (*res) != 0) { - Xfree (*res); - *res = NULL; /* cache is not safe */ - } - return -1; - } - - m = mmap (NULL, sizeof (struct _XimCacheStruct), PROT_READ, MAP_PRIVATE, - fd, 0); - if (m == NULL || m == MAP_FAILED) { - close (fd); - Xfree (*res); - *res = NULL; - return -1; - } - if (*size < sizeof (struct _XimCacheStruct) || m->id != XIM_CACHE_MAGIC) { - munmap (m, sizeof (struct _XimCacheStruct)); - close (fd); - fprintf (stderr, "Ignoring broken XimCache %s\n", *res); - Xfree (*res); - *res = NULL; - return -1; - } - if (m->version != XIM_CACHE_VERSION) { - munmap (m, sizeof (struct _XimCacheStruct)); - close (fd); - if (unlink (*res) != 0) { - Xfree (*res); - *res = NULL; /* cache is not safe */ - } - return -1; - } - munmap (m, sizeof (struct _XimCacheStruct)); - - return fd; -} - - -Private Bool _XimLoadCache ( - int fd, - const char *name, - const char *encoding, - off_t size, - Xim im) -{ - if (_XimCache_mmap || - _XimReadCachedDefaultTree (fd, name, encoding, size)) { - _XimCachedDefaultTreeRefcount++; - memcpy (&im->private.local.base, &_XimCachedDefaultTreeBase, - sizeof (_XimCachedDefaultTreeBase)); - im->private.local.top = _XimCache_mmap->top; - return True; - } - - return False; -} - - -Private void -_XimWriteCachedDefaultTree( - const char *name, - const char *encoding, - const char *cachename, - Xim im) -{ - int fd; - FILE *fp; - struct _XimCacheStruct *m; - int msize = (XOffsetOf(struct _XimCacheStruct, fname) - + strlen(name) + strlen(encoding) + 2 - + XIM_CACHE_TREE_ALIGNMENT-1) & -XIM_CACHE_TREE_ALIGNMENT; - DefTreeBase *b = &im->private.local.base; - - if (! b->tree && ! (b->tree = Xmalloc (sizeof(DefTree))) ) - return; - if (! b->mb && ! (b->mb = Xmalloc (1)) ) - return; - if (! b->wc && ! (b->wc = Xmalloc (sizeof(wchar_t))) ) - return; - if (! b->utf8 && ! (b->utf8 = Xmalloc (1)) ) - return; - - /* First entry is always unused */ - memset (b->tree, 0, sizeof(DefTree)); - b->mb[0] = 0; - b->wc[0] = 0; - b->utf8[0] = 0; - - m = Xmalloc (msize); - memset (m, 0, msize); - m->id = XIM_CACHE_MAGIC; - m->version = XIM_CACHE_VERSION; - m->top = im->private.local.top; - m->treeused = b->treeused; - m->mbused = b->mbused; - m->wcused = b->wcused; - m->utf8used = b->utf8used; - /* Tree first, then wide chars, then the rest due to alignment */ - m->tree = msize; - m->wc = msize + sizeof (DefTree) * m->treeused; - m->mb = m->wc + sizeof (wchar_t) * m->wcused; - m->utf8 = m->mb + m->mbused; - m->size = m->utf8 + m->utf8used; - strcpy (m->fname, name); - strcpy (m->fname+strlen(name)+1, encoding); - - /* This STILL might be racy on NFS */ - if ( (fd = _XOpenFileMode (cachename, O_WRONLY | O_CREAT | O_EXCL, - 0600)) < 0) - return; - if (! (fp = fdopen (fd, "wb")) ) { - close (fd); - return; - } - fwrite (m, msize, 1, fp); - fwrite (im->private.local.base.tree, sizeof(DefTree), m->treeused, fp); - fwrite (im->private.local.base.wc, sizeof(wchar_t), m->wcused, fp); - fwrite (im->private.local.base.mb, 1, m->mbused, fp); - fwrite (im->private.local.base.utf8, 1, m->utf8used, fp); - if (fclose (fp) != 0) - unlink (cachename); - _XimCache_mmap = m; - memcpy (&_XimCachedDefaultTreeBase, &im->private.local.base, - sizeof (_XimCachedDefaultTreeBase)); -/* fprintf (stderr, "wrote tree %s size %ld to %s\n", name, m->size, cachename); */ -} - -#endif - - -Private void -_XimCreateDefaultTree( - Xim im) -{ - FILE *fp = NULL; - char *name, *tmpname = NULL, *intname; - char *cachename = NULL; - /* Should use getpwent() instead of $HOME (cross-platform?) */ - char *home = getenv("HOME"); - char *cachedir = NULL; - char *tmpcachedir = NULL; - int hl = home ? strlen (home) : 0; -#ifdef COMPOSECACHE - const char *encoding = nl_langinfo (CODESET); - uid_t euid = geteuid (); - gid_t egid = getegid (); - int cachefd = -1; - off_t size; -#endif - - name = getenv("XCOMPOSEFILE"); - if (name == (char *) NULL) { - if (home != (char *) NULL) { - tmpname = name = Xmalloc(hl + 10 + 1); - if (name != (char *) NULL) { - int fd; - strcpy(name, home); - strcpy(name + hl, "/.XCompose"); - if ( (fd = _XOpenFile (name, O_RDONLY)) < 0) { - Xfree (name); - name = tmpname = NULL; - } else - close (fd); - } - } - } - - if (name == (char *) NULL) { - tmpname = name = _XlcFileName(im->core.lcd, COMPOSE_FILE); - } - intname = name; - -#ifdef COMPOSECACHE - if (getuid () == euid && getgid () == egid && euid != 0) { - char *c; - /* Usage: XCOMPOSECACHE=<cachedir>[=<filename>] - * cachedir: directory of cache files - * filename: internally used name for cache file */ - cachedir = getenv("XCOMPOSECACHE"); - if (cachedir && (c = strchr (cachedir, '='))) { - tmpcachedir = strdup (cachedir); - intname = tmpcachedir + (c-cachedir) + 1; - tmpcachedir[c-cachedir] = '\0'; - cachedir = tmpcachedir; - } - } - - if (! cachedir) { - cachefd = _XimCachedFileName (XIM_GLOBAL_CACHE_DIR, name, intname, - encoding, 0, 1, &cachename, &size); - if (cachefd != -1) { - if (_XimLoadCache (cachefd, intname, encoding, size, im)) { - if (tmpcachedir) - Xfree (tmpcachedir); - if (tmpname) - Xfree (tmpname); - if (cachename) - Xfree (cachename); - close (cachefd); - return; - } - close (cachefd); - } - if (cachename) - Xfree (cachename); - cachename = NULL; - } - - if (getuid () == euid && getgid () == egid && euid != 0 && home) { - - if (! cachedir) { - tmpcachedir = cachedir = Xmalloc (hl+strlen(XIM_HOME_CACHE_DIR)+1); - strcpy (cachedir, home); - strcat (cachedir, XIM_HOME_CACHE_DIR); - } - cachefd = _XimCachedFileName (cachedir, name, intname, encoding, - euid, 0, &cachename, &size); - if (cachefd != -1) { - if (_XimLoadCache (cachefd, intname, encoding, size, im)) { - if (tmpcachedir) - Xfree (tmpcachedir); - if (tmpname) - Xfree (tmpname); - if (cachename) - Xfree (cachename); - close (cachefd); - return; - } - close (cachefd); - } - } -#endif - - if (! (fp = _XFopenFile (name, "r"))) { - if (tmpcachedir) - Xfree (tmpcachedir); - if (tmpname) - Xfree (tmpname); - if (cachename) - Xfree (cachename); - return; - } - _XimParseStringFile(fp, im); - fclose(fp); - -#ifdef COMPOSECACHE - if (cachename) { - assert (euid != 0); - _XimWriteCachedDefaultTree (intname, encoding, cachename, im); - } -#endif - - if (tmpcachedir) - Xfree (tmpcachedir); - if (tmpname) - Xfree (tmpname); - if (cachename) - Xfree (cachename); -} - -Private XIMMethodsRec Xim_im_local_methods = { - _XimLocalCloseIM, /* close */ - _XimLocalSetIMValues, /* set_values */ - _XimLocalGetIMValues, /* get_values */ - _XimLocalCreateIC, /* create_ic */ - _XimLcctstombs, /* ctstombs */ - _XimLcctstowcs, /* ctstowcs */ - _XimLcctstoutf8 /* ctstoutf8 */ -}; - -Public Bool -_XimLocalOpenIM( - Xim im) -{ - XLCd lcd = im->core.lcd; - XlcConv conv; - XimDefIMValues im_values; - XimLocalPrivateRec* private = &im->private.local; - - _XimInitialResourceInfo(); - if(_XimSetIMResourceList(&im->core.im_resources, - &im->core.im_num_resources) == False) { - goto Open_Error; - } - if(_XimSetICResourceList(&im->core.ic_resources, - &im->core.ic_num_resources) == False) { - goto Open_Error; - } - - _XimSetIMMode(im->core.im_resources, im->core.im_num_resources); - - _XimGetCurrentIMValues(im, &im_values); - if(_XimSetLocalIMDefaults(im, (XPointer)&im_values, - im->core.im_resources, im->core.im_num_resources) == False) { - goto Open_Error; - } - _XimSetCurrentIMValues(im, &im_values); - - if (!(conv = _XlcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte))) - goto Open_Error; - private->ctom_conv = conv; - - if (!(conv = _XlcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNWideChar))) - goto Open_Error; - private->ctow_conv = conv; - - if (!(conv = _XlcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNUtf8String))) - goto Open_Error; - private->ctoutf8_conv = conv; - - if (!(conv = _XlcOpenConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte))) - goto Open_Error; - private->cstomb_conv = conv; - - if (!(conv = _XlcOpenConverter(lcd, XlcNCharSet, lcd, XlcNWideChar))) - goto Open_Error; - private->cstowc_conv = conv; - - if (!(conv = _XlcOpenConverter(lcd, XlcNCharSet, lcd, XlcNUtf8String))) - goto Open_Error; - private->cstoutf8_conv = conv; - - if (!(conv = _XlcOpenConverter(lcd, XlcNUcsChar, lcd, XlcNChar))) - goto Open_Error; - private->ucstoc_conv = conv; - - if (!(conv = _XlcOpenConverter(lcd, XlcNUcsChar, lcd, XlcNUtf8String))) - goto Open_Error; - private->ucstoutf8_conv = conv; - - private->base.treeused = 1; - private->base.mbused = 1; - private->base.wcused = 1; - private->base.utf8used = 1; - - _XimCreateDefaultTree(im); - - im->methods = &Xim_im_local_methods; - private->current_ic = (XIC)NULL; - - return(True); - -Open_Error : - _XimLocalIMFree(im); - return(False); -} +/******************************************************************
+
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+ Copyright 1993 by Digital Equipment 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
+Digital Equipment Corporation not be used in advertising or publicity
+pertaining to distribution of the software without specific, written
+prior permission. FUJITSU LIMITED and Digital Equipment 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 DIGITAL EQUIPMENT CORPORATION DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+FUJITSU LIMITED AND DIGITAL EQUIPMENT 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: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+ Modifier: Franky Ling Digital Equipment Corporation
+ frankyling@hgrd01.enet.dec.com
+
+******************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+
+#include <X11/Xmd.h>
+#include <X11/Xatom.h>
+#include <X11/Xos.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "XlcPublic.h"
+#include "XlcPubI.h"
+#include "Ximint.h"
+#include <ctype.h>
+#include <assert.h>
+
+#ifdef COMPOSECACHE
+# include <sys/types.h>
+# include <sys/stat.h>
+# include <sys/mman.h>
+# include <langinfo.h>
+#endif
+
+
+#ifdef COMPOSECACHE
+
+/* include trailing '/' for cache directory, file prefix otherwise */
+#define XIM_GLOBAL_CACHE_DIR "/var/cache/libx11/compose/"
+#define XIM_HOME_CACHE_DIR "/.compose-cache/"
+#define XIM_CACHE_MAGIC ('X' | 'i'<<8 | 'm'<<16 | 'C'<<24)
+#define XIM_CACHE_VERSION 4
+#define XIM_CACHE_TREE_ALIGNMENT 4
+
+#define XIM_HASH_PRIME_1 13
+#define XIM_HASH_PRIME_2 1234096939
+
+typedef INT32 DTStructIndex;
+struct _XimCacheStruct {
+ INT32 id;
+ INT32 version;
+ DTStructIndex tree;
+ DTStructIndex mb;
+ DTStructIndex wc;
+ DTStructIndex utf8;
+ DTStructIndex size;
+ DTIndex top;
+ DTIndex treeused;
+ DTCharIndex mbused;
+ DTCharIndex wcused;
+ DTCharIndex utf8used;
+ char fname[1];
+ /* char encoding[1] */
+};
+
+Private struct _XimCacheStruct* _XimCache_mmap = NULL;
+Private DefTreeBase _XimCachedDefaultTreeBase;
+Private int _XimCachedDefaultTreeRefcount = 0;
+
+#endif
+
+
+Public Bool
+_XimCheckIfLocalProcessing(Xim im)
+{
+ FILE *fp;
+ char *name;
+
+ if(strcmp(im->core.im_name, "") == 0) {
+ name = _XlcFileName(im->core.lcd, COMPOSE_FILE);
+ if (name != (char *)NULL) {
+ fp = _XFopenFile (name, "r");
+ Xfree(name);
+ if (fp != (FILE *)NULL) {
+ fclose(fp);
+ return(True);
+ }
+ }
+ return(False);
+ } else if(strcmp(im->core.im_name, "local") == 0 ||
+ strcmp(im->core.im_name, "none" ) == 0 ) {
+ return(True);
+ }
+ return(False);
+}
+
+Private void
+XimFreeDefaultTree(
+ DefTreeBase *b)
+{
+ if (!b) return;
+ if (b->tree == NULL) return;
+#ifdef COMPOSECACHE
+ if (b->tree == _XimCachedDefaultTreeBase.tree) {
+ _XimCachedDefaultTreeRefcount--;
+ /* No deleting, it's a cache after all. */
+ return;
+ }
+#endif
+ Xfree (b->tree);
+ if (b->mb) Xfree (b->mb);
+ if (b->wc) Xfree (b->wc);
+ if (b->utf8) Xfree (b->utf8);
+ b->tree = NULL;
+ b->mb = NULL;
+ b->wc = NULL;
+ b->utf8 = NULL;
+ b->treeused = b->treesize = 0;
+ b->mbused = b->mbsize = 0;
+ b->wcused = b->wcsize = 0;
+ b->utf8used = b->utf8size = 0;
+}
+
+Public void
+_XimLocalIMFree(
+ Xim im)
+{
+ XimFreeDefaultTree(&im->private.local.base);
+ im->private.local.top = 0;
+
+ if(im->core.im_resources) {
+ Xfree(im->core.im_resources);
+ im->core.im_resources = NULL;
+ }
+ if(im->core.ic_resources) {
+ Xfree(im->core.ic_resources);
+ im->core.ic_resources = NULL;
+ }
+ if(im->core.im_values_list) {
+ Xfree(im->core.im_values_list);
+ im->core.im_values_list = NULL;
+ }
+ if(im->core.ic_values_list) {
+ Xfree(im->core.ic_values_list);
+ im->core.ic_values_list = NULL;
+ }
+ if(im->core.styles) {
+ Xfree(im->core.styles);
+ im->core.styles = NULL;
+ }
+ if(im->core.res_name) {
+ Xfree(im->core.res_name);
+ im->core.res_name = NULL;
+ }
+ if(im->core.res_class) {
+ Xfree(im->core.res_class);
+ im->core.res_class = NULL;
+ }
+ if(im->core.im_name) {
+ Xfree(im->core.im_name);
+ im->core.im_name = NULL;
+ }
+ if (im->private.local.ctom_conv) {
+ _XlcCloseConverter(im->private.local.ctom_conv);
+ im->private.local.ctom_conv = NULL;
+ }
+ if (im->private.local.ctow_conv) {
+ _XlcCloseConverter(im->private.local.ctow_conv);
+ im->private.local.ctow_conv = NULL;
+ }
+ if (im->private.local.ctoutf8_conv) {
+ _XlcCloseConverter(im->private.local.ctoutf8_conv);
+ im->private.local.ctoutf8_conv = NULL;
+ }
+ if (im->private.local.cstomb_conv) {
+ _XlcCloseConverter(im->private.local.cstomb_conv);
+ im->private.local.cstomb_conv = NULL;
+ }
+ if (im->private.local.cstowc_conv) {
+ _XlcCloseConverter(im->private.local.cstowc_conv);
+ im->private.local.cstowc_conv = NULL;
+ }
+ if (im->private.local.cstoutf8_conv) {
+ _XlcCloseConverter(im->private.local.cstoutf8_conv);
+ im->private.local.cstoutf8_conv = NULL;
+ }
+ if (im->private.local.ucstoc_conv) {
+ _XlcCloseConverter(im->private.local.ucstoc_conv);
+ im->private.local.ucstoc_conv = NULL;
+ }
+ if (im->private.local.ucstoutf8_conv) {
+ _XlcCloseConverter(im->private.local.ucstoutf8_conv);
+ im->private.local.ucstoutf8_conv = NULL;
+ }
+ return;
+}
+
+Private Status
+_XimLocalCloseIM(
+ XIM xim)
+{
+ Xim im = (Xim)xim;
+ XIC ic;
+ XIC next;
+
+ ic = im->core.ic_chain;
+ im->core.ic_chain = NULL;
+ while (ic) {
+ (*ic->methods->destroy) (ic);
+ next = ic->core.next;
+ Xfree ((char *) ic);
+ ic = next;
+ }
+ _XimLocalIMFree(im);
+ _XimDestroyIMStructureList(im);
+ return(True);
+}
+
+Public char *
+_XimLocalGetIMValues(
+ XIM xim,
+ XIMArg *values)
+{
+ Xim im = (Xim)xim;
+ XimDefIMValues im_values;
+
+ _XimGetCurrentIMValues(im, &im_values);
+ return(_XimGetIMValueData(im, (XPointer)&im_values, values,
+ im->core.im_resources, im->core.im_num_resources));
+}
+
+Public char *
+_XimLocalSetIMValues(
+ XIM xim,
+ XIMArg *values)
+{
+ Xim im = (Xim)xim;
+ XimDefIMValues im_values;
+ char *name = (char *)NULL;
+
+ _XimGetCurrentIMValues(im, &im_values);
+ name = _XimSetIMValueData(im, (XPointer)&im_values, values,
+ im->core.im_resources, im->core.im_num_resources);
+ _XimSetCurrentIMValues(im, &im_values);
+ return(name);
+}
+
+
+#ifdef COMPOSECACHE
+
+Private Bool
+_XimReadCachedDefaultTree(
+ int fd_cache,
+ const char *name,
+ const char *encoding,
+ DTStructIndex size)
+{
+ struct _XimCacheStruct* m;
+ int namelen = strlen (name) + 1;
+ int encodinglen = strlen (encoding) + 1;
+
+ m = mmap (NULL, size, PROT_READ, MAP_PRIVATE, fd_cache, 0);
+ if (m == NULL || m == MAP_FAILED)
+ return False;
+ assert (m->id == XIM_CACHE_MAGIC);
+ assert (m->version == XIM_CACHE_VERSION);
+ if (size != m->size ||
+ size < XOffsetOf (struct _XimCacheStruct, fname) + namelen + encodinglen) {
+ fprintf (stderr, "Ignoring broken XimCache %s [%s]\n", name, encoding);
+ munmap (m, size);
+ return False;
+ }
+ if (strncmp (name, m->fname, namelen) != 0) {
+ /* m->fname may *not* be terminated - but who cares here */
+ fprintf (stderr, "Filename hash clash - expected %s, got %s\n",
+ name, m->fname);
+ munmap (m, size);
+ return False;
+ }
+ if (strncmp (encoding, m->fname + namelen, encodinglen) != 0) {
+ /* m->fname+namelen may *not* be terminated - but who cares here */
+ fprintf (stderr, "Enoding hash clash - expected %s, got %s\n",
+ encoding, m->fname + namelen);
+ munmap (m, size);
+ return False;
+ }
+ _XimCache_mmap = m;
+ _XimCachedDefaultTreeBase.tree = (DefTree *) (((char *) m) + m->tree);
+ _XimCachedDefaultTreeBase.mb = (((char *) m) + m->mb);
+ _XimCachedDefaultTreeBase.wc = (wchar_t *) (((char *) m) + m->wc);
+ _XimCachedDefaultTreeBase.utf8 = (((char *) m) + m->utf8);
+ _XimCachedDefaultTreeBase.treeused = m->treeused;
+ _XimCachedDefaultTreeBase.mbused = m->mbused;
+ _XimCachedDefaultTreeBase.wcused = m->wcused;
+ _XimCachedDefaultTreeBase.utf8used = m->utf8used;
+ /* treesize etc. is ignored because only used during parsing */
+ _XimCachedDefaultTreeRefcount = 0;
+/* fprintf (stderr, "read cached tree at %p: %s\n", (void *) m, name); */
+ return True;
+}
+
+Private unsigned int strToHash (
+ const char *name)
+{
+ unsigned int hash = 0;
+ while (*name)
+ hash = hash * XIM_HASH_PRIME_1 + *(unsigned const char *)name++;
+ return hash % XIM_HASH_PRIME_2;
+}
+
+
+/* Returns read-only fd of cache file, -1 if none.
+ * Sets *res to cache filename if safe. Sets *size to file size of cache. */
+Private int _XimCachedFileName (
+ const char *dir, const char *name,
+ const char *intname, const char *encoding,
+ uid_t uid, int isglobal, char **res, off_t *size)
+{
+ struct stat st_name, st;
+ int fd;
+ unsigned int len, hash, hash2;
+ struct _XimCacheStruct *m;
+ /* There are some races here with 'dir', but we are either in our own home
+ * or the global cache dir, and not inside some public writable dir */
+/* fprintf (stderr, "XimCachedFileName for dir %s name %s intname %s encoding %s uid %d\n", dir, name, intname, encoding, uid); */
+ if (stat (name, &st_name) == -1 || ! S_ISREG (st_name.st_mode)
+ || stat (dir, &st) == -1 || ! S_ISDIR (st.st_mode) || st.st_uid != uid
+ || (st.st_mode & 0022) != 0000) {
+ *res = NULL;
+ return -1;
+ }
+ len = strlen (dir);
+ hash = strToHash (intname);
+ hash2 = strToHash (encoding);
+ *res = Xmalloc (len + 1 + 27 + 1); /* Max VERSION 9999 */
+
+ if (len == 0 || dir [len-1] != '/')
+ sprintf (*res, "%s/%c%d_%03x_%08x_%08x", dir, _XimGetMyEndian(),
+ XIM_CACHE_VERSION, (unsigned int)sizeof (DefTree), hash, hash2);
+ else
+ sprintf (*res, "%s%c%d_%03x_%08x_%08x", dir, _XimGetMyEndian(),
+ XIM_CACHE_VERSION, (unsigned int)sizeof (DefTree), hash, hash2);
+
+/* fprintf (stderr, "-> %s\n", *res); */
+ if ( (fd = _XOpenFile (*res, O_RDONLY)) == -1)
+ return -1;
+
+ if (fstat (fd, &st) == -1) {
+ Xfree (*res);
+ *res = NULL;
+ close (fd);
+ return -1;
+ }
+ *size = st.st_size;
+
+ if (! S_ISREG (st.st_mode) || st.st_uid != uid
+ || (st.st_mode & 0022) != 0000 || st.st_mtime <= st_name.st_mtime
+ || (st.st_mtime < time (NULL) - 24*60*60 && ! isglobal)) {
+
+ close (fd);
+ if (unlink (*res) != 0) {
+ Xfree (*res);
+ *res = NULL; /* cache is not safe */
+ }
+ return -1;
+ }
+
+ m = mmap (NULL, sizeof (struct _XimCacheStruct), PROT_READ, MAP_PRIVATE,
+ fd, 0);
+ if (m == NULL || m == MAP_FAILED) {
+ close (fd);
+ Xfree (*res);
+ *res = NULL;
+ return -1;
+ }
+ if (*size < sizeof (struct _XimCacheStruct) || m->id != XIM_CACHE_MAGIC) {
+ munmap (m, sizeof (struct _XimCacheStruct));
+ close (fd);
+ fprintf (stderr, "Ignoring broken XimCache %s\n", *res);
+ Xfree (*res);
+ *res = NULL;
+ return -1;
+ }
+ if (m->version != XIM_CACHE_VERSION) {
+ munmap (m, sizeof (struct _XimCacheStruct));
+ close (fd);
+ if (unlink (*res) != 0) {
+ Xfree (*res);
+ *res = NULL; /* cache is not safe */
+ }
+ return -1;
+ }
+ munmap (m, sizeof (struct _XimCacheStruct));
+
+ return fd;
+}
+
+
+Private Bool _XimLoadCache (
+ int fd,
+ const char *name,
+ const char *encoding,
+ off_t size,
+ Xim im)
+{
+ if (_XimCache_mmap ||
+ _XimReadCachedDefaultTree (fd, name, encoding, size)) {
+ _XimCachedDefaultTreeRefcount++;
+ memcpy (&im->private.local.base, &_XimCachedDefaultTreeBase,
+ sizeof (_XimCachedDefaultTreeBase));
+ im->private.local.top = _XimCache_mmap->top;
+ return True;
+ }
+
+ return False;
+}
+
+
+Private void
+_XimWriteCachedDefaultTree(
+ const char *name,
+ const char *encoding,
+ const char *cachename,
+ Xim im)
+{
+ int fd;
+ FILE *fp;
+ struct _XimCacheStruct *m;
+ int msize = (XOffsetOf(struct _XimCacheStruct, fname)
+ + strlen(name) + strlen(encoding) + 2
+ + XIM_CACHE_TREE_ALIGNMENT-1) & -XIM_CACHE_TREE_ALIGNMENT;
+ DefTreeBase *b = &im->private.local.base;
+
+ if (! b->tree && ! (b->tree = Xmalloc (sizeof(DefTree))) )
+ return;
+ if (! b->mb && ! (b->mb = Xmalloc (1)) )
+ return;
+ if (! b->wc && ! (b->wc = Xmalloc (sizeof(wchar_t))) )
+ return;
+ if (! b->utf8 && ! (b->utf8 = Xmalloc (1)) )
+ return;
+
+ /* First entry is always unused */
+ memset (b->tree, 0, sizeof(DefTree));
+ b->mb[0] = 0;
+ b->wc[0] = 0;
+ b->utf8[0] = 0;
+
+ m = Xmalloc (msize);
+ memset (m, 0, msize);
+ m->id = XIM_CACHE_MAGIC;
+ m->version = XIM_CACHE_VERSION;
+ m->top = im->private.local.top;
+ m->treeused = b->treeused;
+ m->mbused = b->mbused;
+ m->wcused = b->wcused;
+ m->utf8used = b->utf8used;
+ /* Tree first, then wide chars, then the rest due to alignment */
+ m->tree = msize;
+ m->wc = msize + sizeof (DefTree) * m->treeused;
+ m->mb = m->wc + sizeof (wchar_t) * m->wcused;
+ m->utf8 = m->mb + m->mbused;
+ m->size = m->utf8 + m->utf8used;
+ strcpy (m->fname, name);
+ strcpy (m->fname+strlen(name)+1, encoding);
+
+ /* This STILL might be racy on NFS */
+ if ( (fd = _XOpenFileMode (cachename, O_WRONLY | O_CREAT | O_EXCL,
+ 0600)) < 0)
+ return;
+ if (! (fp = fdopen (fd, "wb")) ) {
+ close (fd);
+ return;
+ }
+ fwrite (m, msize, 1, fp);
+ fwrite (im->private.local.base.tree, sizeof(DefTree), m->treeused, fp);
+ fwrite (im->private.local.base.wc, sizeof(wchar_t), m->wcused, fp);
+ fwrite (im->private.local.base.mb, 1, m->mbused, fp);
+ fwrite (im->private.local.base.utf8, 1, m->utf8used, fp);
+ if (fclose (fp) != 0)
+ unlink (cachename);
+ _XimCache_mmap = m;
+ memcpy (&_XimCachedDefaultTreeBase, &im->private.local.base,
+ sizeof (_XimCachedDefaultTreeBase));
+/* fprintf (stderr, "wrote tree %s size %ld to %s\n", name, m->size, cachename); */
+}
+
+#endif
+
+
+Private void
+_XimCreateDefaultTree(
+ Xim im)
+{
+ FILE *fp = NULL;
+ char *name, *tmpname = NULL, *intname;
+ char *cachename = NULL;
+ /* Should use getpwent() instead of $HOME (cross-platform?) */
+ char *home = getenv("HOME");
+ char *cachedir = NULL;
+ char *tmpcachedir = NULL;
+ int hl = home ? strlen (home) : 0;
+#ifdef COMPOSECACHE
+ const char *encoding = nl_langinfo (CODESET);
+ uid_t euid = geteuid ();
+ gid_t egid = getegid ();
+ int cachefd = -1;
+ off_t size;
+#endif
+
+ name = getenv("XCOMPOSEFILE");
+ if (name == (char *) NULL) {
+ if (home != (char *) NULL) {
+ tmpname = name = Xmalloc(hl + 10 + 1);
+ if (name != (char *) NULL) {
+ int fd;
+ strcpy(name, home);
+ strcpy(name + hl, "/.XCompose");
+ if ( (fd = _XOpenFile (name, O_RDONLY)) < 0) {
+ Xfree (name);
+ name = tmpname = NULL;
+ } else
+ close (fd);
+ }
+ }
+ }
+
+ if (name == (char *) NULL) {
+ tmpname = name = _XlcFileName(im->core.lcd, COMPOSE_FILE);
+ }
+ intname = name;
+
+#ifdef COMPOSECACHE
+ if (getuid () == euid && getgid () == egid && euid != 0) {
+ char *c;
+ /* Usage: XCOMPOSECACHE=<cachedir>[=<filename>]
+ * cachedir: directory of cache files
+ * filename: internally used name for cache file */
+ cachedir = getenv("XCOMPOSECACHE");
+ if (cachedir && (c = strchr (cachedir, '='))) {
+ tmpcachedir = strdup (cachedir);
+ intname = tmpcachedir + (c-cachedir) + 1;
+ tmpcachedir[c-cachedir] = '\0';
+ cachedir = tmpcachedir;
+ }
+ }
+
+ if (! cachedir) {
+ cachefd = _XimCachedFileName (XIM_GLOBAL_CACHE_DIR, name, intname,
+ encoding, 0, 1, &cachename, &size);
+ if (cachefd != -1) {
+ if (_XimLoadCache (cachefd, intname, encoding, size, im)) {
+ if (tmpcachedir)
+ Xfree (tmpcachedir);
+ if (tmpname)
+ Xfree (tmpname);
+ if (cachename)
+ Xfree (cachename);
+ close (cachefd);
+ return;
+ }
+ close (cachefd);
+ }
+ if (cachename)
+ Xfree (cachename);
+ cachename = NULL;
+ }
+
+ if (getuid () == euid && getgid () == egid && euid != 0 && home) {
+
+ if (! cachedir) {
+ tmpcachedir = cachedir = Xmalloc (hl+strlen(XIM_HOME_CACHE_DIR)+1);
+ strcpy (cachedir, home);
+ strcat (cachedir, XIM_HOME_CACHE_DIR);
+ }
+ cachefd = _XimCachedFileName (cachedir, name, intname, encoding,
+ euid, 0, &cachename, &size);
+ if (cachefd != -1) {
+ if (_XimLoadCache (cachefd, intname, encoding, size, im)) {
+ if (tmpcachedir)
+ Xfree (tmpcachedir);
+ if (tmpname)
+ Xfree (tmpname);
+ if (cachename)
+ Xfree (cachename);
+ close (cachefd);
+ return;
+ }
+ close (cachefd);
+ }
+ }
+#endif
+
+ if (! (fp = _XFopenFile (name, "r"))) {
+ if (tmpcachedir)
+ Xfree (tmpcachedir);
+ if (tmpname)
+ Xfree (tmpname);
+ if (cachename)
+ Xfree (cachename);
+ return;
+ }
+ _XimParseStringFile(fp, im);
+ fclose(fp);
+
+#ifdef COMPOSECACHE
+ if (cachename) {
+ assert (euid != 0);
+ _XimWriteCachedDefaultTree (intname, encoding, cachename, im);
+ }
+#endif
+
+ if (tmpcachedir)
+ Xfree (tmpcachedir);
+ if (tmpname)
+ Xfree (tmpname);
+ if (cachename)
+ Xfree (cachename);
+}
+
+Private XIMMethodsRec Xim_im_local_methods = {
+ _XimLocalCloseIM, /* close */
+ _XimLocalSetIMValues, /* set_values */
+ _XimLocalGetIMValues, /* get_values */
+ _XimLocalCreateIC, /* create_ic */
+ _XimLcctstombs, /* ctstombs */
+ _XimLcctstowcs, /* ctstowcs */
+ _XimLcctstoutf8 /* ctstoutf8 */
+};
+
+Public Bool
+_XimLocalOpenIM(
+ Xim im)
+{
+ XLCd lcd = im->core.lcd;
+ XlcConv conv;
+ XimDefIMValues im_values;
+ XimLocalPrivateRec* private = &im->private.local;
+
+ _XimInitialResourceInfo();
+ if(_XimSetIMResourceList(&im->core.im_resources,
+ &im->core.im_num_resources) == False) {
+ goto Open_Error;
+ }
+ if(_XimSetICResourceList(&im->core.ic_resources,
+ &im->core.ic_num_resources) == False) {
+ goto Open_Error;
+ }
+
+ _XimSetIMMode(im->core.im_resources, im->core.im_num_resources);
+
+ _XimGetCurrentIMValues(im, &im_values);
+ if(_XimSetLocalIMDefaults(im, (XPointer)&im_values,
+ im->core.im_resources, im->core.im_num_resources) == False) {
+ goto Open_Error;
+ }
+ _XimSetCurrentIMValues(im, &im_values);
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte)))
+ goto Open_Error;
+ private->ctom_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNWideChar)))
+ goto Open_Error;
+ private->ctow_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNUtf8String)))
+ goto Open_Error;
+ private->ctoutf8_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte)))
+ goto Open_Error;
+ private->cstomb_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNCharSet, lcd, XlcNWideChar)))
+ goto Open_Error;
+ private->cstowc_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNCharSet, lcd, XlcNUtf8String)))
+ goto Open_Error;
+ private->cstoutf8_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNUcsChar, lcd, XlcNChar)))
+ goto Open_Error;
+ private->ucstoc_conv = conv;
+
+ if (!(conv = _XlcOpenConverter(lcd, XlcNUcsChar, lcd, XlcNUtf8String)))
+ goto Open_Error;
+ private->ucstoutf8_conv = conv;
+
+ private->base.treeused = 1;
+ private->base.mbused = 1;
+ private->base.wcused = 1;
+ private->base.utf8used = 1;
+
+ _XimCreateDefaultTree(im);
+
+ im->methods = &Xim_im_local_methods;
+ private->current_ic = (XIC)NULL;
+
+ return(True);
+
+Open_Error :
+ _XimLocalIMFree(im);
+ return(False);
+}
diff --git a/libX11/modules/im/ximcp/imLcPrs.c b/libX11/modules/im/ximcp/imLcPrs.c index c0801722a..f6c42daa8 100644 --- a/libX11/modules/im/ximcp/imLcPrs.c +++ b/libX11/modules/im/ximcp/imLcPrs.c @@ -1,689 +1,684 @@ -/****************************************************************** - - Copyright 1992 by Oki Technosystems Laboratory, Inc. - Copyright 1992 by Fuji Xerox Co., Ltd. - -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 Oki Technosystems -Laboratory and Fuji Xerox not be used in advertising or publicity -pertaining to distribution of the software without specific, written -prior permission. -Oki Technosystems Laboratory and Fuji Xerox make no representations -about the suitability of this software for any purpose. It is provided -"as is" without express or implied warranty. - -OKI TECHNOSYSTEMS LABORATORY AND FUJI XEROX DISCLAIM ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL OKI TECHNOSYSTEMS -LABORATORY AND FUJI XEROX 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: Yasuhiro Kawai Oki Technosystems Laboratory - Author: Kazunori Nishihara Fuji Xerox - -******************************************************************/ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xlib.h> -#include <X11/Xmd.h> -#include <X11/Xos.h> -#include "Xlibint.h" -#include "Xlcint.h" -#include "Ximint.h" -#include <sys/stat.h> -#include <stdio.h> - -#define XLC_BUFSIZE 256 - -extern void xlocaledir( - char *buf, - int buf_len -); - -extern int _Xmbstowcs( - wchar_t *wstr, - char *str, - int len -); - -extern int _Xmbstoutf8( - char *ustr, - const char *str, - int len -); - -/* - * Parsing File Format: - * - * FILE ::= { [PRODUCTION] [COMMENT] "\n"} - * PRODUCTION ::= LHS ":" RHS [ COMMENT ] - * COMMENT ::= "#" {<any character except null or newline>} - * LHS ::= EVENT { EVENT } - * EVENT ::= [MODIFIER_LIST] "<" keysym ">" - * MODIFIER_LIST ::= ("!" {MODIFIER} ) | "None" - * MODIFIER ::= ["~"] modifier_name - * RHS ::= ( STRING | keysym | STRING keysym ) - * STRING ::= '"' { CHAR } '"' - * CHAR ::= GRAPHIC_CHAR | ESCAPED_CHAR - * GRAPHIC_CHAR ::= locale (codeset) dependent code - * ESCAPED_CHAR ::= ('\\' | '\"' | OCTAL | HEX ) - * OCTAL ::= '\' OCTAL_CHAR [OCTAL_CHAR [OCTAL_CHAR]] - * OCTAL_CHAR ::= (0|1|2|3|4|5|6|7) - * HEX ::= '\' (x|X) HEX_CHAR [HEX_CHAR]] - * HEX_CHAR ::= (0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|a|b|c|d|e|f) - * - */ - -static int -nextch( - FILE *fp, - int *lastch) -{ - int c; - - if (*lastch != 0) { - c = *lastch; - *lastch = 0; - } else { - c = getc(fp); - if (c == '\\') { - c = getc(fp); - if (c == '\n') { - c = getc(fp); - } else { - ungetc(c, fp); - c = '\\'; - } - } - } - return(c); -} - -static void -putbackch( - int c, - int *lastch) -{ - *lastch = c; -} - -#define ENDOFFILE 0 -#define ENDOFLINE 1 -#define COLON 2 -#define LESS 3 -#define GREATER 4 -#define EXCLAM 5 -#define TILDE 6 -#define STRING 7 -#define KEY 8 -#define ERROR 9 - -#ifndef isalnum -#define isalnum(c) \ - (('0' <= (c) && (c) <= '9') || \ - ('A' <= (c) && (c) <= 'Z') || \ - ('a' <= (c) && (c) <= 'z')) -#endif - -static int -nexttoken( - FILE *fp, - char *tokenbuf, - int *lastch) -{ - int c; - int token; - char *p; - int i, j; - - while ((c = nextch(fp, lastch)) == ' ' || c == '\t') { - } - switch (c) { - case EOF: - token = ENDOFFILE; - break; - case '\n': - token = ENDOFLINE; - break; - case '<': - token = LESS; - break; - case '>': - token = GREATER; - break; - case ':': - token = COLON; - break; - case '!': - token = EXCLAM; - break; - case '~': - token = TILDE; - break; - case '"': - p = tokenbuf; - while ((c = nextch(fp, lastch)) != '"') { - if (c == '\n' || c == EOF) { - putbackch(c, lastch); - token = ERROR; - goto string_error; - } else if (c == '\\') { - c = nextch(fp, lastch); - switch (c) { - case '\\': - case '"': - *p++ = c; - break; - case 'n': - *p++ = '\n'; - break; - case 'r': - *p++ = '\r'; - break; - case 't': - *p++ = '\t'; - break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - i = c - '0'; - c = nextch(fp, lastch); - for (j = 0; j < 2 && c >= '0' && c <= '7'; j++) { - i <<= 3; - i += c - '0'; - c = nextch(fp, lastch); - } - putbackch(c, lastch); - *p++ = (char)i; - break; - case 'X': - case 'x': - i = 0; - for (j = 0; j < 2; j++) { - c = nextch(fp, lastch); - i <<= 4; - if (c >= '0' && c <= '9') { - i += c - '0'; - } else if (c >= 'A' && c <= 'F') { - i += c - 'A' + 10; - } else if (c >= 'a' && c <= 'f') { - i += c - 'a' + 10; - } else { - putbackch(c, lastch); - i >>= 4; - break; - } - } - if (j == 0) { - token = ERROR; - goto string_error; - } - *p++ = (char)i; - break; - case EOF: - putbackch(c, lastch); - token = ERROR; - goto string_error; - default: - *p++ = c; - break; - } - } else { - *p++ = c; - } - } - *p = '\0'; - token = STRING; - break; - case '#': - while ((c = nextch(fp, lastch)) != '\n' && c != EOF) { - } - if (c == '\n') { - token = ENDOFLINE; - } else { - token = ENDOFFILE; - } - break; - default: - if (isalnum(c) || c == '_' || c == '-') { - p = tokenbuf; - *p++ = c; - c = nextch(fp, lastch); - while (isalnum(c) || c == '_' || c == '-') { - *p++ = c; - c = nextch(fp, lastch); - } - *p = '\0'; - putbackch(c, lastch); - token = KEY; - } else { - token = ERROR; - } - break; - } -string_error: - return(token); -} - -static long -modmask( - char *name) -{ - struct _modtbl { - const char name[6]; - long mask; - }; - - static const struct _modtbl tbl[] = { - { "Ctrl", ControlMask }, - { "Lock", LockMask }, - { "Caps", LockMask }, - { "Shift", ShiftMask }, - { "Alt", Mod1Mask }, - { "Meta", Mod1Mask }}; - - int i, num_entries = sizeof (tbl) / sizeof (tbl[0]); - - for (i = 0; i < num_entries; i++) - if (!strcmp (name, tbl[i].name)) - return tbl[i].mask; - - return 0; -} - -static char* -TransFileName(Xim im, char *name) -{ - char *home = NULL, *lcCompose = NULL; - char dir[XLC_BUFSIZE]; - char *i = name, *ret, *j; - int l = 0; - - while (*i) { - if (*i == '%') { - i++; - switch (*i) { - case '%': - l++; - break; - case 'H': - home = getenv("HOME"); - if (home) - l += strlen(home); - break; - case 'L': - lcCompose = _XlcFileName(im->core.lcd, COMPOSE_FILE); - if (lcCompose) - l += strlen(lcCompose); - break; - case 'S': - xlocaledir(dir, XLC_BUFSIZE); - l += strlen(dir); - break; - } - } else { - l++; - } - i++; - } - - j = ret = Xmalloc(l+1); - if (ret == NULL) - return ret; - i = name; - while (*i) { - if (*i == '%') { - i++; - switch (*i) { - case '%': - *j++ = '%'; - break; - case 'H': - if (home) { - strcpy(j, home); - j += strlen(home); - } - break; - case 'L': - if (lcCompose) { - strcpy(j, lcCompose); - j += strlen(lcCompose); - Xfree(lcCompose); - } - break; - case 'S': - strcpy(j, dir); - j += strlen(dir); - break; - } - i++; - } else { - *j++ = *i++; - } - } - *j = '\0'; - return ret; -} - -#ifndef MB_LEN_MAX -#define MB_LEN_MAX 6 -#endif - -static int -get_mb_string (Xim im, char *buf, KeySym ks) -{ - XPointer from, to; - int from_len, to_len, len; - XPointer args[1]; - XlcCharSet charset; - char local_buf[MB_LEN_MAX]; - unsigned int ucs; - ucs = KeySymToUcs4(ks); - - from = (XPointer) &ucs; - to = (XPointer) local_buf; - from_len = 1; - to_len = MB_LEN_MAX; - args[0] = (XPointer) &charset; - if (_XlcConvert(im->private.local.ucstoc_conv, - &from, &from_len, &to, &to_len, args, 1 ) != 0) { - return 0; - } - - from = (XPointer) local_buf; - to = (XPointer) buf; - from_len = MB_LEN_MAX - to_len; - to_len = MB_LEN_MAX + 1; - args[0] = (XPointer) charset; - if (_XlcConvert(im->private.local.cstomb_conv, - &from, &from_len, &to, &to_len, args, 1 ) != 0) { - return 0; - } - len = MB_LEN_MAX + 1 - to_len; - buf[len] = '\0'; - return len; -} - -#define AllMask (ShiftMask | LockMask | ControlMask | Mod1Mask) -#define LOCAL_WC_BUFSIZE 128 -#define LOCAL_UTF8_BUFSIZE 256 -#define SEQUENCE_MAX 10 - -static int -parseline( - FILE *fp, - Xim im, - char* tokenbuf) -{ - int token; - DTModifier modifier_mask; - DTModifier modifier; - DTModifier tmp; - KeySym keysym = NoSymbol; - DTIndex *top = &im->private.local.top; - DefTreeBase *b = &im->private.local.base; - DTIndex t; - DefTree *p = NULL; - Bool exclam, tilde; - KeySym rhs_keysym = 0; - char *rhs_string_mb; - int l; - int lastch = 0; - char local_mb_buf[MB_LEN_MAX+1]; - wchar_t local_wc_buf[LOCAL_WC_BUFSIZE], *rhs_string_wc; - char local_utf8_buf[LOCAL_UTF8_BUFSIZE], *rhs_string_utf8; - - struct DefBuffer { - DTModifier modifier_mask; - DTModifier modifier; - KeySym keysym; - }; - - struct DefBuffer buf[SEQUENCE_MAX]; - int i, n; - - do { - token = nexttoken(fp, tokenbuf, &lastch); - } while (token == ENDOFLINE); - - if (token == ENDOFFILE) { - return(-1); - } - - n = 0; - do { - if ((token == KEY) && (strcmp("include", tokenbuf) == 0)) { - char *filename; - FILE *infp; - token = nexttoken(fp, tokenbuf, &lastch); - if (token != KEY && token != STRING) - goto error; - if ((filename = TransFileName(im, tokenbuf)) == NULL) - goto error; - infp = _XFopenFile(filename, "r"); - Xfree(filename); - if (infp == NULL) - goto error; - _XimParseStringFile(infp, im); - fclose(infp); - return (0); - } else if ((token == KEY) && (strcmp("None", tokenbuf) == 0)) { - modifier = 0; - modifier_mask = AllMask; - token = nexttoken(fp, tokenbuf, &lastch); - } else { - modifier_mask = modifier = 0; - exclam = False; - if (token == EXCLAM) { - exclam = True; - token = nexttoken(fp, tokenbuf, &lastch); - } - while (token == TILDE || token == KEY) { - tilde = False; - if (token == TILDE) { - tilde = True; - token = nexttoken(fp, tokenbuf, &lastch); - if (token != KEY) - goto error; - } - tmp = modmask(tokenbuf); - if (!tmp) { - goto error; - } - modifier_mask |= tmp; - if (tilde) { - modifier &= ~tmp; - } else { - modifier |= tmp; - } - token = nexttoken(fp, tokenbuf, &lastch); - } - if (exclam) { - modifier_mask = AllMask; - } - } - - if (token != LESS) { - goto error; - } - - token = nexttoken(fp, tokenbuf, &lastch); - if (token != KEY) { - goto error; - } - - token = nexttoken(fp, tokenbuf, &lastch); - if (token != GREATER) { - goto error; - } - - keysym = XStringToKeysym(tokenbuf); - if (keysym == NoSymbol) { - goto error; - } - - buf[n].keysym = keysym; - buf[n].modifier = modifier; - buf[n].modifier_mask = modifier_mask; - n++; - if( n >= SEQUENCE_MAX ) - goto error; - token = nexttoken(fp, tokenbuf, &lastch); - } while (token != COLON); - - token = nexttoken(fp, tokenbuf, &lastch); - if (token == STRING) { - l = strlen(tokenbuf) + 1; - while (b->mbused + l > b->mbsize) { - b->mbsize = b->mbsize ? b->mbsize * 1.5 : 1024; - if (! (b->mb = Xrealloc (b->mb, b->mbsize)) ) - goto error; - } - rhs_string_mb = &b->mb[b->mbused]; - b->mbused += l; - strcpy(rhs_string_mb, tokenbuf); - token = nexttoken(fp, tokenbuf, &lastch); - if (token == KEY) { - rhs_keysym = XStringToKeysym(tokenbuf); - if (rhs_keysym == NoSymbol) { - goto error; - } - token = nexttoken(fp, tokenbuf, &lastch); - } - if (token != ENDOFLINE && token != ENDOFFILE) { - goto error; - } - } else if (token == KEY) { - rhs_keysym = XStringToKeysym(tokenbuf); - if (rhs_keysym == NoSymbol) { - goto error; - } - token = nexttoken(fp, tokenbuf, &lastch); - if (token != ENDOFLINE && token != ENDOFFILE) { - goto error; - } - - l = get_mb_string(im, local_mb_buf, rhs_keysym); - while (b->mbused + l + 1 > b->mbsize) { - b->mbsize = b->mbsize ? b->mbsize * 1.5 : 1024; - if (! (b->mb = Xrealloc (b->mb, b->mbsize)) ) - goto error; - } - rhs_string_mb = &b->mb[b->mbused]; - b->mbused += l + 1; - memcpy(rhs_string_mb, local_mb_buf, l); - rhs_string_mb[l] = '\0'; - } else { - goto error; - } - - l = _Xmbstowcs(local_wc_buf, rhs_string_mb, LOCAL_WC_BUFSIZE - 1); - if (l == LOCAL_WC_BUFSIZE - 1) { - local_wc_buf[l] = (wchar_t)'\0'; - } - while (b->wcused + l + 1 > b->wcsize) { - b->wcsize = b->wcsize ? b->wcsize * 1.5 : 512; - if (! (b->wc = Xrealloc (b->wc, sizeof(wchar_t) * b->wcsize)) ) - goto error; - } - rhs_string_wc = &b->wc[b->wcused]; - b->wcused += l + 1; - memcpy((char *)rhs_string_wc, (char *)local_wc_buf, (l + 1) * sizeof(wchar_t) ); - - l = _Xmbstoutf8(local_utf8_buf, rhs_string_mb, LOCAL_UTF8_BUFSIZE - 1); - if (l == LOCAL_UTF8_BUFSIZE - 1) { - local_utf8_buf[l] = '\0'; - } - while (b->utf8used + l + 1 > b->utf8size) { - b->utf8size = b->utf8size ? b->utf8size * 1.5 : 1024; - if (! (b->utf8 = Xrealloc (b->utf8, b->utf8size)) ) - goto error; - } - rhs_string_utf8 = &b->utf8[b->utf8used]; - b->utf8used += l + 1; - memcpy(rhs_string_utf8, local_utf8_buf, l + 1); - - for (i = 0; i < n; i++) { - for (t = *top; t; t = b->tree[t].next) { - if (buf[i].keysym == b->tree[t].keysym && - buf[i].modifier == b->tree[t].modifier && - buf[i].modifier_mask == b->tree[t].modifier_mask) { - break; - } - } - if (t) { - p = &b->tree[t]; - top = &p->succession; - } else { - while (b->treeused >= b->treesize) { - DefTree *old = b->tree; - int oldsize = b->treesize; - b->treesize = b->treesize ? b->treesize * 1.5 : 256; - if (! (b->tree = Xrealloc (b->tree, sizeof(DefTree) * b->treesize)) ) - goto error; - if (top >= (DTIndex *) old && top < (DTIndex *) &old[oldsize]) - top = (DTIndex *) (((char *) top) + (((char *)b->tree)-(char *)old)); - } - p = &b->tree[b->treeused]; - p->keysym = buf[i].keysym; - p->modifier = buf[i].modifier; - p->modifier_mask = buf[i].modifier_mask; - p->succession = 0; - p->next = *top; - p->mb = 0; - p->wc = 0; - p->utf8 = 0; - p->ks = NoSymbol; - *top = b->treeused; - top = &p->succession; - b->treeused++; - } - } - - /* old entries no longer freed... */ - p->mb = rhs_string_mb - b->mb; - p->wc = rhs_string_wc - b->wc; - p->utf8 = rhs_string_utf8 - b->utf8; - p->ks = rhs_keysym; - return(n); -error: - while (token != ENDOFLINE && token != ENDOFFILE) { - token = nexttoken(fp, tokenbuf, &lastch); - } - return(0); -} - -void -_XimParseStringFile( - FILE *fp, - Xim im) -{ - char tb[8192]; - char* tbp; - struct stat st; - - if (fstat (fileno (fp), &st) != -1) { - unsigned long size = (unsigned long) st.st_size; - if (size <= sizeof tb) tbp = tb; - else tbp = malloc (size); - - if (tbp != NULL) { - while (parseline(fp, im, tbp) >= 0) {} - if (tbp != tb) free (tbp); - } - } -} +/******************************************************************
+
+ Copyright 1992 by Oki Technosystems Laboratory, Inc.
+ Copyright 1992 by Fuji Xerox Co., Ltd.
+
+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 Oki Technosystems
+Laboratory and Fuji Xerox not be used in advertising or publicity
+pertaining to distribution of the software without specific, written
+prior permission.
+Oki Technosystems Laboratory and Fuji Xerox make no representations
+about the suitability of this software for any purpose. It is provided
+"as is" without express or implied warranty.
+
+OKI TECHNOSYSTEMS LABORATORY AND FUJI XEROX DISCLAIM ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL OKI TECHNOSYSTEMS
+LABORATORY AND FUJI XEROX 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: Yasuhiro Kawai Oki Technosystems Laboratory
+ Author: Kazunori Nishihara Fuji Xerox
+
+******************************************************************/
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlib.h>
+#include <X11/Xmd.h>
+#include <X11/Xos.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+#include <sys/stat.h>
+#include <stdio.h>
+
+#define XLC_BUFSIZE 256
+
+extern int _Xmbstowcs(
+ wchar_t *wstr,
+ char *str,
+ int len
+);
+
+extern int _Xmbstoutf8(
+ char *ustr,
+ const char *str,
+ int len
+);
+
+/*
+ * Parsing File Format:
+ *
+ * FILE ::= { [PRODUCTION] [COMMENT] "\n"}
+ * PRODUCTION ::= LHS ":" RHS [ COMMENT ]
+ * COMMENT ::= "#" {<any character except null or newline>}
+ * LHS ::= EVENT { EVENT }
+ * EVENT ::= [MODIFIER_LIST] "<" keysym ">"
+ * MODIFIER_LIST ::= ("!" {MODIFIER} ) | "None"
+ * MODIFIER ::= ["~"] modifier_name
+ * RHS ::= ( STRING | keysym | STRING keysym )
+ * STRING ::= '"' { CHAR } '"'
+ * CHAR ::= GRAPHIC_CHAR | ESCAPED_CHAR
+ * GRAPHIC_CHAR ::= locale (codeset) dependent code
+ * ESCAPED_CHAR ::= ('\\' | '\"' | OCTAL | HEX )
+ * OCTAL ::= '\' OCTAL_CHAR [OCTAL_CHAR [OCTAL_CHAR]]
+ * OCTAL_CHAR ::= (0|1|2|3|4|5|6|7)
+ * HEX ::= '\' (x|X) HEX_CHAR [HEX_CHAR]]
+ * HEX_CHAR ::= (0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|a|b|c|d|e|f)
+ *
+ */
+
+static int
+nextch(
+ FILE *fp,
+ int *lastch)
+{
+ int c;
+
+ if (*lastch != 0) {
+ c = *lastch;
+ *lastch = 0;
+ } else {
+ c = getc(fp);
+ if (c == '\\') {
+ c = getc(fp);
+ if (c == '\n') {
+ c = getc(fp);
+ } else {
+ ungetc(c, fp);
+ c = '\\';
+ }
+ }
+ }
+ return(c);
+}
+
+static void
+putbackch(
+ int c,
+ int *lastch)
+{
+ *lastch = c;
+}
+
+#define ENDOFFILE 0
+#define ENDOFLINE 1
+#define COLON 2
+#define LESS 3
+#define GREATER 4
+#define EXCLAM 5
+#define TILDE 6
+#define STRING 7
+#define KEY 8
+#define ERROR 9
+
+#ifndef isalnum
+#define isalnum(c) \
+ (('0' <= (c) && (c) <= '9') || \
+ ('A' <= (c) && (c) <= 'Z') || \
+ ('a' <= (c) && (c) <= 'z'))
+#endif
+
+static int
+nexttoken(
+ FILE *fp,
+ char *tokenbuf,
+ int *lastch)
+{
+ int c;
+ int token;
+ char *p;
+ int i, j;
+
+ while ((c = nextch(fp, lastch)) == ' ' || c == '\t') {
+ }
+ switch (c) {
+ case EOF:
+ token = ENDOFFILE;
+ break;
+ case '\n':
+ token = ENDOFLINE;
+ break;
+ case '<':
+ token = LESS;
+ break;
+ case '>':
+ token = GREATER;
+ break;
+ case ':':
+ token = COLON;
+ break;
+ case '!':
+ token = EXCLAM;
+ break;
+ case '~':
+ token = TILDE;
+ break;
+ case '"':
+ p = tokenbuf;
+ while ((c = nextch(fp, lastch)) != '"') {
+ if (c == '\n' || c == EOF) {
+ putbackch(c, lastch);
+ token = ERROR;
+ goto string_error;
+ } else if (c == '\\') {
+ c = nextch(fp, lastch);
+ switch (c) {
+ case '\\':
+ case '"':
+ *p++ = c;
+ break;
+ case 'n':
+ *p++ = '\n';
+ break;
+ case 'r':
+ *p++ = '\r';
+ break;
+ case 't':
+ *p++ = '\t';
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ i = c - '0';
+ c = nextch(fp, lastch);
+ for (j = 0; j < 2 && c >= '0' && c <= '7'; j++) {
+ i <<= 3;
+ i += c - '0';
+ c = nextch(fp, lastch);
+ }
+ putbackch(c, lastch);
+ *p++ = (char)i;
+ break;
+ case 'X':
+ case 'x':
+ i = 0;
+ for (j = 0; j < 2; j++) {
+ c = nextch(fp, lastch);
+ i <<= 4;
+ if (c >= '0' && c <= '9') {
+ i += c - '0';
+ } else if (c >= 'A' && c <= 'F') {
+ i += c - 'A' + 10;
+ } else if (c >= 'a' && c <= 'f') {
+ i += c - 'a' + 10;
+ } else {
+ putbackch(c, lastch);
+ i >>= 4;
+ break;
+ }
+ }
+ if (j == 0) {
+ token = ERROR;
+ goto string_error;
+ }
+ *p++ = (char)i;
+ break;
+ case EOF:
+ putbackch(c, lastch);
+ token = ERROR;
+ goto string_error;
+ default:
+ *p++ = c;
+ break;
+ }
+ } else {
+ *p++ = c;
+ }
+ }
+ *p = '\0';
+ token = STRING;
+ break;
+ case '#':
+ while ((c = nextch(fp, lastch)) != '\n' && c != EOF) {
+ }
+ if (c == '\n') {
+ token = ENDOFLINE;
+ } else {
+ token = ENDOFFILE;
+ }
+ break;
+ default:
+ if (isalnum(c) || c == '_' || c == '-') {
+ p = tokenbuf;
+ *p++ = c;
+ c = nextch(fp, lastch);
+ while (isalnum(c) || c == '_' || c == '-') {
+ *p++ = c;
+ c = nextch(fp, lastch);
+ }
+ *p = '\0';
+ putbackch(c, lastch);
+ token = KEY;
+ } else {
+ token = ERROR;
+ }
+ break;
+ }
+string_error:
+ return(token);
+}
+
+static long
+modmask(
+ char *name)
+{
+ struct _modtbl {
+ const char name[6];
+ long mask;
+ };
+
+ static const struct _modtbl tbl[] = {
+ { "Ctrl", ControlMask },
+ { "Lock", LockMask },
+ { "Caps", LockMask },
+ { "Shift", ShiftMask },
+ { "Alt", Mod1Mask },
+ { "Meta", Mod1Mask }};
+
+ int i, num_entries = sizeof (tbl) / sizeof (tbl[0]);
+
+ for (i = 0; i < num_entries; i++)
+ if (!strcmp (name, tbl[i].name))
+ return tbl[i].mask;
+
+ return 0;
+}
+
+static char*
+TransFileName(Xim im, char *name)
+{
+ char *home = NULL, *lcCompose = NULL;
+ char dir[XLC_BUFSIZE];
+ char *i = name, *ret, *j;
+ int l = 0;
+
+ while (*i) {
+ if (*i == '%') {
+ i++;
+ switch (*i) {
+ case '%':
+ l++;
+ break;
+ case 'H':
+ home = getenv("HOME");
+ if (home)
+ l += strlen(home);
+ break;
+ case 'L':
+ lcCompose = _XlcFileName(im->core.lcd, COMPOSE_FILE);
+ if (lcCompose)
+ l += strlen(lcCompose);
+ break;
+ case 'S':
+ xlocaledir(dir, XLC_BUFSIZE);
+ l += strlen(dir);
+ break;
+ }
+ } else {
+ l++;
+ }
+ i++;
+ }
+
+ j = ret = Xmalloc(l+1);
+ if (ret == NULL)
+ return ret;
+ i = name;
+ while (*i) {
+ if (*i == '%') {
+ i++;
+ switch (*i) {
+ case '%':
+ *j++ = '%';
+ break;
+ case 'H':
+ if (home) {
+ strcpy(j, home);
+ j += strlen(home);
+ }
+ break;
+ case 'L':
+ if (lcCompose) {
+ strcpy(j, lcCompose);
+ j += strlen(lcCompose);
+ Xfree(lcCompose);
+ }
+ break;
+ case 'S':
+ strcpy(j, dir);
+ j += strlen(dir);
+ break;
+ }
+ i++;
+ } else {
+ *j++ = *i++;
+ }
+ }
+ *j = '\0';
+ return ret;
+}
+
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 6
+#endif
+
+static int
+get_mb_string (Xim im, char *buf, KeySym ks)
+{
+ XPointer from, to;
+ int from_len, to_len, len;
+ XPointer args[1];
+ XlcCharSet charset;
+ char local_buf[MB_LEN_MAX];
+ unsigned int ucs;
+ ucs = KeySymToUcs4(ks);
+
+ from = (XPointer) &ucs;
+ to = (XPointer) local_buf;
+ from_len = 1;
+ to_len = MB_LEN_MAX;
+ args[0] = (XPointer) &charset;
+ if (_XlcConvert(im->private.local.ucstoc_conv,
+ &from, &from_len, &to, &to_len, args, 1 ) != 0) {
+ return 0;
+ }
+
+ from = (XPointer) local_buf;
+ to = (XPointer) buf;
+ from_len = MB_LEN_MAX - to_len;
+ to_len = MB_LEN_MAX + 1;
+ args[0] = (XPointer) charset;
+ if (_XlcConvert(im->private.local.cstomb_conv,
+ &from, &from_len, &to, &to_len, args, 1 ) != 0) {
+ return 0;
+ }
+ len = MB_LEN_MAX + 1 - to_len;
+ buf[len] = '\0';
+ return len;
+}
+
+#define AllMask (ShiftMask | LockMask | ControlMask | Mod1Mask)
+#define LOCAL_WC_BUFSIZE 128
+#define LOCAL_UTF8_BUFSIZE 256
+#define SEQUENCE_MAX 10
+
+static int
+parseline(
+ FILE *fp,
+ Xim im,
+ char* tokenbuf)
+{
+ int token;
+ DTModifier modifier_mask;
+ DTModifier modifier;
+ DTModifier tmp;
+ KeySym keysym = NoSymbol;
+ DTIndex *top = &im->private.local.top;
+ DefTreeBase *b = &im->private.local.base;
+ DTIndex t;
+ DefTree *p = NULL;
+ Bool exclam, tilde;
+ KeySym rhs_keysym = 0;
+ char *rhs_string_mb;
+ int l;
+ int lastch = 0;
+ char local_mb_buf[MB_LEN_MAX+1];
+ wchar_t local_wc_buf[LOCAL_WC_BUFSIZE], *rhs_string_wc;
+ char local_utf8_buf[LOCAL_UTF8_BUFSIZE], *rhs_string_utf8;
+
+ struct DefBuffer {
+ DTModifier modifier_mask;
+ DTModifier modifier;
+ KeySym keysym;
+ };
+
+ struct DefBuffer buf[SEQUENCE_MAX];
+ int i, n;
+
+ do {
+ token = nexttoken(fp, tokenbuf, &lastch);
+ } while (token == ENDOFLINE);
+
+ if (token == ENDOFFILE) {
+ return(-1);
+ }
+
+ n = 0;
+ do {
+ if ((token == KEY) && (strcmp("include", tokenbuf) == 0)) {
+ char *filename;
+ FILE *infp;
+ token = nexttoken(fp, tokenbuf, &lastch);
+ if (token != KEY && token != STRING)
+ goto error;
+ if ((filename = TransFileName(im, tokenbuf)) == NULL)
+ goto error;
+ infp = _XFopenFile(filename, "r");
+ Xfree(filename);
+ if (infp == NULL)
+ goto error;
+ _XimParseStringFile(infp, im);
+ fclose(infp);
+ return (0);
+ } else if ((token == KEY) && (strcmp("None", tokenbuf) == 0)) {
+ modifier = 0;
+ modifier_mask = AllMask;
+ token = nexttoken(fp, tokenbuf, &lastch);
+ } else {
+ modifier_mask = modifier = 0;
+ exclam = False;
+ if (token == EXCLAM) {
+ exclam = True;
+ token = nexttoken(fp, tokenbuf, &lastch);
+ }
+ while (token == TILDE || token == KEY) {
+ tilde = False;
+ if (token == TILDE) {
+ tilde = True;
+ token = nexttoken(fp, tokenbuf, &lastch);
+ if (token != KEY)
+ goto error;
+ }
+ tmp = modmask(tokenbuf);
+ if (!tmp) {
+ goto error;
+ }
+ modifier_mask |= tmp;
+ if (tilde) {
+ modifier &= ~tmp;
+ } else {
+ modifier |= tmp;
+ }
+ token = nexttoken(fp, tokenbuf, &lastch);
+ }
+ if (exclam) {
+ modifier_mask = AllMask;
+ }
+ }
+
+ if (token != LESS) {
+ goto error;
+ }
+
+ token = nexttoken(fp, tokenbuf, &lastch);
+ if (token != KEY) {
+ goto error;
+ }
+
+ token = nexttoken(fp, tokenbuf, &lastch);
+ if (token != GREATER) {
+ goto error;
+ }
+
+ keysym = XStringToKeysym(tokenbuf);
+ if (keysym == NoSymbol) {
+ goto error;
+ }
+
+ buf[n].keysym = keysym;
+ buf[n].modifier = modifier;
+ buf[n].modifier_mask = modifier_mask;
+ n++;
+ if( n >= SEQUENCE_MAX )
+ goto error;
+ token = nexttoken(fp, tokenbuf, &lastch);
+ } while (token != COLON);
+
+ token = nexttoken(fp, tokenbuf, &lastch);
+ if (token == STRING) {
+ l = strlen(tokenbuf) + 1;
+ while (b->mbused + l > b->mbsize) {
+ b->mbsize = b->mbsize ? b->mbsize * 1.5 : 1024;
+ if (! (b->mb = Xrealloc (b->mb, b->mbsize)) )
+ goto error;
+ }
+ rhs_string_mb = &b->mb[b->mbused];
+ b->mbused += l;
+ strcpy(rhs_string_mb, tokenbuf);
+ token = nexttoken(fp, tokenbuf, &lastch);
+ if (token == KEY) {
+ rhs_keysym = XStringToKeysym(tokenbuf);
+ if (rhs_keysym == NoSymbol) {
+ goto error;
+ }
+ token = nexttoken(fp, tokenbuf, &lastch);
+ }
+ if (token != ENDOFLINE && token != ENDOFFILE) {
+ goto error;
+ }
+ } else if (token == KEY) {
+ rhs_keysym = XStringToKeysym(tokenbuf);
+ if (rhs_keysym == NoSymbol) {
+ goto error;
+ }
+ token = nexttoken(fp, tokenbuf, &lastch);
+ if (token != ENDOFLINE && token != ENDOFFILE) {
+ goto error;
+ }
+
+ l = get_mb_string(im, local_mb_buf, rhs_keysym);
+ while (b->mbused + l + 1 > b->mbsize) {
+ b->mbsize = b->mbsize ? b->mbsize * 1.5 : 1024;
+ if (! (b->mb = Xrealloc (b->mb, b->mbsize)) )
+ goto error;
+ }
+ rhs_string_mb = &b->mb[b->mbused];
+ b->mbused += l + 1;
+ memcpy(rhs_string_mb, local_mb_buf, l);
+ rhs_string_mb[l] = '\0';
+ } else {
+ goto error;
+ }
+
+ l = _Xmbstowcs(local_wc_buf, rhs_string_mb, LOCAL_WC_BUFSIZE - 1);
+ if (l == LOCAL_WC_BUFSIZE - 1) {
+ local_wc_buf[l] = (wchar_t)'\0';
+ }
+ while (b->wcused + l + 1 > b->wcsize) {
+ b->wcsize = b->wcsize ? b->wcsize * 1.5 : 512;
+ if (! (b->wc = Xrealloc (b->wc, sizeof(wchar_t) * b->wcsize)) )
+ goto error;
+ }
+ rhs_string_wc = &b->wc[b->wcused];
+ b->wcused += l + 1;
+ memcpy((char *)rhs_string_wc, (char *)local_wc_buf, (l + 1) * sizeof(wchar_t) );
+
+ l = _Xmbstoutf8(local_utf8_buf, rhs_string_mb, LOCAL_UTF8_BUFSIZE - 1);
+ if (l == LOCAL_UTF8_BUFSIZE - 1) {
+ local_utf8_buf[l] = '\0';
+ }
+ while (b->utf8used + l + 1 > b->utf8size) {
+ b->utf8size = b->utf8size ? b->utf8size * 1.5 : 1024;
+ if (! (b->utf8 = Xrealloc (b->utf8, b->utf8size)) )
+ goto error;
+ }
+ rhs_string_utf8 = &b->utf8[b->utf8used];
+ b->utf8used += l + 1;
+ memcpy(rhs_string_utf8, local_utf8_buf, l + 1);
+
+ for (i = 0; i < n; i++) {
+ for (t = *top; t; t = b->tree[t].next) {
+ if (buf[i].keysym == b->tree[t].keysym &&
+ buf[i].modifier == b->tree[t].modifier &&
+ buf[i].modifier_mask == b->tree[t].modifier_mask) {
+ break;
+ }
+ }
+ if (t) {
+ p = &b->tree[t];
+ top = &p->succession;
+ } else {
+ while (b->treeused >= b->treesize) {
+ DefTree *old = b->tree;
+ int oldsize = b->treesize;
+ b->treesize = b->treesize ? b->treesize * 1.5 : 256;
+ if (! (b->tree = Xrealloc (b->tree, sizeof(DefTree) * b->treesize)) )
+ goto error;
+ if (top >= (DTIndex *) old && top < (DTIndex *) &old[oldsize])
+ top = (DTIndex *) (((char *) top) + (((char *)b->tree)-(char *)old));
+ }
+ p = &b->tree[b->treeused];
+ p->keysym = buf[i].keysym;
+ p->modifier = buf[i].modifier;
+ p->modifier_mask = buf[i].modifier_mask;
+ p->succession = 0;
+ p->next = *top;
+ p->mb = 0;
+ p->wc = 0;
+ p->utf8 = 0;
+ p->ks = NoSymbol;
+ *top = b->treeused;
+ top = &p->succession;
+ b->treeused++;
+ }
+ }
+
+ /* old entries no longer freed... */
+ p->mb = rhs_string_mb - b->mb;
+ p->wc = rhs_string_wc - b->wc;
+ p->utf8 = rhs_string_utf8 - b->utf8;
+ p->ks = rhs_keysym;
+ return(n);
+error:
+ while (token != ENDOFLINE && token != ENDOFFILE) {
+ token = nexttoken(fp, tokenbuf, &lastch);
+ }
+ return(0);
+}
+
+void
+_XimParseStringFile(
+ FILE *fp,
+ Xim im)
+{
+ char tb[8192];
+ char* tbp;
+ struct stat st;
+
+ if (fstat (fileno (fp), &st) != -1) {
+ unsigned long size = (unsigned long) st.st_size;
+ if (size <= sizeof tb) tbp = tb;
+ else tbp = malloc (size);
+
+ if (tbp != NULL) {
+ while (parseline(fp, im, tbp) >= 0) {}
+ if (tbp != tb) free (tbp);
+ }
+ }
+}
diff --git a/libX11/modules/im/ximcp/imRm.c b/libX11/modules/im/ximcp/imRm.c index 94190e9bb..249c42d3d 100644 --- a/libX11/modules/im/ximcp/imRm.c +++ b/libX11/modules/im/ximcp/imRm.c @@ -1,3205 +1,3205 @@ -/****************************************************************** - - Copyright 1990, 1991, 1992,1993, 1994 by FUJITSU LIMITED - Copyright 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 make -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 DISCLAIM ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJITSU LIMITED AND -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: Takashi Fujiwara FUJITSU LIMITED - fujiwara@a80.tech.yk.fujitsu.co.jp - Modifier: Makoto Wakamatsu Sony Corporation - makoto@sm.sony.co.jp - -******************************************************************/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <stdio.h> -#include <X11/Xlib.h> -#include "Xlibint.h" -#include "Xlcint.h" -#include "Ximint.h" -#include "Xresource.h" - -#define GET_NAME(x) name_table + x.name_offset - -typedef struct _XimValueOffsetInfo { - unsigned short name_offset; - XrmQuark quark; - unsigned int offset; - Bool (*defaults)( - struct _XimValueOffsetInfo *, XPointer, XPointer, unsigned long - ); - Bool (*encode)( - struct _XimValueOffsetInfo *, XPointer, XPointer - ); - Bool (*decode)( - struct _XimValueOffsetInfo *, XPointer, XPointer - ); -} XimValueOffsetInfoRec, *XimValueOffsetInfo; - -#ifdef XIM_CONNECTABLE -Private Bool -_XimCheckBool(str) - char *str; -{ - if(!strcmp(str, "True") || !strcmp(str, "true") || - !strcmp(str, "Yes") || !strcmp(str, "yes") || - !strcmp(str, "ON") || !strcmp(str, "on")) - return True; - return False; -} - -Public void -_XimSetProtoResource(im) - Xim im; -{ - char res_name_buf[256]; - char* res_name; - char res_class_buf[256]; - char* res_class; - char* str_type; - XrmValue value; - XIMStyle preedit_style = 0; - XIMStyle status_style = 0; - XIMStyles* imstyles; - char* dotximdot = ".xim."; - char* ximdot = "xim."; - char* dotXimdot = ".Xim."; - char* Ximdot = "Xim."; - - if (!im->core.rdb) - return; - - if (strlen (im->core.res_name) < 200) res_name = res_name_buf; - else res_name = Xmalloc (strlen (im->core.res_name) + 50); - if (strlen (im->core.res_class) < 200) res_class = res_class_buf; - else res_class = Xmalloc (strlen (im->core.res_class) + 50); - /* pretend malloc always works */ - - (void) sprintf (res_name, "%s%s%s", - im->core.res_name != NULL ? im->core.res_name : "*", - im->core.res_name != NULL ? dotximdot : ximdot, - "useAuth"); - (void) sprintf (res_class, "%s%s%s", - im->core.res_class != NULL ? im->core.res_class : "*", - im->core.res_class != NULL ? dotXimdot : Ximdot, - "UseAuth"); - bzero(&value, sizeof(XrmValue)); - if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) { - if(_XimCheckBool(value.addr)) { - MARK_USE_AUTHORIZATION_FUNC(im); - } - } - - (void) sprintf (res_name, "%s%s%s", - im->core.res_name != NULL ? im->core.res_name : "*", - im->core.res_name != NULL ? dotximdot : ximdot, - "delaybinding"); - (void) sprintf (res_class, "%s%s%s", - im->core.res_class != NULL ? im->core.res_class : "*", - im->core.res_class != NULL ? dotXimdot : Ximdot, - "Delaybinding"); - bzero(&value, sizeof(XrmValue)); - if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) { - if(_XimCheckBool(value.addr)) { - MARK_DELAYBINDABLE(im); - } - } - - (void) sprintf (res_name, "%s%s%s", - im->core.res_name != NULL ? im->core.res_name : "*", - im->core.res_name != NULL ? dotximdot : ximdot, - "reconnect"); - (void) sprintf (res_class, "%s%s%s", - im->core.res_class != NULL ? im->core.res_class : "*", - im->core.res_class != NULL ? dotXimdot : Ximdot, - "Reconnect"); - bzero(&value, sizeof(XrmValue)); - if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) { - if(_XimCheckBool(value.addr)) { - MARK_RECONNECTABLE(im); - } - } - - if(!IS_CONNECTABLE(im)) { - if (res_name != res_name_buf) Xfree (res_name); - if (res_class != res_class_buf) Xfree (res_class); - return; - } - - (void) sprintf (res_name, "%s%s%s", - im->core.res_name != NULL ? im->core.res_name : "*", - im->core.res_name != NULL ? dotximdot : ximdot, - "preeditDefaultStyle"); - (void) sprintf (res_class, "%s%s%s", - im->core.res_class != NULL ? im->core.res_class : "*", - im->core.res_class != NULL ? dotXimdot : Ximdot, - "PreeditDefaultStyle"); - if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) { - if(!strcmp(value.addr, "XIMPreeditArea")) - preedit_style = XIMPreeditArea; - else if(!strcmp(value.addr, "XIMPreeditCallbacks")) - preedit_style = XIMPreeditCallbacks; - else if(!strcmp(value.addr, "XIMPreeditPosition")) - preedit_style = XIMPreeditPosition; - else if(!strcmp(value.addr, "XIMPreeditNothing")) - preedit_style = XIMPreeditNothing; - else if(!strcmp(value.addr, "XIMPreeditNone")) - preedit_style = XIMPreeditNone; - } - if(!preedit_style) - preedit_style = XIMPreeditNothing; - - (void) sprintf (res_name, "%s%s%s", - im->core.res_name != NULL ? im->core.res_name : "*", - im->core.res_name != NULL ? dotximdot : ximdot, - "statusDefaultStyle"); - (void) sprintf (res_class, "%s%s%s", - im->core.res_class != NULL ? im->core.res_class : "*", - im->core.res_class != NULL ? dotXimdot : Ximdot, - "StatusDefaultStyle"); - if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) { - if(!strcmp(value.addr, "XIMStatusArea")) - status_style = XIMStatusArea; - else if(!strcmp(value.addr, "XIMStatusCallbacks")) - status_style = XIMStatusCallbacks; - else if(!strcmp(value.addr, "XIMStatusNothing")) - status_style = XIMStatusNothing; - else if(!strcmp(value.addr, "XIMStatusNone")) - status_style = XIMStatusNone; - } - if(!status_style) - status_style = XIMStatusNothing; - - if(!(imstyles = (XIMStyles *)Xmalloc(sizeof(XIMStyles) + sizeof(XIMStyle)))){ - if (res_name != res_name_buf) Xfree (res_name); - if (res_class != res_class_buf) Xfree (res_class); - return; - } - imstyles->count_styles = 1; - imstyles->supported_styles = - (XIMStyle *)((char *)imstyles + sizeof(XIMStyles)); - imstyles->supported_styles[0] = preedit_style | status_style; - im->private.proto.default_styles = imstyles; - if (res_name != res_name_buf) Xfree (res_name); - if (res_class != res_class_buf) Xfree (res_class); -} -#endif /* XIM_CONNECTABLE */ - -static const char name_table[] = - /* 0 */ XNQueryInputStyle"\0" - /* 16 */ XNClientWindow"\0" - /* 29 */ XNInputStyle"\0" - /* 40 */ XNFocusWindow"\0" - /* 52 */ XNResourceName"\0" - /* 65 */ XNResourceClass"\0" - /* 79 */ XNGeometryCallback"\0" - /* 96 */ XNDestroyCallback"\0" - /* 112 */ XNFilterEvents"\0" - /* 125 */ XNPreeditStartCallback"\0" - /* 146 */ XNPreeditDoneCallback"\0" - /* 166 */ XNPreeditDrawCallback"\0" - /* 186 */ XNPreeditCaretCallback"\0" - /* 207 */ XNPreeditStateNotifyCallback"\0" - /* 234 */ XNPreeditAttributes"\0" - /* 252 */ XNStatusStartCallback"\0" - /* 272 */ XNStatusDoneCallback"\0" - /* 291 */ XNStatusDrawCallback"\0" - /* 310 */ XNStatusAttributes"\0" - /* 327 */ XNArea"\0" - /* 332 */ XNAreaNeeded"\0" - /* 343 */ XNSpotLocation"\0" - /* 356 */ XNColormap"\0" - /* 365 */ XNStdColormap"\0" - /* 377 */ XNForeground"\0" - /* 388 */ XNBackground"\0" - /* 399 */ XNBackgroundPixmap"\0" - /* 416 */ XNFontSet"\0" - /* 424 */ XNLineSpace"\0" - /* 434 */ XNCursor"\0" - /* 441 */ XNQueryIMValuesList"\0" - /* 459 */ XNQueryICValuesList"\0" - /* 477 */ XNVisiblePosition"\0" - /* 493 */ XNStringConversionCallback"\0" - /* 518 */ XNStringConversion"\0" - /* 535 */ XNResetState"\0" - /* 546 */ XNHotKey"\0" - /* 553 */ XNHotKeyState"\0" - /* 565 */ XNPreeditState -; - -#define OFFSET_XNQUERYINPUTSTYLE 0 -#define OFFSET_XNCLIENTWINDOW 16 -#define OFFSET_XNINPUTSTYLE 29 -#define OFFSET_XNFOCUSWINDOW 40 -#define OFFSET_XNRESOURCENAME 52 -#define OFFSET_XNRESOURCECLASS 65 -#define OFFSET_XNGEOMETRYCALLBACK 79 -#define OFFSET_XNDESTROYCALLBACK 96 -#define OFFSET_XNFILTEREVENTS 112 -#define OFFSET_XNPREEDITSTARTCALLBACK 125 -#define OFFSET_XNPREEDITDONECALLBACK 146 -#define OFFSET_XNPREEDITDRAWCALLBACK 166 -#define OFFSET_XNPREEDITCARETCALLBACK 186 -#define OFFSET_XNPREEDITSTATENOTIFYCALLBACK 207 -#define OFFSET_XNPREEDITATTRIBUTES 234 -#define OFFSET_XNSTATUSSTARTCALLBACK 252 -#define OFFSET_XNSTATUSDONECALLBACK 272 -#define OFFSET_XNSTATUSDRAWCALLBACK 291 -#define OFFSET_XNSTATUSATTRIBUTES 310 -#define OFFSET_XNAREA 327 -#define OFFSET_XNAREANEEDED 332 -#define OFFSET_XNSPOTLOCATION 343 -#define OFFSET_XNCOLORMAP 356 -#define OFFSET_XNSTDCOLORMAP 365 -#define OFFSET_XNFOREGROUND 377 -#define OFFSET_XNBACKGROUND 388 -#define OFFSET_XNBACKGROUNDPIXMAP 399 -#define OFFSET_XNFONTSET 416 -#define OFFSET_XNLINESPACE 424 -#define OFFSET_XNCURSOR 434 -#define OFFSET_XNQUERYIMVALUESLIST 441 -#define OFFSET_XNQUERYICVALUESLIST 459 -#define OFFSET_XNVISIBLEPOSITION 477 -#define OFFSET_XNSTRINGCONVERSIONCALLBACK 493 -#define OFFSET_XNSTRINGCONVERSION 518 -#define OFFSET_XNRESETSTATE 535 -#define OFFSET_XNHOTKEY 546 -#define OFFSET_XNHOTKEYSTATE 553 -#define OFFSET_XNPREEDITSTATE 565 - -/* offsets into name_table */ -static const unsigned short supported_local_im_values_list[] = { - OFFSET_XNQUERYINPUTSTYLE, - OFFSET_XNRESOURCENAME, - OFFSET_XNRESOURCECLASS, - OFFSET_XNDESTROYCALLBACK, - OFFSET_XNQUERYIMVALUESLIST, - OFFSET_XNQUERYICVALUESLIST, - OFFSET_XNVISIBLEPOSITION -}; - -/* offsets into name_table */ -static const unsigned short supported_local_ic_values_list[] = { - OFFSET_XNINPUTSTYLE, - OFFSET_XNCLIENTWINDOW, - OFFSET_XNFOCUSWINDOW, - OFFSET_XNRESOURCENAME, - OFFSET_XNRESOURCECLASS, - OFFSET_XNGEOMETRYCALLBACK, - OFFSET_XNFILTEREVENTS, - OFFSET_XNDESTROYCALLBACK, - OFFSET_XNSTRINGCONVERSIONCALLBACK, - OFFSET_XNSTRINGCONVERSIONCALLBACK, - OFFSET_XNRESETSTATE, - OFFSET_XNHOTKEY, - OFFSET_XNHOTKEYSTATE, - OFFSET_XNPREEDITATTRIBUTES, - OFFSET_XNSTATUSATTRIBUTES, - OFFSET_XNAREA, - OFFSET_XNAREANEEDED, - OFFSET_XNSPOTLOCATION, - OFFSET_XNCOLORMAP, - OFFSET_XNSTDCOLORMAP, - OFFSET_XNFOREGROUND, - OFFSET_XNBACKGROUND, - OFFSET_XNBACKGROUNDPIXMAP, - OFFSET_XNFONTSET, - OFFSET_XNLINESPACE, - OFFSET_XNCURSOR, - OFFSET_XNPREEDITSTARTCALLBACK, - OFFSET_XNPREEDITDONECALLBACK, - OFFSET_XNPREEDITDRAWCALLBACK, - OFFSET_XNPREEDITCARETCALLBACK, - OFFSET_XNSTATUSSTARTCALLBACK, - OFFSET_XNSTATUSDONECALLBACK, - OFFSET_XNSTATUSDRAWCALLBACK, - OFFSET_XNPREEDITSTATE, - OFFSET_XNPREEDITSTATENOTIFYCALLBACK -}; - -static XIMStyle const supported_local_styles[] = { - XIMPreeditNone | XIMStatusNone, - XIMPreeditNothing | XIMStatusNothing, - 0 /* dummy */ -}; - -Private Bool -_XimDefaultStyles( - XimValueOffsetInfo info, - XPointer top, - XPointer parm, /* unused */ - unsigned long mode) /* unused */ -{ - XIMStyles *styles; - XIMStyles **out; - register int i; - unsigned int n; - int len; - XPointer tmp; - - n = XIMNumber(supported_local_styles) - 1; - len = sizeof(XIMStyles) + sizeof(XIMStyle) * n; - if(!(tmp = (XPointer)Xmalloc(len))) { - return False; - } - bzero(tmp, len); - - styles = (XIMStyles *)tmp; - if (n > 0) { - styles->count_styles = (unsigned short)n; - styles->supported_styles = - (XIMStyle *)((char *)tmp + sizeof(XIMStyles)); - for(i = 0; i < n; i++) { - styles->supported_styles[i] = supported_local_styles[i]; - } - } - - out = (XIMStyles **)((char *)top + info->offset); - *out = styles; - return True; -} - -Private Bool -_XimDefaultIMValues( - XimValueOffsetInfo info, - XPointer top, - XPointer parm, /* unused */ - unsigned long mode) /* unused */ -{ - XIMValuesList *values_list; - XIMValuesList **out; - register int i; - unsigned int n; - int len; - XPointer tmp; - - n = XIMNumber(supported_local_im_values_list); - len = sizeof(XIMValuesList) + sizeof(char **) * n; - if(!(tmp = (XPointer)Xmalloc(len))) { - return False; - } - bzero(tmp, len); - - values_list = (XIMValuesList *)tmp; - if (n > 0) { - values_list->count_values = (unsigned short)n; - values_list->supported_values - = (char **)((char *)tmp + sizeof(XIMValuesList)); - for(i = 0; i < n; i++) { - values_list->supported_values[i] = - (char *)name_table + supported_local_im_values_list[i]; - } - } - - out = (XIMValuesList **)((char *)top + info->offset); - *out = values_list; - return True; -} - -Private Bool -_XimDefaultICValues( - XimValueOffsetInfo info, - XPointer top, - XPointer parm, /* unused */ - unsigned long mode) /* unused */ -{ - XIMValuesList *values_list; - XIMValuesList **out; - register int i; - unsigned int n; - int len; - XPointer tmp; - - n = XIMNumber(supported_local_ic_values_list); - len = sizeof(XIMValuesList) + sizeof(char **) * n; - if(!(tmp = (XPointer)Xmalloc(len))) { - return False; - } - bzero(tmp, len); - - values_list = (XIMValuesList *)tmp; - if (n > 0) { - values_list->count_values = (unsigned short)n; - values_list->supported_values - = (char **)((char *)tmp + sizeof(XIMValuesList)); - for(i = 0; i < n; i++) { - values_list->supported_values[i] = - (char *)name_table + supported_local_ic_values_list[i]; - } - } - - out = (XIMValuesList **)((char *)top + info->offset); - *out = values_list; - return True; -} - -Private Bool -_XimDefaultVisiblePos( - XimValueOffsetInfo info, - XPointer top, - XPointer parm, /* unused */ - unsigned long mode) /* unused */ -{ - Bool *out; - - out = (Bool *)((char *)top + info->offset); - *out = False; - return True; -} - -Private Bool -_XimDefaultFocusWindow( - XimValueOffsetInfo info, - XPointer top, - XPointer parm, - unsigned long mode) -{ - Xic ic = (Xic)parm; - Window *out; - - if(ic->core.client_window == (Window)NULL) { - return True; - } - - out = (Window *)((char *)top + info->offset); - *out = ic->core.client_window; - return True; -} - -Private Bool -_XimDefaultResName( - XimValueOffsetInfo info, - XPointer top, - XPointer parm, - unsigned long mode) -{ - Xic ic = (Xic)parm; - Xim im = (Xim)ic->core.im; - char **out; - - if(im->core.res_name == (char *)NULL) { - return True; - } - - out = (char **)((char *)top + info->offset); - *out = im->core.res_name; - return True; -} - -Private Bool -_XimDefaultResClass( - XimValueOffsetInfo info, - XPointer top, - XPointer parm, - unsigned long mode) -{ - Xic ic = (Xic)parm; - Xim im = (Xim)ic->core.im; - char **out; - - if(im->core.res_class == (char *)NULL) { - return True; - } - - out = (char **)((char *)top + info->offset); - *out = im->core.res_class; - return True; -} - -Private Bool -_XimDefaultDestroyCB( - XimValueOffsetInfo info, - XPointer top, - XPointer parm, - unsigned long mode) -{ - Xic ic = (Xic)parm; - Xim im = (Xim)ic->core.im; - XIMCallback *out; - - out = (XIMCallback *)((char *)top + info->offset); - *out = im->core.destroy_callback; - return True; -} - -Private Bool -_XimDefaultResetState( - XimValueOffsetInfo info, - XPointer top, - XPointer parm, - unsigned long mode) -{ - XIMResetState *out; - - out = (XIMResetState *)((char *)top + info->offset); - *out = XIMInitialState; - return True; -} - -Private Bool -_XimDefaultHotKeyState( - XimValueOffsetInfo info, - XPointer top, - XPointer parm, - unsigned long mode) -{ - XIMHotKeyState *out; - - out = (XIMHotKeyState *)((char *)top + info->offset); - *out = XIMHotKeyStateOFF; - return True; -} - -Private Bool -_XimDefaultArea( - XimValueOffsetInfo info, - XPointer top, - XPointer parm, - unsigned long mode) -{ - Xic ic = (Xic)parm; - Xim im = (Xim)ic->core.im; - Window root_return; - int x_return, y_return; - unsigned int width_return, height_return; - unsigned int border_width_return; - unsigned int depth_return; - XRectangle area; - XRectangle *out; - - if(ic->core.focus_window == (Window)NULL) { - return True; - } - if(XGetGeometry(im->core.display, (Drawable)ic->core.focus_window, - &root_return, &x_return, &y_return, &width_return, - &height_return, &border_width_return, &depth_return) - == (Status)NULL) { - return True; - } - area.x = 0; - area.y = 0; - area.width = width_return; - area.height = height_return; - - out = (XRectangle *)((char *)top + info->offset); - *out = area; - return True; -} - -Private Bool -_XimDefaultColormap( - XimValueOffsetInfo info, - XPointer top, - XPointer parm, - unsigned long mode) -{ - Xic ic = (Xic)parm; - Xim im = (Xim)ic->core.im; - XWindowAttributes win_attr; - Colormap *out; - - if(ic->core.client_window == (Window)NULL) { - return True; - } - if(XGetWindowAttributes(im->core.display, ic->core.client_window, - &win_attr) == (Status)NULL) { - return True; - } - - out = (Colormap *)((char *)top + info->offset); - *out = win_attr.colormap; - return True; -} - -Private Bool -_XimDefaultStdColormap( - XimValueOffsetInfo info, - XPointer top, - XPointer parm, - unsigned long mode) -{ - Atom *out; - - out = (Atom *)((char *)top + info->offset); - *out = (Atom)0; - return True; -} - -Private Bool -_XimDefaultFg( - XimValueOffsetInfo info, - XPointer top, - XPointer parm, - unsigned long mode) -{ - Xic ic = (Xic)parm; - Xim im = (Xim)ic->core.im; - unsigned long fg; - unsigned long *out; - - fg = WhitePixel(im->core.display, DefaultScreen(im->core.display)); - out = (unsigned long *)((char *)top + info->offset); - *out = fg; - return True; -} - -Private Bool -_XimDefaultBg( - XimValueOffsetInfo info, - XPointer top, - XPointer parm, - unsigned long mode) -{ - Xic ic = (Xic)parm; - Xim im = (Xim)ic->core.im; - unsigned long bg; - unsigned long *out; - - bg = BlackPixel(im->core.display, DefaultScreen(im->core.display)); - out = (unsigned long *)((char *)top + info->offset); - *out = bg; - return True; -} - -Private Bool -_XimDefaultBgPixmap( - XimValueOffsetInfo info, - XPointer top, - XPointer parm, - unsigned long mode) -{ - Pixmap *out; - - out = (Pixmap *)((char *)top + info->offset); - *out = (Pixmap)0; - return True; -} - -Private Bool -_XimDefaultFontSet( - XimValueOffsetInfo info, - XPointer top, - XPointer parm, - unsigned long mode) -{ - XFontSet *out; - - out = (XFontSet *)((char *)top + info->offset); - *out = 0; - return True; -} - -Private Bool -_XimDefaultLineSpace( - XimValueOffsetInfo info, - XPointer top, - XPointer parm, - unsigned long mode) -{ - Xic ic = (Xic)parm; - XFontSet fontset; - XFontSetExtents *fset_extents; - int line_space = 0; - int *out; - - if(mode & XIM_PREEDIT_ATTR) { - fontset = ic->core.preedit_attr.fontset; - } else if(mode & XIM_STATUS_ATTR) { - fontset = ic->core.status_attr.fontset; - } else { - return True; - } - if (fontset) { - fset_extents = XExtentsOfFontSet(fontset); - line_space = fset_extents->max_logical_extent.height; - } - out = (int *)((char *)top + info->offset); - *out = line_space; - return True; -} - -Private Bool -_XimDefaultCursor( - XimValueOffsetInfo info, - XPointer top, - XPointer parm, - unsigned long mode) -{ - Cursor *out; - - out = (Cursor *)((char *)top + info->offset); - *out = (Cursor)0; - return True; -} - -Private Bool -_XimDefaultPreeditState( - XimValueOffsetInfo info, - XPointer top, - XPointer parm, - unsigned long mode) -{ - XIMPreeditState *out; - - out = (XIMPreeditState *)((char *)top + info->offset); - *out = XIMPreeditDisable; - return True; -} - -Private Bool -_XimDefaultNest( - XimValueOffsetInfo info, - XPointer top, - XPointer parm, - unsigned long mode) -{ - return True; -} - -Private Bool -_XimEncodeCallback( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - XIMCallback *out; - - out = (XIMCallback *)((char *)top + info->offset); - *out = *((XIMCallback *)val); - return True; -} - -Private Bool -_XimEncodeString( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - int len; - char *string; - char **out; - - if(val == (XPointer)NULL) { - return False; - } - len = strlen((char *)val); - if(!(string = (char *)Xmalloc(len + 1))) { - return False; - } - (void)strcpy(string, (char *)val); - string[len] = '\0'; - - out = (char **)((char *)top + info->offset); - if(*out) { - Xfree(*out); - } - *out = string; - return True; -} - -Private Bool -_XimEncodeStyle( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - XIMStyle *out; - - out = (XIMStyle *)((char *)top + info->offset); - *out = (XIMStyle)val; - return True; -} - -Private Bool -_XimEncodeWindow( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - Window *out; - - out = (Window *)((char *)top + info->offset); - *out = (Window)val; - return True; -} - -Private Bool -_XimEncodeStringConv( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - /* - * Not yet - */ - return True; -} - -Private Bool -_XimEncodeResetState( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - XIMResetState *out; - - out = (XIMResetState *)((char *)top + info->offset); - *out = (XIMResetState)val; - return True; -} - -Private Bool -_XimEncodeHotKey( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - XIMHotKeyTriggers *hotkey = (XIMHotKeyTriggers *)val; - XIMHotKeyTriggers **out; - XIMHotKeyTriggers *key_list; - XIMHotKeyTrigger *key; - XPointer tmp; - int num; - int len; - register int i; - - if(hotkey == (XIMHotKeyTriggers *)NULL) { - return True; - } - - if((num = hotkey->num_hot_key) == 0) { - return True; - } - - len = sizeof(XIMHotKeyTriggers) + sizeof(XIMHotKeyTrigger) * num; - if(!(tmp = (XPointer)Xmalloc(len))) { - return False; - } - - key_list = (XIMHotKeyTriggers *)tmp; - key = (XIMHotKeyTrigger *)((char *)tmp + sizeof(XIMHotKeyTriggers)); - - for(i = 0; i < num; i++) { - key[i] = hotkey->key[i]; - } - - key_list->num_hot_key = num; - key_list->key = key; - - out = (XIMHotKeyTriggers **)((char *)top + info->offset); - *out = key_list; - return True; -} - -Private Bool -_XimEncodeHotKetState( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - XIMHotKeyState *out; - - out = (XIMHotKeyState *)((char *)top + info->offset); - *out = (XIMHotKeyState)val; - return True; -} - -Private Bool -_XimEncodeRectangle( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - XRectangle *out; - - out = (XRectangle *)((char *)top + info->offset); - *out = *((XRectangle *)val); - return True; -} - -Private Bool -_XimEncodeSpot( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - XPoint *out; - - out = (XPoint *)((char *)top + info->offset); - *out = *((XPoint *)val); - return True; -} - -Private Bool -_XimEncodeColormap( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - Colormap *out; - - out = (Colormap *)((char *)top + info->offset); - *out = (Colormap)val; - return True; -} - -Private Bool -_XimEncodeStdColormap( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - Atom *out; - - out = (Atom *)((char *)top + info->offset); - *out = (Atom)val; - return True; -} - -Private Bool -_XimEncodeLong( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - unsigned long *out; - - out = (unsigned long *)((char *)top + info->offset); - *out = (unsigned long)val; - return True; -} - -Private Bool -_XimEncodeBgPixmap( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - Pixmap *out; - - out = (Pixmap *)((char *)top + info->offset); - *out = (Pixmap)val; - return True; -} - -Private Bool -_XimEncodeFontSet( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - XFontSet *out; - - out = (XFontSet *)((char *)top + info->offset); - *out = (XFontSet)val; - return True; -} - -Private Bool -_XimEncodeLineSpace( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - int *out; - - out = (int *)((char *)top + info->offset); - *out = (long)val; - return True; -} - -Private Bool -_XimEncodeCursor( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - Cursor *out; - - out = (Cursor *)((char *)top + info->offset); - *out = (Cursor)val; - return True; -} - -Private Bool -_XimEncodePreeditState( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - XIMPreeditState *out; - - out = (XIMPreeditState *)((char *)top + info->offset); - *out = (XIMPreeditState)val; - return True; -} - -Private Bool -_XimEncodeNest( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - return True; -} - -Private Bool -_XimDecodeStyles( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - XIMStyles *styles; - XIMStyles *out; - register int i; - unsigned int num; - int len; - XPointer tmp; - - if(val == (XPointer)NULL) { - return False; - } - - styles = *((XIMStyles **)((char *)top + info->offset)); - num = styles->count_styles; - - len = sizeof(XIMStyles) + sizeof(XIMStyle) * num; - if(!(tmp = (XPointer)Xmalloc(len))) { - return False; - } - bzero(tmp, len); - - out = (XIMStyles *)tmp; - if(num >0) { - out->count_styles = (unsigned short)num; - out->supported_styles = (XIMStyle *)((char *)tmp + sizeof(XIMStyles)); - - for(i = 0; i < num; i++) { - out->supported_styles[i] = styles->supported_styles[i]; - } - } - *((XIMStyles **)val) = out; - return True; -} - -Private Bool -_XimDecodeValues( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - XIMValuesList *values_list; - XIMValuesList *out; - register int i; - unsigned int num; - int len; - XPointer tmp; - - if(val == (XPointer)NULL) { - return False; - } - - values_list = *((XIMValuesList **)((char *)top + info->offset)); - num = values_list->count_values; - - len = sizeof(XIMValuesList) + sizeof(char **) * num; - if(!(tmp = (char *)Xmalloc(len))) { - return False; - } - bzero(tmp, len); - - out = (XIMValuesList *)tmp; - if(num) { - out->count_values = (unsigned short)num; - out->supported_values = (char **)((char *)tmp + sizeof(XIMValuesList)); - - for(i = 0; i < num; i++) { - out->supported_values[i] = values_list->supported_values[i]; - } - } - *((XIMValuesList **)val) = out; - return True; -} - -Private Bool -_XimDecodeCallback( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - XIMCallback *in; - XIMCallback *callback; - - in = (XIMCallback *)((char *)top + info->offset); - if(!(callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback)))) { - return False; - } - callback->client_data = in->client_data; - callback->callback = in->callback; - - *((XIMCallback **)val) = callback; - return True; -} - -Private Bool -_XimDecodeString( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - int len = 0; - char *in; - char *string; - - in = *((char **)((char *)top + info->offset)); - if(in != (char *)NULL) { - len = strlen(in); - } - if(!(string = (char *)Xmalloc(len + 1))) { - return False; - } - if(in != (char *)NULL) { - (void)strcpy(string, in); - } - string[len] = '\0'; - *((char **)val) = string; - return True; -} - -Private Bool -_XimDecodeBool( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - Bool *in; - - in = (Bool *)((char *)top + info->offset); - *((Bool *)val) = *in; - return True; -} - -Private Bool -_XimDecodeStyle( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - XIMStyle *in; - - in = (XIMStyle *)((char *)top + info->offset); - *((XIMStyle *)val) = *in; - return True; -} - -Private Bool -_XimDecodeWindow( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - Window *in; - - in = (Window *)((char *)top + info->offset); - *((Window *)val) = *in; - return True; -} - -Private Bool -_XimDecodeStringConv( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - /* - * Not yet - */ - return True; -} - -Private Bool -_XimDecodeResetState( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - XIMResetState *in; - - in = (XIMResetState *)((char *)top + info->offset); - *((XIMResetState *)val) = *in; - return True; -} - -Private Bool -_XimDecodeHotKey( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - XIMHotKeyTriggers *in; - XIMHotKeyTriggers *hotkey; - XIMHotKeyTrigger *key; - XPointer tmp; - int num; - int len; - register int i; - - in = *((XIMHotKeyTriggers **)((char *)top + info->offset)); - num = in->num_hot_key; - len = sizeof(XIMHotKeyTriggers) + sizeof(XIMHotKeyTrigger) * num; - if(!(tmp = (XPointer)Xmalloc(len))) { - return False; - } - - hotkey = (XIMHotKeyTriggers *)tmp; - key = (XIMHotKeyTrigger *)((char *)tmp + sizeof(XIMHotKeyTriggers)); - - for(i = 0; i < num; i++) { - key[i] = in->key[i]; - } - hotkey->num_hot_key = num; - hotkey->key = key; - - *((XIMHotKeyTriggers **)val) = hotkey; - return True; -} - -Private Bool -_XimDecodeHotKetState( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - XIMHotKeyState *in; - - in = (XIMHotKeyState *)((char *)top + info->offset); - *((XIMHotKeyState *)val) = *in; - return True; -} - -Private Bool -_XimDecodeRectangle( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - XRectangle *in; - XRectangle *rect; - - in = (XRectangle *)((char *)top + info->offset); - if(!(rect = (XRectangle *)Xmalloc(sizeof(XRectangle)))) { - return False; - } - *rect = *in; - *((XRectangle **)val) = rect; - return True; -} - -Private Bool -_XimDecodeSpot( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - XPoint *in; - XPoint *spot; - - in = (XPoint *)((char *)top + info->offset); - if(!(spot = (XPoint *)Xmalloc(sizeof(XPoint)))) { - return False; - } - *spot = *in; - *((XPoint **)val) = spot; - return True; -} - -Private Bool -_XimDecodeColormap( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - Colormap *in; - - in = (Colormap *)((char *)top + info->offset); - *((Colormap *)val) = *in; - return True; -} - -Private Bool -_XimDecodeStdColormap( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - Atom *in; - - in = (Atom *)((char *)top + info->offset); - *((Atom *)val) = *in; - return True; -} - -Private Bool -_XimDecodeLong( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - unsigned long *in; - - in = (unsigned long *)((char *)top + info->offset); - *((unsigned long *)val) = *in; - return True; -} - -Private Bool -_XimDecodeBgPixmap( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - Pixmap *in; - - in = (Pixmap *)((char *)top + info->offset); - *((Pixmap *)val) = *in; - return True; -} - -Private Bool -_XimDecodeFontSet( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - XFontSet *in; - - in = (XFontSet *)((char *)top + info->offset); - *((XFontSet *)val) = *in; - return True; -} - -Private Bool -_XimDecodeLineSpace( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - int *in; - - in = (int *)((char *)top + info->offset); - *((int *)val) = *in; - return True; -} - -Private Bool -_XimDecodeCursor( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - Cursor *in; - - in = (Cursor *)((char *)top + info->offset); - *((Cursor *)val) = *in; - return True; -} - -Private Bool -_XimDecodePreeditState( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - XIMPreeditState *in; - - in = (XIMPreeditState *)((char *)top + info->offset); - *((XIMPreeditState *)val) = *in; - return True; -} - -Private Bool -_XimDecodeNest( - XimValueOffsetInfo info, - XPointer top, - XPointer val) -{ - return True; -} - -static XIMResource im_resources[] = { - {XNQueryInputStyle, 0, XimType_XIMStyles, 0, 0, 0}, - {XNDestroyCallback, 0, 0, 0, 0, 0}, - {XNResourceName, 0, XimType_STRING8, 0, 0, 0}, - {XNResourceClass, 0, XimType_STRING8, 0, 0, 0}, - {XNQueryIMValuesList, 0, 0, 0, 0, 0}, - {XNQueryICValuesList, 0, 0, 0, 0, 0}, - {XNVisiblePosition, 0, 0, 0, 0, 0} -}; - -static XIMResource im_inner_resources[] = { - {XNDestroyCallback, 0, 0, 0, 0, 0}, - {XNResourceName, 0, XimType_STRING8, 0, 0, 0}, - {XNResourceClass, 0, XimType_STRING8, 0, 0, 0}, - {XNQueryIMValuesList, 0, 0, 0, 0, 0}, - {XNQueryICValuesList, 0, 0, 0, 0, 0}, - {XNVisiblePosition, 0, 0, 0, 0, 0} -}; - -static XIMResource ic_resources[] = { - {XNInputStyle, 0, XimType_CARD32, 0, 0, 0}, - {XNClientWindow, 0, XimType_Window, 0, 0, 0}, - {XNFocusWindow, 0, XimType_Window, 0, 0, 0}, - {XNResourceName, 0, XimType_STRING8, 0, 0, 0}, - {XNResourceClass, 0, XimType_STRING8, 0, 0, 0}, - {XNGeometryCallback, 0, 0, 0, 0, 0}, - {XNFilterEvents, 0, XimType_CARD32, 0, 0, 0}, - {XNDestroyCallback, 0, 0, 0, 0, 0}, - {XNStringConversionCallback, 0, 0, 0, 0, 0}, - {XNStringConversion, 0, XimType_XIMStringConversion,0, 0, 0}, - {XNResetState, 0, 0, 0, 0, 0}, - {XNHotKey, 0, XimType_XIMHotKeyTriggers,0, 0, 0}, - {XNHotKeyState, 0, XimType_XIMHotKeyState, 0, 0, 0}, - {XNPreeditAttributes, 0, XimType_NEST, 0, 0, 0}, - {XNStatusAttributes, 0, XimType_NEST, 0, 0, 0}, - {XNArea, 0, XimType_XRectangle, 0, 0, 0}, - {XNAreaNeeded, 0, XimType_XRectangle, 0, 0, 0}, - {XNSpotLocation, 0, XimType_XPoint, 0, 0, 0}, - {XNColormap, 0, XimType_CARD32, 0, 0, 0}, - {XNStdColormap, 0, XimType_CARD32, 0, 0, 0}, - {XNForeground, 0, XimType_CARD32, 0, 0, 0}, - {XNBackground, 0, XimType_CARD32, 0, 0, 0}, - {XNBackgroundPixmap, 0, XimType_CARD32, 0, 0, 0}, - {XNFontSet, 0, XimType_XFontSet, 0, 0, 0}, - {XNLineSpace, 0, XimType_CARD32, 0, 0, 0}, - {XNCursor, 0, XimType_CARD32, 0, 0, 0}, - {XNPreeditStartCallback, 0, 0, 0, 0, 0}, - {XNPreeditDoneCallback, 0, 0, 0, 0, 0}, - {XNPreeditDrawCallback, 0, 0, 0, 0, 0}, - {XNPreeditCaretCallback, 0, 0, 0, 0, 0}, - {XNStatusStartCallback, 0, 0, 0, 0, 0}, - {XNStatusDoneCallback, 0, 0, 0, 0, 0}, - {XNStatusDrawCallback, 0, 0, 0, 0, 0}, - {XNPreeditState, 0, 0, 0, 0, 0}, - {XNPreeditStateNotifyCallback, 0, 0, 0, 0, 0}, -}; - -static XIMResource ic_inner_resources[] = { - {XNResourceName, 0, XimType_STRING8, 0, 0, 0}, - {XNResourceClass, 0, XimType_STRING8, 0, 0, 0}, - {XNGeometryCallback, 0, 0, 0, 0, 0}, - {XNDestroyCallback, 0, 0, 0, 0, 0}, - {XNStringConversionCallback, 0, 0, 0, 0, 0}, - {XNPreeditStartCallback, 0, 0, 0, 0, 0}, - {XNPreeditDoneCallback, 0, 0, 0, 0, 0}, - {XNPreeditDrawCallback, 0, 0, 0, 0, 0}, - {XNPreeditCaretCallback, 0, 0, 0, 0, 0}, - {XNStatusStartCallback, 0, 0, 0, 0, 0}, - {XNStatusDoneCallback, 0, 0, 0, 0, 0}, - {XNStatusDrawCallback, 0, 0, 0, 0, 0}, - {XNPreeditStateNotifyCallback, 0, 0, 0, 0, 0}, -}; - -static XimValueOffsetInfoRec im_attr_info[] = { - {OFFSET_XNQUERYINPUTSTYLE, 0, - XOffsetOf(XimDefIMValues, styles), - _XimDefaultStyles, NULL, _XimDecodeStyles}, - - {OFFSET_XNDESTROYCALLBACK, 0, - XOffsetOf(XimDefIMValues, destroy_callback), - NULL, _XimEncodeCallback, _XimDecodeCallback}, - - {OFFSET_XNRESOURCENAME, 0, - XOffsetOf(XimDefIMValues, res_name), - NULL, _XimEncodeString, _XimDecodeString}, - - {OFFSET_XNRESOURCECLASS, 0, - XOffsetOf(XimDefIMValues, res_class), - NULL, _XimEncodeString, _XimDecodeString}, - - {OFFSET_XNQUERYIMVALUESLIST, 0, - XOffsetOf(XimDefIMValues, im_values_list), - _XimDefaultIMValues, NULL, _XimDecodeValues}, - - {OFFSET_XNQUERYICVALUESLIST, 0, - XOffsetOf(XimDefIMValues, ic_values_list), - _XimDefaultICValues, NULL, _XimDecodeValues}, - - {OFFSET_XNVISIBLEPOSITION, 0, - XOffsetOf(XimDefIMValues, visible_position), - _XimDefaultVisiblePos, NULL, _XimDecodeBool} -}; - -static XimValueOffsetInfoRec ic_attr_info[] = { - {OFFSET_XNINPUTSTYLE, 0, - XOffsetOf(XimDefICValues, input_style), - NULL, _XimEncodeStyle, _XimDecodeStyle}, - - {OFFSET_XNCLIENTWINDOW, 0, - XOffsetOf(XimDefICValues, client_window), - NULL, _XimEncodeWindow, _XimDecodeWindow}, - - {OFFSET_XNFOCUSWINDOW, 0, - XOffsetOf(XimDefICValues, focus_window), - _XimDefaultFocusWindow, _XimEncodeWindow, _XimDecodeWindow}, - - {OFFSET_XNRESOURCENAME, 0, - XOffsetOf(XimDefICValues, res_name), - _XimDefaultResName, _XimEncodeString, _XimDecodeString}, - - {OFFSET_XNRESOURCECLASS, 0, - XOffsetOf(XimDefICValues, res_class), - _XimDefaultResClass, _XimEncodeString, _XimDecodeString}, - - {OFFSET_XNGEOMETRYCALLBACK, 0, - XOffsetOf(XimDefICValues, geometry_callback), - NULL, _XimEncodeCallback, _XimDecodeCallback}, - - {OFFSET_XNFILTEREVENTS, 0, - XOffsetOf(XimDefICValues, filter_events), - NULL, NULL, _XimDecodeLong}, - - {OFFSET_XNDESTROYCALLBACK, 0, - XOffsetOf(XimDefICValues, destroy_callback), - _XimDefaultDestroyCB, _XimEncodeCallback, _XimDecodeCallback}, - - {OFFSET_XNSTRINGCONVERSIONCALLBACK, 0, - XOffsetOf(XimDefICValues, string_conversion_callback), - NULL, _XimEncodeCallback, _XimDecodeCallback}, - - {OFFSET_XNSTRINGCONVERSION, 0, - XOffsetOf(XimDefICValues, string_conversion), - NULL, _XimEncodeStringConv, _XimDecodeStringConv}, - - {OFFSET_XNRESETSTATE, 0, - XOffsetOf(XimDefICValues, reset_state), - _XimDefaultResetState, _XimEncodeResetState, _XimDecodeResetState}, - - {OFFSET_XNHOTKEY, 0, - XOffsetOf(XimDefICValues, hotkey), - NULL, _XimEncodeHotKey, _XimDecodeHotKey}, - - {OFFSET_XNHOTKEYSTATE, 0, - XOffsetOf(XimDefICValues, hotkey_state), - _XimDefaultHotKeyState, _XimEncodeHotKetState, _XimDecodeHotKetState}, - - {OFFSET_XNPREEDITATTRIBUTES, 0, - XOffsetOf(XimDefICValues, preedit_attr), - _XimDefaultNest, _XimEncodeNest, _XimDecodeNest}, - - {OFFSET_XNSTATUSATTRIBUTES, 0, - XOffsetOf(XimDefICValues, status_attr), - _XimDefaultNest, _XimEncodeNest, _XimDecodeNest}, -}; - -static XimValueOffsetInfoRec ic_pre_attr_info[] = { - {OFFSET_XNAREA, 0, - XOffsetOf(ICPreeditAttributes, area), - _XimDefaultArea, _XimEncodeRectangle, _XimDecodeRectangle}, - - {OFFSET_XNAREANEEDED, 0, - XOffsetOf(ICPreeditAttributes, area_needed), - NULL, _XimEncodeRectangle, _XimDecodeRectangle}, - - {OFFSET_XNSPOTLOCATION, 0, - XOffsetOf(ICPreeditAttributes, spot_location), - NULL, _XimEncodeSpot, _XimDecodeSpot}, - - {OFFSET_XNCOLORMAP, 0, - XOffsetOf(ICPreeditAttributes, colormap), - _XimDefaultColormap, _XimEncodeColormap, _XimDecodeColormap}, - - {OFFSET_XNSTDCOLORMAP, 0, - XOffsetOf(ICPreeditAttributes, std_colormap), - _XimDefaultStdColormap, _XimEncodeStdColormap, _XimDecodeStdColormap}, - - {OFFSET_XNFOREGROUND, 0, - XOffsetOf(ICPreeditAttributes, foreground), - _XimDefaultFg, _XimEncodeLong, _XimDecodeLong}, - - {OFFSET_XNBACKGROUND, 0, - XOffsetOf(ICPreeditAttributes, background), - _XimDefaultBg, _XimEncodeLong, _XimDecodeLong}, - - {OFFSET_XNBACKGROUNDPIXMAP, 0, - XOffsetOf(ICPreeditAttributes, background_pixmap), - _XimDefaultBgPixmap, _XimEncodeBgPixmap, _XimDecodeBgPixmap}, - - {OFFSET_XNFONTSET, 0, - XOffsetOf(ICPreeditAttributes, fontset), - _XimDefaultFontSet, _XimEncodeFontSet, _XimDecodeFontSet}, - - {OFFSET_XNLINESPACE, 0, - XOffsetOf(ICPreeditAttributes, line_spacing), - _XimDefaultLineSpace, _XimEncodeLineSpace, _XimDecodeLineSpace}, - - {OFFSET_XNCURSOR, 0, - XOffsetOf(ICPreeditAttributes, cursor), - _XimDefaultCursor, _XimEncodeCursor, _XimDecodeCursor}, - - {OFFSET_XNPREEDITSTARTCALLBACK, 0, - XOffsetOf(ICPreeditAttributes, start_callback), - NULL, _XimEncodeCallback, _XimDecodeCallback}, - - {OFFSET_XNPREEDITDONECALLBACK, 0, - XOffsetOf(ICPreeditAttributes, done_callback), - NULL, _XimEncodeCallback, _XimDecodeCallback}, - - {OFFSET_XNPREEDITDRAWCALLBACK, 0, - XOffsetOf(ICPreeditAttributes, draw_callback), - NULL, _XimEncodeCallback, _XimDecodeCallback}, - - {OFFSET_XNPREEDITCARETCALLBACK, 0, - XOffsetOf(ICPreeditAttributes, caret_callback), - NULL, _XimEncodeCallback, _XimDecodeCallback}, - - {OFFSET_XNPREEDITSTATE, 0, - XOffsetOf(ICPreeditAttributes, preedit_state), - _XimDefaultPreeditState, _XimEncodePreeditState,_XimDecodePreeditState}, - - {OFFSET_XNPREEDITSTATENOTIFYCALLBACK, 0, - XOffsetOf(ICPreeditAttributes, state_notify_callback), - NULL, _XimEncodeCallback, _XimDecodeCallback}, -}; - -static XimValueOffsetInfoRec ic_sts_attr_info[] = { - {OFFSET_XNAREA, 0, - XOffsetOf(ICStatusAttributes, area), - _XimDefaultArea, _XimEncodeRectangle, _XimDecodeRectangle}, - - {OFFSET_XNAREANEEDED, 0, - XOffsetOf(ICStatusAttributes, area_needed), - NULL, _XimEncodeRectangle, _XimDecodeRectangle}, - - {OFFSET_XNCOLORMAP, 0, - XOffsetOf(ICStatusAttributes, colormap), - _XimDefaultColormap, _XimEncodeColormap, _XimDecodeColormap}, - - {OFFSET_XNSTDCOLORMAP, 0, - XOffsetOf(ICStatusAttributes, std_colormap), - _XimDefaultStdColormap, _XimEncodeStdColormap, _XimDecodeStdColormap}, - - {OFFSET_XNFOREGROUND, 0, - XOffsetOf(ICStatusAttributes, foreground), - _XimDefaultFg, _XimEncodeLong, _XimDecodeLong}, - - {OFFSET_XNBACKGROUND, 0, - XOffsetOf(ICStatusAttributes, background), - _XimDefaultBg, _XimEncodeLong, _XimDecodeLong}, - - {OFFSET_XNBACKGROUNDPIXMAP, 0, - XOffsetOf(ICStatusAttributes, background_pixmap), - _XimDefaultBgPixmap, _XimEncodeBgPixmap, _XimDecodeBgPixmap}, - - {OFFSET_XNFONTSET, 0, - XOffsetOf(ICStatusAttributes, fontset), - _XimDefaultFontSet, _XimEncodeFontSet, _XimDecodeFontSet}, - - {OFFSET_XNLINESPACE, 0, - XOffsetOf(ICStatusAttributes, line_spacing), - _XimDefaultLineSpace, _XimEncodeLineSpace, _XimDecodeLineSpace}, - - {OFFSET_XNCURSOR, 0, - XOffsetOf(ICStatusAttributes, cursor), - _XimDefaultCursor, _XimEncodeCursor, _XimDecodeCursor}, - - {OFFSET_XNSTATUSSTARTCALLBACK, 0, - XOffsetOf(ICStatusAttributes, start_callback), - NULL, _XimEncodeCallback, _XimDecodeCallback}, - - {OFFSET_XNSTATUSDONECALLBACK, 0, - XOffsetOf(ICStatusAttributes, done_callback), - NULL, _XimEncodeCallback, _XimDecodeCallback}, - - {OFFSET_XNSTATUSDRAWCALLBACK, 0, - XOffsetOf(ICStatusAttributes, draw_callback), - NULL, _XimEncodeCallback, _XimDecodeCallback} -}; - -typedef struct _XimIMMode { - unsigned short name_offset; - unsigned short mode; -} XimIMMode; - -static const XimIMMode im_mode[] = { - {OFFSET_XNQUERYINPUTSTYLE, - (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_GET)}, - {OFFSET_XNDESTROYCALLBACK, - (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_SET | XIM_MODE_IM_GET)}, - {OFFSET_XNRESOURCENAME, - (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_SET | XIM_MODE_IM_GET)}, - {OFFSET_XNRESOURCECLASS, - (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_SET | XIM_MODE_IM_GET)}, - {OFFSET_XNQUERYIMVALUESLIST, - (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_GET)}, - {OFFSET_XNQUERYICVALUESLIST, - (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_GET)}, - {OFFSET_XNVISIBLEPOSITION, - (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_GET)} -}; - -typedef struct _XimICMode { - unsigned short name_offset; - unsigned short preedit_callback_mode; - unsigned short preedit_position_mode; - unsigned short preedit_area_mode; - unsigned short preedit_nothing_mode; - unsigned short preedit_none_mode; - unsigned short status_callback_mode; - unsigned short status_area_mode; - unsigned short status_nothing_mode; - unsigned short status_none_mode; -} XimICMode; - -static const XimICMode ic_mode[] = { - {OFFSET_XNINPUTSTYLE, - (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET), - (XIM_MODE_STS_CREATE | XIM_MODE_STS_GET), - (XIM_MODE_STS_CREATE | XIM_MODE_STS_GET), - (XIM_MODE_STS_CREATE | XIM_MODE_STS_GET), - (XIM_MODE_STS_CREATE | XIM_MODE_STS_GET)}, - {OFFSET_XNCLIENTWINDOW, - (XIM_MODE_PRE_ONCE | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_ONCE | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_ONCE | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_ONCE | XIM_MODE_PRE_GET), - 0, - (XIM_MODE_STS_ONCE | XIM_MODE_STS_GET), - (XIM_MODE_STS_ONCE | XIM_MODE_STS_GET), - (XIM_MODE_STS_ONCE | XIM_MODE_STS_GET), - 0}, - {OFFSET_XNFOCUSWINDOW, - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - 0}, - {OFFSET_XNRESOURCENAME, - 0, - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - 0}, - {OFFSET_XNRESOURCECLASS, - 0, - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - 0}, - {OFFSET_XNGEOMETRYCALLBACK, - 0, - 0, - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - 0, - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - 0, - 0}, - {OFFSET_XNFILTEREVENTS, - XIM_MODE_PRE_GET, - XIM_MODE_PRE_GET, - XIM_MODE_PRE_GET, - XIM_MODE_PRE_GET, - 0, - XIM_MODE_STS_GET, - XIM_MODE_STS_GET, - XIM_MODE_STS_GET, - XIM_MODE_STS_GET}, - {OFFSET_XNDESTROYCALLBACK, - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - 0, - 0}, - {OFFSET_XNSTRINGCONVERSIONCALLBACK, - (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - 0, - 0}, - {OFFSET_XNSTRINGCONVERSION, - XIM_MODE_PRE_SET, - XIM_MODE_PRE_SET, - XIM_MODE_PRE_SET, - XIM_MODE_PRE_SET, - XIM_MODE_PRE_SET, - 0, - 0, - 0, - 0}, - {OFFSET_XNRESETSTATE, - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - 0, - 0, - 0}, - {OFFSET_XNHOTKEY, - (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - 0, - 0, - 0}, - {OFFSET_XNHOTKEYSTATE, - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - 0, - 0, - 0}, - {OFFSET_XNPREEDITATTRIBUTES, - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - 0, - 0, - 0}, - {OFFSET_XNSTATUSATTRIBUTES, - 0, - 0, - 0, - 0, - 0, - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - 0}, - {OFFSET_XNAREA, - 0, - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - 0, - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - 0, - 0}, - {OFFSET_XNAREANEEDED, - 0, - 0, - (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - 0, - (XIM_MODE_STS_SET | XIM_MODE_STS_GET), - 0, - 0}, - {OFFSET_XNSPOTLOCATION, - 0, /*(XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),*/ - (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - 0, - 0}, - {OFFSET_XNCOLORMAP, - 0, - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - 0}, - {OFFSET_XNSTDCOLORMAP, - 0, - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - 0}, - {OFFSET_XNFOREGROUND, - 0, - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - 0}, - {OFFSET_XNBACKGROUND, - 0, - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - 0}, - {OFFSET_XNBACKGROUNDPIXMAP, - 0, - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - 0}, - {OFFSET_XNFONTSET, - 0, - (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - (XIM_MODE_STS_CREATE | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - 0}, - {OFFSET_XNLINESPACE, - 0, - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - 0}, - {OFFSET_XNCURSOR, - 0, - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - 0}, - {OFFSET_XNPREEDITSTARTCALLBACK, - (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0}, - {OFFSET_XNPREEDITDONECALLBACK, - (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0}, - {OFFSET_XNPREEDITDRAWCALLBACK, - (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0}, - {OFFSET_XNPREEDITCARETCALLBACK, - (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0}, - {OFFSET_XNPREEDITSTATE, - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - 0, - 0, - 0}, - {OFFSET_XNPREEDITSTATENOTIFYCALLBACK, - (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), - 0, - 0, - 0, - 0, - 0}, - {OFFSET_XNSTATUSSTARTCALLBACK, - 0, - 0, - 0, - 0, - 0, - (XIM_MODE_STS_CREATE | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - 0, - 0, - 0}, - {OFFSET_XNSTATUSDONECALLBACK, - 0, - 0, - 0, - 0, - 0, - (XIM_MODE_STS_CREATE | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - 0, - 0, - 0}, - {OFFSET_XNSTATUSDRAWCALLBACK, - 0, - 0, - 0, - 0, - 0, - (XIM_MODE_STS_CREATE | XIM_MODE_STS_SET | XIM_MODE_STS_GET), - 0, - 0, - 0} -}; - -/* the quarks are separated from im_mode/ic_mode so those arrays - * can be const. - */ -static XrmQuark im_mode_quark[sizeof(im_mode) / sizeof(im_mode[0])]; -static XrmQuark ic_mode_quark[sizeof(ic_mode) / sizeof(ic_mode[0])]; - -Private Bool -_XimSetResourceList( - XIMResourceList *res_list, - unsigned int *list_num, - XIMResourceList resource, - unsigned int num_resource, - unsigned short id) -{ - register int i; - int len; - XIMResourceList res; - - len = sizeof(XIMResource) * num_resource; - if(!(res = (XIMResourceList)Xmalloc(len))) { - return False; - } - bzero((char *)res, len); - - for(i = 0; i < num_resource; i++, id++) { - res[i] = resource[i]; - res[i].id = id; - } - - _XIMCompileResourceList(res, num_resource); - *res_list = res; - *list_num = num_resource; - return True; -} - -Public Bool -_XimSetIMResourceList( - XIMResourceList *res_list, - unsigned int *list_num) -{ - return _XimSetResourceList(res_list, list_num, - im_resources, XIMNumber(im_resources), 100); -} - -Public Bool -_XimSetICResourceList( - XIMResourceList *res_list, - unsigned int *list_num) -{ - return _XimSetResourceList(res_list, list_num, - ic_resources, XIMNumber(ic_resources), 200); -} - -Public Bool -_XimSetInnerIMResourceList( - XIMResourceList *res_list, - unsigned int *list_num) -{ - return _XimSetResourceList(res_list, list_num, - im_inner_resources, XIMNumber(im_inner_resources), 100); -} - -Public Bool -_XimSetInnerICResourceList( - XIMResourceList *res_list, - unsigned int *list_num) -{ - return _XimSetResourceList(res_list, list_num, - ic_inner_resources, XIMNumber(ic_inner_resources), 200); -} - -Private XIMResourceList -_XimGetResourceListRecByMode( - XIMResourceList res_list, - unsigned int list_num, - unsigned short mode) -{ - register int i; - - for(i = 0; i < list_num; i++) { - if (res_list[i].mode & mode) { - return (XIMResourceList)&res_list[i]; - } - } - return (XIMResourceList)NULL; -} - -Public Bool -_XimCheckCreateICValues( - XIMResourceList res_list, - unsigned int list_num) -{ - if (!_XimGetResourceListRecByMode(res_list, list_num, XIM_MODE_IC_CREATE)) { - return True; - } - return False; -} - -Public XIMResourceList -_XimGetResourceListRecByQuark( - XIMResourceList res_list, - unsigned int list_num, - XrmQuark quark) -{ - register int i; - - for(i = 0; i < list_num; i++) { - if (res_list[i].xrm_name == quark) { - return (XIMResourceList)&res_list[i]; - } - } - return (XIMResourceList)NULL; -} - -Public XIMResourceList -_XimGetResourceListRec( - XIMResourceList res_list, - unsigned int list_num, - const char *name) -{ - XrmQuark quark = XrmStringToQuark(name); - - return _XimGetResourceListRecByQuark(res_list, list_num, quark); -} - -Public char * -_XimSetIMValueData( - Xim im, - XPointer top, - XIMArg *values, - XIMResourceList res_list, - unsigned int list_num) -{ - register XIMArg *p; - XIMResourceList res; - int check; - - for(p = values; p->name != NULL; p++) { - if(!(res = _XimGetResourceListRec(res_list, list_num, p->name))) { - return p->value; - } - check = _XimCheckIMMode(res, XIM_SETIMVALUES); - if(check == XIM_CHECK_INVALID) { - continue; - } else if (check == XIM_CHECK_ERROR) { - return p->value; - } - - if(!_XimEncodeLocalIMAttr(res, top, p->value)) { - return p->value; - } - } - return NULL; -} - -Public char * -_XimGetIMValueData( - Xim im, - XPointer top, - XIMArg *values, - XIMResourceList res_list, - unsigned int list_num) -{ - register XIMArg *p; - XIMResourceList res; - int check; - - for(p = values; p->name != NULL; p++) { - if(!(res = _XimGetResourceListRec(res_list, list_num, p->name))) { - return p->value; - } - check = _XimCheckIMMode(res, XIM_GETIMVALUES); - if(check == XIM_CHECK_INVALID) { - continue; - } else if (check == XIM_CHECK_ERROR) { - return p->value; - } - - if(!_XimDecodeLocalIMAttr(res, top, p->value)) { - return p->value; - } - } - return NULL; -} - -Public void -_XimSetIMMode( - XIMResourceList res_list, - unsigned int list_num) -{ - XIMResourceList res; - unsigned int n = XIMNumber(im_mode); - register int i; - - for(i = 0; i < n; i++) { - if(!(res = _XimGetResourceListRecByQuark(res_list, - list_num, im_mode_quark[i]))) { - continue; - } - res->mode = im_mode[i].mode; - } - return; -} - -Private int -_XimCheckSetIMDefaultsMode( - XIMResourceList res) -{ - if(res->mode & XIM_MODE_IM_DEFAULT) { - return XIM_CHECK_VALID; - } - return XIM_CHECK_INVALID; -} - -Private int -_XimCheckSetIMValuesMode( - XIMResourceList res) -{ - if(res->mode & XIM_MODE_IM_SET) { - return XIM_CHECK_VALID; - } - return XIM_CHECK_INVALID; -} - -Private int - _XimCheckGetIMValuesMode( - XIMResourceList res) -{ - if(res->mode & XIM_MODE_IM_GET) { - return XIM_CHECK_VALID; - } - return XIM_CHECK_INVALID; -} - -Public int - _XimCheckIMMode( - XIMResourceList res, - unsigned long mode) -{ - if(res->mode == 0) { - return XIM_CHECK_INVALID; - } - if(mode & XIM_SETIMDEFAULTS) { - return _XimCheckSetIMDefaultsMode(res); - } else if (mode & XIM_SETIMVALUES) { - return _XimCheckSetIMValuesMode(res); - } else if (mode & XIM_GETIMVALUES) { - return _XimCheckGetIMValuesMode(res); - } else { - return XIM_CHECK_ERROR; - } -} - -Public void -_XimSetICMode(XIMResourceList res_list, unsigned int list_num, XIMStyle style) -{ - XIMResourceList res; - unsigned int n = XIMNumber(ic_mode); - register int i; - unsigned int pre_offset; - unsigned int sts_offset; - - if(style & XIMPreeditArea) { - pre_offset = XOffsetOf(XimICMode, preedit_area_mode); - } else if(style & XIMPreeditCallbacks) { - pre_offset = XOffsetOf(XimICMode, preedit_callback_mode); - } else if(style & XIMPreeditPosition) { - pre_offset = XOffsetOf(XimICMode, preedit_position_mode); - } else if(style & XIMPreeditNothing) { - pre_offset = XOffsetOf(XimICMode, preedit_nothing_mode); - } else { - pre_offset = XOffsetOf(XimICMode, preedit_none_mode); - } - - if(style & XIMStatusArea) { - sts_offset = XOffsetOf(XimICMode, status_area_mode); - } else if(style & XIMStatusCallbacks) { - sts_offset = XOffsetOf(XimICMode, status_callback_mode); - } else if(style & XIMStatusNothing) { - sts_offset = XOffsetOf(XimICMode, status_nothing_mode); - } else { - sts_offset = XOffsetOf(XimICMode, status_none_mode); - } - - for(i = 0; i < n; i++) { - if(!(res = _XimGetResourceListRecByQuark(res_list, - list_num, ic_mode_quark[i]))) { - continue; - } - res->mode = ( (*(unsigned short *)((char *)&ic_mode[i] + pre_offset)) - | (*(unsigned short *)((char *)&ic_mode[i] + sts_offset))); - } - return; -} - -Private int -_XimCheckSetICDefaultsMode( - XIMResourceList res, - unsigned long mode) -{ - if(mode & XIM_PREEDIT_ATTR) { - if(!(res->mode & XIM_MODE_PRE_MASK)) { - return XIM_CHECK_INVALID; - } - - if(res->mode & XIM_MODE_PRE_CREATE) { - return XIM_CHECK_ERROR; - } else if (!(res->mode & XIM_MODE_PRE_DEFAULT)) { - return XIM_CHECK_INVALID; - } - - } else if(mode & XIM_STATUS_ATTR) { - if(!(res->mode & XIM_MODE_STS_MASK)) { - return XIM_CHECK_INVALID; - } - - if(res->mode & XIM_MODE_STS_CREATE) { - return XIM_CHECK_ERROR; - } - if(!(res->mode & XIM_MODE_STS_DEFAULT)) { - return XIM_CHECK_INVALID; - } - - } else { - if(!res->mode) { - return XIM_CHECK_INVALID; - } - - if(res->mode & XIM_MODE_IC_CREATE) { - return XIM_CHECK_ERROR; - } - if(!(res->mode & XIM_MODE_IC_DEFAULT)) { - return XIM_CHECK_INVALID; - } - } - return XIM_CHECK_VALID; -} - -Private int -_XimCheckCreateICMode( - XIMResourceList res, - unsigned long mode) -{ - if(mode & XIM_PREEDIT_ATTR) { - if(!(res->mode & XIM_MODE_PRE_MASK)) { - return XIM_CHECK_INVALID; - } - - if(res->mode & XIM_MODE_PRE_CREATE) { - res->mode &= ~XIM_MODE_PRE_CREATE; - } else if(res->mode & XIM_MODE_PRE_ONCE) { - res->mode &= ~XIM_MODE_PRE_ONCE; - } else if(res->mode & XIM_MODE_PRE_DEFAULT) { - res->mode &= ~XIM_MODE_PRE_DEFAULT; - } else if (!(res->mode & XIM_MODE_PRE_SET)) { - return XIM_CHECK_ERROR; - } - - } else if(mode & XIM_STATUS_ATTR) { - if(!(res->mode & XIM_MODE_STS_MASK)) { - return XIM_CHECK_INVALID; - } - - if(res->mode & XIM_MODE_STS_CREATE) { - res->mode &= ~XIM_MODE_STS_CREATE; - } else if(res->mode & XIM_MODE_STS_ONCE) { - res->mode &= ~XIM_MODE_STS_ONCE; - } else if(res->mode & XIM_MODE_STS_DEFAULT) { - res->mode &= ~XIM_MODE_STS_DEFAULT; - } else if (!(res->mode & XIM_MODE_STS_SET)) { - return XIM_CHECK_ERROR; - } - - } else { - if(!res->mode) { - return XIM_CHECK_INVALID; - } - - if(res->mode & XIM_MODE_IC_CREATE) { - res->mode &= ~XIM_MODE_IC_CREATE; - } else if(res->mode & XIM_MODE_IC_ONCE) { - res->mode &= ~XIM_MODE_IC_ONCE; - } else if(res->mode & XIM_MODE_IC_DEFAULT) { - res->mode &= ~XIM_MODE_IC_DEFAULT; - } else if (!(res->mode & XIM_MODE_IC_SET)) { - return XIM_CHECK_ERROR; - } - } - return XIM_CHECK_VALID; -} - -Private int -_XimCheckSetICValuesMode( - XIMResourceList res, - unsigned long mode) -{ - if(mode & XIM_PREEDIT_ATTR) { - if(!(res->mode & XIM_MODE_PRE_MASK)) { - return XIM_CHECK_INVALID; - } - - if(res->mode & XIM_MODE_PRE_ONCE) { - res->mode &= ~XIM_MODE_PRE_ONCE; - } else if(!(res->mode & XIM_MODE_PRE_SET)) { - return XIM_CHECK_ERROR; - } - - } else if(mode & XIM_STATUS_ATTR) { - if(!(res->mode & XIM_MODE_STS_MASK)) { - return XIM_CHECK_INVALID; - } - - if(res->mode & XIM_MODE_STS_ONCE) { - res->mode &= ~XIM_MODE_STS_ONCE; - } else if(!(res->mode & XIM_MODE_STS_SET)) { - return XIM_CHECK_ERROR; - } - - } else { - if(!res->mode) { - return XIM_CHECK_INVALID; - } - - if(res->mode & XIM_MODE_IC_ONCE) { - res->mode &= ~XIM_MODE_IC_ONCE; - } else if(!(res->mode & XIM_MODE_IC_SET)) { - return XIM_CHECK_ERROR; - } - } - return XIM_CHECK_VALID; -} - -Private int -_XimCheckGetICValuesMode( - XIMResourceList res, - unsigned long mode) -{ - if(mode & XIM_PREEDIT_ATTR) { - if(!(res->mode & XIM_MODE_PRE_MASK)) { - return XIM_CHECK_INVALID; - } - - if(!(res->mode & XIM_MODE_PRE_GET)) { - return XIM_CHECK_ERROR; - } - - } else if(mode & XIM_STATUS_ATTR) { - if(!(res->mode & XIM_MODE_STS_MASK)) { - return XIM_CHECK_INVALID; - } - - if(!(res->mode & XIM_MODE_STS_GET)) { - return XIM_CHECK_ERROR; - } - - } else { - if(!res->mode) { - return XIM_CHECK_INVALID; - } - - if(!(res->mode & XIM_MODE_IC_GET)) { - return XIM_CHECK_ERROR; - } - } - return XIM_CHECK_VALID; -} - -Public int - _XimCheckICMode( - XIMResourceList res, - unsigned long mode) -{ - if(mode &XIM_SETICDEFAULTS) { - return _XimCheckSetICDefaultsMode(res, mode); - } else if (mode & XIM_CREATEIC) { - return _XimCheckCreateICMode(res, mode); - } else if (mode & XIM_SETICVALUES) { - return _XimCheckSetICValuesMode(res, mode); - } else if (mode & XIM_GETICVALUES) { - return _XimCheckGetICValuesMode(res, mode); - } else { - return XIM_CHECK_ERROR; - } -} - -Public Bool -_XimSetLocalIMDefaults( - Xim im, - XPointer top, - XIMResourceList res_list, - unsigned int list_num) -{ - XimValueOffsetInfo info; - unsigned int num; - register int i; - XIMResourceList res; - int check; - - info = im_attr_info; - num = XIMNumber(im_attr_info); - - for(i = 0; i < num; i++) { - if((res = _XimGetResourceListRecByQuark( res_list, list_num, - info[i].quark)) == (XIMResourceList)NULL) { - return False; - } - - check = _XimCheckIMMode(res, XIM_SETIMDEFAULTS); - if(check == XIM_CHECK_INVALID) { - continue; - } else if (check == XIM_CHECK_ERROR) { - return False; - } - - if(!info[i].defaults) { - continue; - } - if(!(info[i].defaults(&info[i], top, (XPointer)NULL, 0))) { - return False; - } - } - return True; -} - -Public Bool -_XimSetICDefaults( - Xic ic, - XPointer top, - unsigned long mode, - XIMResourceList res_list, - unsigned int list_num) -{ - unsigned int num; - XimValueOffsetInfo info; - register int i; - XIMResourceList res; - int check; - XrmQuark pre_quark; - XrmQuark sts_quark; - - pre_quark = XrmStringToQuark(XNPreeditAttributes); - sts_quark = XrmStringToQuark(XNStatusAttributes); - - if(mode & XIM_PREEDIT_ATTR) { - info = ic_pre_attr_info; - num = XIMNumber(ic_pre_attr_info); - } else if(mode & XIM_STATUS_ATTR) { - info = ic_sts_attr_info; - num = XIMNumber(ic_sts_attr_info); - } else { - info = ic_attr_info; - num = XIMNumber(ic_attr_info); - } - - for(i = 0; i < num; i++) { - if(info[i].quark == pre_quark) { - if(!_XimSetICDefaults(ic, (XPointer)((char *)top + info[i].offset), - (mode | XIM_PREEDIT_ATTR), res_list, list_num)) { - return False; - } - } else if (info[i].quark == sts_quark) { - if(!_XimSetICDefaults(ic, (XPointer)((char *)top + info[i].offset), - (mode | XIM_STATUS_ATTR), res_list, list_num)) { - return False; - } - } else { - if(!(res = _XimGetResourceListRecByQuark(res_list, list_num, - info[i].quark))) { - return False; - } - - check = _XimCheckICMode(res, mode); - if (check == XIM_CHECK_INVALID) { - continue; - } else if (check == XIM_CHECK_ERROR) { - return False; - } - - if (!info[i].defaults) { - continue; - } - if (!(info[i].defaults(&info[i], top, (XPointer)ic, mode))) { - return False; - } - } - } - return True; -} - -Private Bool -_XimEncodeAttr( - XimValueOffsetInfo info, - unsigned int num, - XIMResourceList res, - XPointer top, - XPointer val) -{ - register int i; - - for(i = 0; i < num; i++ ) { - if(info[i].quark == res->xrm_name) { - if(!info[i].encode) { - return False; - } - return (*info[i].encode)(&info[i], top, val); - } - } - return False; -} - -Public Bool -_XimEncodeLocalIMAttr( - XIMResourceList res, - XPointer top, - XPointer val) -{ - return _XimEncodeAttr(im_attr_info, XIMNumber(im_attr_info), - res, top, val); -} - -Public Bool -_XimEncodeLocalICAttr( - Xic ic, - XIMResourceList res, - XPointer top, - XIMArg *arg, - unsigned long mode) -{ - unsigned int num; - XimValueOffsetInfo info; - - if(mode & XIM_PREEDIT_ATTR) { - info = ic_pre_attr_info; - num = XIMNumber(ic_pre_attr_info); - } else if(mode & XIM_STATUS_ATTR) { - info = ic_sts_attr_info; - num = XIMNumber(ic_sts_attr_info); - } else { - info = ic_attr_info; - num = XIMNumber(ic_attr_info); - } - - return _XimEncodeAttr(info, num, res, top, arg->value); -} - -Private Bool -_XimEncodeLocalTopValue( - Xic ic, - XIMResourceList res, - XPointer val, - Bool flag) -{ - XIMArg *p = (XIMArg *)val; - - if (res->xrm_name == XrmStringToQuark(XNClientWindow)) { - ic->core.client_window = (Window)p->value; - if (ic->core.focus_window == (Window)0) - ic->core.focus_window = ic->core.client_window; - if (flag) { - _XRegisterFilterByType(ic->core.im->core.display, - ic->core.focus_window, - KeyPress, KeyRelease, _XimLocalFilter, (XPointer)ic); - } - } else if (res->xrm_name == XrmStringToQuark(XNFocusWindow)) { - if (ic->core.client_window) { - if (flag) { - _XUnregisterFilter(ic->core.im->core.display, - ic->core.focus_window, _XimLocalFilter, (XPointer)ic); - } - ic->core.focus_window = (Window)p->value; - if (flag) { - _XRegisterFilterByType(ic->core.im->core.display, - ic->core.focus_window, KeyPress, KeyRelease, - _XimLocalFilter, (XPointer)ic); - } - } else - ic->core.focus_window = (Window)p->value; - } - return True; -} - -Private Bool -_XimEncodeLocalPreeditValue( - Xic ic, - XIMResourceList res, - XPointer val) -{ - XIMArg *p = (XIMArg *)val; - - if (res->xrm_name == XrmStringToQuark(XNStdColormap)) { - XStandardColormap *colormap_ret; - int count; - - if (!(XGetRGBColormaps(ic->core.im->core.display, - ic->core.focus_window, &colormap_ret, - &count, (Atom)p->value))) - return False; - } - return True; -} - -Private Bool -_XimEncodeLocalStatusValue( - Xic ic, - XIMResourceList res, - XPointer val) -{ - XIMArg *p = (XIMArg *)val; - - if (res->xrm_name == XrmStringToQuark(XNStdColormap)) { - XStandardColormap *colormap_ret; - int count; - - if (!(XGetRGBColormaps(ic->core.im->core.display, - ic->core.focus_window, &colormap_ret, - &count, (Atom)p->value))) - return False; - } - return True; -} - -Public char * -_XimSetICValueData( - Xic ic, - XPointer top, - XIMResourceList res_list, - unsigned int list_num, - XIMArg *values, - unsigned long mode, - Bool flag) -{ - register XIMArg *p; - XIMResourceList res; - char *name; - int check; - XrmQuark pre_quark; - XrmQuark sts_quark; - - pre_quark = XrmStringToQuark(XNPreeditAttributes); - sts_quark = XrmStringToQuark(XNStatusAttributes); - - for(p = values; p->name != NULL; p++) { - if((res = _XimGetResourceListRec(res_list, list_num, - p->name)) == (XIMResourceList)NULL) { - return p->name; - } - if(res->xrm_name == pre_quark) { - if(((name = _XimSetICValueData(ic, - (XPointer)(&((XimDefICValues *)top)->preedit_attr), - res_list, list_num, (XIMArg *)p->value, - (mode | XIM_PREEDIT_ATTR), flag)))) { - return name; - } - } else if(res->xrm_name == sts_quark) { - if(((name = _XimSetICValueData(ic, - (XPointer)(&((XimDefICValues *)top)->status_attr), - res_list, list_num, (XIMArg *)p->value, - (mode | XIM_STATUS_ATTR), flag)))) { - return name; - } - } else { - check = _XimCheckICMode(res, mode); - if(check == XIM_CHECK_INVALID) { - continue; - } else if(check == XIM_CHECK_ERROR) { - return p->name; - } - - if(mode & XIM_PREEDIT_ATTR) { - if (!_XimEncodeLocalPreeditValue(ic, res, (XPointer)p)) - return False; - } else if(mode & XIM_STATUS_ATTR) { - if (!_XimEncodeLocalStatusValue(ic, res, (XPointer)p)) - return False; - } else { - if (!_XimEncodeLocalTopValue(ic, res, (XPointer)p, flag)) - return False; - } - if(_XimEncodeLocalICAttr(ic, res, top, p, mode) == False) { - return p->name; - } - } - } - return NULL; -} - -Private Bool -_XimCheckInputStyle( - XIMStyles *styles, - XIMStyle style) -{ - int num = styles->count_styles; - register int i; - - for(i = 0; i < num; i++) { - if(styles->supported_styles[i] == style) { - return True; - } - } - return False; -} - -Public Bool -_XimCheckLocalInputStyle( - Xic ic, - XPointer top, - XIMArg *values, - XIMStyles *styles, - XIMResourceList res_list, - unsigned int list_num) -{ - XrmQuark quark = XrmStringToQuark(XNInputStyle); - register XIMArg *p; - XIMResourceList res; - - for(p = values; p && p->name != NULL; p++) { - if(quark == XrmStringToQuark(p->name)) { - if(!(res = _XimGetResourceListRec(res_list, list_num, p->name))) { - return False; - } - if(!_XimEncodeLocalICAttr(ic, res, top, p, 0)) { - return False; - } - if (_XimCheckInputStyle(styles, - ((XimDefICValues *)top)->input_style)) { - return True; - } - return False; - } - } - return False; -} - -Private Bool -_XimDecodeAttr( - XimValueOffsetInfo info, - unsigned int num, - XIMResourceList res, - XPointer top, - XPointer val) -{ - register int i; - - for(i = 0; i < num; i++ ) { - if(info[i].quark == res->xrm_name) { - if(!info[i].decode) { - return False; - } - return (*info[i].decode)(&info[i], top, val); - } - } - return False; -} - -Public Bool -_XimDecodeLocalIMAttr( - XIMResourceList res, - XPointer top, - XPointer val) -{ - return _XimDecodeAttr(im_attr_info, XIMNumber(im_attr_info), - res, top, val); -} - -Public Bool -_XimDecodeLocalICAttr( - XIMResourceList res, - XPointer top, - XPointer val, - unsigned long mode) -{ - unsigned int num; - XimValueOffsetInfo info; - - if(mode & XIM_PREEDIT_ATTR) { - info = ic_pre_attr_info; - num = XIMNumber(ic_pre_attr_info); - } else if(mode & XIM_STATUS_ATTR) { - info = ic_sts_attr_info; - num = XIMNumber(ic_sts_attr_info); - } else { - info = ic_attr_info; - num = XIMNumber(ic_attr_info); - } - - return _XimDecodeAttr(info, num, res, top, val); -} - -Public char * -_XimGetICValueData(Xic ic, XPointer top, XIMResourceList res_list, - unsigned int list_num, XIMArg *values, unsigned long mode) -{ - register XIMArg *p; - XIMResourceList res; - char *name; - int check; - XrmQuark pre_quark; - XrmQuark sts_quark; - - pre_quark = XrmStringToQuark(XNPreeditAttributes); - sts_quark = XrmStringToQuark(XNStatusAttributes); - - for(p = values; p->name != NULL; p++) { - if((res = _XimGetResourceListRec(res_list, list_num, - p->name)) == (XIMResourceList)NULL) { - return p->name; - } - if(res->xrm_name == pre_quark) { - if((name = _XimGetICValueData(ic, - (XPointer)(&((XimDefICValues *)top)->preedit_attr), - res_list, list_num, (XIMArg *)p->value, - (mode | XIM_PREEDIT_ATTR)))) { - return name; - } - } else if(res->xrm_name == sts_quark) { - if((name = _XimGetICValueData(ic, - (XPointer)(&((XimDefICValues *)top)->status_attr), - res_list, list_num, (XIMArg *)p->value, - (mode | XIM_STATUS_ATTR)))) { - return name; - } - } else { - check = _XimCheckICMode(res, mode); - if(check == XIM_CHECK_INVALID) { - continue; - } else if(check == XIM_CHECK_ERROR) { - return p->name; - } - - if(_XimDecodeLocalICAttr(res, top, p->value, mode) == False) { - return p->name; - } - } - } - return NULL; -} - -Public void -_XimGetCurrentIMValues(Xim im, XimDefIMValues *im_values) -{ - bzero((char *)im_values, sizeof(XimDefIMValues)); - - im_values->styles = im->core.styles; - im_values->im_values_list = im->core.im_values_list; - im_values->ic_values_list = im->core.ic_values_list; - im_values->destroy_callback = im->core.destroy_callback; - im_values->res_name = im->core.res_name; - im_values->res_class = im->core.res_class; - im_values->visible_position = im->core.visible_position; -} - -Public void -_XimSetCurrentIMValues(Xim im, XimDefIMValues *im_values) -{ - im->core.styles = im_values->styles; - im->core.im_values_list = im_values->im_values_list; - im->core.ic_values_list = im_values->ic_values_list; - im->core.destroy_callback = im_values->destroy_callback; - im->core.res_name = im_values->res_name; - im->core.res_class = im_values->res_class; - im->core.visible_position = im_values->visible_position; -} - -Public void -_XimGetCurrentICValues(Xic ic, XimDefICValues *ic_values) -{ - bzero((char *)ic_values, sizeof(XimDefICValues)); - - ic_values->input_style = ic->core.input_style; - ic_values->client_window = ic->core.client_window; - ic_values->focus_window = ic->core.focus_window; - ic_values->filter_events = ic->core.filter_events; - ic_values->geometry_callback = ic->core.geometry_callback; - ic_values->res_name = ic->core.res_name; - ic_values->res_class = ic->core.res_class; - ic_values->destroy_callback = ic->core.destroy_callback; - ic_values->string_conversion_callback - = ic->core.string_conversion_callback; - ic_values->string_conversion = ic->core.string_conversion; - ic_values->reset_state = ic->core.reset_state; - ic_values->hotkey = ic->core.hotkey; - ic_values->hotkey_state = ic->core.hotkey_state; - ic_values->preedit_attr = ic->core.preedit_attr; - ic_values->status_attr = ic->core.status_attr; -} - -Public void -_XimSetCurrentICValues( - Xic ic, - XimDefICValues *ic_values) -{ - ic->core.input_style = ic_values->input_style; - ic->core.client_window = ic_values->client_window; - if (ic_values->focus_window) - ic->core.focus_window = ic_values->focus_window; - ic->core.filter_events = ic_values->filter_events; - ic->core.geometry_callback = ic_values->geometry_callback; - ic->core.res_name = ic_values->res_name; - ic->core.res_class = ic_values->res_class; - ic->core.destroy_callback = ic_values->destroy_callback; - ic->core.string_conversion_callback - = ic_values->string_conversion_callback; - ic->core.string_conversion = ic_values->string_conversion; - ic->core.reset_state = ic_values->reset_state; - ic->core.hotkey = ic_values->hotkey; - ic->core.hotkey_state = ic_values->hotkey_state; - ic->core.preedit_attr = ic_values->preedit_attr; - ic->core.status_attr = ic_values->status_attr; -} - -Private void -_XimInitialIMOffsetInfo(void) -{ - unsigned int n = XIMNumber(im_attr_info); - register int i; - - for(i = 0; i < n; i++) { - im_attr_info[i].quark = XrmStringToQuark(GET_NAME(im_attr_info[i])); - } -} - -Private void -_XimInitialICOffsetInfo(void) -{ - unsigned int n; - register int i; - - n = XIMNumber(ic_attr_info); - for(i = 0; i < n; i++) { - ic_attr_info[i].quark = XrmStringToQuark(GET_NAME(ic_attr_info[i])); - } - - n = XIMNumber(ic_pre_attr_info); - for(i = 0; i < n; i++) { - ic_pre_attr_info[i].quark = XrmStringToQuark(GET_NAME(ic_pre_attr_info[i])); - } - - n = XIMNumber(ic_sts_attr_info); - for(i = 0; i < n; i++) { - ic_sts_attr_info[i].quark = XrmStringToQuark(GET_NAME(ic_sts_attr_info[i])); - } -} - -Private void -_XimInitialIMMode(void) -{ - unsigned int n = XIMNumber(im_mode); - register int i; - - for(i = 0; i < n; i++) { - im_mode_quark[i] = XrmStringToQuark(GET_NAME(im_mode[i])); - } -} - -Private void -_XimInitialICMode(void) -{ - unsigned int n = XIMNumber(ic_mode); - register int i; - - for(i = 0; i < n; i++) { - ic_mode_quark[i] = XrmStringToQuark(GET_NAME(ic_mode[i])); - } -} - -Public void -_XimInitialResourceInfo(void) -{ - static Bool init_flag = False; - - if(init_flag == True) { - return; - } - _XimInitialIMOffsetInfo(); - _XimInitialICOffsetInfo(); - _XimInitialIMMode(); - _XimInitialICMode(); - init_flag = True; -} +/******************************************************************
+
+ Copyright 1990, 1991, 1992,1993, 1994 by FUJITSU LIMITED
+ Copyright 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 make
+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 DISCLAIM ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJITSU LIMITED AND
+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: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+ Modifier: Makoto Wakamatsu Sony Corporation
+ makoto@sm.sony.co.jp
+
+******************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+#include "Xresource.h"
+
+#define GET_NAME(x) name_table + x.name_offset
+
+typedef struct _XimValueOffsetInfo {
+ unsigned short name_offset;
+ XrmQuark quark;
+ unsigned int offset;
+ Bool (*defaults)(
+ struct _XimValueOffsetInfo *, XPointer, XPointer, unsigned long
+ );
+ Bool (*encode)(
+ struct _XimValueOffsetInfo *, XPointer, XPointer
+ );
+ Bool (*decode)(
+ struct _XimValueOffsetInfo *, XPointer, XPointer
+ );
+} XimValueOffsetInfoRec, *XimValueOffsetInfo;
+
+#ifdef XIM_CONNECTABLE
+Private Bool
+_XimCheckBool(str)
+ char *str;
+{
+ if(!strcmp(str, "True") || !strcmp(str, "true") ||
+ !strcmp(str, "Yes") || !strcmp(str, "yes") ||
+ !strcmp(str, "ON") || !strcmp(str, "on"))
+ return True;
+ return False;
+}
+
+Public void
+_XimSetProtoResource(im)
+ Xim im;
+{
+ char res_name_buf[256];
+ char* res_name;
+ char res_class_buf[256];
+ char* res_class;
+ char* str_type;
+ XrmValue value;
+ XIMStyle preedit_style = 0;
+ XIMStyle status_style = 0;
+ XIMStyles* imstyles;
+ char* dotximdot = ".xim.";
+ char* ximdot = "xim.";
+ char* dotXimdot = ".Xim.";
+ char* Ximdot = "Xim.";
+
+ if (!im->core.rdb)
+ return;
+
+ if (strlen (im->core.res_name) < 200) res_name = res_name_buf;
+ else res_name = Xmalloc (strlen (im->core.res_name) + 50);
+ if (strlen (im->core.res_class) < 200) res_class = res_class_buf;
+ else res_class = Xmalloc (strlen (im->core.res_class) + 50);
+ /* pretend malloc always works */
+
+ (void) sprintf (res_name, "%s%s%s",
+ im->core.res_name != NULL ? im->core.res_name : "*",
+ im->core.res_name != NULL ? dotximdot : ximdot,
+ "useAuth");
+ (void) sprintf (res_class, "%s%s%s",
+ im->core.res_class != NULL ? im->core.res_class : "*",
+ im->core.res_class != NULL ? dotXimdot : Ximdot,
+ "UseAuth");
+ bzero(&value, sizeof(XrmValue));
+ if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) {
+ if(_XimCheckBool(value.addr)) {
+ MARK_USE_AUTHORIZATION_FUNC(im);
+ }
+ }
+
+ (void) sprintf (res_name, "%s%s%s",
+ im->core.res_name != NULL ? im->core.res_name : "*",
+ im->core.res_name != NULL ? dotximdot : ximdot,
+ "delaybinding");
+ (void) sprintf (res_class, "%s%s%s",
+ im->core.res_class != NULL ? im->core.res_class : "*",
+ im->core.res_class != NULL ? dotXimdot : Ximdot,
+ "Delaybinding");
+ bzero(&value, sizeof(XrmValue));
+ if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) {
+ if(_XimCheckBool(value.addr)) {
+ MARK_DELAYBINDABLE(im);
+ }
+ }
+
+ (void) sprintf (res_name, "%s%s%s",
+ im->core.res_name != NULL ? im->core.res_name : "*",
+ im->core.res_name != NULL ? dotximdot : ximdot,
+ "reconnect");
+ (void) sprintf (res_class, "%s%s%s",
+ im->core.res_class != NULL ? im->core.res_class : "*",
+ im->core.res_class != NULL ? dotXimdot : Ximdot,
+ "Reconnect");
+ bzero(&value, sizeof(XrmValue));
+ if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) {
+ if(_XimCheckBool(value.addr)) {
+ MARK_RECONNECTABLE(im);
+ }
+ }
+
+ if(!IS_CONNECTABLE(im)) {
+ if (res_name != res_name_buf) Xfree (res_name);
+ if (res_class != res_class_buf) Xfree (res_class);
+ return;
+ }
+
+ (void) sprintf (res_name, "%s%s%s",
+ im->core.res_name != NULL ? im->core.res_name : "*",
+ im->core.res_name != NULL ? dotximdot : ximdot,
+ "preeditDefaultStyle");
+ (void) sprintf (res_class, "%s%s%s",
+ im->core.res_class != NULL ? im->core.res_class : "*",
+ im->core.res_class != NULL ? dotXimdot : Ximdot,
+ "PreeditDefaultStyle");
+ if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) {
+ if(!strcmp(value.addr, "XIMPreeditArea"))
+ preedit_style = XIMPreeditArea;
+ else if(!strcmp(value.addr, "XIMPreeditCallbacks"))
+ preedit_style = XIMPreeditCallbacks;
+ else if(!strcmp(value.addr, "XIMPreeditPosition"))
+ preedit_style = XIMPreeditPosition;
+ else if(!strcmp(value.addr, "XIMPreeditNothing"))
+ preedit_style = XIMPreeditNothing;
+ else if(!strcmp(value.addr, "XIMPreeditNone"))
+ preedit_style = XIMPreeditNone;
+ }
+ if(!preedit_style)
+ preedit_style = XIMPreeditNothing;
+
+ (void) sprintf (res_name, "%s%s%s",
+ im->core.res_name != NULL ? im->core.res_name : "*",
+ im->core.res_name != NULL ? dotximdot : ximdot,
+ "statusDefaultStyle");
+ (void) sprintf (res_class, "%s%s%s",
+ im->core.res_class != NULL ? im->core.res_class : "*",
+ im->core.res_class != NULL ? dotXimdot : Ximdot,
+ "StatusDefaultStyle");
+ if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) {
+ if(!strcmp(value.addr, "XIMStatusArea"))
+ status_style = XIMStatusArea;
+ else if(!strcmp(value.addr, "XIMStatusCallbacks"))
+ status_style = XIMStatusCallbacks;
+ else if(!strcmp(value.addr, "XIMStatusNothing"))
+ status_style = XIMStatusNothing;
+ else if(!strcmp(value.addr, "XIMStatusNone"))
+ status_style = XIMStatusNone;
+ }
+ if(!status_style)
+ status_style = XIMStatusNothing;
+
+ if(!(imstyles = (XIMStyles *)Xmalloc(sizeof(XIMStyles) + sizeof(XIMStyle)))){
+ if (res_name != res_name_buf) Xfree (res_name);
+ if (res_class != res_class_buf) Xfree (res_class);
+ return;
+ }
+ imstyles->count_styles = 1;
+ imstyles->supported_styles =
+ (XIMStyle *)((char *)imstyles + sizeof(XIMStyles));
+ imstyles->supported_styles[0] = preedit_style | status_style;
+ im->private.proto.default_styles = imstyles;
+ if (res_name != res_name_buf) Xfree (res_name);
+ if (res_class != res_class_buf) Xfree (res_class);
+}
+#endif /* XIM_CONNECTABLE */
+
+static const char name_table[] =
+ /* 0 */ XNQueryInputStyle"\0"
+ /* 16 */ XNClientWindow"\0"
+ /* 29 */ XNInputStyle"\0"
+ /* 40 */ XNFocusWindow"\0"
+ /* 52 */ XNResourceName"\0"
+ /* 65 */ XNResourceClass"\0"
+ /* 79 */ XNGeometryCallback"\0"
+ /* 96 */ XNDestroyCallback"\0"
+ /* 112 */ XNFilterEvents"\0"
+ /* 125 */ XNPreeditStartCallback"\0"
+ /* 146 */ XNPreeditDoneCallback"\0"
+ /* 166 */ XNPreeditDrawCallback"\0"
+ /* 186 */ XNPreeditCaretCallback"\0"
+ /* 207 */ XNPreeditStateNotifyCallback"\0"
+ /* 234 */ XNPreeditAttributes"\0"
+ /* 252 */ XNStatusStartCallback"\0"
+ /* 272 */ XNStatusDoneCallback"\0"
+ /* 291 */ XNStatusDrawCallback"\0"
+ /* 310 */ XNStatusAttributes"\0"
+ /* 327 */ XNArea"\0"
+ /* 332 */ XNAreaNeeded"\0"
+ /* 343 */ XNSpotLocation"\0"
+ /* 356 */ XNColormap"\0"
+ /* 365 */ XNStdColormap"\0"
+ /* 377 */ XNForeground"\0"
+ /* 388 */ XNBackground"\0"
+ /* 399 */ XNBackgroundPixmap"\0"
+ /* 416 */ XNFontSet"\0"
+ /* 424 */ XNLineSpace"\0"
+ /* 434 */ XNCursor"\0"
+ /* 441 */ XNQueryIMValuesList"\0"
+ /* 459 */ XNQueryICValuesList"\0"
+ /* 477 */ XNVisiblePosition"\0"
+ /* 493 */ XNStringConversionCallback"\0"
+ /* 518 */ XNStringConversion"\0"
+ /* 535 */ XNResetState"\0"
+ /* 546 */ XNHotKey"\0"
+ /* 553 */ XNHotKeyState"\0"
+ /* 565 */ XNPreeditState
+;
+
+#define OFFSET_XNQUERYINPUTSTYLE 0
+#define OFFSET_XNCLIENTWINDOW 16
+#define OFFSET_XNINPUTSTYLE 29
+#define OFFSET_XNFOCUSWINDOW 40
+#define OFFSET_XNRESOURCENAME 52
+#define OFFSET_XNRESOURCECLASS 65
+#define OFFSET_XNGEOMETRYCALLBACK 79
+#define OFFSET_XNDESTROYCALLBACK 96
+#define OFFSET_XNFILTEREVENTS 112
+#define OFFSET_XNPREEDITSTARTCALLBACK 125
+#define OFFSET_XNPREEDITDONECALLBACK 146
+#define OFFSET_XNPREEDITDRAWCALLBACK 166
+#define OFFSET_XNPREEDITCARETCALLBACK 186
+#define OFFSET_XNPREEDITSTATENOTIFYCALLBACK 207
+#define OFFSET_XNPREEDITATTRIBUTES 234
+#define OFFSET_XNSTATUSSTARTCALLBACK 252
+#define OFFSET_XNSTATUSDONECALLBACK 272
+#define OFFSET_XNSTATUSDRAWCALLBACK 291
+#define OFFSET_XNSTATUSATTRIBUTES 310
+#define OFFSET_XNAREA 327
+#define OFFSET_XNAREANEEDED 332
+#define OFFSET_XNSPOTLOCATION 343
+#define OFFSET_XNCOLORMAP 356
+#define OFFSET_XNSTDCOLORMAP 365
+#define OFFSET_XNFOREGROUND 377
+#define OFFSET_XNBACKGROUND 388
+#define OFFSET_XNBACKGROUNDPIXMAP 399
+#define OFFSET_XNFONTSET 416
+#define OFFSET_XNLINESPACE 424
+#define OFFSET_XNCURSOR 434
+#define OFFSET_XNQUERYIMVALUESLIST 441
+#define OFFSET_XNQUERYICVALUESLIST 459
+#define OFFSET_XNVISIBLEPOSITION 477
+#define OFFSET_XNSTRINGCONVERSIONCALLBACK 493
+#define OFFSET_XNSTRINGCONVERSION 518
+#define OFFSET_XNRESETSTATE 535
+#define OFFSET_XNHOTKEY 546
+#define OFFSET_XNHOTKEYSTATE 553
+#define OFFSET_XNPREEDITSTATE 565
+
+/* offsets into name_table */
+static const unsigned short supported_local_im_values_list[] = {
+ OFFSET_XNQUERYINPUTSTYLE,
+ OFFSET_XNRESOURCENAME,
+ OFFSET_XNRESOURCECLASS,
+ OFFSET_XNDESTROYCALLBACK,
+ OFFSET_XNQUERYIMVALUESLIST,
+ OFFSET_XNQUERYICVALUESLIST,
+ OFFSET_XNVISIBLEPOSITION
+};
+
+/* offsets into name_table */
+static const unsigned short supported_local_ic_values_list[] = {
+ OFFSET_XNINPUTSTYLE,
+ OFFSET_XNCLIENTWINDOW,
+ OFFSET_XNFOCUSWINDOW,
+ OFFSET_XNRESOURCENAME,
+ OFFSET_XNRESOURCECLASS,
+ OFFSET_XNGEOMETRYCALLBACK,
+ OFFSET_XNFILTEREVENTS,
+ OFFSET_XNDESTROYCALLBACK,
+ OFFSET_XNSTRINGCONVERSIONCALLBACK,
+ OFFSET_XNSTRINGCONVERSIONCALLBACK,
+ OFFSET_XNRESETSTATE,
+ OFFSET_XNHOTKEY,
+ OFFSET_XNHOTKEYSTATE,
+ OFFSET_XNPREEDITATTRIBUTES,
+ OFFSET_XNSTATUSATTRIBUTES,
+ OFFSET_XNAREA,
+ OFFSET_XNAREANEEDED,
+ OFFSET_XNSPOTLOCATION,
+ OFFSET_XNCOLORMAP,
+ OFFSET_XNSTDCOLORMAP,
+ OFFSET_XNFOREGROUND,
+ OFFSET_XNBACKGROUND,
+ OFFSET_XNBACKGROUNDPIXMAP,
+ OFFSET_XNFONTSET,
+ OFFSET_XNLINESPACE,
+ OFFSET_XNCURSOR,
+ OFFSET_XNPREEDITSTARTCALLBACK,
+ OFFSET_XNPREEDITDONECALLBACK,
+ OFFSET_XNPREEDITDRAWCALLBACK,
+ OFFSET_XNPREEDITCARETCALLBACK,
+ OFFSET_XNSTATUSSTARTCALLBACK,
+ OFFSET_XNSTATUSDONECALLBACK,
+ OFFSET_XNSTATUSDRAWCALLBACK,
+ OFFSET_XNPREEDITSTATE,
+ OFFSET_XNPREEDITSTATENOTIFYCALLBACK
+};
+
+static XIMStyle const supported_local_styles[] = {
+ XIMPreeditNone | XIMStatusNone,
+ XIMPreeditNothing | XIMStatusNothing,
+ 0 /* dummy */
+};
+
+Private Bool
+_XimDefaultStyles(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm, /* unused */
+ unsigned long mode) /* unused */
+{
+ XIMStyles *styles;
+ XIMStyles **out;
+ register int i;
+ unsigned int n;
+ int len;
+ XPointer tmp;
+
+ n = XIMNumber(supported_local_styles) - 1;
+ len = sizeof(XIMStyles) + sizeof(XIMStyle) * n;
+ if(!(tmp = (XPointer)Xmalloc(len))) {
+ return False;
+ }
+ bzero(tmp, len);
+
+ styles = (XIMStyles *)tmp;
+ if (n > 0) {
+ styles->count_styles = (unsigned short)n;
+ styles->supported_styles =
+ (XIMStyle *)((char *)tmp + sizeof(XIMStyles));
+ for(i = 0; i < n; i++) {
+ styles->supported_styles[i] = supported_local_styles[i];
+ }
+ }
+
+ out = (XIMStyles **)((char *)top + info->offset);
+ *out = styles;
+ return True;
+}
+
+Private Bool
+_XimDefaultIMValues(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm, /* unused */
+ unsigned long mode) /* unused */
+{
+ XIMValuesList *values_list;
+ XIMValuesList **out;
+ register int i;
+ unsigned int n;
+ int len;
+ XPointer tmp;
+
+ n = XIMNumber(supported_local_im_values_list);
+ len = sizeof(XIMValuesList) + sizeof(char **) * n;
+ if(!(tmp = (XPointer)Xmalloc(len))) {
+ return False;
+ }
+ bzero(tmp, len);
+
+ values_list = (XIMValuesList *)tmp;
+ if (n > 0) {
+ values_list->count_values = (unsigned short)n;
+ values_list->supported_values
+ = (char **)((char *)tmp + sizeof(XIMValuesList));
+ for(i = 0; i < n; i++) {
+ values_list->supported_values[i] =
+ (char *)name_table + supported_local_im_values_list[i];
+ }
+ }
+
+ out = (XIMValuesList **)((char *)top + info->offset);
+ *out = values_list;
+ return True;
+}
+
+Private Bool
+_XimDefaultICValues(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm, /* unused */
+ unsigned long mode) /* unused */
+{
+ XIMValuesList *values_list;
+ XIMValuesList **out;
+ register int i;
+ unsigned int n;
+ int len;
+ XPointer tmp;
+
+ n = XIMNumber(supported_local_ic_values_list);
+ len = sizeof(XIMValuesList) + sizeof(char **) * n;
+ if(!(tmp = (XPointer)Xmalloc(len))) {
+ return False;
+ }
+ bzero(tmp, len);
+
+ values_list = (XIMValuesList *)tmp;
+ if (n > 0) {
+ values_list->count_values = (unsigned short)n;
+ values_list->supported_values
+ = (char **)((char *)tmp + sizeof(XIMValuesList));
+ for(i = 0; i < n; i++) {
+ values_list->supported_values[i] =
+ (char *)name_table + supported_local_ic_values_list[i];
+ }
+ }
+
+ out = (XIMValuesList **)((char *)top + info->offset);
+ *out = values_list;
+ return True;
+}
+
+Private Bool
+_XimDefaultVisiblePos(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm, /* unused */
+ unsigned long mode) /* unused */
+{
+ Bool *out;
+
+ out = (Bool *)((char *)top + info->offset);
+ *out = False;
+ return True;
+}
+
+Private Bool
+_XimDefaultFocusWindow(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ Xic ic = (Xic)parm;
+ Window *out;
+
+ if(ic->core.client_window == (Window)NULL) {
+ return True;
+ }
+
+ out = (Window *)((char *)top + info->offset);
+ *out = ic->core.client_window;
+ return True;
+}
+
+Private Bool
+_XimDefaultResName(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ Xic ic = (Xic)parm;
+ Xim im = (Xim)ic->core.im;
+ char **out;
+
+ if(im->core.res_name == (char *)NULL) {
+ return True;
+ }
+
+ out = (char **)((char *)top + info->offset);
+ *out = im->core.res_name;
+ return True;
+}
+
+Private Bool
+_XimDefaultResClass(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ Xic ic = (Xic)parm;
+ Xim im = (Xim)ic->core.im;
+ char **out;
+
+ if(im->core.res_class == (char *)NULL) {
+ return True;
+ }
+
+ out = (char **)((char *)top + info->offset);
+ *out = im->core.res_class;
+ return True;
+}
+
+Private Bool
+_XimDefaultDestroyCB(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ Xic ic = (Xic)parm;
+ Xim im = (Xim)ic->core.im;
+ XIMCallback *out;
+
+ out = (XIMCallback *)((char *)top + info->offset);
+ *out = im->core.destroy_callback;
+ return True;
+}
+
+Private Bool
+_XimDefaultResetState(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ XIMResetState *out;
+
+ out = (XIMResetState *)((char *)top + info->offset);
+ *out = XIMInitialState;
+ return True;
+}
+
+Private Bool
+_XimDefaultHotKeyState(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ XIMHotKeyState *out;
+
+ out = (XIMHotKeyState *)((char *)top + info->offset);
+ *out = XIMHotKeyStateOFF;
+ return True;
+}
+
+Private Bool
+_XimDefaultArea(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ Xic ic = (Xic)parm;
+ Xim im = (Xim)ic->core.im;
+ Window root_return;
+ int x_return, y_return;
+ unsigned int width_return, height_return;
+ unsigned int border_width_return;
+ unsigned int depth_return;
+ XRectangle area;
+ XRectangle *out;
+
+ if(ic->core.focus_window == (Window)NULL) {
+ return True;
+ }
+ if(XGetGeometry(im->core.display, (Drawable)ic->core.focus_window,
+ &root_return, &x_return, &y_return, &width_return,
+ &height_return, &border_width_return, &depth_return)
+ == (Status)Success) {
+ return True;
+ }
+ area.x = 0;
+ area.y = 0;
+ area.width = width_return;
+ area.height = height_return;
+
+ out = (XRectangle *)((char *)top + info->offset);
+ *out = area;
+ return True;
+}
+
+Private Bool
+_XimDefaultColormap(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ Xic ic = (Xic)parm;
+ Xim im = (Xim)ic->core.im;
+ XWindowAttributes win_attr;
+ Colormap *out;
+
+ if(ic->core.client_window == (Window)NULL) {
+ return True;
+ }
+ if(XGetWindowAttributes(im->core.display, ic->core.client_window,
+ &win_attr) == (Status)Success) {
+ return True;
+ }
+
+ out = (Colormap *)((char *)top + info->offset);
+ *out = win_attr.colormap;
+ return True;
+}
+
+Private Bool
+_XimDefaultStdColormap(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ Atom *out;
+
+ out = (Atom *)((char *)top + info->offset);
+ *out = (Atom)0;
+ return True;
+}
+
+Private Bool
+_XimDefaultFg(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ Xic ic = (Xic)parm;
+ Xim im = (Xim)ic->core.im;
+ unsigned long fg;
+ unsigned long *out;
+
+ fg = WhitePixel(im->core.display, DefaultScreen(im->core.display));
+ out = (unsigned long *)((char *)top + info->offset);
+ *out = fg;
+ return True;
+}
+
+Private Bool
+_XimDefaultBg(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ Xic ic = (Xic)parm;
+ Xim im = (Xim)ic->core.im;
+ unsigned long bg;
+ unsigned long *out;
+
+ bg = BlackPixel(im->core.display, DefaultScreen(im->core.display));
+ out = (unsigned long *)((char *)top + info->offset);
+ *out = bg;
+ return True;
+}
+
+Private Bool
+_XimDefaultBgPixmap(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ Pixmap *out;
+
+ out = (Pixmap *)((char *)top + info->offset);
+ *out = (Pixmap)0;
+ return True;
+}
+
+Private Bool
+_XimDefaultFontSet(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ XFontSet *out;
+
+ out = (XFontSet *)((char *)top + info->offset);
+ *out = 0;
+ return True;
+}
+
+Private Bool
+_XimDefaultLineSpace(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ Xic ic = (Xic)parm;
+ XFontSet fontset;
+ XFontSetExtents *fset_extents;
+ int line_space = 0;
+ int *out;
+
+ if(mode & XIM_PREEDIT_ATTR) {
+ fontset = ic->core.preedit_attr.fontset;
+ } else if(mode & XIM_STATUS_ATTR) {
+ fontset = ic->core.status_attr.fontset;
+ } else {
+ return True;
+ }
+ if (fontset) {
+ fset_extents = XExtentsOfFontSet(fontset);
+ line_space = fset_extents->max_logical_extent.height;
+ }
+ out = (int *)((char *)top + info->offset);
+ *out = line_space;
+ return True;
+}
+
+Private Bool
+_XimDefaultCursor(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ Cursor *out;
+
+ out = (Cursor *)((char *)top + info->offset);
+ *out = (Cursor)0;
+ return True;
+}
+
+Private Bool
+_XimDefaultPreeditState(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ XIMPreeditState *out;
+
+ out = (XIMPreeditState *)((char *)top + info->offset);
+ *out = XIMPreeditDisable;
+ return True;
+}
+
+Private Bool
+_XimDefaultNest(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer parm,
+ unsigned long mode)
+{
+ return True;
+}
+
+Private Bool
+_XimEncodeCallback(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMCallback *out;
+
+ out = (XIMCallback *)((char *)top + info->offset);
+ *out = *((XIMCallback *)val);
+ return True;
+}
+
+Private Bool
+_XimEncodeString(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ int len;
+ char *string;
+ char **out;
+
+ if(val == (XPointer)NULL) {
+ return False;
+ }
+ len = strlen((char *)val);
+ if(!(string = (char *)Xmalloc(len + 1))) {
+ return False;
+ }
+ (void)strcpy(string, (char *)val);
+ string[len] = '\0';
+
+ out = (char **)((char *)top + info->offset);
+ if(*out) {
+ Xfree(*out);
+ }
+ *out = string;
+ return True;
+}
+
+Private Bool
+_XimEncodeStyle(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMStyle *out;
+
+ out = (XIMStyle *)((char *)top + info->offset);
+ *out = (XIMStyle)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeWindow(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ Window *out;
+
+ out = (Window *)((char *)top + info->offset);
+ *out = (Window)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeStringConv(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ /*
+ * Not yet
+ */
+ return True;
+}
+
+Private Bool
+_XimEncodeResetState(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMResetState *out;
+
+ out = (XIMResetState *)((char *)top + info->offset);
+ *out = (XIMResetState)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeHotKey(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMHotKeyTriggers *hotkey = (XIMHotKeyTriggers *)val;
+ XIMHotKeyTriggers **out;
+ XIMHotKeyTriggers *key_list;
+ XIMHotKeyTrigger *key;
+ XPointer tmp;
+ int num;
+ int len;
+ register int i;
+
+ if(hotkey == (XIMHotKeyTriggers *)NULL) {
+ return True;
+ }
+
+ if((num = hotkey->num_hot_key) == 0) {
+ return True;
+ }
+
+ len = sizeof(XIMHotKeyTriggers) + sizeof(XIMHotKeyTrigger) * num;
+ if(!(tmp = (XPointer)Xmalloc(len))) {
+ return False;
+ }
+
+ key_list = (XIMHotKeyTriggers *)tmp;
+ key = (XIMHotKeyTrigger *)((char *)tmp + sizeof(XIMHotKeyTriggers));
+
+ for(i = 0; i < num; i++) {
+ key[i] = hotkey->key[i];
+ }
+
+ key_list->num_hot_key = num;
+ key_list->key = key;
+
+ out = (XIMHotKeyTriggers **)((char *)top + info->offset);
+ *out = key_list;
+ return True;
+}
+
+Private Bool
+_XimEncodeHotKetState(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMHotKeyState *out;
+
+ out = (XIMHotKeyState *)((char *)top + info->offset);
+ *out = (XIMHotKeyState)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeRectangle(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XRectangle *out;
+
+ out = (XRectangle *)((char *)top + info->offset);
+ *out = *((XRectangle *)val);
+ return True;
+}
+
+Private Bool
+_XimEncodeSpot(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XPoint *out;
+
+ out = (XPoint *)((char *)top + info->offset);
+ *out = *((XPoint *)val);
+ return True;
+}
+
+Private Bool
+_XimEncodeColormap(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ Colormap *out;
+
+ out = (Colormap *)((char *)top + info->offset);
+ *out = (Colormap)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeStdColormap(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ Atom *out;
+
+ out = (Atom *)((char *)top + info->offset);
+ *out = (Atom)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeLong(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ unsigned long *out;
+
+ out = (unsigned long *)((char *)top + info->offset);
+ *out = (unsigned long)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeBgPixmap(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ Pixmap *out;
+
+ out = (Pixmap *)((char *)top + info->offset);
+ *out = (Pixmap)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeFontSet(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XFontSet *out;
+
+ out = (XFontSet *)((char *)top + info->offset);
+ *out = (XFontSet)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeLineSpace(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ int *out;
+
+ out = (int *)((char *)top + info->offset);
+ *out = (long)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeCursor(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ Cursor *out;
+
+ out = (Cursor *)((char *)top + info->offset);
+ *out = (Cursor)val;
+ return True;
+}
+
+Private Bool
+_XimEncodePreeditState(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMPreeditState *out;
+
+ out = (XIMPreeditState *)((char *)top + info->offset);
+ *out = (XIMPreeditState)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeNest(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ return True;
+}
+
+Private Bool
+_XimDecodeStyles(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMStyles *styles;
+ XIMStyles *out;
+ register int i;
+ unsigned int num;
+ int len;
+ XPointer tmp;
+
+ if(val == (XPointer)NULL) {
+ return False;
+ }
+
+ styles = *((XIMStyles **)((char *)top + info->offset));
+ num = styles->count_styles;
+
+ len = sizeof(XIMStyles) + sizeof(XIMStyle) * num;
+ if(!(tmp = (XPointer)Xmalloc(len))) {
+ return False;
+ }
+ bzero(tmp, len);
+
+ out = (XIMStyles *)tmp;
+ if(num >0) {
+ out->count_styles = (unsigned short)num;
+ out->supported_styles = (XIMStyle *)((char *)tmp + sizeof(XIMStyles));
+
+ for(i = 0; i < num; i++) {
+ out->supported_styles[i] = styles->supported_styles[i];
+ }
+ }
+ *((XIMStyles **)val) = out;
+ return True;
+}
+
+Private Bool
+_XimDecodeValues(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMValuesList *values_list;
+ XIMValuesList *out;
+ register int i;
+ unsigned int num;
+ int len;
+ XPointer tmp;
+
+ if(val == (XPointer)NULL) {
+ return False;
+ }
+
+ values_list = *((XIMValuesList **)((char *)top + info->offset));
+ num = values_list->count_values;
+
+ len = sizeof(XIMValuesList) + sizeof(char **) * num;
+ if(!(tmp = (char *)Xmalloc(len))) {
+ return False;
+ }
+ bzero(tmp, len);
+
+ out = (XIMValuesList *)tmp;
+ if(num) {
+ out->count_values = (unsigned short)num;
+ out->supported_values = (char **)((char *)tmp + sizeof(XIMValuesList));
+
+ for(i = 0; i < num; i++) {
+ out->supported_values[i] = values_list->supported_values[i];
+ }
+ }
+ *((XIMValuesList **)val) = out;
+ return True;
+}
+
+Private Bool
+_XimDecodeCallback(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMCallback *in;
+ XIMCallback *callback;
+
+ in = (XIMCallback *)((char *)top + info->offset);
+ if(!(callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback)))) {
+ return False;
+ }
+ callback->client_data = in->client_data;
+ callback->callback = in->callback;
+
+ *((XIMCallback **)val) = callback;
+ return True;
+}
+
+Private Bool
+_XimDecodeString(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ int len = 0;
+ char *in;
+ char *string;
+
+ in = *((char **)((char *)top + info->offset));
+ if(in != (char *)NULL) {
+ len = strlen(in);
+ }
+ if(!(string = (char *)Xmalloc(len + 1))) {
+ return False;
+ }
+ if(in != (char *)NULL) {
+ (void)strcpy(string, in);
+ }
+ string[len] = '\0';
+ *((char **)val) = string;
+ return True;
+}
+
+Private Bool
+_XimDecodeBool(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ Bool *in;
+
+ in = (Bool *)((char *)top + info->offset);
+ *((Bool *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeStyle(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMStyle *in;
+
+ in = (XIMStyle *)((char *)top + info->offset);
+ *((XIMStyle *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeWindow(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ Window *in;
+
+ in = (Window *)((char *)top + info->offset);
+ *((Window *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeStringConv(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ /*
+ * Not yet
+ */
+ return True;
+}
+
+Private Bool
+_XimDecodeResetState(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMResetState *in;
+
+ in = (XIMResetState *)((char *)top + info->offset);
+ *((XIMResetState *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeHotKey(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMHotKeyTriggers *in;
+ XIMHotKeyTriggers *hotkey;
+ XIMHotKeyTrigger *key;
+ XPointer tmp;
+ int num;
+ int len;
+ register int i;
+
+ in = *((XIMHotKeyTriggers **)((char *)top + info->offset));
+ num = in->num_hot_key;
+ len = sizeof(XIMHotKeyTriggers) + sizeof(XIMHotKeyTrigger) * num;
+ if(!(tmp = (XPointer)Xmalloc(len))) {
+ return False;
+ }
+
+ hotkey = (XIMHotKeyTriggers *)tmp;
+ key = (XIMHotKeyTrigger *)((char *)tmp + sizeof(XIMHotKeyTriggers));
+
+ for(i = 0; i < num; i++) {
+ key[i] = in->key[i];
+ }
+ hotkey->num_hot_key = num;
+ hotkey->key = key;
+
+ *((XIMHotKeyTriggers **)val) = hotkey;
+ return True;
+}
+
+Private Bool
+_XimDecodeHotKetState(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMHotKeyState *in;
+
+ in = (XIMHotKeyState *)((char *)top + info->offset);
+ *((XIMHotKeyState *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeRectangle(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XRectangle *in;
+ XRectangle *rect;
+
+ in = (XRectangle *)((char *)top + info->offset);
+ if(!(rect = (XRectangle *)Xmalloc(sizeof(XRectangle)))) {
+ return False;
+ }
+ *rect = *in;
+ *((XRectangle **)val) = rect;
+ return True;
+}
+
+Private Bool
+_XimDecodeSpot(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XPoint *in;
+ XPoint *spot;
+
+ in = (XPoint *)((char *)top + info->offset);
+ if(!(spot = (XPoint *)Xmalloc(sizeof(XPoint)))) {
+ return False;
+ }
+ *spot = *in;
+ *((XPoint **)val) = spot;
+ return True;
+}
+
+Private Bool
+_XimDecodeColormap(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ Colormap *in;
+
+ in = (Colormap *)((char *)top + info->offset);
+ *((Colormap *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeStdColormap(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ Atom *in;
+
+ in = (Atom *)((char *)top + info->offset);
+ *((Atom *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeLong(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ unsigned long *in;
+
+ in = (unsigned long *)((char *)top + info->offset);
+ *((unsigned long *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeBgPixmap(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ Pixmap *in;
+
+ in = (Pixmap *)((char *)top + info->offset);
+ *((Pixmap *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeFontSet(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XFontSet *in;
+
+ in = (XFontSet *)((char *)top + info->offset);
+ *((XFontSet *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeLineSpace(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ int *in;
+
+ in = (int *)((char *)top + info->offset);
+ *((int *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeCursor(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ Cursor *in;
+
+ in = (Cursor *)((char *)top + info->offset);
+ *((Cursor *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodePreeditState(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ XIMPreeditState *in;
+
+ in = (XIMPreeditState *)((char *)top + info->offset);
+ *((XIMPreeditState *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeNest(
+ XimValueOffsetInfo info,
+ XPointer top,
+ XPointer val)
+{
+ return True;
+}
+
+static XIMResource im_resources[] = {
+ {XNQueryInputStyle, 0, XimType_XIMStyles, 0, 0, 0},
+ {XNDestroyCallback, 0, 0, 0, 0, 0},
+ {XNResourceName, 0, XimType_STRING8, 0, 0, 0},
+ {XNResourceClass, 0, XimType_STRING8, 0, 0, 0},
+ {XNQueryIMValuesList, 0, 0, 0, 0, 0},
+ {XNQueryICValuesList, 0, 0, 0, 0, 0},
+ {XNVisiblePosition, 0, 0, 0, 0, 0}
+};
+
+static XIMResource im_inner_resources[] = {
+ {XNDestroyCallback, 0, 0, 0, 0, 0},
+ {XNResourceName, 0, XimType_STRING8, 0, 0, 0},
+ {XNResourceClass, 0, XimType_STRING8, 0, 0, 0},
+ {XNQueryIMValuesList, 0, 0, 0, 0, 0},
+ {XNQueryICValuesList, 0, 0, 0, 0, 0},
+ {XNVisiblePosition, 0, 0, 0, 0, 0}
+};
+
+static XIMResource ic_resources[] = {
+ {XNInputStyle, 0, XimType_CARD32, 0, 0, 0},
+ {XNClientWindow, 0, XimType_Window, 0, 0, 0},
+ {XNFocusWindow, 0, XimType_Window, 0, 0, 0},
+ {XNResourceName, 0, XimType_STRING8, 0, 0, 0},
+ {XNResourceClass, 0, XimType_STRING8, 0, 0, 0},
+ {XNGeometryCallback, 0, 0, 0, 0, 0},
+ {XNFilterEvents, 0, XimType_CARD32, 0, 0, 0},
+ {XNDestroyCallback, 0, 0, 0, 0, 0},
+ {XNStringConversionCallback, 0, 0, 0, 0, 0},
+ {XNStringConversion, 0, XimType_XIMStringConversion,0, 0, 0},
+ {XNResetState, 0, 0, 0, 0, 0},
+ {XNHotKey, 0, XimType_XIMHotKeyTriggers,0, 0, 0},
+ {XNHotKeyState, 0, XimType_XIMHotKeyState, 0, 0, 0},
+ {XNPreeditAttributes, 0, XimType_NEST, 0, 0, 0},
+ {XNStatusAttributes, 0, XimType_NEST, 0, 0, 0},
+ {XNArea, 0, XimType_XRectangle, 0, 0, 0},
+ {XNAreaNeeded, 0, XimType_XRectangle, 0, 0, 0},
+ {XNSpotLocation, 0, XimType_XPoint, 0, 0, 0},
+ {XNColormap, 0, XimType_CARD32, 0, 0, 0},
+ {XNStdColormap, 0, XimType_CARD32, 0, 0, 0},
+ {XNForeground, 0, XimType_CARD32, 0, 0, 0},
+ {XNBackground, 0, XimType_CARD32, 0, 0, 0},
+ {XNBackgroundPixmap, 0, XimType_CARD32, 0, 0, 0},
+ {XNFontSet, 0, XimType_XFontSet, 0, 0, 0},
+ {XNLineSpace, 0, XimType_CARD32, 0, 0, 0},
+ {XNCursor, 0, XimType_CARD32, 0, 0, 0},
+ {XNPreeditStartCallback, 0, 0, 0, 0, 0},
+ {XNPreeditDoneCallback, 0, 0, 0, 0, 0},
+ {XNPreeditDrawCallback, 0, 0, 0, 0, 0},
+ {XNPreeditCaretCallback, 0, 0, 0, 0, 0},
+ {XNStatusStartCallback, 0, 0, 0, 0, 0},
+ {XNStatusDoneCallback, 0, 0, 0, 0, 0},
+ {XNStatusDrawCallback, 0, 0, 0, 0, 0},
+ {XNPreeditState, 0, 0, 0, 0, 0},
+ {XNPreeditStateNotifyCallback, 0, 0, 0, 0, 0},
+};
+
+static XIMResource ic_inner_resources[] = {
+ {XNResourceName, 0, XimType_STRING8, 0, 0, 0},
+ {XNResourceClass, 0, XimType_STRING8, 0, 0, 0},
+ {XNGeometryCallback, 0, 0, 0, 0, 0},
+ {XNDestroyCallback, 0, 0, 0, 0, 0},
+ {XNStringConversionCallback, 0, 0, 0, 0, 0},
+ {XNPreeditStartCallback, 0, 0, 0, 0, 0},
+ {XNPreeditDoneCallback, 0, 0, 0, 0, 0},
+ {XNPreeditDrawCallback, 0, 0, 0, 0, 0},
+ {XNPreeditCaretCallback, 0, 0, 0, 0, 0},
+ {XNStatusStartCallback, 0, 0, 0, 0, 0},
+ {XNStatusDoneCallback, 0, 0, 0, 0, 0},
+ {XNStatusDrawCallback, 0, 0, 0, 0, 0},
+ {XNPreeditStateNotifyCallback, 0, 0, 0, 0, 0},
+};
+
+static XimValueOffsetInfoRec im_attr_info[] = {
+ {OFFSET_XNQUERYINPUTSTYLE, 0,
+ XOffsetOf(XimDefIMValues, styles),
+ _XimDefaultStyles, NULL, _XimDecodeStyles},
+
+ {OFFSET_XNDESTROYCALLBACK, 0,
+ XOffsetOf(XimDefIMValues, destroy_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {OFFSET_XNRESOURCENAME, 0,
+ XOffsetOf(XimDefIMValues, res_name),
+ NULL, _XimEncodeString, _XimDecodeString},
+
+ {OFFSET_XNRESOURCECLASS, 0,
+ XOffsetOf(XimDefIMValues, res_class),
+ NULL, _XimEncodeString, _XimDecodeString},
+
+ {OFFSET_XNQUERYIMVALUESLIST, 0,
+ XOffsetOf(XimDefIMValues, im_values_list),
+ _XimDefaultIMValues, NULL, _XimDecodeValues},
+
+ {OFFSET_XNQUERYICVALUESLIST, 0,
+ XOffsetOf(XimDefIMValues, ic_values_list),
+ _XimDefaultICValues, NULL, _XimDecodeValues},
+
+ {OFFSET_XNVISIBLEPOSITION, 0,
+ XOffsetOf(XimDefIMValues, visible_position),
+ _XimDefaultVisiblePos, NULL, _XimDecodeBool}
+};
+
+static XimValueOffsetInfoRec ic_attr_info[] = {
+ {OFFSET_XNINPUTSTYLE, 0,
+ XOffsetOf(XimDefICValues, input_style),
+ NULL, _XimEncodeStyle, _XimDecodeStyle},
+
+ {OFFSET_XNCLIENTWINDOW, 0,
+ XOffsetOf(XimDefICValues, client_window),
+ NULL, _XimEncodeWindow, _XimDecodeWindow},
+
+ {OFFSET_XNFOCUSWINDOW, 0,
+ XOffsetOf(XimDefICValues, focus_window),
+ _XimDefaultFocusWindow, _XimEncodeWindow, _XimDecodeWindow},
+
+ {OFFSET_XNRESOURCENAME, 0,
+ XOffsetOf(XimDefICValues, res_name),
+ _XimDefaultResName, _XimEncodeString, _XimDecodeString},
+
+ {OFFSET_XNRESOURCECLASS, 0,
+ XOffsetOf(XimDefICValues, res_class),
+ _XimDefaultResClass, _XimEncodeString, _XimDecodeString},
+
+ {OFFSET_XNGEOMETRYCALLBACK, 0,
+ XOffsetOf(XimDefICValues, geometry_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {OFFSET_XNFILTEREVENTS, 0,
+ XOffsetOf(XimDefICValues, filter_events),
+ NULL, NULL, _XimDecodeLong},
+
+ {OFFSET_XNDESTROYCALLBACK, 0,
+ XOffsetOf(XimDefICValues, destroy_callback),
+ _XimDefaultDestroyCB, _XimEncodeCallback, _XimDecodeCallback},
+
+ {OFFSET_XNSTRINGCONVERSIONCALLBACK, 0,
+ XOffsetOf(XimDefICValues, string_conversion_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {OFFSET_XNSTRINGCONVERSION, 0,
+ XOffsetOf(XimDefICValues, string_conversion),
+ NULL, _XimEncodeStringConv, _XimDecodeStringConv},
+
+ {OFFSET_XNRESETSTATE, 0,
+ XOffsetOf(XimDefICValues, reset_state),
+ _XimDefaultResetState, _XimEncodeResetState, _XimDecodeResetState},
+
+ {OFFSET_XNHOTKEY, 0,
+ XOffsetOf(XimDefICValues, hotkey),
+ NULL, _XimEncodeHotKey, _XimDecodeHotKey},
+
+ {OFFSET_XNHOTKEYSTATE, 0,
+ XOffsetOf(XimDefICValues, hotkey_state),
+ _XimDefaultHotKeyState, _XimEncodeHotKetState, _XimDecodeHotKetState},
+
+ {OFFSET_XNPREEDITATTRIBUTES, 0,
+ XOffsetOf(XimDefICValues, preedit_attr),
+ _XimDefaultNest, _XimEncodeNest, _XimDecodeNest},
+
+ {OFFSET_XNSTATUSATTRIBUTES, 0,
+ XOffsetOf(XimDefICValues, status_attr),
+ _XimDefaultNest, _XimEncodeNest, _XimDecodeNest},
+};
+
+static XimValueOffsetInfoRec ic_pre_attr_info[] = {
+ {OFFSET_XNAREA, 0,
+ XOffsetOf(ICPreeditAttributes, area),
+ _XimDefaultArea, _XimEncodeRectangle, _XimDecodeRectangle},
+
+ {OFFSET_XNAREANEEDED, 0,
+ XOffsetOf(ICPreeditAttributes, area_needed),
+ NULL, _XimEncodeRectangle, _XimDecodeRectangle},
+
+ {OFFSET_XNSPOTLOCATION, 0,
+ XOffsetOf(ICPreeditAttributes, spot_location),
+ NULL, _XimEncodeSpot, _XimDecodeSpot},
+
+ {OFFSET_XNCOLORMAP, 0,
+ XOffsetOf(ICPreeditAttributes, colormap),
+ _XimDefaultColormap, _XimEncodeColormap, _XimDecodeColormap},
+
+ {OFFSET_XNSTDCOLORMAP, 0,
+ XOffsetOf(ICPreeditAttributes, std_colormap),
+ _XimDefaultStdColormap, _XimEncodeStdColormap, _XimDecodeStdColormap},
+
+ {OFFSET_XNFOREGROUND, 0,
+ XOffsetOf(ICPreeditAttributes, foreground),
+ _XimDefaultFg, _XimEncodeLong, _XimDecodeLong},
+
+ {OFFSET_XNBACKGROUND, 0,
+ XOffsetOf(ICPreeditAttributes, background),
+ _XimDefaultBg, _XimEncodeLong, _XimDecodeLong},
+
+ {OFFSET_XNBACKGROUNDPIXMAP, 0,
+ XOffsetOf(ICPreeditAttributes, background_pixmap),
+ _XimDefaultBgPixmap, _XimEncodeBgPixmap, _XimDecodeBgPixmap},
+
+ {OFFSET_XNFONTSET, 0,
+ XOffsetOf(ICPreeditAttributes, fontset),
+ _XimDefaultFontSet, _XimEncodeFontSet, _XimDecodeFontSet},
+
+ {OFFSET_XNLINESPACE, 0,
+ XOffsetOf(ICPreeditAttributes, line_spacing),
+ _XimDefaultLineSpace, _XimEncodeLineSpace, _XimDecodeLineSpace},
+
+ {OFFSET_XNCURSOR, 0,
+ XOffsetOf(ICPreeditAttributes, cursor),
+ _XimDefaultCursor, _XimEncodeCursor, _XimDecodeCursor},
+
+ {OFFSET_XNPREEDITSTARTCALLBACK, 0,
+ XOffsetOf(ICPreeditAttributes, start_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {OFFSET_XNPREEDITDONECALLBACK, 0,
+ XOffsetOf(ICPreeditAttributes, done_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {OFFSET_XNPREEDITDRAWCALLBACK, 0,
+ XOffsetOf(ICPreeditAttributes, draw_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {OFFSET_XNPREEDITCARETCALLBACK, 0,
+ XOffsetOf(ICPreeditAttributes, caret_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {OFFSET_XNPREEDITSTATE, 0,
+ XOffsetOf(ICPreeditAttributes, preedit_state),
+ _XimDefaultPreeditState, _XimEncodePreeditState,_XimDecodePreeditState},
+
+ {OFFSET_XNPREEDITSTATENOTIFYCALLBACK, 0,
+ XOffsetOf(ICPreeditAttributes, state_notify_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+};
+
+static XimValueOffsetInfoRec ic_sts_attr_info[] = {
+ {OFFSET_XNAREA, 0,
+ XOffsetOf(ICStatusAttributes, area),
+ _XimDefaultArea, _XimEncodeRectangle, _XimDecodeRectangle},
+
+ {OFFSET_XNAREANEEDED, 0,
+ XOffsetOf(ICStatusAttributes, area_needed),
+ NULL, _XimEncodeRectangle, _XimDecodeRectangle},
+
+ {OFFSET_XNCOLORMAP, 0,
+ XOffsetOf(ICStatusAttributes, colormap),
+ _XimDefaultColormap, _XimEncodeColormap, _XimDecodeColormap},
+
+ {OFFSET_XNSTDCOLORMAP, 0,
+ XOffsetOf(ICStatusAttributes, std_colormap),
+ _XimDefaultStdColormap, _XimEncodeStdColormap, _XimDecodeStdColormap},
+
+ {OFFSET_XNFOREGROUND, 0,
+ XOffsetOf(ICStatusAttributes, foreground),
+ _XimDefaultFg, _XimEncodeLong, _XimDecodeLong},
+
+ {OFFSET_XNBACKGROUND, 0,
+ XOffsetOf(ICStatusAttributes, background),
+ _XimDefaultBg, _XimEncodeLong, _XimDecodeLong},
+
+ {OFFSET_XNBACKGROUNDPIXMAP, 0,
+ XOffsetOf(ICStatusAttributes, background_pixmap),
+ _XimDefaultBgPixmap, _XimEncodeBgPixmap, _XimDecodeBgPixmap},
+
+ {OFFSET_XNFONTSET, 0,
+ XOffsetOf(ICStatusAttributes, fontset),
+ _XimDefaultFontSet, _XimEncodeFontSet, _XimDecodeFontSet},
+
+ {OFFSET_XNLINESPACE, 0,
+ XOffsetOf(ICStatusAttributes, line_spacing),
+ _XimDefaultLineSpace, _XimEncodeLineSpace, _XimDecodeLineSpace},
+
+ {OFFSET_XNCURSOR, 0,
+ XOffsetOf(ICStatusAttributes, cursor),
+ _XimDefaultCursor, _XimEncodeCursor, _XimDecodeCursor},
+
+ {OFFSET_XNSTATUSSTARTCALLBACK, 0,
+ XOffsetOf(ICStatusAttributes, start_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {OFFSET_XNSTATUSDONECALLBACK, 0,
+ XOffsetOf(ICStatusAttributes, done_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {OFFSET_XNSTATUSDRAWCALLBACK, 0,
+ XOffsetOf(ICStatusAttributes, draw_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback}
+};
+
+typedef struct _XimIMMode {
+ unsigned short name_offset;
+ unsigned short mode;
+} XimIMMode;
+
+static const XimIMMode im_mode[] = {
+ {OFFSET_XNQUERYINPUTSTYLE,
+ (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_GET)},
+ {OFFSET_XNDESTROYCALLBACK,
+ (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_SET | XIM_MODE_IM_GET)},
+ {OFFSET_XNRESOURCENAME,
+ (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_SET | XIM_MODE_IM_GET)},
+ {OFFSET_XNRESOURCECLASS,
+ (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_SET | XIM_MODE_IM_GET)},
+ {OFFSET_XNQUERYIMVALUESLIST,
+ (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_GET)},
+ {OFFSET_XNQUERYICVALUESLIST,
+ (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_GET)},
+ {OFFSET_XNVISIBLEPOSITION,
+ (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_GET)}
+};
+
+typedef struct _XimICMode {
+ unsigned short name_offset;
+ unsigned short preedit_callback_mode;
+ unsigned short preedit_position_mode;
+ unsigned short preedit_area_mode;
+ unsigned short preedit_nothing_mode;
+ unsigned short preedit_none_mode;
+ unsigned short status_callback_mode;
+ unsigned short status_area_mode;
+ unsigned short status_nothing_mode;
+ unsigned short status_none_mode;
+} XimICMode;
+
+static const XimICMode ic_mode[] = {
+ {OFFSET_XNINPUTSTYLE,
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET),
+ (XIM_MODE_STS_CREATE | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_CREATE | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_CREATE | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_CREATE | XIM_MODE_STS_GET)},
+ {OFFSET_XNCLIENTWINDOW,
+ (XIM_MODE_PRE_ONCE | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_ONCE | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_ONCE | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_ONCE | XIM_MODE_PRE_GET),
+ 0,
+ (XIM_MODE_STS_ONCE | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_ONCE | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_ONCE | XIM_MODE_STS_GET),
+ 0},
+ {OFFSET_XNFOCUSWINDOW,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {OFFSET_XNRESOURCENAME,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {OFFSET_XNRESOURCECLASS,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {OFFSET_XNGEOMETRYCALLBACK,
+ 0,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0,
+ 0},
+ {OFFSET_XNFILTEREVENTS,
+ XIM_MODE_PRE_GET,
+ XIM_MODE_PRE_GET,
+ XIM_MODE_PRE_GET,
+ XIM_MODE_PRE_GET,
+ 0,
+ XIM_MODE_STS_GET,
+ XIM_MODE_STS_GET,
+ XIM_MODE_STS_GET,
+ XIM_MODE_STS_GET},
+ {OFFSET_XNDESTROYCALLBACK,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0},
+ {OFFSET_XNSTRINGCONVERSIONCALLBACK,
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0},
+ {OFFSET_XNSTRINGCONVERSION,
+ XIM_MODE_PRE_SET,
+ XIM_MODE_PRE_SET,
+ XIM_MODE_PRE_SET,
+ XIM_MODE_PRE_SET,
+ XIM_MODE_PRE_SET,
+ 0,
+ 0,
+ 0,
+ 0},
+ {OFFSET_XNRESETSTATE,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {OFFSET_XNHOTKEY,
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {OFFSET_XNHOTKEYSTATE,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {OFFSET_XNPREEDITATTRIBUTES,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {OFFSET_XNSTATUSATTRIBUTES,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {OFFSET_XNAREA,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0,
+ 0},
+ {OFFSET_XNAREANEEDED,
+ 0,
+ 0,
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ (XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0,
+ 0},
+ {OFFSET_XNSPOTLOCATION,
+ 0, /*(XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),*/
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0},
+ {OFFSET_XNCOLORMAP,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {OFFSET_XNSTDCOLORMAP,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {OFFSET_XNFOREGROUND,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {OFFSET_XNBACKGROUND,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {OFFSET_XNBACKGROUNDPIXMAP,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {OFFSET_XNFONTSET,
+ 0,
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_CREATE | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {OFFSET_XNLINESPACE,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {OFFSET_XNCURSOR,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {OFFSET_XNPREEDITSTARTCALLBACK,
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {OFFSET_XNPREEDITDONECALLBACK,
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {OFFSET_XNPREEDITDRAWCALLBACK,
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {OFFSET_XNPREEDITCARETCALLBACK,
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {OFFSET_XNPREEDITSTATE,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {OFFSET_XNPREEDITSTATENOTIFYCALLBACK,
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {OFFSET_XNSTATUSSTARTCALLBACK,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ (XIM_MODE_STS_CREATE | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0,
+ 0,
+ 0},
+ {OFFSET_XNSTATUSDONECALLBACK,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ (XIM_MODE_STS_CREATE | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0,
+ 0,
+ 0},
+ {OFFSET_XNSTATUSDRAWCALLBACK,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ (XIM_MODE_STS_CREATE | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0,
+ 0,
+ 0}
+};
+
+/* the quarks are separated from im_mode/ic_mode so those arrays
+ * can be const.
+ */
+static XrmQuark im_mode_quark[sizeof(im_mode) / sizeof(im_mode[0])];
+static XrmQuark ic_mode_quark[sizeof(ic_mode) / sizeof(ic_mode[0])];
+
+Private Bool
+_XimSetResourceList(
+ XIMResourceList *res_list,
+ unsigned int *list_num,
+ XIMResourceList resource,
+ unsigned int num_resource,
+ unsigned short id)
+{
+ register int i;
+ int len;
+ XIMResourceList res;
+
+ len = sizeof(XIMResource) * num_resource;
+ if(!(res = (XIMResourceList)Xmalloc(len))) {
+ return False;
+ }
+ bzero((char *)res, len);
+
+ for(i = 0; i < num_resource; i++, id++) {
+ res[i] = resource[i];
+ res[i].id = id;
+ }
+
+ _XIMCompileResourceList(res, num_resource);
+ *res_list = res;
+ *list_num = num_resource;
+ return True;
+}
+
+Public Bool
+_XimSetIMResourceList(
+ XIMResourceList *res_list,
+ unsigned int *list_num)
+{
+ return _XimSetResourceList(res_list, list_num,
+ im_resources, XIMNumber(im_resources), 100);
+}
+
+Public Bool
+_XimSetICResourceList(
+ XIMResourceList *res_list,
+ unsigned int *list_num)
+{
+ return _XimSetResourceList(res_list, list_num,
+ ic_resources, XIMNumber(ic_resources), 200);
+}
+
+Public Bool
+_XimSetInnerIMResourceList(
+ XIMResourceList *res_list,
+ unsigned int *list_num)
+{
+ return _XimSetResourceList(res_list, list_num,
+ im_inner_resources, XIMNumber(im_inner_resources), 100);
+}
+
+Public Bool
+_XimSetInnerICResourceList(
+ XIMResourceList *res_list,
+ unsigned int *list_num)
+{
+ return _XimSetResourceList(res_list, list_num,
+ ic_inner_resources, XIMNumber(ic_inner_resources), 200);
+}
+
+Private XIMResourceList
+_XimGetResourceListRecByMode(
+ XIMResourceList res_list,
+ unsigned int list_num,
+ unsigned short mode)
+{
+ register int i;
+
+ for(i = 0; i < list_num; i++) {
+ if (res_list[i].mode & mode) {
+ return (XIMResourceList)&res_list[i];
+ }
+ }
+ return (XIMResourceList)NULL;
+}
+
+Public Bool
+_XimCheckCreateICValues(
+ XIMResourceList res_list,
+ unsigned int list_num)
+{
+ if (!_XimGetResourceListRecByMode(res_list, list_num, XIM_MODE_IC_CREATE)) {
+ return True;
+ }
+ return False;
+}
+
+Public XIMResourceList
+_XimGetResourceListRecByQuark(
+ XIMResourceList res_list,
+ unsigned int list_num,
+ XrmQuark quark)
+{
+ register int i;
+
+ for(i = 0; i < list_num; i++) {
+ if (res_list[i].xrm_name == quark) {
+ return (XIMResourceList)&res_list[i];
+ }
+ }
+ return (XIMResourceList)NULL;
+}
+
+Public XIMResourceList
+_XimGetResourceListRec(
+ XIMResourceList res_list,
+ unsigned int list_num,
+ const char *name)
+{
+ XrmQuark quark = XrmStringToQuark(name);
+
+ return _XimGetResourceListRecByQuark(res_list, list_num, quark);
+}
+
+Public char *
+_XimSetIMValueData(
+ Xim im,
+ XPointer top,
+ XIMArg *values,
+ XIMResourceList res_list,
+ unsigned int list_num)
+{
+ register XIMArg *p;
+ XIMResourceList res;
+ int check;
+
+ for(p = values; p->name != NULL; p++) {
+ if(!(res = _XimGetResourceListRec(res_list, list_num, p->name))) {
+ return p->value;
+ }
+ check = _XimCheckIMMode(res, XIM_SETIMVALUES);
+ if(check == XIM_CHECK_INVALID) {
+ continue;
+ } else if (check == XIM_CHECK_ERROR) {
+ return p->value;
+ }
+
+ if(!_XimEncodeLocalIMAttr(res, top, p->value)) {
+ return p->value;
+ }
+ }
+ return NULL;
+}
+
+Public char *
+_XimGetIMValueData(
+ Xim im,
+ XPointer top,
+ XIMArg *values,
+ XIMResourceList res_list,
+ unsigned int list_num)
+{
+ register XIMArg *p;
+ XIMResourceList res;
+ int check;
+
+ for(p = values; p->name != NULL; p++) {
+ if(!(res = _XimGetResourceListRec(res_list, list_num, p->name))) {
+ return p->value;
+ }
+ check = _XimCheckIMMode(res, XIM_GETIMVALUES);
+ if(check == XIM_CHECK_INVALID) {
+ continue;
+ } else if (check == XIM_CHECK_ERROR) {
+ return p->value;
+ }
+
+ if(!_XimDecodeLocalIMAttr(res, top, p->value)) {
+ return p->value;
+ }
+ }
+ return NULL;
+}
+
+Public void
+_XimSetIMMode(
+ XIMResourceList res_list,
+ unsigned int list_num)
+{
+ XIMResourceList res;
+ unsigned int n = XIMNumber(im_mode);
+ register int i;
+
+ for(i = 0; i < n; i++) {
+ if(!(res = _XimGetResourceListRecByQuark(res_list,
+ list_num, im_mode_quark[i]))) {
+ continue;
+ }
+ res->mode = im_mode[i].mode;
+ }
+ return;
+}
+
+Private int
+_XimCheckSetIMDefaultsMode(
+ XIMResourceList res)
+{
+ if(res->mode & XIM_MODE_IM_DEFAULT) {
+ return XIM_CHECK_VALID;
+ }
+ return XIM_CHECK_INVALID;
+}
+
+Private int
+_XimCheckSetIMValuesMode(
+ XIMResourceList res)
+{
+ if(res->mode & XIM_MODE_IM_SET) {
+ return XIM_CHECK_VALID;
+ }
+ return XIM_CHECK_INVALID;
+}
+
+Private int
+ _XimCheckGetIMValuesMode(
+ XIMResourceList res)
+{
+ if(res->mode & XIM_MODE_IM_GET) {
+ return XIM_CHECK_VALID;
+ }
+ return XIM_CHECK_INVALID;
+}
+
+Public int
+ _XimCheckIMMode(
+ XIMResourceList res,
+ unsigned long mode)
+{
+ if(res->mode == 0) {
+ return XIM_CHECK_INVALID;
+ }
+ if(mode & XIM_SETIMDEFAULTS) {
+ return _XimCheckSetIMDefaultsMode(res);
+ } else if (mode & XIM_SETIMVALUES) {
+ return _XimCheckSetIMValuesMode(res);
+ } else if (mode & XIM_GETIMVALUES) {
+ return _XimCheckGetIMValuesMode(res);
+ } else {
+ return XIM_CHECK_ERROR;
+ }
+}
+
+Public void
+_XimSetICMode(XIMResourceList res_list, unsigned int list_num, XIMStyle style)
+{
+ XIMResourceList res;
+ unsigned int n = XIMNumber(ic_mode);
+ register int i;
+ unsigned int pre_offset;
+ unsigned int sts_offset;
+
+ if(style & XIMPreeditArea) {
+ pre_offset = XOffsetOf(XimICMode, preedit_area_mode);
+ } else if(style & XIMPreeditCallbacks) {
+ pre_offset = XOffsetOf(XimICMode, preedit_callback_mode);
+ } else if(style & XIMPreeditPosition) {
+ pre_offset = XOffsetOf(XimICMode, preedit_position_mode);
+ } else if(style & XIMPreeditNothing) {
+ pre_offset = XOffsetOf(XimICMode, preedit_nothing_mode);
+ } else {
+ pre_offset = XOffsetOf(XimICMode, preedit_none_mode);
+ }
+
+ if(style & XIMStatusArea) {
+ sts_offset = XOffsetOf(XimICMode, status_area_mode);
+ } else if(style & XIMStatusCallbacks) {
+ sts_offset = XOffsetOf(XimICMode, status_callback_mode);
+ } else if(style & XIMStatusNothing) {
+ sts_offset = XOffsetOf(XimICMode, status_nothing_mode);
+ } else {
+ sts_offset = XOffsetOf(XimICMode, status_none_mode);
+ }
+
+ for(i = 0; i < n; i++) {
+ if(!(res = _XimGetResourceListRecByQuark(res_list,
+ list_num, ic_mode_quark[i]))) {
+ continue;
+ }
+ res->mode = ( (*(unsigned short *)((char *)&ic_mode[i] + pre_offset))
+ | (*(unsigned short *)((char *)&ic_mode[i] + sts_offset)));
+ }
+ return;
+}
+
+Private int
+_XimCheckSetICDefaultsMode(
+ XIMResourceList res,
+ unsigned long mode)
+{
+ if(mode & XIM_PREEDIT_ATTR) {
+ if(!(res->mode & XIM_MODE_PRE_MASK)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_PRE_CREATE) {
+ return XIM_CHECK_ERROR;
+ } else if (!(res->mode & XIM_MODE_PRE_DEFAULT)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ } else if(mode & XIM_STATUS_ATTR) {
+ if(!(res->mode & XIM_MODE_STS_MASK)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_STS_CREATE) {
+ return XIM_CHECK_ERROR;
+ }
+ if(!(res->mode & XIM_MODE_STS_DEFAULT)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ } else {
+ if(!res->mode) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_IC_CREATE) {
+ return XIM_CHECK_ERROR;
+ }
+ if(!(res->mode & XIM_MODE_IC_DEFAULT)) {
+ return XIM_CHECK_INVALID;
+ }
+ }
+ return XIM_CHECK_VALID;
+}
+
+Private int
+_XimCheckCreateICMode(
+ XIMResourceList res,
+ unsigned long mode)
+{
+ if(mode & XIM_PREEDIT_ATTR) {
+ if(!(res->mode & XIM_MODE_PRE_MASK)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_PRE_CREATE) {
+ res->mode &= ~XIM_MODE_PRE_CREATE;
+ } else if(res->mode & XIM_MODE_PRE_ONCE) {
+ res->mode &= ~XIM_MODE_PRE_ONCE;
+ } else if(res->mode & XIM_MODE_PRE_DEFAULT) {
+ res->mode &= ~XIM_MODE_PRE_DEFAULT;
+ } else if (!(res->mode & XIM_MODE_PRE_SET)) {
+ return XIM_CHECK_ERROR;
+ }
+
+ } else if(mode & XIM_STATUS_ATTR) {
+ if(!(res->mode & XIM_MODE_STS_MASK)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_STS_CREATE) {
+ res->mode &= ~XIM_MODE_STS_CREATE;
+ } else if(res->mode & XIM_MODE_STS_ONCE) {
+ res->mode &= ~XIM_MODE_STS_ONCE;
+ } else if(res->mode & XIM_MODE_STS_DEFAULT) {
+ res->mode &= ~XIM_MODE_STS_DEFAULT;
+ } else if (!(res->mode & XIM_MODE_STS_SET)) {
+ return XIM_CHECK_ERROR;
+ }
+
+ } else {
+ if(!res->mode) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_IC_CREATE) {
+ res->mode &= ~XIM_MODE_IC_CREATE;
+ } else if(res->mode & XIM_MODE_IC_ONCE) {
+ res->mode &= ~XIM_MODE_IC_ONCE;
+ } else if(res->mode & XIM_MODE_IC_DEFAULT) {
+ res->mode &= ~XIM_MODE_IC_DEFAULT;
+ } else if (!(res->mode & XIM_MODE_IC_SET)) {
+ return XIM_CHECK_ERROR;
+ }
+ }
+ return XIM_CHECK_VALID;
+}
+
+Private int
+_XimCheckSetICValuesMode(
+ XIMResourceList res,
+ unsigned long mode)
+{
+ if(mode & XIM_PREEDIT_ATTR) {
+ if(!(res->mode & XIM_MODE_PRE_MASK)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_PRE_ONCE) {
+ res->mode &= ~XIM_MODE_PRE_ONCE;
+ } else if(!(res->mode & XIM_MODE_PRE_SET)) {
+ return XIM_CHECK_ERROR;
+ }
+
+ } else if(mode & XIM_STATUS_ATTR) {
+ if(!(res->mode & XIM_MODE_STS_MASK)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_STS_ONCE) {
+ res->mode &= ~XIM_MODE_STS_ONCE;
+ } else if(!(res->mode & XIM_MODE_STS_SET)) {
+ return XIM_CHECK_ERROR;
+ }
+
+ } else {
+ if(!res->mode) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_IC_ONCE) {
+ res->mode &= ~XIM_MODE_IC_ONCE;
+ } else if(!(res->mode & XIM_MODE_IC_SET)) {
+ return XIM_CHECK_ERROR;
+ }
+ }
+ return XIM_CHECK_VALID;
+}
+
+Private int
+_XimCheckGetICValuesMode(
+ XIMResourceList res,
+ unsigned long mode)
+{
+ if(mode & XIM_PREEDIT_ATTR) {
+ if(!(res->mode & XIM_MODE_PRE_MASK)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(!(res->mode & XIM_MODE_PRE_GET)) {
+ return XIM_CHECK_ERROR;
+ }
+
+ } else if(mode & XIM_STATUS_ATTR) {
+ if(!(res->mode & XIM_MODE_STS_MASK)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(!(res->mode & XIM_MODE_STS_GET)) {
+ return XIM_CHECK_ERROR;
+ }
+
+ } else {
+ if(!res->mode) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(!(res->mode & XIM_MODE_IC_GET)) {
+ return XIM_CHECK_ERROR;
+ }
+ }
+ return XIM_CHECK_VALID;
+}
+
+Public int
+ _XimCheckICMode(
+ XIMResourceList res,
+ unsigned long mode)
+{
+ if(mode &XIM_SETICDEFAULTS) {
+ return _XimCheckSetICDefaultsMode(res, mode);
+ } else if (mode & XIM_CREATEIC) {
+ return _XimCheckCreateICMode(res, mode);
+ } else if (mode & XIM_SETICVALUES) {
+ return _XimCheckSetICValuesMode(res, mode);
+ } else if (mode & XIM_GETICVALUES) {
+ return _XimCheckGetICValuesMode(res, mode);
+ } else {
+ return XIM_CHECK_ERROR;
+ }
+}
+
+Public Bool
+_XimSetLocalIMDefaults(
+ Xim im,
+ XPointer top,
+ XIMResourceList res_list,
+ unsigned int list_num)
+{
+ XimValueOffsetInfo info;
+ unsigned int num;
+ register int i;
+ XIMResourceList res;
+ int check;
+
+ info = im_attr_info;
+ num = XIMNumber(im_attr_info);
+
+ for(i = 0; i < num; i++) {
+ if((res = _XimGetResourceListRecByQuark( res_list, list_num,
+ info[i].quark)) == (XIMResourceList)NULL) {
+ return False;
+ }
+
+ check = _XimCheckIMMode(res, XIM_SETIMDEFAULTS);
+ if(check == XIM_CHECK_INVALID) {
+ continue;
+ } else if (check == XIM_CHECK_ERROR) {
+ return False;
+ }
+
+ if(!info[i].defaults) {
+ continue;
+ }
+ if(!(info[i].defaults(&info[i], top, (XPointer)NULL, 0))) {
+ return False;
+ }
+ }
+ return True;
+}
+
+Public Bool
+_XimSetICDefaults(
+ Xic ic,
+ XPointer top,
+ unsigned long mode,
+ XIMResourceList res_list,
+ unsigned int list_num)
+{
+ unsigned int num;
+ XimValueOffsetInfo info;
+ register int i;
+ XIMResourceList res;
+ int check;
+ XrmQuark pre_quark;
+ XrmQuark sts_quark;
+
+ pre_quark = XrmStringToQuark(XNPreeditAttributes);
+ sts_quark = XrmStringToQuark(XNStatusAttributes);
+
+ if(mode & XIM_PREEDIT_ATTR) {
+ info = ic_pre_attr_info;
+ num = XIMNumber(ic_pre_attr_info);
+ } else if(mode & XIM_STATUS_ATTR) {
+ info = ic_sts_attr_info;
+ num = XIMNumber(ic_sts_attr_info);
+ } else {
+ info = ic_attr_info;
+ num = XIMNumber(ic_attr_info);
+ }
+
+ for(i = 0; i < num; i++) {
+ if(info[i].quark == pre_quark) {
+ if(!_XimSetICDefaults(ic, (XPointer)((char *)top + info[i].offset),
+ (mode | XIM_PREEDIT_ATTR), res_list, list_num)) {
+ return False;
+ }
+ } else if (info[i].quark == sts_quark) {
+ if(!_XimSetICDefaults(ic, (XPointer)((char *)top + info[i].offset),
+ (mode | XIM_STATUS_ATTR), res_list, list_num)) {
+ return False;
+ }
+ } else {
+ if(!(res = _XimGetResourceListRecByQuark(res_list, list_num,
+ info[i].quark))) {
+ return False;
+ }
+
+ check = _XimCheckICMode(res, mode);
+ if (check == XIM_CHECK_INVALID) {
+ continue;
+ } else if (check == XIM_CHECK_ERROR) {
+ return False;
+ }
+
+ if (!info[i].defaults) {
+ continue;
+ }
+ if (!(info[i].defaults(&info[i], top, (XPointer)ic, mode))) {
+ return False;
+ }
+ }
+ }
+ return True;
+}
+
+Private Bool
+_XimEncodeAttr(
+ XimValueOffsetInfo info,
+ unsigned int num,
+ XIMResourceList res,
+ XPointer top,
+ XPointer val)
+{
+ register int i;
+
+ for(i = 0; i < num; i++ ) {
+ if(info[i].quark == res->xrm_name) {
+ if(!info[i].encode) {
+ return False;
+ }
+ return (*info[i].encode)(&info[i], top, val);
+ }
+ }
+ return False;
+}
+
+Public Bool
+_XimEncodeLocalIMAttr(
+ XIMResourceList res,
+ XPointer top,
+ XPointer val)
+{
+ return _XimEncodeAttr(im_attr_info, XIMNumber(im_attr_info),
+ res, top, val);
+}
+
+Public Bool
+_XimEncodeLocalICAttr(
+ Xic ic,
+ XIMResourceList res,
+ XPointer top,
+ XIMArg *arg,
+ unsigned long mode)
+{
+ unsigned int num;
+ XimValueOffsetInfo info;
+
+ if(mode & XIM_PREEDIT_ATTR) {
+ info = ic_pre_attr_info;
+ num = XIMNumber(ic_pre_attr_info);
+ } else if(mode & XIM_STATUS_ATTR) {
+ info = ic_sts_attr_info;
+ num = XIMNumber(ic_sts_attr_info);
+ } else {
+ info = ic_attr_info;
+ num = XIMNumber(ic_attr_info);
+ }
+
+ return _XimEncodeAttr(info, num, res, top, arg->value);
+}
+
+Private Bool
+_XimEncodeLocalTopValue(
+ Xic ic,
+ XIMResourceList res,
+ XPointer val,
+ Bool flag)
+{
+ XIMArg *p = (XIMArg *)val;
+
+ if (res->xrm_name == XrmStringToQuark(XNClientWindow)) {
+ ic->core.client_window = (Window)p->value;
+ if (ic->core.focus_window == (Window)0)
+ ic->core.focus_window = ic->core.client_window;
+ if (flag) {
+ _XRegisterFilterByType(ic->core.im->core.display,
+ ic->core.focus_window,
+ KeyPress, KeyRelease, _XimLocalFilter, (XPointer)ic);
+ }
+ } else if (res->xrm_name == XrmStringToQuark(XNFocusWindow)) {
+ if (ic->core.client_window) {
+ if (flag) {
+ _XUnregisterFilter(ic->core.im->core.display,
+ ic->core.focus_window, _XimLocalFilter, (XPointer)ic);
+ }
+ ic->core.focus_window = (Window)p->value;
+ if (flag) {
+ _XRegisterFilterByType(ic->core.im->core.display,
+ ic->core.focus_window, KeyPress, KeyRelease,
+ _XimLocalFilter, (XPointer)ic);
+ }
+ } else
+ ic->core.focus_window = (Window)p->value;
+ }
+ return True;
+}
+
+Private Bool
+_XimEncodeLocalPreeditValue(
+ Xic ic,
+ XIMResourceList res,
+ XPointer val)
+{
+ XIMArg *p = (XIMArg *)val;
+
+ if (res->xrm_name == XrmStringToQuark(XNStdColormap)) {
+ XStandardColormap *colormap_ret;
+ int count;
+
+ if (!(XGetRGBColormaps(ic->core.im->core.display,
+ ic->core.focus_window, &colormap_ret,
+ &count, (Atom)p->value)))
+ return False;
+ }
+ return True;
+}
+
+Private Bool
+_XimEncodeLocalStatusValue(
+ Xic ic,
+ XIMResourceList res,
+ XPointer val)
+{
+ XIMArg *p = (XIMArg *)val;
+
+ if (res->xrm_name == XrmStringToQuark(XNStdColormap)) {
+ XStandardColormap *colormap_ret;
+ int count;
+
+ if (!(XGetRGBColormaps(ic->core.im->core.display,
+ ic->core.focus_window, &colormap_ret,
+ &count, (Atom)p->value)))
+ return False;
+ }
+ return True;
+}
+
+Public char *
+_XimSetICValueData(
+ Xic ic,
+ XPointer top,
+ XIMResourceList res_list,
+ unsigned int list_num,
+ XIMArg *values,
+ unsigned long mode,
+ Bool flag)
+{
+ register XIMArg *p;
+ XIMResourceList res;
+ char *name;
+ int check;
+ XrmQuark pre_quark;
+ XrmQuark sts_quark;
+
+ pre_quark = XrmStringToQuark(XNPreeditAttributes);
+ sts_quark = XrmStringToQuark(XNStatusAttributes);
+
+ for(p = values; p->name != NULL; p++) {
+ if((res = _XimGetResourceListRec(res_list, list_num,
+ p->name)) == (XIMResourceList)NULL) {
+ return p->name;
+ }
+ if(res->xrm_name == pre_quark) {
+ if(((name = _XimSetICValueData(ic,
+ (XPointer)(&((XimDefICValues *)top)->preedit_attr),
+ res_list, list_num, (XIMArg *)p->value,
+ (mode | XIM_PREEDIT_ATTR), flag)))) {
+ return name;
+ }
+ } else if(res->xrm_name == sts_quark) {
+ if(((name = _XimSetICValueData(ic,
+ (XPointer)(&((XimDefICValues *)top)->status_attr),
+ res_list, list_num, (XIMArg *)p->value,
+ (mode | XIM_STATUS_ATTR), flag)))) {
+ return name;
+ }
+ } else {
+ check = _XimCheckICMode(res, mode);
+ if(check == XIM_CHECK_INVALID) {
+ continue;
+ } else if(check == XIM_CHECK_ERROR) {
+ return p->name;
+ }
+
+ if(mode & XIM_PREEDIT_ATTR) {
+ if (!_XimEncodeLocalPreeditValue(ic, res, (XPointer)p))
+ return False;
+ } else if(mode & XIM_STATUS_ATTR) {
+ if (!_XimEncodeLocalStatusValue(ic, res, (XPointer)p))
+ return False;
+ } else {
+ if (!_XimEncodeLocalTopValue(ic, res, (XPointer)p, flag))
+ return False;
+ }
+ if(_XimEncodeLocalICAttr(ic, res, top, p, mode) == False) {
+ return p->name;
+ }
+ }
+ }
+ return NULL;
+}
+
+Private Bool
+_XimCheckInputStyle(
+ XIMStyles *styles,
+ XIMStyle style)
+{
+ int num = styles->count_styles;
+ register int i;
+
+ for(i = 0; i < num; i++) {
+ if(styles->supported_styles[i] == style) {
+ return True;
+ }
+ }
+ return False;
+}
+
+Public Bool
+_XimCheckLocalInputStyle(
+ Xic ic,
+ XPointer top,
+ XIMArg *values,
+ XIMStyles *styles,
+ XIMResourceList res_list,
+ unsigned int list_num)
+{
+ XrmQuark quark = XrmStringToQuark(XNInputStyle);
+ register XIMArg *p;
+ XIMResourceList res;
+
+ for(p = values; p && p->name != NULL; p++) {
+ if(quark == XrmStringToQuark(p->name)) {
+ if(!(res = _XimGetResourceListRec(res_list, list_num, p->name))) {
+ return False;
+ }
+ if(!_XimEncodeLocalICAttr(ic, res, top, p, 0)) {
+ return False;
+ }
+ if (_XimCheckInputStyle(styles,
+ ((XimDefICValues *)top)->input_style)) {
+ return True;
+ }
+ return False;
+ }
+ }
+ return False;
+}
+
+Private Bool
+_XimDecodeAttr(
+ XimValueOffsetInfo info,
+ unsigned int num,
+ XIMResourceList res,
+ XPointer top,
+ XPointer val)
+{
+ register int i;
+
+ for(i = 0; i < num; i++ ) {
+ if(info[i].quark == res->xrm_name) {
+ if(!info[i].decode) {
+ return False;
+ }
+ return (*info[i].decode)(&info[i], top, val);
+ }
+ }
+ return False;
+}
+
+Public Bool
+_XimDecodeLocalIMAttr(
+ XIMResourceList res,
+ XPointer top,
+ XPointer val)
+{
+ return _XimDecodeAttr(im_attr_info, XIMNumber(im_attr_info),
+ res, top, val);
+}
+
+Public Bool
+_XimDecodeLocalICAttr(
+ XIMResourceList res,
+ XPointer top,
+ XPointer val,
+ unsigned long mode)
+{
+ unsigned int num;
+ XimValueOffsetInfo info;
+
+ if(mode & XIM_PREEDIT_ATTR) {
+ info = ic_pre_attr_info;
+ num = XIMNumber(ic_pre_attr_info);
+ } else if(mode & XIM_STATUS_ATTR) {
+ info = ic_sts_attr_info;
+ num = XIMNumber(ic_sts_attr_info);
+ } else {
+ info = ic_attr_info;
+ num = XIMNumber(ic_attr_info);
+ }
+
+ return _XimDecodeAttr(info, num, res, top, val);
+}
+
+Public char *
+_XimGetICValueData(Xic ic, XPointer top, XIMResourceList res_list,
+ unsigned int list_num, XIMArg *values, unsigned long mode)
+{
+ register XIMArg *p;
+ XIMResourceList res;
+ char *name;
+ int check;
+ XrmQuark pre_quark;
+ XrmQuark sts_quark;
+
+ pre_quark = XrmStringToQuark(XNPreeditAttributes);
+ sts_quark = XrmStringToQuark(XNStatusAttributes);
+
+ for(p = values; p->name != NULL; p++) {
+ if((res = _XimGetResourceListRec(res_list, list_num,
+ p->name)) == (XIMResourceList)NULL) {
+ return p->name;
+ }
+ if(res->xrm_name == pre_quark) {
+ if((name = _XimGetICValueData(ic,
+ (XPointer)(&((XimDefICValues *)top)->preedit_attr),
+ res_list, list_num, (XIMArg *)p->value,
+ (mode | XIM_PREEDIT_ATTR)))) {
+ return name;
+ }
+ } else if(res->xrm_name == sts_quark) {
+ if((name = _XimGetICValueData(ic,
+ (XPointer)(&((XimDefICValues *)top)->status_attr),
+ res_list, list_num, (XIMArg *)p->value,
+ (mode | XIM_STATUS_ATTR)))) {
+ return name;
+ }
+ } else {
+ check = _XimCheckICMode(res, mode);
+ if(check == XIM_CHECK_INVALID) {
+ continue;
+ } else if(check == XIM_CHECK_ERROR) {
+ return p->name;
+ }
+
+ if(_XimDecodeLocalICAttr(res, top, p->value, mode) == False) {
+ return p->name;
+ }
+ }
+ }
+ return NULL;
+}
+
+Public void
+_XimGetCurrentIMValues(Xim im, XimDefIMValues *im_values)
+{
+ bzero((char *)im_values, sizeof(XimDefIMValues));
+
+ im_values->styles = im->core.styles;
+ im_values->im_values_list = im->core.im_values_list;
+ im_values->ic_values_list = im->core.ic_values_list;
+ im_values->destroy_callback = im->core.destroy_callback;
+ im_values->res_name = im->core.res_name;
+ im_values->res_class = im->core.res_class;
+ im_values->visible_position = im->core.visible_position;
+}
+
+Public void
+_XimSetCurrentIMValues(Xim im, XimDefIMValues *im_values)
+{
+ im->core.styles = im_values->styles;
+ im->core.im_values_list = im_values->im_values_list;
+ im->core.ic_values_list = im_values->ic_values_list;
+ im->core.destroy_callback = im_values->destroy_callback;
+ im->core.res_name = im_values->res_name;
+ im->core.res_class = im_values->res_class;
+ im->core.visible_position = im_values->visible_position;
+}
+
+Public void
+_XimGetCurrentICValues(Xic ic, XimDefICValues *ic_values)
+{
+ bzero((char *)ic_values, sizeof(XimDefICValues));
+
+ ic_values->input_style = ic->core.input_style;
+ ic_values->client_window = ic->core.client_window;
+ ic_values->focus_window = ic->core.focus_window;
+ ic_values->filter_events = ic->core.filter_events;
+ ic_values->geometry_callback = ic->core.geometry_callback;
+ ic_values->res_name = ic->core.res_name;
+ ic_values->res_class = ic->core.res_class;
+ ic_values->destroy_callback = ic->core.destroy_callback;
+ ic_values->string_conversion_callback
+ = ic->core.string_conversion_callback;
+ ic_values->string_conversion = ic->core.string_conversion;
+ ic_values->reset_state = ic->core.reset_state;
+ ic_values->hotkey = ic->core.hotkey;
+ ic_values->hotkey_state = ic->core.hotkey_state;
+ ic_values->preedit_attr = ic->core.preedit_attr;
+ ic_values->status_attr = ic->core.status_attr;
+}
+
+Public void
+_XimSetCurrentICValues(
+ Xic ic,
+ XimDefICValues *ic_values)
+{
+ ic->core.input_style = ic_values->input_style;
+ ic->core.client_window = ic_values->client_window;
+ if (ic_values->focus_window)
+ ic->core.focus_window = ic_values->focus_window;
+ ic->core.filter_events = ic_values->filter_events;
+ ic->core.geometry_callback = ic_values->geometry_callback;
+ ic->core.res_name = ic_values->res_name;
+ ic->core.res_class = ic_values->res_class;
+ ic->core.destroy_callback = ic_values->destroy_callback;
+ ic->core.string_conversion_callback
+ = ic_values->string_conversion_callback;
+ ic->core.string_conversion = ic_values->string_conversion;
+ ic->core.reset_state = ic_values->reset_state;
+ ic->core.hotkey = ic_values->hotkey;
+ ic->core.hotkey_state = ic_values->hotkey_state;
+ ic->core.preedit_attr = ic_values->preedit_attr;
+ ic->core.status_attr = ic_values->status_attr;
+}
+
+Private void
+_XimInitialIMOffsetInfo(void)
+{
+ unsigned int n = XIMNumber(im_attr_info);
+ register int i;
+
+ for(i = 0; i < n; i++) {
+ im_attr_info[i].quark = XrmStringToQuark(GET_NAME(im_attr_info[i]));
+ }
+}
+
+Private void
+_XimInitialICOffsetInfo(void)
+{
+ unsigned int n;
+ register int i;
+
+ n = XIMNumber(ic_attr_info);
+ for(i = 0; i < n; i++) {
+ ic_attr_info[i].quark = XrmStringToQuark(GET_NAME(ic_attr_info[i]));
+ }
+
+ n = XIMNumber(ic_pre_attr_info);
+ for(i = 0; i < n; i++) {
+ ic_pre_attr_info[i].quark = XrmStringToQuark(GET_NAME(ic_pre_attr_info[i]));
+ }
+
+ n = XIMNumber(ic_sts_attr_info);
+ for(i = 0; i < n; i++) {
+ ic_sts_attr_info[i].quark = XrmStringToQuark(GET_NAME(ic_sts_attr_info[i]));
+ }
+}
+
+Private void
+_XimInitialIMMode(void)
+{
+ unsigned int n = XIMNumber(im_mode);
+ register int i;
+
+ for(i = 0; i < n; i++) {
+ im_mode_quark[i] = XrmStringToQuark(GET_NAME(im_mode[i]));
+ }
+}
+
+Private void
+_XimInitialICMode(void)
+{
+ unsigned int n = XIMNumber(ic_mode);
+ register int i;
+
+ for(i = 0; i < n; i++) {
+ ic_mode_quark[i] = XrmStringToQuark(GET_NAME(ic_mode[i]));
+ }
+}
+
+Public void
+_XimInitialResourceInfo(void)
+{
+ static Bool init_flag = False;
+
+ if(init_flag == True) {
+ return;
+ }
+ _XimInitialIMOffsetInfo();
+ _XimInitialICOffsetInfo();
+ _XimInitialIMMode();
+ _XimInitialICMode();
+ init_flag = True;
+}
|